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