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