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