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