blob: 656aa570b2cfa2592e79d66bcb8c85da24d180d0 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
Steve Mucklea55df6e2010-01-07 12:43:24 -08002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
Steve Mucklea55df6e2010-01-07 12:43:24 -080012 */
13
14#include <linux/kernel.h>
15#include <linux/platform_device.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070016#include <linux/gpio.h>
Steve Muckle9161d302010-02-11 11:50:40 -080017#include <linux/irq.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070018#include <linux/io.h>
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +053019#include <linux/msm_ssbi.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070020#include <linux/mfd/pmic8058.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080021
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070022#include <linux/leds.h>
23#include <linux/pmic8058-othc.h>
24#include <linux/mfd/pmic8901.h>
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053025#include <linux/regulator/gpio-regulator.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070026#include <linux/regulator/pmic8901-regulator.h>
27#include <linux/bootmem.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070028#include <linux/msm_adc.h>
29#include <linux/m_adcproc.h>
30#include <linux/mfd/marimba.h>
31#include <linux/msm-charger.h>
32#include <linux/i2c.h>
33#include <linux/i2c/sx150x.h>
34#include <linux/smsc911x.h>
35#include <linux/spi/spi.h>
36#include <linux/input/tdisc_shinetsu.h>
37#include <linux/input/cy8c_ts.h>
38#include <linux/cyttsp.h>
39#include <linux/i2c/isa1200.h>
40#include <linux/dma-mapping.h>
41#include <linux/i2c/bq27520.h>
42
43#ifdef CONFIG_ANDROID_PMEM
44#include <linux/android_pmem.h>
45#endif
46
47#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
48#include <linux/i2c/smb137b.h>
49#endif
Lei Zhou338cab82011-08-19 13:38:17 -040050#ifdef CONFIG_SND_SOC_WM8903
51#include <sound/wm8903.h>
52#endif
Steve Mucklea55df6e2010-01-07 12:43:24 -080053#include <asm/mach-types.h>
54#include <asm/mach/arch.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070055#include <asm/setup.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080056
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070057#include <mach/dma.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080058#include <mach/board.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070059#include <mach/irqs.h>
60#include <mach/msm_spi.h>
61#include <mach/msm_serial_hs.h>
62#include <mach/msm_serial_hs_lite.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080063#include <mach/msm_iomap.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070064#include <mach/msm_memtypes.h>
65#include <asm/mach/mmc.h>
66#include <mach/msm_battery.h>
67#include <mach/msm_hsusb.h>
Rohit Vaswania513aa8d2011-07-18 15:14:28 -070068#include <mach/gpiomux.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070069#ifdef CONFIG_MSM_DSPS
70#include <mach/msm_dsps.h>
71#endif
72#include <mach/msm_xo.h>
73#include <mach/msm_bus_board.h>
74#include <mach/socinfo.h>
75#include <linux/i2c/isl9519.h>
76#ifdef CONFIG_USB_G_ANDROID
77#include <linux/usb/android.h>
78#include <mach/usbdiag.h>
79#endif
80#include <linux/regulator/consumer.h>
81#include <linux/regulator/machine.h>
82#include <mach/sdio_al.h>
83#include <mach/rpm.h>
84#include <mach/rpm-regulator.h>
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070085#include <mach/restart.h>
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053086#include <mach/board-msm8660.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080087
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070088#include "devices.h"
89#include "devices-msm8x60.h"
90#include "cpuidle.h"
91#include "pm.h"
92#include "mpm.h"
93#include "spm.h"
94#include "rpm_log.h"
95#include "timer.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070096#include "gpiomux-8x60.h"
97#include "rpm_stats.h"
98#include "peripheral-loader.h"
99#include <linux/platform_data/qcom_crypto_device.h>
100#include "rpm_resources.h"
Matt Wagantall6d9ebee2011-08-26 12:15:24 -0700101#include "acpuclock.h"
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -0600102#include "pm-boot.h"
Laura Abbott63cfd7e2011-10-10 18:21:01 -0700103
104#include <linux/ion.h>
105#include <mach/ion.h>
106
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700107#define MSM_SHARED_RAM_PHYS 0x40000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700108#define MDM2AP_SYNC 129
109
Terence Hampson1c73fef2011-07-19 17:10:49 -0400110#define GPIO_ETHERNET_RESET_N_DRAGON 30
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700111#define LCDC_SPI_GPIO_CLK 73
112#define LCDC_SPI_GPIO_CS 72
113#define LCDC_SPI_GPIO_MOSI 70
114#define LCDC_AUO_PANEL_NAME "lcdc_auo_wvga"
115#define LCDC_SAMSUNG_OLED_PANEL_NAME "lcdc_samsung_oled"
116#define LCDC_SAMSUNG_WSVGA_PANEL_NAME "lcdc_samsung_wsvga"
117#define LCDC_SAMSUNG_SPI_DEVICE_NAME "lcdc_samsung_ams367pe02"
118#define LCDC_AUO_SPI_DEVICE_NAME "lcdc_auo_nt35582"
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -0400119#define LCDC_NT35582_PANEL_NAME "lcdc_nt35582_wvga"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700120
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -0700121#define PANEL_NAME_MAX_LEN 30
122#define MIPI_CMD_NOVATEK_QHD_PANEL_NAME "mipi_cmd_novatek_qhd"
123#define MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME "mipi_video_novatek_qhd"
124#define MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME "mipi_video_toshiba_wvga"
125#define HDMI_PANEL_NAME "hdmi_msm"
126#define TVOUT_PANEL_NAME "tvout_msm"
127
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700128#define DSPS_PIL_GENERIC_NAME "dsps"
129#define DSPS_PIL_FLUID_NAME "dsps_fluid"
130
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -0800131#ifdef CONFIG_ION_MSM
132static struct platform_device ion_dev;
133#endif
134
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700135enum {
136 GPIO_EXPANDER_IRQ_BASE = PM8901_IRQ_BASE + NR_PMIC8901_IRQS,
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530137 GPIO_EXPANDER_GPIO_BASE = PM8901_MPP_BASE + PM8901_MPPS,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700138 /* CORE expander */
139 GPIO_CORE_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE,
140 GPIO_CLASS_D1_EN = GPIO_CORE_EXPANDER_BASE,
141 GPIO_WLAN_DEEP_SLEEP_N,
142 GPIO_LVDS_SHUTDOWN_N,
143 GPIO_DISP_RESX_N = GPIO_LVDS_SHUTDOWN_N,
144 GPIO_MS_SYS_RESET_N,
145 GPIO_CAP_TS_RESOUT_N,
146 GPIO_CAP_GAUGE_BI_TOUT,
147 GPIO_ETHERNET_PME,
148 GPIO_EXT_GPS_LNA_EN,
149 GPIO_MSM_WAKES_BT,
150 GPIO_ETHERNET_RESET_N,
151 GPIO_HEADSET_DET_N,
152 GPIO_USB_UICC_EN,
153 GPIO_BACKLIGHT_EN,
154 GPIO_EXT_CAMIF_PWR_EN,
155 GPIO_BATT_GAUGE_INT_N,
156 GPIO_BATT_GAUGE_EN,
157 /* DOCKING expander */
158 GPIO_DOCKING_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + 16,
159 GPIO_MIPI_DSI_RST_N = GPIO_DOCKING_EXPANDER_BASE,
160 GPIO_AUX_JTAG_DET_N,
161 GPIO_DONGLE_DET_N,
162 GPIO_SVIDEO_LOAD_DET,
163 GPIO_SVID_AMP_SHUTDOWN1_N,
164 GPIO_SVID_AMP_SHUTDOWN0_N,
165 GPIO_SDC_WP,
166 GPIO_IRDA_PWDN,
167 GPIO_IRDA_RESET_N,
168 GPIO_DONGLE_GPIO0,
169 GPIO_DONGLE_GPIO1,
170 GPIO_DONGLE_GPIO2,
171 GPIO_DONGLE_GPIO3,
172 GPIO_DONGLE_PWR_EN,
173 GPIO_EMMC_RESET_N,
174 GPIO_TP_EXP2_IO15,
175 /* SURF expander */
176 GPIO_SURF_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + (16 * 2),
177 GPIO_SD_CARD_DET_1 = GPIO_SURF_EXPANDER_BASE,
178 GPIO_SD_CARD_DET_2,
179 GPIO_SD_CARD_DET_4,
180 GPIO_SD_CARD_DET_5,
181 GPIO_UIM3_RST,
182 GPIO_SURF_EXPANDER_IO5,
183 GPIO_SURF_EXPANDER_IO6,
184 GPIO_ADC_I2C_EN,
185 GPIO_SURF_EXPANDER_IO8,
186 GPIO_SURF_EXPANDER_IO9,
187 GPIO_SURF_EXPANDER_IO10,
188 GPIO_SURF_EXPANDER_IO11,
189 GPIO_SURF_EXPANDER_IO12,
190 GPIO_SURF_EXPANDER_IO13,
191 GPIO_SURF_EXPANDER_IO14,
192 GPIO_SURF_EXPANDER_IO15,
193 /* LEFT KB IO expander */
194 GPIO_LEFT_KB_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + (16 * 3),
195 GPIO_LEFT_LED_1 = GPIO_LEFT_KB_EXPANDER_BASE,
196 GPIO_LEFT_LED_2,
197 GPIO_LEFT_LED_3,
198 GPIO_LEFT_LED_WLAN,
199 GPIO_JOYSTICK_EN,
200 GPIO_CAP_TS_SLEEP,
201 GPIO_LEFT_KB_IO6,
202 GPIO_LEFT_LED_5,
203 /* RIGHT KB IO expander */
204 GPIO_RIGHT_KB_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + (16 * 3) + 8,
205 GPIO_RIGHT_LED_1 = GPIO_RIGHT_KB_EXPANDER_BASE,
206 GPIO_RIGHT_LED_2,
207 GPIO_RIGHT_LED_3,
208 GPIO_RIGHT_LED_BT,
209 GPIO_WEB_CAMIF_STANDBY,
210 GPIO_COMPASS_RST_N,
211 GPIO_WEB_CAMIF_RESET_N,
212 GPIO_RIGHT_LED_5,
213 GPIO_R_ALTIMETER_RESET_N,
214 /* FLUID S IO expander */
215 GPIO_SOUTH_EXPANDER_BASE,
216 GPIO_MIC2_ANCR_SEL = GPIO_SOUTH_EXPANDER_BASE,
217 GPIO_MIC1_ANCL_SEL,
218 GPIO_HS_MIC4_SEL,
219 GPIO_FML_MIC3_SEL,
220 GPIO_FMR_MIC5_SEL,
221 GPIO_TS_SLEEP,
222 GPIO_HAP_SHIFT_LVL_OE,
223 GPIO_HS_SW_DIR,
224 /* FLUID N IO expander */
225 GPIO_NORTH_EXPANDER_BASE,
226 GPIO_EPM_3_3V_EN = GPIO_NORTH_EXPANDER_BASE,
227 GPIO_EPM_5V_BOOST_EN,
228 GPIO_AUX_CAM_2P7_EN,
229 GPIO_LED_FLASH_EN,
230 GPIO_LED1_GREEN_N,
231 GPIO_LED2_RED_N,
232 GPIO_FRONT_CAM_RESET_N,
233 GPIO_EPM_LVLSFT_EN,
234 GPIO_N_ALTIMETER_RESET_N,
235 /* EPM expander */
236 GPIO_EPM_EXPANDER_BASE,
237 GPIO_PWR_MON_START = GPIO_EPM_EXPANDER_BASE,
238 GPIO_PWR_MON_RESET_N,
239 GPIO_ADC1_PWDN_N,
240 GPIO_ADC2_PWDN_N,
241 GPIO_EPM_EXPANDER_IO4,
242 GPIO_ADC1_MUX_SPI_INT_N_3_3V,
243 GPIO_ADC2_MUX_SPI_INT_N,
244 GPIO_EPM_EXPANDER_IO7,
245 GPIO_PWR_MON_ENABLE,
246 GPIO_EPM_SPI_ADC1_CS_N,
247 GPIO_EPM_SPI_ADC2_CS_N,
248 GPIO_EPM_EXPANDER_IO11,
249 GPIO_EPM_EXPANDER_IO12,
250 GPIO_EPM_EXPANDER_IO13,
251 GPIO_EPM_EXPANDER_IO14,
252 GPIO_EPM_EXPANDER_IO15,
253};
254
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530255struct pm8xxx_mpp_init_info {
256 unsigned mpp;
257 struct pm8xxx_mpp_config_data config;
258};
259
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530260#define PM8058_MPP_INIT(_mpp, _type, _level, _control) \
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530261{ \
262 .mpp = PM8058_MPP_PM_TO_SYS(_mpp), \
263 .config = { \
264 .type = PM8XXX_MPP_TYPE_##_type, \
265 .level = _level, \
266 .control = PM8XXX_MPP_##_control, \
267 } \
268}
269
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530270#define PM8901_MPP_INIT(_mpp, _type, _level, _control) \
271{ \
272 .mpp = PM8901_MPP_PM_TO_SYS(_mpp), \
273 .config = { \
274 .type = PM8XXX_MPP_TYPE_##_type, \
275 .level = _level, \
276 .control = PM8XXX_MPP_##_control, \
277 } \
278}
279
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700280/*
281 * The UI_INTx_N lines are pmic gpio lines which connect i2c
282 * gpio expanders to the pm8058.
283 */
284#define UI_INT1_N 25
285#define UI_INT2_N 34
286#define UI_INT3_N 14
287/*
288FM GPIO is GPIO 18 on PMIC 8058.
289As the index starts from 0 in the PMIC driver, and hence 17
290corresponds to GPIO 18 on PMIC 8058.
291*/
292#define FM_GPIO 17
293
294#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
295static void (*sdc2_status_notify_cb)(int card_present, void *dev_id);
296static void *sdc2_status_notify_cb_devid;
297#endif
298
299#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
300static void (*sdc5_status_notify_cb)(int card_present, void *dev_id);
301static void *sdc5_status_notify_cb_devid;
302#endif
303
304static struct msm_spm_platform_data msm_spm_data_v1[] __initdata = {
305 [0] = {
306 .reg_base_addr = MSM_SAW0_BASE,
307
308#ifdef CONFIG_MSM_AVS_HW
309 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
310#endif
311 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x0F,
312 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
313 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0xFFFFFFFF,
314 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFFFFFFFF,
315
316 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
317 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
318 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
319
320 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
321 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
322 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
323
324 .awake_vlevel = 0x94,
325 .retention_vlevel = 0x81,
326 .collapse_vlevel = 0x20,
327 .retention_mid_vlevel = 0x94,
328 .collapse_mid_vlevel = 0x8C,
329
330 .vctl_timeout_us = 50,
331 },
332
333 [1] = {
334 .reg_base_addr = MSM_SAW1_BASE,
335
336#ifdef CONFIG_MSM_AVS_HW
337 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
338#endif
339 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x0F,
340 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
341 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0xFFFFFFFF,
342 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFFFFFFFF,
343
344 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x13,
345 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
346 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
347
348 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
349 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
350 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
351
352 .awake_vlevel = 0x94,
353 .retention_vlevel = 0x81,
354 .collapse_vlevel = 0x20,
355 .retention_mid_vlevel = 0x94,
356 .collapse_mid_vlevel = 0x8C,
357
358 .vctl_timeout_us = 50,
359 },
360};
361
362static struct msm_spm_platform_data msm_spm_data[] __initdata = {
363 [0] = {
364 .reg_base_addr = MSM_SAW0_BASE,
365
366#ifdef CONFIG_MSM_AVS_HW
367 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
368#endif
369 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x1C,
370 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
371 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x0C0CFFFF,
372 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0x78780FFF,
373
374 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
375 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
376 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
377
378 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
379 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
380 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
381
382 .awake_vlevel = 0xA0,
383 .retention_vlevel = 0x89,
384 .collapse_vlevel = 0x20,
385 .retention_mid_vlevel = 0x89,
386 .collapse_mid_vlevel = 0x89,
387
388 .vctl_timeout_us = 50,
389 },
390
391 [1] = {
392 .reg_base_addr = MSM_SAW1_BASE,
393
394#ifdef CONFIG_MSM_AVS_HW
395 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
396#endif
397 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x1C,
398 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
399 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x0C0CFFFF,
400 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0x78780FFF,
401
402 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x13,
403 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
404 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
405
406 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
407 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
408 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
409
410 .awake_vlevel = 0xA0,
411 .retention_vlevel = 0x89,
412 .collapse_vlevel = 0x20,
413 .retention_mid_vlevel = 0x89,
414 .collapse_mid_vlevel = 0x89,
415
416 .vctl_timeout_us = 50,
417 },
418};
419
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700420/*
421 * Consumer specific regulator names:
422 * regulator name consumer dev_name
423 */
424static struct regulator_consumer_supply vreg_consumers_8901_S0[] = {
425 REGULATOR_SUPPLY("8901_s0", NULL),
426};
427static struct regulator_consumer_supply vreg_consumers_8901_S1[] = {
428 REGULATOR_SUPPLY("8901_s1", NULL),
429};
430
431static struct regulator_init_data saw_s0_init_data = {
432 .constraints = {
433 .name = "8901_s0",
434 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
Tianyi Gou7c81dfa2011-07-27 12:15:24 -0700435 .min_uV = 800000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700436 .max_uV = 1250000,
437 },
438 .consumer_supplies = vreg_consumers_8901_S0,
439 .num_consumer_supplies = ARRAY_SIZE(vreg_consumers_8901_S0),
440};
441
442static struct regulator_init_data saw_s1_init_data = {
443 .constraints = {
444 .name = "8901_s1",
445 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
Tianyi Gou7c81dfa2011-07-27 12:15:24 -0700446 .min_uV = 800000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700447 .max_uV = 1250000,
448 },
449 .consumer_supplies = vreg_consumers_8901_S1,
450 .num_consumer_supplies = ARRAY_SIZE(vreg_consumers_8901_S1),
451};
452
453static struct platform_device msm_device_saw_s0 = {
454 .name = "saw-regulator",
455 .id = 0,
456 .dev = {
457 .platform_data = &saw_s0_init_data,
458 },
459};
460
461static struct platform_device msm_device_saw_s1 = {
462 .name = "saw-regulator",
463 .id = 1,
464 .dev = {
465 .platform_data = &saw_s1_init_data,
466 },
467};
468
469/*
470 * The smc91x configuration varies depending on platform.
471 * The resources data structure is filled in at runtime.
472 */
473static struct resource smc91x_resources[] = {
474 [0] = {
475 .flags = IORESOURCE_MEM,
476 },
477 [1] = {
478 .flags = IORESOURCE_IRQ,
479 },
480};
481
482static struct platform_device smc91x_device = {
483 .name = "smc91x",
484 .id = 0,
485 .num_resources = ARRAY_SIZE(smc91x_resources),
486 .resource = smc91x_resources,
487};
488
489static struct resource smsc911x_resources[] = {
490 [0] = {
491 .flags = IORESOURCE_MEM,
492 .start = 0x1b800000,
493 .end = 0x1b8000ff
494 },
495 [1] = {
496 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
497 },
498};
499
500static struct smsc911x_platform_config smsc911x_config = {
501 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
502 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
503 .flags = SMSC911X_USE_16BIT,
504 .has_reset_gpio = 1,
505 .reset_gpio = GPIO_ETHERNET_RESET_N
506};
507
508static struct platform_device smsc911x_device = {
509 .name = "smsc911x",
510 .id = 0,
511 .num_resources = ARRAY_SIZE(smsc911x_resources),
512 .resource = smsc911x_resources,
513 .dev = {
514 .platform_data = &smsc911x_config
515 }
516};
517
518#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
519 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
520 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
521 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
522
523#define QCE_SIZE 0x10000
524#define QCE_0_BASE 0x18500000
525
526#define QCE_HW_KEY_SUPPORT 0
527#define QCE_SHA_HMAC_SUPPORT 0
528#define QCE_SHARE_CE_RESOURCE 2
529#define QCE_CE_SHARED 1
530
531static struct resource qcrypto_resources[] = {
532 [0] = {
533 .start = QCE_0_BASE,
534 .end = QCE_0_BASE + QCE_SIZE - 1,
535 .flags = IORESOURCE_MEM,
536 },
537 [1] = {
538 .name = "crypto_channels",
539 .start = DMOV_CE_IN_CHAN,
540 .end = DMOV_CE_OUT_CHAN,
541 .flags = IORESOURCE_DMA,
542 },
543 [2] = {
544 .name = "crypto_crci_in",
545 .start = DMOV_CE_IN_CRCI,
546 .end = DMOV_CE_IN_CRCI,
547 .flags = IORESOURCE_DMA,
548 },
549 [3] = {
550 .name = "crypto_crci_out",
551 .start = DMOV_CE_OUT_CRCI,
552 .end = DMOV_CE_OUT_CRCI,
553 .flags = IORESOURCE_DMA,
554 },
555 [4] = {
556 .name = "crypto_crci_hash",
557 .start = DMOV_CE_HASH_CRCI,
558 .end = DMOV_CE_HASH_CRCI,
559 .flags = IORESOURCE_DMA,
560 },
561};
562
563static struct resource qcedev_resources[] = {
564 [0] = {
565 .start = QCE_0_BASE,
566 .end = QCE_0_BASE + QCE_SIZE - 1,
567 .flags = IORESOURCE_MEM,
568 },
569 [1] = {
570 .name = "crypto_channels",
571 .start = DMOV_CE_IN_CHAN,
572 .end = DMOV_CE_OUT_CHAN,
573 .flags = IORESOURCE_DMA,
574 },
575 [2] = {
576 .name = "crypto_crci_in",
577 .start = DMOV_CE_IN_CRCI,
578 .end = DMOV_CE_IN_CRCI,
579 .flags = IORESOURCE_DMA,
580 },
581 [3] = {
582 .name = "crypto_crci_out",
583 .start = DMOV_CE_OUT_CRCI,
584 .end = DMOV_CE_OUT_CRCI,
585 .flags = IORESOURCE_DMA,
586 },
587 [4] = {
588 .name = "crypto_crci_hash",
589 .start = DMOV_CE_HASH_CRCI,
590 .end = DMOV_CE_HASH_CRCI,
591 .flags = IORESOURCE_DMA,
592 },
593};
594
595#endif
596
597#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
598 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
599
600static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
601 .ce_shared = QCE_CE_SHARED,
602 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
603 .hw_key_support = QCE_HW_KEY_SUPPORT,
604 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
605};
606
607static struct platform_device qcrypto_device = {
608 .name = "qcrypto",
609 .id = 0,
610 .num_resources = ARRAY_SIZE(qcrypto_resources),
611 .resource = qcrypto_resources,
612 .dev = {
613 .coherent_dma_mask = DMA_BIT_MASK(32),
614 .platform_data = &qcrypto_ce_hw_suppport,
615 },
616};
617#endif
618
619#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
620 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
621
622static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
623 .ce_shared = QCE_CE_SHARED,
624 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
625 .hw_key_support = QCE_HW_KEY_SUPPORT,
626 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
627};
628
629static struct platform_device qcedev_device = {
630 .name = "qce",
631 .id = 0,
632 .num_resources = ARRAY_SIZE(qcedev_resources),
633 .resource = qcedev_resources,
634 .dev = {
635 .coherent_dma_mask = DMA_BIT_MASK(32),
636 .platform_data = &qcedev_ce_hw_suppport,
637 },
638};
639#endif
640
641#if defined(CONFIG_HAPTIC_ISA1200) || \
642 defined(CONFIG_HAPTIC_ISA1200_MODULE)
643
644static const char *vregs_isa1200_name[] = {
645 "8058_s3",
646 "8901_l4",
647};
648
649static const int vregs_isa1200_val[] = {
650 1800000,/* uV */
651 2600000,
652};
653static struct regulator *vregs_isa1200[ARRAY_SIZE(vregs_isa1200_name)];
654static struct msm_xo_voter *xo_handle_a1;
655
656static int isa1200_power(int vreg_on)
Steve Mucklea55df6e2010-01-07 12:43:24 -0800657{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700658 int i, rc = 0;
659
660 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++) {
661 rc = vreg_on ? regulator_enable(vregs_isa1200[i]) :
662 regulator_disable(vregs_isa1200[i]);
663 if (rc < 0) {
664 pr_err("%s: vreg %s %s failed (%d)\n",
665 __func__, vregs_isa1200_name[i],
666 vreg_on ? "enable" : "disable", rc);
667 goto vreg_fail;
668 }
669 }
670
671 rc = vreg_on ? msm_xo_mode_vote(xo_handle_a1, MSM_XO_MODE_ON) :
672 msm_xo_mode_vote(xo_handle_a1, MSM_XO_MODE_OFF);
673 if (rc < 0) {
674 pr_err("%s: failed to %svote for TCXO A1 buffer%d\n",
675 __func__, vreg_on ? "" : "de-", rc);
676 goto vreg_fail;
677 }
678 return 0;
679
680vreg_fail:
681 while (i--)
682 !vreg_on ? regulator_enable(vregs_isa1200[i]) :
683 regulator_disable(vregs_isa1200[i]);
684 return rc;
Steve Mucklea55df6e2010-01-07 12:43:24 -0800685}
686
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700687static int isa1200_dev_setup(bool enable)
Steve Mucklea55df6e2010-01-07 12:43:24 -0800688{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700689 int i, rc;
Steve Muckle9161d302010-02-11 11:50:40 -0800690
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700691 if (enable == true) {
692 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++) {
693 vregs_isa1200[i] = regulator_get(NULL,
694 vregs_isa1200_name[i]);
695 if (IS_ERR(vregs_isa1200[i])) {
696 pr_err("%s: regulator get of %s failed (%ld)\n",
697 __func__, vregs_isa1200_name[i],
698 PTR_ERR(vregs_isa1200[i]));
699 rc = PTR_ERR(vregs_isa1200[i]);
700 goto vreg_get_fail;
701 }
702 rc = regulator_set_voltage(vregs_isa1200[i],
703 vregs_isa1200_val[i], vregs_isa1200_val[i]);
704 if (rc) {
705 pr_err("%s: regulator_set_voltage(%s) failed\n",
706 __func__, vregs_isa1200_name[i]);
707 goto vreg_get_fail;
708 }
709 }
Steve Muckle9161d302010-02-11 11:50:40 -0800710
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700711 rc = gpio_request(GPIO_HAP_SHIFT_LVL_OE, "haptics_shft_lvl_oe");
712 if (rc) {
713 pr_err("%s: unable to request gpio %d (%d)\n",
714 __func__, GPIO_HAP_SHIFT_LVL_OE, rc);
715 goto vreg_get_fail;
716 }
Steve Muckle9161d302010-02-11 11:50:40 -0800717
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700718 rc = gpio_direction_output(GPIO_HAP_SHIFT_LVL_OE, 1);
719 if (rc) {
720 pr_err("%s: Unable to set direction\n", __func__);;
721 goto free_gpio;
722 }
723
724 xo_handle_a1 = msm_xo_get(MSM_XO_TCXO_A1, "isa1200");
725 if (IS_ERR(xo_handle_a1)) {
726 rc = PTR_ERR(xo_handle_a1);
727 pr_err("%s: failed to get the handle for A1(%d)\n",
728 __func__, rc);
729 goto gpio_set_dir;
730 }
731 } else {
732 gpio_set_value(GPIO_HAP_SHIFT_LVL_OE, 0);
733 gpio_free(GPIO_HAP_SHIFT_LVL_OE);
734
735 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++)
736 regulator_put(vregs_isa1200[i]);
737
738 msm_xo_put(xo_handle_a1);
739 }
740
741 return 0;
742gpio_set_dir:
743 gpio_set_value(GPIO_HAP_SHIFT_LVL_OE, 0);
744free_gpio:
745 gpio_free(GPIO_HAP_SHIFT_LVL_OE);
746vreg_get_fail:
747 while (i)
748 regulator_put(vregs_isa1200[--i]);
749 return rc;
750}
751
752#define PMIC_GPIO_HAP_ENABLE 18 /* PMIC GPIO Number 19 */
Mohan Pallaka4a1160d2011-09-09 15:17:45 +0530753#define PMIC_GPIO_HAP_LDO_ENABLE 5 /* PMIC GPIO Number 6 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700754static struct isa1200_platform_data isa1200_1_pdata = {
755 .name = "vibrator",
756 .power_on = isa1200_power,
757 .dev_setup = isa1200_dev_setup,
758 /*gpio to enable haptic*/
759 .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
Mohan Pallaka4a1160d2011-09-09 15:17:45 +0530760 .hap_len_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700761 .max_timeout = 15000,
762 .mode_ctrl = PWM_GEN_MODE,
763 .pwm_fd = {
764 .pwm_div = 256,
765 },
766 .is_erm = false,
767 .smart_en = true,
768 .ext_clk_en = true,
769 .chip_en = 1,
770};
771
772static struct i2c_board_info msm_isa1200_board_info[] = {
773 {
774 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
775 .platform_data = &isa1200_1_pdata,
776 },
777};
778#endif
779
780#if defined(CONFIG_BATTERY_BQ27520) || \
781 defined(CONFIG_BATTERY_BQ27520_MODULE)
782static struct bq27520_platform_data bq27520_pdata = {
783 .name = "fuel-gauge",
784 .vreg_name = "8058_s3",
785 .vreg_value = 1800000,
786 .soc_int = GPIO_BATT_GAUGE_INT_N,
787 .bi_tout = GPIO_CAP_GAUGE_BI_TOUT,
788 .chip_en = GPIO_BATT_GAUGE_EN,
789 .enable_dlog = 0, /* if enable coulomb counter logger */
790};
791
792static struct i2c_board_info msm_bq27520_board_info[] = {
793 {
794 I2C_BOARD_INFO("bq27520", 0xaa>>1),
795 .platform_data = &bq27520_pdata,
796 },
797};
798#endif
799
800static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR * 2] = {
801 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
802 .idle_supported = 1,
803 .suspend_supported = 1,
804 .idle_enabled = 0,
805 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700806 },
807
808 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
809 .idle_supported = 1,
810 .suspend_supported = 1,
811 .idle_enabled = 0,
812 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700813 },
814
815 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
816 .idle_supported = 1,
817 .suspend_supported = 1,
818 .idle_enabled = 1,
819 .suspend_enabled = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700820 },
821
822 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
823 .idle_supported = 1,
824 .suspend_supported = 1,
825 .idle_enabled = 0,
826 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700827 },
828
829 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
830 .idle_supported = 1,
831 .suspend_supported = 1,
832 .idle_enabled = 0,
833 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700834 },
835
836 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
837 .idle_supported = 1,
838 .suspend_supported = 1,
839 .idle_enabled = 1,
840 .suspend_enabled = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700841 },
842};
843
844static struct msm_cpuidle_state msm_cstates[] __initdata = {
845 {0, 0, "C0", "WFI",
846 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
847
848 {0, 1, "C1", "STANDALONE_POWER_COLLAPSE",
849 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
850
851 {0, 2, "C2", "POWER_COLLAPSE",
852 MSM_PM_SLEEP_MODE_POWER_COLLAPSE},
853
854 {1, 0, "C0", "WFI",
855 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
856
857 {1, 1, "C1", "STANDALONE_POWER_COLLAPSE",
858 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
859};
860
861static struct msm_rpmrs_level msm_rpmrs_levels[] __initdata = {
862 {
863 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
864 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
865 true,
866 1, 8000, 100000, 1,
867 },
868
869 {
870 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
871 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
872 true,
873 1500, 5000, 60100000, 3000,
874 },
875
876 {
877 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
878 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
879 false,
880 1800, 5000, 60350000, 3500,
881 },
882 {
883 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
884 MSM_RPMRS_LIMITS(OFF, ACTIVE, MAX, ACTIVE),
885 false,
886 3800, 4500, 65350000, 5500,
887 },
888
889 {
890 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
891 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, MAX, ACTIVE),
892 false,
893 2800, 2500, 66850000, 4800,
894 },
895
896 {
897 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
898 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
899 false,
900 4800, 2000, 71850000, 6800,
901 },
902
903 {
904 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
905 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
906 false,
907 6800, 500, 75850000, 8800,
908 },
909
910 {
911 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
912 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
913 false,
914 7800, 0, 76350000, 9800,
915 },
916};
917
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600918static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
919 .mode = MSM_PM_BOOT_CONFIG_TZ,
920};
921
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700922#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
923
924#define ISP1763_INT_GPIO 117
925#define ISP1763_RST_GPIO 152
926static struct resource isp1763_resources[] = {
927 [0] = {
928 .flags = IORESOURCE_MEM,
929 .start = 0x1D000000,
930 .end = 0x1D005FFF, /* 24KB */
931 },
932 [1] = {
933 .flags = IORESOURCE_IRQ,
934 },
935};
936static void __init msm8x60_cfg_isp1763(void)
937{
938 isp1763_resources[1].start = gpio_to_irq(ISP1763_INT_GPIO);
939 isp1763_resources[1].end = gpio_to_irq(ISP1763_INT_GPIO);
940}
941
942static int isp1763_setup_gpio(int enable)
943{
944 int status = 0;
945
946 if (enable) {
947 status = gpio_request(ISP1763_INT_GPIO, "isp1763_usb");
948 if (status) {
949 pr_err("%s:Failed to request GPIO %d\n",
950 __func__, ISP1763_INT_GPIO);
951 return status;
952 }
953 status = gpio_direction_input(ISP1763_INT_GPIO);
954 if (status) {
955 pr_err("%s:Failed to configure GPIO %d\n",
956 __func__, ISP1763_INT_GPIO);
957 goto gpio_free_int;
958 }
959 status = gpio_request(ISP1763_RST_GPIO, "isp1763_usb");
960 if (status) {
961 pr_err("%s:Failed to request GPIO %d\n",
962 __func__, ISP1763_RST_GPIO);
963 goto gpio_free_int;
964 }
965 status = gpio_direction_output(ISP1763_RST_GPIO, 1);
966 if (status) {
967 pr_err("%s:Failed to configure GPIO %d\n",
968 __func__, ISP1763_RST_GPIO);
969 goto gpio_free_rst;
970 }
971 pr_debug("\nISP GPIO configuration done\n");
972 return status;
973 }
974
975gpio_free_rst:
976 gpio_free(ISP1763_RST_GPIO);
977gpio_free_int:
978 gpio_free(ISP1763_INT_GPIO);
979
980 return status;
981}
982static struct isp1763_platform_data isp1763_pdata = {
983 .reset_gpio = ISP1763_RST_GPIO,
984 .setup_gpio = isp1763_setup_gpio
985};
986
987static struct platform_device isp1763_device = {
988 .name = "isp1763_usb",
989 .num_resources = ARRAY_SIZE(isp1763_resources),
990 .resource = isp1763_resources,
991 .dev = {
992 .platform_data = &isp1763_pdata
993 }
994};
995#endif
996
997#if defined(CONFIG_USB_GADGET_MSM_72K) || defined(CONFIG_USB_EHCI_MSM_72K)
Anji jonnalaeb9e60d2011-10-05 12:19:46 +0530998static struct msm_otg_platform_data msm_otg_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700999static struct regulator *ldo6_3p3;
1000static struct regulator *ldo7_1p8;
1001static struct regulator *vdd_cx;
1002#define PMICID_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 36)
Anji jonnalaae745e92011-11-14 18:34:31 +05301003#define PMIC_ID_GPIO 36
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001004notify_vbus_state notify_vbus_state_func_ptr;
1005static int usb_phy_susp_dig_vol = 750000;
1006static int pmic_id_notif_supported;
1007
1008#ifdef CONFIG_USB_EHCI_MSM_72K
1009#define USB_PMIC_ID_DET_DELAY msecs_to_jiffies(100)
1010struct delayed_work pmic_id_det;
1011
1012static int __init usb_id_pin_rework_setup(char *support)
1013{
1014 if (strncmp(support, "true", 4) == 0)
1015 pmic_id_notif_supported = 1;
1016
1017 return 1;
1018}
1019__setup("usb_id_pin_rework=", usb_id_pin_rework_setup);
1020
1021static void pmic_id_detect(struct work_struct *w)
1022{
1023 int val = gpio_get_value_cansleep(PM8058_GPIO_PM_TO_SYS(36));
1024 pr_debug("%s(): gpio_read_value = %d\n", __func__, val);
1025
1026 if (notify_vbus_state_func_ptr)
1027 (*notify_vbus_state_func_ptr) (val);
1028}
1029
1030static irqreturn_t pmic_id_on_irq(int irq, void *data)
1031{
1032 /*
1033 * Spurious interrupts are observed on pmic gpio line
1034 * even though there is no state change on USB ID. Schedule the
1035 * work to to allow debounce on gpio
Steve Muckle9161d302010-02-11 11:50:40 -08001036 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001037 schedule_delayed_work(&pmic_id_det, USB_PMIC_ID_DET_DELAY);
Steve Muckle9161d302010-02-11 11:50:40 -08001038
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001039 return IRQ_HANDLED;
1040}
1041
Anji jonnalaae745e92011-11-14 18:34:31 +05301042static int msm_hsusb_phy_id_setup_init(int init)
1043{
1044 unsigned ret;
1045
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301046 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
1047 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
1048 .level = PM8901_MPP_DIG_LEVEL_L5,
1049 };
1050
Anji jonnalaae745e92011-11-14 18:34:31 +05301051 if (init) {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301052 hsusb_phy_mpp.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
1053 ret = pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1),
1054 &hsusb_phy_mpp);
Anji jonnalaae745e92011-11-14 18:34:31 +05301055 if (ret < 0)
1056 pr_err("%s:MPP2 configuration failed\n", __func__);
1057 } else {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301058 hsusb_phy_mpp.control = PM8XXX_MPP_DOUT_CTRL_LOW;
1059 ret = pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1),
1060 &hsusb_phy_mpp);
Anji jonnalaae745e92011-11-14 18:34:31 +05301061 if (ret < 0)
1062 pr_err("%s:MPP2 un config failed\n", __func__);
1063 }
1064 return ret;
1065}
1066
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001067static int msm_hsusb_pmic_id_notif_init(void (*callback)(int online), int init)
1068{
1069 unsigned ret = -ENODEV;
1070
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301071 struct pm_gpio pmic_id_cfg = {
Anji jonnalaae745e92011-11-14 18:34:31 +05301072 .direction = PM_GPIO_DIR_IN,
1073 .pull = PM_GPIO_PULL_UP_1P5,
1074 .function = PM_GPIO_FUNC_NORMAL,
1075 .vin_sel = 2,
1076 .inv_int_pol = 0,
1077 };
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301078 struct pm_gpio pmic_id_uncfg = {
Anji jonnalaae745e92011-11-14 18:34:31 +05301079 .direction = PM_GPIO_DIR_IN,
1080 .pull = PM_GPIO_PULL_NO,
1081 .function = PM_GPIO_FUNC_NORMAL,
1082 .vin_sel = 2,
1083 .inv_int_pol = 0,
1084 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001085 if (!callback)
1086 return -EINVAL;
1087
1088 if (machine_is_msm8x60_fluid())
1089 return -ENOTSUPP;
1090
1091 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 2) {
1092 pr_debug("%s: USB_ID pin is not routed to PMIC"
1093 "on V1 surf/ffa\n", __func__);
1094 return -ENOTSUPP;
1095 }
1096
Manu Gautam62158eb2011-11-24 16:20:46 +05301097 if ((machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa() ||
1098 machine_is_msm8x60_ffa()) && !pmic_id_notif_supported) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001099 pr_debug("%s: USB_ID is not routed to PMIC"
1100 "on V2 ffa\n", __func__);
1101 return -ENOTSUPP;
1102 }
1103
1104 usb_phy_susp_dig_vol = 500000;
1105
1106 if (init) {
1107 notify_vbus_state_func_ptr = callback;
Manu Gautame8420ef2011-11-11 15:37:21 +05301108 INIT_DELAYED_WORK(&pmic_id_det, pmic_id_detect);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301109 ret = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(PMIC_ID_GPIO),
1110 &pmic_id_cfg);
Anji jonnalaae745e92011-11-14 18:34:31 +05301111 if (ret) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301112 pr_err("%s:return val of pm8xxx_gpio_config: %d\n",
Anji jonnalaae745e92011-11-14 18:34:31 +05301113 __func__, ret);
1114 return ret;
1115 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001116 ret = request_threaded_irq(PMICID_INT, NULL, pmic_id_on_irq,
1117 (IRQF_TRIGGER_RISING|IRQF_TRIGGER_FALLING),
1118 "msm_otg_id", NULL);
1119 if (ret) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001120 pr_err("%s:pmic_usb_id interrupt registration failed",
1121 __func__);
1122 return ret;
1123 }
Anji jonnalaeb9e60d2011-10-05 12:19:46 +05301124 msm_otg_pdata.pmic_id_irq = PMICID_INT;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001125 } else {
Anji jonnalaae745e92011-11-14 18:34:31 +05301126 usb_phy_susp_dig_vol = 750000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001127 free_irq(PMICID_INT, 0);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301128 ret = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(PMIC_ID_GPIO),
1129 &pmic_id_uncfg);
Anji jonnalaae745e92011-11-14 18:34:31 +05301130 if (ret) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301131 pr_err("%s: return val of pm8xxx_gpio_config: %d\n",
Anji jonnalaae745e92011-11-14 18:34:31 +05301132 __func__, ret);
1133 return ret;
1134 }
Anji jonnalaeb9e60d2011-10-05 12:19:46 +05301135 msm_otg_pdata.pmic_id_irq = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001136 cancel_delayed_work_sync(&pmic_id_det);
1137 notify_vbus_state_func_ptr = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001138 }
1139 return 0;
1140}
1141#endif
1142
1143#define USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL 1000000
1144#define USB_PHY_MAX_VDD_DIG_VOL 1320000
1145static int msm_hsusb_init_vddcx(int init)
1146{
1147 int ret = 0;
1148
1149 if (init) {
1150 vdd_cx = regulator_get(NULL, "8058_s1");
1151 if (IS_ERR(vdd_cx)) {
1152 return PTR_ERR(vdd_cx);
1153 }
1154
1155 ret = regulator_set_voltage(vdd_cx,
1156 USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL,
1157 USB_PHY_MAX_VDD_DIG_VOL);
1158 if (ret) {
1159 pr_err("%s: unable to set the voltage for regulator"
1160 "vdd_cx\n", __func__);
1161 regulator_put(vdd_cx);
1162 return ret;
1163 }
1164
1165 ret = regulator_enable(vdd_cx);
1166 if (ret) {
1167 pr_err("%s: unable to enable regulator"
1168 "vdd_cx\n", __func__);
1169 regulator_put(vdd_cx);
1170 }
1171 } else {
1172 ret = regulator_disable(vdd_cx);
1173 if (ret) {
1174 pr_err("%s: Unable to disable the regulator:"
1175 "vdd_cx\n", __func__);
1176 return ret;
1177 }
1178
1179 regulator_put(vdd_cx);
1180 }
1181
1182 return ret;
1183}
1184
1185static int msm_hsusb_config_vddcx(int high)
1186{
1187 int max_vol = USB_PHY_MAX_VDD_DIG_VOL;
1188 int min_vol;
1189 int ret;
1190
1191 if (high)
1192 min_vol = USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL;
1193 else
1194 min_vol = usb_phy_susp_dig_vol;
1195
1196 ret = regulator_set_voltage(vdd_cx, min_vol, max_vol);
1197 if (ret) {
1198 pr_err("%s: unable to set the voltage for regulator"
1199 "vdd_cx\n", __func__);
1200 return ret;
1201 }
1202
1203 pr_debug("%s: min_vol:%d max_vol:%d\n", __func__, min_vol, max_vol);
1204
1205 return ret;
1206}
1207
1208#define USB_PHY_3P3_VOL_MIN 3050000 /* uV */
1209#define USB_PHY_3P3_VOL_MAX 3050000 /* uV */
1210#define USB_PHY_3P3_HPM_LOAD 50000 /* uA */
1211#define USB_PHY_3P3_LPM_LOAD 4000 /* uA */
1212
1213#define USB_PHY_1P8_VOL_MIN 1800000 /* uV */
1214#define USB_PHY_1P8_VOL_MAX 1800000 /* uV */
1215#define USB_PHY_1P8_HPM_LOAD 50000 /* uA */
1216#define USB_PHY_1P8_LPM_LOAD 4000 /* uA */
1217static int msm_hsusb_ldo_init(int init)
1218{
1219 int rc = 0;
1220
1221 if (init) {
1222 ldo6_3p3 = regulator_get(NULL, "8058_l6");
1223 if (IS_ERR(ldo6_3p3))
1224 return PTR_ERR(ldo6_3p3);
1225
1226 ldo7_1p8 = regulator_get(NULL, "8058_l7");
1227 if (IS_ERR(ldo7_1p8)) {
1228 rc = PTR_ERR(ldo7_1p8);
1229 goto put_3p3;
1230 }
1231
1232 rc = regulator_set_voltage(ldo6_3p3, USB_PHY_3P3_VOL_MIN,
1233 USB_PHY_3P3_VOL_MAX);
1234 if (rc) {
1235 pr_err("%s: Unable to set voltage level for"
1236 "ldo6_3p3 regulator\n", __func__);
1237 goto put_1p8;
1238 }
1239 rc = regulator_enable(ldo6_3p3);
1240 if (rc) {
1241 pr_err("%s: Unable to enable the regulator:"
1242 "ldo6_3p3\n", __func__);
1243 goto put_1p8;
1244 }
1245 rc = regulator_set_voltage(ldo7_1p8, USB_PHY_1P8_VOL_MIN,
1246 USB_PHY_1P8_VOL_MAX);
1247 if (rc) {
1248 pr_err("%s: Unable to set voltage level for"
1249 "ldo7_1p8 regulator\n", __func__);
1250 goto disable_3p3;
1251 }
1252 rc = regulator_enable(ldo7_1p8);
1253 if (rc) {
1254 pr_err("%s: Unable to enable the regulator:"
1255 "ldo7_1p8\n", __func__);
1256 goto disable_3p3;
1257 }
1258
1259 return 0;
1260 }
1261
1262 regulator_disable(ldo7_1p8);
1263disable_3p3:
1264 regulator_disable(ldo6_3p3);
1265put_1p8:
1266 regulator_put(ldo7_1p8);
1267put_3p3:
1268 regulator_put(ldo6_3p3);
1269 return rc;
1270}
1271
1272static int msm_hsusb_ldo_enable(int on)
1273{
1274 int ret = 0;
1275
1276 if (!ldo7_1p8 || IS_ERR(ldo7_1p8)) {
1277 pr_err("%s: ldo7_1p8 is not initialized\n", __func__);
1278 return -ENODEV;
1279 }
1280
1281 if (!ldo6_3p3 || IS_ERR(ldo6_3p3)) {
1282 pr_err("%s: ldo6_3p3 is not initialized\n", __func__);
1283 return -ENODEV;
1284 }
1285
1286 if (on) {
1287 ret = regulator_set_optimum_mode(ldo7_1p8,
1288 USB_PHY_1P8_HPM_LOAD);
1289 if (ret < 0) {
1290 pr_err("%s: Unable to set HPM of the regulator:"
1291 "ldo7_1p8\n", __func__);
1292 return ret;
1293 }
1294 ret = regulator_set_optimum_mode(ldo6_3p3,
1295 USB_PHY_3P3_HPM_LOAD);
1296 if (ret < 0) {
1297 pr_err("%s: Unable to set HPM of the regulator:"
1298 "ldo6_3p3\n", __func__);
1299 regulator_set_optimum_mode(ldo7_1p8,
1300 USB_PHY_1P8_LPM_LOAD);
1301 return ret;
1302 }
1303 } else {
1304 ret = regulator_set_optimum_mode(ldo7_1p8,
1305 USB_PHY_1P8_LPM_LOAD);
1306 if (ret < 0)
1307 pr_err("%s: Unable to set LPM of the regulator:"
1308 "ldo7_1p8\n", __func__);
1309 ret = regulator_set_optimum_mode(ldo6_3p3,
1310 USB_PHY_3P3_LPM_LOAD);
1311 if (ret < 0)
1312 pr_err("%s: Unable to set LPM of the regulator:"
1313 "ldo6_3p3\n", __func__);
1314 }
1315
1316 pr_debug("reg (%s)\n", on ? "HPM" : "LPM");
1317 return ret < 0 ? ret : 0;
1318 }
1319#endif
1320#ifdef CONFIG_USB_EHCI_MSM_72K
1321#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
1322static void msm_hsusb_smb137b_vbus_power(unsigned phy_info, int on)
1323{
1324 static int vbus_is_on;
1325
1326 /* If VBUS is already on (or off), do nothing. */
1327 if (on == vbus_is_on)
1328 return;
1329 smb137b_otg_power(on);
1330 vbus_is_on = on;
1331}
1332#endif
1333static void msm_hsusb_vbus_power(unsigned phy_info, int on)
1334{
1335 static struct regulator *votg_5v_switch;
1336 static struct regulator *ext_5v_reg;
1337 static int vbus_is_on;
1338
1339 /* If VBUS is already on (or off), do nothing. */
1340 if (on == vbus_is_on)
1341 return;
1342
1343 if (!votg_5v_switch) {
1344 votg_5v_switch = regulator_get(NULL, "8901_usb_otg");
1345 if (IS_ERR(votg_5v_switch)) {
1346 pr_err("%s: unable to get votg_5v_switch\n", __func__);
1347 return;
1348 }
1349 }
1350 if (!ext_5v_reg) {
1351 ext_5v_reg = regulator_get(NULL, "8901_mpp0");
1352 if (IS_ERR(ext_5v_reg)) {
1353 pr_err("%s: unable to get ext_5v_reg\n", __func__);
1354 return;
1355 }
1356 }
1357 if (on) {
1358 if (regulator_enable(ext_5v_reg)) {
1359 pr_err("%s: Unable to enable the regulator:"
1360 " ext_5v_reg\n", __func__);
1361 return;
1362 }
1363 if (regulator_enable(votg_5v_switch)) {
1364 pr_err("%s: Unable to enable the regulator:"
1365 " votg_5v_switch\n", __func__);
1366 return;
1367 }
1368 } else {
1369 if (regulator_disable(votg_5v_switch))
1370 pr_err("%s: Unable to enable the regulator:"
1371 " votg_5v_switch\n", __func__);
1372 if (regulator_disable(ext_5v_reg))
1373 pr_err("%s: Unable to enable the regulator:"
1374 " ext_5v_reg\n", __func__);
1375 }
1376
1377 vbus_is_on = on;
1378}
1379
1380static struct msm_usb_host_platform_data msm_usb_host_pdata = {
1381 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
1382 .power_budget = 390,
1383};
1384#endif
1385
1386#ifdef CONFIG_BATTERY_MSM8X60
1387static int msm_hsusb_pmic_vbus_notif_init(void (*callback)(int online),
1388 int init)
1389{
1390 int ret = -ENOTSUPP;
1391
1392#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
1393 if (machine_is_msm8x60_fluid()) {
1394 if (init)
1395 msm_charger_register_vbus_sn(callback);
1396 else
1397 msm_charger_unregister_vbus_sn(callback);
1398 return 0;
1399 }
1400#endif
1401 /* ID and VBUS lines are connected to pmic on 8660.V2.SURF,
1402 * hence, irrespective of either peripheral only mode or
1403 * OTG (host and peripheral) modes, can depend on pmic for
1404 * vbus notifications
Steve Muckle9161d302010-02-11 11:50:40 -08001405 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001406 if ((SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2)
1407 && (machine_is_msm8x60_surf() ||
1408 pmic_id_notif_supported)) {
1409 if (init)
1410 ret = msm_charger_register_vbus_sn(callback);
1411 else {
1412 msm_charger_unregister_vbus_sn(callback);
1413 ret = 0;
1414 }
1415 } else {
1416#if !defined(CONFIG_USB_EHCI_MSM_72K)
1417 if (init)
1418 ret = msm_charger_register_vbus_sn(callback);
1419 else {
1420 msm_charger_unregister_vbus_sn(callback);
1421 ret = 0;
1422 }
1423#endif
1424 }
1425 return ret;
1426}
1427#endif
1428
1429#if defined(CONFIG_USB_GADGET_MSM_72K) || defined(CONFIG_USB_EHCI_MSM_72K)
1430static struct msm_otg_platform_data msm_otg_pdata = {
1431 /* if usb link is in sps there is no need for
1432 * usb pclk as dayatona fabric clock will be
1433 * used instead
1434 */
1435 .pclk_src_name = "dfab_usb_hs_clk",
1436 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
1437 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
1438 .se1_gating = SE1_GATING_DISABLE,
Chandra Devireddyb3fc78c2011-08-30 17:25:55 +05301439 .bam_disable = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001440#ifdef CONFIG_USB_EHCI_MSM_72K
1441 .pmic_id_notif_init = msm_hsusb_pmic_id_notif_init,
Anji jonnalaae745e92011-11-14 18:34:31 +05301442 .phy_id_setup_init = msm_hsusb_phy_id_setup_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001443#endif
1444#ifdef CONFIG_USB_EHCI_MSM_72K
1445 .vbus_power = msm_hsusb_vbus_power,
1446#endif
1447#ifdef CONFIG_BATTERY_MSM8X60
1448 .pmic_vbus_notif_init = msm_hsusb_pmic_vbus_notif_init,
1449#endif
1450 .ldo_init = msm_hsusb_ldo_init,
1451 .ldo_enable = msm_hsusb_ldo_enable,
1452 .config_vddcx = msm_hsusb_config_vddcx,
1453 .init_vddcx = msm_hsusb_init_vddcx,
1454#ifdef CONFIG_BATTERY_MSM8X60
1455 .chg_vbus_draw = msm_charger_vbus_draw,
1456#endif
1457};
1458#endif
1459
1460#ifdef CONFIG_USB_GADGET_MSM_72K
1461static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
1462 .is_phy_status_timer_on = 1,
1463};
1464#endif
1465
1466#ifdef CONFIG_USB_G_ANDROID
1467
1468#define PID_MAGIC_ID 0x71432909
1469#define SERIAL_NUM_MAGIC_ID 0x61945374
1470#define SERIAL_NUMBER_LENGTH 127
1471#define DLOAD_USB_BASE_ADD 0x2A05F0C8
1472
1473struct magic_num_struct {
1474 uint32_t pid;
1475 uint32_t serial_num;
1476};
1477
1478struct dload_struct {
1479 uint32_t reserved1;
1480 uint32_t reserved2;
1481 uint32_t reserved3;
1482 uint16_t reserved4;
1483 uint16_t pid;
1484 char serial_number[SERIAL_NUMBER_LENGTH];
1485 uint16_t reserved5;
1486 struct magic_num_struct
1487 magic_struct;
1488};
1489
1490static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
1491{
1492 struct dload_struct __iomem *dload = 0;
1493
1494 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
1495 if (!dload) {
1496 pr_err("%s: cannot remap I/O memory region: %08x\n",
1497 __func__, DLOAD_USB_BASE_ADD);
1498 return -ENXIO;
1499 }
1500
1501 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
1502 __func__, dload, pid, snum);
1503 /* update pid */
1504 dload->magic_struct.pid = PID_MAGIC_ID;
1505 dload->pid = pid;
1506
1507 /* update serial number */
1508 dload->magic_struct.serial_num = 0;
1509 if (!snum)
1510 return 0;
1511
1512 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
1513 strncpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
1514 dload->serial_number[SERIAL_NUMBER_LENGTH - 1] = '\0';
1515
1516 iounmap(dload);
1517
1518 return 0;
1519}
1520
1521static struct android_usb_platform_data android_usb_pdata = {
1522 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
1523};
1524
1525static struct platform_device android_usb_device = {
1526 .name = "android_usb",
1527 .id = -1,
1528 .dev = {
1529 .platform_data = &android_usb_pdata,
1530 },
1531};
1532
1533
1534#endif
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08001535
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001536#ifdef CONFIG_MSM_VPE
1537static struct resource msm_vpe_resources[] = {
1538 {
1539 .start = 0x05300000,
1540 .end = 0x05300000 + SZ_1M - 1,
1541 .flags = IORESOURCE_MEM,
1542 },
1543 {
1544 .start = INT_VPE,
1545 .end = INT_VPE,
1546 .flags = IORESOURCE_IRQ,
1547 },
1548};
1549
1550static struct platform_device msm_vpe_device = {
1551 .name = "msm_vpe",
1552 .id = 0,
1553 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1554 .resource = msm_vpe_resources,
1555};
1556#endif
1557
1558#ifdef CONFIG_MSM_CAMERA
1559#ifdef CONFIG_MSM_CAMERA_FLASH
1560#define VFE_CAMIF_TIMER1_GPIO 29
1561#define VFE_CAMIF_TIMER2_GPIO 30
1562#define VFE_CAMIF_TIMER3_GPIO_INT 31
1563#define FUSION_VFE_CAMIF_TIMER1_GPIO 42
1564static struct msm_camera_sensor_flash_src msm_flash_src = {
1565 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PMIC,
1566 ._fsrc.pmic_src.num_of_src = 2,
1567 ._fsrc.pmic_src.low_current = 100,
1568 ._fsrc.pmic_src.high_current = 300,
1569 ._fsrc.pmic_src.led_src_1 = PMIC8058_ID_FLASH_LED_0,
1570 ._fsrc.pmic_src.led_src_2 = PMIC8058_ID_FLASH_LED_1,
1571 ._fsrc.pmic_src.pmic_set_current = pm8058_set_flash_led_current,
1572};
1573#ifdef CONFIG_IMX074
1574static struct msm_camera_sensor_strobe_flash_data strobe_flash_xenon = {
1575 .flash_trigger = VFE_CAMIF_TIMER2_GPIO,
1576 .flash_charge = VFE_CAMIF_TIMER1_GPIO,
1577 .flash_charge_done = VFE_CAMIF_TIMER3_GPIO_INT,
1578 .flash_recharge_duration = 50000,
1579 .irq = MSM_GPIO_TO_INT(VFE_CAMIF_TIMER3_GPIO_INT),
1580};
1581#endif
1582#endif
1583
1584int msm_cam_gpio_tbl[] = {
1585 32,/*CAMIF_MCLK*/
1586 47,/*CAMIF_I2C_DATA*/
1587 48,/*CAMIF_I2C_CLK*/
1588 105,/*STANDBY*/
1589};
1590
1591enum msm_cam_stat{
1592 MSM_CAM_OFF,
1593 MSM_CAM_ON,
1594};
1595
1596static int config_gpio_table(enum msm_cam_stat stat)
1597{
1598 int rc = 0, i = 0;
1599 if (stat == MSM_CAM_ON) {
1600 for (i = 0; i < ARRAY_SIZE(msm_cam_gpio_tbl); i++) {
1601 rc = gpio_request(msm_cam_gpio_tbl[i], "CAM_GPIO");
1602 if (unlikely(rc < 0)) {
1603 pr_err("%s not able to get gpio\n", __func__);
1604 for (i--; i >= 0; i--)
1605 gpio_free(msm_cam_gpio_tbl[i]);
1606 break;
1607 }
1608 }
1609 } else {
1610 for (i = 0; i < ARRAY_SIZE(msm_cam_gpio_tbl); i++)
1611 gpio_free(msm_cam_gpio_tbl[i]);
1612 }
1613 return rc;
1614}
1615
1616static struct msm_camera_sensor_platform_info sensor_board_info = {
1617 .mount_angle = 0
1618};
1619
1620/*external regulator VREG_5V*/
1621static struct regulator *reg_flash_5V;
1622
1623static int config_camera_on_gpios_fluid(void)
1624{
1625 int rc = 0;
1626
1627 reg_flash_5V = regulator_get(NULL, "8901_mpp0");
1628 if (IS_ERR(reg_flash_5V)) {
1629 pr_err("'%s' regulator not found, rc=%ld\n",
1630 "8901_mpp0", IS_ERR(reg_flash_5V));
1631 return -ENODEV;
1632 }
1633
1634 rc = regulator_enable(reg_flash_5V);
1635 if (rc) {
1636 pr_err("'%s' regulator enable failed, rc=%d\n",
1637 "8901_mpp0", rc);
1638 regulator_put(reg_flash_5V);
1639 return rc;
1640 }
1641
1642#ifdef CONFIG_IMX074
1643 sensor_board_info.mount_angle = 90;
1644#endif
1645 rc = config_gpio_table(MSM_CAM_ON);
1646 if (rc < 0) {
1647 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1648 "failed\n", __func__);
1649 return rc;
1650 }
1651
1652 rc = gpio_request(GPIO_EXT_CAMIF_PWR_EN, "CAM_EN");
1653 if (rc < 0) {
1654 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1655 "failed\n", __func__, GPIO_EXT_CAMIF_PWR_EN);
1656 regulator_disable(reg_flash_5V);
1657 regulator_put(reg_flash_5V);
1658 return rc;
1659 }
1660 gpio_direction_output(GPIO_EXT_CAMIF_PWR_EN, 0);
1661 msleep(20);
1662 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 1);
1663
1664
1665 /*Enable LED_FLASH_EN*/
1666 rc = gpio_request(GPIO_LED_FLASH_EN, "LED_FLASH_EN");
1667 if (rc < 0) {
1668 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1669 "failed\n", __func__, GPIO_LED_FLASH_EN);
1670
1671 regulator_disable(reg_flash_5V);
1672 regulator_put(reg_flash_5V);
1673 config_gpio_table(MSM_CAM_OFF);
1674 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1675 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1676 return rc;
1677 }
1678 gpio_direction_output(GPIO_LED_FLASH_EN, 1);
1679 msleep(20);
1680 return rc;
1681}
1682
1683
1684static void config_camera_off_gpios_fluid(void)
1685{
1686 regulator_disable(reg_flash_5V);
1687 regulator_put(reg_flash_5V);
1688
1689 gpio_direction_output(GPIO_LED_FLASH_EN, 0);
1690 gpio_free(GPIO_LED_FLASH_EN);
1691
1692 config_gpio_table(MSM_CAM_OFF);
1693
1694 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1695 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1696}
1697static int config_camera_on_gpios(void)
1698{
1699 int rc = 0;
1700
1701 if (machine_is_msm8x60_fluid())
1702 return config_camera_on_gpios_fluid();
1703
1704 rc = config_gpio_table(MSM_CAM_ON);
1705 if (rc < 0) {
1706 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1707 "failed\n", __func__);
1708 return rc;
1709 }
1710
Jilai Wang971f97f2011-07-13 14:25:25 -04001711 if (!machine_is_msm8x60_dragon()) {
1712 rc = gpio_request(GPIO_EXT_CAMIF_PWR_EN, "CAM_EN");
1713 if (rc < 0) {
1714 config_gpio_table(MSM_CAM_OFF);
1715 pr_err("%s: CAMSENSOR gpio %d request"
1716 "failed\n", __func__, GPIO_EXT_CAMIF_PWR_EN);
1717 return rc;
1718 }
1719 gpio_direction_output(GPIO_EXT_CAMIF_PWR_EN, 0);
1720 msleep(20);
1721 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001722 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001723
1724#ifdef CONFIG_MSM_CAMERA_FLASH
1725#ifdef CONFIG_IMX074
1726 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
1727 strobe_flash_xenon.flash_charge = FUSION_VFE_CAMIF_TIMER1_GPIO;
1728#endif
1729#endif
1730 return rc;
1731}
1732
1733static void config_camera_off_gpios(void)
1734{
1735 if (machine_is_msm8x60_fluid())
1736 return config_camera_off_gpios_fluid();
1737
1738
1739 config_gpio_table(MSM_CAM_OFF);
1740
Jilai Wang971f97f2011-07-13 14:25:25 -04001741 if (!machine_is_msm8x60_dragon()) {
1742 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1743 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1744 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001745}
1746
1747#ifdef CONFIG_QS_S5K4E1
1748
1749#define QS_CAM_HC37_CAM_PD PM8058_GPIO_PM_TO_SYS(26)
1750
1751static int config_camera_on_gpios_qs_cam_fluid(void)
1752{
1753 int rc = 0;
1754
1755 /* request QS_CAM_HC37_CAM_PD as an output to HC37 ASIC pin CAM_PD */
1756 rc = gpio_request(QS_CAM_HC37_CAM_PD, "QS_CAM_HC37_CAM_PD");
1757 if (rc < 0) {
1758 printk(KERN_ERR "%s: QS_CAM_HC37_CAM_PD gpio %d request"
1759 " failed\n", __func__, QS_CAM_HC37_CAM_PD);
1760 return rc;
1761 }
1762 gpio_direction_output(QS_CAM_HC37_CAM_PD, 0);
1763 msleep(20);
1764 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 1);
1765 msleep(20);
1766
1767 /*
1768 * Set GPIO_AUX_CAM_2P7_EN to 1 on North Expander IO2
1769 * to enable 2.7V power to Camera
1770 */
1771 rc = gpio_request(GPIO_AUX_CAM_2P7_EN, "CAM_2P7_EN");
1772 if (rc < 0) {
1773 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1774 " failed\n", __func__, GPIO_AUX_CAM_2P7_EN);
1775 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1776 gpio_free(QS_CAM_HC37_CAM_PD);
1777 return rc;
1778 }
1779 gpio_direction_output(GPIO_AUX_CAM_2P7_EN, 0);
1780 msleep(20);
1781 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 1);
1782 msleep(20);
1783
1784 rc = config_camera_on_gpios_fluid();
1785 if (rc < 0) {
1786 printk(KERN_ERR "%s: config_camera_on_gpios_fluid"
1787 " failed\n", __func__);
1788 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1789 gpio_free(QS_CAM_HC37_CAM_PD);
1790 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 0);
1791 gpio_free(GPIO_AUX_CAM_2P7_EN);
1792 return rc;
1793 }
1794 return rc;
1795}
1796
1797static void config_camera_off_gpios_qs_cam_fluid(void)
1798{
1799 /*
1800 * Set GPIO_AUX_CAM_2P7_EN to 0 on North Expander IO2
1801 * to disable 2.7V power to Camera
1802 */
1803 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 0);
1804 gpio_free(GPIO_AUX_CAM_2P7_EN);
1805
1806 /* set QS_CAM_HC37_CAM_PD to 0 to power off HC37 ASIC*/
1807 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1808 gpio_free(QS_CAM_HC37_CAM_PD);
1809
1810 config_camera_off_gpios_fluid();
1811 return;
1812}
1813
1814static int config_camera_on_gpios_qs_cam(void)
1815{
1816 int rc = 0;
1817
1818 if (machine_is_msm8x60_fluid())
1819 return config_camera_on_gpios_qs_cam_fluid();
1820
1821 rc = config_camera_on_gpios();
1822 return rc;
1823}
1824
1825static void config_camera_off_gpios_qs_cam(void)
1826{
1827 if (machine_is_msm8x60_fluid())
1828 return config_camera_off_gpios_qs_cam_fluid();
1829
1830 config_camera_off_gpios();
1831 return;
1832}
1833#endif
1834
1835static int config_camera_on_gpios_web_cam(void)
1836{
1837 int rc = 0;
1838 rc = config_gpio_table(MSM_CAM_ON);
1839 if (rc < 0) {
1840 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1841 "failed\n", __func__);
1842 return rc;
1843 }
1844
Jilai Wang53d27a82011-07-13 14:32:58 -04001845 if (!(machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon())) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001846 rc = gpio_request(GPIO_WEB_CAMIF_STANDBY, "CAM_EN");
1847 if (rc < 0) {
1848 config_gpio_table(MSM_CAM_OFF);
1849 pr_err(KERN_ERR "%s: CAMSENSOR gpio %d request"
1850 "failed\n", __func__, GPIO_WEB_CAMIF_STANDBY);
1851 return rc;
1852 }
1853 gpio_direction_output(GPIO_WEB_CAMIF_STANDBY, 0);
1854 }
1855 return rc;
1856}
1857
1858static void config_camera_off_gpios_web_cam(void)
1859{
1860 config_gpio_table(MSM_CAM_OFF);
Jilai Wang53d27a82011-07-13 14:32:58 -04001861 if (!(machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon())) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001862 gpio_set_value_cansleep(GPIO_WEB_CAMIF_STANDBY, 1);
1863 gpio_free(GPIO_WEB_CAMIF_STANDBY);
1864 }
1865 return;
1866}
1867
1868#ifdef CONFIG_MSM_BUS_SCALING
1869static struct msm_bus_vectors cam_init_vectors[] = {
1870 {
1871 .src = MSM_BUS_MASTER_VFE,
1872 .dst = MSM_BUS_SLAVE_SMI,
1873 .ab = 0,
1874 .ib = 0,
1875 },
1876 {
1877 .src = MSM_BUS_MASTER_VFE,
1878 .dst = MSM_BUS_SLAVE_EBI_CH0,
1879 .ab = 0,
1880 .ib = 0,
1881 },
1882 {
1883 .src = MSM_BUS_MASTER_VPE,
1884 .dst = MSM_BUS_SLAVE_SMI,
1885 .ab = 0,
1886 .ib = 0,
1887 },
1888 {
1889 .src = MSM_BUS_MASTER_VPE,
1890 .dst = MSM_BUS_SLAVE_EBI_CH0,
1891 .ab = 0,
1892 .ib = 0,
1893 },
1894 {
1895 .src = MSM_BUS_MASTER_JPEG_ENC,
1896 .dst = MSM_BUS_SLAVE_SMI,
1897 .ab = 0,
1898 .ib = 0,
1899 },
1900 {
1901 .src = MSM_BUS_MASTER_JPEG_ENC,
1902 .dst = MSM_BUS_SLAVE_EBI_CH0,
1903 .ab = 0,
1904 .ib = 0,
1905 },
1906};
1907
1908static struct msm_bus_vectors cam_preview_vectors[] = {
1909 {
1910 .src = MSM_BUS_MASTER_VFE,
1911 .dst = MSM_BUS_SLAVE_SMI,
1912 .ab = 0,
1913 .ib = 0,
1914 },
1915 {
1916 .src = MSM_BUS_MASTER_VFE,
1917 .dst = MSM_BUS_SLAVE_EBI_CH0,
1918 .ab = 283115520,
1919 .ib = 452984832,
1920 },
1921 {
1922 .src = MSM_BUS_MASTER_VPE,
1923 .dst = MSM_BUS_SLAVE_SMI,
1924 .ab = 0,
1925 .ib = 0,
1926 },
1927 {
1928 .src = MSM_BUS_MASTER_VPE,
1929 .dst = MSM_BUS_SLAVE_EBI_CH0,
1930 .ab = 0,
1931 .ib = 0,
1932 },
1933 {
1934 .src = MSM_BUS_MASTER_JPEG_ENC,
1935 .dst = MSM_BUS_SLAVE_SMI,
1936 .ab = 0,
1937 .ib = 0,
1938 },
1939 {
1940 .src = MSM_BUS_MASTER_JPEG_ENC,
1941 .dst = MSM_BUS_SLAVE_EBI_CH0,
1942 .ab = 0,
1943 .ib = 0,
1944 },
1945};
1946
1947static struct msm_bus_vectors cam_video_vectors[] = {
1948 {
1949 .src = MSM_BUS_MASTER_VFE,
1950 .dst = MSM_BUS_SLAVE_SMI,
1951 .ab = 283115520,
1952 .ib = 452984832,
1953 },
1954 {
1955 .src = MSM_BUS_MASTER_VFE,
1956 .dst = MSM_BUS_SLAVE_EBI_CH0,
1957 .ab = 283115520,
1958 .ib = 452984832,
1959 },
1960 {
1961 .src = MSM_BUS_MASTER_VPE,
1962 .dst = MSM_BUS_SLAVE_SMI,
1963 .ab = 319610880,
1964 .ib = 511377408,
1965 },
1966 {
1967 .src = MSM_BUS_MASTER_VPE,
1968 .dst = MSM_BUS_SLAVE_EBI_CH0,
1969 .ab = 0,
1970 .ib = 0,
1971 },
1972 {
1973 .src = MSM_BUS_MASTER_JPEG_ENC,
1974 .dst = MSM_BUS_SLAVE_SMI,
1975 .ab = 0,
1976 .ib = 0,
1977 },
1978 {
1979 .src = MSM_BUS_MASTER_JPEG_ENC,
1980 .dst = MSM_BUS_SLAVE_EBI_CH0,
1981 .ab = 0,
1982 .ib = 0,
1983 },
1984};
1985
1986static struct msm_bus_vectors cam_snapshot_vectors[] = {
1987 {
1988 .src = MSM_BUS_MASTER_VFE,
1989 .dst = MSM_BUS_SLAVE_SMI,
1990 .ab = 566231040,
1991 .ib = 905969664,
1992 },
1993 {
1994 .src = MSM_BUS_MASTER_VFE,
1995 .dst = MSM_BUS_SLAVE_EBI_CH0,
1996 .ab = 69984000,
1997 .ib = 111974400,
1998 },
1999 {
2000 .src = MSM_BUS_MASTER_VPE,
2001 .dst = MSM_BUS_SLAVE_SMI,
2002 .ab = 0,
2003 .ib = 0,
2004 },
2005 {
2006 .src = MSM_BUS_MASTER_VPE,
2007 .dst = MSM_BUS_SLAVE_EBI_CH0,
2008 .ab = 0,
2009 .ib = 0,
2010 },
2011 {
2012 .src = MSM_BUS_MASTER_JPEG_ENC,
2013 .dst = MSM_BUS_SLAVE_SMI,
2014 .ab = 320864256,
2015 .ib = 513382810,
2016 },
2017 {
2018 .src = MSM_BUS_MASTER_JPEG_ENC,
2019 .dst = MSM_BUS_SLAVE_EBI_CH0,
2020 .ab = 320864256,
2021 .ib = 513382810,
2022 },
2023};
2024
2025static struct msm_bus_vectors cam_zsl_vectors[] = {
2026 {
2027 .src = MSM_BUS_MASTER_VFE,
2028 .dst = MSM_BUS_SLAVE_SMI,
2029 .ab = 566231040,
2030 .ib = 905969664,
2031 },
2032 {
2033 .src = MSM_BUS_MASTER_VFE,
2034 .dst = MSM_BUS_SLAVE_EBI_CH0,
2035 .ab = 706199040,
2036 .ib = 1129918464,
2037 },
2038 {
2039 .src = MSM_BUS_MASTER_VPE,
2040 .dst = MSM_BUS_SLAVE_SMI,
2041 .ab = 0,
2042 .ib = 0,
2043 },
2044 {
2045 .src = MSM_BUS_MASTER_VPE,
2046 .dst = MSM_BUS_SLAVE_EBI_CH0,
2047 .ab = 0,
2048 .ib = 0,
2049 },
2050 {
2051 .src = MSM_BUS_MASTER_JPEG_ENC,
2052 .dst = MSM_BUS_SLAVE_SMI,
2053 .ab = 320864256,
2054 .ib = 513382810,
2055 },
2056 {
2057 .src = MSM_BUS_MASTER_JPEG_ENC,
2058 .dst = MSM_BUS_SLAVE_EBI_CH0,
2059 .ab = 320864256,
2060 .ib = 513382810,
2061 },
2062};
2063
2064static struct msm_bus_vectors cam_stereo_video_vectors[] = {
2065 {
2066 .src = MSM_BUS_MASTER_VFE,
2067 .dst = MSM_BUS_SLAVE_SMI,
2068 .ab = 212336640,
2069 .ib = 339738624,
2070 },
2071 {
2072 .src = MSM_BUS_MASTER_VFE,
2073 .dst = MSM_BUS_SLAVE_EBI_CH0,
2074 .ab = 25090560,
2075 .ib = 40144896,
2076 },
2077 {
2078 .src = MSM_BUS_MASTER_VPE,
2079 .dst = MSM_BUS_SLAVE_SMI,
2080 .ab = 239708160,
2081 .ib = 383533056,
2082 },
2083 {
2084 .src = MSM_BUS_MASTER_VPE,
2085 .dst = MSM_BUS_SLAVE_EBI_CH0,
2086 .ab = 79902720,
2087 .ib = 127844352,
2088 },
2089 {
2090 .src = MSM_BUS_MASTER_JPEG_ENC,
2091 .dst = MSM_BUS_SLAVE_SMI,
2092 .ab = 0,
2093 .ib = 0,
2094 },
2095 {
2096 .src = MSM_BUS_MASTER_JPEG_ENC,
2097 .dst = MSM_BUS_SLAVE_EBI_CH0,
2098 .ab = 0,
2099 .ib = 0,
2100 },
2101};
2102
2103static struct msm_bus_vectors cam_stereo_snapshot_vectors[] = {
2104 {
2105 .src = MSM_BUS_MASTER_VFE,
2106 .dst = MSM_BUS_SLAVE_SMI,
2107 .ab = 0,
2108 .ib = 0,
2109 },
2110 {
2111 .src = MSM_BUS_MASTER_VFE,
2112 .dst = MSM_BUS_SLAVE_EBI_CH0,
2113 .ab = 300902400,
2114 .ib = 481443840,
2115 },
2116 {
2117 .src = MSM_BUS_MASTER_VPE,
2118 .dst = MSM_BUS_SLAVE_SMI,
2119 .ab = 230307840,
2120 .ib = 368492544,
2121 },
2122 {
2123 .src = MSM_BUS_MASTER_VPE,
2124 .dst = MSM_BUS_SLAVE_EBI_CH0,
2125 .ab = 245113344,
2126 .ib = 392181351,
2127 },
2128 {
2129 .src = MSM_BUS_MASTER_JPEG_ENC,
2130 .dst = MSM_BUS_SLAVE_SMI,
2131 .ab = 106536960,
2132 .ib = 170459136,
2133 },
2134 {
2135 .src = MSM_BUS_MASTER_JPEG_ENC,
2136 .dst = MSM_BUS_SLAVE_EBI_CH0,
2137 .ab = 106536960,
2138 .ib = 170459136,
2139 },
2140};
2141
2142static struct msm_bus_paths cam_bus_client_config[] = {
2143 {
2144 ARRAY_SIZE(cam_init_vectors),
2145 cam_init_vectors,
2146 },
2147 {
2148 ARRAY_SIZE(cam_preview_vectors),
2149 cam_preview_vectors,
2150 },
2151 {
2152 ARRAY_SIZE(cam_video_vectors),
2153 cam_video_vectors,
2154 },
2155 {
2156 ARRAY_SIZE(cam_snapshot_vectors),
2157 cam_snapshot_vectors,
2158 },
2159 {
2160 ARRAY_SIZE(cam_zsl_vectors),
2161 cam_zsl_vectors,
2162 },
2163 {
2164 ARRAY_SIZE(cam_stereo_video_vectors),
2165 cam_stereo_video_vectors,
2166 },
2167 {
2168 ARRAY_SIZE(cam_stereo_snapshot_vectors),
2169 cam_stereo_snapshot_vectors,
2170 },
2171};
2172
2173static struct msm_bus_scale_pdata cam_bus_client_pdata = {
2174 cam_bus_client_config,
2175 ARRAY_SIZE(cam_bus_client_config),
2176 .name = "msm_camera",
2177};
2178#endif
2179
2180struct msm_camera_device_platform_data msm_camera_device_data = {
2181 .camera_gpio_on = config_camera_on_gpios,
2182 .camera_gpio_off = config_camera_off_gpios,
2183 .ioext.csiphy = 0x04800000,
2184 .ioext.csisz = 0x00000400,
2185 .ioext.csiirq = CSI_0_IRQ,
2186 .ioclk.mclk_clk_rate = 24000000,
2187 .ioclk.vfe_clk_rate = 228570000,
2188#ifdef CONFIG_MSM_BUS_SCALING
2189 .cam_bus_scale_table = &cam_bus_client_pdata,
2190#endif
2191};
2192
2193#ifdef CONFIG_QS_S5K4E1
2194struct msm_camera_device_platform_data msm_camera_device_data_qs_cam = {
2195 .camera_gpio_on = config_camera_on_gpios_qs_cam,
2196 .camera_gpio_off = config_camera_off_gpios_qs_cam,
2197 .ioext.csiphy = 0x04800000,
2198 .ioext.csisz = 0x00000400,
2199 .ioext.csiirq = CSI_0_IRQ,
2200 .ioclk.mclk_clk_rate = 24000000,
2201 .ioclk.vfe_clk_rate = 228570000,
2202#ifdef CONFIG_MSM_BUS_SCALING
2203 .cam_bus_scale_table = &cam_bus_client_pdata,
2204#endif
2205};
2206#endif
2207
2208struct msm_camera_device_platform_data msm_camera_device_data_web_cam = {
2209 .camera_gpio_on = config_camera_on_gpios_web_cam,
2210 .camera_gpio_off = config_camera_off_gpios_web_cam,
2211 .ioext.csiphy = 0x04900000,
2212 .ioext.csisz = 0x00000400,
2213 .ioext.csiirq = CSI_1_IRQ,
2214 .ioclk.mclk_clk_rate = 24000000,
2215 .ioclk.vfe_clk_rate = 228570000,
2216#ifdef CONFIG_MSM_BUS_SCALING
2217 .cam_bus_scale_table = &cam_bus_client_pdata,
2218#endif
2219};
2220
2221struct resource msm_camera_resources[] = {
2222 {
2223 .start = 0x04500000,
2224 .end = 0x04500000 + SZ_1M - 1,
2225 .flags = IORESOURCE_MEM,
2226 },
2227 {
2228 .start = VFE_IRQ,
2229 .end = VFE_IRQ,
2230 .flags = IORESOURCE_IRQ,
2231 },
2232};
2233#ifdef CONFIG_MT9E013
2234static struct msm_camera_sensor_platform_info mt9e013_sensor_8660_info = {
2235 .mount_angle = 0
2236};
2237
2238static struct msm_camera_sensor_flash_data flash_mt9e013 = {
2239 .flash_type = MSM_CAMERA_FLASH_LED,
2240 .flash_src = &msm_flash_src
2241};
2242
2243static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
2244 .sensor_name = "mt9e013",
2245 .sensor_reset = 106,
2246 .sensor_pwd = 85,
2247 .vcm_pwd = 1,
2248 .vcm_enable = 0,
2249 .pdata = &msm_camera_device_data,
2250 .resource = msm_camera_resources,
2251 .num_resources = ARRAY_SIZE(msm_camera_resources),
2252 .flash_data = &flash_mt9e013,
2253 .strobe_flash_data = &strobe_flash_xenon,
2254 .sensor_platform_info = &mt9e013_sensor_8660_info,
2255 .csi_if = 1
2256};
2257struct platform_device msm_camera_sensor_mt9e013 = {
2258 .name = "msm_camera_mt9e013",
2259 .dev = {
2260 .platform_data = &msm_camera_sensor_mt9e013_data,
2261 },
2262};
2263#endif
2264
2265#ifdef CONFIG_IMX074
Roja Rani Yarubandi68ebb4d2011-10-20 10:33:16 +05302266static struct msm_camera_sensor_platform_info imx074_sensor_board_info = {
2267 .mount_angle = 180
2268};
2269
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002270static struct msm_camera_sensor_flash_data flash_imx074 = {
2271 .flash_type = MSM_CAMERA_FLASH_LED,
2272 .flash_src = &msm_flash_src
2273};
2274
2275static struct msm_camera_sensor_info msm_camera_sensor_imx074_data = {
2276 .sensor_name = "imx074",
2277 .sensor_reset = 106,
2278 .sensor_pwd = 85,
2279 .vcm_pwd = GPIO_AUX_CAM_2P7_EN,
2280 .vcm_enable = 1,
2281 .pdata = &msm_camera_device_data,
2282 .resource = msm_camera_resources,
2283 .num_resources = ARRAY_SIZE(msm_camera_resources),
2284 .flash_data = &flash_imx074,
2285 .strobe_flash_data = &strobe_flash_xenon,
Roja Rani Yarubandi68ebb4d2011-10-20 10:33:16 +05302286 .sensor_platform_info = &imx074_sensor_board_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002287 .csi_if = 1
2288};
2289struct platform_device msm_camera_sensor_imx074 = {
2290 .name = "msm_camera_imx074",
2291 .dev = {
2292 .platform_data = &msm_camera_sensor_imx074_data,
2293 },
2294};
2295#endif
2296#ifdef CONFIG_WEBCAM_OV9726
2297
2298static struct msm_camera_sensor_platform_info ov9726_sensor_8660_info = {
2299 .mount_angle = 0
2300};
2301
2302static struct msm_camera_sensor_flash_data flash_ov9726 = {
2303 .flash_type = MSM_CAMERA_FLASH_LED,
2304 .flash_src = &msm_flash_src
2305};
2306static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
2307 .sensor_name = "ov9726",
Kevin Chan3382c512011-07-19 21:00:45 -07002308 .sensor_reset_enable = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002309 .sensor_reset = GPIO_FRONT_CAM_RESET_N,
2310 .sensor_pwd = 85,
2311 .vcm_pwd = 1,
2312 .vcm_enable = 0,
2313 .pdata = &msm_camera_device_data_web_cam,
2314 .resource = msm_camera_resources,
2315 .num_resources = ARRAY_SIZE(msm_camera_resources),
2316 .flash_data = &flash_ov9726,
2317 .sensor_platform_info = &ov9726_sensor_8660_info,
2318 .csi_if = 1
2319};
2320struct platform_device msm_camera_sensor_webcam_ov9726 = {
2321 .name = "msm_camera_ov9726",
2322 .dev = {
2323 .platform_data = &msm_camera_sensor_ov9726_data,
2324 },
2325};
2326#endif
2327#ifdef CONFIG_WEBCAM_OV7692
2328static struct msm_camera_sensor_flash_data flash_ov7692 = {
2329 .flash_type = MSM_CAMERA_FLASH_LED,
2330 .flash_src = &msm_flash_src
2331};
2332static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
2333 .sensor_name = "ov7692",
2334 .sensor_reset = GPIO_WEB_CAMIF_RESET_N,
2335 .sensor_pwd = 85,
2336 .vcm_pwd = 1,
2337 .vcm_enable = 0,
2338 .pdata = &msm_camera_device_data_web_cam,
2339 .resource = msm_camera_resources,
2340 .num_resources = ARRAY_SIZE(msm_camera_resources),
2341 .flash_data = &flash_ov7692,
2342 .csi_if = 1
2343};
2344
2345static struct platform_device msm_camera_sensor_webcam_ov7692 = {
2346 .name = "msm_camera_ov7692",
2347 .dev = {
2348 .platform_data = &msm_camera_sensor_ov7692_data,
2349 },
2350};
2351#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04002352#ifdef CONFIG_VX6953
2353static struct msm_camera_sensor_platform_info vx6953_sensor_8660_info = {
2354 .mount_angle = 270
2355};
2356
2357static struct msm_camera_sensor_flash_data flash_vx6953 = {
2358 .flash_type = MSM_CAMERA_FLASH_NONE,
2359 .flash_src = &msm_flash_src
2360};
2361
2362static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
2363 .sensor_name = "vx6953",
2364 .sensor_reset = 63,
2365 .sensor_pwd = 63,
2366 .vcm_pwd = GPIO_AUX_CAM_2P7_EN,
2367 .vcm_enable = 1,
2368 .pdata = &msm_camera_device_data,
2369 .resource = msm_camera_resources,
2370 .num_resources = ARRAY_SIZE(msm_camera_resources),
2371 .flash_data = &flash_vx6953,
2372 .sensor_platform_info = &vx6953_sensor_8660_info,
2373 .csi_if = 1
2374};
2375struct platform_device msm_camera_sensor_vx6953 = {
2376 .name = "msm_camera_vx6953",
2377 .dev = {
2378 .platform_data = &msm_camera_sensor_vx6953_data,
2379 },
2380};
2381#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002382#ifdef CONFIG_QS_S5K4E1
2383
Nishant Pandit613ab7a2011-09-02 03:36:01 +05302384static struct msm_camera_sensor_platform_info qs_s5k4e1_sensor_8660_info = {
2385#ifdef CONFIG_FB_MSM_MIPI_NOVATEK_CMD_QHD_PT
2386 .mount_angle = 90
2387#else
2388 .mount_angle = 0
2389#endif
2390};
2391
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002392static char eeprom_data[864];
2393static struct msm_camera_sensor_flash_data flash_qs_s5k4e1 = {
2394 .flash_type = MSM_CAMERA_FLASH_LED,
2395 .flash_src = &msm_flash_src
2396};
2397
2398static struct msm_camera_sensor_info msm_camera_sensor_qs_s5k4e1_data = {
2399 .sensor_name = "qs_s5k4e1",
2400 .sensor_reset = 106,
2401 .sensor_pwd = 85,
2402 .vcm_pwd = 1,
2403 .vcm_enable = 0,
2404 .pdata = &msm_camera_device_data_qs_cam,
2405 .resource = msm_camera_resources,
2406 .num_resources = ARRAY_SIZE(msm_camera_resources),
2407 .flash_data = &flash_qs_s5k4e1,
2408 .strobe_flash_data = &strobe_flash_xenon,
Nishant Pandit613ab7a2011-09-02 03:36:01 +05302409 .sensor_platform_info = &qs_s5k4e1_sensor_8660_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002410 .csi_if = 1,
2411 .eeprom_data = eeprom_data,
2412};
2413struct platform_device msm_camera_sensor_qs_s5k4e1 = {
2414 .name = "msm_camera_qs_s5k4e1",
2415 .dev = {
2416 .platform_data = &msm_camera_sensor_qs_s5k4e1_data,
2417 },
2418};
2419#endif
2420static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
2421 #ifdef CONFIG_MT9E013
2422 {
2423 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
2424 },
2425 #endif
2426 #ifdef CONFIG_IMX074
2427 {
2428 I2C_BOARD_INFO("imx074", 0x1A),
2429 },
2430 #endif
2431 #ifdef CONFIG_WEBCAM_OV7692
2432 {
2433 I2C_BOARD_INFO("ov7692", 0x78),
2434 },
2435 #endif
2436 #ifdef CONFIG_WEBCAM_OV9726
2437 {
2438 I2C_BOARD_INFO("ov9726", 0x10),
2439 },
2440 #endif
2441 #ifdef CONFIG_QS_S5K4E1
2442 {
2443 I2C_BOARD_INFO("qs_s5k4e1", 0x20),
2444 },
2445 #endif
2446};
Jilai Wang971f97f2011-07-13 14:25:25 -04002447
2448static struct i2c_board_info msm_camera_dragon_boardinfo[] __initdata = {
Jilai Wang53d27a82011-07-13 14:32:58 -04002449 #ifdef CONFIG_WEBCAM_OV9726
2450 {
2451 I2C_BOARD_INFO("ov9726", 0x10),
2452 },
2453 #endif
Jilai Wang971f97f2011-07-13 14:25:25 -04002454 #ifdef CONFIG_VX6953
2455 {
2456 I2C_BOARD_INFO("vx6953", 0x20),
2457 },
2458 #endif
2459};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002460#endif
2461
2462#ifdef CONFIG_MSM_GEMINI
2463static struct resource msm_gemini_resources[] = {
2464 {
2465 .start = 0x04600000,
2466 .end = 0x04600000 + SZ_1M - 1,
2467 .flags = IORESOURCE_MEM,
2468 },
2469 {
2470 .start = INT_JPEG,
2471 .end = INT_JPEG,
2472 .flags = IORESOURCE_IRQ,
2473 },
2474};
2475
2476static struct platform_device msm_gemini_device = {
2477 .name = "msm_gemini",
2478 .resource = msm_gemini_resources,
2479 .num_resources = ARRAY_SIZE(msm_gemini_resources),
2480};
2481#endif
2482
2483#ifdef CONFIG_I2C_QUP
2484static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
2485{
2486}
2487
2488static struct msm_i2c_platform_data msm_gsbi3_qup_i2c_pdata = {
2489 .clk_freq = 384000,
2490 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002491 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2492};
2493
2494static struct msm_i2c_platform_data msm_gsbi4_qup_i2c_pdata = {
2495 .clk_freq = 100000,
2496 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002497 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2498};
2499
2500static struct msm_i2c_platform_data msm_gsbi7_qup_i2c_pdata = {
2501 .clk_freq = 100000,
2502 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002503 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2504};
2505
2506static struct msm_i2c_platform_data msm_gsbi8_qup_i2c_pdata = {
2507 .clk_freq = 100000,
2508 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002509 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2510};
2511
2512static struct msm_i2c_platform_data msm_gsbi9_qup_i2c_pdata = {
2513 .clk_freq = 100000,
2514 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002515 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2516};
2517
2518static struct msm_i2c_platform_data msm_gsbi12_qup_i2c_pdata = {
2519 .clk_freq = 100000,
2520 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002521 .use_gsbi_shared_mode = 1,
2522 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2523};
2524#endif
2525
2526#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
2527static struct msm_spi_platform_data msm_gsbi1_qup_spi_pdata = {
2528 .max_clock_speed = 24000000,
2529};
2530
2531static struct msm_spi_platform_data msm_gsbi10_qup_spi_pdata = {
2532 .max_clock_speed = 24000000,
2533};
2534#endif
2535
2536#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002537/* CODEC/TSSC SSBI */
2538static struct msm_i2c_ssbi_platform_data msm_ssbi3_pdata = {
2539 .controller_type = MSM_SBI_CTRL_SSBI,
2540};
2541#endif
2542
2543#ifdef CONFIG_BATTERY_MSM
2544/* Use basic value for fake MSM battery */
2545static struct msm_psy_batt_pdata msm_psy_batt_data = {
2546 .avail_chg_sources = AC_CHG,
2547};
2548
2549static struct platform_device msm_batt_device = {
2550 .name = "msm-battery",
2551 .id = -1,
2552 .dev.platform_data = &msm_psy_batt_data,
2553};
2554#endif
2555
2556#ifdef CONFIG_FB_MSM_LCDC_DSUB
2557/* VGA = 1440 x 900 x 4(bpp) x 2(pages)
2558 prim = 1024 x 600 x 4(bpp) x 2(pages)
2559 This is the difference. */
2560#define MSM_FB_DSUB_PMEM_ADDER (0xA32000-0x4B0000)
2561#else
2562#define MSM_FB_DSUB_PMEM_ADDER (0)
2563#endif
2564
2565/* Sensors DSPS platform data */
2566#ifdef CONFIG_MSM_DSPS
2567
2568static struct dsps_gpio_info dsps_surf_gpios[] = {
2569 {
2570 .name = "compass_rst_n",
2571 .num = GPIO_COMPASS_RST_N,
2572 .on_val = 1, /* device not in reset */
2573 .off_val = 0, /* device in reset */
2574 },
2575 {
2576 .name = "gpio_r_altimeter_reset_n",
2577 .num = GPIO_R_ALTIMETER_RESET_N,
2578 .on_val = 1, /* device not in reset */
2579 .off_val = 0, /* device in reset */
2580 }
2581};
2582
2583static struct dsps_gpio_info dsps_fluid_gpios[] = {
2584 {
2585 .name = "gpio_n_altimeter_reset_n",
2586 .num = GPIO_N_ALTIMETER_RESET_N,
2587 .on_val = 1, /* device not in reset */
2588 .off_val = 0, /* device in reset */
2589 }
2590};
2591
2592static void __init msm8x60_init_dsps(void)
2593{
2594 struct msm_dsps_platform_data *pdata =
2595 msm_dsps_device.dev.platform_data;
2596 /*
2597 * On Fluid the Compass sensor Chip-Select (CS) is directly connected
2598 * to the power supply and not controled via GPIOs. Fluid uses a
2599 * different IO-Expender (north) than used on surf/ffa.
2600 */
2601 if (machine_is_msm8x60_fluid()) {
2602 /* fluid has different firmware, gpios */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002603 pdata->pil_name = DSPS_PIL_FLUID_NAME;
2604 pdata->gpios = dsps_fluid_gpios;
2605 pdata->gpios_num = ARRAY_SIZE(dsps_fluid_gpios);
2606 } else {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002607 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
2608 pdata->gpios = dsps_surf_gpios;
2609 pdata->gpios_num = ARRAY_SIZE(dsps_surf_gpios);
2610 }
2611
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002612 platform_device_register(&msm_dsps_device);
2613}
2614#endif /* CONFIG_MSM_DSPS */
2615
2616#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002617#define MSM_FB_PRIM_BUF_SIZE (1024 * 600 * 4 * 3) /* 4 bpp x 3 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002618#else
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002619#define MSM_FB_PRIM_BUF_SIZE (1024 * 600 * 4 * 2) /* 4 bpp x 2 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002620#endif
2621
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002622#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
2623#define MSM_FB_EXT_BUF_SIZE (1920 * 1080 * 2 * 1) /* 2 bpp x 1 page */
2624#elif defined(CONFIG_FB_MSM_TVOUT)
2625#define MSM_FB_EXT_BUF_SIZE (720 * 576 * 2 * 2) /* 2 bpp x 2 pages */
2626#else
2627#define MSM_FB_EXT_BUFT_SIZE 0
2628#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002629
Huaibin Yang335f4012011-12-02 14:11:48 -08002630#ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK
kuogee hsieha39040b2011-08-11 15:40:45 -07002631/* width x height x 3 bpp x 2 frame buffer */
2632#define MSM_FB_WRITEBACK_SIZE (1024 * 600 * 3 * 2)
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002633#define MSM_FB_WRITEBACK_OFFSET \
2634 (MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002635#else
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002636#define MSM_FB_WRITEBACK_SIZE 0
2637#define MSM_FB_WRITEBACK_OFFSET 0
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002638#endif
2639
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002640#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
2641/* 4 bpp x 2 page HDMI case */
2642#define MSM_FB_SIZE roundup((1920 * 1088 * 4 * 2), 4096)
2643#else
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002644/* Note: must be multiple of 4096 */
2645#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE + \
2646 MSM_FB_WRITEBACK_SIZE + \
2647 MSM_FB_DSUB_PMEM_ADDER, 4096)
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002648#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002649
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002650#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
2651#define MSM_PMEM_SF_SIZE 0x8000000 /* 128 Mbytes */
2652#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002653#define MSM_PMEM_SF_SIZE 0x4000000 /* 64 Mbytes */
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002654#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002655
Huaibin Yanga5419422011-12-08 23:52:10 -08002656#ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK
2657#define MSM_FB_OVERLAY0_WRITEBACK_SIZE roundup((1376 * 768 * 3 * 2), 4096)
2658#else
2659#define MSM_FB_OVERLAY0_WRITEBACK_SIZE (0)
2660#endif /* CONFIG_FB_MSM_OVERLAY0_WRITEBACK */
2661
2662#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
2663#define MSM_FB_OVERLAY1_WRITEBACK_SIZE roundup((1920 * 1088 * 3 * 2), 4096)
2664#else
2665#define MSM_FB_OVERLAY1_WRITEBACK_SIZE (0)
2666#endif /* CONFIG_FB_MSM_OVERLAY1_WRITEBACK */
2667
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002668static int writeback_offset(void)
2669{
2670 return MSM_FB_WRITEBACK_OFFSET;
2671}
2672
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002673#define MSM_PMEM_KERNEL_EBI1_SIZE 0x600000
2674#define MSM_PMEM_ADSP_SIZE 0x2000000
Ben Romberger09e462d2011-08-09 15:24:37 -07002675#define MSM_PMEM_AUDIO_SIZE 0x28B000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002676
2677#define MSM_SMI_BASE 0x38000000
2678#define MSM_SMI_SIZE 0x4000000
2679
2680#define KERNEL_SMI_BASE (MSM_SMI_BASE)
Maheshwar Ajjac60c0462011-11-29 17:46:57 -08002681#define KERNEL_SMI_SIZE 0x600000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002682
2683#define USER_SMI_BASE (KERNEL_SMI_BASE + KERNEL_SMI_SIZE)
2684#define USER_SMI_SIZE (MSM_SMI_SIZE - KERNEL_SMI_SIZE)
2685#define MSM_PMEM_SMIPOOL_SIZE USER_SMI_SIZE
2686
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002687#define MSM_ION_EBI_SIZE MSM_PMEM_SF_SIZE
2688#define MSM_ION_ADSP_SIZE MSM_PMEM_ADSP_SIZE
Laura Abbottdf8b8a82011-11-02 23:13:45 -07002689#define MSM_ION_SMI_SIZE MSM_PMEM_SMIPOOL_SIZE
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002690
2691#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
2692#define MSM_ION_HEAP_NUM 5
2693#else
2694#define MSM_ION_HEAP_NUM 2
2695#endif
2696
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002697static unsigned fb_size;
2698static int __init fb_size_setup(char *p)
2699{
2700 fb_size = memparse(p, NULL);
2701 return 0;
2702}
2703early_param("fb_size", fb_size_setup);
2704
2705static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
2706static int __init pmem_kernel_ebi1_size_setup(char *p)
2707{
2708 pmem_kernel_ebi1_size = memparse(p, NULL);
2709 return 0;
2710}
2711early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
2712
2713#ifdef CONFIG_ANDROID_PMEM
2714static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
2715static int __init pmem_sf_size_setup(char *p)
2716{
2717 pmem_sf_size = memparse(p, NULL);
2718 return 0;
2719}
2720early_param("pmem_sf_size", pmem_sf_size_setup);
2721
2722static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
2723
2724static int __init pmem_adsp_size_setup(char *p)
2725{
2726 pmem_adsp_size = memparse(p, NULL);
2727 return 0;
2728}
2729early_param("pmem_adsp_size", pmem_adsp_size_setup);
2730
2731static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
2732
2733static int __init pmem_audio_size_setup(char *p)
2734{
2735 pmem_audio_size = memparse(p, NULL);
2736 return 0;
2737}
2738early_param("pmem_audio_size", pmem_audio_size_setup);
2739#endif
2740
2741static struct resource msm_fb_resources[] = {
2742 {
2743 .flags = IORESOURCE_DMA,
2744 }
2745};
2746
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002747static int msm_fb_detect_panel(const char *name)
2748{
2749 if (machine_is_msm8x60_fluid()) {
2750 uint32_t soc_platform_version = socinfo_get_platform_version();
2751 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
2752#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2753 if (!strncmp(name, LCDC_SAMSUNG_OLED_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002754 strnlen(LCDC_SAMSUNG_OLED_PANEL_NAME,
2755 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002756 return 0;
2757#endif
2758 } else { /*P3 and up use AUO panel */
2759#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
2760 if (!strncmp(name, LCDC_AUO_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002761 strnlen(LCDC_AUO_PANEL_NAME,
2762 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002763 return 0;
2764#endif
2765 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002766#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
2767 } else if machine_is_msm8x60_dragon() {
2768 if (!strncmp(name, LCDC_NT35582_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002769 strnlen(LCDC_NT35582_PANEL_NAME,
2770 PANEL_NAME_MAX_LEN)))
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002771 return 0;
2772#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002773 } else {
2774 if (!strncmp(name, LCDC_SAMSUNG_WSVGA_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002775 strnlen(LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2776 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002777 return 0;
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002778
2779#if !defined(CONFIG_FB_MSM_LCDC_AUTO_DETECT) && \
2780 !defined(CONFIG_FB_MSM_MIPI_PANEL_AUTO_DETECT) && \
2781 !defined(CONFIG_FB_MSM_LCDC_MIPI_PANEL_AUTO_DETECT)
2782 if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2783 strnlen(MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2784 PANEL_NAME_MAX_LEN)))
2785 return 0;
2786
2787 if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2788 strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2789 PANEL_NAME_MAX_LEN)))
2790 return 0;
2791
2792 if (!strncmp(name, MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2793 strnlen(MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2794 PANEL_NAME_MAX_LEN)))
2795 return 0;
2796#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002797 }
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002798
2799 if (!strncmp(name, HDMI_PANEL_NAME,
2800 strnlen(HDMI_PANEL_NAME,
2801 PANEL_NAME_MAX_LEN)))
2802 return 0;
2803
2804 if (!strncmp(name, TVOUT_PANEL_NAME,
2805 strnlen(TVOUT_PANEL_NAME,
2806 PANEL_NAME_MAX_LEN)))
2807 return 0;
2808
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002809 pr_warning("%s: not supported '%s'", __func__, name);
2810 return -ENODEV;
2811}
2812
2813static struct msm_fb_platform_data msm_fb_pdata = {
2814 .detect_client = msm_fb_detect_panel,
2815};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002816
2817static struct platform_device msm_fb_device = {
2818 .name = "msm_fb",
2819 .id = 0,
2820 .num_resources = ARRAY_SIZE(msm_fb_resources),
2821 .resource = msm_fb_resources,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002822 .dev.platform_data = &msm_fb_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002823};
2824
2825#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002826#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002827static struct android_pmem_platform_data android_pmem_pdata = {
2828 .name = "pmem",
2829 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
2830 .cached = 1,
2831 .memory_type = MEMTYPE_EBI1,
2832};
2833
2834static struct platform_device android_pmem_device = {
2835 .name = "android_pmem",
2836 .id = 0,
2837 .dev = {.platform_data = &android_pmem_pdata},
2838};
2839
2840static struct android_pmem_platform_data android_pmem_adsp_pdata = {
2841 .name = "pmem_adsp",
2842 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2843 .cached = 0,
2844 .memory_type = MEMTYPE_EBI1,
2845};
2846
2847static struct platform_device android_pmem_adsp_device = {
2848 .name = "android_pmem",
2849 .id = 2,
2850 .dev = { .platform_data = &android_pmem_adsp_pdata },
2851};
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002852#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002853static struct android_pmem_platform_data android_pmem_audio_pdata = {
2854 .name = "pmem_audio",
2855 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2856 .cached = 0,
2857 .memory_type = MEMTYPE_EBI1,
2858};
2859
2860static struct platform_device android_pmem_audio_device = {
2861 .name = "android_pmem",
2862 .id = 4,
2863 .dev = { .platform_data = &android_pmem_audio_pdata },
2864};
2865
Laura Abbott1e36a022011-06-22 17:08:13 -07002866#define PMEM_BUS_WIDTH(_bw) \
2867 { \
2868 .vectors = &(struct msm_bus_vectors){ \
2869 .src = MSM_BUS_MASTER_AMPSS_M0, \
2870 .dst = MSM_BUS_SLAVE_SMI, \
2871 .ib = (_bw), \
2872 .ab = 0, \
2873 }, \
2874 .num_paths = 1, \
2875 }
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002876#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Laura Abbott1e36a022011-06-22 17:08:13 -07002877static struct msm_bus_paths pmem_smi_table[] = {
2878 [0] = PMEM_BUS_WIDTH(0), /* Off */
2879 [1] = PMEM_BUS_WIDTH(1), /* On */
2880};
2881
2882static struct msm_bus_scale_pdata smi_client_pdata = {
2883 .usecase = pmem_smi_table,
2884 .num_usecases = ARRAY_SIZE(pmem_smi_table),
2885 .name = "pmem_smi",
2886};
2887
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002888int request_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002889{
2890 int bus_id = (int) data;
2891
2892 msm_bus_scale_client_update_request(bus_id, 1);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002893 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002894}
2895
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002896int release_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002897{
2898 int bus_id = (int) data;
2899
2900 msm_bus_scale_client_update_request(bus_id, 0);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002901 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002902}
2903
Alex Bird199980e2011-10-21 11:29:27 -07002904void *setup_smi_region(void)
Laura Abbott1e36a022011-06-22 17:08:13 -07002905{
2906 return (void *)msm_bus_scale_register_client(&smi_client_pdata);
2907}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002908static struct android_pmem_platform_data android_pmem_smipool_pdata = {
2909 .name = "pmem_smipool",
2910 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2911 .cached = 0,
2912 .memory_type = MEMTYPE_SMI,
Alex Bird199980e2011-10-21 11:29:27 -07002913 .request_region = request_smi_region,
2914 .release_region = release_smi_region,
2915 .setup_region = setup_smi_region,
Laura Abbott1e36a022011-06-22 17:08:13 -07002916 .map_on_demand = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002917};
2918static struct platform_device android_pmem_smipool_device = {
2919 .name = "android_pmem",
2920 .id = 7,
2921 .dev = { .platform_data = &android_pmem_smipool_pdata },
2922};
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002923#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002924#endif
2925
2926#define GPIO_DONGLE_PWR_EN 258
2927static void setup_display_power(void);
2928static int lcdc_vga_enabled;
2929static int vga_enable_request(int enable)
2930{
2931 if (enable)
2932 lcdc_vga_enabled = 1;
2933 else
2934 lcdc_vga_enabled = 0;
2935 setup_display_power();
2936
2937 return 0;
2938}
2939
2940#define GPIO_BACKLIGHT_PWM0 0
2941#define GPIO_BACKLIGHT_PWM1 1
2942
2943static int pmic_backlight_gpio[2]
2944 = { GPIO_BACKLIGHT_PWM0, GPIO_BACKLIGHT_PWM1 };
2945static struct msm_panel_common_pdata lcdc_samsung_panel_data = {
2946 .gpio_num = pmic_backlight_gpio, /* two LPG CHANNELS for backlight */
2947 .vga_switch = vga_enable_request,
2948};
2949
2950static struct platform_device lcdc_samsung_panel_device = {
2951 .name = LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2952 .id = 0,
2953 .dev = {
2954 .platform_data = &lcdc_samsung_panel_data,
2955 }
2956};
2957#if (!defined(CONFIG_SPI_QUP)) && \
2958 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
2959 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA))
2960
2961static int lcdc_spi_gpio_array_num[] = {
2962 LCDC_SPI_GPIO_CLK,
2963 LCDC_SPI_GPIO_CS,
2964 LCDC_SPI_GPIO_MOSI,
2965};
2966
2967static uint32_t lcdc_spi_gpio_config_data[] = {
2968 GPIO_CFG(LCDC_SPI_GPIO_CLK, 0,
2969 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2970 GPIO_CFG(LCDC_SPI_GPIO_CS, 0,
2971 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2972 GPIO_CFG(LCDC_SPI_GPIO_MOSI, 0,
2973 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2974};
2975
2976static void lcdc_config_spi_gpios(int enable)
2977{
2978 int n;
2979 for (n = 0; n < ARRAY_SIZE(lcdc_spi_gpio_config_data); ++n)
2980 gpio_tlmm_config(lcdc_spi_gpio_config_data[n], 0);
2981}
2982#endif
2983
2984#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2985#ifdef CONFIG_SPI_QUP
2986static struct spi_board_info lcdc_samsung_spi_board_info[] __initdata = {
2987 {
2988 .modalias = LCDC_SAMSUNG_SPI_DEVICE_NAME,
2989 .mode = SPI_MODE_3,
2990 .bus_num = 1,
2991 .chip_select = 0,
2992 .max_speed_hz = 10800000,
2993 }
2994};
2995#endif /* CONFIG_SPI_QUP */
2996
2997static struct msm_panel_common_pdata lcdc_samsung_oled_panel_data = {
2998#ifndef CONFIG_SPI_QUP
2999 .panel_config_gpio = lcdc_config_spi_gpios,
3000 .gpio_num = lcdc_spi_gpio_array_num,
3001#endif
3002};
3003
3004static struct platform_device lcdc_samsung_oled_panel_device = {
3005 .name = LCDC_SAMSUNG_OLED_PANEL_NAME,
3006 .id = 0,
3007 .dev.platform_data = &lcdc_samsung_oled_panel_data,
3008};
3009#endif /*CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT */
3010
3011#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
3012#ifdef CONFIG_SPI_QUP
3013static struct spi_board_info lcdc_auo_spi_board_info[] __initdata = {
3014 {
3015 .modalias = LCDC_AUO_SPI_DEVICE_NAME,
3016 .mode = SPI_MODE_3,
3017 .bus_num = 1,
3018 .chip_select = 0,
3019 .max_speed_hz = 10800000,
3020 }
3021};
3022#endif
3023
3024static struct msm_panel_common_pdata lcdc_auo_wvga_panel_data = {
3025#ifndef CONFIG_SPI_QUP
3026 .panel_config_gpio = lcdc_config_spi_gpios,
3027 .gpio_num = lcdc_spi_gpio_array_num,
3028#endif
3029};
3030
3031static struct platform_device lcdc_auo_wvga_panel_device = {
3032 .name = LCDC_AUO_PANEL_NAME,
3033 .id = 0,
3034 .dev.platform_data = &lcdc_auo_wvga_panel_data,
3035};
3036#endif /*CONFIG_FB_MSM_LCDC_AUO_WVGA*/
3037
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04003038#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
3039
3040#define GPIO_NT35582_RESET 94
3041#define GPIO_NT35582_BL_EN_HW_PIN 24
3042#define GPIO_NT35582_BL_EN \
3043 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1)
3044
3045static int lcdc_nt35582_pmic_gpio[] = {GPIO_NT35582_BL_EN };
3046
3047static struct msm_panel_common_pdata lcdc_nt35582_panel_data = {
3048 .gpio_num = lcdc_nt35582_pmic_gpio,
3049};
3050
3051static struct platform_device lcdc_nt35582_panel_device = {
3052 .name = LCDC_NT35582_PANEL_NAME,
3053 .id = 0,
3054 .dev = {
3055 .platform_data = &lcdc_nt35582_panel_data,
3056 }
3057};
3058
3059static struct spi_board_info lcdc_nt35582_spi_board_info[] __initdata = {
3060 {
3061 .modalias = "lcdc_nt35582_spi",
3062 .mode = SPI_MODE_0,
3063 .bus_num = 0,
3064 .chip_select = 0,
3065 .max_speed_hz = 1100000,
3066 }
3067};
3068#endif
3069
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003070#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
3071static struct resource hdmi_msm_resources[] = {
3072 {
3073 .name = "hdmi_msm_qfprom_addr",
3074 .start = 0x00700000,
3075 .end = 0x007060FF,
3076 .flags = IORESOURCE_MEM,
3077 },
3078 {
3079 .name = "hdmi_msm_hdmi_addr",
3080 .start = 0x04A00000,
3081 .end = 0x04A00FFF,
3082 .flags = IORESOURCE_MEM,
3083 },
3084 {
3085 .name = "hdmi_msm_irq",
3086 .start = HDMI_IRQ,
3087 .end = HDMI_IRQ,
3088 .flags = IORESOURCE_IRQ,
3089 },
3090};
3091
3092static int hdmi_enable_5v(int on);
3093static int hdmi_core_power(int on, int show);
3094static int hdmi_cec_power(int on);
3095
3096static struct msm_hdmi_platform_data hdmi_msm_data = {
3097 .irq = HDMI_IRQ,
3098 .enable_5v = hdmi_enable_5v,
3099 .core_power = hdmi_core_power,
3100 .cec_power = hdmi_cec_power,
3101};
3102
3103static struct platform_device hdmi_msm_device = {
3104 .name = "hdmi_msm",
3105 .id = 0,
3106 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
3107 .resource = hdmi_msm_resources,
3108 .dev.platform_data = &hdmi_msm_data,
3109};
3110#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
3111
3112#ifdef CONFIG_FB_MSM_MIPI_DSI
3113static struct platform_device mipi_dsi_toshiba_panel_device = {
3114 .name = "mipi_toshiba",
3115 .id = 0,
3116};
3117
3118#define FPGA_3D_GPIO_CONFIG_ADDR 0x1D00017A
3119
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07003120static struct mipi_dsi_panel_platform_data novatek_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003121 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
Chandan Uddaraju83eac3c2011-09-11 18:32:23 -07003122 .fpga_ctrl_mode = FPGA_EBI2_INTF,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003123};
3124
3125static struct platform_device mipi_dsi_novatek_panel_device = {
3126 .name = "mipi_novatek",
3127 .id = 0,
3128 .dev = {
3129 .platform_data = &novatek_pdata,
3130 }
3131};
3132#endif
3133
3134static void __init msm8x60_allocate_memory_regions(void)
3135{
3136 void *addr;
3137 unsigned long size;
3138
3139 size = MSM_FB_SIZE;
3140 addr = alloc_bootmem_align(size, 0x1000);
3141 msm_fb_resources[0].start = __pa(addr);
3142 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
3143 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
3144 size, addr, __pa(addr));
3145
3146}
3147
3148#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
3149 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
3150/*virtual key support */
3151static ssize_t tma300_vkeys_show(struct kobject *kobj,
3152 struct kobj_attribute *attr, char *buf)
3153{
3154 return sprintf(buf,
3155 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":60:900:90:120"
3156 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":180:900:90:120"
3157 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":300:900:90:120"
3158 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":420:900:90:120"
3159 "\n");
3160}
3161
3162static struct kobj_attribute tma300_vkeys_attr = {
3163 .attr = {
3164 .mode = S_IRUGO,
3165 },
3166 .show = &tma300_vkeys_show,
3167};
3168
3169static struct attribute *tma300_properties_attrs[] = {
3170 &tma300_vkeys_attr.attr,
3171 NULL
3172};
3173
3174static struct attribute_group tma300_properties_attr_group = {
3175 .attrs = tma300_properties_attrs,
3176};
3177
3178static struct kobject *properties_kobj;
3179
3180
3181
3182#define CYTTSP_TS_GPIO_IRQ 61
3183static int cyttsp_platform_init(struct i2c_client *client)
3184{
3185 int rc = -EINVAL;
3186 struct regulator *pm8058_l5 = NULL, *pm8058_s3;
3187
3188 if (machine_is_msm8x60_fluid()) {
3189 pm8058_l5 = regulator_get(NULL, "8058_l5");
3190 if (IS_ERR(pm8058_l5)) {
3191 pr_err("%s: regulator get of 8058_l5 failed (%ld)\n",
3192 __func__, PTR_ERR(pm8058_l5));
3193 rc = PTR_ERR(pm8058_l5);
3194 return rc;
3195 }
3196 rc = regulator_set_voltage(pm8058_l5, 2850000, 2850000);
3197 if (rc) {
3198 pr_err("%s: regulator_set_voltage of 8058_l5 failed(%d)\n",
3199 __func__, rc);
3200 goto reg_l5_put;
3201 }
3202
3203 rc = regulator_enable(pm8058_l5);
3204 if (rc) {
3205 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3206 __func__, rc);
3207 goto reg_l5_put;
3208 }
3209 }
3210 /* vote for s3 to enable i2c communication lines */
3211 pm8058_s3 = regulator_get(NULL, "8058_s3");
3212 if (IS_ERR(pm8058_s3)) {
3213 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3214 __func__, PTR_ERR(pm8058_s3));
3215 rc = PTR_ERR(pm8058_s3);
3216 goto reg_l5_disable;
3217 }
3218
3219 rc = regulator_set_voltage(pm8058_s3, 1800000, 1800000);
3220 if (rc) {
3221 pr_err("%s: regulator_set_voltage() = %d\n",
3222 __func__, rc);
3223 goto reg_s3_put;
3224 }
3225
3226 rc = regulator_enable(pm8058_s3);
3227 if (rc) {
3228 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3229 __func__, rc);
3230 goto reg_s3_put;
3231 }
3232
3233 /* wait for vregs to stabilize */
3234 usleep_range(10000, 10000);
3235
3236 /* check this device active by reading first byte/register */
3237 rc = i2c_smbus_read_byte_data(client, 0x01);
3238 if (rc < 0) {
3239 pr_err("%s: i2c sanity check failed\n", __func__);
3240 goto reg_s3_disable;
3241 }
3242
3243 /* virtual keys */
3244 if (machine_is_msm8x60_fluid()) {
3245 tma300_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
3246 properties_kobj = kobject_create_and_add("board_properties",
3247 NULL);
3248 if (properties_kobj)
3249 rc = sysfs_create_group(properties_kobj,
3250 &tma300_properties_attr_group);
3251 if (!properties_kobj || rc)
3252 pr_err("%s: failed to create board_properties\n",
3253 __func__);
3254 }
3255 return CY_OK;
3256
3257reg_s3_disable:
3258 regulator_disable(pm8058_s3);
3259reg_s3_put:
3260 regulator_put(pm8058_s3);
3261reg_l5_disable:
3262 if (machine_is_msm8x60_fluid())
3263 regulator_disable(pm8058_l5);
3264reg_l5_put:
3265 if (machine_is_msm8x60_fluid())
3266 regulator_put(pm8058_l5);
3267 return rc;
3268}
3269
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303270/* TODO: Put the regulator to LPM / HPM in suspend/resume*/
3271static int cyttsp_platform_suspend(struct i2c_client *client)
3272{
3273 msleep(20);
3274
3275 return CY_OK;
3276}
3277
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003278static int cyttsp_platform_resume(struct i2c_client *client)
3279{
3280 /* add any special code to strobe a wakeup pin or chip reset */
3281 msleep(10);
3282
3283 return CY_OK;
3284}
3285
3286static struct cyttsp_platform_data cyttsp_fluid_pdata = {
3287 .flags = 0x04,
3288 .gen = CY_GEN3, /* or */
3289 .use_st = CY_USE_ST,
3290 .use_mt = CY_USE_MT,
3291 .use_hndshk = CY_SEND_HNDSHK,
3292 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303293 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003294 .use_gestures = CY_USE_GESTURES,
3295 /* activate up to 4 groups
3296 * and set active distance
3297 */
3298 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3299 CY_GEST_GRP3 | CY_GEST_GRP4 |
3300 CY_ACT_DIST,
3301 /* change act_intrvl to customize the Active power state
3302 * scanning/processing refresh interval for Operating mode
3303 */
3304 .act_intrvl = CY_ACT_INTRVL_DFLT,
3305 /* change tch_tmout to customize the touch timeout for the
3306 * Active power state for Operating mode
3307 */
3308 .tch_tmout = CY_TCH_TMOUT_DFLT,
3309 /* change lp_intrvl to customize the Low Power power state
3310 * scanning/processing refresh interval for Operating mode
3311 */
3312 .lp_intrvl = CY_LP_INTRVL_DFLT,
3313 .sleep_gpio = -1,
3314 .resout_gpio = -1,
3315 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3316 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303317 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003318 .init = cyttsp_platform_init,
3319};
3320
3321static struct cyttsp_platform_data cyttsp_tmg240_pdata = {
3322 .panel_maxx = 1083,
3323 .panel_maxy = 659,
3324 .disp_minx = 30,
3325 .disp_maxx = 1053,
3326 .disp_miny = 30,
3327 .disp_maxy = 629,
3328 .correct_fw_ver = 8,
3329 .fw_fname = "cyttsp_8660_ffa.hex",
3330 .flags = 0x00,
3331 .gen = CY_GEN2, /* or */
3332 .use_st = CY_USE_ST,
3333 .use_mt = CY_USE_MT,
3334 .use_hndshk = CY_SEND_HNDSHK,
3335 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303336 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003337 .use_gestures = CY_USE_GESTURES,
3338 /* activate up to 4 groups
3339 * and set active distance
3340 */
3341 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3342 CY_GEST_GRP3 | CY_GEST_GRP4 |
3343 CY_ACT_DIST,
3344 /* change act_intrvl to customize the Active power state
3345 * scanning/processing refresh interval for Operating mode
3346 */
3347 .act_intrvl = CY_ACT_INTRVL_DFLT,
3348 /* change tch_tmout to customize the touch timeout for the
3349 * Active power state for Operating mode
3350 */
3351 .tch_tmout = CY_TCH_TMOUT_DFLT,
3352 /* change lp_intrvl to customize the Low Power power state
3353 * scanning/processing refresh interval for Operating mode
3354 */
3355 .lp_intrvl = CY_LP_INTRVL_DFLT,
3356 .sleep_gpio = -1,
3357 .resout_gpio = -1,
3358 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3359 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303360 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003361 .init = cyttsp_platform_init,
Mohan Pallaka1ea7d8a2011-08-18 15:06:00 +05303362 .disable_ghost_det = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003363};
3364static void cyttsp_set_params(void)
3365{
3366 if (SOCINFO_VERSION_MAJOR(socinfo_get_platform_version()) < 3) {
3367 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p2.hex";
3368 cyttsp_fluid_pdata.panel_maxx = 539;
3369 cyttsp_fluid_pdata.panel_maxy = 994;
3370 cyttsp_fluid_pdata.disp_minx = 30;
3371 cyttsp_fluid_pdata.disp_maxx = 509;
3372 cyttsp_fluid_pdata.disp_miny = 60;
3373 cyttsp_fluid_pdata.disp_maxy = 859;
3374 cyttsp_fluid_pdata.correct_fw_ver = 4;
3375 } else {
3376 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p3.hex";
3377 cyttsp_fluid_pdata.panel_maxx = 550;
3378 cyttsp_fluid_pdata.panel_maxy = 1013;
3379 cyttsp_fluid_pdata.disp_minx = 35;
3380 cyttsp_fluid_pdata.disp_maxx = 515;
3381 cyttsp_fluid_pdata.disp_miny = 69;
3382 cyttsp_fluid_pdata.disp_maxy = 869;
3383 cyttsp_fluid_pdata.correct_fw_ver = 5;
3384 }
3385
3386}
3387
3388static struct i2c_board_info cyttsp_fluid_info[] __initdata = {
3389 {
3390 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
3391 .platform_data = &cyttsp_fluid_pdata,
3392#ifndef CY_USE_TIMER
3393 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3394#endif /* CY_USE_TIMER */
3395 },
3396};
3397
3398static struct i2c_board_info cyttsp_ffa_info[] __initdata = {
3399 {
3400 I2C_BOARD_INFO(CY_I2C_NAME, 0x3b),
3401 .platform_data = &cyttsp_tmg240_pdata,
3402#ifndef CY_USE_TIMER
3403 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3404#endif /* CY_USE_TIMER */
3405 },
3406};
3407#endif
3408
3409static struct regulator *vreg_tmg200;
3410
3411#define TS_PEN_IRQ_GPIO 61
3412static int tmg200_power(int vreg_on)
3413{
3414 int rc = -EINVAL;
3415
3416 if (!vreg_tmg200) {
3417 printk(KERN_ERR "%s: regulator 8058_s3 not found (%d)\n",
3418 __func__, rc);
3419 return rc;
3420 }
3421
3422 rc = vreg_on ? regulator_enable(vreg_tmg200) :
3423 regulator_disable(vreg_tmg200);
3424 if (rc < 0)
3425 printk(KERN_ERR "%s: vreg 8058_s3 %s failed (%d)\n",
3426 __func__, vreg_on ? "enable" : "disable", rc);
3427
3428 /* wait for vregs to stabilize */
Amy Maloche12b5d4e2011-08-03 15:42:28 -07003429 msleep(20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003430
3431 return rc;
3432}
3433
3434static int tmg200_dev_setup(bool enable)
3435{
3436 int rc;
3437
3438 if (enable) {
3439 vreg_tmg200 = regulator_get(NULL, "8058_s3");
3440 if (IS_ERR(vreg_tmg200)) {
3441 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3442 __func__, PTR_ERR(vreg_tmg200));
3443 rc = PTR_ERR(vreg_tmg200);
3444 return rc;
3445 }
3446
3447 rc = regulator_set_voltage(vreg_tmg200, 1800000, 1800000);
3448 if (rc) {
3449 pr_err("%s: regulator_set_voltage() = %d\n",
3450 __func__, rc);
3451 goto reg_put;
3452 }
3453 } else {
3454 /* put voltage sources */
3455 regulator_put(vreg_tmg200);
3456 }
3457 return 0;
3458reg_put:
3459 regulator_put(vreg_tmg200);
3460 return rc;
3461}
3462
3463static struct cy8c_ts_platform_data cy8ctmg200_pdata = {
3464 .ts_name = "msm_tmg200_ts",
3465 .dis_min_x = 0,
3466 .dis_max_x = 1023,
3467 .dis_min_y = 0,
3468 .dis_max_y = 599,
3469 .min_tid = 0,
3470 .max_tid = 255,
3471 .min_touch = 0,
3472 .max_touch = 255,
3473 .min_width = 0,
3474 .max_width = 255,
3475 .power_on = tmg200_power,
3476 .dev_setup = tmg200_dev_setup,
3477 .nfingers = 2,
3478 .irq_gpio = TS_PEN_IRQ_GPIO,
3479 .resout_gpio = GPIO_CAP_TS_RESOUT_N,
3480};
3481
3482static struct i2c_board_info cy8ctmg200_board_info[] = {
3483 {
3484 I2C_BOARD_INFO("cy8ctmg200", 0x2),
3485 .platform_data = &cy8ctmg200_pdata,
3486 }
3487};
3488
Zhang Chang Ken211df572011-07-05 19:16:39 -04003489static struct regulator *vreg_tma340;
3490
3491static int tma340_power(int vreg_on)
3492{
3493 int rc = -EINVAL;
3494
3495 if (!vreg_tma340) {
3496 pr_err("%s: regulator 8901_l2 not found (%d)\n",
3497 __func__, rc);
3498 return rc;
3499 }
3500
3501 rc = vreg_on ? regulator_enable(vreg_tma340) :
3502 regulator_disable(vreg_tma340);
3503 if (rc < 0)
3504 pr_err("%s: vreg 8901_l2 %s failed (%d)\n",
3505 __func__, vreg_on ? "enable" : "disable", rc);
3506
3507 /* wait for vregs to stabilize */
Amy Malocheb5c67e8d2011-08-18 16:39:35 -07003508 msleep(100);
Zhang Chang Ken211df572011-07-05 19:16:39 -04003509
3510 return rc;
3511}
3512
3513static struct kobject *tma340_prop_kobj;
3514
3515static int tma340_dragon_dev_setup(bool enable)
3516{
3517 int rc;
3518
3519 if (enable) {
3520 vreg_tma340 = regulator_get(NULL, "8901_l2");
3521 if (IS_ERR(vreg_tma340)) {
3522 pr_err("%s: regulator get of 8901_l2 failed (%ld)\n",
3523 __func__, PTR_ERR(vreg_tma340));
3524 rc = PTR_ERR(vreg_tma340);
3525 return rc;
3526 }
3527
3528 rc = regulator_set_voltage(vreg_tma340, 3300000, 3300000);
3529 if (rc) {
3530 pr_err("%s: regulator_set_voltage() = %d\n",
3531 __func__, rc);
3532 goto reg_put;
3533 }
3534 tma300_vkeys_attr.attr.name = "virtualkeys.cy8ctma340";
3535 tma340_prop_kobj = kobject_create_and_add("board_properties",
3536 NULL);
3537 if (tma340_prop_kobj) {
3538 rc = sysfs_create_group(tma340_prop_kobj,
3539 &tma300_properties_attr_group);
3540 if (rc) {
3541 kobject_put(tma340_prop_kobj);
3542 pr_err("%s: failed to create board_properties\n",
3543 __func__);
3544 goto reg_put;
3545 }
3546 }
3547
3548 } else {
3549 /* put voltage sources */
3550 regulator_put(vreg_tma340);
3551 /* destroy virtual keys */
3552 if (tma340_prop_kobj) {
3553 sysfs_remove_group(tma340_prop_kobj,
3554 &tma300_properties_attr_group);
3555 kobject_put(tma340_prop_kobj);
3556 }
3557 }
3558 return 0;
3559reg_put:
3560 regulator_put(vreg_tma340);
3561 return rc;
3562}
3563
3564
3565static struct cy8c_ts_platform_data cy8ctma340_dragon_pdata = {
3566 .ts_name = "cy8ctma340",
3567 .dis_min_x = 0,
3568 .dis_max_x = 479,
3569 .dis_min_y = 0,
3570 .dis_max_y = 799,
3571 .min_tid = 0,
3572 .max_tid = 255,
3573 .min_touch = 0,
3574 .max_touch = 255,
3575 .min_width = 0,
3576 .max_width = 255,
3577 .power_on = tma340_power,
3578 .dev_setup = tma340_dragon_dev_setup,
3579 .nfingers = 2,
3580 .irq_gpio = TS_PEN_IRQ_GPIO,
3581 .resout_gpio = -1,
3582};
3583
3584static struct i2c_board_info cy8ctma340_dragon_board_info[] = {
3585 {
3586 I2C_BOARD_INFO("cy8ctma340", 0x24),
3587 .platform_data = &cy8ctma340_dragon_pdata,
3588 }
3589};
3590
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003591#ifdef CONFIG_SERIAL_MSM_HS
3592static int configure_uart_gpios(int on)
3593{
3594 int ret = 0, i;
3595 int uart_gpios[] = {53, 54, 55, 56};
3596 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
3597 if (on) {
3598 ret = msm_gpiomux_get(uart_gpios[i]);
3599 if (unlikely(ret))
3600 break;
3601 } else {
3602 ret = msm_gpiomux_put(uart_gpios[i]);
3603 if (unlikely(ret))
3604 return ret;
3605 }
3606 }
3607 if (ret)
3608 for (; i >= 0; i--)
3609 msm_gpiomux_put(uart_gpios[i]);
3610 return ret;
3611}
3612static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3613 .inject_rx_on_wakeup = 1,
3614 .rx_to_inject = 0xFD,
3615 .gpio_config = configure_uart_gpios,
3616};
3617#endif
3618
3619
3620#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
3621
3622static struct gpio_led gpio_exp_leds_config[] = {
3623 {
3624 .name = "left_led1:green",
3625 .gpio = GPIO_LEFT_LED_1,
3626 .active_low = 1,
3627 .retain_state_suspended = 0,
3628 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3629 },
3630 {
3631 .name = "left_led2:red",
3632 .gpio = GPIO_LEFT_LED_2,
3633 .active_low = 1,
3634 .retain_state_suspended = 0,
3635 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3636 },
3637 {
3638 .name = "left_led3:green",
3639 .gpio = GPIO_LEFT_LED_3,
3640 .active_low = 1,
3641 .retain_state_suspended = 0,
3642 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3643 },
3644 {
3645 .name = "wlan_led:orange",
3646 .gpio = GPIO_LEFT_LED_WLAN,
3647 .active_low = 1,
3648 .retain_state_suspended = 0,
3649 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3650 },
3651 {
3652 .name = "left_led5:green",
3653 .gpio = GPIO_LEFT_LED_5,
3654 .active_low = 1,
3655 .retain_state_suspended = 0,
3656 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3657 },
3658 {
3659 .name = "right_led1:green",
3660 .gpio = GPIO_RIGHT_LED_1,
3661 .active_low = 1,
3662 .retain_state_suspended = 0,
3663 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3664 },
3665 {
3666 .name = "right_led2:red",
3667 .gpio = GPIO_RIGHT_LED_2,
3668 .active_low = 1,
3669 .retain_state_suspended = 0,
3670 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3671 },
3672 {
3673 .name = "right_led3:green",
3674 .gpio = GPIO_RIGHT_LED_3,
3675 .active_low = 1,
3676 .retain_state_suspended = 0,
3677 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3678 },
3679 {
3680 .name = "bt_led:blue",
3681 .gpio = GPIO_RIGHT_LED_BT,
3682 .active_low = 1,
3683 .retain_state_suspended = 0,
3684 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3685 },
3686 {
3687 .name = "right_led5:green",
3688 .gpio = GPIO_RIGHT_LED_5,
3689 .active_low = 1,
3690 .retain_state_suspended = 0,
3691 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3692 },
3693};
3694
3695static struct gpio_led_platform_data gpio_leds_pdata = {
3696 .num_leds = ARRAY_SIZE(gpio_exp_leds_config),
3697 .leds = gpio_exp_leds_config,
3698};
3699
3700static struct platform_device gpio_leds = {
3701 .name = "leds-gpio",
3702 .id = -1,
3703 .dev = {
3704 .platform_data = &gpio_leds_pdata,
3705 },
3706};
3707
3708static struct gpio_led fluid_gpio_leds[] = {
3709 {
3710 .name = "dual_led:green",
3711 .gpio = GPIO_LED1_GREEN_N,
3712 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3713 .active_low = 1,
3714 .retain_state_suspended = 0,
3715 },
3716 {
3717 .name = "dual_led:red",
3718 .gpio = GPIO_LED2_RED_N,
3719 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3720 .active_low = 1,
3721 .retain_state_suspended = 0,
3722 },
3723};
3724
3725static struct gpio_led_platform_data gpio_led_pdata = {
3726 .leds = fluid_gpio_leds,
3727 .num_leds = ARRAY_SIZE(fluid_gpio_leds),
3728};
3729
3730static struct platform_device fluid_leds_gpio = {
3731 .name = "leds-gpio",
3732 .id = -1,
3733 .dev = {
3734 .platform_data = &gpio_led_pdata,
3735 },
3736};
3737
3738#endif
3739
3740#if defined(CONFIG_MSM_RPM_LOG) || defined(CONFIG_MSM_RPM_LOG_MODULE)
3741
3742static struct msm_rpm_log_platform_data msm_rpm_log_pdata = {
3743 .phys_addr_base = 0x00106000,
3744 .reg_offsets = {
3745 [MSM_RPM_LOG_PAGE_INDICES] = 0x00000C80,
3746 [MSM_RPM_LOG_PAGE_BUFFER] = 0x00000CA0,
3747 },
3748 .phys_size = SZ_8K,
3749 .log_len = 4096, /* log's buffer length in bytes */
3750 .log_len_mask = (4096 >> 2) - 1, /* length mask in units of u32 */
3751};
3752
3753static struct platform_device msm_rpm_log_device = {
3754 .name = "msm_rpm_log",
3755 .id = -1,
3756 .dev = {
3757 .platform_data = &msm_rpm_log_pdata,
3758 },
3759};
3760#endif
3761
3762#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,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005104#ifdef CONFIG_I2C_QUP
5105 &msm_gsbi3_qup_i2c_device,
5106 &msm_gsbi4_qup_i2c_device,
5107 &msm_gsbi7_qup_i2c_device,
5108 &msm_gsbi8_qup_i2c_device,
5109 &msm_gsbi9_qup_i2c_device,
5110 &msm_gsbi12_qup_i2c_device,
5111#endif
5112#ifdef CONFIG_SERIAL_MSM_HS
5113 &msm_device_uart_dm1,
5114#endif
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305115#ifdef CONFIG_MSM_SSBI
5116 &msm_device_ssbi_pmic1,
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05305117 &msm_device_ssbi_pmic2,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305118#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005119#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005120 &msm_device_ssbi3,
5121#endif
5122#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
5123 &isp1763_device,
5124#endif
5125
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005126#if defined (CONFIG_MSM_8x60_VOIP)
5127 &asoc_msm_mvs,
5128 &asoc_mvs_dai0,
5129 &asoc_mvs_dai1,
5130#endif
Lei Zhou338cab82011-08-19 13:38:17 -04005131
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005132#if defined(CONFIG_USB_GADGET_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
5133 &msm_device_otg,
5134#endif
5135#ifdef CONFIG_USB_GADGET_MSM_72K
5136 &msm_device_gadget_peripheral,
5137#endif
5138#ifdef CONFIG_USB_G_ANDROID
5139 &android_usb_device,
5140#endif
5141#ifdef CONFIG_BATTERY_MSM
5142 &msm_batt_device,
5143#endif
5144#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005145#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005146 &android_pmem_device,
5147 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005148 &android_pmem_smipool_device,
5149#endif
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005150 &android_pmem_audio_device,
5151#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005152#ifdef CONFIG_MSM_ROTATOR
5153 &msm_rotator_device,
5154#endif
5155 &msm_fb_device,
5156 &msm_kgsl_3d0,
5157 &msm_kgsl_2d0,
5158 &msm_kgsl_2d1,
5159 &lcdc_samsung_panel_device,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005160#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5161 &lcdc_nt35582_panel_device,
5162#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005163#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
5164 &lcdc_samsung_oled_panel_device,
5165#endif
5166#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
5167 &lcdc_auo_wvga_panel_device,
5168#endif
5169#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
5170 &hdmi_msm_device,
5171#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
5172#ifdef CONFIG_FB_MSM_MIPI_DSI
5173 &mipi_dsi_toshiba_panel_device,
5174 &mipi_dsi_novatek_panel_device,
5175#endif
5176#ifdef CONFIG_MSM_CAMERA
5177#ifdef CONFIG_MT9E013
5178 &msm_camera_sensor_mt9e013,
5179#endif
5180#ifdef CONFIG_IMX074
5181 &msm_camera_sensor_imx074,
5182#endif
5183#ifdef CONFIG_WEBCAM_OV7692
5184 &msm_camera_sensor_webcam_ov7692,
5185#endif
5186#ifdef CONFIG_WEBCAM_OV9726
5187 &msm_camera_sensor_webcam_ov9726,
5188#endif
5189#ifdef CONFIG_QS_S5K4E1
5190 &msm_camera_sensor_qs_s5k4e1,
5191#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04005192#ifdef CONFIG_VX6953
5193 &msm_camera_sensor_vx6953,
5194#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005195#endif
5196#ifdef CONFIG_MSM_GEMINI
5197 &msm_gemini_device,
5198#endif
5199#ifdef CONFIG_MSM_VPE
5200 &msm_vpe_device,
5201#endif
5202
5203#if defined(CONFIG_MSM_RPM_LOG) || defined(CONFIG_MSM_RPM_LOG_MODULE)
5204 &msm_rpm_log_device,
5205#endif
5206#if defined(CONFIG_MSM_RPM_STATS_LOG)
5207 &msm_rpm_stat_device,
5208#endif
5209 &msm_device_vidc,
5210#if (defined(CONFIG_MARIMBA_CORE)) && \
5211 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5212 &msm_bt_power_device,
5213#endif
5214#ifdef CONFIG_SENSORS_MSM_ADC
5215 &msm_adc_device,
5216#endif
David Collins6f032ba2011-08-31 14:08:15 -07005217 &rpm_regulator_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005218
5219#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5220 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5221 &qcrypto_device,
5222#endif
5223
5224#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5225 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5226 &qcedev_device,
5227#endif
5228
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005229
5230#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5231#ifdef CONFIG_MSM_USE_TSIF1
5232 &msm_device_tsif[1],
5233#else
5234 &msm_device_tsif[0],
5235#endif /* CONFIG_MSM_USE_TSIF1 */
5236#endif /* CONFIG_TSIF */
5237
5238#ifdef CONFIG_HW_RANDOM_MSM
5239 &msm_device_rng,
5240#endif
5241
5242 &msm_tsens_device,
Praveen Chidambaram043f4ce2011-08-02 09:37:59 -06005243 &msm_rpm_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005244#ifdef CONFIG_ION_MSM
5245 &ion_dev,
5246#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -07005247 &msm8660_device_watchdog,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005248};
5249
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005250#ifdef CONFIG_ION_MSM
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005251static struct ion_platform_data ion_pdata = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005252 .nr = MSM_ION_HEAP_NUM,
5253 .heaps = {
5254 {
5255 .id = ION_HEAP_SYSTEM_ID,
5256 .type = ION_HEAP_TYPE_SYSTEM,
5257 .name = ION_VMALLOC_HEAP_NAME,
5258 },
5259 {
5260 .id = ION_HEAP_SYSTEM_CONTIG_ID,
5261 .type = ION_HEAP_TYPE_SYSTEM_CONTIG,
5262 .name = ION_KMALLOC_HEAP_NAME,
5263 },
5264#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5265 {
5266 .id = ION_HEAP_EBI_ID,
5267 .type = ION_HEAP_TYPE_CARVEOUT,
5268 .name = ION_EBI1_HEAP_NAME,
5269 .size = MSM_ION_EBI_SIZE,
5270 .memory_type = ION_EBI_TYPE,
5271 },
5272 {
5273 .id = ION_HEAP_ADSP_ID,
5274 .type = ION_HEAP_TYPE_CARVEOUT,
5275 .name = ION_ADSP_HEAP_NAME,
5276 .size = MSM_ION_ADSP_SIZE,
5277 .memory_type = ION_EBI_TYPE,
5278 },
5279 {
5280 .id = ION_HEAP_SMI_ID,
5281 .type = ION_HEAP_TYPE_CARVEOUT,
5282 .name = ION_SMI_HEAP_NAME,
5283 .size = MSM_ION_SMI_SIZE,
5284 .memory_type = ION_SMI_TYPE,
5285 },
5286#endif
5287 }
5288};
5289
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005290static struct platform_device ion_dev = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005291 .name = "ion-msm",
5292 .id = 1,
5293 .dev = { .platform_data = &ion_pdata },
5294};
5295#endif
5296
5297
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005298static struct memtype_reserve msm8x60_reserve_table[] __initdata = {
5299 /* Kernel SMI memory pool for video core, used for firmware */
5300 /* and encoder, decoder scratch buffers */
5301 /* Kernel SMI memory pool should always precede the user space */
5302 /* SMI memory pool, as the video core will use offset address */
5303 /* from the Firmware base */
5304 [MEMTYPE_SMI_KERNEL] = {
5305 .start = KERNEL_SMI_BASE,
5306 .limit = KERNEL_SMI_SIZE,
5307 .size = KERNEL_SMI_SIZE,
5308 .flags = MEMTYPE_FLAGS_FIXED,
5309 },
5310 /* User space SMI memory pool for video core */
5311 /* used for encoder, decoder input & output buffers */
5312 [MEMTYPE_SMI] = {
5313 .start = USER_SMI_BASE,
5314 .limit = USER_SMI_SIZE,
5315 .flags = MEMTYPE_FLAGS_FIXED,
5316 },
5317 [MEMTYPE_EBI0] = {
5318 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5319 },
5320 [MEMTYPE_EBI1] = {
5321 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5322 },
5323};
5324
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005325static void reserve_ion_memory(void)
5326{
5327#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
5328 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_EBI_SIZE;
5329 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_ADSP_SIZE;
5330 msm8x60_reserve_table[MEMTYPE_SMI].size += MSM_ION_SMI_SIZE;
5331#endif
5332}
5333
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005334static void __init size_pmem_devices(void)
5335{
5336#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005337#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005338 android_pmem_adsp_pdata.size = pmem_adsp_size;
5339 android_pmem_smipool_pdata.size = MSM_PMEM_SMIPOOL_SIZE;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005340 android_pmem_pdata.size = pmem_sf_size;
5341#endif
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005342 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
5343#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005344}
5345
5346static void __init reserve_memory_for(struct android_pmem_platform_data *p)
5347{
5348 msm8x60_reserve_table[p->memory_type].size += p->size;
5349}
5350
5351static void __init reserve_pmem_memory(void)
5352{
5353#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005354#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005355 reserve_memory_for(&android_pmem_adsp_pdata);
5356 reserve_memory_for(&android_pmem_smipool_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005357 reserve_memory_for(&android_pmem_pdata);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005358#endif
5359 reserve_memory_for(&android_pmem_audio_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005360 msm8x60_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
5361#endif
5362}
5363
Huaibin Yanga5419422011-12-08 23:52:10 -08005364static void __init reserve_mdp_memory(void);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005365
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005366static void __init msm8x60_calculate_reserve_sizes(void)
5367{
5368 size_pmem_devices();
5369 reserve_pmem_memory();
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005370 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -08005371 reserve_mdp_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005372}
5373
5374static int msm8x60_paddr_to_memtype(unsigned int paddr)
5375{
5376 if (paddr >= 0x40000000 && paddr < 0x60000000)
5377 return MEMTYPE_EBI1;
5378 if (paddr >= 0x38000000 && paddr < 0x40000000)
5379 return MEMTYPE_SMI;
5380 return MEMTYPE_NONE;
5381}
5382
5383static struct reserve_info msm8x60_reserve_info __initdata = {
5384 .memtype_reserve_table = msm8x60_reserve_table,
5385 .calculate_reserve_sizes = msm8x60_calculate_reserve_sizes,
5386 .paddr_to_memtype = msm8x60_paddr_to_memtype,
5387};
5388
5389static void __init msm8x60_reserve(void)
5390{
5391 reserve_info = &msm8x60_reserve_info;
5392 msm_reserve();
5393}
5394
5395#define EXT_CHG_VALID_MPP 10
5396#define EXT_CHG_VALID_MPP_2 11
5397
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305398static struct pm8xxx_mpp_init_info isl_mpp[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305399 PM8058_MPP_INIT(EXT_CHG_VALID_MPP, D_INPUT,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305400 PM8058_MPP_DIG_LEVEL_S3, DIN_TO_INT),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305401 PM8058_MPP_INIT(EXT_CHG_VALID_MPP_2, D_BI_DIR,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305402 PM8058_MPP_DIG_LEVEL_S3, BI_PULLUP_10KOHM),
5403};
5404
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005405#ifdef CONFIG_ISL9519_CHARGER
5406static int isl_detection_setup(void)
5407{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305408 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005409
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305410 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5411 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5412 &isl_mpp[i].config);
5413 if (ret) {
5414 pr_err("%s: Config MPP %d of PM8058 failed\n",
5415 __func__, isl_mpp[i].mpp);
5416 return ret;
5417 }
5418 }
5419
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005420 return ret;
5421}
5422
5423static struct isl_platform_data isl_data __initdata = {
5424 .chgcurrent = 700,
5425 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5426 .chg_detection_config = isl_detection_setup,
5427 .max_system_voltage = 4200,
5428 .min_system_voltage = 3200,
5429 .term_current = 120,
5430 .input_current = 2048,
5431};
5432
5433static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
5434 {
5435 I2C_BOARD_INFO("isl9519q", 0x9),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305436 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005437 .platform_data = &isl_data,
5438 },
5439};
5440#endif
5441
5442#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
5443static int smb137b_detection_setup(void)
5444{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305445 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005446
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305447 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5448 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5449 &isl_mpp[i].config);
5450 if (ret) {
5451 pr_err("%s: Config MPP %d of PM8058 failed\n",
5452 __func__, isl_mpp[i].mpp);
5453 return ret;
5454 }
5455 }
5456
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005457 return ret;
5458}
5459
5460static struct smb137b_platform_data smb137b_data __initdata = {
5461 .chg_detection_config = smb137b_detection_setup,
5462 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5463 .batt_mah_rating = 950,
5464};
5465
5466static struct i2c_board_info smb137b_charger_i2c_info[] __initdata = {
5467 {
5468 I2C_BOARD_INFO("smb137b", 0x08),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305469 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005470 .platform_data = &smb137b_data,
5471 },
5472};
5473#endif
5474
5475#ifdef CONFIG_PMIC8058
5476#define PMIC_GPIO_SDC3_DET 22
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305477#define PMIC_GPIO_TOUCH_DISC_INTR 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005478
5479static int pm8058_gpios_init(void)
5480{
5481 int i;
5482 int rc;
5483 struct pm8058_gpio_cfg {
5484 int gpio;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305485 struct pm_gpio cfg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005486 };
5487
5488 struct pm8058_gpio_cfg gpio_cfgs[] = {
5489 { /* FFA ethernet */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305490 PM8058_GPIO_PM_TO_SYS(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005491 {
5492 .direction = PM_GPIO_DIR_IN,
5493 .pull = PM_GPIO_PULL_DN,
5494 .vin_sel = 2,
5495 .function = PM_GPIO_FUNC_NORMAL,
5496 .inv_int_pol = 0,
5497 },
5498 },
5499#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
5500 {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305501 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005502 {
5503 .direction = PM_GPIO_DIR_IN,
5504 .pull = PM_GPIO_PULL_UP_30,
5505 .vin_sel = 2,
5506 .function = PM_GPIO_FUNC_NORMAL,
5507 .inv_int_pol = 0,
5508 },
5509 },
5510#endif
5511 { /* core&surf gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305512 PM8058_GPIO_PM_TO_SYS(UI_INT1_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005513 {
5514 .direction = PM_GPIO_DIR_IN,
5515 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305516 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005517 .function = PM_GPIO_FUNC_NORMAL,
5518 .inv_int_pol = 0,
5519 },
5520 },
5521 { /* docking gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305522 PM8058_GPIO_PM_TO_SYS(UI_INT2_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005523 {
5524 .direction = PM_GPIO_DIR_IN,
5525 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305526 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005527 .function = PM_GPIO_FUNC_NORMAL,
5528 .inv_int_pol = 0,
5529 },
5530 },
5531 { /* FHA/keypad gpio expanders */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305532 PM8058_GPIO_PM_TO_SYS(UI_INT3_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005533 {
5534 .direction = PM_GPIO_DIR_IN,
5535 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305536 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005537 .function = PM_GPIO_FUNC_NORMAL,
5538 .inv_int_pol = 0,
5539 },
5540 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005541 { /* Timpani Reset */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305542 PM8058_GPIO_PM_TO_SYS(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005543 {
5544 .direction = PM_GPIO_DIR_OUT,
5545 .output_value = 1,
5546 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5547 .pull = PM_GPIO_PULL_DN,
5548 .out_strength = PM_GPIO_STRENGTH_HIGH,
5549 .function = PM_GPIO_FUNC_NORMAL,
5550 .vin_sel = 2,
5551 .inv_int_pol = 0,
5552 }
5553 },
5554 { /* PMIC ID interrupt */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305555 PM8058_GPIO_PM_TO_SYS(36),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005556 {
5557 .direction = PM_GPIO_DIR_IN,
Anji jonnalaae745e92011-11-14 18:34:31 +05305558 .pull = PM_GPIO_PULL_NO,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005559 .function = PM_GPIO_FUNC_NORMAL,
5560 .vin_sel = 2,
5561 .inv_int_pol = 0,
5562 }
5563 },
5564 };
5565
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305566#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5567 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305568 struct pm_gpio touchdisc_intr_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305569 .direction = PM_GPIO_DIR_IN,
5570 .pull = PM_GPIO_PULL_UP_1P5,
5571 .vin_sel = 2,
5572 .function = PM_GPIO_FUNC_NORMAL,
5573 };
5574#endif
5575
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005576#if defined(CONFIG_HAPTIC_ISA1200) || \
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305577 defined(CONFIG_HAPTIC_ISA1200_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305578 struct pm_gpio en_hap_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305579 .direction = PM_GPIO_DIR_OUT,
5580 .pull = PM_GPIO_PULL_NO,
5581 .out_strength = PM_GPIO_STRENGTH_HIGH,
5582 .function = PM_GPIO_FUNC_NORMAL,
5583 .inv_int_pol = 0,
5584 .vin_sel = 2,
5585 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5586 .output_value = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005587 };
5588#endif
5589
5590#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5591 struct pm8058_gpio_cfg line_in_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305592 PM8058_GPIO_PM_TO_SYS(18),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005593 {
5594 .direction = PM_GPIO_DIR_IN,
5595 .pull = PM_GPIO_PULL_UP_1P5,
5596 .vin_sel = 2,
5597 .function = PM_GPIO_FUNC_NORMAL,
5598 .inv_int_pol = 0,
5599 }
5600 };
5601#endif
5602
5603#if defined(CONFIG_QS_S5K4E1)
5604 {
5605 struct pm8058_gpio_cfg qs_hc37_cam_pd_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305606 PM8058_GPIO_PM_TO_SYS(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005607 {
5608 .direction = PM_GPIO_DIR_OUT,
5609 .output_value = 0,
5610 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5611 .pull = PM_GPIO_PULL_DN,
5612 .out_strength = PM_GPIO_STRENGTH_HIGH,
5613 .function = PM_GPIO_FUNC_NORMAL,
5614 .vin_sel = 2,
5615 .inv_int_pol = 0,
5616 }
5617 };
5618#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005619#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5620 struct pm8058_gpio_cfg pmic_lcdc_nt35582_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305621 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1),
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005622 {
5623 .direction = PM_GPIO_DIR_OUT,
5624 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5625 .output_value = 1,
5626 .pull = PM_GPIO_PULL_UP_30,
5627 /* 2.9V PM_GPIO_VIN_L2, which gives 2.6V */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305628 .vin_sel = PM8058_GPIO_VIN_L5,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005629 .out_strength = PM_GPIO_STRENGTH_HIGH,
5630 .function = PM_GPIO_FUNC_NORMAL,
5631 .inv_int_pol = 0,
5632 }
5633 };
5634#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005635#if defined(CONFIG_HAPTIC_ISA1200) || \
5636 defined(CONFIG_HAPTIC_ISA1200_MODULE)
5637 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305638 rc = pm8xxx_gpio_config(
5639 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
5640 &en_hap_gpio_cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005641 if (rc < 0) {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305642 pr_err("%s: pmic haptics gpio config failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005643 __func__);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305644 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305645 rc = pm8xxx_gpio_config(
5646 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
5647 &en_hap_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305648 if (rc < 0) {
5649 pr_err("%s: pmic haptics ldo gpio config failed\n",
5650 __func__);
5651 }
5652
5653 }
5654#endif
5655
5656#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5657 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
5658 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
5659 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305660 rc = pm8xxx_gpio_config(
5661 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_TOUCH_DISC_INTR),
5662 &touchdisc_intr_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305663 if (rc < 0) {
5664 pr_err("%s: Touchdisc interrupt gpio config failed\n",
5665 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005666 }
5667 }
5668#endif
5669
5670#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5671 /* Line_in only for 8660 ffa & surf */
5672 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04005673 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005674 machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305675 rc = pm8xxx_gpio_config(line_in_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005676 &line_in_gpio_cfg.cfg);
5677 if (rc < 0) {
5678 pr_err("%s pmic line_in gpio config failed\n",
5679 __func__);
5680 return rc;
5681 }
5682 }
5683#endif
5684
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005685#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5686 if (machine_is_msm8x60_dragon()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305687 rc = pm8xxx_gpio_config(pmic_lcdc_nt35582_gpio_cfg.gpio,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005688 &pmic_lcdc_nt35582_gpio_cfg.cfg);
5689 if (rc < 0) {
5690 pr_err("%s pmic gpio config failed\n", __func__);
5691 return rc;
5692 }
5693 }
5694#endif
5695
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005696#if defined(CONFIG_QS_S5K4E1)
5697 /* qs_cam_hc37_cam_pd only for 8660 fluid qs camera*/
5698 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305699 rc = pm8xxx_gpio_config(qs_hc37_cam_pd_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005700 &qs_hc37_cam_pd_gpio_cfg.cfg);
5701 if (rc < 0) {
5702 pr_err("%s pmic qs_hc37_cam_pd gpio config failed\n",
5703 __func__);
5704 return rc;
5705 }
5706 }
5707 }
5708#endif
5709
5710 for (i = 0; i < ARRAY_SIZE(gpio_cfgs); ++i) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305711 rc = pm8xxx_gpio_config(gpio_cfgs[i].gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005712 &gpio_cfgs[i].cfg);
5713 if (rc < 0) {
5714 pr_err("%s pmic gpio config failed\n",
5715 __func__);
5716 return rc;
5717 }
5718 }
5719
5720 return 0;
5721}
5722
5723static const unsigned int ffa_keymap[] = {
5724 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5725 KEY(0, 1, KEY_UP), /* NAV - UP */
5726 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5727 KEY(0, 3, KEY_VOLUMEUP), /* Shuttle SW_UP */
5728
5729 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5730 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5731 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5732 KEY(1, 3, KEY_VOLUMEDOWN),
5733
5734 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5735
5736 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5737 KEY(4, 1, KEY_UP), /* USER_UP */
5738 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5739 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5740 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5741
5742 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
5743 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5744 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5745 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5746 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5747};
5748
Zhang Chang Ken683be172011-08-10 17:45:34 -04005749static const unsigned int dragon_keymap[] = {
5750 KEY(0, 0, KEY_MENU),
5751 KEY(0, 2, KEY_1),
5752 KEY(0, 3, KEY_4),
5753 KEY(0, 4, KEY_7),
5754
5755 KEY(1, 0, KEY_UP),
5756 KEY(1, 1, KEY_LEFT),
5757 KEY(1, 2, KEY_DOWN),
5758 KEY(1, 3, KEY_5),
5759 KEY(1, 4, KEY_8),
5760
5761 KEY(2, 0, KEY_HOME),
5762 KEY(2, 1, KEY_REPLY),
5763 KEY(2, 2, KEY_2),
5764 KEY(2, 3, KEY_6),
5765 KEY(2, 4, KEY_0),
5766
5767 KEY(3, 0, KEY_VOLUMEUP),
5768 KEY(3, 1, KEY_RIGHT),
5769 KEY(3, 2, KEY_3),
5770 KEY(3, 3, KEY_9),
5771 KEY(3, 4, KEY_SWITCHVIDEOMODE),
5772
5773 KEY(4, 0, KEY_VOLUMEDOWN),
5774 KEY(4, 1, KEY_BACK),
5775 KEY(4, 2, KEY_CAMERA),
5776 KEY(4, 3, KEY_KBDILLUMTOGGLE),
5777};
5778
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005779static struct matrix_keymap_data ffa_keymap_data = {
5780 .keymap_size = ARRAY_SIZE(ffa_keymap),
5781 .keymap = ffa_keymap,
5782};
5783
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305784static struct pm8xxx_keypad_platform_data ffa_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005785 .input_name = "ffa-keypad",
5786 .input_phys_device = "ffa-keypad/input0",
5787 .num_rows = 6,
5788 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305789 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5790 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5791 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005792 .scan_delay_ms = 32,
5793 .row_hold_ns = 91500,
5794 .wakeup = 1,
5795 .keymap_data = &ffa_keymap_data,
5796};
5797
Zhang Chang Ken683be172011-08-10 17:45:34 -04005798static struct matrix_keymap_data dragon_keymap_data = {
5799 .keymap_size = ARRAY_SIZE(dragon_keymap),
5800 .keymap = dragon_keymap,
5801};
5802
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305803static struct pm8xxx_keypad_platform_data dragon_keypad_data = {
Zhang Chang Ken683be172011-08-10 17:45:34 -04005804 .input_name = "dragon-keypad",
5805 .input_phys_device = "dragon-keypad/input0",
5806 .num_rows = 6,
5807 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305808 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5809 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5810 .debounce_ms = 15,
Zhang Chang Ken683be172011-08-10 17:45:34 -04005811 .scan_delay_ms = 32,
5812 .row_hold_ns = 91500,
5813 .wakeup = 1,
5814 .keymap_data = &dragon_keymap_data,
5815};
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305816
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005817static const unsigned int fluid_keymap[] = {
5818 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5819 KEY(0, 1, KEY_UP), /* NAV - UP */
5820 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5821 KEY(0, 3, KEY_VOLUMEDOWN), /* Shuttle SW_UP */
5822
5823 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5824 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5825 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5826 KEY(1, 3, KEY_VOLUMEUP),
5827
5828 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5829
5830 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5831 KEY(4, 1, KEY_UP), /* USER_UP */
5832 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5833 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5834 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5835
Jilai Wang9a895102011-07-12 14:00:35 -04005836 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005837 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5838 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5839 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5840 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5841};
5842
5843static struct matrix_keymap_data fluid_keymap_data = {
5844 .keymap_size = ARRAY_SIZE(fluid_keymap),
5845 .keymap = fluid_keymap,
5846};
5847
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305848static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005849 .input_name = "fluid-keypad",
5850 .input_phys_device = "fluid-keypad/input0",
5851 .num_rows = 6,
5852 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305853 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5854 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5855 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005856 .scan_delay_ms = 32,
5857 .row_hold_ns = 91500,
5858 .wakeup = 1,
5859 .keymap_data = &fluid_keymap_data,
5860};
5861
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305862static struct pm8xxx_vibrator_platform_data pm8058_vib_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005863 .initial_vibrate_ms = 500,
5864 .level_mV = 3000,
5865 .max_timeout_ms = 15000,
5866};
5867
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305868static struct pm8xxx_rtc_platform_data pm8058_rtc_pdata = {
5869 .rtc_write_enable = false,
5870 .rtc_alarm_powerup = false,
5871};
5872
5873static struct pm8xxx_pwrkey_platform_data pm8058_pwrkey_pdata = {
5874 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -08005875 .kpd_trigger_delay_us = 15625,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305876 .wakeup = 1,
5877};
5878
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005879#define PM8058_LINE_IN_DET_GPIO PM8058_GPIO_PM_TO_SYS(18)
5880
5881static struct othc_accessory_info othc_accessories[] = {
5882 {
5883 .accessory = OTHC_SVIDEO_OUT,
5884 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT
5885 | OTHC_ADC_DETECT,
5886 .key_code = SW_VIDEOOUT_INSERT,
5887 .enabled = false,
5888 .adc_thres = {
5889 .min_threshold = 20,
5890 .max_threshold = 40,
5891 },
5892 },
5893 {
5894 .accessory = OTHC_ANC_HEADPHONE,
5895 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT |
5896 OTHC_SWITCH_DETECT,
5897 .gpio = PM8058_LINE_IN_DET_GPIO,
5898 .active_low = 1,
5899 .key_code = SW_HEADPHONE_INSERT,
5900 .enabled = true,
5901 },
5902 {
5903 .accessory = OTHC_ANC_HEADSET,
5904 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT,
5905 .gpio = PM8058_LINE_IN_DET_GPIO,
5906 .active_low = 1,
5907 .key_code = SW_HEADPHONE_INSERT,
5908 .enabled = true,
5909 },
5910 {
5911 .accessory = OTHC_HEADPHONE,
5912 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT,
5913 .key_code = SW_HEADPHONE_INSERT,
5914 .enabled = true,
5915 },
5916 {
5917 .accessory = OTHC_MICROPHONE,
5918 .detect_flags = OTHC_GPIO_DETECT,
5919 .gpio = PM8058_LINE_IN_DET_GPIO,
5920 .active_low = 1,
5921 .key_code = SW_MICROPHONE_INSERT,
5922 .enabled = true,
5923 },
5924 {
5925 .accessory = OTHC_HEADSET,
5926 .detect_flags = OTHC_MICBIAS_DETECT,
5927 .key_code = SW_HEADPHONE_INSERT,
5928 .enabled = true,
5929 },
5930};
5931
5932static struct othc_switch_info switch_info[] = {
5933 {
5934 .min_adc_threshold = 0,
5935 .max_adc_threshold = 100,
5936 .key_code = KEY_PLAYPAUSE,
5937 },
5938 {
5939 .min_adc_threshold = 100,
5940 .max_adc_threshold = 200,
5941 .key_code = KEY_REWIND,
5942 },
5943 {
5944 .min_adc_threshold = 200,
5945 .max_adc_threshold = 500,
5946 .key_code = KEY_FASTFORWARD,
5947 },
5948};
5949
5950static struct othc_n_switch_config switch_config = {
5951 .voltage_settling_time_ms = 0,
5952 .num_adc_samples = 3,
5953 .adc_channel = CHANNEL_ADC_HDSET,
5954 .switch_info = switch_info,
5955 .num_keys = ARRAY_SIZE(switch_info),
5956 .default_sw_en = true,
5957 .default_sw_idx = 0,
5958};
5959
5960static struct hsed_bias_config hsed_bias_config = {
5961 /* HSED mic bias config info */
5962 .othc_headset = OTHC_HEADSET_NO,
5963 .othc_lowcurr_thresh_uA = 100,
5964 .othc_highcurr_thresh_uA = 600,
5965 .othc_hyst_prediv_us = 7800,
5966 .othc_period_clkdiv_us = 62500,
5967 .othc_hyst_clk_us = 121000,
5968 .othc_period_clk_us = 312500,
5969 .othc_wakeup = 1,
5970};
5971
5972static struct othc_hsed_config hsed_config_1 = {
5973 .hsed_bias_config = &hsed_bias_config,
5974 /*
5975 * The detection delay and switch reporting delay are
5976 * required to encounter a hardware bug (spurious switch
5977 * interrupts on slow insertion/removal of the headset).
5978 * This will introduce a delay in reporting the accessory
5979 * insertion and removal to the userspace.
5980 */
5981 .detection_delay_ms = 1500,
5982 /* Switch info */
5983 .switch_debounce_ms = 1500,
5984 .othc_support_n_switch = false,
5985 .switch_config = &switch_config,
5986 .ir_gpio = -1,
5987 /* Accessory info */
5988 .accessories_support = true,
5989 .accessories = othc_accessories,
5990 .othc_num_accessories = ARRAY_SIZE(othc_accessories),
5991};
5992
5993static struct othc_regulator_config othc_reg = {
5994 .regulator = "8058_l5",
5995 .max_uV = 2850000,
5996 .min_uV = 2850000,
5997};
5998
5999/* MIC_BIAS0 is configured as normal MIC BIAS */
6000static struct pmic8058_othc_config_pdata othc_config_pdata_0 = {
6001 .micbias_select = OTHC_MICBIAS_0,
6002 .micbias_capability = OTHC_MICBIAS,
6003 .micbias_enable = OTHC_SIGNAL_OFF,
6004 .micbias_regulator = &othc_reg,
6005};
6006
6007/* MIC_BIAS1 is configured as HSED_BIAS for OTHC */
6008static struct pmic8058_othc_config_pdata othc_config_pdata_1 = {
6009 .micbias_select = OTHC_MICBIAS_1,
6010 .micbias_capability = OTHC_MICBIAS_HSED,
6011 .micbias_enable = OTHC_SIGNAL_PWM_TCXO,
6012 .micbias_regulator = &othc_reg,
6013 .hsed_config = &hsed_config_1,
6014 .hsed_name = "8660_handset",
6015};
6016
6017/* MIC_BIAS2 is configured as normal MIC BIAS */
6018static struct pmic8058_othc_config_pdata othc_config_pdata_2 = {
6019 .micbias_select = OTHC_MICBIAS_2,
6020 .micbias_capability = OTHC_MICBIAS,
6021 .micbias_enable = OTHC_SIGNAL_OFF,
6022 .micbias_regulator = &othc_reg,
6023};
6024
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006025
6026static void __init msm8x60_init_pm8058_othc(void)
6027{
6028 int i;
6029
6030 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 ||
6031 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
6032 machine_is_msm8x60_fusn_ffa()) {
6033 /* 3-switch headset supported only by V2 FFA and FLUID */
6034 hsed_config_1.accessories_adc_support = true,
6035 /* ADC based accessory detection works only on V2 and FLUID */
6036 hsed_config_1.accessories_adc_channel = CHANNEL_ADC_HDSET,
6037 hsed_config_1.othc_support_n_switch = true;
6038 }
6039
6040 /* IR GPIO is absent on FLUID */
6041 if (machine_is_msm8x60_fluid())
6042 hsed_config_1.ir_gpio = -1;
6043
6044 for (i = 0; i < ARRAY_SIZE(othc_accessories); i++) {
6045 if (machine_is_msm8x60_fluid()) {
6046 switch (othc_accessories[i].accessory) {
6047 case OTHC_ANC_HEADPHONE:
6048 case OTHC_ANC_HEADSET:
6049 othc_accessories[i].gpio = GPIO_HEADSET_DET_N;
6050 break;
6051 case OTHC_MICROPHONE:
6052 othc_accessories[i].enabled = false;
6053 break;
6054 case OTHC_SVIDEO_OUT:
6055 othc_accessories[i].enabled = true;
6056 hsed_config_1.video_out_gpio = GPIO_HS_SW_DIR;
6057 break;
6058 }
6059 }
6060 }
6061}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006062
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006063
6064static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
6065{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306066 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006067 .direction = PM_GPIO_DIR_OUT,
6068 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
6069 .output_value = 0,
6070 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306071 .vin_sel = PM8058_GPIO_VIN_VPH,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006072 .out_strength = PM_GPIO_STRENGTH_HIGH,
6073 .function = PM_GPIO_FUNC_2,
6074 };
6075
6076 int rc = -EINVAL;
6077 int id, mode, max_mA;
6078
6079 id = mode = max_mA = 0;
6080 switch (ch) {
6081 case 0:
6082 case 1:
6083 case 2:
6084 if (on) {
6085 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306086 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
6087 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006088 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306089 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006090 __func__, id, rc);
6091 }
6092 break;
6093
6094 case 6:
6095 id = PM_PWM_LED_FLASH;
6096 mode = PM_PWM_CONF_PWM1;
6097 max_mA = 300;
6098 break;
6099
6100 case 7:
6101 id = PM_PWM_LED_FLASH1;
6102 mode = PM_PWM_CONF_PWM1;
6103 max_mA = 300;
6104 break;
6105
6106 default:
6107 break;
6108 }
6109
6110 if (ch >= 6 && ch <= 7) {
6111 if (!on) {
6112 mode = PM_PWM_CONF_NONE;
6113 max_mA = 0;
6114 }
6115 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
6116 if (rc)
6117 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
6118 __func__, ch, rc);
6119 }
6120 return rc;
6121
6122}
6123
6124static struct pm8058_pwm_pdata pm8058_pwm_data = {
6125 .config = pm8058_pwm_config,
6126};
6127
6128#define PM8058_GPIO_INT 88
6129
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006130static struct pmic8058_led pmic8058_flash_leds[] = {
6131 [0] = {
6132 .name = "camera:flash0",
6133 .max_brightness = 15,
6134 .id = PMIC8058_ID_FLASH_LED_0,
6135 },
6136 [1] = {
6137 .name = "camera:flash1",
6138 .max_brightness = 15,
6139 .id = PMIC8058_ID_FLASH_LED_1,
6140 },
6141};
6142
6143static struct pmic8058_leds_platform_data pm8058_flash_leds_data = {
6144 .num_leds = ARRAY_SIZE(pmic8058_flash_leds),
6145 .leds = pmic8058_flash_leds,
6146};
6147
Terence Hampsonc0b6dfb2011-07-15 11:07:17 -04006148static struct pmic8058_led pmic8058_dragon_leds[] = {
6149 [0] = {
6150 /* RED */
6151 .name = "led_drv0",
6152 .max_brightness = 15,
6153 .id = PMIC8058_ID_LED_0,
6154 },/* 300 mA flash led0 drv sink */
6155 [1] = {
6156 /* Yellow */
6157 .name = "led_drv1",
6158 .max_brightness = 15,
6159 .id = PMIC8058_ID_LED_1,
6160 },/* 300 mA flash led0 drv sink */
6161 [2] = {
6162 /* Green */
6163 .name = "led_drv2",
6164 .max_brightness = 15,
6165 .id = PMIC8058_ID_LED_2,
6166 },/* 300 mA flash led0 drv sink */
6167 [3] = {
6168 .name = "led_psensor",
6169 .max_brightness = 15,
6170 .id = PMIC8058_ID_LED_KB_LIGHT,
6171 },/* 300 mA flash led0 drv sink */
6172};
6173
6174static struct pmic8058_leds_platform_data pm8058_dragon_leds_data = {
6175 .num_leds = ARRAY_SIZE(pmic8058_dragon_leds),
6176 .leds = pmic8058_dragon_leds,
6177};
6178
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006179static struct pmic8058_led pmic8058_fluid_flash_leds[] = {
6180 [0] = {
6181 .name = "led:drv0",
6182 .max_brightness = 15,
6183 .id = PMIC8058_ID_FLASH_LED_0,
6184 },/* 300 mA flash led0 drv sink */
6185 [1] = {
6186 .name = "led:drv1",
6187 .max_brightness = 15,
6188 .id = PMIC8058_ID_FLASH_LED_1,
6189 },/* 300 mA flash led1 sink */
6190 [2] = {
6191 .name = "led:drv2",
6192 .max_brightness = 20,
6193 .id = PMIC8058_ID_LED_0,
6194 },/* 40 mA led0 sink */
6195 [3] = {
6196 .name = "keypad:drv",
6197 .max_brightness = 15,
6198 .id = PMIC8058_ID_LED_KB_LIGHT,
6199 },/* 300 mA keypad drv sink */
6200};
6201
6202static struct pmic8058_leds_platform_data pm8058_fluid_flash_leds_data = {
6203 .num_leds = ARRAY_SIZE(pmic8058_fluid_flash_leds),
6204 .leds = pmic8058_fluid_flash_leds,
6205};
6206
Terence Hampson90508a92011-08-09 10:40:08 -04006207static struct pmic8058_charger_data pmic8058_charger_dragon = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306208 .charger_data_valid = true,
Terence Hampson90508a92011-08-09 10:40:08 -04006209 .max_source_current = 1800,
6210 .charger_type = CHG_TYPE_AC,
6211};
6212
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306213static struct pmic8058_charger_data pmic8058_charger_ffa_surf = {
6214 .charger_data_valid = false,
6215};
6216
6217static struct pm8xxx_misc_platform_data pm8058_misc_pdata = {
6218 .priority = 0,
6219};
6220
6221static struct pm8xxx_irq_platform_data pm8058_irq_pdata = {
6222 .irq_base = PM8058_IRQ_BASE,
6223 .devirq = MSM_GPIO_TO_INT(PM8058_GPIO_INT),
6224 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6225};
6226
6227static struct pm8xxx_gpio_platform_data pm8058_gpio_pdata = {
6228 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
6229};
6230
6231static struct pm8xxx_mpp_platform_data pm8058_mpp_pdata = {
6232 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006233};
6234
6235static struct pm8058_platform_data pm8058_platform_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306236 .irq_pdata = &pm8058_irq_pdata,
6237 .gpio_pdata = &pm8058_gpio_pdata,
6238 .mpp_pdata = &pm8058_mpp_pdata,
6239 .rtc_pdata = &pm8058_rtc_pdata,
6240 .pwrkey_pdata = &pm8058_pwrkey_pdata,
6241 .othc0_pdata = &othc_config_pdata_0,
6242 .othc1_pdata = &othc_config_pdata_1,
6243 .othc2_pdata = &othc_config_pdata_2,
6244 .pwm_pdata = &pm8058_pwm_data,
6245 .misc_pdata = &pm8058_misc_pdata,
6246#ifdef CONFIG_SENSORS_MSM_ADC
6247 .xoadc_pdata = &pm8058_xoadc_pdata,
6248#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006249};
6250
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306251#ifdef CONFIG_MSM_SSBI
6252static struct msm_ssbi_platform_data msm8x60_ssbi_pm8058_pdata __devinitdata = {
6253 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6254 .slave = {
6255 .name = "pm8058-core",
6256 .platform_data = &pm8058_platform_data,
6257 },
6258};
6259#endif
6260#endif /* CONFIG_PMIC8058 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006261
6262#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
6263 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
6264#define TDISC_I2C_SLAVE_ADDR 0x67
6265#define PMIC_GPIO_TDISC PM8058_GPIO_PM_TO_SYS(5)
6266#define TDISC_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 5)
6267
6268static const char *vregs_tdisc_name[] = {
6269 "8058_l5",
6270 "8058_s3",
6271};
6272
6273static const int vregs_tdisc_val[] = {
6274 2850000,/* uV */
6275 1800000,
6276};
6277static struct regulator *vregs_tdisc[ARRAY_SIZE(vregs_tdisc_name)];
6278
6279static int tdisc_shinetsu_setup(void)
6280{
6281 int rc, i;
6282
6283 rc = gpio_request(PMIC_GPIO_TDISC, "tdisc_interrupt");
6284 if (rc) {
6285 pr_err("%s: gpio_request failed for PMIC_GPIO_TDISC\n",
6286 __func__);
6287 return rc;
6288 }
6289
6290 rc = gpio_request(GPIO_JOYSTICK_EN, "tdisc_oe");
6291 if (rc) {
6292 pr_err("%s: gpio_request failed for GPIO_JOYSTICK_EN\n",
6293 __func__);
6294 goto fail_gpio_oe;
6295 }
6296
6297 rc = gpio_direction_output(GPIO_JOYSTICK_EN, 1);
6298 if (rc) {
6299 pr_err("%s: gpio_direction_output failed for GPIO_JOYSTICK_EN\n",
6300 __func__);
6301 gpio_free(GPIO_JOYSTICK_EN);
6302 goto fail_gpio_oe;
6303 }
6304
6305 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6306 vregs_tdisc[i] = regulator_get(NULL, vregs_tdisc_name[i]);
6307 if (IS_ERR(vregs_tdisc[i])) {
6308 printk(KERN_ERR "%s: regulator get %s failed (%ld)\n",
6309 __func__, vregs_tdisc_name[i],
6310 PTR_ERR(vregs_tdisc[i]));
6311 rc = PTR_ERR(vregs_tdisc[i]);
6312 goto vreg_get_fail;
6313 }
6314
6315 rc = regulator_set_voltage(vregs_tdisc[i],
6316 vregs_tdisc_val[i], vregs_tdisc_val[i]);
6317 if (rc) {
6318 printk(KERN_ERR "%s: regulator_set_voltage() = %d\n",
6319 __func__, rc);
6320 goto vreg_set_voltage_fail;
6321 }
6322 }
6323
6324 return rc;
6325vreg_set_voltage_fail:
6326 i++;
6327vreg_get_fail:
6328 while (i)
6329 regulator_put(vregs_tdisc[--i]);
6330fail_gpio_oe:
6331 gpio_free(PMIC_GPIO_TDISC);
6332 return rc;
6333}
6334
6335static void tdisc_shinetsu_release(void)
6336{
6337 int i;
6338
6339 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++)
6340 regulator_put(vregs_tdisc[i]);
6341
6342 gpio_free(PMIC_GPIO_TDISC);
6343 gpio_free(GPIO_JOYSTICK_EN);
6344}
6345
6346static int tdisc_shinetsu_enable(void)
6347{
6348 int i, rc = -EINVAL;
6349
6350 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6351 rc = regulator_enable(vregs_tdisc[i]);
6352 if (rc < 0) {
6353 printk(KERN_ERR "%s: vreg %s enable failed (%d)\n",
6354 __func__, vregs_tdisc_name[i], rc);
6355 goto vreg_fail;
6356 }
6357 }
6358
6359 /* Enable the OE (output enable) gpio */
6360 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 1);
6361 /* voltage and gpio stabilization delay */
6362 msleep(50);
6363
6364 return 0;
6365vreg_fail:
6366 while (i)
6367 regulator_disable(vregs_tdisc[--i]);
6368 return rc;
6369}
6370
6371static int tdisc_shinetsu_disable(void)
6372{
6373 int i, rc;
6374
6375 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6376 rc = regulator_disable(vregs_tdisc[i]);
6377 if (rc < 0) {
6378 printk(KERN_ERR "%s: vreg %s disable failed (%d)\n",
6379 __func__, vregs_tdisc_name[i], rc);
6380 goto tdisc_reg_fail;
6381 }
6382 }
6383
6384 /* Disable the OE (output enable) gpio */
6385 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 0);
6386
6387 return 0;
6388
6389tdisc_reg_fail:
6390 while (i)
6391 regulator_enable(vregs_tdisc[--i]);
6392 return rc;
6393}
6394
6395static struct tdisc_abs_values tdisc_abs = {
6396 .x_max = 32,
6397 .y_max = 32,
6398 .x_min = -32,
6399 .y_min = -32,
6400 .pressure_max = 32,
6401 .pressure_min = 0,
6402};
6403
6404static struct tdisc_platform_data tdisc_data = {
6405 .tdisc_setup = tdisc_shinetsu_setup,
6406 .tdisc_release = tdisc_shinetsu_release,
6407 .tdisc_enable = tdisc_shinetsu_enable,
6408 .tdisc_disable = tdisc_shinetsu_disable,
6409 .tdisc_wakeup = 0,
6410 .tdisc_gpio = PMIC_GPIO_TDISC,
6411 .tdisc_report_keys = true,
6412 .tdisc_report_relative = true,
6413 .tdisc_report_absolute = false,
6414 .tdisc_report_wheel = false,
6415 .tdisc_reverse_x = false,
6416 .tdisc_reverse_y = true,
6417 .tdisc_abs = &tdisc_abs,
6418};
6419
6420static struct i2c_board_info msm_i2c_gsbi3_tdisc_info[] = {
6421 {
6422 I2C_BOARD_INFO("vtd518", TDISC_I2C_SLAVE_ADDR),
6423 .irq = TDISC_INT,
6424 .platform_data = &tdisc_data,
6425 },
6426};
6427#endif
6428
6429#define PM_GPIO_CDC_RST_N 20
6430#define GPIO_CDC_RST_N PM8058_GPIO_PM_TO_SYS(PM_GPIO_CDC_RST_N)
6431
6432static struct regulator *vreg_timpani_1;
6433static struct regulator *vreg_timpani_2;
6434
6435static unsigned int msm_timpani_setup_power(void)
6436{
6437 int rc;
6438
6439 vreg_timpani_1 = regulator_get(NULL, "8058_l0");
6440 if (IS_ERR(vreg_timpani_1)) {
6441 pr_err("%s: Unable to get 8058_l0\n", __func__);
6442 return -ENODEV;
6443 }
6444
6445 vreg_timpani_2 = regulator_get(NULL, "8058_s3");
6446 if (IS_ERR(vreg_timpani_2)) {
6447 pr_err("%s: Unable to get 8058_s3\n", __func__);
6448 regulator_put(vreg_timpani_1);
6449 return -ENODEV;
6450 }
6451
6452 rc = regulator_set_voltage(vreg_timpani_1, 1200000, 1200000);
6453 if (rc) {
6454 pr_err("%s: unable to set L0 voltage to 1.2V\n", __func__);
6455 goto fail;
6456 }
6457
6458 rc = regulator_set_voltage(vreg_timpani_2, 1800000, 1800000);
6459 if (rc) {
6460 pr_err("%s: unable to set S3 voltage to 1.8V\n", __func__);
6461 goto fail;
6462 }
6463
6464 rc = regulator_enable(vreg_timpani_1);
6465 if (rc) {
6466 pr_err("%s: Enable regulator 8058_l0 failed\n", __func__);
6467 goto fail;
6468 }
6469
6470 /* The settings for LDO0 should be set such that
6471 * it doesn't require to reset the timpani. */
6472 rc = regulator_set_optimum_mode(vreg_timpani_1, 5000);
6473 if (rc < 0) {
6474 pr_err("Timpani regulator optimum mode setting failed\n");
6475 goto fail;
6476 }
6477
6478 rc = regulator_enable(vreg_timpani_2);
6479 if (rc) {
6480 pr_err("%s: Enable regulator 8058_s3 failed\n", __func__);
6481 regulator_disable(vreg_timpani_1);
6482 goto fail;
6483 }
6484
6485 rc = gpio_request(GPIO_CDC_RST_N, "CDC_RST_N");
6486 if (rc) {
6487 pr_err("%s: GPIO Request %d failed\n", __func__,
6488 GPIO_CDC_RST_N);
6489 regulator_disable(vreg_timpani_1);
6490 regulator_disable(vreg_timpani_2);
6491 goto fail;
6492 } else {
6493 gpio_direction_output(GPIO_CDC_RST_N, 1);
6494 usleep_range(1000, 1050);
6495 gpio_direction_output(GPIO_CDC_RST_N, 0);
6496 usleep_range(1000, 1050);
6497 gpio_direction_output(GPIO_CDC_RST_N, 1);
6498 gpio_free(GPIO_CDC_RST_N);
6499 }
6500 return rc;
6501
6502fail:
6503 regulator_put(vreg_timpani_1);
6504 regulator_put(vreg_timpani_2);
6505 return rc;
6506}
6507
6508static void msm_timpani_shutdown_power(void)
6509{
6510 int rc;
6511
6512 rc = regulator_disable(vreg_timpani_1);
6513 if (rc)
6514 pr_err("%s: Disable regulator 8058_l0 failed\n", __func__);
6515
6516 regulator_put(vreg_timpani_1);
6517
6518 rc = regulator_disable(vreg_timpani_2);
6519 if (rc)
6520 pr_err("%s: Disable regulator 8058_s3 failed\n", __func__);
6521
6522 regulator_put(vreg_timpani_2);
6523}
6524
6525/* Power analog function of codec */
6526static struct regulator *vreg_timpani_cdc_apwr;
6527static int msm_timpani_codec_power(int vreg_on)
6528{
6529 int rc = 0;
6530
6531 if (!vreg_timpani_cdc_apwr) {
6532
6533 vreg_timpani_cdc_apwr = regulator_get(NULL, "8058_s4");
6534
6535 if (IS_ERR(vreg_timpani_cdc_apwr)) {
6536 pr_err("%s: vreg_get failed (%ld)\n",
6537 __func__, PTR_ERR(vreg_timpani_cdc_apwr));
6538 rc = PTR_ERR(vreg_timpani_cdc_apwr);
6539 return rc;
6540 }
6541 }
6542
6543 if (vreg_on) {
6544
6545 rc = regulator_set_voltage(vreg_timpani_cdc_apwr,
6546 2200000, 2200000);
6547 if (rc) {
6548 pr_err("%s: unable to set 8058_s4 voltage to 2.2 V\n",
6549 __func__);
6550 goto vreg_fail;
6551 }
6552
6553 rc = regulator_enable(vreg_timpani_cdc_apwr);
6554 if (rc) {
6555 pr_err("%s: vreg_enable failed %d\n", __func__, rc);
6556 goto vreg_fail;
6557 }
6558 } else {
6559 rc = regulator_disable(vreg_timpani_cdc_apwr);
6560 if (rc) {
6561 pr_err("%s: vreg_disable failed %d\n",
6562 __func__, rc);
6563 goto vreg_fail;
6564 }
6565 }
6566
6567 return 0;
6568
6569vreg_fail:
6570 regulator_put(vreg_timpani_cdc_apwr);
6571 vreg_timpani_cdc_apwr = NULL;
6572 return rc;
6573}
6574
6575static struct marimba_codec_platform_data timpani_codec_pdata = {
6576 .marimba_codec_power = msm_timpani_codec_power,
6577};
6578
6579#define TIMPANI_SLAVE_ID_CDC_ADDR 0X77
6580#define TIMPANI_SLAVE_ID_QMEMBIST_ADDR 0X66
6581
6582static struct marimba_platform_data timpani_pdata = {
6583 .slave_id[MARIMBA_SLAVE_ID_CDC] = TIMPANI_SLAVE_ID_CDC_ADDR,
6584 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = TIMPANI_SLAVE_ID_QMEMBIST_ADDR,
6585 .marimba_setup = msm_timpani_setup_power,
6586 .marimba_shutdown = msm_timpani_shutdown_power,
6587 .codec = &timpani_codec_pdata,
6588 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6589};
6590
6591#define TIMPANI_I2C_SLAVE_ADDR 0xD
6592
6593static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
6594 {
6595 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
6596 .platform_data = &timpani_pdata,
6597 },
6598};
6599
Lei Zhou338cab82011-08-19 13:38:17 -04006600#ifdef CONFIG_SND_SOC_WM8903
6601static struct wm8903_platform_data wm8903_pdata = {
6602 .gpio_cfg[2] = 0x3A8,
6603};
6604
6605#define WM8903_I2C_SLAVE_ADDR 0x34
6606static struct i2c_board_info wm8903_codec_i2c_info[] = {
6607 {
6608 I2C_BOARD_INFO("wm8903", WM8903_I2C_SLAVE_ADDR >> 1),
6609 .platform_data = &wm8903_pdata,
6610 },
6611};
6612#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006613#ifdef CONFIG_PMIC8901
6614
6615#define PM8901_GPIO_INT 91
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006616/*
6617 * Consumer specific regulator names:
6618 * regulator name consumer dev_name
6619 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006620static struct regulator_consumer_supply vreg_consumers_8901_USB_OTG[] = {
6621 REGULATOR_SUPPLY("8901_usb_otg", NULL),
6622};
6623static struct regulator_consumer_supply vreg_consumers_8901_HDMI_MVS[] = {
6624 REGULATOR_SUPPLY("8901_hdmi_mvs", NULL),
6625};
6626
6627#define PM8901_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306628 _always_on) \
6629 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006630 .init_data = { \
6631 .constraints = { \
6632 .valid_modes_mask = _modes, \
6633 .valid_ops_mask = _ops, \
6634 .min_uV = _min_uV, \
6635 .max_uV = _max_uV, \
6636 .input_uV = _min_uV, \
6637 .apply_uV = _apply_uV, \
6638 .always_on = _always_on, \
6639 }, \
6640 .consumer_supplies = vreg_consumers_8901_##_id, \
6641 .num_consumer_supplies = \
6642 ARRAY_SIZE(vreg_consumers_8901_##_id), \
6643 }, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306644 .id = PM8901_VREG_ID_##_id, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006645 }
6646
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006647#define PM8901_VREG_INIT_VS(_id) \
6648 PM8901_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306649 REGULATOR_CHANGE_STATUS, 0, 0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006650
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306651static struct pm8901_vreg_pdata pm8901_vreg_init[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006652 PM8901_VREG_INIT_VS(USB_OTG),
6653 PM8901_VREG_INIT_VS(HDMI_MVS),
6654};
6655
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306656static struct pm8xxx_misc_platform_data pm8901_misc_pdata = {
6657 .priority = 1,
6658};
6659
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306660static struct pm8xxx_irq_platform_data pm8901_irq_pdata = {
6661 .irq_base = PM8901_IRQ_BASE,
6662 .devirq = MSM_GPIO_TO_INT(PM8901_GPIO_INT),
6663 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6664};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006665
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306666static struct pm8xxx_mpp_platform_data pm8901_mpp_pdata = {
6667 .mpp_base = PM8901_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006668};
6669
6670static struct pm8901_platform_data pm8901_platform_data = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306671 .irq_pdata = &pm8901_irq_pdata,
6672 .mpp_pdata = &pm8901_mpp_pdata,
6673 .regulator_pdatas = pm8901_vreg_init,
6674 .num_regulators = ARRAY_SIZE(pm8901_vreg_init),
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306675 .misc_pdata = &pm8901_misc_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006676};
6677
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05306678static struct msm_ssbi_platform_data msm8x60_ssbi_pm8901_pdata __devinitdata = {
6679 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6680 .slave = {
6681 .name = "pm8901-core",
6682 .platform_data = &pm8901_platform_data,
6683 },
6684};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006685#endif /* CONFIG_PMIC8901 */
6686
6687#if defined(CONFIG_MARIMBA_CORE) && (defined(CONFIG_GPIO_SX150X) \
6688 || defined(CONFIG_GPIO_SX150X_MODULE))
6689
6690static struct regulator *vreg_bahama;
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006691static int msm_bahama_sys_rst = GPIO_MS_SYS_RESET_N;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006692
6693struct bahama_config_register{
6694 u8 reg;
6695 u8 value;
6696 u8 mask;
6697};
6698
6699enum version{
6700 VER_1_0,
6701 VER_2_0,
6702 VER_UNSUPPORTED = 0xFF
6703};
6704
6705static u8 read_bahama_ver(void)
6706{
6707 int rc;
6708 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6709 u8 bahama_version;
6710
6711 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
6712 if (rc < 0) {
6713 printk(KERN_ERR
6714 "%s: version read failed: %d\n",
6715 __func__, rc);
6716 return VER_UNSUPPORTED;
6717 } else {
6718 printk(KERN_INFO
6719 "%s: version read got: 0x%x\n",
6720 __func__, bahama_version);
6721 }
6722
6723 switch (bahama_version) {
6724 case 0x08: /* varient of bahama v1 */
6725 case 0x10:
6726 case 0x00:
6727 return VER_1_0;
6728 case 0x09: /* variant of bahama v2 */
6729 return VER_2_0;
6730 default:
6731 return VER_UNSUPPORTED;
6732 }
6733}
6734
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006735static int msm_bahama_setup_power_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006736static unsigned int msm_bahama_setup_power(void)
6737{
6738 int rc = 0;
6739 const char *msm_bahama_regulator = "8058_s3";
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006740
6741 if (machine_is_msm8x60_dragon())
6742 msm_bahama_sys_rst = GPIO_CDC_RST_N;
6743
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006744 vreg_bahama = regulator_get(NULL, msm_bahama_regulator);
6745
6746 if (IS_ERR(vreg_bahama)) {
6747 rc = PTR_ERR(vreg_bahama);
6748 pr_err("%s: regulator_get %s = %d\n", __func__,
6749 msm_bahama_regulator, rc);
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006750 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006751 }
6752
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006753 rc = regulator_set_voltage(vreg_bahama, 1800000, 1800000);
6754 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006755 pr_err("%s: regulator_set_voltage %s = %d\n", __func__,
6756 msm_bahama_regulator, rc);
6757 goto unget;
6758 }
6759
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006760 rc = regulator_enable(vreg_bahama);
6761 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006762 pr_err("%s: regulator_enable %s = %d\n", __func__,
6763 msm_bahama_regulator, rc);
6764 goto unget;
6765 }
6766
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006767 rc = gpio_request(msm_bahama_sys_rst, "bahama sys_rst_n");
6768 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006769 pr_err("%s: gpio_request %d = %d\n", __func__,
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006770 msm_bahama_sys_rst, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006771 goto unenable;
6772 }
6773
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006774 gpio_direction_output(msm_bahama_sys_rst, 0);
6775 usleep_range(1000, 1050);
6776 gpio_set_value_cansleep(msm_bahama_sys_rst, 1);
6777 usleep_range(1000, 1050);
6778 msm_bahama_setup_power_enable = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006779 return rc;
6780
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006781unenable:
6782 regulator_disable(vreg_bahama);
6783unget:
6784 regulator_put(vreg_bahama);
6785 return rc;
6786};
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006787
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006788static unsigned int msm_bahama_shutdown_power(int value)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006789{
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006790 if (msm_bahama_setup_power_enable) {
6791 gpio_set_value_cansleep(msm_bahama_sys_rst, 0);
6792 gpio_free(msm_bahama_sys_rst);
6793 regulator_disable(vreg_bahama);
6794 regulator_put(vreg_bahama);
6795 msm_bahama_setup_power_enable = 0;
6796 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006797
6798 return 0;
6799};
6800
6801static unsigned int msm_bahama_core_config(int type)
6802{
6803 int rc = 0;
6804
6805 if (type == BAHAMA_ID) {
6806
6807 int i;
6808 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6809
6810 const struct bahama_config_register v20_init[] = {
6811 /* reg, value, mask */
6812 { 0xF4, 0x84, 0xFF }, /* AREG */
6813 { 0xF0, 0x04, 0xFF } /* DREG */
6814 };
6815
6816 if (read_bahama_ver() == VER_2_0) {
6817 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
6818 u8 value = v20_init[i].value;
6819 rc = marimba_write_bit_mask(&config,
6820 v20_init[i].reg,
6821 &value,
6822 sizeof(v20_init[i].value),
6823 v20_init[i].mask);
6824 if (rc < 0) {
6825 printk(KERN_ERR
6826 "%s: reg %d write failed: %d\n",
6827 __func__, v20_init[i].reg, rc);
6828 return rc;
6829 }
6830 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
6831 " mask 0x%02x\n",
6832 __func__, v20_init[i].reg,
6833 v20_init[i].value, v20_init[i].mask);
6834 }
6835 }
6836 }
6837 printk(KERN_INFO "core type: %d\n", type);
6838
6839 return rc;
6840}
6841
6842static struct regulator *fm_regulator_s3;
6843static struct msm_xo_voter *fm_clock;
6844
6845static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
6846{
6847 int rc = 0;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306848 struct pm_gpio cfg = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006849 .direction = PM_GPIO_DIR_IN,
6850 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306851 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006852 .function = PM_GPIO_FUNC_NORMAL,
6853 .inv_int_pol = 0,
6854 };
6855
6856 if (!fm_regulator_s3) {
6857 fm_regulator_s3 = regulator_get(NULL, "8058_s3");
6858 if (IS_ERR(fm_regulator_s3)) {
6859 rc = PTR_ERR(fm_regulator_s3);
6860 printk(KERN_ERR "%s: regulator get s3 (%d)\n",
6861 __func__, rc);
6862 goto out;
6863 }
6864 }
6865
6866
6867 rc = regulator_set_voltage(fm_regulator_s3, 1800000, 1800000);
6868 if (rc < 0) {
6869 printk(KERN_ERR "%s: regulator set voltage failed (%d)\n",
6870 __func__, rc);
6871 goto fm_fail_put;
6872 }
6873
6874 rc = regulator_enable(fm_regulator_s3);
6875 if (rc < 0) {
6876 printk(KERN_ERR "%s: regulator s3 enable failed (%d)\n",
6877 __func__, rc);
6878 goto fm_fail_put;
6879 }
6880
6881 /*Vote for XO clock*/
6882 fm_clock = msm_xo_get(MSM_XO_TCXO_D0, "fm_power");
6883
6884 if (IS_ERR(fm_clock)) {
6885 rc = PTR_ERR(fm_clock);
6886 printk(KERN_ERR "%s: Couldn't get TCXO_D0 vote for FM (%d)\n",
6887 __func__, rc);
6888 goto fm_fail_switch;
6889 }
6890
6891 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_ON);
6892 if (rc < 0) {
6893 printk(KERN_ERR "%s: Failed to vote for TCX0_D0 ON (%d)\n",
6894 __func__, rc);
6895 goto fm_fail_vote;
6896 }
6897
6898 /*GPIO 18 on PMIC is FM_IRQ*/
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306899 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(FM_GPIO), &cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006900 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306901 printk(KERN_ERR "%s: return val of pm8xxx_gpio_config: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006902 __func__, rc);
6903 goto fm_fail_clock;
6904 }
6905 goto out;
6906
6907fm_fail_clock:
6908 msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
6909fm_fail_vote:
6910 msm_xo_put(fm_clock);
6911fm_fail_switch:
6912 regulator_disable(fm_regulator_s3);
6913fm_fail_put:
6914 regulator_put(fm_regulator_s3);
6915out:
6916 return rc;
6917};
6918
6919static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
6920{
6921 int rc = 0;
6922 if (fm_regulator_s3 != NULL) {
6923 rc = regulator_disable(fm_regulator_s3);
6924 if (rc < 0) {
6925 printk(KERN_ERR "%s: regulator s3 disable (%d)\n",
6926 __func__, rc);
6927 }
6928 regulator_put(fm_regulator_s3);
6929 fm_regulator_s3 = NULL;
6930 }
6931 printk(KERN_ERR "%s: Voting off for XO", __func__);
6932
6933 if (fm_clock != NULL) {
6934 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
6935 if (rc < 0) {
6936 printk(KERN_ERR "%s: Voting off XO clock (%d)\n",
6937 __func__, rc);
6938 }
6939 msm_xo_put(fm_clock);
6940 }
6941 printk(KERN_ERR "%s: coming out of fm_radio_shutdown", __func__);
6942}
6943
6944/* Slave id address for FM/CDC/QMEMBIST
6945 * Values can be programmed using Marimba slave id 0
6946 * should there be a conflict with other I2C devices
6947 * */
6948#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
6949#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
6950
6951static struct marimba_fm_platform_data marimba_fm_pdata = {
6952 .fm_setup = fm_radio_setup,
6953 .fm_shutdown = fm_radio_shutdown,
6954 .irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, FM_GPIO),
6955 .is_fm_soc_i2s_master = false,
6956 .config_i2s_gpio = NULL,
6957};
6958
6959/*
6960Just initializing the BAHAMA related slave
6961*/
6962static struct marimba_platform_data marimba_pdata = {
6963 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
6964 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
6965 .bahama_setup = msm_bahama_setup_power,
6966 .bahama_shutdown = msm_bahama_shutdown_power,
6967 .bahama_core_config = msm_bahama_core_config,
6968 .fm = &marimba_fm_pdata,
6969 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6970};
6971
6972
6973static struct i2c_board_info msm_marimba_board_info[] = {
6974 {
6975 I2C_BOARD_INFO("marimba", 0xc),
6976 .platform_data = &marimba_pdata,
6977 }
6978};
6979#endif /* CONFIG_MAIMBA_CORE */
6980
6981#ifdef CONFIG_I2C
6982#define I2C_SURF 1
6983#define I2C_FFA (1 << 1)
6984#define I2C_RUMI (1 << 2)
6985#define I2C_SIM (1 << 3)
6986#define I2C_FLUID (1 << 4)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04006987#define I2C_DRAGON (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006988
6989struct i2c_registry {
6990 u8 machs;
6991 int bus;
6992 struct i2c_board_info *info;
6993 int len;
6994};
6995
6996static struct i2c_registry msm8x60_i2c_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006997#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
6998 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04006999 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007000 MSM_GSBI8_QUP_I2C_BUS_ID,
7001 core_expander_i2c_info,
7002 ARRAY_SIZE(core_expander_i2c_info),
7003 },
7004 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007005 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007006 MSM_GSBI8_QUP_I2C_BUS_ID,
7007 docking_expander_i2c_info,
7008 ARRAY_SIZE(docking_expander_i2c_info),
7009 },
7010 {
7011 I2C_SURF,
7012 MSM_GSBI8_QUP_I2C_BUS_ID,
7013 surf_expanders_i2c_info,
7014 ARRAY_SIZE(surf_expanders_i2c_info),
7015 },
7016 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007017 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007018 MSM_GSBI3_QUP_I2C_BUS_ID,
7019 fha_expanders_i2c_info,
7020 ARRAY_SIZE(fha_expanders_i2c_info),
7021 },
7022 {
7023 I2C_FLUID,
7024 MSM_GSBI3_QUP_I2C_BUS_ID,
7025 fluid_expanders_i2c_info,
7026 ARRAY_SIZE(fluid_expanders_i2c_info),
7027 },
7028 {
7029 I2C_FLUID,
7030 MSM_GSBI8_QUP_I2C_BUS_ID,
7031 fluid_core_expander_i2c_info,
7032 ARRAY_SIZE(fluid_core_expander_i2c_info),
7033 },
7034#endif
7035#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
7036 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
7037 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007038 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007039 MSM_GSBI3_QUP_I2C_BUS_ID,
7040 msm_i2c_gsbi3_tdisc_info,
7041 ARRAY_SIZE(msm_i2c_gsbi3_tdisc_info),
7042 },
7043#endif
7044 {
Zhang Chang Ken211df572011-07-05 19:16:39 -04007045 I2C_SURF | I2C_FFA | I2C_FLUID,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007046 MSM_GSBI3_QUP_I2C_BUS_ID,
7047 cy8ctmg200_board_info,
7048 ARRAY_SIZE(cy8ctmg200_board_info),
7049 },
Zhang Chang Ken211df572011-07-05 19:16:39 -04007050 {
7051 I2C_DRAGON,
7052 MSM_GSBI3_QUP_I2C_BUS_ID,
7053 cy8ctma340_dragon_board_info,
7054 ARRAY_SIZE(cy8ctma340_dragon_board_info),
7055 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007056#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
7057 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
7058 {
7059 I2C_FLUID,
7060 MSM_GSBI3_QUP_I2C_BUS_ID,
7061 cyttsp_fluid_info,
7062 ARRAY_SIZE(cyttsp_fluid_info),
7063 },
7064 {
7065 I2C_FFA | I2C_SURF,
7066 MSM_GSBI3_QUP_I2C_BUS_ID,
7067 cyttsp_ffa_info,
7068 ARRAY_SIZE(cyttsp_ffa_info),
7069 },
7070#endif
7071#ifdef CONFIG_MSM_CAMERA
Jilai Wang971f97f2011-07-13 14:25:25 -04007072 {
7073 I2C_SURF | I2C_FFA | I2C_FLUID ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007074 MSM_GSBI4_QUP_I2C_BUS_ID,
7075 msm_camera_boardinfo,
7076 ARRAY_SIZE(msm_camera_boardinfo),
7077 },
Jilai Wang971f97f2011-07-13 14:25:25 -04007078 {
7079 I2C_DRAGON,
7080 MSM_GSBI4_QUP_I2C_BUS_ID,
7081 msm_camera_dragon_boardinfo,
7082 ARRAY_SIZE(msm_camera_dragon_boardinfo),
7083 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007084#endif
7085 {
7086 I2C_SURF | I2C_FFA | I2C_FLUID,
7087 MSM_GSBI7_QUP_I2C_BUS_ID,
7088 msm_i2c_gsbi7_timpani_info,
7089 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info),
7090 },
7091#if defined(CONFIG_MARIMBA_CORE)
7092 {
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04007093 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007094 MSM_GSBI7_QUP_I2C_BUS_ID,
7095 msm_marimba_board_info,
7096 ARRAY_SIZE(msm_marimba_board_info),
7097 },
7098#endif /* CONFIG_MARIMBA_CORE */
7099#ifdef CONFIG_ISL9519_CHARGER
7100 {
7101 I2C_SURF | I2C_FFA,
7102 MSM_GSBI8_QUP_I2C_BUS_ID,
7103 isl_charger_i2c_info,
7104 ARRAY_SIZE(isl_charger_i2c_info),
7105 },
7106#endif
7107#if defined(CONFIG_HAPTIC_ISA1200) || \
7108 defined(CONFIG_HAPTIC_ISA1200_MODULE)
7109 {
7110 I2C_FLUID,
7111 MSM_GSBI8_QUP_I2C_BUS_ID,
7112 msm_isa1200_board_info,
7113 ARRAY_SIZE(msm_isa1200_board_info),
7114 },
7115#endif
7116#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
7117 {
7118 I2C_FLUID,
7119 MSM_GSBI8_QUP_I2C_BUS_ID,
7120 smb137b_charger_i2c_info,
7121 ARRAY_SIZE(smb137b_charger_i2c_info),
7122 },
7123#endif
7124#if defined(CONFIG_BATTERY_BQ27520) || \
7125 defined(CONFIG_BATTERY_BQ27520_MODULE)
7126 {
7127 I2C_FLUID,
7128 MSM_GSBI8_QUP_I2C_BUS_ID,
7129 msm_bq27520_board_info,
7130 ARRAY_SIZE(msm_bq27520_board_info),
7131 },
7132#endif
Lei Zhou338cab82011-08-19 13:38:17 -04007133#if defined(CONFIG_SND_SOC_WM8903) || defined(CONFIG_SND_SOC_WM8903_MODULE)
7134 {
7135 I2C_DRAGON,
7136 MSM_GSBI8_QUP_I2C_BUS_ID,
7137 wm8903_codec_i2c_info,
7138 ARRAY_SIZE(wm8903_codec_i2c_info),
7139 },
7140#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007141};
7142#endif /* CONFIG_I2C */
7143
7144static void fixup_i2c_configs(void)
7145{
7146#ifdef CONFIG_I2C
7147#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7148 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7149 sx150x_data[SX150X_CORE].irq_summary =
7150 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT2_N);
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007151 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
7152 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007153 sx150x_data[SX150X_CORE].irq_summary =
7154 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7155 else if (machine_is_msm8x60_fluid())
7156 sx150x_data[SX150X_CORE_FLUID].irq_summary =
7157 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7158#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007159#endif
7160}
7161
7162static void register_i2c_devices(void)
7163{
7164#ifdef CONFIG_I2C
7165 u8 mach_mask = 0;
7166 int i;
7167
7168 /* Build the matching 'supported_machs' bitmask */
7169 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7170 mach_mask = I2C_SURF;
7171 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
7172 mach_mask = I2C_FFA;
7173 else if (machine_is_msm8x60_rumi3())
7174 mach_mask = I2C_RUMI;
7175 else if (machine_is_msm8x60_sim())
7176 mach_mask = I2C_SIM;
7177 else if (machine_is_msm8x60_fluid())
7178 mach_mask = I2C_FLUID;
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007179 else if (machine_is_msm8x60_dragon())
7180 mach_mask = I2C_DRAGON;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007181 else
7182 pr_err("unmatched machine ID in register_i2c_devices\n");
7183
7184 /* Run the array and install devices as appropriate */
7185 for (i = 0; i < ARRAY_SIZE(msm8x60_i2c_devices); ++i) {
7186 if (msm8x60_i2c_devices[i].machs & mach_mask)
7187 i2c_register_board_info(msm8x60_i2c_devices[i].bus,
7188 msm8x60_i2c_devices[i].info,
7189 msm8x60_i2c_devices[i].len);
7190 }
7191#endif
7192}
7193
7194static void __init msm8x60_init_uart12dm(void)
7195{
7196#if !defined(CONFIG_USB_PEHCI_HCD) && !defined(CONFIG_USB_PEHCI_HCD_MODULE)
7197 /* 0x1D000000 now belongs to EBI2:CS3 i.e. USB ISP Controller */
7198 void *fpga_mem = ioremap_nocache(0x1D000000, SZ_4K);
7199
7200 if (!fpga_mem)
7201 pr_err("%s(): Error getting memory\n", __func__);
7202
7203 /* Advanced mode */
7204 writew(0xFFFF, fpga_mem + 0x15C);
7205 /* FPGA_UART_SEL */
7206 writew(0, fpga_mem + 0x172);
7207 /* FPGA_GPIO_CONFIG_117 */
7208 writew(1, fpga_mem + 0xEA);
7209 /* FPGA_GPIO_CONFIG_118 */
7210 writew(1, fpga_mem + 0xEC);
7211 mb();
7212 iounmap(fpga_mem);
7213#endif
7214}
7215
7216#define MSM_GSBI9_PHYS 0x19900000
7217#define GSBI_DUAL_MODE_CODE 0x60
7218
7219static void __init msm8x60_init_buses(void)
7220{
7221#ifdef CONFIG_I2C_QUP
7222 void *gsbi_mem = ioremap_nocache(0x19C00000, 4);
7223 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI12 */
7224 writel_relaxed(0x6 << 4, gsbi_mem);
7225 /* Ensure protocol code is written before proceeding further */
7226 mb();
7227 iounmap(gsbi_mem);
7228
7229 msm_gsbi3_qup_i2c_device.dev.platform_data = &msm_gsbi3_qup_i2c_pdata;
7230 msm_gsbi4_qup_i2c_device.dev.platform_data = &msm_gsbi4_qup_i2c_pdata;
7231 msm_gsbi7_qup_i2c_device.dev.platform_data = &msm_gsbi7_qup_i2c_pdata;
7232 msm_gsbi8_qup_i2c_device.dev.platform_data = &msm_gsbi8_qup_i2c_pdata;
7233
7234#ifdef CONFIG_MSM_GSBI9_UART
7235 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7236 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI9 */
7237 gsbi_mem = ioremap_nocache(MSM_GSBI9_PHYS, 4);
7238 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
7239 iounmap(gsbi_mem);
7240 msm_gsbi9_qup_i2c_pdata.use_gsbi_shared_mode = 1;
7241 }
7242#endif
7243 msm_gsbi9_qup_i2c_device.dev.platform_data = &msm_gsbi9_qup_i2c_pdata;
7244 msm_gsbi12_qup_i2c_device.dev.platform_data = &msm_gsbi12_qup_i2c_pdata;
7245#endif
7246#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7247 msm_gsbi1_qup_spi_device.dev.platform_data = &msm_gsbi1_qup_spi_pdata;
7248#endif
7249#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007250 msm_device_ssbi3.dev.platform_data = &msm_ssbi3_pdata;
7251#endif
7252
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307253#ifdef CONFIG_MSM_SSBI
7254 msm_device_ssbi_pmic1.dev.platform_data =
7255 &msm8x60_ssbi_pm8058_pdata;
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05307256 msm_device_ssbi_pmic2.dev.platform_data =
7257 &msm8x60_ssbi_pm8901_pdata;
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307258#endif
7259
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007260 if (machine_is_msm8x60_fluid()) {
7261#if (defined(CONFIG_USB_EHCI_MSM_72K) && \
7262 (defined(CONFIG_SMB137B_CHARGER) || \
7263 defined(CONFIG_SMB137B_CHARGER_MODULE)))
7264 msm_otg_pdata.vbus_power = msm_hsusb_smb137b_vbus_power;
7265#endif
7266#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7267 msm_gsbi10_qup_spi_device.dev.platform_data =
7268 &msm_gsbi10_qup_spi_pdata;
7269#endif
7270 }
7271
7272#if defined(CONFIG_USB_GADGET_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
7273 /*
7274 * We can not put USB regulators (8058_l6 and 8058_l7) in LPM
7275 * when we depend on USB PHY for VBUS/ID notifications. VBUS
7276 * and ID notifications are available only on V2 surf and FFA
7277 * with a hardware workaround.
7278 */
7279 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 &&
7280 (machine_is_msm8x60_surf() ||
7281 (machine_is_msm8x60_ffa() &&
7282 pmic_id_notif_supported)))
7283 msm_otg_pdata.phy_can_powercollapse = 1;
7284 msm_device_otg.dev.platform_data = &msm_otg_pdata;
7285#endif
7286
7287#ifdef CONFIG_USB_GADGET_MSM_72K
7288 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
7289#endif
7290
7291#ifdef CONFIG_SERIAL_MSM_HS
7292 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(54); /* GSBI6(2) */
7293 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
7294#endif
7295#ifdef CONFIG_MSM_GSBI9_UART
7296 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7297 msm_device_uart_gsbi9 = msm_add_gsbi9_uart();
7298 if (IS_ERR(msm_device_uart_gsbi9))
7299 pr_err("%s(): Failed to create uart gsbi9 device\n",
7300 __func__);
7301 }
7302#endif
7303
7304#ifdef CONFIG_MSM_BUS_SCALING
7305
7306 /* RPM calls are only enabled on V2 */
7307 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2) {
7308 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
7309 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
7310 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
7311 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
7312 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
7313 }
7314
7315 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
7316 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
7317 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
7318 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
7319 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
7320#endif
7321}
7322
7323static void __init msm8x60_map_io(void)
7324{
7325 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
7326 msm_map_msm8x60_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007327
7328 if (socinfo_init() < 0)
7329 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007330}
7331
7332/*
7333 * Most segments of the EBI2 bus are disabled by default.
7334 */
7335static void __init msm8x60_init_ebi2(void)
7336{
7337 uint32_t ebi2_cfg;
7338 void *ebi2_cfg_ptr;
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007339 struct clk *mem_clk = clk_get_sys("msm_ebi2", "mem_clk");
7340
7341 if (IS_ERR(mem_clk)) {
7342 pr_err("%s: clk_get_sys(%s,%s), failed", __func__,
7343 "msm_ebi2", "mem_clk");
7344 return;
7345 }
7346 clk_enable(mem_clk);
7347 clk_put(mem_clk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007348
7349 ebi2_cfg_ptr = ioremap_nocache(0x1a100000, sizeof(uint32_t));
7350 if (ebi2_cfg_ptr != 0) {
7351 ebi2_cfg = readl_relaxed(ebi2_cfg_ptr);
7352
7353 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007354 machine_is_msm8x60_fluid() ||
7355 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007356 ebi2_cfg |= (1 << 4) | (1 << 5); /* CS2, CS3 */
7357 else if (machine_is_msm8x60_sim())
7358 ebi2_cfg |= (1 << 4); /* CS2 */
7359 else if (machine_is_msm8x60_rumi3())
7360 ebi2_cfg |= (1 << 5); /* CS3 */
7361
7362 writel_relaxed(ebi2_cfg, ebi2_cfg_ptr);
7363 iounmap(ebi2_cfg_ptr);
7364 }
7365
7366 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007367 machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007368 ebi2_cfg_ptr = ioremap_nocache(0x1a110000, SZ_4K);
7369 if (ebi2_cfg_ptr != 0) {
7370 /* EBI2_XMEM_CFG:PWRSAVE_MODE off */
7371 writel_relaxed(0UL, ebi2_cfg_ptr);
7372
7373 /* CS2: Delay 9 cycles (140ns@64MHz) between SMSC
7374 * LAN9221 Ethernet controller reads and writes.
7375 * The lowest 4 bits are the read delay, the next
7376 * 4 are the write delay. */
7377 writel_relaxed(0x031F1C99, ebi2_cfg_ptr + 0x10);
7378#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
7379 /*
7380 * RECOVERY=5, HOLD_WR=1
7381 * INIT_LATENCY_WR=1, INIT_LATENCY_RD=1
7382 * WAIT_WR=1, WAIT_RD=2
7383 */
7384 writel_relaxed(0x51010112, ebi2_cfg_ptr + 0x14);
7385 /*
7386 * HOLD_RD=1
7387 * ADV_OE_RECOVERY=0, ADDR_HOLD_ENA=1
7388 */
7389 writel_relaxed(0x01000020, ebi2_cfg_ptr + 0x34);
7390#else
7391 /* EBI2 CS3 muxed address/data,
7392 * two cyc addr enable */
7393 writel_relaxed(0xA3030020, ebi2_cfg_ptr + 0x34);
7394
7395#endif
7396 iounmap(ebi2_cfg_ptr);
7397 }
7398 }
7399}
7400
7401static void __init msm8x60_configure_smc91x(void)
7402{
7403 if (machine_is_msm8x60_sim()) {
7404
7405 smc91x_resources[0].start = 0x1b800300;
7406 smc91x_resources[0].end = 0x1b8003ff;
7407
7408 smc91x_resources[1].start = (NR_MSM_IRQS + 40);
7409 smc91x_resources[1].end = (NR_MSM_IRQS + 40);
7410
7411 } else if (machine_is_msm8x60_rumi3()) {
7412
7413 smc91x_resources[0].start = 0x1d000300;
7414 smc91x_resources[0].end = 0x1d0003ff;
7415
7416 smc91x_resources[1].start = TLMM_MSM_DIR_CONN_IRQ_0;
7417 smc91x_resources[1].end = TLMM_MSM_DIR_CONN_IRQ_0;
7418 }
7419}
7420
7421static void __init msm8x60_init_tlmm(void)
7422{
7423 if (machine_is_msm8x60_rumi3())
7424 msm_gpio_install_direct_irq(0, 0, 1);
7425}
7426
7427#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
7428 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
7429 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
7430 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\
7431 || defined(CONFIG_MMC_MSM_SDC5_SUPPORT))
7432
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007433/* 8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007434#define MAX_SDCC_CONTROLLER 5
7435
7436struct msm_sdcc_gpio {
7437 /* maximum 10 GPIOs per SDCC controller */
7438 s16 no;
7439 /* name of this GPIO */
7440 const char *name;
7441 bool always_on;
7442 bool is_enabled;
7443};
7444
7445#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7446static struct msm_sdcc_gpio sdc1_gpio_cfg[] = {
7447 {159, "sdc1_dat_0"},
7448 {160, "sdc1_dat_1"},
7449 {161, "sdc1_dat_2"},
7450 {162, "sdc1_dat_3"},
7451#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
7452 {163, "sdc1_dat_4"},
7453 {164, "sdc1_dat_5"},
7454 {165, "sdc1_dat_6"},
7455 {166, "sdc1_dat_7"},
7456#endif
7457 {167, "sdc1_clk"},
7458 {168, "sdc1_cmd"}
7459};
7460#endif
7461
7462#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7463static struct msm_sdcc_gpio sdc2_gpio_cfg[] = {
7464 {143, "sdc2_dat_0"},
7465 {144, "sdc2_dat_1", 1},
7466 {145, "sdc2_dat_2"},
7467 {146, "sdc2_dat_3"},
7468#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
7469 {147, "sdc2_dat_4"},
7470 {148, "sdc2_dat_5"},
7471 {149, "sdc2_dat_6"},
7472 {150, "sdc2_dat_7"},
7473#endif
7474 {151, "sdc2_cmd"},
7475 {152, "sdc2_clk", 1}
7476};
7477#endif
7478
7479#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7480static struct msm_sdcc_gpio sdc5_gpio_cfg[] = {
7481 {95, "sdc5_cmd"},
7482 {96, "sdc5_dat_3"},
7483 {97, "sdc5_clk", 1},
7484 {98, "sdc5_dat_2"},
7485 {99, "sdc5_dat_1", 1},
7486 {100, "sdc5_dat_0"}
7487};
7488#endif
7489
7490struct msm_sdcc_pad_pull_cfg {
7491 enum msm_tlmm_pull_tgt pull;
7492 u32 pull_val;
7493};
7494
7495struct msm_sdcc_pad_drv_cfg {
7496 enum msm_tlmm_hdrive_tgt drv;
7497 u32 drv_val;
7498};
7499
7500#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7501static struct msm_sdcc_pad_drv_cfg sdc3_pad_on_drv_cfg[] = {
7502 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
7503 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
7504 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
7505};
7506
7507static struct msm_sdcc_pad_pull_cfg sdc3_pad_on_pull_cfg[] = {
7508 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
7509 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
7510};
7511
7512static struct msm_sdcc_pad_drv_cfg sdc3_pad_off_drv_cfg[] = {
7513 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
7514 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
7515 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
7516};
7517
7518static struct msm_sdcc_pad_pull_cfg sdc3_pad_off_pull_cfg[] = {
7519 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
7520 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
7521};
7522#endif
7523
7524#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7525static struct msm_sdcc_pad_drv_cfg sdc4_pad_on_drv_cfg[] = {
7526 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_8MA},
7527 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_8MA},
7528 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_8MA}
7529};
7530
7531static struct msm_sdcc_pad_pull_cfg sdc4_pad_on_pull_cfg[] = {
7532 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_UP},
7533 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_UP}
7534};
7535
7536static struct msm_sdcc_pad_drv_cfg sdc4_pad_off_drv_cfg[] = {
7537 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_2MA},
7538 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_2MA},
7539 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_2MA}
7540};
7541
7542static struct msm_sdcc_pad_pull_cfg sdc4_pad_off_pull_cfg[] = {
7543 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_DOWN},
7544 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_DOWN}
7545};
7546#endif
7547
7548struct msm_sdcc_pin_cfg {
7549 /*
7550 * = 1 if controller pins are using gpios
7551 * = 0 if controller has dedicated MSM pins
7552 */
7553 u8 is_gpio;
7554 u8 cfg_sts;
7555 u8 gpio_data_size;
7556 struct msm_sdcc_gpio *gpio_data;
7557 struct msm_sdcc_pad_drv_cfg *pad_drv_on_data;
7558 struct msm_sdcc_pad_drv_cfg *pad_drv_off_data;
7559 struct msm_sdcc_pad_pull_cfg *pad_pull_on_data;
7560 struct msm_sdcc_pad_pull_cfg *pad_pull_off_data;
7561 u8 pad_drv_data_size;
7562 u8 pad_pull_data_size;
7563 u8 sdio_lpm_gpio_cfg;
7564};
7565
7566
7567static struct msm_sdcc_pin_cfg sdcc_pin_cfg_data[MAX_SDCC_CONTROLLER] = {
7568#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7569 [0] = {
7570 .is_gpio = 1,
7571 .gpio_data_size = ARRAY_SIZE(sdc1_gpio_cfg),
7572 .gpio_data = sdc1_gpio_cfg
7573 },
7574#endif
7575#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7576 [1] = {
7577 .is_gpio = 1,
7578 .gpio_data_size = ARRAY_SIZE(sdc2_gpio_cfg),
7579 .gpio_data = sdc2_gpio_cfg
7580 },
7581#endif
7582#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7583 [2] = {
7584 .is_gpio = 0,
7585 .pad_drv_on_data = sdc3_pad_on_drv_cfg,
7586 .pad_drv_off_data = sdc3_pad_off_drv_cfg,
7587 .pad_pull_on_data = sdc3_pad_on_pull_cfg,
7588 .pad_pull_off_data = sdc3_pad_off_pull_cfg,
7589 .pad_drv_data_size = ARRAY_SIZE(sdc3_pad_on_drv_cfg),
7590 .pad_pull_data_size = ARRAY_SIZE(sdc3_pad_on_pull_cfg)
7591 },
7592#endif
7593#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7594 [3] = {
7595 .is_gpio = 0,
7596 .pad_drv_on_data = sdc4_pad_on_drv_cfg,
7597 .pad_drv_off_data = sdc4_pad_off_drv_cfg,
7598 .pad_pull_on_data = sdc4_pad_on_pull_cfg,
7599 .pad_pull_off_data = sdc4_pad_off_pull_cfg,
7600 .pad_drv_data_size = ARRAY_SIZE(sdc4_pad_on_drv_cfg),
7601 .pad_pull_data_size = ARRAY_SIZE(sdc4_pad_on_pull_cfg)
7602 },
7603#endif
7604#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7605 [4] = {
7606 .is_gpio = 1,
7607 .gpio_data_size = ARRAY_SIZE(sdc5_gpio_cfg),
7608 .gpio_data = sdc5_gpio_cfg
7609 }
7610#endif
7611};
7612
7613static int msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
7614{
7615 int rc = 0;
7616 struct msm_sdcc_pin_cfg *curr;
7617 int n;
7618
7619 curr = &sdcc_pin_cfg_data[dev_id - 1];
7620 if (!curr->gpio_data)
7621 goto out;
7622
7623 for (n = 0; n < curr->gpio_data_size; n++) {
7624 if (enable) {
7625
7626 if (curr->gpio_data[n].always_on &&
7627 curr->gpio_data[n].is_enabled)
7628 continue;
7629 pr_debug("%s: enable: %s\n", __func__,
7630 curr->gpio_data[n].name);
7631 rc = gpio_request(curr->gpio_data[n].no,
7632 curr->gpio_data[n].name);
7633 if (rc) {
7634 pr_err("%s: gpio_request(%d, %s)"
7635 "failed", __func__,
7636 curr->gpio_data[n].no,
7637 curr->gpio_data[n].name);
7638 goto free_gpios;
7639 }
7640 /* set direction as output for all GPIOs */
7641 rc = gpio_direction_output(
7642 curr->gpio_data[n].no, 1);
7643 if (rc) {
7644 pr_err("%s: gpio_direction_output"
7645 "(%d, 1) failed\n", __func__,
7646 curr->gpio_data[n].no);
7647 goto free_gpios;
7648 }
7649 curr->gpio_data[n].is_enabled = 1;
7650 } else {
7651 /*
7652 * now free this GPIO which will put GPIO
7653 * in low power mode and will also put GPIO
7654 * in input mode
7655 */
7656 if (curr->gpio_data[n].always_on)
7657 continue;
7658 pr_debug("%s: disable: %s\n", __func__,
7659 curr->gpio_data[n].name);
7660 gpio_free(curr->gpio_data[n].no);
7661 curr->gpio_data[n].is_enabled = 0;
7662 }
7663 }
7664 curr->cfg_sts = enable;
7665 goto out;
7666
7667free_gpios:
7668 for (; n >= 0; n--)
7669 gpio_free(curr->gpio_data[n].no);
7670out:
7671 return rc;
7672}
7673
7674static int msm_sdcc_setup_pad(int dev_id, unsigned int enable)
7675{
7676 int rc = 0;
7677 struct msm_sdcc_pin_cfg *curr;
7678 int n;
7679
7680 curr = &sdcc_pin_cfg_data[dev_id - 1];
7681 if (!curr->pad_drv_on_data || !curr->pad_pull_on_data)
7682 goto out;
7683
7684 if (enable) {
7685 /*
7686 * set up the normal driver strength and
7687 * pull config for pads
7688 */
7689 for (n = 0; n < curr->pad_drv_data_size; n++) {
7690 if (curr->sdio_lpm_gpio_cfg) {
7691 if (curr->pad_drv_on_data[n].drv ==
7692 TLMM_HDRV_SDC4_DATA)
7693 continue;
7694 }
7695 msm_tlmm_set_hdrive(curr->pad_drv_on_data[n].drv,
7696 curr->pad_drv_on_data[n].drv_val);
7697 }
7698 for (n = 0; n < curr->pad_pull_data_size; n++) {
7699 if (curr->sdio_lpm_gpio_cfg) {
7700 if (curr->pad_pull_on_data[n].pull ==
7701 TLMM_PULL_SDC4_DATA)
7702 continue;
7703 }
7704 msm_tlmm_set_pull(curr->pad_pull_on_data[n].pull,
7705 curr->pad_pull_on_data[n].pull_val);
7706 }
7707 } else {
7708 /* set the low power config for pads */
7709 for (n = 0; n < curr->pad_drv_data_size; n++) {
7710 if (curr->sdio_lpm_gpio_cfg) {
7711 if (curr->pad_drv_off_data[n].drv ==
7712 TLMM_HDRV_SDC4_DATA)
7713 continue;
7714 }
7715 msm_tlmm_set_hdrive(
7716 curr->pad_drv_off_data[n].drv,
7717 curr->pad_drv_off_data[n].drv_val);
7718 }
7719 for (n = 0; n < curr->pad_pull_data_size; n++) {
7720 if (curr->sdio_lpm_gpio_cfg) {
7721 if (curr->pad_pull_off_data[n].pull ==
7722 TLMM_PULL_SDC4_DATA)
7723 continue;
7724 }
7725 msm_tlmm_set_pull(
7726 curr->pad_pull_off_data[n].pull,
7727 curr->pad_pull_off_data[n].pull_val);
7728 }
7729 }
7730 curr->cfg_sts = enable;
7731out:
7732 return rc;
7733}
7734
7735struct sdcc_reg {
7736 /* VDD/VCC/VCCQ regulator name on PMIC8058/PMIC8089*/
7737 const char *reg_name;
7738 /*
7739 * is set voltage supported for this regulator?
7740 * 0 = not supported, 1 = supported
7741 */
7742 unsigned char set_voltage_sup;
7743 /* voltage level to be set */
7744 unsigned int level;
7745 /* VDD/VCC/VCCQ voltage regulator handle */
7746 struct regulator *reg;
7747 /* is this regulator enabled? */
7748 bool enabled;
7749 /* is this regulator needs to be always on? */
7750 bool always_on;
7751 /* is operating power mode setting required for this regulator? */
7752 bool op_pwr_mode_sup;
7753 /* Load values for low power and high power mode */
7754 unsigned int lpm_uA;
7755 unsigned int hpm_uA;
7756};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007757/* all SDCC controllers require VDD/VCC voltage */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007758static struct sdcc_reg sdcc_vdd_reg_data[MAX_SDCC_CONTROLLER];
7759/* only SDCC1 requires VCCQ voltage */
7760static struct sdcc_reg sdcc_vccq_reg_data[1];
7761/* all SDCC controllers may require voting for VDD PAD voltage */
7762static struct sdcc_reg sdcc_vddp_reg_data[MAX_SDCC_CONTROLLER];
7763
7764struct sdcc_reg_data {
7765 struct sdcc_reg *vdd_data; /* keeps VDD/VCC regulator info */
7766 struct sdcc_reg *vccq_data; /* keeps VCCQ regulator info */
7767 struct sdcc_reg *vddp_data; /* keeps VDD Pad regulator info */
7768 unsigned char sts; /* regulator enable/disable status */
7769};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007770/* msm8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007771static struct sdcc_reg_data sdcc_vreg_data[MAX_SDCC_CONTROLLER];
7772
7773static int msm_sdcc_vreg_init_reg(struct sdcc_reg *vreg)
7774{
7775 int rc = 0;
7776
7777 /* Get the regulator handle */
7778 vreg->reg = regulator_get(NULL, vreg->reg_name);
7779 if (IS_ERR(vreg->reg)) {
7780 rc = PTR_ERR(vreg->reg);
7781 pr_err("%s: regulator_get(%s) failed. rc=%d\n",
7782 __func__, vreg->reg_name, rc);
7783 goto out;
7784 }
7785
7786 /* Set the voltage level if required */
7787 if (vreg->set_voltage_sup) {
7788 rc = regulator_set_voltage(vreg->reg, vreg->level,
7789 vreg->level);
7790 if (rc) {
7791 pr_err("%s: regulator_set_voltage(%s) failed rc=%d\n",
7792 __func__, vreg->reg_name, rc);
7793 goto vreg_put;
7794 }
7795 }
7796 goto out;
7797
7798vreg_put:
7799 regulator_put(vreg->reg);
7800out:
7801 return rc;
7802}
7803
7804static inline void msm_sdcc_vreg_deinit_reg(struct sdcc_reg *vreg)
7805{
7806 regulator_put(vreg->reg);
7807}
7808
7809/* this init function should be called only once for each SDCC */
7810static int msm_sdcc_vreg_init(int dev_id, unsigned char init)
7811{
7812 int rc = 0;
7813 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
7814 struct sdcc_reg_data *curr;
7815
7816 curr = &sdcc_vreg_data[dev_id - 1];
7817 curr_vdd_reg = curr->vdd_data;
7818 curr_vccq_reg = curr->vccq_data;
7819 curr_vddp_reg = curr->vddp_data;
7820
7821 if (init) {
7822 /*
7823 * get the regulator handle from voltage regulator framework
7824 * and then try to set the voltage level for the regulator
7825 */
7826 if (curr_vdd_reg) {
7827 rc = msm_sdcc_vreg_init_reg(curr_vdd_reg);
7828 if (rc)
7829 goto out;
7830 }
7831 if (curr_vccq_reg) {
7832 rc = msm_sdcc_vreg_init_reg(curr_vccq_reg);
7833 if (rc)
7834 goto vdd_reg_deinit;
7835 }
7836 if (curr_vddp_reg) {
7837 rc = msm_sdcc_vreg_init_reg(curr_vddp_reg);
7838 if (rc)
7839 goto vccq_reg_deinit;
7840 }
7841 goto out;
7842 } else
7843 /* deregister with all regulators from regulator framework */
7844 goto vddp_reg_deinit;
7845
7846vddp_reg_deinit:
7847 if (curr_vddp_reg)
7848 msm_sdcc_vreg_deinit_reg(curr_vddp_reg);
7849vccq_reg_deinit:
7850 if (curr_vccq_reg)
7851 msm_sdcc_vreg_deinit_reg(curr_vccq_reg);
7852vdd_reg_deinit:
7853 if (curr_vdd_reg)
7854 msm_sdcc_vreg_deinit_reg(curr_vdd_reg);
7855out:
7856 return rc;
7857}
7858
7859static int msm_sdcc_vreg_enable(struct sdcc_reg *vreg)
7860{
7861 int rc;
7862
7863 if (!vreg->enabled) {
7864 rc = regulator_enable(vreg->reg);
7865 if (rc) {
7866 pr_err("%s: regulator_enable(%s) failed. rc=%d\n",
7867 __func__, vreg->reg_name, rc);
7868 goto out;
7869 }
7870 vreg->enabled = 1;
7871 }
7872
7873 /* Put always_on regulator in HPM (high power mode) */
7874 if (vreg->always_on && vreg->op_pwr_mode_sup) {
7875 rc = regulator_set_optimum_mode(vreg->reg, vreg->hpm_uA);
7876 if (rc < 0) {
7877 pr_err("%s: reg=%s: HPM setting failed"
7878 " hpm_uA=%d, rc=%d\n",
7879 __func__, vreg->reg_name,
7880 vreg->hpm_uA, rc);
7881 goto vreg_disable;
7882 }
7883 rc = 0;
7884 }
7885 goto out;
7886
7887vreg_disable:
7888 regulator_disable(vreg->reg);
7889 vreg->enabled = 0;
7890out:
7891 return rc;
7892}
7893
7894static int msm_sdcc_vreg_disable(struct sdcc_reg *vreg)
7895{
7896 int rc;
7897
7898 /* Never disable always_on regulator */
7899 if (!vreg->always_on) {
7900 rc = regulator_disable(vreg->reg);
7901 if (rc) {
7902 pr_err("%s: regulator_disable(%s) failed. rc=%d\n",
7903 __func__, vreg->reg_name, rc);
7904 goto out;
7905 }
7906 vreg->enabled = 0;
7907 }
7908
7909 /* Put always_on regulator in LPM (low power mode) */
7910 if (vreg->always_on && vreg->op_pwr_mode_sup) {
7911 rc = regulator_set_optimum_mode(vreg->reg, vreg->lpm_uA);
7912 if (rc < 0) {
7913 pr_err("%s: reg=%s: LPM setting failed"
7914 " lpm_uA=%d, rc=%d\n",
7915 __func__,
7916 vreg->reg_name,
7917 vreg->lpm_uA, rc);
7918 goto out;
7919 }
7920 rc = 0;
7921 }
7922
7923out:
7924 return rc;
7925}
7926
7927static int msm_sdcc_setup_vreg(int dev_id, unsigned char enable)
7928{
7929 int rc = 0;
7930 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
7931 struct sdcc_reg_data *curr;
7932
7933 curr = &sdcc_vreg_data[dev_id - 1];
7934 curr_vdd_reg = curr->vdd_data;
7935 curr_vccq_reg = curr->vccq_data;
7936 curr_vddp_reg = curr->vddp_data;
7937
7938 /* check if regulators are initialized or not? */
7939 if ((curr_vdd_reg && !curr_vdd_reg->reg) ||
7940 (curr_vccq_reg && !curr_vccq_reg->reg) ||
7941 (curr_vddp_reg && !curr_vddp_reg->reg)) {
7942 /* initialize voltage regulators required for this SDCC */
7943 rc = msm_sdcc_vreg_init(dev_id, 1);
7944 if (rc) {
7945 pr_err("%s: regulator init failed = %d\n",
7946 __func__, rc);
7947 goto out;
7948 }
7949 }
7950
7951 if (curr->sts == enable)
7952 goto out;
7953
7954 if (curr_vdd_reg) {
7955 if (enable)
7956 rc = msm_sdcc_vreg_enable(curr_vdd_reg);
7957 else
7958 rc = msm_sdcc_vreg_disable(curr_vdd_reg);
7959 if (rc)
7960 goto out;
7961 }
7962
7963 if (curr_vccq_reg) {
7964 if (enable)
7965 rc = msm_sdcc_vreg_enable(curr_vccq_reg);
7966 else
7967 rc = msm_sdcc_vreg_disable(curr_vccq_reg);
7968 if (rc)
7969 goto out;
7970 }
7971
7972 if (curr_vddp_reg) {
7973 if (enable)
7974 rc = msm_sdcc_vreg_enable(curr_vddp_reg);
7975 else
7976 rc = msm_sdcc_vreg_disable(curr_vddp_reg);
7977 if (rc)
7978 goto out;
7979 }
7980 curr->sts = enable;
7981
7982out:
7983 return rc;
7984}
7985
7986static u32 msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
7987{
7988 u32 rc_pin_cfg = 0;
7989 u32 rc_vreg_cfg = 0;
7990 u32 rc = 0;
7991 struct platform_device *pdev;
7992 struct msm_sdcc_pin_cfg *curr_pin_cfg;
7993
7994 pdev = container_of(dv, struct platform_device, dev);
7995
7996 /* setup gpio/pad */
7997 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
7998 if (curr_pin_cfg->cfg_sts == !!vdd)
7999 goto setup_vreg;
8000
8001 if (curr_pin_cfg->is_gpio)
8002 rc_pin_cfg = msm_sdcc_setup_gpio(pdev->id, !!vdd);
8003 else
8004 rc_pin_cfg = msm_sdcc_setup_pad(pdev->id, !!vdd);
8005
8006setup_vreg:
8007 /* setup voltage regulators */
8008 rc_vreg_cfg = msm_sdcc_setup_vreg(pdev->id, !!vdd);
8009
8010 if (rc_pin_cfg || rc_vreg_cfg)
8011 rc = rc_pin_cfg ? rc_pin_cfg : rc_vreg_cfg;
8012
8013 return rc;
8014}
8015
8016static void msm_sdcc_sdio_lpm_gpio(struct device *dv, unsigned int active)
8017{
8018 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8019 struct platform_device *pdev;
8020
8021 pdev = container_of(dv, struct platform_device, dev);
8022 /* setup gpio/pad */
8023 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8024
8025 if (curr_pin_cfg->cfg_sts == active)
8026 return;
8027
8028 curr_pin_cfg->sdio_lpm_gpio_cfg = 1;
8029 if (curr_pin_cfg->is_gpio)
8030 msm_sdcc_setup_gpio(pdev->id, active);
8031 else
8032 msm_sdcc_setup_pad(pdev->id, active);
8033 curr_pin_cfg->sdio_lpm_gpio_cfg = 0;
8034}
8035
8036static int msm_sdc3_get_wpswitch(struct device *dev)
8037{
8038 struct platform_device *pdev;
8039 int status;
8040 pdev = container_of(dev, struct platform_device, dev);
8041
8042 status = gpio_request(GPIO_SDC_WP, "SD_WP_Switch");
8043 if (status) {
8044 pr_err("%s:Failed to request GPIO %d\n",
8045 __func__, GPIO_SDC_WP);
8046 } else {
8047 status = gpio_direction_input(GPIO_SDC_WP);
8048 if (!status) {
8049 status = gpio_get_value_cansleep(GPIO_SDC_WP);
8050 pr_info("%s: WP Status for Slot %d = %d\n",
8051 __func__, pdev->id, status);
8052 }
8053 gpio_free(GPIO_SDC_WP);
8054 }
8055 return status;
8056}
8057
8058#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8059int sdc5_register_status_notify(void (*callback)(int, void *),
8060 void *dev_id)
8061{
8062 sdc5_status_notify_cb = callback;
8063 sdc5_status_notify_cb_devid = dev_id;
8064 return 0;
8065}
8066#endif
8067
8068#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8069int sdc2_register_status_notify(void (*callback)(int, void *),
8070 void *dev_id)
8071{
8072 sdc2_status_notify_cb = callback;
8073 sdc2_status_notify_cb_devid = dev_id;
8074 return 0;
8075}
8076#endif
8077
8078/* Interrupt handler for SDC2 and SDC5 detection
8079 * This function uses dual-edge interrputs settings in order
8080 * to get SDIO detection when the GPIO is rising and SDIO removal
8081 * when the GPIO is falling */
8082static irqreturn_t msm8x60_multi_sdio_slot_status_irq(int irq, void *dev_id)
8083{
8084 int status;
8085
8086 if (!machine_is_msm8x60_fusion() &&
8087 !machine_is_msm8x60_fusn_ffa())
8088 return IRQ_NONE;
8089
8090 status = gpio_get_value(MDM2AP_SYNC);
8091 pr_info("%s: MDM2AP_SYNC Status = %d\n",
8092 __func__, status);
8093
8094#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8095 if (sdc2_status_notify_cb) {
8096 pr_info("%s: calling sdc2_status_notify_cb\n", __func__);
8097 sdc2_status_notify_cb(status,
8098 sdc2_status_notify_cb_devid);
8099 }
8100#endif
8101
8102#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8103 if (sdc5_status_notify_cb) {
8104 pr_info("%s: calling sdc5_status_notify_cb\n", __func__);
8105 sdc5_status_notify_cb(status,
8106 sdc5_status_notify_cb_devid);
8107 }
8108#endif
8109 return IRQ_HANDLED;
8110}
8111
8112static int msm8x60_multi_sdio_init(void)
8113{
8114 int ret, irq_num;
8115
8116 if (!machine_is_msm8x60_fusion() &&
8117 !machine_is_msm8x60_fusn_ffa())
8118 return 0;
8119
8120 ret = msm_gpiomux_get(MDM2AP_SYNC);
8121 if (ret) {
8122 pr_err("%s:Failed to request GPIO %d, ret=%d\n",
8123 __func__, MDM2AP_SYNC, ret);
8124 return ret;
8125 }
8126
8127 irq_num = gpio_to_irq(MDM2AP_SYNC);
8128
8129 ret = request_irq(irq_num,
8130 msm8x60_multi_sdio_slot_status_irq,
8131 IRQ_TYPE_EDGE_BOTH,
8132 "sdio_multidetection", NULL);
8133
8134 if (ret) {
8135 pr_err("%s:Failed to request irq, ret=%d\n",
8136 __func__, ret);
8137 return ret;
8138 }
8139
8140 return ret;
8141}
8142
8143#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8144#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8145static unsigned int msm8x60_sdcc_slot_status(struct device *dev)
8146{
8147 int status;
8148
8149 status = gpio_request(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)
8150 , "SD_HW_Detect");
8151 if (status) {
8152 pr_err("%s:Failed to request GPIO %d\n", __func__,
8153 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8154 } else {
8155 status = gpio_direction_input(
8156 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8157 if (!status)
8158 status = !(gpio_get_value_cansleep(
8159 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)));
8160 gpio_free(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8161 }
8162 return (unsigned int) status;
8163}
8164#endif
8165#endif
8166
8167#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8168static int msm_sdcc_cfg_mpm_sdiowakeup(struct device *dev, unsigned mode)
8169{
8170 struct platform_device *pdev;
8171 enum msm_mpm_pin pin;
8172 int ret = 0;
8173
8174 pdev = container_of(dev, struct platform_device, dev);
8175
8176 /* Only SDCC4 slot connected to WLAN chip has wakeup capability */
8177 if (pdev->id == 4)
8178 pin = MSM_MPM_PIN_SDC4_DAT1;
8179 else
8180 return -EINVAL;
8181
8182 switch (mode) {
8183 case SDC_DAT1_DISABLE:
8184 ret = msm_mpm_enable_pin(pin, 0);
8185 break;
8186 case SDC_DAT1_ENABLE:
8187 ret = msm_mpm_set_pin_type(pin, IRQ_TYPE_LEVEL_LOW);
8188 ret = msm_mpm_enable_pin(pin, 1);
8189 break;
8190 case SDC_DAT1_ENWAKE:
8191 ret = msm_mpm_set_pin_wake(pin, 1);
8192 break;
8193 case SDC_DAT1_DISWAKE:
8194 ret = msm_mpm_set_pin_wake(pin, 0);
8195 break;
8196 default:
8197 ret = -EINVAL;
8198 break;
8199 }
8200 return ret;
8201}
8202#endif
8203#endif
8204
8205#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8206static struct mmc_platform_data msm8x60_sdc1_data = {
8207 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8208 .translate_vdd = msm_sdcc_setup_power,
8209#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
8210 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8211#else
8212 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8213#endif
8214 .msmsdcc_fmin = 400000,
8215 .msmsdcc_fmid = 24000000,
8216 .msmsdcc_fmax = 48000000,
8217 .nonremovable = 1,
8218 .pclk_src_dfab = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008219};
8220#endif
8221
8222#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8223static struct mmc_platform_data msm8x60_sdc2_data = {
8224 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8225 .translate_vdd = msm_sdcc_setup_power,
8226 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8227 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8228 .msmsdcc_fmin = 400000,
8229 .msmsdcc_fmid = 24000000,
8230 .msmsdcc_fmax = 48000000,
8231 .nonremovable = 0,
8232 .pclk_src_dfab = 1,
8233 .register_status_notify = sdc2_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008234#ifdef CONFIG_MSM_SDIO_AL
8235 .is_sdio_al_client = 1,
8236#endif
8237};
8238#endif
8239
8240#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8241static struct mmc_platform_data msm8x60_sdc3_data = {
8242 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8243 .translate_vdd = msm_sdcc_setup_power,
8244 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8245 .wpswitch = msm_sdc3_get_wpswitch,
8246#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8247 .status = msm8x60_sdcc_slot_status,
8248 .status_irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
8249 PMIC_GPIO_SDC3_DET - 1),
8250 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
8251#endif
8252 .msmsdcc_fmin = 400000,
8253 .msmsdcc_fmid = 24000000,
8254 .msmsdcc_fmax = 48000000,
8255 .nonremovable = 0,
8256 .pclk_src_dfab = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008257};
8258#endif
8259
8260#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8261static struct mmc_platform_data msm8x60_sdc4_data = {
8262 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8263 .translate_vdd = msm_sdcc_setup_power,
8264 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8265 .msmsdcc_fmin = 400000,
8266 .msmsdcc_fmid = 24000000,
8267 .msmsdcc_fmax = 48000000,
8268 .nonremovable = 0,
8269 .pclk_src_dfab = 1,
8270 .cfg_mpm_sdiowakeup = msm_sdcc_cfg_mpm_sdiowakeup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008271};
8272#endif
8273
8274#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8275static struct mmc_platform_data msm8x60_sdc5_data = {
8276 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8277 .translate_vdd = msm_sdcc_setup_power,
8278 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8279 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8280 .msmsdcc_fmin = 400000,
8281 .msmsdcc_fmid = 24000000,
8282 .msmsdcc_fmax = 48000000,
8283 .nonremovable = 0,
8284 .pclk_src_dfab = 1,
8285 .register_status_notify = sdc5_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008286#ifdef CONFIG_MSM_SDIO_AL
8287 .is_sdio_al_client = 1,
8288#endif
8289};
8290#endif
8291
8292static void __init msm8x60_init_mmc(void)
8293{
8294#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8295 /* SDCC1 : eMMC card connected */
8296 sdcc_vreg_data[0].vdd_data = &sdcc_vdd_reg_data[0];
8297 sdcc_vreg_data[0].vdd_data->reg_name = "8901_l5";
8298 sdcc_vreg_data[0].vdd_data->set_voltage_sup = 1;
8299 sdcc_vreg_data[0].vdd_data->level = 2850000;
Subhash Jadavania8482a32011-08-08 11:01:44 +05308300 sdcc_vreg_data[0].vdd_data->always_on = 1;
8301 sdcc_vreg_data[0].vdd_data->op_pwr_mode_sup = 1;
8302 sdcc_vreg_data[0].vdd_data->lpm_uA = 9000;
8303 sdcc_vreg_data[0].vdd_data->hpm_uA = 200000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008304
8305 sdcc_vreg_data[0].vccq_data = &sdcc_vccq_reg_data[0];
8306 sdcc_vreg_data[0].vccq_data->reg_name = "8901_lvs0";
8307 sdcc_vreg_data[0].vccq_data->set_voltage_sup = 0;
8308 sdcc_vreg_data[0].vccq_data->always_on = 1;
8309
8310 msm_add_sdcc(1, &msm8x60_sdc1_data);
8311#endif
8312#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8313 /*
8314 * MDM SDIO client is connected to SDC2 on charm SURF/FFA
8315 * and no card is connected on 8660 SURF/FFA/FLUID.
8316 */
8317 sdcc_vreg_data[1].vdd_data = &sdcc_vdd_reg_data[1];
8318 sdcc_vreg_data[1].vdd_data->reg_name = "8058_s3";
8319 sdcc_vreg_data[1].vdd_data->set_voltage_sup = 1;
8320 sdcc_vreg_data[1].vdd_data->level = 1800000;
8321
8322 sdcc_vreg_data[1].vccq_data = NULL;
8323
8324 if (machine_is_msm8x60_fusion())
8325 msm8x60_sdc2_data.msmsdcc_fmax = 24000000;
8326 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8327#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
8328 msm8x60_sdc2_data.sdiowakeup_irq = gpio_to_irq(144);
8329 msm_sdcc_setup_gpio(2, 1);
8330#endif
8331 msm_add_sdcc(2, &msm8x60_sdc2_data);
8332 }
8333#endif
8334#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8335 /* SDCC3 : External card slot connected */
8336 sdcc_vreg_data[2].vdd_data = &sdcc_vdd_reg_data[2];
8337 sdcc_vreg_data[2].vdd_data->reg_name = "8058_l14";
8338 sdcc_vreg_data[2].vdd_data->set_voltage_sup = 1;
8339 sdcc_vreg_data[2].vdd_data->level = 2850000;
8340 sdcc_vreg_data[2].vdd_data->always_on = 1;
8341 sdcc_vreg_data[2].vdd_data->op_pwr_mode_sup = 1;
8342 sdcc_vreg_data[2].vdd_data->lpm_uA = 9000;
8343 sdcc_vreg_data[2].vdd_data->hpm_uA = 200000;
8344
8345 sdcc_vreg_data[2].vccq_data = NULL;
8346
8347 sdcc_vreg_data[2].vddp_data = &sdcc_vddp_reg_data[2];
8348 sdcc_vreg_data[2].vddp_data->reg_name = "8058_l5";
8349 sdcc_vreg_data[2].vddp_data->set_voltage_sup = 1;
8350 sdcc_vreg_data[2].vddp_data->level = 2850000;
8351 sdcc_vreg_data[2].vddp_data->always_on = 1;
8352 sdcc_vreg_data[2].vddp_data->op_pwr_mode_sup = 1;
8353 /* Sleep current required is ~300 uA. But min. RPM
8354 * vote can be in terms of mA (min. 1 mA).
8355 * So let's vote for 2 mA during sleep.
8356 */
8357 sdcc_vreg_data[2].vddp_data->lpm_uA = 2000;
8358 /* Max. Active current required is 16 mA */
8359 sdcc_vreg_data[2].vddp_data->hpm_uA = 16000;
8360
8361 if (machine_is_msm8x60_fluid())
8362 msm8x60_sdc3_data.wpswitch = NULL;
8363 msm_add_sdcc(3, &msm8x60_sdc3_data);
8364#endif
8365#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8366 /* SDCC4 : WLAN WCN1314 chip is connected */
8367 sdcc_vreg_data[3].vdd_data = &sdcc_vdd_reg_data[3];
8368 sdcc_vreg_data[3].vdd_data->reg_name = "8058_s3";
8369 sdcc_vreg_data[3].vdd_data->set_voltage_sup = 1;
8370 sdcc_vreg_data[3].vdd_data->level = 1800000;
8371
8372 sdcc_vreg_data[3].vccq_data = NULL;
8373
8374 msm_add_sdcc(4, &msm8x60_sdc4_data);
8375#endif
8376#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8377 /*
8378 * MDM SDIO client is connected to SDC5 on charm SURF/FFA
8379 * and no card is connected on 8660 SURF/FFA/FLUID.
8380 */
8381 sdcc_vreg_data[4].vdd_data = &sdcc_vdd_reg_data[4];
8382 sdcc_vreg_data[4].vdd_data->reg_name = "8058_s3";
8383 sdcc_vreg_data[4].vdd_data->set_voltage_sup = 1;
8384 sdcc_vreg_data[4].vdd_data->level = 1800000;
8385
8386 sdcc_vreg_data[4].vccq_data = NULL;
8387
8388 if (machine_is_msm8x60_fusion())
8389 msm8x60_sdc5_data.msmsdcc_fmax = 24000000;
8390 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8391#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
8392 msm8x60_sdc5_data.sdiowakeup_irq = gpio_to_irq(99);
8393 msm_sdcc_setup_gpio(5, 1);
8394#endif
8395 msm_add_sdcc(5, &msm8x60_sdc5_data);
8396 }
8397#endif
8398}
8399
8400#if !defined(CONFIG_GPIO_SX150X) && !defined(CONFIG_GPIO_SX150X_MODULE)
8401static inline void display_common_power(int on) {}
8402#else
8403
8404#define _GET_REGULATOR(var, name) do { \
8405 if (var == NULL) { \
8406 var = regulator_get(NULL, name); \
8407 if (IS_ERR(var)) { \
8408 pr_err("'%s' regulator not found, rc=%ld\n", \
8409 name, PTR_ERR(var)); \
8410 var = NULL; \
8411 } \
8412 } \
8413} while (0)
8414
8415static int dsub_regulator(int on)
8416{
8417 static struct regulator *dsub_reg;
8418 static struct regulator *mpp0_reg;
8419 static int dsub_reg_enabled;
8420 int rc = 0;
8421
8422 _GET_REGULATOR(dsub_reg, "8901_l3");
8423 if (IS_ERR(dsub_reg)) {
8424 printk(KERN_ERR "%s: failed to get reg 8901_l3 err=%ld",
8425 __func__, PTR_ERR(dsub_reg));
8426 return PTR_ERR(dsub_reg);
8427 }
8428
8429 _GET_REGULATOR(mpp0_reg, "8901_mpp0");
8430 if (IS_ERR(mpp0_reg)) {
8431 printk(KERN_ERR "%s: failed to get reg 8901_mpp0 err=%ld",
8432 __func__, PTR_ERR(mpp0_reg));
8433 return PTR_ERR(mpp0_reg);
8434 }
8435
8436 if (on && !dsub_reg_enabled) {
8437 rc = regulator_set_voltage(dsub_reg, 3300000, 3300000);
8438 if (rc) {
8439 printk(KERN_ERR "%s: failed to set reg 8901_l3 voltage"
8440 " err=%d", __func__, rc);
8441 goto dsub_regulator_err;
8442 }
8443 rc = regulator_enable(dsub_reg);
8444 if (rc) {
8445 printk(KERN_ERR "%s: failed to enable reg 8901_l3"
8446 " err=%d", __func__, rc);
8447 goto dsub_regulator_err;
8448 }
8449 rc = regulator_enable(mpp0_reg);
8450 if (rc) {
8451 printk(KERN_ERR "%s: failed to enable reg 8901_mpp0"
8452 " err=%d", __func__, rc);
8453 goto dsub_regulator_err;
8454 }
8455 dsub_reg_enabled = 1;
8456 } else if (!on && dsub_reg_enabled) {
8457 rc = regulator_disable(dsub_reg);
8458 if (rc)
8459 printk(KERN_WARNING "%s: failed to disable reg 8901_l3"
8460 " err=%d", __func__, rc);
8461 rc = regulator_disable(mpp0_reg);
8462 if (rc)
8463 printk(KERN_WARNING "%s: failed to disable reg "
8464 "8901_mpp0 err=%d", __func__, rc);
8465 dsub_reg_enabled = 0;
8466 }
8467
8468 return rc;
8469
8470dsub_regulator_err:
8471 regulator_put(mpp0_reg);
8472 regulator_put(dsub_reg);
8473 return rc;
8474}
8475
8476static int display_power_on;
8477static void setup_display_power(void)
8478{
8479 if (display_power_on)
8480 if (lcdc_vga_enabled) {
8481 dsub_regulator(1);
8482 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8483 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8484 if (machine_is_msm8x60_ffa() ||
8485 machine_is_msm8x60_fusn_ffa())
8486 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 1);
8487 } else {
8488 dsub_regulator(0);
8489 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 1);
8490 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 1);
8491 if (machine_is_msm8x60_ffa() ||
8492 machine_is_msm8x60_fusn_ffa())
8493 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8494 }
8495 else {
8496 dsub_regulator(0);
8497 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
8498 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8499 /* BACKLIGHT */
8500 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8501 /* LVDS */
8502 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8503 }
8504}
8505
8506#define _GET_REGULATOR(var, name) do { \
8507 if (var == NULL) { \
8508 var = regulator_get(NULL, name); \
8509 if (IS_ERR(var)) { \
8510 pr_err("'%s' regulator not found, rc=%ld\n", \
8511 name, PTR_ERR(var)); \
8512 var = NULL; \
8513 } \
8514 } \
8515} while (0)
8516
8517#define GPIO_RESX_N (GPIO_EXPANDER_GPIO_BASE + 2)
8518
8519static void display_common_power(int on)
8520{
8521 int rc;
8522 static struct regulator *display_reg;
8523
8524 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
8525 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8526 if (on) {
8527 /* LVDS */
8528 _GET_REGULATOR(display_reg, "8901_l2");
8529 if (!display_reg)
8530 return;
8531 rc = regulator_set_voltage(display_reg,
8532 3300000, 3300000);
8533 if (rc)
8534 goto out;
8535 rc = regulator_enable(display_reg);
8536 if (rc)
8537 goto out;
8538 rc = gpio_request(GPIO_LVDS_SHUTDOWN_N,
8539 "LVDS_STDN_OUT_N");
8540 if (rc) {
8541 printk(KERN_ERR "%s: LVDS gpio %d request"
8542 "failed\n", __func__,
8543 GPIO_LVDS_SHUTDOWN_N);
8544 goto out2;
8545 }
8546
8547 /* BACKLIGHT */
8548 rc = gpio_request(GPIO_BACKLIGHT_EN, "BACKLIGHT_EN");
8549 if (rc) {
8550 printk(KERN_ERR "%s: BACKLIGHT gpio %d request"
8551 "failed\n", __func__,
8552 GPIO_BACKLIGHT_EN);
8553 goto out3;
8554 }
8555
8556 if (machine_is_msm8x60_ffa() ||
8557 machine_is_msm8x60_fusn_ffa()) {
8558 rc = gpio_request(GPIO_DONGLE_PWR_EN,
8559 "DONGLE_PWR_EN");
8560 if (rc) {
8561 printk(KERN_ERR "%s: DONGLE_PWR_EN gpio"
8562 " %d request failed\n", __func__,
8563 GPIO_DONGLE_PWR_EN);
8564 goto out4;
8565 }
8566 }
8567
8568 gpio_direction_output(GPIO_LVDS_SHUTDOWN_N, 0);
8569 gpio_direction_output(GPIO_BACKLIGHT_EN, 0);
8570 if (machine_is_msm8x60_ffa() ||
8571 machine_is_msm8x60_fusn_ffa())
8572 gpio_direction_output(GPIO_DONGLE_PWR_EN, 0);
8573 mdelay(20);
8574 display_power_on = 1;
8575 setup_display_power();
8576 } else {
8577 if (display_power_on) {
8578 display_power_on = 0;
8579 setup_display_power();
8580 mdelay(20);
8581 if (machine_is_msm8x60_ffa() ||
8582 machine_is_msm8x60_fusn_ffa())
8583 gpio_free(GPIO_DONGLE_PWR_EN);
8584 goto out4;
8585 }
8586 }
8587 }
8588#if defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
8589 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA)
8590 else if (machine_is_msm8x60_fluid()) {
8591 static struct regulator *fluid_reg;
8592 static struct regulator *fluid_reg2;
8593
8594 if (on) {
8595 _GET_REGULATOR(fluid_reg, "8901_l2");
8596 if (!fluid_reg)
8597 return;
8598 _GET_REGULATOR(fluid_reg2, "8058_s3");
8599 if (!fluid_reg2) {
8600 regulator_put(fluid_reg);
8601 return;
8602 }
8603 rc = gpio_request(GPIO_RESX_N, "RESX_N");
8604 if (rc) {
8605 regulator_put(fluid_reg2);
8606 regulator_put(fluid_reg);
8607 return;
8608 }
8609 regulator_set_voltage(fluid_reg, 2850000, 2850000);
8610 regulator_set_voltage(fluid_reg2, 1800000, 1800000);
8611 regulator_enable(fluid_reg);
8612 regulator_enable(fluid_reg2);
8613 msleep(20);
8614 gpio_direction_output(GPIO_RESX_N, 0);
8615 udelay(10);
8616 gpio_set_value_cansleep(GPIO_RESX_N, 1);
8617 display_power_on = 1;
8618 setup_display_power();
8619 } else {
8620 gpio_set_value_cansleep(GPIO_RESX_N, 0);
8621 gpio_free(GPIO_RESX_N);
8622 msleep(20);
8623 regulator_disable(fluid_reg2);
8624 regulator_disable(fluid_reg);
8625 regulator_put(fluid_reg2);
8626 regulator_put(fluid_reg);
8627 display_power_on = 0;
8628 setup_display_power();
8629 fluid_reg = NULL;
8630 fluid_reg2 = NULL;
8631 }
8632 }
8633#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04008634#if defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA)
8635 else if (machine_is_msm8x60_dragon()) {
8636 static struct regulator *dragon_reg;
8637 static struct regulator *dragon_reg2;
8638
8639 if (on) {
8640 _GET_REGULATOR(dragon_reg, "8901_l2");
8641 if (!dragon_reg)
8642 return;
8643 _GET_REGULATOR(dragon_reg2, "8058_l16");
8644 if (!dragon_reg2) {
8645 regulator_put(dragon_reg);
8646 dragon_reg = NULL;
8647 return;
8648 }
8649
8650 rc = gpio_request(GPIO_NT35582_BL_EN, "lcdc_bl_en");
8651 if (rc) {
8652 pr_err("%s: gpio %d request failed with rc=%d\n",
8653 __func__, GPIO_NT35582_BL_EN, rc);
8654 regulator_put(dragon_reg);
8655 regulator_put(dragon_reg2);
8656 dragon_reg = NULL;
8657 dragon_reg2 = NULL;
8658 return;
8659 }
8660
8661 if (gpio_tlmm_config(GPIO_CFG(GPIO_NT35582_RESET, 0,
8662 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
8663 GPIO_CFG_16MA), GPIO_CFG_ENABLE)) {
8664 pr_err("%s: config gpio '%d' failed!\n",
8665 __func__, GPIO_NT35582_RESET);
8666 gpio_free(GPIO_NT35582_BL_EN);
8667 regulator_put(dragon_reg);
8668 regulator_put(dragon_reg2);
8669 dragon_reg = NULL;
8670 dragon_reg2 = NULL;
8671 return;
8672 }
8673
8674 rc = gpio_request(GPIO_NT35582_RESET, "lcdc_reset");
8675 if (rc) {
8676 pr_err("%s: unable to request gpio %d (rc=%d)\n",
8677 __func__, GPIO_NT35582_RESET, rc);
8678 gpio_free(GPIO_NT35582_BL_EN);
8679 regulator_put(dragon_reg);
8680 regulator_put(dragon_reg2);
8681 dragon_reg = NULL;
8682 dragon_reg2 = NULL;
8683 return;
8684 }
8685
8686 regulator_set_voltage(dragon_reg, 3300000, 3300000);
8687 regulator_set_voltage(dragon_reg2, 1800000, 1800000);
8688 regulator_enable(dragon_reg);
8689 regulator_enable(dragon_reg2);
8690 msleep(20);
8691
8692 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8693 msleep(20);
8694 gpio_set_value_cansleep(GPIO_NT35582_RESET, 0);
8695 msleep(20);
8696 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8697 msleep(50);
8698
8699 gpio_set_value_cansleep(GPIO_NT35582_BL_EN, 1);
8700
8701 display_power_on = 1;
8702 } else if ((dragon_reg != NULL) && (dragon_reg2 != NULL)) {
8703 gpio_free(GPIO_NT35582_RESET);
8704 gpio_free(GPIO_NT35582_BL_EN);
8705 regulator_disable(dragon_reg2);
8706 regulator_disable(dragon_reg);
8707 regulator_put(dragon_reg2);
8708 regulator_put(dragon_reg);
8709 display_power_on = 0;
8710 dragon_reg = NULL;
8711 dragon_reg2 = NULL;
8712 }
8713 }
8714#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008715 return;
8716
8717out4:
8718 gpio_free(GPIO_BACKLIGHT_EN);
8719out3:
8720 gpio_free(GPIO_LVDS_SHUTDOWN_N);
8721out2:
8722 regulator_disable(display_reg);
8723out:
8724 regulator_put(display_reg);
8725 display_reg = NULL;
8726}
8727#undef _GET_REGULATOR
8728#endif
8729
8730static int mipi_dsi_panel_power(int on);
8731
8732#define LCDC_NUM_GPIO 28
8733#define LCDC_GPIO_START 0
8734
8735static void lcdc_samsung_panel_power(int on)
8736{
8737 int n, ret = 0;
8738
8739 display_common_power(on);
8740
8741 for (n = 0; n < LCDC_NUM_GPIO; n++) {
8742 if (on) {
8743 ret = gpio_request(LCDC_GPIO_START + n, "LCDC_GPIO");
8744 if (unlikely(ret)) {
8745 pr_err("%s not able to get gpio\n", __func__);
8746 break;
8747 }
8748 } else
8749 gpio_free(LCDC_GPIO_START + n);
8750 }
8751
8752 if (ret) {
8753 for (n--; n >= 0; n--)
8754 gpio_free(LCDC_GPIO_START + n);
8755 }
8756
8757 mipi_dsi_panel_power(0); /* set 8058_ldo0 to LPM */
8758}
8759
8760#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
8761#define _GET_REGULATOR(var, name) do { \
8762 var = regulator_get(NULL, name); \
8763 if (IS_ERR(var)) { \
8764 pr_err("'%s' regulator not found, rc=%ld\n", \
8765 name, IS_ERR(var)); \
8766 var = NULL; \
8767 return -ENODEV; \
8768 } \
8769} while (0)
8770
8771static int hdmi_enable_5v(int on)
8772{
8773 static struct regulator *reg_8901_hdmi_mvs; /* HDMI_5V */
8774 static struct regulator *reg_8901_mpp0; /* External 5V */
8775 static int prev_on;
8776 int rc;
8777
8778 if (on == prev_on)
8779 return 0;
8780
8781 if (!reg_8901_hdmi_mvs)
8782 _GET_REGULATOR(reg_8901_hdmi_mvs, "8901_hdmi_mvs");
8783 if (!reg_8901_mpp0)
8784 _GET_REGULATOR(reg_8901_mpp0, "8901_mpp0");
8785
8786 if (on) {
8787 rc = regulator_enable(reg_8901_mpp0);
8788 if (rc) {
8789 pr_err("'%s' regulator enable failed, rc=%d\n",
8790 "reg_8901_mpp0", rc);
8791 return rc;
8792 }
8793 rc = regulator_enable(reg_8901_hdmi_mvs);
8794 if (rc) {
8795 pr_err("'%s' regulator enable failed, rc=%d\n",
8796 "8901_hdmi_mvs", rc);
8797 return rc;
8798 }
8799 pr_info("%s(on): success\n", __func__);
8800 } else {
8801 rc = regulator_disable(reg_8901_hdmi_mvs);
8802 if (rc)
8803 pr_warning("'%s' regulator disable failed, rc=%d\n",
8804 "8901_hdmi_mvs", rc);
8805 rc = regulator_disable(reg_8901_mpp0);
8806 if (rc)
8807 pr_warning("'%s' regulator disable failed, rc=%d\n",
8808 "reg_8901_mpp0", rc);
8809 pr_info("%s(off): success\n", __func__);
8810 }
8811
8812 prev_on = on;
8813
8814 return 0;
8815}
8816
8817static int hdmi_core_power(int on, int show)
8818{
8819 static struct regulator *reg_8058_l16; /* VDD_HDMI */
8820 static int prev_on;
8821 int rc;
8822
8823 if (on == prev_on)
8824 return 0;
8825
8826 if (!reg_8058_l16)
8827 _GET_REGULATOR(reg_8058_l16, "8058_l16");
8828
8829 if (on) {
8830 rc = regulator_set_voltage(reg_8058_l16, 1800000, 1800000);
8831 if (!rc)
8832 rc = regulator_enable(reg_8058_l16);
8833 if (rc) {
8834 pr_err("'%s' regulator enable failed, rc=%d\n",
8835 "8058_l16", rc);
8836 return rc;
8837 }
8838 rc = gpio_request(170, "HDMI_DDC_CLK");
8839 if (rc) {
8840 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8841 "HDMI_DDC_CLK", 170, rc);
8842 goto error1;
8843 }
8844 rc = gpio_request(171, "HDMI_DDC_DATA");
8845 if (rc) {
8846 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8847 "HDMI_DDC_DATA", 171, rc);
8848 goto error2;
8849 }
8850 rc = gpio_request(172, "HDMI_HPD");
8851 if (rc) {
8852 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8853 "HDMI_HPD", 172, rc);
8854 goto error3;
8855 }
8856 pr_info("%s(on): success\n", __func__);
8857 } else {
8858 gpio_free(170);
8859 gpio_free(171);
8860 gpio_free(172);
8861 rc = regulator_disable(reg_8058_l16);
8862 if (rc)
8863 pr_warning("'%s' regulator disable failed, rc=%d\n",
8864 "8058_l16", rc);
8865 pr_info("%s(off): success\n", __func__);
8866 }
8867
8868 prev_on = on;
8869
8870 return 0;
8871
8872error3:
8873 gpio_free(171);
8874error2:
8875 gpio_free(170);
8876error1:
8877 regulator_disable(reg_8058_l16);
8878 return rc;
8879}
8880
8881static int hdmi_cec_power(int on)
8882{
8883 static struct regulator *reg_8901_l3; /* HDMI_CEC */
8884 static int prev_on;
8885 int rc;
8886
8887 if (on == prev_on)
8888 return 0;
8889
8890 if (!reg_8901_l3)
8891 _GET_REGULATOR(reg_8901_l3, "8901_l3");
8892
8893 if (on) {
8894 rc = regulator_set_voltage(reg_8901_l3, 3300000, 3300000);
8895 if (!rc)
8896 rc = regulator_enable(reg_8901_l3);
8897 if (rc) {
8898 pr_err("'%s' regulator enable failed, rc=%d\n",
8899 "8901_l3", rc);
8900 return rc;
8901 }
8902 rc = gpio_request(169, "HDMI_CEC_VAR");
8903 if (rc) {
8904 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8905 "HDMI_CEC_VAR", 169, rc);
8906 goto error;
8907 }
8908 pr_info("%s(on): success\n", __func__);
8909 } else {
8910 gpio_free(169);
8911 rc = regulator_disable(reg_8901_l3);
8912 if (rc)
8913 pr_warning("'%s' regulator disable failed, rc=%d\n",
8914 "8901_l3", rc);
8915 pr_info("%s(off): success\n", __func__);
8916 }
8917
8918 prev_on = on;
8919
8920 return 0;
8921error:
8922 regulator_disable(reg_8901_l3);
8923 return rc;
8924}
8925
8926#undef _GET_REGULATOR
8927
8928#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
8929
8930static int lcdc_panel_power(int on)
8931{
8932 int flag_on = !!on;
8933 static int lcdc_power_save_on;
8934
8935 if (lcdc_power_save_on == flag_on)
8936 return 0;
8937
8938 lcdc_power_save_on = flag_on;
8939
8940 lcdc_samsung_panel_power(on);
8941
8942 return 0;
8943}
8944
8945#ifdef CONFIG_MSM_BUS_SCALING
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008946static struct msm_bus_vectors mdp_init_vectors[] = {
8947 /* For now, 0th array entry is reserved.
8948 * Please leave 0 as is and don't use it
8949 */
8950 {
8951 .src = MSM_BUS_MASTER_MDP_PORT0,
8952 .dst = MSM_BUS_SLAVE_SMI,
8953 .ab = 0,
8954 .ib = 0,
8955 },
8956 /* Master and slaves can be from different fabrics */
8957 {
8958 .src = MSM_BUS_MASTER_MDP_PORT0,
8959 .dst = MSM_BUS_SLAVE_EBI_CH0,
8960 .ab = 0,
8961 .ib = 0,
8962 },
8963};
8964
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07008965#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
8966static struct msm_bus_vectors hdmi_as_primary_vectors[] = {
8967 /* If HDMI is used as primary */
8968 {
8969 .src = MSM_BUS_MASTER_MDP_PORT0,
8970 .dst = MSM_BUS_SLAVE_SMI,
8971 .ab = 2000000000,
8972 .ib = 2000000000,
8973 },
8974 /* Master and slaves can be from different fabrics */
8975 {
8976 .src = MSM_BUS_MASTER_MDP_PORT0,
8977 .dst = MSM_BUS_SLAVE_EBI_CH0,
8978 .ab = 2000000000,
8979 .ib = 2000000000,
8980 },
8981};
8982
8983static struct msm_bus_paths mdp_bus_scale_usecases[] = {
8984 {
8985 ARRAY_SIZE(mdp_init_vectors),
8986 mdp_init_vectors,
8987 },
8988 {
8989 ARRAY_SIZE(hdmi_as_primary_vectors),
8990 hdmi_as_primary_vectors,
8991 },
8992 {
8993 ARRAY_SIZE(hdmi_as_primary_vectors),
8994 hdmi_as_primary_vectors,
8995 },
8996 {
8997 ARRAY_SIZE(hdmi_as_primary_vectors),
8998 hdmi_as_primary_vectors,
8999 },
9000 {
9001 ARRAY_SIZE(hdmi_as_primary_vectors),
9002 hdmi_as_primary_vectors,
9003 },
9004 {
9005 ARRAY_SIZE(hdmi_as_primary_vectors),
9006 hdmi_as_primary_vectors,
9007 },
9008};
9009#else
9010#ifdef CONFIG_FB_MSM_LCDC_DSUB
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009011static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9012 /* Default case static display/UI/2d/3d if FB SMI */
9013 {
9014 .src = MSM_BUS_MASTER_MDP_PORT0,
9015 .dst = MSM_BUS_SLAVE_SMI,
9016 .ab = 388800000,
9017 .ib = 486000000,
9018 },
9019 /* Master and slaves can be from different fabrics */
9020 {
9021 .src = MSM_BUS_MASTER_MDP_PORT0,
9022 .dst = MSM_BUS_SLAVE_EBI_CH0,
9023 .ab = 0,
9024 .ib = 0,
9025 },
9026};
9027
9028static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9029 /* Default case static display/UI/2d/3d if FB SMI */
9030 {
9031 .src = MSM_BUS_MASTER_MDP_PORT0,
9032 .dst = MSM_BUS_SLAVE_SMI,
9033 .ab = 0,
9034 .ib = 0,
9035 },
9036 /* Master and slaves can be from different fabrics */
9037 {
9038 .src = MSM_BUS_MASTER_MDP_PORT0,
9039 .dst = MSM_BUS_SLAVE_EBI_CH0,
9040 .ab = 388800000,
9041 .ib = 486000000 * 2,
9042 },
9043};
9044static struct msm_bus_vectors mdp_vga_vectors[] = {
9045 /* VGA and less video */
9046 {
9047 .src = MSM_BUS_MASTER_MDP_PORT0,
9048 .dst = MSM_BUS_SLAVE_SMI,
9049 .ab = 458092800,
9050 .ib = 572616000,
9051 },
9052 {
9053 .src = MSM_BUS_MASTER_MDP_PORT0,
9054 .dst = MSM_BUS_SLAVE_EBI_CH0,
9055 .ab = 458092800,
9056 .ib = 572616000 * 2,
9057 },
9058};
9059static struct msm_bus_vectors mdp_720p_vectors[] = {
9060 /* 720p and less video */
9061 {
9062 .src = MSM_BUS_MASTER_MDP_PORT0,
9063 .dst = MSM_BUS_SLAVE_SMI,
9064 .ab = 471744000,
9065 .ib = 589680000,
9066 },
9067 /* Master and slaves can be from different fabrics */
9068 {
9069 .src = MSM_BUS_MASTER_MDP_PORT0,
9070 .dst = MSM_BUS_SLAVE_EBI_CH0,
9071 .ab = 471744000,
9072 .ib = 589680000 * 2,
9073 },
9074};
9075
9076static struct msm_bus_vectors mdp_1080p_vectors[] = {
9077 /* 1080p and less video */
9078 {
9079 .src = MSM_BUS_MASTER_MDP_PORT0,
9080 .dst = MSM_BUS_SLAVE_SMI,
9081 .ab = 575424000,
9082 .ib = 719280000,
9083 },
9084 /* Master and slaves can be from different fabrics */
9085 {
9086 .src = MSM_BUS_MASTER_MDP_PORT0,
9087 .dst = MSM_BUS_SLAVE_EBI_CH0,
9088 .ab = 575424000,
9089 .ib = 719280000 * 2,
9090 },
9091};
9092
9093#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009094static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9095 /* Default case static display/UI/2d/3d if FB SMI */
9096 {
9097 .src = MSM_BUS_MASTER_MDP_PORT0,
9098 .dst = MSM_BUS_SLAVE_SMI,
9099 .ab = 175110000,
9100 .ib = 218887500,
9101 },
9102 /* Master and slaves can be from different fabrics */
9103 {
9104 .src = MSM_BUS_MASTER_MDP_PORT0,
9105 .dst = MSM_BUS_SLAVE_EBI_CH0,
9106 .ab = 0,
9107 .ib = 0,
9108 },
9109};
9110
9111static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9112 /* Default case static display/UI/2d/3d if FB SMI */
9113 {
9114 .src = MSM_BUS_MASTER_MDP_PORT0,
9115 .dst = MSM_BUS_SLAVE_SMI,
9116 .ab = 0,
9117 .ib = 0,
9118 },
9119 /* Master and slaves can be from different fabrics */
9120 {
9121 .src = MSM_BUS_MASTER_MDP_PORT0,
9122 .dst = MSM_BUS_SLAVE_EBI_CH0,
9123 .ab = 216000000,
9124 .ib = 270000000 * 2,
9125 },
9126};
9127static struct msm_bus_vectors mdp_vga_vectors[] = {
9128 /* VGA and less video */
9129 {
9130 .src = MSM_BUS_MASTER_MDP_PORT0,
9131 .dst = MSM_BUS_SLAVE_SMI,
9132 .ab = 216000000,
9133 .ib = 270000000,
9134 },
9135 {
9136 .src = MSM_BUS_MASTER_MDP_PORT0,
9137 .dst = MSM_BUS_SLAVE_EBI_CH0,
9138 .ab = 216000000,
9139 .ib = 270000000 * 2,
9140 },
9141};
9142
9143static struct msm_bus_vectors mdp_720p_vectors[] = {
9144 /* 720p and less video */
9145 {
9146 .src = MSM_BUS_MASTER_MDP_PORT0,
9147 .dst = MSM_BUS_SLAVE_SMI,
9148 .ab = 230400000,
9149 .ib = 288000000,
9150 },
9151 /* Master and slaves can be from different fabrics */
9152 {
9153 .src = MSM_BUS_MASTER_MDP_PORT0,
9154 .dst = MSM_BUS_SLAVE_EBI_CH0,
9155 .ab = 230400000,
9156 .ib = 288000000 * 2,
9157 },
9158};
9159
9160static struct msm_bus_vectors mdp_1080p_vectors[] = {
9161 /* 1080p and less video */
9162 {
9163 .src = MSM_BUS_MASTER_MDP_PORT0,
9164 .dst = MSM_BUS_SLAVE_SMI,
9165 .ab = 334080000,
9166 .ib = 417600000,
9167 },
9168 /* Master and slaves can be from different fabrics */
9169 {
9170 .src = MSM_BUS_MASTER_MDP_PORT0,
9171 .dst = MSM_BUS_SLAVE_EBI_CH0,
9172 .ab = 334080000,
Ravishangar Kalyanam731beb92011-07-07 18:27:32 -07009173 .ib = 550000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009174 },
9175};
9176
9177#endif
9178static struct msm_bus_paths mdp_bus_scale_usecases[] = {
9179 {
9180 ARRAY_SIZE(mdp_init_vectors),
9181 mdp_init_vectors,
9182 },
9183 {
9184 ARRAY_SIZE(mdp_sd_smi_vectors),
9185 mdp_sd_smi_vectors,
9186 },
9187 {
9188 ARRAY_SIZE(mdp_sd_ebi_vectors),
9189 mdp_sd_ebi_vectors,
9190 },
9191 {
9192 ARRAY_SIZE(mdp_vga_vectors),
9193 mdp_vga_vectors,
9194 },
9195 {
9196 ARRAY_SIZE(mdp_720p_vectors),
9197 mdp_720p_vectors,
9198 },
9199 {
9200 ARRAY_SIZE(mdp_1080p_vectors),
9201 mdp_1080p_vectors,
9202 },
9203};
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009204#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009205static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
9206 mdp_bus_scale_usecases,
9207 ARRAY_SIZE(mdp_bus_scale_usecases),
9208 .name = "mdp",
9209};
9210
9211#endif
9212#ifdef CONFIG_MSM_BUS_SCALING
9213static struct msm_bus_vectors dtv_bus_init_vectors[] = {
9214 /* For now, 0th array entry is reserved.
9215 * Please leave 0 as is and don't use it
9216 */
9217 {
9218 .src = MSM_BUS_MASTER_MDP_PORT0,
9219 .dst = MSM_BUS_SLAVE_SMI,
9220 .ab = 0,
9221 .ib = 0,
9222 },
9223 /* Master and slaves can be from different fabrics */
9224 {
9225 .src = MSM_BUS_MASTER_MDP_PORT0,
9226 .dst = MSM_BUS_SLAVE_EBI_CH0,
9227 .ab = 0,
9228 .ib = 0,
9229 },
9230};
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009231#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
9232static struct msm_bus_vectors dtv_bus_def_vectors[] = {
9233 /* For now, 0th array entry is reserved.
9234 * Please leave 0 as is and don't use it
9235 */
9236 {
9237 .src = MSM_BUS_MASTER_MDP_PORT0,
9238 .dst = MSM_BUS_SLAVE_SMI,
9239 .ab = 2000000000,
9240 .ib = 2000000000,
9241 },
9242 /* Master and slaves can be from different fabrics */
9243 {
9244 .src = MSM_BUS_MASTER_MDP_PORT0,
9245 .dst = MSM_BUS_SLAVE_EBI_CH0,
9246 .ab = 2000000000,
9247 .ib = 2000000000,
9248 },
9249};
9250#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009251static struct msm_bus_vectors dtv_bus_def_vectors[] = {
9252 /* For now, 0th array entry is reserved.
9253 * Please leave 0 as is and don't use it
9254 */
9255 {
9256 .src = MSM_BUS_MASTER_MDP_PORT0,
9257 .dst = MSM_BUS_SLAVE_SMI,
9258 .ab = 566092800,
9259 .ib = 707616000,
9260 },
9261 /* Master and slaves can be from different fabrics */
9262 {
9263 .src = MSM_BUS_MASTER_MDP_PORT0,
9264 .dst = MSM_BUS_SLAVE_EBI_CH0,
9265 .ab = 566092800,
9266 .ib = 707616000,
9267 },
9268};
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009269#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009270static struct msm_bus_paths dtv_bus_scale_usecases[] = {
9271 {
9272 ARRAY_SIZE(dtv_bus_init_vectors),
9273 dtv_bus_init_vectors,
9274 },
9275 {
9276 ARRAY_SIZE(dtv_bus_def_vectors),
9277 dtv_bus_def_vectors,
9278 },
9279};
9280static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
9281 dtv_bus_scale_usecases,
9282 ARRAY_SIZE(dtv_bus_scale_usecases),
9283 .name = "dtv",
9284};
9285
9286static struct lcdc_platform_data dtv_pdata = {
9287 .bus_scale_table = &dtv_bus_scale_pdata,
9288};
9289#endif
9290
9291
9292static struct lcdc_platform_data lcdc_pdata = {
9293 .lcdc_power_save = lcdc_panel_power,
9294};
9295
9296
9297#define MDP_VSYNC_GPIO 28
9298
9299/*
9300 * MIPI_DSI only use 8058_LDO0 which need always on
9301 * therefore it need to be put at low power mode if
9302 * it was not used instead of turn it off.
9303 */
9304static int mipi_dsi_panel_power(int on)
9305{
9306 int flag_on = !!on;
9307 static int mipi_dsi_power_save_on;
9308 static struct regulator *ldo0;
9309 int rc = 0;
9310
9311 if (mipi_dsi_power_save_on == flag_on)
9312 return 0;
9313
9314 mipi_dsi_power_save_on = flag_on;
9315
9316 if (ldo0 == NULL) { /* init */
9317 ldo0 = regulator_get(NULL, "8058_l0");
9318 if (IS_ERR(ldo0)) {
9319 pr_debug("%s: LDO0 failed\n", __func__);
9320 rc = PTR_ERR(ldo0);
9321 return rc;
9322 }
9323
9324 rc = regulator_set_voltage(ldo0, 1200000, 1200000);
9325 if (rc)
9326 goto out;
9327
9328 rc = regulator_enable(ldo0);
9329 if (rc)
9330 goto out;
9331 }
9332
9333 if (on) {
9334 /* set ldo0 to HPM */
9335 rc = regulator_set_optimum_mode(ldo0, 100000);
9336 if (rc < 0)
9337 goto out;
9338 } else {
9339 /* set ldo0 to LPM */
Padmanabhan Komanduru0b478ff2011-11-22 19:15:40 +05309340 rc = regulator_set_optimum_mode(ldo0, 1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009341 if (rc < 0)
9342 goto out;
9343 }
9344
9345 return 0;
9346out:
9347 regulator_disable(ldo0);
9348 regulator_put(ldo0);
9349 ldo0 = NULL;
9350 return rc;
9351}
9352
9353static struct mipi_dsi_platform_data mipi_dsi_pdata = {
9354 .vsync_gpio = MDP_VSYNC_GPIO,
9355 .dsi_power_save = mipi_dsi_panel_power,
9356};
9357
9358#ifdef CONFIG_FB_MSM_TVOUT
9359static struct regulator *reg_8058_l13;
9360
9361static int atv_dac_power(int on)
9362{
9363 int rc = 0;
9364 #define _GET_REGULATOR(var, name) do { \
9365 var = regulator_get(NULL, name); \
9366 if (IS_ERR(var)) { \
9367 pr_info("'%s' regulator not found, rc=%ld\n", \
9368 name, IS_ERR(var)); \
9369 var = NULL; \
9370 return -ENODEV; \
9371 } \
9372 } while (0)
9373
9374 if (!reg_8058_l13)
9375 _GET_REGULATOR(reg_8058_l13, "8058_l13");
9376 #undef _GET_REGULATOR
9377
9378 if (on) {
9379 rc = regulator_set_voltage(reg_8058_l13, 2050000, 2050000);
9380 if (rc) {
9381 pr_info("%s: '%s' regulator set voltage failed,\
9382 rc=%d\n", __func__, "8058_l13", rc);
9383 return rc;
9384 }
9385
9386 rc = regulator_enable(reg_8058_l13);
9387 if (rc) {
9388 pr_err("%s: '%s' regulator enable failed,\
9389 rc=%d\n", __func__, "8058_l13", rc);
9390 return rc;
9391 }
9392 } else {
9393 rc = regulator_force_disable(reg_8058_l13);
9394 if (rc)
9395 pr_warning("%s: '%s' regulator disable failed, rc=%d\n",
9396 __func__, "8058_l13", rc);
9397 }
9398 return rc;
9399
9400}
9401#endif
9402
9403#ifdef CONFIG_FB_MSM_MIPI_DSI
9404int mdp_core_clk_rate_table[] = {
9405 85330000,
9406 85330000,
9407 160000000,
9408 200000000,
9409};
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009410#elif defined(CONFIG_FB_MSM_HDMI_AS_PRIMARY)
9411int mdp_core_clk_rate_table[] = {
9412 200000000,
9413 200000000,
9414 200000000,
9415 200000000,
9416};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009417#else
9418int mdp_core_clk_rate_table[] = {
9419 59080000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009420 85330000,
kuogee hsieh26791a92011-08-01 18:35:58 -07009421 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009422 200000000,
9423};
9424#endif
9425
9426static struct msm_panel_common_pdata mdp_pdata = {
9427 .gpio = MDP_VSYNC_GPIO,
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009428#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
9429 .mdp_core_clk_rate = 200000000,
9430#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009431 .mdp_core_clk_rate = 59080000,
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009432#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009433 .mdp_core_clk_table = mdp_core_clk_rate_table,
9434 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
9435#ifdef CONFIG_MSM_BUS_SCALING
9436 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
9437#endif
9438 .mdp_rev = MDP_REV_41,
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07009439 .writeback_offset = writeback_offset,
Huaibin Yanga5419422011-12-08 23:52:10 -08009440 .mdp_writeback_memtype = MEMTYPE_EBI1,
9441 .mdp_writeback_phys = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009442};
9443
Huaibin Yanga5419422011-12-08 23:52:10 -08009444static void __init reserve_mdp_memory(void)
9445{
9446 mdp_pdata.mdp_writeback_size_ov0 = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
9447 mdp_pdata.mdp_writeback_size_ov1 = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
9448
9449 msm8x60_reserve_table[mdp_pdata.mdp_writeback_memtype].size +=
9450 mdp_pdata.mdp_writeback_size_ov0;
9451 msm8x60_reserve_table[mdp_pdata.mdp_writeback_memtype].size +=
9452 mdp_pdata.mdp_writeback_size_ov1;
9453}
9454
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009455#ifdef CONFIG_FB_MSM_TVOUT
9456
9457#ifdef CONFIG_MSM_BUS_SCALING
9458static struct msm_bus_vectors atv_bus_init_vectors[] = {
9459 /* For now, 0th array entry is reserved.
9460 * Please leave 0 as is and don't use it
9461 */
9462 {
9463 .src = MSM_BUS_MASTER_MDP_PORT0,
9464 .dst = MSM_BUS_SLAVE_SMI,
9465 .ab = 0,
9466 .ib = 0,
9467 },
9468 /* Master and slaves can be from different fabrics */
9469 {
9470 .src = MSM_BUS_MASTER_MDP_PORT0,
9471 .dst = MSM_BUS_SLAVE_EBI_CH0,
9472 .ab = 0,
9473 .ib = 0,
9474 },
9475};
9476static struct msm_bus_vectors atv_bus_def_vectors[] = {
9477 /* For now, 0th array entry is reserved.
9478 * Please leave 0 as is and don't use it
9479 */
9480 {
9481 .src = MSM_BUS_MASTER_MDP_PORT0,
9482 .dst = MSM_BUS_SLAVE_SMI,
9483 .ab = 236390400,
9484 .ib = 265939200,
9485 },
9486 /* Master and slaves can be from different fabrics */
9487 {
9488 .src = MSM_BUS_MASTER_MDP_PORT0,
9489 .dst = MSM_BUS_SLAVE_EBI_CH0,
9490 .ab = 236390400,
9491 .ib = 265939200,
9492 },
9493};
9494static struct msm_bus_paths atv_bus_scale_usecases[] = {
9495 {
9496 ARRAY_SIZE(atv_bus_init_vectors),
9497 atv_bus_init_vectors,
9498 },
9499 {
9500 ARRAY_SIZE(atv_bus_def_vectors),
9501 atv_bus_def_vectors,
9502 },
9503};
9504static struct msm_bus_scale_pdata atv_bus_scale_pdata = {
9505 atv_bus_scale_usecases,
9506 ARRAY_SIZE(atv_bus_scale_usecases),
9507 .name = "atv",
9508};
9509#endif
9510
9511static struct tvenc_platform_data atv_pdata = {
9512 .poll = 0,
9513 .pm_vid_en = atv_dac_power,
9514#ifdef CONFIG_MSM_BUS_SCALING
9515 .bus_scale_table = &atv_bus_scale_pdata,
9516#endif
9517};
9518#endif
9519
9520static void __init msm_fb_add_devices(void)
9521{
9522#ifdef CONFIG_FB_MSM_LCDC_DSUB
9523 mdp_pdata.mdp_core_clk_table = NULL;
9524 mdp_pdata.num_mdp_clk = 0;
9525 mdp_pdata.mdp_core_clk_rate = 200000000;
9526#endif
9527 if (machine_is_msm8x60_rumi3())
9528 msm_fb_register_device("mdp", NULL);
9529 else
9530 msm_fb_register_device("mdp", &mdp_pdata);
9531
9532 msm_fb_register_device("lcdc", &lcdc_pdata);
9533 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
9534#ifdef CONFIG_MSM_BUS_SCALING
9535 msm_fb_register_device("dtv", &dtv_pdata);
9536#endif
9537#ifdef CONFIG_FB_MSM_TVOUT
9538 msm_fb_register_device("tvenc", &atv_pdata);
9539 msm_fb_register_device("tvout_device", NULL);
9540#endif
9541}
9542
9543#if (defined(CONFIG_MARIMBA_CORE)) && \
9544 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
9545
9546static const struct {
9547 char *name;
9548 int vmin;
9549 int vmax;
9550} bt_regs_info[] = {
9551 { "8058_s3", 1800000, 1800000 },
9552 { "8058_s2", 1300000, 1300000 },
9553 { "8058_l8", 2900000, 3050000 },
9554};
9555
9556static struct {
9557 bool enabled;
9558} bt_regs_status[] = {
9559 { false },
9560 { false },
9561 { false },
9562};
9563static struct regulator *bt_regs[ARRAY_SIZE(bt_regs_info)];
9564
9565static int bahama_bt(int on)
9566{
9567 int rc;
9568 int i;
9569 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
9570
9571 struct bahama_variant_register {
9572 const size_t size;
9573 const struct bahama_config_register *set;
9574 };
9575
9576 const struct bahama_config_register *p;
9577
9578 u8 version;
9579
9580 const struct bahama_config_register v10_bt_on[] = {
9581 { 0xE9, 0x00, 0xFF },
9582 { 0xF4, 0x80, 0xFF },
9583 { 0xE4, 0x00, 0xFF },
9584 { 0xE5, 0x00, 0x0F },
9585#ifdef CONFIG_WLAN
9586 { 0xE6, 0x38, 0x7F },
9587 { 0xE7, 0x06, 0xFF },
9588#endif
9589 { 0xE9, 0x21, 0xFF },
9590 { 0x01, 0x0C, 0x1F },
9591 { 0x01, 0x08, 0x1F },
9592 };
9593
9594 const struct bahama_config_register v20_bt_on_fm_off[] = {
9595 { 0x11, 0x0C, 0xFF },
9596 { 0x13, 0x01, 0xFF },
9597 { 0xF4, 0x80, 0xFF },
9598 { 0xF0, 0x00, 0xFF },
9599 { 0xE9, 0x00, 0xFF },
9600#ifdef CONFIG_WLAN
9601 { 0x81, 0x00, 0x7F },
9602 { 0x82, 0x00, 0xFF },
9603 { 0xE6, 0x38, 0x7F },
9604 { 0xE7, 0x06, 0xFF },
9605#endif
9606 { 0xE9, 0x21, 0xFF },
9607 };
9608
9609 const struct bahama_config_register v20_bt_on_fm_on[] = {
9610 { 0x11, 0x0C, 0xFF },
9611 { 0x13, 0x01, 0xFF },
9612 { 0xF4, 0x86, 0xFF },
9613 { 0xF0, 0x06, 0xFF },
9614 { 0xE9, 0x00, 0xFF },
9615#ifdef CONFIG_WLAN
9616 { 0x81, 0x00, 0x7F },
9617 { 0x82, 0x00, 0xFF },
9618 { 0xE6, 0x38, 0x7F },
9619 { 0xE7, 0x06, 0xFF },
9620#endif
9621 { 0xE9, 0x21, 0xFF },
9622 };
9623
9624 const struct bahama_config_register v10_bt_off[] = {
9625 { 0xE9, 0x00, 0xFF },
9626 };
9627
9628 const struct bahama_config_register v20_bt_off_fm_off[] = {
9629 { 0xF4, 0x84, 0xFF },
9630 { 0xF0, 0x04, 0xFF },
9631 { 0xE9, 0x00, 0xFF }
9632 };
9633
9634 const struct bahama_config_register v20_bt_off_fm_on[] = {
9635 { 0xF4, 0x86, 0xFF },
9636 { 0xF0, 0x06, 0xFF },
9637 { 0xE9, 0x00, 0xFF }
9638 };
9639 const struct bahama_variant_register bt_bahama[2][3] = {
9640 {
9641 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
9642 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
9643 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
9644 },
9645 {
9646 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
9647 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
9648 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
9649 }
9650 };
9651
9652 u8 offset = 0; /* index into bahama configs */
9653
9654 on = on ? 1 : 0;
9655 version = read_bahama_ver();
9656
9657 if (version == VER_UNSUPPORTED) {
9658 dev_err(&msm_bt_power_device.dev,
9659 "%s: unsupported version\n",
9660 __func__);
9661 return -EIO;
9662 }
9663
9664 if (version == VER_2_0) {
9665 if (marimba_get_fm_status(&config))
9666 offset = 0x01;
9667 }
9668
9669 /* Voting off 1.3V S2 Regulator,BahamaV2 used in Normal mode */
9670 if (on && (version == VER_2_0)) {
9671 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9672 if ((!strcmp(bt_regs_info[i].name, "8058_s2"))
9673 && (bt_regs_status[i].enabled == true)) {
9674 if (regulator_disable(bt_regs[i])) {
9675 dev_err(&msm_bt_power_device.dev,
9676 "%s: regulator disable failed",
9677 __func__);
9678 }
9679 bt_regs_status[i].enabled = false;
9680 break;
9681 }
9682 }
9683 }
9684
9685 p = bt_bahama[on][version + offset].set;
9686
9687 dev_info(&msm_bt_power_device.dev,
9688 "%s: found version %d\n", __func__, version);
9689
9690 for (i = 0; i < bt_bahama[on][version + offset].size; i++) {
9691 u8 value = (p+i)->value;
9692 rc = marimba_write_bit_mask(&config,
9693 (p+i)->reg,
9694 &value,
9695 sizeof((p+i)->value),
9696 (p+i)->mask);
9697 if (rc < 0) {
9698 dev_err(&msm_bt_power_device.dev,
9699 "%s: reg %d write failed: %d\n",
9700 __func__, (p+i)->reg, rc);
9701 return rc;
9702 }
9703 dev_dbg(&msm_bt_power_device.dev,
9704 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
9705 __func__, (p+i)->reg,
9706 value, (p+i)->mask);
9707 }
9708 /* Update BT Status */
9709 if (on)
9710 marimba_set_bt_status(&config, true);
9711 else
9712 marimba_set_bt_status(&config, false);
9713
9714 return 0;
9715}
9716
9717static int bluetooth_use_regulators(int on)
9718{
9719 int i, recover = -1, rc = 0;
9720
9721 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9722 bt_regs[i] = on ? regulator_get(&msm_bt_power_device.dev,
9723 bt_regs_info[i].name) :
9724 (regulator_put(bt_regs[i]), NULL);
9725 if (IS_ERR(bt_regs[i])) {
9726 rc = PTR_ERR(bt_regs[i]);
9727 dev_err(&msm_bt_power_device.dev,
9728 "regulator %s get failed (%d)\n",
9729 bt_regs_info[i].name, rc);
9730 recover = i - 1;
9731 bt_regs[i] = NULL;
9732 break;
9733 }
9734
9735 if (!on)
9736 continue;
9737
9738 rc = regulator_set_voltage(bt_regs[i],
9739 bt_regs_info[i].vmin,
9740 bt_regs_info[i].vmax);
9741 if (rc < 0) {
9742 dev_err(&msm_bt_power_device.dev,
9743 "regulator %s voltage set (%d)\n",
9744 bt_regs_info[i].name, rc);
9745 recover = i;
9746 break;
9747 }
9748 }
9749
9750 if (on && (recover > -1))
9751 for (i = recover; i >= 0; i--) {
9752 regulator_put(bt_regs[i]);
9753 bt_regs[i] = NULL;
9754 }
9755
9756 return rc;
9757}
9758
9759static int bluetooth_switch_regulators(int on)
9760{
9761 int i, rc = 0;
9762
9763 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9764 if (on && (bt_regs_status[i].enabled == false)) {
9765 rc = regulator_enable(bt_regs[i]);
9766 if (rc < 0) {
9767 dev_err(&msm_bt_power_device.dev,
9768 "regulator %s %s failed (%d)\n",
9769 bt_regs_info[i].name,
9770 "enable", rc);
9771 if (i > 0) {
9772 while (--i) {
9773 regulator_disable(bt_regs[i]);
9774 bt_regs_status[i].enabled
9775 = false;
9776 }
9777 break;
9778 }
9779 }
9780 bt_regs_status[i].enabled = true;
9781 } else if (!on && (bt_regs_status[i].enabled == true)) {
9782 rc = regulator_disable(bt_regs[i]);
9783 if (rc < 0) {
9784 dev_err(&msm_bt_power_device.dev,
9785 "regulator %s %s failed (%d)\n",
9786 bt_regs_info[i].name,
9787 "disable", rc);
9788 break;
9789 }
9790 bt_regs_status[i].enabled = false;
9791 }
9792 }
9793 return rc;
9794}
9795
9796static struct msm_xo_voter *bt_clock;
9797
9798static int bluetooth_power(int on)
9799{
9800 int rc = 0;
9801 int id;
9802
9803 /* In case probe function fails, cur_connv_type would be -1 */
9804 id = adie_get_detected_connectivity_type();
9805 if (id != BAHAMA_ID) {
9806 pr_err("%s: unexpected adie connectivity type: %d\n",
9807 __func__, id);
9808 return -ENODEV;
9809 }
9810
9811 if (on) {
9812
9813 rc = bluetooth_use_regulators(1);
9814 if (rc < 0)
9815 goto out;
9816
9817 rc = bluetooth_switch_regulators(1);
9818
9819 if (rc < 0)
9820 goto fail_put;
9821
9822 bt_clock = msm_xo_get(MSM_XO_TCXO_D0, "bt_power");
9823
9824 if (IS_ERR(bt_clock)) {
9825 pr_err("Couldn't get TCXO_D0 voter\n");
9826 goto fail_switch;
9827 }
9828
9829 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_ON);
9830
9831 if (rc < 0) {
9832 pr_err("Failed to vote for TCXO_DO ON\n");
9833 goto fail_vote;
9834 }
9835
9836 rc = bahama_bt(1);
9837
9838 if (rc < 0)
9839 goto fail_clock;
9840
9841 msleep(10);
9842
9843 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_PIN_CTRL);
9844
9845 if (rc < 0) {
9846 pr_err("Failed to vote for TCXO_DO pin control\n");
9847 goto fail_vote;
9848 }
9849 } else {
9850 /* check for initial RFKILL block (power off) */
9851 /* some RFKILL versions/configurations rfkill_register */
9852 /* calls here for an initial set_block */
9853 /* avoid calling i2c and regulator before unblock (on) */
9854 if (platform_get_drvdata(&msm_bt_power_device) == NULL) {
9855 dev_info(&msm_bt_power_device.dev,
9856 "%s: initialized OFF/blocked\n", __func__);
9857 goto out;
9858 }
9859
9860 bahama_bt(0);
9861
9862fail_clock:
9863 msm_xo_mode_vote(bt_clock, MSM_XO_MODE_OFF);
9864fail_vote:
9865 msm_xo_put(bt_clock);
9866fail_switch:
9867 bluetooth_switch_regulators(0);
9868fail_put:
9869 bluetooth_use_regulators(0);
9870 }
9871
9872out:
9873 if (rc < 0)
9874 on = 0;
9875 dev_info(&msm_bt_power_device.dev,
9876 "Bluetooth power switch: state %d result %d\n", on, rc);
9877
9878 return rc;
9879}
9880
9881#endif /*CONFIG_MARIMBA_CORE, CONFIG_MSM_BT_POWER, CONFIG_MSM_BT_POWER_MODULE*/
9882
9883static void __init msm8x60_cfg_smsc911x(void)
9884{
9885 smsc911x_resources[1].start =
9886 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
9887 smsc911x_resources[1].end =
9888 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
9889}
9890
9891#ifdef CONFIG_MSM_RPM
9892static struct msm_rpm_platform_data msm_rpm_data = {
9893 .reg_base_addrs = {
9894 [MSM_RPM_PAGE_STATUS] = MSM_RPM_BASE,
9895 [MSM_RPM_PAGE_CTRL] = MSM_RPM_BASE + 0x400,
9896 [MSM_RPM_PAGE_REQ] = MSM_RPM_BASE + 0x600,
9897 [MSM_RPM_PAGE_ACK] = MSM_RPM_BASE + 0xa00,
9898 },
9899
9900 .irq_ack = RPM_SCSS_CPU0_GP_HIGH_IRQ,
9901 .irq_err = RPM_SCSS_CPU0_GP_LOW_IRQ,
9902 .irq_vmpm = RPM_SCSS_CPU0_GP_MEDIUM_IRQ,
9903 .msm_apps_ipc_rpm_reg = MSM_GCC_BASE + 0x008,
9904 .msm_apps_ipc_rpm_val = 4,
9905};
9906#endif
9907
Laura Abbott5d2d1e62011-08-10 16:27:35 -07009908void msm_fusion_setup_pinctrl(void)
9909{
9910 struct msm_xo_voter *a1;
9911
9912 if (socinfo_get_platform_subtype() == 0x3) {
9913 /*
9914 * Vote for the A1 clock to be in pin control mode before
9915 * the external images are loaded.
9916 */
9917 a1 = msm_xo_get(MSM_XO_TCXO_A1, "mdm");
9918 BUG_ON(!a1);
9919 msm_xo_mode_vote(a1, MSM_XO_MODE_PIN_CTRL);
9920 }
9921}
9922
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009923struct msm_board_data {
9924 struct msm_gpiomux_configs *gpiomux_cfgs;
9925};
9926
9927static struct msm_board_data msm8x60_rumi3_board_data __initdata = {
9928 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
9929};
9930
9931static struct msm_board_data msm8x60_sim_board_data __initdata = {
9932 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
9933};
9934
9935static struct msm_board_data msm8x60_surf_board_data __initdata = {
9936 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
9937};
9938
9939static struct msm_board_data msm8x60_ffa_board_data __initdata = {
9940 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
9941};
9942
9943static struct msm_board_data msm8x60_fluid_board_data __initdata = {
9944 .gpiomux_cfgs = msm8x60_fluid_gpiomux_cfgs,
9945};
9946
9947static struct msm_board_data msm8x60_charm_surf_board_data __initdata = {
9948 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
9949};
9950
9951static struct msm_board_data msm8x60_charm_ffa_board_data __initdata = {
9952 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
9953};
9954
Zhang Chang Kenef05b172011-07-27 15:28:13 -04009955static struct msm_board_data msm8x60_dragon_board_data __initdata = {
9956 .gpiomux_cfgs = msm8x60_dragon_gpiomux_cfgs,
9957};
9958
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009959static void __init msm8x60_init(struct msm_board_data *board_data)
9960{
9961 uint32_t soc_platform_version;
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05309962#ifdef CONFIG_USB_EHCI_MSM_72K
9963 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
9964 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
9965 .level = PM8901_MPP_DIG_LEVEL_L5,
9966 .control = PM8XXX_MPP_DOUT_CTRL_HIGH,
9967 };
9968#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +05309969 pmic_reset_irq = PM8058_IRQ_BASE + PM8058_RESOUT_IRQ;
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -07009970
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009971 /*
9972 * Initialize RPM first as other drivers and devices may need
9973 * it for their initialization.
9974 */
9975#ifdef CONFIG_MSM_RPM
9976 BUG_ON(msm_rpm_init(&msm_rpm_data));
9977#endif
9978 BUG_ON(msm_rpmrs_levels_init(msm_rpmrs_levels,
9979 ARRAY_SIZE(msm_rpmrs_levels)));
9980 if (msm_xo_init())
9981 pr_err("Failed to initialize XO votes\n");
9982
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009983 msm8x60_check_2d_hardware();
9984
9985 /* Change SPM handling of core 1 if PMM 8160 is present. */
9986 soc_platform_version = socinfo_get_platform_version();
9987 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1 &&
9988 SOCINFO_VERSION_MINOR(soc_platform_version) >= 2) {
9989 struct msm_spm_platform_data *spm_data;
9990
9991 spm_data = &msm_spm_data_v1[1];
9992 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
9993 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
9994
9995 spm_data = &msm_spm_data[1];
9996 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
9997 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
9998 }
9999
10000 /*
10001 * Initialize SPM before acpuclock as the latter calls into SPM
10002 * driver to set ACPU voltages.
10003 */
10004 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10005 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
10006 else
10007 msm_spm_init(msm_spm_data_v1, ARRAY_SIZE(msm_spm_data_v1));
10008
10009 /*
10010 * Set regulators 8901_l4 and 8901_l6 to be always on in HPM for SURF
10011 * devices so that the RPM doesn't drop into a low power mode that an
10012 * un-reworked SURF cannot resume from.
10013 */
10014 if (machine_is_msm8x60_surf()) {
David Collins6f032ba2011-08-31 14:08:15 -070010015 int i;
10016
10017 for (i = 0; i < ARRAY_SIZE(rpm_regulator_init_data); i++)
10018 if (rpm_regulator_init_data[i].id
10019 == RPM_VREG_ID_PM8901_L4
10020 || rpm_regulator_init_data[i].id
10021 == RPM_VREG_ID_PM8901_L6)
10022 rpm_regulator_init_data[i]
10023 .init_data.constraints.always_on = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010024 }
10025
10026 /*
10027 * Disable regulator info printing so that regulator registration
10028 * messages do not enter the kmsg log.
10029 */
10030 regulator_suppress_info_printing();
10031
10032 /* Initialize regulators needed for clock_init. */
10033 platform_add_devices(early_regulators, ARRAY_SIZE(early_regulators));
10034
Stephen Boydbb600ae2011-08-02 20:11:40 -070010035 msm_clock_init(&msm8x60_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010036
10037 /* Buses need to be initialized before early-device registration
10038 * to get the platform data for fabrics.
10039 */
10040 msm8x60_init_buses();
10041 platform_add_devices(early_devices, ARRAY_SIZE(early_devices));
10042 /* CPU frequency control is not supported on simulated targets. */
10043 if (!machine_is_msm8x60_rumi3() && !machine_is_msm8x60_sim())
Matt Wagantallec57f062011-08-16 23:54:46 -070010044 acpuclk_init(&acpuclk_8x60_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010045
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010046 /*
10047 * Enable EBI2 only for boards which make use of it. Leave
10048 * it disabled for all others for additional power savings.
10049 */
10050 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10051 machine_is_msm8x60_rumi3() ||
10052 machine_is_msm8x60_sim() ||
10053 machine_is_msm8x60_fluid() ||
10054 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010055 msm8x60_init_ebi2();
10056 msm8x60_init_tlmm();
10057 msm8x60_init_gpiomux(board_data->gpiomux_cfgs);
10058 msm8x60_init_uart12dm();
10059 msm8x60_init_mmc();
10060
10061#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
10062 msm8x60_init_pm8058_othc();
10063#endif
10064
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010065 if (machine_is_msm8x60_fluid())
10066 pm8058_platform_data.keypad_pdata = &fluid_keypad_data;
10067 else if (machine_is_msm8x60_dragon())
10068 pm8058_platform_data.keypad_pdata = &dragon_keypad_data;
10069 else
10070 pm8058_platform_data.keypad_pdata = &ffa_keypad_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010071
Jilai Wang53d27a82011-07-13 14:32:58 -040010072 /* Specify reset pin for OV9726 */
10073 if (machine_is_msm8x60_dragon()) {
10074 msm_camera_sensor_ov9726_data.sensor_reset = 62;
10075 ov9726_sensor_8660_info.mount_angle = 270;
10076 }
10077
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010078#ifdef CONFIG_BATTERY_MSM8X60
10079 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10080 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
10081 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_fluid())
10082 platform_device_register(&msm_charger_device);
10083#endif
10084
10085 if (machine_is_msm8x60_dragon())
10086 pm8058_platform_data.charger_pdata = &pmic8058_charger_dragon;
10087 if (!machine_is_msm8x60_fluid())
10088 pm8058_platform_data.charger_pdata = &pmic8058_charger_ffa_surf;
10089
10090 /* configure pmic leds */
10091 if (machine_is_msm8x60_fluid())
10092 pm8058_platform_data.leds_pdata = &pm8058_fluid_flash_leds_data;
10093 else if (machine_is_msm8x60_dragon())
10094 pm8058_platform_data.leds_pdata = &pm8058_dragon_leds_data;
10095 else
10096 pm8058_platform_data.leds_pdata = &pm8058_flash_leds_data;
10097
10098 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
10099 machine_is_msm8x60_dragon()) {
10100 pm8058_platform_data.vibrator_pdata = &pm8058_vib_pdata;
10101 }
10102
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010103 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10104 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010105 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010106 msm8x60_cfg_smsc911x();
10107 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10108 platform_add_devices(msm_footswitch_devices,
10109 msm_num_footswitch_devices);
10110 platform_add_devices(surf_devices,
10111 ARRAY_SIZE(surf_devices));
10112
10113#ifdef CONFIG_MSM_DSPS
10114 if (machine_is_msm8x60_fluid()) {
10115 platform_device_unregister(&msm_gsbi12_qup_i2c_device);
10116 msm8x60_init_dsps();
10117 }
10118#endif
10119
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010120 pm8901_vreg_mpp0_init();
10121
10122 platform_device_register(&msm8x60_8901_mpp_vreg);
10123
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010124#ifdef CONFIG_USB_EHCI_MSM_72K
10125 /*
10126 * Drive MPP2 pin HIGH for PHY to generate ID interrupts on 8660
10127 * fluid
10128 */
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010129 if (machine_is_msm8x60_fluid())
10130 pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1), &hsusb_phy_mpp);
10131 msm_add_host(0, &msm_usb_host_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010132#endif
Lei Zhou338cab82011-08-19 13:38:17 -040010133
10134#ifdef CONFIG_SND_SOC_MSM8660_APQ
10135 if (machine_is_msm8x60_dragon())
10136 platform_add_devices(dragon_alsa_devices,
10137 ARRAY_SIZE(dragon_alsa_devices));
10138 else
10139#endif
10140 platform_add_devices(asoc_devices,
10141 ARRAY_SIZE(asoc_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010142 } else {
10143 msm8x60_configure_smc91x();
10144 platform_add_devices(rumi_sim_devices,
10145 ARRAY_SIZE(rumi_sim_devices));
10146 }
10147#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010148 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10149 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010150 msm8x60_cfg_isp1763();
10151#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010152
10153 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10154 platform_add_devices(charm_devices, ARRAY_SIZE(charm_devices));
10155
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010156
10157#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
10158 if (machine_is_msm8x60_fluid())
10159 platform_device_register(&msm_gsbi10_qup_spi_device);
10160 else
10161 platform_device_register(&msm_gsbi1_qup_spi_device);
10162#endif
10163
10164#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
10165 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
10166 if (machine_is_msm8x60_fluid())
10167 cyttsp_set_params();
10168#endif
10169 if (!machine_is_msm8x60_sim())
10170 msm_fb_add_devices();
10171 fixup_i2c_configs();
10172 register_i2c_devices();
10173
Terence Hampson1c73fef2011-07-19 17:10:49 -040010174 if (machine_is_msm8x60_dragon())
10175 smsc911x_config.reset_gpio
10176 = GPIO_ETHERNET_RESET_N_DRAGON;
10177
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010178 platform_device_register(&smsc911x_device);
10179
10180#if (defined(CONFIG_SPI_QUP)) && \
10181 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010182 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA) || \
10183 defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010184
10185 if (machine_is_msm8x60_fluid()) {
10186#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
10187 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
10188 spi_register_board_info(lcdc_samsung_spi_board_info,
10189 ARRAY_SIZE(lcdc_samsung_spi_board_info));
10190 } else
10191#endif
10192 {
10193#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
10194 spi_register_board_info(lcdc_auo_spi_board_info,
10195 ARRAY_SIZE(lcdc_auo_spi_board_info));
10196#endif
10197 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010198#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
10199 } else if (machine_is_msm8x60_dragon()) {
10200 spi_register_board_info(lcdc_nt35582_spi_board_info,
10201 ARRAY_SIZE(lcdc_nt35582_spi_board_info));
10202#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010203 }
10204#endif
10205
10206 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
10207 msm_pm_set_rpm_wakeup_irq(RPM_SCSS_CPU0_WAKE_UP_IRQ);
10208 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
10209 msm_pm_data);
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060010210 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010211
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010212 pm8058_gpios_init();
10213
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010214#ifdef CONFIG_SENSORS_MSM_ADC
10215 if (machine_is_msm8x60_fluid()) {
10216 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
10217 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
10218 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3)
10219 msm_adc_pdata.gpio_config = APROC_CONFIG;
10220 else
10221 msm_adc_pdata.gpio_config = MPROC_CONFIG;
10222 }
10223 msm_adc_pdata.target_hw = MSM_8x60;
10224#endif
10225#ifdef CONFIG_MSM8X60_AUDIO
10226 msm_snddev_init();
10227#endif
10228#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
10229 if (machine_is_msm8x60_fluid())
10230 platform_device_register(&fluid_leds_gpio);
10231 else
10232 platform_device_register(&gpio_leds);
10233#endif
10234
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010235 msm8x60_multi_sdio_init();
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010236
10237 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10238 msm_fusion_setup_pinctrl();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010239}
10240
10241static void __init msm8x60_rumi3_init(void)
10242{
10243 msm8x60_init(&msm8x60_rumi3_board_data);
10244}
10245
10246static void __init msm8x60_sim_init(void)
10247{
10248 msm8x60_init(&msm8x60_sim_board_data);
10249}
10250
10251static void __init msm8x60_surf_init(void)
10252{
10253 msm8x60_init(&msm8x60_surf_board_data);
10254}
10255
10256static void __init msm8x60_ffa_init(void)
10257{
10258 msm8x60_init(&msm8x60_ffa_board_data);
10259}
10260
10261static void __init msm8x60_fluid_init(void)
10262{
10263 msm8x60_init(&msm8x60_fluid_board_data);
10264}
10265
10266static void __init msm8x60_charm_surf_init(void)
10267{
10268 msm8x60_init(&msm8x60_charm_surf_board_data);
10269}
10270
10271static void __init msm8x60_charm_ffa_init(void)
10272{
10273 msm8x60_init(&msm8x60_charm_ffa_board_data);
10274}
10275
10276static void __init msm8x60_charm_init_early(void)
10277{
10278 msm8x60_allocate_memory_regions();
Steve Mucklea55df6e2010-01-07 12:43:24 -080010279}
10280
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010281static void __init msm8x60_dragon_init(void)
10282{
10283 msm8x60_init(&msm8x60_dragon_board_data);
10284}
10285
Steve Mucklea55df6e2010-01-07 12:43:24 -080010286MACHINE_START(MSM8X60_RUMI3, "QCT MSM8X60 RUMI3")
10287 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010288 .reserve = msm8x60_reserve,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010289 .init_irq = msm8x60_init_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010290 .init_machine = msm8x60_rumi3_init,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010291 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010292 .init_early = msm8x60_charm_init_early,
Steve Muckle49b76f72010-03-19 17:00:08 -070010293MACHINE_END
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010294
10295MACHINE_START(MSM8X60_SIM, "QCT MSM8X60 SIMULATOR")
10296 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010297 .reserve = msm8x60_reserve,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010298 .init_irq = msm8x60_init_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010299 .init_machine = msm8x60_sim_init,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010300 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010301 .init_early = msm8x60_charm_init_early,
10302MACHINE_END
10303
10304MACHINE_START(MSM8X60_SURF, "QCT MSM8X60 SURF")
10305 .map_io = msm8x60_map_io,
10306 .reserve = msm8x60_reserve,
10307 .init_irq = msm8x60_init_irq,
10308 .init_machine = msm8x60_surf_init,
10309 .timer = &msm_timer,
10310 .init_early = msm8x60_charm_init_early,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010311MACHINE_END
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010312
10313MACHINE_START(MSM8X60_FFA, "QCT MSM8X60 FFA")
10314 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010315 .reserve = msm8x60_reserve,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010316 .init_irq = msm8x60_init_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010317 .init_machine = msm8x60_ffa_init,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010318 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010319 .init_early = msm8x60_charm_init_early,
10320MACHINE_END
10321
10322MACHINE_START(MSM8X60_FLUID, "QCT MSM8X60 FLUID")
10323 .map_io = msm8x60_map_io,
10324 .reserve = msm8x60_reserve,
10325 .init_irq = msm8x60_init_irq,
10326 .init_machine = msm8x60_fluid_init,
10327 .timer = &msm_timer,
10328 .init_early = msm8x60_charm_init_early,
10329MACHINE_END
10330
10331MACHINE_START(MSM8X60_FUSION, "QCT MSM8X60 FUSION SURF")
10332 .map_io = msm8x60_map_io,
10333 .reserve = msm8x60_reserve,
10334 .init_irq = msm8x60_init_irq,
10335 .init_machine = msm8x60_charm_surf_init,
10336 .timer = &msm_timer,
10337 .init_early = msm8x60_charm_init_early,
10338MACHINE_END
10339
10340MACHINE_START(MSM8X60_FUSN_FFA, "QCT MSM8X60 FUSION FFA")
10341 .map_io = msm8x60_map_io,
10342 .reserve = msm8x60_reserve,
10343 .init_irq = msm8x60_init_irq,
10344 .init_machine = msm8x60_charm_ffa_init,
10345 .timer = &msm_timer,
10346 .init_early = msm8x60_charm_init_early,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010347MACHINE_END
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010348
10349MACHINE_START(MSM8X60_DRAGON, "QCT MSM8X60 DRAGON")
10350 .map_io = msm8x60_map_io,
10351 .reserve = msm8x60_reserve,
10352 .init_irq = msm8x60_init_irq,
10353 .init_machine = msm8x60_dragon_init,
10354 .timer = &msm_timer,
10355 .init_early = msm8x60_charm_init_early,
10356MACHINE_END