blob: 7fd07af1b35c0e036ec80ab18c43309d13b88e05 [file] [log] [blame]
Nagamalleswararao Ganji70fac1e2011-12-29 19:06:37 -08001/* Copyright (c) 2010-2012, 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>
Steve Mucklef132c6c2012-06-06 18:30:57 -070025#include <linux/regulator/msm-gpio-regulator.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070026#include <linux/regulator/pmic8901-regulator.h>
27#include <linux/bootmem.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070028#include <linux/msm_adc.h>
29#include <linux/m_adcproc.h>
30#include <linux/mfd/marimba.h>
31#include <linux/msm-charger.h>
32#include <linux/i2c.h>
33#include <linux/i2c/sx150x.h>
34#include <linux/smsc911x.h>
35#include <linux/spi/spi.h>
36#include <linux/input/tdisc_shinetsu.h>
37#include <linux/input/cy8c_ts.h>
Steve Mucklef132c6c2012-06-06 18:30:57 -070038#include <linux/cyttsp-qc.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070039#include <linux/i2c/isa1200.h>
40#include <linux/dma-mapping.h>
41#include <linux/i2c/bq27520.h>
42
43#ifdef CONFIG_ANDROID_PMEM
44#include <linux/android_pmem.h>
45#endif
46
47#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
48#include <linux/i2c/smb137b.h>
49#endif
Lei Zhou338cab82011-08-19 13:38:17 -040050#ifdef CONFIG_SND_SOC_WM8903
51#include <sound/wm8903.h>
52#endif
Steve Mucklea55df6e2010-01-07 12:43:24 -080053#include <asm/mach-types.h>
54#include <asm/mach/arch.h>
Stephen Boyd9e775ad2011-08-12 00:14:28 +010055#include <asm/setup.h>
Marc Zyngier89bdafd12011-12-22 11:39:20 +053056#include <asm/hardware/gic.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080057
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070058#include <mach/dma.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080059#include <mach/board.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070060#include <mach/irqs.h>
61#include <mach/msm_spi.h>
62#include <mach/msm_serial_hs.h>
63#include <mach/msm_serial_hs_lite.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080064#include <mach/msm_iomap.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070065#include <mach/msm_memtypes.h>
66#include <asm/mach/mmc.h>
67#include <mach/msm_battery.h>
68#include <mach/msm_hsusb.h>
Rohit Vaswania513aa8d2011-07-18 15:14:28 -070069#include <mach/gpiomux.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070070#ifdef CONFIG_MSM_DSPS
71#include <mach/msm_dsps.h>
72#endif
73#include <mach/msm_xo.h>
74#include <mach/msm_bus_board.h>
75#include <mach/socinfo.h>
76#include <linux/i2c/isl9519.h>
77#ifdef CONFIG_USB_G_ANDROID
78#include <linux/usb/android.h>
79#include <mach/usbdiag.h>
80#endif
81#include <linux/regulator/consumer.h>
82#include <linux/regulator/machine.h>
83#include <mach/sdio_al.h>
84#include <mach/rpm.h>
85#include <mach/rpm-regulator.h>
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070086#include <mach/restart.h>
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053087#include <mach/board-msm8660.h>
Olav Haugan8726caf2012-05-10 15:11:35 -070088#include <mach/iommu_domains.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080089
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070090#include "devices.h"
91#include "devices-msm8x60.h"
Abhijeet Dharmapurikarefaca4f2011-12-27 16:24:07 -080092#include <mach/cpuidle.h>
Matt Wagantall7cca4642012-02-01 16:43:24 -080093#include "pm.h"
Subhash Jadavani909e04f2012-04-12 10:52:50 +053094#include <mach/mpm.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070095#include "spm.h"
96#include "rpm_log.h"
97#include "timer.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070098#include "gpiomux-8x60.h"
99#include "rpm_stats.h"
100#include "peripheral-loader.h"
101#include <linux/platform_data/qcom_crypto_device.h>
102#include "rpm_resources.h"
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -0600103#include "pm-boot.h"
Subhash Jadavanibcd435f2012-04-24 18:26:49 +0530104#include "board-storage-common-a.h"
Laura Abbott63cfd7e2011-10-10 18:21:01 -0700105
106#include <linux/ion.h>
107#include <mach/ion.h>
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +0530108#include <mach/msm_rtb.h>
Laura Abbott63cfd7e2011-10-10 18:21:01 -0700109
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700110#define MSM_SHARED_RAM_PHYS 0x40000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700111#define MDM2AP_SYNC 129
112
Terence Hampson1c73fef2011-07-19 17:10:49 -0400113#define GPIO_ETHERNET_RESET_N_DRAGON 30
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700114#define LCDC_SPI_GPIO_CLK 73
115#define LCDC_SPI_GPIO_CS 72
116#define LCDC_SPI_GPIO_MOSI 70
117#define LCDC_AUO_PANEL_NAME "lcdc_auo_wvga"
118#define LCDC_SAMSUNG_OLED_PANEL_NAME "lcdc_samsung_oled"
119#define LCDC_SAMSUNG_WSVGA_PANEL_NAME "lcdc_samsung_wsvga"
120#define LCDC_SAMSUNG_SPI_DEVICE_NAME "lcdc_samsung_ams367pe02"
121#define LCDC_AUO_SPI_DEVICE_NAME "lcdc_auo_nt35582"
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -0400122#define LCDC_NT35582_PANEL_NAME "lcdc_nt35582_wvga"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700123
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -0700124#define MIPI_CMD_NOVATEK_QHD_PANEL_NAME "mipi_cmd_novatek_qhd"
125#define MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME "mipi_video_novatek_qhd"
126#define MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME "mipi_video_toshiba_wvga"
127#define HDMI_PANEL_NAME "hdmi_msm"
128#define TVOUT_PANEL_NAME "tvout_msm"
129
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700130#define DSPS_PIL_GENERIC_NAME "dsps"
131#define DSPS_PIL_FLUID_NAME "dsps_fluid"
132
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -0800133#ifdef CONFIG_ION_MSM
134static struct platform_device ion_dev;
135#endif
136
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700137enum {
138 GPIO_EXPANDER_IRQ_BASE = PM8901_IRQ_BASE + NR_PMIC8901_IRQS,
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530139 GPIO_EXPANDER_GPIO_BASE = PM8901_MPP_BASE + PM8901_MPPS,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700140 /* CORE expander */
141 GPIO_CORE_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE,
142 GPIO_CLASS_D1_EN = GPIO_CORE_EXPANDER_BASE,
143 GPIO_WLAN_DEEP_SLEEP_N,
144 GPIO_LVDS_SHUTDOWN_N,
145 GPIO_DISP_RESX_N = GPIO_LVDS_SHUTDOWN_N,
146 GPIO_MS_SYS_RESET_N,
147 GPIO_CAP_TS_RESOUT_N,
148 GPIO_CAP_GAUGE_BI_TOUT,
149 GPIO_ETHERNET_PME,
150 GPIO_EXT_GPS_LNA_EN,
151 GPIO_MSM_WAKES_BT,
152 GPIO_ETHERNET_RESET_N,
153 GPIO_HEADSET_DET_N,
154 GPIO_USB_UICC_EN,
155 GPIO_BACKLIGHT_EN,
156 GPIO_EXT_CAMIF_PWR_EN,
157 GPIO_BATT_GAUGE_INT_N,
158 GPIO_BATT_GAUGE_EN,
159 /* DOCKING expander */
160 GPIO_DOCKING_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + 16,
161 GPIO_MIPI_DSI_RST_N = GPIO_DOCKING_EXPANDER_BASE,
162 GPIO_AUX_JTAG_DET_N,
163 GPIO_DONGLE_DET_N,
164 GPIO_SVIDEO_LOAD_DET,
165 GPIO_SVID_AMP_SHUTDOWN1_N,
166 GPIO_SVID_AMP_SHUTDOWN0_N,
167 GPIO_SDC_WP,
168 GPIO_IRDA_PWDN,
169 GPIO_IRDA_RESET_N,
170 GPIO_DONGLE_GPIO0,
171 GPIO_DONGLE_GPIO1,
172 GPIO_DONGLE_GPIO2,
173 GPIO_DONGLE_GPIO3,
174 GPIO_DONGLE_PWR_EN,
175 GPIO_EMMC_RESET_N,
176 GPIO_TP_EXP2_IO15,
177 /* SURF expander */
178 GPIO_SURF_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + (16 * 2),
179 GPIO_SD_CARD_DET_1 = GPIO_SURF_EXPANDER_BASE,
180 GPIO_SD_CARD_DET_2,
181 GPIO_SD_CARD_DET_4,
182 GPIO_SD_CARD_DET_5,
183 GPIO_UIM3_RST,
184 GPIO_SURF_EXPANDER_IO5,
185 GPIO_SURF_EXPANDER_IO6,
186 GPIO_ADC_I2C_EN,
187 GPIO_SURF_EXPANDER_IO8,
188 GPIO_SURF_EXPANDER_IO9,
189 GPIO_SURF_EXPANDER_IO10,
190 GPIO_SURF_EXPANDER_IO11,
191 GPIO_SURF_EXPANDER_IO12,
192 GPIO_SURF_EXPANDER_IO13,
193 GPIO_SURF_EXPANDER_IO14,
194 GPIO_SURF_EXPANDER_IO15,
195 /* LEFT KB IO expander */
196 GPIO_LEFT_KB_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + (16 * 3),
197 GPIO_LEFT_LED_1 = GPIO_LEFT_KB_EXPANDER_BASE,
198 GPIO_LEFT_LED_2,
199 GPIO_LEFT_LED_3,
200 GPIO_LEFT_LED_WLAN,
201 GPIO_JOYSTICK_EN,
202 GPIO_CAP_TS_SLEEP,
203 GPIO_LEFT_KB_IO6,
204 GPIO_LEFT_LED_5,
205 /* RIGHT KB IO expander */
206 GPIO_RIGHT_KB_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + (16 * 3) + 8,
207 GPIO_RIGHT_LED_1 = GPIO_RIGHT_KB_EXPANDER_BASE,
208 GPIO_RIGHT_LED_2,
209 GPIO_RIGHT_LED_3,
210 GPIO_RIGHT_LED_BT,
211 GPIO_WEB_CAMIF_STANDBY,
212 GPIO_COMPASS_RST_N,
213 GPIO_WEB_CAMIF_RESET_N,
214 GPIO_RIGHT_LED_5,
215 GPIO_R_ALTIMETER_RESET_N,
216 /* FLUID S IO expander */
217 GPIO_SOUTH_EXPANDER_BASE,
218 GPIO_MIC2_ANCR_SEL = GPIO_SOUTH_EXPANDER_BASE,
219 GPIO_MIC1_ANCL_SEL,
220 GPIO_HS_MIC4_SEL,
221 GPIO_FML_MIC3_SEL,
222 GPIO_FMR_MIC5_SEL,
223 GPIO_TS_SLEEP,
224 GPIO_HAP_SHIFT_LVL_OE,
225 GPIO_HS_SW_DIR,
226 /* FLUID N IO expander */
227 GPIO_NORTH_EXPANDER_BASE,
228 GPIO_EPM_3_3V_EN = GPIO_NORTH_EXPANDER_BASE,
229 GPIO_EPM_5V_BOOST_EN,
230 GPIO_AUX_CAM_2P7_EN,
231 GPIO_LED_FLASH_EN,
232 GPIO_LED1_GREEN_N,
233 GPIO_LED2_RED_N,
234 GPIO_FRONT_CAM_RESET_N,
235 GPIO_EPM_LVLSFT_EN,
236 GPIO_N_ALTIMETER_RESET_N,
237 /* EPM expander */
238 GPIO_EPM_EXPANDER_BASE,
239 GPIO_PWR_MON_START = GPIO_EPM_EXPANDER_BASE,
240 GPIO_PWR_MON_RESET_N,
241 GPIO_ADC1_PWDN_N,
242 GPIO_ADC2_PWDN_N,
243 GPIO_EPM_EXPANDER_IO4,
244 GPIO_ADC1_MUX_SPI_INT_N_3_3V,
245 GPIO_ADC2_MUX_SPI_INT_N,
246 GPIO_EPM_EXPANDER_IO7,
247 GPIO_PWR_MON_ENABLE,
248 GPIO_EPM_SPI_ADC1_CS_N,
249 GPIO_EPM_SPI_ADC2_CS_N,
250 GPIO_EPM_EXPANDER_IO11,
251 GPIO_EPM_EXPANDER_IO12,
252 GPIO_EPM_EXPANDER_IO13,
253 GPIO_EPM_EXPANDER_IO14,
254 GPIO_EPM_EXPANDER_IO15,
255};
256
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530257struct pm8xxx_mpp_init_info {
258 unsigned mpp;
259 struct pm8xxx_mpp_config_data config;
260};
261
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530262#define PM8058_MPP_INIT(_mpp, _type, _level, _control) \
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530263{ \
264 .mpp = PM8058_MPP_PM_TO_SYS(_mpp), \
265 .config = { \
266 .type = PM8XXX_MPP_TYPE_##_type, \
267 .level = _level, \
268 .control = PM8XXX_MPP_##_control, \
269 } \
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100270}
271
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530272#define PM8901_MPP_INIT(_mpp, _type, _level, _control) \
273{ \
274 .mpp = PM8901_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,
Matt Wagantall2ecbec22012-03-13 23:18:07 -0700438 .max_uV = 1325000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700439 },
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,
Matt Wagantall2ecbec22012-03-13 23:18:07 -0700449 .max_uV = 1325000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700450 },
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,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800607 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700608};
609
610static struct platform_device qcrypto_device = {
611 .name = "qcrypto",
612 .id = 0,
613 .num_resources = ARRAY_SIZE(qcrypto_resources),
614 .resource = qcrypto_resources,
615 .dev = {
616 .coherent_dma_mask = DMA_BIT_MASK(32),
617 .platform_data = &qcrypto_ce_hw_suppport,
618 },
619};
620#endif
621
622#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
623 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
624
625static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
626 .ce_shared = QCE_CE_SHARED,
627 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
628 .hw_key_support = QCE_HW_KEY_SUPPORT,
629 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800630 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700631};
632
633static struct platform_device qcedev_device = {
634 .name = "qce",
635 .id = 0,
636 .num_resources = ARRAY_SIZE(qcedev_resources),
637 .resource = qcedev_resources,
638 .dev = {
639 .coherent_dma_mask = DMA_BIT_MASK(32),
640 .platform_data = &qcedev_ce_hw_suppport,
641 },
642};
643#endif
644
645#if defined(CONFIG_HAPTIC_ISA1200) || \
646 defined(CONFIG_HAPTIC_ISA1200_MODULE)
647
648static const char *vregs_isa1200_name[] = {
649 "8058_s3",
650 "8901_l4",
651};
652
653static const int vregs_isa1200_val[] = {
654 1800000,/* uV */
655 2600000,
656};
657static struct regulator *vregs_isa1200[ARRAY_SIZE(vregs_isa1200_name)];
658static struct msm_xo_voter *xo_handle_a1;
659
660static int isa1200_power(int vreg_on)
Steve Mucklea55df6e2010-01-07 12:43:24 -0800661{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700662 int i, rc = 0;
663
664 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++) {
665 rc = vreg_on ? regulator_enable(vregs_isa1200[i]) :
666 regulator_disable(vregs_isa1200[i]);
667 if (rc < 0) {
668 pr_err("%s: vreg %s %s failed (%d)\n",
669 __func__, vregs_isa1200_name[i],
670 vreg_on ? "enable" : "disable", rc);
671 goto vreg_fail;
672 }
673 }
674
675 rc = vreg_on ? msm_xo_mode_vote(xo_handle_a1, MSM_XO_MODE_ON) :
676 msm_xo_mode_vote(xo_handle_a1, MSM_XO_MODE_OFF);
677 if (rc < 0) {
678 pr_err("%s: failed to %svote for TCXO A1 buffer%d\n",
679 __func__, vreg_on ? "" : "de-", rc);
680 goto vreg_fail;
681 }
682 return 0;
683
684vreg_fail:
685 while (i--)
686 !vreg_on ? regulator_enable(vregs_isa1200[i]) :
687 regulator_disable(vregs_isa1200[i]);
688 return rc;
Steve Mucklea55df6e2010-01-07 12:43:24 -0800689}
690
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700691static int isa1200_dev_setup(bool enable)
Steve Mucklea55df6e2010-01-07 12:43:24 -0800692{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700693 int i, rc;
Steve Muckle9161d302010-02-11 11:50:40 -0800694
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700695 if (enable == true) {
696 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++) {
697 vregs_isa1200[i] = regulator_get(NULL,
698 vregs_isa1200_name[i]);
699 if (IS_ERR(vregs_isa1200[i])) {
700 pr_err("%s: regulator get of %s failed (%ld)\n",
701 __func__, vregs_isa1200_name[i],
702 PTR_ERR(vregs_isa1200[i]));
703 rc = PTR_ERR(vregs_isa1200[i]);
704 goto vreg_get_fail;
705 }
706 rc = regulator_set_voltage(vregs_isa1200[i],
707 vregs_isa1200_val[i], vregs_isa1200_val[i]);
708 if (rc) {
709 pr_err("%s: regulator_set_voltage(%s) failed\n",
710 __func__, vregs_isa1200_name[i]);
711 goto vreg_get_fail;
712 }
713 }
Steve Muckle9161d302010-02-11 11:50:40 -0800714
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700715 rc = gpio_request(GPIO_HAP_SHIFT_LVL_OE, "haptics_shft_lvl_oe");
716 if (rc) {
717 pr_err("%s: unable to request gpio %d (%d)\n",
718 __func__, GPIO_HAP_SHIFT_LVL_OE, rc);
719 goto vreg_get_fail;
720 }
Steve Muckle9161d302010-02-11 11:50:40 -0800721
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700722 rc = gpio_direction_output(GPIO_HAP_SHIFT_LVL_OE, 1);
723 if (rc) {
724 pr_err("%s: Unable to set direction\n", __func__);;
725 goto free_gpio;
726 }
727
728 xo_handle_a1 = msm_xo_get(MSM_XO_TCXO_A1, "isa1200");
729 if (IS_ERR(xo_handle_a1)) {
730 rc = PTR_ERR(xo_handle_a1);
731 pr_err("%s: failed to get the handle for A1(%d)\n",
732 __func__, rc);
733 goto gpio_set_dir;
734 }
735 } else {
736 gpio_set_value(GPIO_HAP_SHIFT_LVL_OE, 0);
737 gpio_free(GPIO_HAP_SHIFT_LVL_OE);
738
739 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++)
740 regulator_put(vregs_isa1200[i]);
741
742 msm_xo_put(xo_handle_a1);
743 }
744
745 return 0;
746gpio_set_dir:
747 gpio_set_value(GPIO_HAP_SHIFT_LVL_OE, 0);
748free_gpio:
749 gpio_free(GPIO_HAP_SHIFT_LVL_OE);
750vreg_get_fail:
751 while (i)
752 regulator_put(vregs_isa1200[--i]);
753 return rc;
754}
755
756#define PMIC_GPIO_HAP_ENABLE 18 /* PMIC GPIO Number 19 */
Mohan Pallaka4a1160d2011-09-09 15:17:45 +0530757#define PMIC_GPIO_HAP_LDO_ENABLE 5 /* PMIC GPIO Number 6 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700758static struct isa1200_platform_data isa1200_1_pdata = {
759 .name = "vibrator",
760 .power_on = isa1200_power,
761 .dev_setup = isa1200_dev_setup,
762 /*gpio to enable haptic*/
763 .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
Mohan Pallaka4a1160d2011-09-09 15:17:45 +0530764 .hap_len_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700765 .max_timeout = 15000,
766 .mode_ctrl = PWM_GEN_MODE,
767 .pwm_fd = {
768 .pwm_div = 256,
769 },
770 .is_erm = false,
771 .smart_en = true,
772 .ext_clk_en = true,
773 .chip_en = 1,
774};
775
776static struct i2c_board_info msm_isa1200_board_info[] = {
777 {
778 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
779 .platform_data = &isa1200_1_pdata,
780 },
781};
782#endif
783
784#if defined(CONFIG_BATTERY_BQ27520) || \
785 defined(CONFIG_BATTERY_BQ27520_MODULE)
786static struct bq27520_platform_data bq27520_pdata = {
787 .name = "fuel-gauge",
788 .vreg_name = "8058_s3",
789 .vreg_value = 1800000,
790 .soc_int = GPIO_BATT_GAUGE_INT_N,
791 .bi_tout = GPIO_CAP_GAUGE_BI_TOUT,
792 .chip_en = GPIO_BATT_GAUGE_EN,
793 .enable_dlog = 0, /* if enable coulomb counter logger */
794};
795
796static struct i2c_board_info msm_bq27520_board_info[] = {
797 {
798 I2C_BOARD_INFO("bq27520", 0xaa>>1),
799 .platform_data = &bq27520_pdata,
800 },
801};
802#endif
803
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700804static struct msm_rpmrs_level msm_rpmrs_levels[] __initdata = {
805 {
806 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
807 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
808 true,
809 1, 8000, 100000, 1,
810 },
811
812 {
813 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
814 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
815 true,
816 1500, 5000, 60100000, 3000,
817 },
818
819 {
820 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
821 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
822 false,
823 1800, 5000, 60350000, 3500,
824 },
825 {
826 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
827 MSM_RPMRS_LIMITS(OFF, ACTIVE, MAX, ACTIVE),
828 false,
829 3800, 4500, 65350000, 5500,
830 },
831
832 {
833 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
834 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, MAX, ACTIVE),
835 false,
836 2800, 2500, 66850000, 4800,
837 },
838
839 {
840 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
841 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
842 false,
843 4800, 2000, 71850000, 6800,
844 },
845
846 {
847 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
848 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
849 false,
850 6800, 500, 75850000, 8800,
851 },
852
853 {
854 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
855 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
856 false,
857 7800, 0, 76350000, 9800,
858 },
859};
860
Praveen Chidambaram78499012011-11-01 17:15:17 -0600861static struct msm_rpmrs_platform_data msm_rpmrs_data __initdata = {
862 .levels = &msm_rpmrs_levels[0],
863 .num_levels = ARRAY_SIZE(msm_rpmrs_levels),
864 .vdd_mem_levels = {
865 [MSM_RPMRS_VDD_MEM_RET_LOW] = 500,
866 [MSM_RPMRS_VDD_MEM_RET_HIGH] = 750,
867 [MSM_RPMRS_VDD_MEM_ACTIVE] = 1000,
Matt Wagantall2ecbec22012-03-13 23:18:07 -0700868 [MSM_RPMRS_VDD_MEM_MAX] = 1325,
Praveen Chidambaram78499012011-11-01 17:15:17 -0600869 },
870 .vdd_dig_levels = {
871 [MSM_RPMRS_VDD_DIG_RET_LOW] = 500,
872 [MSM_RPMRS_VDD_DIG_RET_HIGH] = 750,
873 [MSM_RPMRS_VDD_DIG_ACTIVE] = 1000,
874 [MSM_RPMRS_VDD_DIG_MAX] = 1250,
875 },
876 .vdd_mask = 0xFFF,
877 .rpmrs_target_id = {
878 [MSM_RPMRS_ID_PXO_CLK] = MSM_RPM_ID_PXO_CLK,
879 [MSM_RPMRS_ID_L2_CACHE_CTL] = MSM_RPM_ID_APPS_L2_CACHE_CTL,
880 [MSM_RPMRS_ID_VDD_DIG_0] = MSM_RPM_ID_SMPS1_0,
881 [MSM_RPMRS_ID_VDD_DIG_1] = MSM_RPM_ID_SMPS1_1,
882 [MSM_RPMRS_ID_VDD_MEM_0] = MSM_RPM_ID_SMPS0_0,
883 [MSM_RPMRS_ID_VDD_MEM_1] = MSM_RPM_ID_SMPS0_1,
884 [MSM_RPMRS_ID_RPM_CTL] = MSM_RPM_ID_TRIGGER_SET_FROM,
885 },
886};
887
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600888static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
889 .mode = MSM_PM_BOOT_CONFIG_TZ,
890};
891
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700892#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
893
894#define ISP1763_INT_GPIO 117
895#define ISP1763_RST_GPIO 152
896static struct resource isp1763_resources[] = {
897 [0] = {
898 .flags = IORESOURCE_MEM,
899 .start = 0x1D000000,
900 .end = 0x1D005FFF, /* 24KB */
901 },
902 [1] = {
903 .flags = IORESOURCE_IRQ,
904 },
905};
906static void __init msm8x60_cfg_isp1763(void)
907{
908 isp1763_resources[1].start = gpio_to_irq(ISP1763_INT_GPIO);
909 isp1763_resources[1].end = gpio_to_irq(ISP1763_INT_GPIO);
910}
911
912static int isp1763_setup_gpio(int enable)
913{
914 int status = 0;
915
916 if (enable) {
917 status = gpio_request(ISP1763_INT_GPIO, "isp1763_usb");
918 if (status) {
919 pr_err("%s:Failed to request GPIO %d\n",
920 __func__, ISP1763_INT_GPIO);
921 return status;
922 }
923 status = gpio_direction_input(ISP1763_INT_GPIO);
924 if (status) {
925 pr_err("%s:Failed to configure GPIO %d\n",
926 __func__, ISP1763_INT_GPIO);
927 goto gpio_free_int;
928 }
929 status = gpio_request(ISP1763_RST_GPIO, "isp1763_usb");
930 if (status) {
931 pr_err("%s:Failed to request GPIO %d\n",
932 __func__, ISP1763_RST_GPIO);
933 goto gpio_free_int;
934 }
935 status = gpio_direction_output(ISP1763_RST_GPIO, 1);
936 if (status) {
937 pr_err("%s:Failed to configure GPIO %d\n",
938 __func__, ISP1763_RST_GPIO);
939 goto gpio_free_rst;
940 }
941 pr_debug("\nISP GPIO configuration done\n");
942 return status;
943 }
944
945gpio_free_rst:
946 gpio_free(ISP1763_RST_GPIO);
947gpio_free_int:
948 gpio_free(ISP1763_INT_GPIO);
949
950 return status;
951}
952static struct isp1763_platform_data isp1763_pdata = {
953 .reset_gpio = ISP1763_RST_GPIO,
954 .setup_gpio = isp1763_setup_gpio
955};
956
957static struct platform_device isp1763_device = {
958 .name = "isp1763_usb",
959 .num_resources = ARRAY_SIZE(isp1763_resources),
960 .resource = isp1763_resources,
961 .dev = {
962 .platform_data = &isp1763_pdata
963 }
964};
965#endif
966
Lena Salman57d167e2012-03-21 19:46:38 +0200967#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_MSM_72K)
Anji jonnalaeb9e60d2011-10-05 12:19:46 +0530968static struct msm_otg_platform_data msm_otg_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700969static struct regulator *ldo6_3p3;
970static struct regulator *ldo7_1p8;
971static struct regulator *vdd_cx;
972#define PMICID_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 36)
Anji jonnalaae745e92011-11-14 18:34:31 +0530973#define PMIC_ID_GPIO 36
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700974notify_vbus_state notify_vbus_state_func_ptr;
975static int usb_phy_susp_dig_vol = 750000;
976static int pmic_id_notif_supported;
977
978#ifdef CONFIG_USB_EHCI_MSM_72K
979#define USB_PMIC_ID_DET_DELAY msecs_to_jiffies(100)
980struct delayed_work pmic_id_det;
981
982static int __init usb_id_pin_rework_setup(char *support)
983{
984 if (strncmp(support, "true", 4) == 0)
985 pmic_id_notif_supported = 1;
986
987 return 1;
988}
989__setup("usb_id_pin_rework=", usb_id_pin_rework_setup);
990
991static void pmic_id_detect(struct work_struct *w)
992{
993 int val = gpio_get_value_cansleep(PM8058_GPIO_PM_TO_SYS(36));
994 pr_debug("%s(): gpio_read_value = %d\n", __func__, val);
995
996 if (notify_vbus_state_func_ptr)
997 (*notify_vbus_state_func_ptr) (val);
998}
999
1000static irqreturn_t pmic_id_on_irq(int irq, void *data)
1001{
1002 /*
1003 * Spurious interrupts are observed on pmic gpio line
1004 * even though there is no state change on USB ID. Schedule the
1005 * work to to allow debounce on gpio
Steve Muckle9161d302010-02-11 11:50:40 -08001006 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001007 schedule_delayed_work(&pmic_id_det, USB_PMIC_ID_DET_DELAY);
Steve Muckle9161d302010-02-11 11:50:40 -08001008
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001009 return IRQ_HANDLED;
1010}
1011
Anji jonnalaae745e92011-11-14 18:34:31 +05301012static int msm_hsusb_phy_id_setup_init(int init)
1013{
1014 unsigned ret;
1015
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301016 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
1017 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
1018 .level = PM8901_MPP_DIG_LEVEL_L5,
1019 };
1020
Anji jonnalaae745e92011-11-14 18:34:31 +05301021 if (init) {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301022 hsusb_phy_mpp.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
1023 ret = pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1),
1024 &hsusb_phy_mpp);
Anji jonnalaae745e92011-11-14 18:34:31 +05301025 if (ret < 0)
1026 pr_err("%s:MPP2 configuration failed\n", __func__);
1027 } else {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301028 hsusb_phy_mpp.control = PM8XXX_MPP_DOUT_CTRL_LOW;
1029 ret = pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1),
1030 &hsusb_phy_mpp);
Anji jonnalaae745e92011-11-14 18:34:31 +05301031 if (ret < 0)
1032 pr_err("%s:MPP2 un config failed\n", __func__);
1033 }
1034 return ret;
1035}
1036
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001037static int msm_hsusb_pmic_id_notif_init(void (*callback)(int online), int init)
1038{
1039 unsigned ret = -ENODEV;
1040
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301041 struct pm_gpio pmic_id_cfg = {
Anji jonnalaae745e92011-11-14 18:34:31 +05301042 .direction = PM_GPIO_DIR_IN,
1043 .pull = PM_GPIO_PULL_UP_1P5,
1044 .function = PM_GPIO_FUNC_NORMAL,
1045 .vin_sel = 2,
1046 .inv_int_pol = 0,
1047 };
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301048 struct pm_gpio pmic_id_uncfg = {
Anji jonnalaae745e92011-11-14 18:34:31 +05301049 .direction = PM_GPIO_DIR_IN,
1050 .pull = PM_GPIO_PULL_NO,
1051 .function = PM_GPIO_FUNC_NORMAL,
1052 .vin_sel = 2,
1053 .inv_int_pol = 0,
1054 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001055 if (!callback)
1056 return -EINVAL;
1057
1058 if (machine_is_msm8x60_fluid())
1059 return -ENOTSUPP;
1060
1061 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 2) {
1062 pr_debug("%s: USB_ID pin is not routed to PMIC"
1063 "on V1 surf/ffa\n", __func__);
1064 return -ENOTSUPP;
1065 }
1066
Manu Gautam62158eb2011-11-24 16:20:46 +05301067 if ((machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa() ||
1068 machine_is_msm8x60_ffa()) && !pmic_id_notif_supported) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001069 pr_debug("%s: USB_ID is not routed to PMIC"
1070 "on V2 ffa\n", __func__);
1071 return -ENOTSUPP;
1072 }
1073
1074 usb_phy_susp_dig_vol = 500000;
1075
1076 if (init) {
1077 notify_vbus_state_func_ptr = callback;
Manu Gautame8420ef2011-11-11 15:37:21 +05301078 INIT_DELAYED_WORK(&pmic_id_det, pmic_id_detect);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301079 ret = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(PMIC_ID_GPIO),
1080 &pmic_id_cfg);
Anji jonnalaae745e92011-11-14 18:34:31 +05301081 if (ret) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301082 pr_err("%s:return val of pm8xxx_gpio_config: %d\n",
Anji jonnalaae745e92011-11-14 18:34:31 +05301083 __func__, ret);
1084 return ret;
1085 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001086 ret = request_threaded_irq(PMICID_INT, NULL, pmic_id_on_irq,
1087 (IRQF_TRIGGER_RISING|IRQF_TRIGGER_FALLING),
1088 "msm_otg_id", NULL);
1089 if (ret) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001090 pr_err("%s:pmic_usb_id interrupt registration failed",
1091 __func__);
1092 return ret;
1093 }
Anji jonnalaeb9e60d2011-10-05 12:19:46 +05301094 msm_otg_pdata.pmic_id_irq = PMICID_INT;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001095 } else {
Anji jonnalaae745e92011-11-14 18:34:31 +05301096 usb_phy_susp_dig_vol = 750000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001097 free_irq(PMICID_INT, 0);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301098 ret = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(PMIC_ID_GPIO),
1099 &pmic_id_uncfg);
Anji jonnalaae745e92011-11-14 18:34:31 +05301100 if (ret) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301101 pr_err("%s: return val of pm8xxx_gpio_config: %d\n",
Anji jonnalaae745e92011-11-14 18:34:31 +05301102 __func__, ret);
1103 return ret;
1104 }
Anji jonnalaeb9e60d2011-10-05 12:19:46 +05301105 msm_otg_pdata.pmic_id_irq = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001106 cancel_delayed_work_sync(&pmic_id_det);
1107 notify_vbus_state_func_ptr = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001108 }
1109 return 0;
1110}
1111#endif
1112
1113#define USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL 1000000
1114#define USB_PHY_MAX_VDD_DIG_VOL 1320000
1115static int msm_hsusb_init_vddcx(int init)
1116{
1117 int ret = 0;
1118
1119 if (init) {
1120 vdd_cx = regulator_get(NULL, "8058_s1");
1121 if (IS_ERR(vdd_cx)) {
1122 return PTR_ERR(vdd_cx);
1123 }
1124
1125 ret = regulator_set_voltage(vdd_cx,
1126 USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL,
1127 USB_PHY_MAX_VDD_DIG_VOL);
1128 if (ret) {
1129 pr_err("%s: unable to set the voltage for regulator"
1130 "vdd_cx\n", __func__);
1131 regulator_put(vdd_cx);
1132 return ret;
1133 }
1134
1135 ret = regulator_enable(vdd_cx);
1136 if (ret) {
1137 pr_err("%s: unable to enable regulator"
1138 "vdd_cx\n", __func__);
1139 regulator_put(vdd_cx);
1140 }
1141 } else {
1142 ret = regulator_disable(vdd_cx);
1143 if (ret) {
1144 pr_err("%s: Unable to disable the regulator:"
1145 "vdd_cx\n", __func__);
1146 return ret;
1147 }
1148
1149 regulator_put(vdd_cx);
1150 }
1151
1152 return ret;
1153}
1154
1155static int msm_hsusb_config_vddcx(int high)
1156{
1157 int max_vol = USB_PHY_MAX_VDD_DIG_VOL;
1158 int min_vol;
1159 int ret;
1160
1161 if (high)
1162 min_vol = USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL;
1163 else
1164 min_vol = usb_phy_susp_dig_vol;
1165
1166 ret = regulator_set_voltage(vdd_cx, min_vol, max_vol);
1167 if (ret) {
1168 pr_err("%s: unable to set the voltage for regulator"
1169 "vdd_cx\n", __func__);
1170 return ret;
1171 }
1172
1173 pr_debug("%s: min_vol:%d max_vol:%d\n", __func__, min_vol, max_vol);
1174
1175 return ret;
1176}
1177
1178#define USB_PHY_3P3_VOL_MIN 3050000 /* uV */
1179#define USB_PHY_3P3_VOL_MAX 3050000 /* uV */
1180#define USB_PHY_3P3_HPM_LOAD 50000 /* uA */
1181#define USB_PHY_3P3_LPM_LOAD 4000 /* uA */
1182
1183#define USB_PHY_1P8_VOL_MIN 1800000 /* uV */
1184#define USB_PHY_1P8_VOL_MAX 1800000 /* uV */
1185#define USB_PHY_1P8_HPM_LOAD 50000 /* uA */
1186#define USB_PHY_1P8_LPM_LOAD 4000 /* uA */
1187static int msm_hsusb_ldo_init(int init)
1188{
1189 int rc = 0;
1190
1191 if (init) {
1192 ldo6_3p3 = regulator_get(NULL, "8058_l6");
1193 if (IS_ERR(ldo6_3p3))
1194 return PTR_ERR(ldo6_3p3);
1195
1196 ldo7_1p8 = regulator_get(NULL, "8058_l7");
1197 if (IS_ERR(ldo7_1p8)) {
1198 rc = PTR_ERR(ldo7_1p8);
1199 goto put_3p3;
1200 }
1201
1202 rc = regulator_set_voltage(ldo6_3p3, USB_PHY_3P3_VOL_MIN,
1203 USB_PHY_3P3_VOL_MAX);
1204 if (rc) {
1205 pr_err("%s: Unable to set voltage level for"
1206 "ldo6_3p3 regulator\n", __func__);
1207 goto put_1p8;
1208 }
1209 rc = regulator_enable(ldo6_3p3);
1210 if (rc) {
1211 pr_err("%s: Unable to enable the regulator:"
1212 "ldo6_3p3\n", __func__);
1213 goto put_1p8;
1214 }
1215 rc = regulator_set_voltage(ldo7_1p8, USB_PHY_1P8_VOL_MIN,
1216 USB_PHY_1P8_VOL_MAX);
1217 if (rc) {
1218 pr_err("%s: Unable to set voltage level for"
1219 "ldo7_1p8 regulator\n", __func__);
1220 goto disable_3p3;
1221 }
1222 rc = regulator_enable(ldo7_1p8);
1223 if (rc) {
1224 pr_err("%s: Unable to enable the regulator:"
1225 "ldo7_1p8\n", __func__);
1226 goto disable_3p3;
1227 }
1228
1229 return 0;
1230 }
1231
1232 regulator_disable(ldo7_1p8);
1233disable_3p3:
1234 regulator_disable(ldo6_3p3);
1235put_1p8:
1236 regulator_put(ldo7_1p8);
1237put_3p3:
1238 regulator_put(ldo6_3p3);
1239 return rc;
1240}
1241
1242static int msm_hsusb_ldo_enable(int on)
1243{
1244 int ret = 0;
1245
1246 if (!ldo7_1p8 || IS_ERR(ldo7_1p8)) {
1247 pr_err("%s: ldo7_1p8 is not initialized\n", __func__);
1248 return -ENODEV;
1249 }
1250
1251 if (!ldo6_3p3 || IS_ERR(ldo6_3p3)) {
1252 pr_err("%s: ldo6_3p3 is not initialized\n", __func__);
1253 return -ENODEV;
1254 }
1255
1256 if (on) {
1257 ret = regulator_set_optimum_mode(ldo7_1p8,
1258 USB_PHY_1P8_HPM_LOAD);
1259 if (ret < 0) {
1260 pr_err("%s: Unable to set HPM of the regulator:"
1261 "ldo7_1p8\n", __func__);
1262 return ret;
1263 }
1264 ret = regulator_set_optimum_mode(ldo6_3p3,
1265 USB_PHY_3P3_HPM_LOAD);
1266 if (ret < 0) {
1267 pr_err("%s: Unable to set HPM of the regulator:"
1268 "ldo6_3p3\n", __func__);
1269 regulator_set_optimum_mode(ldo7_1p8,
1270 USB_PHY_1P8_LPM_LOAD);
1271 return ret;
1272 }
1273 } else {
1274 ret = regulator_set_optimum_mode(ldo7_1p8,
1275 USB_PHY_1P8_LPM_LOAD);
1276 if (ret < 0)
1277 pr_err("%s: Unable to set LPM of the regulator:"
1278 "ldo7_1p8\n", __func__);
1279 ret = regulator_set_optimum_mode(ldo6_3p3,
1280 USB_PHY_3P3_LPM_LOAD);
1281 if (ret < 0)
1282 pr_err("%s: Unable to set LPM of the regulator:"
1283 "ldo6_3p3\n", __func__);
1284 }
1285
1286 pr_debug("reg (%s)\n", on ? "HPM" : "LPM");
1287 return ret < 0 ? ret : 0;
1288 }
1289#endif
1290#ifdef CONFIG_USB_EHCI_MSM_72K
1291#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
1292static void msm_hsusb_smb137b_vbus_power(unsigned phy_info, int on)
1293{
1294 static int vbus_is_on;
1295
1296 /* If VBUS is already on (or off), do nothing. */
1297 if (on == vbus_is_on)
1298 return;
1299 smb137b_otg_power(on);
1300 vbus_is_on = on;
1301}
1302#endif
1303static void msm_hsusb_vbus_power(unsigned phy_info, int on)
1304{
1305 static struct regulator *votg_5v_switch;
1306 static struct regulator *ext_5v_reg;
1307 static int vbus_is_on;
1308
1309 /* If VBUS is already on (or off), do nothing. */
1310 if (on == vbus_is_on)
1311 return;
1312
1313 if (!votg_5v_switch) {
1314 votg_5v_switch = regulator_get(NULL, "8901_usb_otg");
1315 if (IS_ERR(votg_5v_switch)) {
1316 pr_err("%s: unable to get votg_5v_switch\n", __func__);
1317 return;
1318 }
1319 }
1320 if (!ext_5v_reg) {
1321 ext_5v_reg = regulator_get(NULL, "8901_mpp0");
1322 if (IS_ERR(ext_5v_reg)) {
1323 pr_err("%s: unable to get ext_5v_reg\n", __func__);
1324 return;
1325 }
1326 }
1327 if (on) {
1328 if (regulator_enable(ext_5v_reg)) {
1329 pr_err("%s: Unable to enable the regulator:"
1330 " ext_5v_reg\n", __func__);
1331 return;
1332 }
1333 if (regulator_enable(votg_5v_switch)) {
1334 pr_err("%s: Unable to enable the regulator:"
1335 " votg_5v_switch\n", __func__);
1336 return;
1337 }
1338 } else {
1339 if (regulator_disable(votg_5v_switch))
1340 pr_err("%s: Unable to enable the regulator:"
1341 " votg_5v_switch\n", __func__);
1342 if (regulator_disable(ext_5v_reg))
1343 pr_err("%s: Unable to enable the regulator:"
1344 " ext_5v_reg\n", __func__);
1345 }
1346
1347 vbus_is_on = on;
1348}
1349
1350static struct msm_usb_host_platform_data msm_usb_host_pdata = {
1351 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
1352 .power_budget = 390,
1353};
1354#endif
1355
1356#ifdef CONFIG_BATTERY_MSM8X60
1357static int msm_hsusb_pmic_vbus_notif_init(void (*callback)(int online),
1358 int init)
1359{
1360 int ret = -ENOTSUPP;
1361
1362#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
1363 if (machine_is_msm8x60_fluid()) {
1364 if (init)
1365 msm_charger_register_vbus_sn(callback);
1366 else
1367 msm_charger_unregister_vbus_sn(callback);
1368 return 0;
1369 }
1370#endif
1371 /* ID and VBUS lines are connected to pmic on 8660.V2.SURF,
1372 * hence, irrespective of either peripheral only mode or
1373 * OTG (host and peripheral) modes, can depend on pmic for
1374 * vbus notifications
Steve Muckle9161d302010-02-11 11:50:40 -08001375 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001376 if ((SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2)
1377 && (machine_is_msm8x60_surf() ||
1378 pmic_id_notif_supported)) {
1379 if (init)
1380 ret = msm_charger_register_vbus_sn(callback);
1381 else {
1382 msm_charger_unregister_vbus_sn(callback);
1383 ret = 0;
1384 }
1385 } else {
1386#if !defined(CONFIG_USB_EHCI_MSM_72K)
1387 if (init)
1388 ret = msm_charger_register_vbus_sn(callback);
1389 else {
1390 msm_charger_unregister_vbus_sn(callback);
1391 ret = 0;
1392 }
1393#endif
1394 }
1395 return ret;
1396}
1397#endif
1398
Lena Salman57d167e2012-03-21 19:46:38 +02001399#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_MSM_72K)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001400static struct msm_otg_platform_data msm_otg_pdata = {
1401 /* if usb link is in sps there is no need for
1402 * usb pclk as dayatona fabric clock will be
1403 * used instead
1404 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001405 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
1406 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
1407 .se1_gating = SE1_GATING_DISABLE,
Chandra Devireddyb3fc78c2011-08-30 17:25:55 +05301408 .bam_disable = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001409#ifdef CONFIG_USB_EHCI_MSM_72K
1410 .pmic_id_notif_init = msm_hsusb_pmic_id_notif_init,
Anji jonnalaae745e92011-11-14 18:34:31 +05301411 .phy_id_setup_init = msm_hsusb_phy_id_setup_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001412#endif
1413#ifdef CONFIG_USB_EHCI_MSM_72K
1414 .vbus_power = msm_hsusb_vbus_power,
1415#endif
1416#ifdef CONFIG_BATTERY_MSM8X60
1417 .pmic_vbus_notif_init = msm_hsusb_pmic_vbus_notif_init,
1418#endif
1419 .ldo_init = msm_hsusb_ldo_init,
1420 .ldo_enable = msm_hsusb_ldo_enable,
1421 .config_vddcx = msm_hsusb_config_vddcx,
1422 .init_vddcx = msm_hsusb_init_vddcx,
1423#ifdef CONFIG_BATTERY_MSM8X60
1424 .chg_vbus_draw = msm_charger_vbus_draw,
1425#endif
1426};
1427#endif
1428
Lena Salman57d167e2012-03-21 19:46:38 +02001429#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001430static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
1431 .is_phy_status_timer_on = 1,
1432};
1433#endif
1434
1435#ifdef CONFIG_USB_G_ANDROID
1436
1437#define PID_MAGIC_ID 0x71432909
1438#define SERIAL_NUM_MAGIC_ID 0x61945374
1439#define SERIAL_NUMBER_LENGTH 127
1440#define DLOAD_USB_BASE_ADD 0x2A05F0C8
1441
1442struct magic_num_struct {
1443 uint32_t pid;
1444 uint32_t serial_num;
1445};
1446
1447struct dload_struct {
1448 uint32_t reserved1;
1449 uint32_t reserved2;
1450 uint32_t reserved3;
1451 uint16_t reserved4;
1452 uint16_t pid;
1453 char serial_number[SERIAL_NUMBER_LENGTH];
1454 uint16_t reserved5;
1455 struct magic_num_struct
1456 magic_struct;
1457};
1458
1459static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
1460{
1461 struct dload_struct __iomem *dload = 0;
1462
1463 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
1464 if (!dload) {
1465 pr_err("%s: cannot remap I/O memory region: %08x\n",
1466 __func__, DLOAD_USB_BASE_ADD);
1467 return -ENXIO;
1468 }
1469
1470 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
1471 __func__, dload, pid, snum);
1472 /* update pid */
1473 dload->magic_struct.pid = PID_MAGIC_ID;
1474 dload->pid = pid;
1475
1476 /* update serial number */
1477 dload->magic_struct.serial_num = 0;
1478 if (!snum)
1479 return 0;
1480
1481 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
1482 strncpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
1483 dload->serial_number[SERIAL_NUMBER_LENGTH - 1] = '\0';
1484
1485 iounmap(dload);
1486
1487 return 0;
1488}
1489
1490static struct android_usb_platform_data android_usb_pdata = {
1491 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
1492};
1493
1494static struct platform_device android_usb_device = {
1495 .name = "android_usb",
1496 .id = -1,
1497 .dev = {
1498 .platform_data = &android_usb_pdata,
1499 },
1500};
1501
1502
1503#endif
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08001504
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001505#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07001506#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001507static struct resource msm_vpe_resources[] = {
1508 {
1509 .start = 0x05300000,
1510 .end = 0x05300000 + SZ_1M - 1,
1511 .flags = IORESOURCE_MEM,
1512 },
1513 {
1514 .start = INT_VPE,
1515 .end = INT_VPE,
1516 .flags = IORESOURCE_IRQ,
1517 },
1518};
1519
1520static struct platform_device msm_vpe_device = {
1521 .name = "msm_vpe",
1522 .id = 0,
1523 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1524 .resource = msm_vpe_resources,
1525};
1526#endif
Kevin Chan3be11612012-03-22 20:05:40 -07001527#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001528
1529#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07001530#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001531#ifdef CONFIG_MSM_CAMERA_FLASH
1532#define VFE_CAMIF_TIMER1_GPIO 29
1533#define VFE_CAMIF_TIMER2_GPIO 30
1534#define VFE_CAMIF_TIMER3_GPIO_INT 31
1535#define FUSION_VFE_CAMIF_TIMER1_GPIO 42
1536static struct msm_camera_sensor_flash_src msm_flash_src = {
1537 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PMIC,
1538 ._fsrc.pmic_src.num_of_src = 2,
1539 ._fsrc.pmic_src.low_current = 100,
1540 ._fsrc.pmic_src.high_current = 300,
1541 ._fsrc.pmic_src.led_src_1 = PMIC8058_ID_FLASH_LED_0,
1542 ._fsrc.pmic_src.led_src_2 = PMIC8058_ID_FLASH_LED_1,
1543 ._fsrc.pmic_src.pmic_set_current = pm8058_set_flash_led_current,
1544};
1545#ifdef CONFIG_IMX074
1546static struct msm_camera_sensor_strobe_flash_data strobe_flash_xenon = {
1547 .flash_trigger = VFE_CAMIF_TIMER2_GPIO,
1548 .flash_charge = VFE_CAMIF_TIMER1_GPIO,
1549 .flash_charge_done = VFE_CAMIF_TIMER3_GPIO_INT,
1550 .flash_recharge_duration = 50000,
1551 .irq = MSM_GPIO_TO_INT(VFE_CAMIF_TIMER3_GPIO_INT),
1552};
1553#endif
1554#endif
1555
1556int msm_cam_gpio_tbl[] = {
1557 32,/*CAMIF_MCLK*/
1558 47,/*CAMIF_I2C_DATA*/
1559 48,/*CAMIF_I2C_CLK*/
1560 105,/*STANDBY*/
1561};
1562
1563enum msm_cam_stat{
1564 MSM_CAM_OFF,
1565 MSM_CAM_ON,
1566};
1567
1568static int config_gpio_table(enum msm_cam_stat stat)
1569{
1570 int rc = 0, i = 0;
1571 if (stat == MSM_CAM_ON) {
1572 for (i = 0; i < ARRAY_SIZE(msm_cam_gpio_tbl); i++) {
1573 rc = gpio_request(msm_cam_gpio_tbl[i], "CAM_GPIO");
1574 if (unlikely(rc < 0)) {
1575 pr_err("%s not able to get gpio\n", __func__);
1576 for (i--; i >= 0; i--)
1577 gpio_free(msm_cam_gpio_tbl[i]);
1578 break;
1579 }
1580 }
1581 } else {
1582 for (i = 0; i < ARRAY_SIZE(msm_cam_gpio_tbl); i++)
1583 gpio_free(msm_cam_gpio_tbl[i]);
1584 }
1585 return rc;
1586}
1587
1588static struct msm_camera_sensor_platform_info sensor_board_info = {
1589 .mount_angle = 0
1590};
1591
1592/*external regulator VREG_5V*/
1593static struct regulator *reg_flash_5V;
1594
1595static int config_camera_on_gpios_fluid(void)
1596{
1597 int rc = 0;
1598
1599 reg_flash_5V = regulator_get(NULL, "8901_mpp0");
1600 if (IS_ERR(reg_flash_5V)) {
1601 pr_err("'%s' regulator not found, rc=%ld\n",
1602 "8901_mpp0", IS_ERR(reg_flash_5V));
1603 return -ENODEV;
1604 }
1605
1606 rc = regulator_enable(reg_flash_5V);
1607 if (rc) {
1608 pr_err("'%s' regulator enable failed, rc=%d\n",
1609 "8901_mpp0", rc);
1610 regulator_put(reg_flash_5V);
1611 return rc;
1612 }
1613
1614#ifdef CONFIG_IMX074
1615 sensor_board_info.mount_angle = 90;
1616#endif
1617 rc = config_gpio_table(MSM_CAM_ON);
1618 if (rc < 0) {
1619 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1620 "failed\n", __func__);
1621 return rc;
1622 }
1623
1624 rc = gpio_request(GPIO_EXT_CAMIF_PWR_EN, "CAM_EN");
1625 if (rc < 0) {
1626 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1627 "failed\n", __func__, GPIO_EXT_CAMIF_PWR_EN);
1628 regulator_disable(reg_flash_5V);
1629 regulator_put(reg_flash_5V);
1630 return rc;
1631 }
1632 gpio_direction_output(GPIO_EXT_CAMIF_PWR_EN, 0);
1633 msleep(20);
1634 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 1);
1635
1636
1637 /*Enable LED_FLASH_EN*/
1638 rc = gpio_request(GPIO_LED_FLASH_EN, "LED_FLASH_EN");
1639 if (rc < 0) {
1640 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1641 "failed\n", __func__, GPIO_LED_FLASH_EN);
1642
1643 regulator_disable(reg_flash_5V);
1644 regulator_put(reg_flash_5V);
1645 config_gpio_table(MSM_CAM_OFF);
1646 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1647 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1648 return rc;
1649 }
1650 gpio_direction_output(GPIO_LED_FLASH_EN, 1);
1651 msleep(20);
1652 return rc;
1653}
1654
1655
1656static void config_camera_off_gpios_fluid(void)
1657{
1658 regulator_disable(reg_flash_5V);
1659 regulator_put(reg_flash_5V);
1660
1661 gpio_direction_output(GPIO_LED_FLASH_EN, 0);
1662 gpio_free(GPIO_LED_FLASH_EN);
1663
1664 config_gpio_table(MSM_CAM_OFF);
1665
1666 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1667 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1668}
1669static int config_camera_on_gpios(void)
1670{
1671 int rc = 0;
1672
1673 if (machine_is_msm8x60_fluid())
1674 return config_camera_on_gpios_fluid();
1675
1676 rc = config_gpio_table(MSM_CAM_ON);
1677 if (rc < 0) {
1678 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1679 "failed\n", __func__);
1680 return rc;
1681 }
1682
Jilai Wang971f97f2011-07-13 14:25:25 -04001683 if (!machine_is_msm8x60_dragon()) {
1684 rc = gpio_request(GPIO_EXT_CAMIF_PWR_EN, "CAM_EN");
1685 if (rc < 0) {
1686 config_gpio_table(MSM_CAM_OFF);
1687 pr_err("%s: CAMSENSOR gpio %d request"
1688 "failed\n", __func__, GPIO_EXT_CAMIF_PWR_EN);
1689 return rc;
1690 }
1691 gpio_direction_output(GPIO_EXT_CAMIF_PWR_EN, 0);
1692 msleep(20);
1693 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001694 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001695
1696#ifdef CONFIG_MSM_CAMERA_FLASH
1697#ifdef CONFIG_IMX074
1698 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
1699 strobe_flash_xenon.flash_charge = FUSION_VFE_CAMIF_TIMER1_GPIO;
1700#endif
1701#endif
1702 return rc;
1703}
1704
1705static void config_camera_off_gpios(void)
1706{
1707 if (machine_is_msm8x60_fluid())
1708 return config_camera_off_gpios_fluid();
1709
1710
1711 config_gpio_table(MSM_CAM_OFF);
1712
Jilai Wang971f97f2011-07-13 14:25:25 -04001713 if (!machine_is_msm8x60_dragon()) {
1714 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1715 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1716 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001717}
1718
1719#ifdef CONFIG_QS_S5K4E1
1720
1721#define QS_CAM_HC37_CAM_PD PM8058_GPIO_PM_TO_SYS(26)
1722
1723static int config_camera_on_gpios_qs_cam_fluid(void)
1724{
1725 int rc = 0;
1726
1727 /* request QS_CAM_HC37_CAM_PD as an output to HC37 ASIC pin CAM_PD */
1728 rc = gpio_request(QS_CAM_HC37_CAM_PD, "QS_CAM_HC37_CAM_PD");
1729 if (rc < 0) {
1730 printk(KERN_ERR "%s: QS_CAM_HC37_CAM_PD gpio %d request"
1731 " failed\n", __func__, QS_CAM_HC37_CAM_PD);
1732 return rc;
1733 }
1734 gpio_direction_output(QS_CAM_HC37_CAM_PD, 0);
1735 msleep(20);
1736 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 1);
1737 msleep(20);
1738
1739 /*
1740 * Set GPIO_AUX_CAM_2P7_EN to 1 on North Expander IO2
1741 * to enable 2.7V power to Camera
1742 */
1743 rc = gpio_request(GPIO_AUX_CAM_2P7_EN, "CAM_2P7_EN");
1744 if (rc < 0) {
1745 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1746 " failed\n", __func__, GPIO_AUX_CAM_2P7_EN);
1747 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1748 gpio_free(QS_CAM_HC37_CAM_PD);
1749 return rc;
1750 }
1751 gpio_direction_output(GPIO_AUX_CAM_2P7_EN, 0);
1752 msleep(20);
1753 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 1);
1754 msleep(20);
1755
1756 rc = config_camera_on_gpios_fluid();
1757 if (rc < 0) {
1758 printk(KERN_ERR "%s: config_camera_on_gpios_fluid"
1759 " failed\n", __func__);
1760 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1761 gpio_free(QS_CAM_HC37_CAM_PD);
1762 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 0);
1763 gpio_free(GPIO_AUX_CAM_2P7_EN);
1764 return rc;
1765 }
1766 return rc;
1767}
1768
1769static void config_camera_off_gpios_qs_cam_fluid(void)
1770{
1771 /*
1772 * Set GPIO_AUX_CAM_2P7_EN to 0 on North Expander IO2
1773 * to disable 2.7V power to Camera
1774 */
1775 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 0);
1776 gpio_free(GPIO_AUX_CAM_2P7_EN);
1777
1778 /* set QS_CAM_HC37_CAM_PD to 0 to power off HC37 ASIC*/
1779 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1780 gpio_free(QS_CAM_HC37_CAM_PD);
1781
1782 config_camera_off_gpios_fluid();
1783 return;
1784}
1785
1786static int config_camera_on_gpios_qs_cam(void)
1787{
1788 int rc = 0;
1789
1790 if (machine_is_msm8x60_fluid())
1791 return config_camera_on_gpios_qs_cam_fluid();
1792
1793 rc = config_camera_on_gpios();
1794 return rc;
1795}
1796
1797static void config_camera_off_gpios_qs_cam(void)
1798{
1799 if (machine_is_msm8x60_fluid())
1800 return config_camera_off_gpios_qs_cam_fluid();
1801
1802 config_camera_off_gpios();
1803 return;
1804}
1805#endif
1806
1807static int config_camera_on_gpios_web_cam(void)
1808{
1809 int rc = 0;
1810 rc = config_gpio_table(MSM_CAM_ON);
1811 if (rc < 0) {
1812 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1813 "failed\n", __func__);
1814 return rc;
1815 }
1816
Jilai Wang53d27a82011-07-13 14:32:58 -04001817 if (!(machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon())) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001818 rc = gpio_request(GPIO_WEB_CAMIF_STANDBY, "CAM_EN");
1819 if (rc < 0) {
1820 config_gpio_table(MSM_CAM_OFF);
1821 pr_err(KERN_ERR "%s: CAMSENSOR gpio %d request"
1822 "failed\n", __func__, GPIO_WEB_CAMIF_STANDBY);
1823 return rc;
1824 }
1825 gpio_direction_output(GPIO_WEB_CAMIF_STANDBY, 0);
1826 }
1827 return rc;
1828}
1829
1830static void config_camera_off_gpios_web_cam(void)
1831{
1832 config_gpio_table(MSM_CAM_OFF);
Jilai Wang53d27a82011-07-13 14:32:58 -04001833 if (!(machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon())) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001834 gpio_set_value_cansleep(GPIO_WEB_CAMIF_STANDBY, 1);
1835 gpio_free(GPIO_WEB_CAMIF_STANDBY);
1836 }
1837 return;
1838}
1839
1840#ifdef CONFIG_MSM_BUS_SCALING
1841static struct msm_bus_vectors cam_init_vectors[] = {
1842 {
1843 .src = MSM_BUS_MASTER_VFE,
1844 .dst = MSM_BUS_SLAVE_SMI,
1845 .ab = 0,
1846 .ib = 0,
1847 },
1848 {
1849 .src = MSM_BUS_MASTER_VFE,
1850 .dst = MSM_BUS_SLAVE_EBI_CH0,
1851 .ab = 0,
1852 .ib = 0,
1853 },
1854 {
1855 .src = MSM_BUS_MASTER_VPE,
1856 .dst = MSM_BUS_SLAVE_SMI,
1857 .ab = 0,
1858 .ib = 0,
1859 },
1860 {
1861 .src = MSM_BUS_MASTER_VPE,
1862 .dst = MSM_BUS_SLAVE_EBI_CH0,
1863 .ab = 0,
1864 .ib = 0,
1865 },
1866 {
1867 .src = MSM_BUS_MASTER_JPEG_ENC,
1868 .dst = MSM_BUS_SLAVE_SMI,
1869 .ab = 0,
1870 .ib = 0,
1871 },
1872 {
1873 .src = MSM_BUS_MASTER_JPEG_ENC,
1874 .dst = MSM_BUS_SLAVE_EBI_CH0,
1875 .ab = 0,
1876 .ib = 0,
1877 },
1878};
1879
1880static struct msm_bus_vectors cam_preview_vectors[] = {
1881 {
1882 .src = MSM_BUS_MASTER_VFE,
1883 .dst = MSM_BUS_SLAVE_SMI,
1884 .ab = 0,
1885 .ib = 0,
1886 },
1887 {
1888 .src = MSM_BUS_MASTER_VFE,
1889 .dst = MSM_BUS_SLAVE_EBI_CH0,
1890 .ab = 283115520,
1891 .ib = 452984832,
1892 },
1893 {
1894 .src = MSM_BUS_MASTER_VPE,
1895 .dst = MSM_BUS_SLAVE_SMI,
1896 .ab = 0,
1897 .ib = 0,
1898 },
1899 {
1900 .src = MSM_BUS_MASTER_VPE,
1901 .dst = MSM_BUS_SLAVE_EBI_CH0,
1902 .ab = 0,
1903 .ib = 0,
1904 },
1905 {
1906 .src = MSM_BUS_MASTER_JPEG_ENC,
1907 .dst = MSM_BUS_SLAVE_SMI,
1908 .ab = 0,
1909 .ib = 0,
1910 },
1911 {
1912 .src = MSM_BUS_MASTER_JPEG_ENC,
1913 .dst = MSM_BUS_SLAVE_EBI_CH0,
1914 .ab = 0,
1915 .ib = 0,
1916 },
1917};
1918
1919static struct msm_bus_vectors cam_video_vectors[] = {
1920 {
1921 .src = MSM_BUS_MASTER_VFE,
1922 .dst = MSM_BUS_SLAVE_SMI,
1923 .ab = 283115520,
1924 .ib = 452984832,
1925 },
1926 {
1927 .src = MSM_BUS_MASTER_VFE,
1928 .dst = MSM_BUS_SLAVE_EBI_CH0,
1929 .ab = 283115520,
1930 .ib = 452984832,
1931 },
1932 {
1933 .src = MSM_BUS_MASTER_VPE,
1934 .dst = MSM_BUS_SLAVE_SMI,
1935 .ab = 319610880,
1936 .ib = 511377408,
1937 },
1938 {
1939 .src = MSM_BUS_MASTER_VPE,
1940 .dst = MSM_BUS_SLAVE_EBI_CH0,
1941 .ab = 0,
1942 .ib = 0,
1943 },
1944 {
1945 .src = MSM_BUS_MASTER_JPEG_ENC,
1946 .dst = MSM_BUS_SLAVE_SMI,
1947 .ab = 0,
1948 .ib = 0,
1949 },
1950 {
1951 .src = MSM_BUS_MASTER_JPEG_ENC,
1952 .dst = MSM_BUS_SLAVE_EBI_CH0,
1953 .ab = 0,
1954 .ib = 0,
1955 },
1956};
1957
1958static struct msm_bus_vectors cam_snapshot_vectors[] = {
1959 {
1960 .src = MSM_BUS_MASTER_VFE,
1961 .dst = MSM_BUS_SLAVE_SMI,
1962 .ab = 566231040,
1963 .ib = 905969664,
1964 },
1965 {
1966 .src = MSM_BUS_MASTER_VFE,
1967 .dst = MSM_BUS_SLAVE_EBI_CH0,
1968 .ab = 69984000,
1969 .ib = 111974400,
1970 },
1971 {
1972 .src = MSM_BUS_MASTER_VPE,
1973 .dst = MSM_BUS_SLAVE_SMI,
1974 .ab = 0,
1975 .ib = 0,
1976 },
1977 {
1978 .src = MSM_BUS_MASTER_VPE,
1979 .dst = MSM_BUS_SLAVE_EBI_CH0,
1980 .ab = 0,
1981 .ib = 0,
1982 },
1983 {
1984 .src = MSM_BUS_MASTER_JPEG_ENC,
1985 .dst = MSM_BUS_SLAVE_SMI,
1986 .ab = 320864256,
1987 .ib = 513382810,
1988 },
1989 {
1990 .src = MSM_BUS_MASTER_JPEG_ENC,
1991 .dst = MSM_BUS_SLAVE_EBI_CH0,
1992 .ab = 320864256,
1993 .ib = 513382810,
1994 },
1995};
1996
1997static struct msm_bus_vectors cam_zsl_vectors[] = {
1998 {
1999 .src = MSM_BUS_MASTER_VFE,
2000 .dst = MSM_BUS_SLAVE_SMI,
2001 .ab = 566231040,
2002 .ib = 905969664,
2003 },
2004 {
2005 .src = MSM_BUS_MASTER_VFE,
2006 .dst = MSM_BUS_SLAVE_EBI_CH0,
2007 .ab = 706199040,
2008 .ib = 1129918464,
2009 },
2010 {
2011 .src = MSM_BUS_MASTER_VPE,
2012 .dst = MSM_BUS_SLAVE_SMI,
2013 .ab = 0,
2014 .ib = 0,
2015 },
2016 {
2017 .src = MSM_BUS_MASTER_VPE,
2018 .dst = MSM_BUS_SLAVE_EBI_CH0,
2019 .ab = 0,
2020 .ib = 0,
2021 },
2022 {
2023 .src = MSM_BUS_MASTER_JPEG_ENC,
2024 .dst = MSM_BUS_SLAVE_SMI,
2025 .ab = 320864256,
2026 .ib = 513382810,
2027 },
2028 {
2029 .src = MSM_BUS_MASTER_JPEG_ENC,
2030 .dst = MSM_BUS_SLAVE_EBI_CH0,
2031 .ab = 320864256,
2032 .ib = 513382810,
2033 },
2034};
2035
2036static struct msm_bus_vectors cam_stereo_video_vectors[] = {
2037 {
2038 .src = MSM_BUS_MASTER_VFE,
2039 .dst = MSM_BUS_SLAVE_SMI,
2040 .ab = 212336640,
2041 .ib = 339738624,
2042 },
2043 {
2044 .src = MSM_BUS_MASTER_VFE,
2045 .dst = MSM_BUS_SLAVE_EBI_CH0,
2046 .ab = 25090560,
2047 .ib = 40144896,
2048 },
2049 {
2050 .src = MSM_BUS_MASTER_VPE,
2051 .dst = MSM_BUS_SLAVE_SMI,
2052 .ab = 239708160,
2053 .ib = 383533056,
2054 },
2055 {
2056 .src = MSM_BUS_MASTER_VPE,
2057 .dst = MSM_BUS_SLAVE_EBI_CH0,
2058 .ab = 79902720,
2059 .ib = 127844352,
2060 },
2061 {
2062 .src = MSM_BUS_MASTER_JPEG_ENC,
2063 .dst = MSM_BUS_SLAVE_SMI,
2064 .ab = 0,
2065 .ib = 0,
2066 },
2067 {
2068 .src = MSM_BUS_MASTER_JPEG_ENC,
2069 .dst = MSM_BUS_SLAVE_EBI_CH0,
2070 .ab = 0,
2071 .ib = 0,
2072 },
2073};
2074
2075static struct msm_bus_vectors cam_stereo_snapshot_vectors[] = {
2076 {
2077 .src = MSM_BUS_MASTER_VFE,
2078 .dst = MSM_BUS_SLAVE_SMI,
2079 .ab = 0,
2080 .ib = 0,
2081 },
2082 {
2083 .src = MSM_BUS_MASTER_VFE,
2084 .dst = MSM_BUS_SLAVE_EBI_CH0,
2085 .ab = 300902400,
2086 .ib = 481443840,
2087 },
2088 {
2089 .src = MSM_BUS_MASTER_VPE,
2090 .dst = MSM_BUS_SLAVE_SMI,
2091 .ab = 230307840,
2092 .ib = 368492544,
2093 },
2094 {
2095 .src = MSM_BUS_MASTER_VPE,
2096 .dst = MSM_BUS_SLAVE_EBI_CH0,
2097 .ab = 245113344,
2098 .ib = 392181351,
2099 },
2100 {
2101 .src = MSM_BUS_MASTER_JPEG_ENC,
2102 .dst = MSM_BUS_SLAVE_SMI,
2103 .ab = 106536960,
2104 .ib = 170459136,
2105 },
2106 {
2107 .src = MSM_BUS_MASTER_JPEG_ENC,
2108 .dst = MSM_BUS_SLAVE_EBI_CH0,
2109 .ab = 106536960,
2110 .ib = 170459136,
2111 },
2112};
2113
2114static struct msm_bus_paths cam_bus_client_config[] = {
2115 {
2116 ARRAY_SIZE(cam_init_vectors),
2117 cam_init_vectors,
2118 },
2119 {
2120 ARRAY_SIZE(cam_preview_vectors),
2121 cam_preview_vectors,
2122 },
2123 {
2124 ARRAY_SIZE(cam_video_vectors),
2125 cam_video_vectors,
2126 },
2127 {
2128 ARRAY_SIZE(cam_snapshot_vectors),
2129 cam_snapshot_vectors,
2130 },
2131 {
2132 ARRAY_SIZE(cam_zsl_vectors),
2133 cam_zsl_vectors,
2134 },
2135 {
2136 ARRAY_SIZE(cam_stereo_video_vectors),
2137 cam_stereo_video_vectors,
2138 },
2139 {
2140 ARRAY_SIZE(cam_stereo_snapshot_vectors),
2141 cam_stereo_snapshot_vectors,
2142 },
2143};
2144
2145static struct msm_bus_scale_pdata cam_bus_client_pdata = {
2146 cam_bus_client_config,
2147 ARRAY_SIZE(cam_bus_client_config),
2148 .name = "msm_camera",
2149};
2150#endif
2151
2152struct msm_camera_device_platform_data msm_camera_device_data = {
2153 .camera_gpio_on = config_camera_on_gpios,
2154 .camera_gpio_off = config_camera_off_gpios,
2155 .ioext.csiphy = 0x04800000,
2156 .ioext.csisz = 0x00000400,
2157 .ioext.csiirq = CSI_0_IRQ,
2158 .ioclk.mclk_clk_rate = 24000000,
2159 .ioclk.vfe_clk_rate = 228570000,
2160#ifdef CONFIG_MSM_BUS_SCALING
2161 .cam_bus_scale_table = &cam_bus_client_pdata,
2162#endif
2163};
2164
2165#ifdef CONFIG_QS_S5K4E1
2166struct msm_camera_device_platform_data msm_camera_device_data_qs_cam = {
2167 .camera_gpio_on = config_camera_on_gpios_qs_cam,
2168 .camera_gpio_off = config_camera_off_gpios_qs_cam,
2169 .ioext.csiphy = 0x04800000,
2170 .ioext.csisz = 0x00000400,
2171 .ioext.csiirq = CSI_0_IRQ,
2172 .ioclk.mclk_clk_rate = 24000000,
2173 .ioclk.vfe_clk_rate = 228570000,
2174#ifdef CONFIG_MSM_BUS_SCALING
2175 .cam_bus_scale_table = &cam_bus_client_pdata,
2176#endif
2177};
2178#endif
2179
2180struct msm_camera_device_platform_data msm_camera_device_data_web_cam = {
2181 .camera_gpio_on = config_camera_on_gpios_web_cam,
2182 .camera_gpio_off = config_camera_off_gpios_web_cam,
2183 .ioext.csiphy = 0x04900000,
2184 .ioext.csisz = 0x00000400,
2185 .ioext.csiirq = CSI_1_IRQ,
2186 .ioclk.mclk_clk_rate = 24000000,
2187 .ioclk.vfe_clk_rate = 228570000,
2188#ifdef CONFIG_MSM_BUS_SCALING
2189 .cam_bus_scale_table = &cam_bus_client_pdata,
2190#endif
2191};
2192
2193struct resource msm_camera_resources[] = {
2194 {
2195 .start = 0x04500000,
2196 .end = 0x04500000 + SZ_1M - 1,
2197 .flags = IORESOURCE_MEM,
2198 },
2199 {
2200 .start = VFE_IRQ,
2201 .end = VFE_IRQ,
2202 .flags = IORESOURCE_IRQ,
2203 },
2204};
2205#ifdef CONFIG_MT9E013
2206static struct msm_camera_sensor_platform_info mt9e013_sensor_8660_info = {
2207 .mount_angle = 0
2208};
2209
2210static struct msm_camera_sensor_flash_data flash_mt9e013 = {
2211 .flash_type = MSM_CAMERA_FLASH_LED,
2212 .flash_src = &msm_flash_src
2213};
2214
2215static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
2216 .sensor_name = "mt9e013",
2217 .sensor_reset = 106,
2218 .sensor_pwd = 85,
2219 .vcm_pwd = 1,
2220 .vcm_enable = 0,
2221 .pdata = &msm_camera_device_data,
2222 .resource = msm_camera_resources,
2223 .num_resources = ARRAY_SIZE(msm_camera_resources),
2224 .flash_data = &flash_mt9e013,
2225 .strobe_flash_data = &strobe_flash_xenon,
2226 .sensor_platform_info = &mt9e013_sensor_8660_info,
2227 .csi_if = 1
2228};
2229struct platform_device msm_camera_sensor_mt9e013 = {
2230 .name = "msm_camera_mt9e013",
2231 .dev = {
2232 .platform_data = &msm_camera_sensor_mt9e013_data,
2233 },
2234};
2235#endif
2236
2237#ifdef CONFIG_IMX074
Roja Rani Yarubandi68ebb4d2011-10-20 10:33:16 +05302238static struct msm_camera_sensor_platform_info imx074_sensor_board_info = {
2239 .mount_angle = 180
2240};
2241
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002242static struct msm_camera_sensor_flash_data flash_imx074 = {
2243 .flash_type = MSM_CAMERA_FLASH_LED,
2244 .flash_src = &msm_flash_src
2245};
2246
2247static struct msm_camera_sensor_info msm_camera_sensor_imx074_data = {
2248 .sensor_name = "imx074",
2249 .sensor_reset = 106,
2250 .sensor_pwd = 85,
2251 .vcm_pwd = GPIO_AUX_CAM_2P7_EN,
2252 .vcm_enable = 1,
2253 .pdata = &msm_camera_device_data,
2254 .resource = msm_camera_resources,
2255 .num_resources = ARRAY_SIZE(msm_camera_resources),
2256 .flash_data = &flash_imx074,
2257 .strobe_flash_data = &strobe_flash_xenon,
Roja Rani Yarubandi68ebb4d2011-10-20 10:33:16 +05302258 .sensor_platform_info = &imx074_sensor_board_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002259 .csi_if = 1
2260};
2261struct platform_device msm_camera_sensor_imx074 = {
2262 .name = "msm_camera_imx074",
2263 .dev = {
2264 .platform_data = &msm_camera_sensor_imx074_data,
2265 },
2266};
2267#endif
2268#ifdef CONFIG_WEBCAM_OV9726
2269
2270static struct msm_camera_sensor_platform_info ov9726_sensor_8660_info = {
2271 .mount_angle = 0
2272};
2273
2274static struct msm_camera_sensor_flash_data flash_ov9726 = {
2275 .flash_type = MSM_CAMERA_FLASH_LED,
2276 .flash_src = &msm_flash_src
2277};
2278static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
2279 .sensor_name = "ov9726",
Kevin Chan3382c512011-07-19 21:00:45 -07002280 .sensor_reset_enable = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002281 .sensor_reset = GPIO_FRONT_CAM_RESET_N,
2282 .sensor_pwd = 85,
2283 .vcm_pwd = 1,
2284 .vcm_enable = 0,
2285 .pdata = &msm_camera_device_data_web_cam,
2286 .resource = msm_camera_resources,
2287 .num_resources = ARRAY_SIZE(msm_camera_resources),
2288 .flash_data = &flash_ov9726,
2289 .sensor_platform_info = &ov9726_sensor_8660_info,
2290 .csi_if = 1
2291};
2292struct platform_device msm_camera_sensor_webcam_ov9726 = {
2293 .name = "msm_camera_ov9726",
2294 .dev = {
2295 .platform_data = &msm_camera_sensor_ov9726_data,
2296 },
2297};
2298#endif
2299#ifdef CONFIG_WEBCAM_OV7692
2300static struct msm_camera_sensor_flash_data flash_ov7692 = {
2301 .flash_type = MSM_CAMERA_FLASH_LED,
2302 .flash_src = &msm_flash_src
2303};
2304static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
2305 .sensor_name = "ov7692",
2306 .sensor_reset = GPIO_WEB_CAMIF_RESET_N,
2307 .sensor_pwd = 85,
2308 .vcm_pwd = 1,
2309 .vcm_enable = 0,
2310 .pdata = &msm_camera_device_data_web_cam,
2311 .resource = msm_camera_resources,
2312 .num_resources = ARRAY_SIZE(msm_camera_resources),
2313 .flash_data = &flash_ov7692,
2314 .csi_if = 1
2315};
2316
2317static struct platform_device msm_camera_sensor_webcam_ov7692 = {
2318 .name = "msm_camera_ov7692",
2319 .dev = {
2320 .platform_data = &msm_camera_sensor_ov7692_data,
2321 },
2322};
2323#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04002324#ifdef CONFIG_VX6953
2325static struct msm_camera_sensor_platform_info vx6953_sensor_8660_info = {
2326 .mount_angle = 270
2327};
2328
2329static struct msm_camera_sensor_flash_data flash_vx6953 = {
2330 .flash_type = MSM_CAMERA_FLASH_NONE,
2331 .flash_src = &msm_flash_src
2332};
2333
2334static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
2335 .sensor_name = "vx6953",
2336 .sensor_reset = 63,
2337 .sensor_pwd = 63,
2338 .vcm_pwd = GPIO_AUX_CAM_2P7_EN,
2339 .vcm_enable = 1,
2340 .pdata = &msm_camera_device_data,
2341 .resource = msm_camera_resources,
2342 .num_resources = ARRAY_SIZE(msm_camera_resources),
2343 .flash_data = &flash_vx6953,
2344 .sensor_platform_info = &vx6953_sensor_8660_info,
2345 .csi_if = 1
2346};
2347struct platform_device msm_camera_sensor_vx6953 = {
2348 .name = "msm_camera_vx6953",
2349 .dev = {
2350 .platform_data = &msm_camera_sensor_vx6953_data,
2351 },
2352};
2353#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002354#ifdef CONFIG_QS_S5K4E1
2355
Nishant Pandit613ab7a2011-09-02 03:36:01 +05302356static struct msm_camera_sensor_platform_info qs_s5k4e1_sensor_8660_info = {
2357#ifdef CONFIG_FB_MSM_MIPI_NOVATEK_CMD_QHD_PT
2358 .mount_angle = 90
2359#else
2360 .mount_angle = 0
2361#endif
2362};
2363
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002364static char eeprom_data[864];
2365static struct msm_camera_sensor_flash_data flash_qs_s5k4e1 = {
2366 .flash_type = MSM_CAMERA_FLASH_LED,
2367 .flash_src = &msm_flash_src
2368};
2369
2370static struct msm_camera_sensor_info msm_camera_sensor_qs_s5k4e1_data = {
2371 .sensor_name = "qs_s5k4e1",
2372 .sensor_reset = 106,
2373 .sensor_pwd = 85,
2374 .vcm_pwd = 1,
2375 .vcm_enable = 0,
2376 .pdata = &msm_camera_device_data_qs_cam,
2377 .resource = msm_camera_resources,
2378 .num_resources = ARRAY_SIZE(msm_camera_resources),
2379 .flash_data = &flash_qs_s5k4e1,
2380 .strobe_flash_data = &strobe_flash_xenon,
Nishant Pandit613ab7a2011-09-02 03:36:01 +05302381 .sensor_platform_info = &qs_s5k4e1_sensor_8660_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002382 .csi_if = 1,
2383 .eeprom_data = eeprom_data,
2384};
2385struct platform_device msm_camera_sensor_qs_s5k4e1 = {
2386 .name = "msm_camera_qs_s5k4e1",
2387 .dev = {
2388 .platform_data = &msm_camera_sensor_qs_s5k4e1_data,
2389 },
2390};
2391#endif
2392static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
2393 #ifdef CONFIG_MT9E013
2394 {
2395 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
2396 },
2397 #endif
2398 #ifdef CONFIG_IMX074
2399 {
2400 I2C_BOARD_INFO("imx074", 0x1A),
2401 },
2402 #endif
2403 #ifdef CONFIG_WEBCAM_OV7692
2404 {
2405 I2C_BOARD_INFO("ov7692", 0x78),
2406 },
2407 #endif
2408 #ifdef CONFIG_WEBCAM_OV9726
2409 {
2410 I2C_BOARD_INFO("ov9726", 0x10),
2411 },
2412 #endif
2413 #ifdef CONFIG_QS_S5K4E1
2414 {
2415 I2C_BOARD_INFO("qs_s5k4e1", 0x20),
2416 },
2417 #endif
2418};
Jilai Wang971f97f2011-07-13 14:25:25 -04002419
2420static struct i2c_board_info msm_camera_dragon_boardinfo[] __initdata = {
Jilai Wang53d27a82011-07-13 14:32:58 -04002421 #ifdef CONFIG_WEBCAM_OV9726
2422 {
2423 I2C_BOARD_INFO("ov9726", 0x10),
2424 },
2425 #endif
Jilai Wang971f97f2011-07-13 14:25:25 -04002426 #ifdef CONFIG_VX6953
2427 {
2428 I2C_BOARD_INFO("vx6953", 0x20),
2429 },
2430 #endif
2431};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002432#endif
Kevin Chan3be11612012-03-22 20:05:40 -07002433#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002434
2435#ifdef CONFIG_MSM_GEMINI
2436static struct resource msm_gemini_resources[] = {
2437 {
2438 .start = 0x04600000,
2439 .end = 0x04600000 + SZ_1M - 1,
2440 .flags = IORESOURCE_MEM,
2441 },
2442 {
2443 .start = INT_JPEG,
2444 .end = INT_JPEG,
2445 .flags = IORESOURCE_IRQ,
2446 },
2447};
2448
2449static struct platform_device msm_gemini_device = {
2450 .name = "msm_gemini",
2451 .resource = msm_gemini_resources,
2452 .num_resources = ARRAY_SIZE(msm_gemini_resources),
2453};
2454#endif
2455
2456#ifdef CONFIG_I2C_QUP
2457static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
2458{
2459}
2460
2461static struct msm_i2c_platform_data msm_gsbi3_qup_i2c_pdata = {
2462 .clk_freq = 384000,
2463 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002464 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2465};
2466
2467static struct msm_i2c_platform_data msm_gsbi4_qup_i2c_pdata = {
2468 .clk_freq = 100000,
2469 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002470 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2471};
2472
2473static struct msm_i2c_platform_data msm_gsbi7_qup_i2c_pdata = {
2474 .clk_freq = 100000,
2475 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002476 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2477};
2478
2479static struct msm_i2c_platform_data msm_gsbi8_qup_i2c_pdata = {
2480 .clk_freq = 100000,
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_gsbi9_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_gsbi12_qup_i2c_pdata = {
2492 .clk_freq = 100000,
2493 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002494 .use_gsbi_shared_mode = 1,
2495 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2496};
2497#endif
2498
2499#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
2500static struct msm_spi_platform_data msm_gsbi1_qup_spi_pdata = {
2501 .max_clock_speed = 24000000,
2502};
2503
2504static struct msm_spi_platform_data msm_gsbi10_qup_spi_pdata = {
2505 .max_clock_speed = 24000000,
2506};
2507#endif
2508
2509#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002510/* CODEC/TSSC SSBI */
2511static struct msm_i2c_ssbi_platform_data msm_ssbi3_pdata = {
2512 .controller_type = MSM_SBI_CTRL_SSBI,
2513};
2514#endif
2515
2516#ifdef CONFIG_BATTERY_MSM
2517/* Use basic value for fake MSM battery */
2518static struct msm_psy_batt_pdata msm_psy_batt_data = {
2519 .avail_chg_sources = AC_CHG,
2520};
2521
2522static struct platform_device msm_batt_device = {
2523 .name = "msm-battery",
2524 .id = -1,
2525 .dev.platform_data = &msm_psy_batt_data,
2526};
2527#endif
2528
2529#ifdef CONFIG_FB_MSM_LCDC_DSUB
2530/* VGA = 1440 x 900 x 4(bpp) x 2(pages)
2531 prim = 1024 x 600 x 4(bpp) x 2(pages)
2532 This is the difference. */
2533#define MSM_FB_DSUB_PMEM_ADDER (0xA32000-0x4B0000)
2534#else
2535#define MSM_FB_DSUB_PMEM_ADDER (0)
2536#endif
2537
2538/* Sensors DSPS platform data */
2539#ifdef CONFIG_MSM_DSPS
2540
2541static struct dsps_gpio_info dsps_surf_gpios[] = {
2542 {
2543 .name = "compass_rst_n",
2544 .num = GPIO_COMPASS_RST_N,
2545 .on_val = 1, /* device not in reset */
2546 .off_val = 0, /* device in reset */
2547 },
2548 {
2549 .name = "gpio_r_altimeter_reset_n",
2550 .num = GPIO_R_ALTIMETER_RESET_N,
2551 .on_val = 1, /* device not in reset */
2552 .off_val = 0, /* device in reset */
2553 }
2554};
2555
2556static struct dsps_gpio_info dsps_fluid_gpios[] = {
2557 {
2558 .name = "gpio_n_altimeter_reset_n",
2559 .num = GPIO_N_ALTIMETER_RESET_N,
2560 .on_val = 1, /* device not in reset */
2561 .off_val = 0, /* device in reset */
2562 }
2563};
2564
2565static void __init msm8x60_init_dsps(void)
2566{
2567 struct msm_dsps_platform_data *pdata =
2568 msm_dsps_device.dev.platform_data;
2569 /*
2570 * On Fluid the Compass sensor Chip-Select (CS) is directly connected
2571 * to the power supply and not controled via GPIOs. Fluid uses a
2572 * different IO-Expender (north) than used on surf/ffa.
2573 */
2574 if (machine_is_msm8x60_fluid()) {
2575 /* fluid has different firmware, gpios */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002576 pdata->pil_name = DSPS_PIL_FLUID_NAME;
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002577 msm_pil_dsps.dev.platform_data = DSPS_PIL_FLUID_NAME;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002578 pdata->gpios = dsps_fluid_gpios;
2579 pdata->gpios_num = ARRAY_SIZE(dsps_fluid_gpios);
2580 } else {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002581 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002582 msm_pil_dsps.dev.platform_data = DSPS_PIL_GENERIC_NAME;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002583 pdata->gpios = dsps_surf_gpios;
2584 pdata->gpios_num = ARRAY_SIZE(dsps_surf_gpios);
2585 }
2586
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002587 platform_device_register(&msm_dsps_device);
2588}
2589#endif /* CONFIG_MSM_DSPS */
2590
2591#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302592#define MSM_FB_PRIM_BUF_SIZE \
2593 (roundup((1024 * 600 * 4), 4096) * 3) /* 4 bpp x 3 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002594#else
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302595#define MSM_FB_PRIM_BUF_SIZE \
2596 (roundup((1024 * 600 * 4), 4096) * 2) /* 4 bpp x 2 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002597#endif
2598
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002599#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302600#define MSM_FB_EXT_BUF_SIZE \
2601 (roundup((1920 * 1080 * 2), 4096) * 1) /* 2 bpp x 1 page */
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002602#elif defined(CONFIG_FB_MSM_TVOUT)
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302603#define MSM_FB_EXT_BUF_SIZE \
2604 (roundup((720 * 576 * 2), 4096) * 2) /* 2 bpp x 2 pages */
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002605#else
Ajay Singh Parmardf694562012-06-05 15:06:21 +05302606#define MSM_FB_EXT_BUF_SIZE 0
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002607#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002608
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002609/* Note: must be multiple of 4096 */
2610#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE + \
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002611 MSM_FB_DSUB_PMEM_ADDER, 4096)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002612
2613#define MSM_PMEM_SF_SIZE 0x4000000 /* 64 Mbytes */
Sravan Kumar D.V.Nb4d77dd2012-03-16 12:25:37 +05302614#define MSM_HDMI_PRIM_PMEM_SF_SIZE 0x8000000 /* 128 Mbytes */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002615
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002616#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002617unsigned char hdmi_is_primary = 1;
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002618#else
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002619unsigned char hdmi_is_primary;
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002620#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002621
Huaibin Yanga5419422011-12-08 23:52:10 -08002622#ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK
2623#define MSM_FB_OVERLAY0_WRITEBACK_SIZE roundup((1376 * 768 * 3 * 2), 4096)
2624#else
2625#define MSM_FB_OVERLAY0_WRITEBACK_SIZE (0)
2626#endif /* CONFIG_FB_MSM_OVERLAY0_WRITEBACK */
2627
2628#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
2629#define MSM_FB_OVERLAY1_WRITEBACK_SIZE roundup((1920 * 1088 * 3 * 2), 4096)
2630#else
2631#define MSM_FB_OVERLAY1_WRITEBACK_SIZE (0)
2632#endif /* CONFIG_FB_MSM_OVERLAY1_WRITEBACK */
2633
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302634#define MSM_PMEM_KERNEL_EBI1_SIZE 0x3BC000
Ankit Premrajkaaee8f562012-04-09 03:57:53 -07002635#define MSM_PMEM_ADSP_SIZE 0x4200000
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302636#define MSM_PMEM_AUDIO_SIZE 0x4CF000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002637
2638#define MSM_SMI_BASE 0x38000000
2639#define MSM_SMI_SIZE 0x4000000
2640
2641#define KERNEL_SMI_BASE (MSM_SMI_BASE)
Sravan Kumar D.V.Nad046702012-05-23 11:25:42 +05302642#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
2643#define KERNEL_SMI_SIZE 0x000000
2644#else
Maheshwar Ajjac60c0462011-11-29 17:46:57 -08002645#define KERNEL_SMI_SIZE 0x600000
Sravan Kumar D.V.Nad046702012-05-23 11:25:42 +05302646#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002647
2648#define USER_SMI_BASE (KERNEL_SMI_BASE + KERNEL_SMI_SIZE)
2649#define USER_SMI_SIZE (MSM_SMI_SIZE - KERNEL_SMI_SIZE)
2650#define MSM_PMEM_SMIPOOL_SIZE USER_SMI_SIZE
2651
Chintan Pandyafda5bc42012-05-08 14:15:33 +05302652#define MSM_ION_HOLE_SIZE SZ_128K /* (128KB) */
2653#define MSM_MM_FW_SIZE (0x200000 - MSM_ION_HOLE_SIZE) /*(2MB-128KB)*/
2654#define MSM_ION_MM_SIZE 0x3800000 /* (56MB) */
2655#define MSM_ION_MFC_SIZE SZ_8K
2656
2657#define MSM_MM_FW_BASE MSM_SMI_BASE
2658#define MSM_ION_HOLE_BASE (MSM_MM_FW_BASE + MSM_MM_FW_SIZE)
2659#define MSM_ION_MM_BASE (MSM_ION_HOLE_BASE + MSM_ION_HOLE_SIZE)
2660#define MSM_ION_MFC_BASE (MSM_ION_MM_BASE + MSM_ION_MM_SIZE)
2661
Naseer Ahmed51860b02012-02-07 18:53:29 +05302662#define MSM_ION_SF_SIZE 0x4000000 /* 64MB */
Olav Hauganb5be7992011-11-18 14:29:02 -08002663#define MSM_ION_CAMERA_SIZE MSM_PMEM_ADSP_SIZE
Chintan Pandyafda5bc42012-05-08 14:15:33 +05302664
Mayank Choprac22ace32012-03-03 00:45:04 +05302665#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
2666#define MSM_ION_WB_SIZE 0xC00000 /* 12MB */
2667#else
Olav Hauganb5be7992011-11-18 14:29:02 -08002668#define MSM_ION_WB_SIZE 0x600000 /* 6MB */
Mayank Choprac22ace32012-03-03 00:45:04 +05302669#endif
2670
Olav Haugan424ff492012-03-13 11:41:23 -07002671#define MSM_ION_QSECOM_SIZE 0x600000 /* (6MB) */
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002672
2673#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302674#define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
Olav Haugan6ab47252012-02-15 14:46:49 -08002675#define MSM_ION_HEAP_NUM 9
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002676#define MSM_HDMI_PRIM_ION_SF_SIZE MSM_HDMI_PRIM_PMEM_SF_SIZE
2677static unsigned msm_ion_sf_size = MSM_ION_SF_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002678#else
Olav Hauganb5be7992011-11-18 14:29:02 -08002679#define MSM_ION_HEAP_NUM 1
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002680#endif
2681
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002682static unsigned fb_size;
2683static int __init fb_size_setup(char *p)
2684{
2685 fb_size = memparse(p, NULL);
2686 return 0;
2687}
2688early_param("fb_size", fb_size_setup);
2689
2690static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
2691static int __init pmem_kernel_ebi1_size_setup(char *p)
2692{
2693 pmem_kernel_ebi1_size = memparse(p, NULL);
2694 return 0;
2695}
2696early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
2697
2698#ifdef CONFIG_ANDROID_PMEM
2699static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
2700static int __init pmem_sf_size_setup(char *p)
2701{
2702 pmem_sf_size = memparse(p, NULL);
2703 return 0;
2704}
2705early_param("pmem_sf_size", pmem_sf_size_setup);
2706
2707static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
2708
2709static int __init pmem_adsp_size_setup(char *p)
2710{
2711 pmem_adsp_size = memparse(p, NULL);
2712 return 0;
2713}
2714early_param("pmem_adsp_size", pmem_adsp_size_setup);
2715
2716static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
2717
2718static int __init pmem_audio_size_setup(char *p)
2719{
2720 pmem_audio_size = memparse(p, NULL);
2721 return 0;
2722}
2723early_param("pmem_audio_size", pmem_audio_size_setup);
2724#endif
2725
2726static struct resource msm_fb_resources[] = {
2727 {
2728 .flags = IORESOURCE_DMA,
2729 }
2730};
2731
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002732static void set_mdp_clocks_for_wuxga(void);
2733
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002734static int msm_fb_detect_panel(const char *name)
2735{
2736 if (machine_is_msm8x60_fluid()) {
2737 uint32_t soc_platform_version = socinfo_get_platform_version();
2738 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
2739#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2740 if (!strncmp(name, LCDC_SAMSUNG_OLED_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002741 strnlen(LCDC_SAMSUNG_OLED_PANEL_NAME,
2742 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002743 return 0;
2744#endif
2745 } else { /*P3 and up use AUO panel */
2746#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
2747 if (!strncmp(name, LCDC_AUO_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002748 strnlen(LCDC_AUO_PANEL_NAME,
2749 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002750 return 0;
2751#endif
2752 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002753#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
2754 } else if machine_is_msm8x60_dragon() {
2755 if (!strncmp(name, LCDC_NT35582_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002756 strnlen(LCDC_NT35582_PANEL_NAME,
2757 PANEL_NAME_MAX_LEN)))
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002758 return 0;
2759#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002760 } else {
2761 if (!strncmp(name, LCDC_SAMSUNG_WSVGA_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002762 strnlen(LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2763 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002764 return 0;
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002765
2766#if !defined(CONFIG_FB_MSM_LCDC_AUTO_DETECT) && \
2767 !defined(CONFIG_FB_MSM_MIPI_PANEL_AUTO_DETECT) && \
2768 !defined(CONFIG_FB_MSM_LCDC_MIPI_PANEL_AUTO_DETECT)
2769 if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2770 strnlen(MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2771 PANEL_NAME_MAX_LEN)))
2772 return 0;
2773
2774 if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2775 strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2776 PANEL_NAME_MAX_LEN)))
2777 return 0;
2778
2779 if (!strncmp(name, MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2780 strnlen(MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2781 PANEL_NAME_MAX_LEN)))
2782 return 0;
2783#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002784 }
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002785
2786 if (!strncmp(name, HDMI_PANEL_NAME,
2787 strnlen(HDMI_PANEL_NAME,
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002788 PANEL_NAME_MAX_LEN))) {
2789 if (hdmi_is_primary)
2790 set_mdp_clocks_for_wuxga();
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002791 return 0;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002792 }
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002793
2794 if (!strncmp(name, TVOUT_PANEL_NAME,
2795 strnlen(TVOUT_PANEL_NAME,
2796 PANEL_NAME_MAX_LEN)))
2797 return 0;
2798
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002799 pr_warning("%s: not supported '%s'", __func__, name);
2800 return -ENODEV;
2801}
2802
2803static struct msm_fb_platform_data msm_fb_pdata = {
2804 .detect_client = msm_fb_detect_panel,
2805};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002806
2807static struct platform_device msm_fb_device = {
2808 .name = "msm_fb",
2809 .id = 0,
2810 .num_resources = ARRAY_SIZE(msm_fb_resources),
2811 .resource = msm_fb_resources,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002812 .dev.platform_data = &msm_fb_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002813};
2814
2815#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002816#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002817static struct android_pmem_platform_data android_pmem_pdata = {
2818 .name = "pmem",
2819 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
2820 .cached = 1,
2821 .memory_type = MEMTYPE_EBI1,
2822};
2823
2824static struct platform_device android_pmem_device = {
2825 .name = "android_pmem",
2826 .id = 0,
2827 .dev = {.platform_data = &android_pmem_pdata},
2828};
2829
2830static struct android_pmem_platform_data android_pmem_adsp_pdata = {
2831 .name = "pmem_adsp",
2832 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2833 .cached = 0,
2834 .memory_type = MEMTYPE_EBI1,
2835};
2836
2837static struct platform_device android_pmem_adsp_device = {
2838 .name = "android_pmem",
2839 .id = 2,
2840 .dev = { .platform_data = &android_pmem_adsp_pdata },
2841};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302842
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002843static struct android_pmem_platform_data android_pmem_audio_pdata = {
2844 .name = "pmem_audio",
2845 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2846 .cached = 0,
2847 .memory_type = MEMTYPE_EBI1,
2848};
2849
2850static struct platform_device android_pmem_audio_device = {
2851 .name = "android_pmem",
2852 .id = 4,
2853 .dev = { .platform_data = &android_pmem_audio_pdata },
2854};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302855#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Laura Abbott1e36a022011-06-22 17:08:13 -07002856#define PMEM_BUS_WIDTH(_bw) \
2857 { \
2858 .vectors = &(struct msm_bus_vectors){ \
2859 .src = MSM_BUS_MASTER_AMPSS_M0, \
2860 .dst = MSM_BUS_SLAVE_SMI, \
2861 .ib = (_bw), \
2862 .ab = 0, \
2863 }, \
2864 .num_paths = 1, \
2865 }
Olav Hauganee0f7802011-12-19 13:28:57 -08002866
2867static struct msm_bus_paths mem_smi_table[] = {
Laura Abbott1e36a022011-06-22 17:08:13 -07002868 [0] = PMEM_BUS_WIDTH(0), /* Off */
2869 [1] = PMEM_BUS_WIDTH(1), /* On */
2870};
2871
2872static struct msm_bus_scale_pdata smi_client_pdata = {
Olav Hauganee0f7802011-12-19 13:28:57 -08002873 .usecase = mem_smi_table,
2874 .num_usecases = ARRAY_SIZE(mem_smi_table),
2875 .name = "mem_smi",
Laura Abbott1e36a022011-06-22 17:08:13 -07002876};
2877
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002878int request_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002879{
2880 int bus_id = (int) data;
2881
2882 msm_bus_scale_client_update_request(bus_id, 1);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002883 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002884}
2885
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002886int release_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002887{
2888 int bus_id = (int) data;
2889
2890 msm_bus_scale_client_update_request(bus_id, 0);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002891 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002892}
2893
Alex Bird199980e2011-10-21 11:29:27 -07002894void *setup_smi_region(void)
Laura Abbott1e36a022011-06-22 17:08:13 -07002895{
2896 return (void *)msm_bus_scale_register_client(&smi_client_pdata);
2897}
Olav Hauganee0f7802011-12-19 13:28:57 -08002898#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002899static struct android_pmem_platform_data android_pmem_smipool_pdata = {
2900 .name = "pmem_smipool",
2901 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2902 .cached = 0,
2903 .memory_type = MEMTYPE_SMI,
Alex Bird199980e2011-10-21 11:29:27 -07002904 .request_region = request_smi_region,
2905 .release_region = release_smi_region,
2906 .setup_region = setup_smi_region,
Laura Abbott1e36a022011-06-22 17:08:13 -07002907 .map_on_demand = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002908};
2909static struct platform_device android_pmem_smipool_device = {
2910 .name = "android_pmem",
2911 .id = 7,
2912 .dev = { .platform_data = &android_pmem_smipool_pdata },
2913};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302914#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
2915#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002916
2917#define GPIO_DONGLE_PWR_EN 258
2918static void setup_display_power(void);
2919static int lcdc_vga_enabled;
2920static int vga_enable_request(int enable)
2921{
2922 if (enable)
2923 lcdc_vga_enabled = 1;
2924 else
2925 lcdc_vga_enabled = 0;
2926 setup_display_power();
2927
2928 return 0;
2929}
2930
2931#define GPIO_BACKLIGHT_PWM0 0
2932#define GPIO_BACKLIGHT_PWM1 1
2933
2934static int pmic_backlight_gpio[2]
2935 = { GPIO_BACKLIGHT_PWM0, GPIO_BACKLIGHT_PWM1 };
2936static struct msm_panel_common_pdata lcdc_samsung_panel_data = {
2937 .gpio_num = pmic_backlight_gpio, /* two LPG CHANNELS for backlight */
2938 .vga_switch = vga_enable_request,
2939};
2940
2941static struct platform_device lcdc_samsung_panel_device = {
2942 .name = LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2943 .id = 0,
2944 .dev = {
2945 .platform_data = &lcdc_samsung_panel_data,
2946 }
2947};
2948#if (!defined(CONFIG_SPI_QUP)) && \
2949 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
2950 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA))
2951
2952static int lcdc_spi_gpio_array_num[] = {
2953 LCDC_SPI_GPIO_CLK,
2954 LCDC_SPI_GPIO_CS,
2955 LCDC_SPI_GPIO_MOSI,
2956};
2957
2958static uint32_t lcdc_spi_gpio_config_data[] = {
2959 GPIO_CFG(LCDC_SPI_GPIO_CLK, 0,
2960 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2961 GPIO_CFG(LCDC_SPI_GPIO_CS, 0,
2962 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2963 GPIO_CFG(LCDC_SPI_GPIO_MOSI, 0,
2964 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2965};
2966
2967static void lcdc_config_spi_gpios(int enable)
2968{
2969 int n;
2970 for (n = 0; n < ARRAY_SIZE(lcdc_spi_gpio_config_data); ++n)
2971 gpio_tlmm_config(lcdc_spi_gpio_config_data[n], 0);
2972}
2973#endif
2974
2975#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2976#ifdef CONFIG_SPI_QUP
2977static struct spi_board_info lcdc_samsung_spi_board_info[] __initdata = {
2978 {
2979 .modalias = LCDC_SAMSUNG_SPI_DEVICE_NAME,
2980 .mode = SPI_MODE_3,
2981 .bus_num = 1,
2982 .chip_select = 0,
2983 .max_speed_hz = 10800000,
2984 }
2985};
2986#endif /* CONFIG_SPI_QUP */
2987
2988static struct msm_panel_common_pdata lcdc_samsung_oled_panel_data = {
2989#ifndef CONFIG_SPI_QUP
2990 .panel_config_gpio = lcdc_config_spi_gpios,
2991 .gpio_num = lcdc_spi_gpio_array_num,
2992#endif
2993};
2994
2995static struct platform_device lcdc_samsung_oled_panel_device = {
2996 .name = LCDC_SAMSUNG_OLED_PANEL_NAME,
2997 .id = 0,
2998 .dev.platform_data = &lcdc_samsung_oled_panel_data,
2999};
3000#endif /*CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT */
3001
3002#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
3003#ifdef CONFIG_SPI_QUP
3004static struct spi_board_info lcdc_auo_spi_board_info[] __initdata = {
3005 {
3006 .modalias = LCDC_AUO_SPI_DEVICE_NAME,
3007 .mode = SPI_MODE_3,
3008 .bus_num = 1,
3009 .chip_select = 0,
3010 .max_speed_hz = 10800000,
3011 }
3012};
3013#endif
3014
3015static struct msm_panel_common_pdata lcdc_auo_wvga_panel_data = {
3016#ifndef CONFIG_SPI_QUP
3017 .panel_config_gpio = lcdc_config_spi_gpios,
3018 .gpio_num = lcdc_spi_gpio_array_num,
3019#endif
3020};
3021
3022static struct platform_device lcdc_auo_wvga_panel_device = {
3023 .name = LCDC_AUO_PANEL_NAME,
3024 .id = 0,
3025 .dev.platform_data = &lcdc_auo_wvga_panel_data,
3026};
3027#endif /*CONFIG_FB_MSM_LCDC_AUO_WVGA*/
3028
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04003029#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
3030
3031#define GPIO_NT35582_RESET 94
3032#define GPIO_NT35582_BL_EN_HW_PIN 24
3033#define GPIO_NT35582_BL_EN \
3034 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1)
3035
3036static int lcdc_nt35582_pmic_gpio[] = {GPIO_NT35582_BL_EN };
3037
3038static struct msm_panel_common_pdata lcdc_nt35582_panel_data = {
3039 .gpio_num = lcdc_nt35582_pmic_gpio,
3040};
3041
3042static struct platform_device lcdc_nt35582_panel_device = {
3043 .name = LCDC_NT35582_PANEL_NAME,
3044 .id = 0,
3045 .dev = {
3046 .platform_data = &lcdc_nt35582_panel_data,
3047 }
3048};
3049
3050static struct spi_board_info lcdc_nt35582_spi_board_info[] __initdata = {
3051 {
3052 .modalias = "lcdc_nt35582_spi",
3053 .mode = SPI_MODE_0,
3054 .bus_num = 0,
3055 .chip_select = 0,
3056 .max_speed_hz = 1100000,
3057 }
3058};
3059#endif
3060
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003061#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
3062static struct resource hdmi_msm_resources[] = {
3063 {
3064 .name = "hdmi_msm_qfprom_addr",
3065 .start = 0x00700000,
3066 .end = 0x007060FF,
3067 .flags = IORESOURCE_MEM,
3068 },
3069 {
3070 .name = "hdmi_msm_hdmi_addr",
3071 .start = 0x04A00000,
3072 .end = 0x04A00FFF,
3073 .flags = IORESOURCE_MEM,
3074 },
3075 {
3076 .name = "hdmi_msm_irq",
3077 .start = HDMI_IRQ,
3078 .end = HDMI_IRQ,
3079 .flags = IORESOURCE_IRQ,
3080 },
3081};
3082
3083static int hdmi_enable_5v(int on);
3084static int hdmi_core_power(int on, int show);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05303085static int hdmi_gpio_config(int on);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003086static int hdmi_cec_power(int on);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05303087static int hdmi_panel_power(int on);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003088
3089static struct msm_hdmi_platform_data hdmi_msm_data = {
3090 .irq = HDMI_IRQ,
3091 .enable_5v = hdmi_enable_5v,
3092 .core_power = hdmi_core_power,
3093 .cec_power = hdmi_cec_power,
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05303094 .panel_power = hdmi_panel_power,
3095 .gpio_config = hdmi_gpio_config,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003096};
3097
3098static struct platform_device hdmi_msm_device = {
3099 .name = "hdmi_msm",
3100 .id = 0,
3101 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
3102 .resource = hdmi_msm_resources,
3103 .dev.platform_data = &hdmi_msm_data,
3104};
3105#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
3106
3107#ifdef CONFIG_FB_MSM_MIPI_DSI
3108static struct platform_device mipi_dsi_toshiba_panel_device = {
3109 .name = "mipi_toshiba",
3110 .id = 0,
3111};
3112
3113#define FPGA_3D_GPIO_CONFIG_ADDR 0x1D00017A
3114
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07003115static struct mipi_dsi_panel_platform_data novatek_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003116 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
Chandan Uddaraju83eac3c2011-09-11 18:32:23 -07003117 .fpga_ctrl_mode = FPGA_EBI2_INTF,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003118};
3119
3120static struct platform_device mipi_dsi_novatek_panel_device = {
3121 .name = "mipi_novatek",
3122 .id = 0,
3123 .dev = {
3124 .platform_data = &novatek_pdata,
3125 }
3126};
3127#endif
3128
3129static void __init msm8x60_allocate_memory_regions(void)
3130{
3131 void *addr;
3132 unsigned long size;
3133
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003134 if (hdmi_is_primary)
3135 size = roundup((1920 * 1088 * 4 * 2), 4096);
3136 else
3137 size = MSM_FB_SIZE;
3138
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003139 addr = alloc_bootmem_align(size, 0x1000);
3140 msm_fb_resources[0].start = __pa(addr);
3141 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
3142 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
3143 size, addr, __pa(addr));
3144
3145}
3146
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003147void __init msm8x60_set_display_params(char *prim_panel, char *ext_panel)
3148{
3149 if (strnlen(prim_panel, PANEL_NAME_MAX_LEN)) {
3150 strlcpy(msm_fb_pdata.prim_panel_name, prim_panel,
3151 PANEL_NAME_MAX_LEN);
3152 pr_debug("msm_fb_pdata.prim_panel_name %s\n",
3153 msm_fb_pdata.prim_panel_name);
3154
3155 if (!strncmp((char *)msm_fb_pdata.prim_panel_name,
3156 HDMI_PANEL_NAME, strnlen(HDMI_PANEL_NAME,
3157 PANEL_NAME_MAX_LEN))) {
3158 pr_debug("HDMI is the primary display by"
3159 " boot parameter\n");
3160 hdmi_is_primary = 1;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07003161 set_mdp_clocks_for_wuxga();
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003162 }
3163 }
3164 if (strnlen(ext_panel, PANEL_NAME_MAX_LEN)) {
3165 strlcpy(msm_fb_pdata.ext_panel_name, ext_panel,
3166 PANEL_NAME_MAX_LEN);
3167 pr_debug("msm_fb_pdata.ext_panel_name %s\n",
3168 msm_fb_pdata.ext_panel_name);
3169 }
3170}
3171
Steve Mucklef132c6c2012-06-06 18:30:57 -07003172#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
3173 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003174/*virtual key support */
3175static ssize_t tma300_vkeys_show(struct kobject *kobj,
3176 struct kobj_attribute *attr, char *buf)
3177{
3178 return sprintf(buf,
3179 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":60:900:90:120"
3180 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":180:900:90:120"
3181 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":300:900:90:120"
3182 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":420:900:90:120"
3183 "\n");
3184}
3185
3186static struct kobj_attribute tma300_vkeys_attr = {
3187 .attr = {
3188 .mode = S_IRUGO,
3189 },
3190 .show = &tma300_vkeys_show,
3191};
3192
3193static struct attribute *tma300_properties_attrs[] = {
3194 &tma300_vkeys_attr.attr,
3195 NULL
3196};
3197
3198static struct attribute_group tma300_properties_attr_group = {
3199 .attrs = tma300_properties_attrs,
3200};
3201
3202static struct kobject *properties_kobj;
3203
3204
3205
3206#define CYTTSP_TS_GPIO_IRQ 61
3207static int cyttsp_platform_init(struct i2c_client *client)
3208{
3209 int rc = -EINVAL;
3210 struct regulator *pm8058_l5 = NULL, *pm8058_s3;
3211
3212 if (machine_is_msm8x60_fluid()) {
3213 pm8058_l5 = regulator_get(NULL, "8058_l5");
3214 if (IS_ERR(pm8058_l5)) {
3215 pr_err("%s: regulator get of 8058_l5 failed (%ld)\n",
3216 __func__, PTR_ERR(pm8058_l5));
3217 rc = PTR_ERR(pm8058_l5);
3218 return rc;
3219 }
3220 rc = regulator_set_voltage(pm8058_l5, 2850000, 2850000);
3221 if (rc) {
3222 pr_err("%s: regulator_set_voltage of 8058_l5 failed(%d)\n",
3223 __func__, rc);
3224 goto reg_l5_put;
3225 }
3226
3227 rc = regulator_enable(pm8058_l5);
3228 if (rc) {
3229 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3230 __func__, rc);
3231 goto reg_l5_put;
3232 }
3233 }
3234 /* vote for s3 to enable i2c communication lines */
3235 pm8058_s3 = regulator_get(NULL, "8058_s3");
3236 if (IS_ERR(pm8058_s3)) {
3237 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3238 __func__, PTR_ERR(pm8058_s3));
3239 rc = PTR_ERR(pm8058_s3);
3240 goto reg_l5_disable;
3241 }
3242
3243 rc = regulator_set_voltage(pm8058_s3, 1800000, 1800000);
3244 if (rc) {
3245 pr_err("%s: regulator_set_voltage() = %d\n",
3246 __func__, rc);
3247 goto reg_s3_put;
3248 }
3249
3250 rc = regulator_enable(pm8058_s3);
3251 if (rc) {
3252 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3253 __func__, rc);
3254 goto reg_s3_put;
3255 }
3256
3257 /* wait for vregs to stabilize */
3258 usleep_range(10000, 10000);
3259
3260 /* check this device active by reading first byte/register */
3261 rc = i2c_smbus_read_byte_data(client, 0x01);
3262 if (rc < 0) {
3263 pr_err("%s: i2c sanity check failed\n", __func__);
3264 goto reg_s3_disable;
3265 }
3266
3267 /* virtual keys */
3268 if (machine_is_msm8x60_fluid()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003269 properties_kobj = kobject_create_and_add("board_properties",
3270 NULL);
Steve Mucklef132c6c2012-06-06 18:30:57 -07003271 if (properties_kobj);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003272 if (!properties_kobj || rc)
3273 pr_err("%s: failed to create board_properties\n",
3274 __func__);
3275 }
3276 return CY_OK;
3277
3278reg_s3_disable:
3279 regulator_disable(pm8058_s3);
3280reg_s3_put:
3281 regulator_put(pm8058_s3);
3282reg_l5_disable:
3283 if (machine_is_msm8x60_fluid())
3284 regulator_disable(pm8058_l5);
3285reg_l5_put:
3286 if (machine_is_msm8x60_fluid())
3287 regulator_put(pm8058_l5);
3288 return rc;
3289}
3290
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303291/* TODO: Put the regulator to LPM / HPM in suspend/resume*/
3292static int cyttsp_platform_suspend(struct i2c_client *client)
3293{
3294 msleep(20);
3295
3296 return CY_OK;
3297}
3298
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003299static int cyttsp_platform_resume(struct i2c_client *client)
3300{
3301 /* add any special code to strobe a wakeup pin or chip reset */
3302 msleep(10);
3303
3304 return CY_OK;
3305}
3306
3307static struct cyttsp_platform_data cyttsp_fluid_pdata = {
3308 .flags = 0x04,
3309 .gen = CY_GEN3, /* or */
3310 .use_st = CY_USE_ST,
3311 .use_mt = CY_USE_MT,
3312 .use_hndshk = CY_SEND_HNDSHK,
3313 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303314 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003315 .use_gestures = CY_USE_GESTURES,
3316 /* activate up to 4 groups
3317 * and set active distance
3318 */
3319 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3320 CY_GEST_GRP3 | CY_GEST_GRP4 |
3321 CY_ACT_DIST,
3322 /* change act_intrvl to customize the Active power state
3323 * scanning/processing refresh interval for Operating mode
3324 */
3325 .act_intrvl = CY_ACT_INTRVL_DFLT,
3326 /* change tch_tmout to customize the touch timeout for the
3327 * Active power state for Operating mode
3328 */
3329 .tch_tmout = CY_TCH_TMOUT_DFLT,
3330 /* change lp_intrvl to customize the Low Power power state
3331 * scanning/processing refresh interval for Operating mode
3332 */
3333 .lp_intrvl = CY_LP_INTRVL_DFLT,
3334 .sleep_gpio = -1,
3335 .resout_gpio = -1,
3336 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3337 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303338 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003339 .init = cyttsp_platform_init,
3340};
3341
3342static struct cyttsp_platform_data cyttsp_tmg240_pdata = {
3343 .panel_maxx = 1083,
3344 .panel_maxy = 659,
3345 .disp_minx = 30,
3346 .disp_maxx = 1053,
3347 .disp_miny = 30,
3348 .disp_maxy = 629,
3349 .correct_fw_ver = 8,
3350 .fw_fname = "cyttsp_8660_ffa.hex",
3351 .flags = 0x00,
3352 .gen = CY_GEN2, /* or */
3353 .use_st = CY_USE_ST,
3354 .use_mt = CY_USE_MT,
3355 .use_hndshk = CY_SEND_HNDSHK,
3356 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303357 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003358 .use_gestures = CY_USE_GESTURES,
3359 /* activate up to 4 groups
3360 * and set active distance
3361 */
3362 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3363 CY_GEST_GRP3 | CY_GEST_GRP4 |
3364 CY_ACT_DIST,
3365 /* change act_intrvl to customize the Active power state
3366 * scanning/processing refresh interval for Operating mode
3367 */
3368 .act_intrvl = CY_ACT_INTRVL_DFLT,
3369 /* change tch_tmout to customize the touch timeout for the
3370 * Active power state for Operating mode
3371 */
3372 .tch_tmout = CY_TCH_TMOUT_DFLT,
3373 /* change lp_intrvl to customize the Low Power power state
3374 * scanning/processing refresh interval for Operating mode
3375 */
3376 .lp_intrvl = CY_LP_INTRVL_DFLT,
3377 .sleep_gpio = -1,
3378 .resout_gpio = -1,
3379 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3380 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303381 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003382 .init = cyttsp_platform_init,
Mohan Pallaka1ea7d8a2011-08-18 15:06:00 +05303383 .disable_ghost_det = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003384};
3385static void cyttsp_set_params(void)
3386{
3387 if (SOCINFO_VERSION_MAJOR(socinfo_get_platform_version()) < 3) {
3388 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p2.hex";
3389 cyttsp_fluid_pdata.panel_maxx = 539;
3390 cyttsp_fluid_pdata.panel_maxy = 994;
3391 cyttsp_fluid_pdata.disp_minx = 30;
3392 cyttsp_fluid_pdata.disp_maxx = 509;
3393 cyttsp_fluid_pdata.disp_miny = 60;
3394 cyttsp_fluid_pdata.disp_maxy = 859;
3395 cyttsp_fluid_pdata.correct_fw_ver = 4;
3396 } else {
3397 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p3.hex";
3398 cyttsp_fluid_pdata.panel_maxx = 550;
3399 cyttsp_fluid_pdata.panel_maxy = 1013;
3400 cyttsp_fluid_pdata.disp_minx = 35;
3401 cyttsp_fluid_pdata.disp_maxx = 515;
3402 cyttsp_fluid_pdata.disp_miny = 69;
3403 cyttsp_fluid_pdata.disp_maxy = 869;
3404 cyttsp_fluid_pdata.correct_fw_ver = 5;
3405 }
3406
3407}
3408
3409static struct i2c_board_info cyttsp_fluid_info[] __initdata = {
3410 {
3411 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
3412 .platform_data = &cyttsp_fluid_pdata,
3413#ifndef CY_USE_TIMER
3414 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3415#endif /* CY_USE_TIMER */
3416 },
3417};
3418
3419static struct i2c_board_info cyttsp_ffa_info[] __initdata = {
3420 {
3421 I2C_BOARD_INFO(CY_I2C_NAME, 0x3b),
3422 .platform_data = &cyttsp_tmg240_pdata,
3423#ifndef CY_USE_TIMER
3424 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3425#endif /* CY_USE_TIMER */
3426 },
3427};
3428#endif
3429
3430static struct regulator *vreg_tmg200;
3431
3432#define TS_PEN_IRQ_GPIO 61
3433static int tmg200_power(int vreg_on)
3434{
3435 int rc = -EINVAL;
3436
3437 if (!vreg_tmg200) {
3438 printk(KERN_ERR "%s: regulator 8058_s3 not found (%d)\n",
3439 __func__, rc);
3440 return rc;
3441 }
3442
3443 rc = vreg_on ? regulator_enable(vreg_tmg200) :
3444 regulator_disable(vreg_tmg200);
3445 if (rc < 0)
3446 printk(KERN_ERR "%s: vreg 8058_s3 %s failed (%d)\n",
3447 __func__, vreg_on ? "enable" : "disable", rc);
3448
3449 /* wait for vregs to stabilize */
Amy Maloche12b5d4e2011-08-03 15:42:28 -07003450 msleep(20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003451
3452 return rc;
3453}
3454
3455static int tmg200_dev_setup(bool enable)
3456{
3457 int rc;
3458
3459 if (enable) {
3460 vreg_tmg200 = regulator_get(NULL, "8058_s3");
3461 if (IS_ERR(vreg_tmg200)) {
3462 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3463 __func__, PTR_ERR(vreg_tmg200));
3464 rc = PTR_ERR(vreg_tmg200);
3465 return rc;
3466 }
3467
3468 rc = regulator_set_voltage(vreg_tmg200, 1800000, 1800000);
3469 if (rc) {
3470 pr_err("%s: regulator_set_voltage() = %d\n",
3471 __func__, rc);
3472 goto reg_put;
3473 }
3474 } else {
3475 /* put voltage sources */
3476 regulator_put(vreg_tmg200);
3477 }
3478 return 0;
3479reg_put:
3480 regulator_put(vreg_tmg200);
3481 return rc;
3482}
3483
3484static struct cy8c_ts_platform_data cy8ctmg200_pdata = {
3485 .ts_name = "msm_tmg200_ts",
3486 .dis_min_x = 0,
3487 .dis_max_x = 1023,
3488 .dis_min_y = 0,
3489 .dis_max_y = 599,
3490 .min_tid = 0,
3491 .max_tid = 255,
3492 .min_touch = 0,
3493 .max_touch = 255,
3494 .min_width = 0,
3495 .max_width = 255,
3496 .power_on = tmg200_power,
3497 .dev_setup = tmg200_dev_setup,
3498 .nfingers = 2,
3499 .irq_gpio = TS_PEN_IRQ_GPIO,
3500 .resout_gpio = GPIO_CAP_TS_RESOUT_N,
3501};
3502
3503static struct i2c_board_info cy8ctmg200_board_info[] = {
3504 {
3505 I2C_BOARD_INFO("cy8ctmg200", 0x2),
3506 .platform_data = &cy8ctmg200_pdata,
3507 }
3508};
3509
Zhang Chang Ken211df572011-07-05 19:16:39 -04003510static struct regulator *vreg_tma340;
3511
3512static int tma340_power(int vreg_on)
3513{
3514 int rc = -EINVAL;
3515
3516 if (!vreg_tma340) {
3517 pr_err("%s: regulator 8901_l2 not found (%d)\n",
3518 __func__, rc);
3519 return rc;
3520 }
3521
3522 rc = vreg_on ? regulator_enable(vreg_tma340) :
3523 regulator_disable(vreg_tma340);
3524 if (rc < 0)
3525 pr_err("%s: vreg 8901_l2 %s failed (%d)\n",
3526 __func__, vreg_on ? "enable" : "disable", rc);
3527
3528 /* wait for vregs to stabilize */
Amy Malocheb5c67e8d2011-08-18 16:39:35 -07003529 msleep(100);
Zhang Chang Ken211df572011-07-05 19:16:39 -04003530
3531 return rc;
3532}
3533
3534static struct kobject *tma340_prop_kobj;
3535
3536static int tma340_dragon_dev_setup(bool enable)
3537{
3538 int rc;
3539
3540 if (enable) {
3541 vreg_tma340 = regulator_get(NULL, "8901_l2");
3542 if (IS_ERR(vreg_tma340)) {
3543 pr_err("%s: regulator get of 8901_l2 failed (%ld)\n",
3544 __func__, PTR_ERR(vreg_tma340));
3545 rc = PTR_ERR(vreg_tma340);
3546 return rc;
3547 }
3548
3549 rc = regulator_set_voltage(vreg_tma340, 3300000, 3300000);
3550 if (rc) {
3551 pr_err("%s: regulator_set_voltage() = %d\n",
3552 __func__, rc);
3553 goto reg_put;
3554 }
Zhang Chang Ken211df572011-07-05 19:16:39 -04003555 tma340_prop_kobj = kobject_create_and_add("board_properties",
3556 NULL);
3557 if (tma340_prop_kobj) {
Steve Mucklef132c6c2012-06-06 18:30:57 -07003558 ;
Zhang Chang Ken211df572011-07-05 19:16:39 -04003559 if (rc) {
3560 kobject_put(tma340_prop_kobj);
3561 pr_err("%s: failed to create board_properties\n",
3562 __func__);
3563 goto reg_put;
3564 }
3565 }
3566
3567 } else {
3568 /* put voltage sources */
3569 regulator_put(vreg_tma340);
3570 /* destroy virtual keys */
3571 if (tma340_prop_kobj) {
Zhang Chang Ken211df572011-07-05 19:16:39 -04003572 kobject_put(tma340_prop_kobj);
3573 }
3574 }
3575 return 0;
3576reg_put:
3577 regulator_put(vreg_tma340);
3578 return rc;
3579}
3580
3581
3582static struct cy8c_ts_platform_data cy8ctma340_dragon_pdata = {
3583 .ts_name = "cy8ctma340",
3584 .dis_min_x = 0,
3585 .dis_max_x = 479,
3586 .dis_min_y = 0,
3587 .dis_max_y = 799,
3588 .min_tid = 0,
3589 .max_tid = 255,
3590 .min_touch = 0,
3591 .max_touch = 255,
3592 .min_width = 0,
3593 .max_width = 255,
3594 .power_on = tma340_power,
3595 .dev_setup = tma340_dragon_dev_setup,
3596 .nfingers = 2,
3597 .irq_gpio = TS_PEN_IRQ_GPIO,
3598 .resout_gpio = -1,
3599};
3600
3601static struct i2c_board_info cy8ctma340_dragon_board_info[] = {
3602 {
3603 I2C_BOARD_INFO("cy8ctma340", 0x24),
3604 .platform_data = &cy8ctma340_dragon_pdata,
3605 }
3606};
3607
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003608#ifdef CONFIG_SERIAL_MSM_HS
3609static int configure_uart_gpios(int on)
3610{
3611 int ret = 0, i;
3612 int uart_gpios[] = {53, 54, 55, 56};
3613 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
3614 if (on) {
3615 ret = msm_gpiomux_get(uart_gpios[i]);
3616 if (unlikely(ret))
3617 break;
3618 } else {
3619 ret = msm_gpiomux_put(uart_gpios[i]);
3620 if (unlikely(ret))
3621 return ret;
3622 }
3623 }
3624 if (ret)
3625 for (; i >= 0; i--)
3626 msm_gpiomux_put(uart_gpios[i]);
3627 return ret;
3628}
3629static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3630 .inject_rx_on_wakeup = 1,
3631 .rx_to_inject = 0xFD,
3632 .gpio_config = configure_uart_gpios,
3633};
3634#endif
3635
3636
3637#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
3638
3639static struct gpio_led gpio_exp_leds_config[] = {
3640 {
3641 .name = "left_led1:green",
3642 .gpio = GPIO_LEFT_LED_1,
3643 .active_low = 1,
3644 .retain_state_suspended = 0,
3645 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3646 },
3647 {
3648 .name = "left_led2:red",
3649 .gpio = GPIO_LEFT_LED_2,
3650 .active_low = 1,
3651 .retain_state_suspended = 0,
3652 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3653 },
3654 {
3655 .name = "left_led3:green",
3656 .gpio = GPIO_LEFT_LED_3,
3657 .active_low = 1,
3658 .retain_state_suspended = 0,
3659 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3660 },
3661 {
3662 .name = "wlan_led:orange",
3663 .gpio = GPIO_LEFT_LED_WLAN,
3664 .active_low = 1,
3665 .retain_state_suspended = 0,
3666 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3667 },
3668 {
3669 .name = "left_led5:green",
3670 .gpio = GPIO_LEFT_LED_5,
3671 .active_low = 1,
3672 .retain_state_suspended = 0,
3673 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3674 },
3675 {
3676 .name = "right_led1:green",
3677 .gpio = GPIO_RIGHT_LED_1,
3678 .active_low = 1,
3679 .retain_state_suspended = 0,
3680 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3681 },
3682 {
3683 .name = "right_led2:red",
3684 .gpio = GPIO_RIGHT_LED_2,
3685 .active_low = 1,
3686 .retain_state_suspended = 0,
3687 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3688 },
3689 {
3690 .name = "right_led3:green",
3691 .gpio = GPIO_RIGHT_LED_3,
3692 .active_low = 1,
3693 .retain_state_suspended = 0,
3694 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3695 },
3696 {
3697 .name = "bt_led:blue",
3698 .gpio = GPIO_RIGHT_LED_BT,
3699 .active_low = 1,
3700 .retain_state_suspended = 0,
3701 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3702 },
3703 {
3704 .name = "right_led5:green",
3705 .gpio = GPIO_RIGHT_LED_5,
3706 .active_low = 1,
3707 .retain_state_suspended = 0,
3708 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3709 },
3710};
3711
3712static struct gpio_led_platform_data gpio_leds_pdata = {
3713 .num_leds = ARRAY_SIZE(gpio_exp_leds_config),
3714 .leds = gpio_exp_leds_config,
3715};
3716
3717static struct platform_device gpio_leds = {
3718 .name = "leds-gpio",
3719 .id = -1,
3720 .dev = {
3721 .platform_data = &gpio_leds_pdata,
3722 },
3723};
3724
3725static struct gpio_led fluid_gpio_leds[] = {
3726 {
3727 .name = "dual_led:green",
3728 .gpio = GPIO_LED1_GREEN_N,
3729 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3730 .active_low = 1,
3731 .retain_state_suspended = 0,
3732 },
3733 {
3734 .name = "dual_led:red",
3735 .gpio = GPIO_LED2_RED_N,
3736 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3737 .active_low = 1,
3738 .retain_state_suspended = 0,
3739 },
3740};
3741
3742static struct gpio_led_platform_data gpio_led_pdata = {
3743 .leds = fluid_gpio_leds,
3744 .num_leds = ARRAY_SIZE(fluid_gpio_leds),
3745};
3746
3747static struct platform_device fluid_leds_gpio = {
3748 .name = "leds-gpio",
3749 .id = -1,
3750 .dev = {
3751 .platform_data = &gpio_led_pdata,
3752 },
3753};
3754
3755#endif
3756
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003757#ifdef CONFIG_BATTERY_MSM8X60
3758static struct msm_charger_platform_data msm_charger_data = {
3759 .safety_time = 180,
3760 .update_time = 1,
3761 .max_voltage = 4200,
3762 .min_voltage = 3200,
3763};
3764
3765static struct platform_device msm_charger_device = {
3766 .name = "msm-charger",
3767 .id = -1,
3768 .dev = {
3769 .platform_data = &msm_charger_data,
3770 }
3771};
3772#endif
3773
3774/*
3775 * Consumer specific regulator names:
3776 * regulator name consumer dev_name
3777 */
3778static struct regulator_consumer_supply vreg_consumers_PM8058_L0[] = {
3779 REGULATOR_SUPPLY("8058_l0", NULL),
3780};
3781static struct regulator_consumer_supply vreg_consumers_PM8058_L1[] = {
3782 REGULATOR_SUPPLY("8058_l1", NULL),
3783};
3784static struct regulator_consumer_supply vreg_consumers_PM8058_L2[] = {
3785 REGULATOR_SUPPLY("8058_l2", NULL),
3786};
3787static struct regulator_consumer_supply vreg_consumers_PM8058_L3[] = {
3788 REGULATOR_SUPPLY("8058_l3", NULL),
3789};
3790static struct regulator_consumer_supply vreg_consumers_PM8058_L4[] = {
3791 REGULATOR_SUPPLY("8058_l4", NULL),
3792};
3793static struct regulator_consumer_supply vreg_consumers_PM8058_L5[] = {
3794 REGULATOR_SUPPLY("8058_l5", NULL),
3795};
3796static struct regulator_consumer_supply vreg_consumers_PM8058_L6[] = {
3797 REGULATOR_SUPPLY("8058_l6", NULL),
3798};
3799static struct regulator_consumer_supply vreg_consumers_PM8058_L7[] = {
3800 REGULATOR_SUPPLY("8058_l7", NULL),
3801};
3802static struct regulator_consumer_supply vreg_consumers_PM8058_L8[] = {
3803 REGULATOR_SUPPLY("8058_l8", NULL),
3804};
3805static struct regulator_consumer_supply vreg_consumers_PM8058_L9[] = {
3806 REGULATOR_SUPPLY("8058_l9", NULL),
3807};
3808static struct regulator_consumer_supply vreg_consumers_PM8058_L10[] = {
3809 REGULATOR_SUPPLY("8058_l10", NULL),
3810};
3811static struct regulator_consumer_supply vreg_consumers_PM8058_L11[] = {
3812 REGULATOR_SUPPLY("8058_l11", NULL),
3813};
3814static struct regulator_consumer_supply vreg_consumers_PM8058_L12[] = {
3815 REGULATOR_SUPPLY("8058_l12", NULL),
3816};
3817static struct regulator_consumer_supply vreg_consumers_PM8058_L13[] = {
3818 REGULATOR_SUPPLY("8058_l13", NULL),
3819};
3820static struct regulator_consumer_supply vreg_consumers_PM8058_L14[] = {
3821 REGULATOR_SUPPLY("8058_l14", NULL),
3822};
3823static struct regulator_consumer_supply vreg_consumers_PM8058_L15[] = {
3824 REGULATOR_SUPPLY("8058_l15", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003825 REGULATOR_SUPPLY("cam_vana", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003826 REGULATOR_SUPPLY("cam_vana", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003827 REGULATOR_SUPPLY("cam_vana", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003828};
3829static struct regulator_consumer_supply vreg_consumers_PM8058_L16[] = {
3830 REGULATOR_SUPPLY("8058_l16", NULL),
3831};
3832static struct regulator_consumer_supply vreg_consumers_PM8058_L17[] = {
3833 REGULATOR_SUPPLY("8058_l17", NULL),
3834};
3835static struct regulator_consumer_supply vreg_consumers_PM8058_L18[] = {
3836 REGULATOR_SUPPLY("8058_l18", NULL),
3837};
3838static struct regulator_consumer_supply vreg_consumers_PM8058_L19[] = {
3839 REGULATOR_SUPPLY("8058_l19", NULL),
3840};
3841static struct regulator_consumer_supply vreg_consumers_PM8058_L20[] = {
3842 REGULATOR_SUPPLY("8058_l20", NULL),
3843};
3844static struct regulator_consumer_supply vreg_consumers_PM8058_L21[] = {
3845 REGULATOR_SUPPLY("8058_l21", NULL),
3846};
3847static struct regulator_consumer_supply vreg_consumers_PM8058_L22[] = {
3848 REGULATOR_SUPPLY("8058_l22", NULL),
3849};
3850static struct regulator_consumer_supply vreg_consumers_PM8058_L23[] = {
3851 REGULATOR_SUPPLY("8058_l23", NULL),
3852};
3853static struct regulator_consumer_supply vreg_consumers_PM8058_L24[] = {
3854 REGULATOR_SUPPLY("8058_l24", NULL),
3855};
3856static struct regulator_consumer_supply vreg_consumers_PM8058_L25[] = {
3857 REGULATOR_SUPPLY("8058_l25", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003858 REGULATOR_SUPPLY("cam_vdig", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003859 REGULATOR_SUPPLY("cam_vdig", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003860 REGULATOR_SUPPLY("cam_vdig", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003861};
3862static struct regulator_consumer_supply vreg_consumers_PM8058_S0[] = {
3863 REGULATOR_SUPPLY("8058_s0", NULL),
3864};
3865static struct regulator_consumer_supply vreg_consumers_PM8058_S1[] = {
3866 REGULATOR_SUPPLY("8058_s1", NULL),
3867};
3868static struct regulator_consumer_supply vreg_consumers_PM8058_S2[] = {
3869 REGULATOR_SUPPLY("8058_s2", NULL),
3870};
3871static struct regulator_consumer_supply vreg_consumers_PM8058_S3[] = {
3872 REGULATOR_SUPPLY("8058_s3", NULL),
3873};
3874static struct regulator_consumer_supply vreg_consumers_PM8058_S4[] = {
3875 REGULATOR_SUPPLY("8058_s4", NULL),
3876};
3877static struct regulator_consumer_supply vreg_consumers_PM8058_LVS0[] = {
3878 REGULATOR_SUPPLY("8058_lvs0", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003879 REGULATOR_SUPPLY("cam_vio", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003880 REGULATOR_SUPPLY("cam_vio", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003881 REGULATOR_SUPPLY("cam_vio", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003882};
3883static struct regulator_consumer_supply vreg_consumers_PM8058_LVS1[] = {
3884 REGULATOR_SUPPLY("8058_lvs1", NULL),
3885};
3886static struct regulator_consumer_supply vreg_consumers_PM8058_NCP[] = {
3887 REGULATOR_SUPPLY("8058_ncp", NULL),
3888};
3889
3890static struct regulator_consumer_supply vreg_consumers_PM8901_L0[] = {
3891 REGULATOR_SUPPLY("8901_l0", NULL),
3892};
3893static struct regulator_consumer_supply vreg_consumers_PM8901_L1[] = {
3894 REGULATOR_SUPPLY("8901_l1", NULL),
3895};
3896static struct regulator_consumer_supply vreg_consumers_PM8901_L2[] = {
3897 REGULATOR_SUPPLY("8901_l2", NULL),
3898};
3899static struct regulator_consumer_supply vreg_consumers_PM8901_L3[] = {
3900 REGULATOR_SUPPLY("8901_l3", NULL),
3901};
3902static struct regulator_consumer_supply vreg_consumers_PM8901_L4[] = {
3903 REGULATOR_SUPPLY("8901_l4", NULL),
3904};
3905static struct regulator_consumer_supply vreg_consumers_PM8901_L5[] = {
3906 REGULATOR_SUPPLY("8901_l5", NULL),
3907};
3908static struct regulator_consumer_supply vreg_consumers_PM8901_L6[] = {
3909 REGULATOR_SUPPLY("8901_l6", NULL),
3910};
3911static struct regulator_consumer_supply vreg_consumers_PM8901_S2[] = {
3912 REGULATOR_SUPPLY("8901_s2", NULL),
3913};
3914static struct regulator_consumer_supply vreg_consumers_PM8901_S3[] = {
3915 REGULATOR_SUPPLY("8901_s3", NULL),
3916};
3917static struct regulator_consumer_supply vreg_consumers_PM8901_S4[] = {
3918 REGULATOR_SUPPLY("8901_s4", NULL),
3919};
3920static struct regulator_consumer_supply vreg_consumers_PM8901_LVS0[] = {
3921 REGULATOR_SUPPLY("8901_lvs0", NULL),
3922};
3923static struct regulator_consumer_supply vreg_consumers_PM8901_LVS1[] = {
3924 REGULATOR_SUPPLY("8901_lvs1", NULL),
3925};
3926static struct regulator_consumer_supply vreg_consumers_PM8901_LVS2[] = {
3927 REGULATOR_SUPPLY("8901_lvs2", NULL),
3928};
3929static struct regulator_consumer_supply vreg_consumers_PM8901_LVS3[] = {
3930 REGULATOR_SUPPLY("8901_lvs3", NULL),
3931};
3932static struct regulator_consumer_supply vreg_consumers_PM8901_MVS0[] = {
3933 REGULATOR_SUPPLY("8901_mvs0", NULL),
3934};
3935
David Collins6f032ba2011-08-31 14:08:15 -07003936/* Pin control regulators */
3937static struct regulator_consumer_supply vreg_consumers_PM8058_L8_PC[] = {
3938 REGULATOR_SUPPLY("8058_l8_pc", NULL),
3939};
3940static struct regulator_consumer_supply vreg_consumers_PM8058_L20_PC[] = {
3941 REGULATOR_SUPPLY("8058_l20_pc", NULL),
3942};
3943static struct regulator_consumer_supply vreg_consumers_PM8058_L21_PC[] = {
3944 REGULATOR_SUPPLY("8058_l21_pc", NULL),
3945};
3946static struct regulator_consumer_supply vreg_consumers_PM8058_S2_PC[] = {
3947 REGULATOR_SUPPLY("8058_s2_pc", NULL),
3948};
3949static struct regulator_consumer_supply vreg_consumers_PM8901_L0_PC[] = {
3950 REGULATOR_SUPPLY("8901_l0_pc", NULL),
3951};
3952static struct regulator_consumer_supply vreg_consumers_PM8901_S4_PC[] = {
3953 REGULATOR_SUPPLY("8901_s4_pc", NULL),
3954};
3955
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003956#define RPM_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
3957 _default_uV, _peak_uA, _avg_uA, _pull_down, _pin_ctrl, \
David Collins15789042012-03-19 10:44:36 -07003958 _freq, _pin_fn, _force_mode, _sleep_set_force_mode, \
3959 _state, _sleep_selectable, _always_on) \
David Collins6f032ba2011-08-31 14:08:15 -07003960 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003961 .init_data = { \
3962 .constraints = { \
David Collins6f032ba2011-08-31 14:08:15 -07003963 .valid_modes_mask = _modes, \
3964 .valid_ops_mask = _ops, \
3965 .min_uV = _min_uV, \
3966 .max_uV = _max_uV, \
3967 .input_uV = _min_uV, \
3968 .apply_uV = _apply_uV, \
3969 .always_on = _always_on, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003970 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003971 .consumer_supplies = vreg_consumers_##_id, \
3972 .num_consumer_supplies = \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003973 ARRAY_SIZE(vreg_consumers_##_id), \
3974 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003975 .id = RPM_VREG_ID_##_id, \
3976 .default_uV = _default_uV, \
3977 .peak_uA = _peak_uA, \
3978 .avg_uA = _avg_uA, \
3979 .pull_down_enable = _pull_down, \
3980 .pin_ctrl = _pin_ctrl, \
3981 .freq = RPM_VREG_FREQ_##_freq, \
3982 .pin_fn = _pin_fn, \
3983 .force_mode = _force_mode, \
David Collins15789042012-03-19 10:44:36 -07003984 .sleep_set_force_mode = _sleep_set_force_mode, \
David Collins6f032ba2011-08-31 14:08:15 -07003985 .state = _state, \
3986 .sleep_selectable = _sleep_selectable, \
3987 }
3988
3989/* Pin control initialization */
3990#define RPM_PC(_id, _always_on, _pin_fn, _pin_ctrl) \
3991 { \
3992 .init_data = { \
3993 .constraints = { \
3994 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
3995 .always_on = _always_on, \
3996 }, \
3997 .num_consumer_supplies = \
3998 ARRAY_SIZE(vreg_consumers_##_id##_PC), \
3999 .consumer_supplies = vreg_consumers_##_id##_PC, \
4000 }, \
4001 .id = RPM_VREG_ID_##_id##_PC, \
4002 .pin_fn = RPM_VREG_PIN_FN_8660_##_pin_fn, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004003 .pin_ctrl = _pin_ctrl, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004004 }
4005
4006/*
4007 * The default LPM/HPM state of an RPM controlled regulator can be controlled
4008 * via the peak_uA value specified in the table below. If the value is less
4009 * than the high power min threshold for the regulator, then the regulator will
4010 * be set to LPM. Otherwise, it will be set to HPM.
4011 *
4012 * This value can be further overridden by specifying an initial mode via
4013 * .init_data.constraints.initial_mode.
4014 */
4015
David Collins6f032ba2011-08-31 14:08:15 -07004016#define RPM_LDO(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4017 _init_peak_uA) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004018 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4019 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4020 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4021 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4022 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004023 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4024 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004025 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004026 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004027 _sleep_selectable, _always_on)
4028
David Collins6f032ba2011-08-31 14:08:15 -07004029#define RPM_SMPS(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4030 _init_peak_uA, _freq) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004031 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4032 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4033 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4034 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4035 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004036 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, _freq, \
4037 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004038 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004039 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4040 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004041
David Collins6f032ba2011-08-31 14:08:15 -07004042#define RPM_VS(_id, _always_on, _pd, _sleep_selectable) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004043 RPM_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE, \
4044 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE, 0, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004045 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4046 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004047 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004048 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4049 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004050
David Collins6f032ba2011-08-31 14:08:15 -07004051#define RPM_NCP(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004052 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL, \
4053 REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004054 _min_uV, 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4055 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004056 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004057 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4058 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004059
David Collins6f032ba2011-08-31 14:08:15 -07004060#define LDO50HMIN RPM_VREG_8660_LDO_50_HPM_MIN_LOAD
4061#define LDO150HMIN RPM_VREG_8660_LDO_150_HPM_MIN_LOAD
4062#define LDO300HMIN RPM_VREG_8660_LDO_300_HPM_MIN_LOAD
4063#define SMPS_HMIN RPM_VREG_8660_SMPS_HPM_MIN_LOAD
4064#define FTS_HMIN RPM_VREG_8660_FTSMPS_HPM_MIN_LOAD
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004065
David Collins6f032ba2011-08-31 14:08:15 -07004066/* RPM early regulator constraints */
4067static struct rpm_regulator_init_data rpm_regulator_early_init_data[] = {
4068 /* ID a_on pd ss min_uV max_uV init_ip freq */
Matt Wagantall2ecbec22012-03-13 23:18:07 -07004069 RPM_SMPS(PM8058_S0, 0, 1, 1, 500000, 1325000, SMPS_HMIN, 1p60),
David Collins6f032ba2011-08-31 14:08:15 -07004070 RPM_SMPS(PM8058_S1, 0, 1, 1, 500000, 1250000, SMPS_HMIN, 1p60),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004071};
4072
David Collins6f032ba2011-08-31 14:08:15 -07004073/* RPM regulator constraints */
4074static struct rpm_regulator_init_data rpm_regulator_init_data[] = {
4075 /* ID a_on pd ss min_uV max_uV init_ip */
4076 RPM_LDO(PM8058_L0, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4077 RPM_LDO(PM8058_L1, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4078 RPM_LDO(PM8058_L2, 0, 1, 0, 1800000, 2600000, LDO300HMIN),
4079 RPM_LDO(PM8058_L3, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4080 RPM_LDO(PM8058_L4, 0, 1, 0, 2850000, 2850000, LDO50HMIN),
4081 RPM_LDO(PM8058_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4082 RPM_LDO(PM8058_L6, 0, 1, 0, 3000000, 3600000, LDO50HMIN),
4083 RPM_LDO(PM8058_L7, 0, 1, 0, 1800000, 1800000, LDO50HMIN),
4084 RPM_LDO(PM8058_L8, 0, 1, 0, 2900000, 3050000, LDO300HMIN),
4085 RPM_LDO(PM8058_L9, 0, 1, 0, 1800000, 1800000, LDO300HMIN),
4086 RPM_LDO(PM8058_L10, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4087 RPM_LDO(PM8058_L11, 0, 1, 0, 1500000, 1500000, LDO150HMIN),
4088 RPM_LDO(PM8058_L12, 0, 1, 0, 2900000, 2900000, LDO150HMIN),
4089 RPM_LDO(PM8058_L13, 0, 1, 0, 2050000, 2050000, LDO300HMIN),
4090 RPM_LDO(PM8058_L14, 0, 0, 0, 2850000, 2850000, LDO300HMIN),
4091 RPM_LDO(PM8058_L15, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4092 RPM_LDO(PM8058_L16, 1, 1, 0, 1800000, 1800000, LDO300HMIN),
4093 RPM_LDO(PM8058_L17, 0, 1, 0, 2600000, 2600000, LDO150HMIN),
4094 RPM_LDO(PM8058_L18, 0, 1, 0, 2200000, 2200000, LDO150HMIN),
4095 RPM_LDO(PM8058_L19, 0, 1, 0, 2500000, 2500000, LDO150HMIN),
4096 RPM_LDO(PM8058_L20, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4097 RPM_LDO(PM8058_L21, 1, 1, 0, 1200000, 1200000, LDO150HMIN),
4098 RPM_LDO(PM8058_L22, 0, 1, 0, 1150000, 1150000, LDO300HMIN),
4099 RPM_LDO(PM8058_L23, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4100 RPM_LDO(PM8058_L24, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4101 RPM_LDO(PM8058_L25, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004102
David Collins6f032ba2011-08-31 14:08:15 -07004103 /* ID a_on pd ss min_uV max_uV init_ip freq */
4104 RPM_SMPS(PM8058_S2, 0, 1, 1, 1200000, 1400000, SMPS_HMIN, 1p60),
4105 RPM_SMPS(PM8058_S3, 1, 1, 0, 1800000, 1800000, SMPS_HMIN, 1p60),
4106 RPM_SMPS(PM8058_S4, 1, 1, 0, 2200000, 2200000, SMPS_HMIN, 1p60),
4107
4108 /* ID a_on pd ss */
4109 RPM_VS(PM8058_LVS0, 0, 1, 0),
4110 RPM_VS(PM8058_LVS1, 0, 1, 0),
4111
4112 /* ID a_on pd ss min_uV max_uV */
4113 RPM_NCP(PM8058_NCP, 0, 1, 0, 1800000, 1800000),
4114
4115 /* ID a_on pd ss min_uV max_uV init_ip */
4116 RPM_LDO(PM8901_L0, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4117 RPM_LDO(PM8901_L1, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4118 RPM_LDO(PM8901_L2, 0, 1, 0, 2850000, 3300000, LDO300HMIN),
4119 RPM_LDO(PM8901_L3, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4120 RPM_LDO(PM8901_L4, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4121 RPM_LDO(PM8901_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4122 RPM_LDO(PM8901_L6, 0, 1, 0, 2200000, 2200000, LDO300HMIN),
4123
4124 /* ID a_on pd ss min_uV max_uV init_ip freq */
4125 RPM_SMPS(PM8901_S2, 0, 1, 0, 1300000, 1300000, FTS_HMIN, 1p60),
4126 RPM_SMPS(PM8901_S3, 0, 1, 0, 1100000, 1100000, FTS_HMIN, 1p60),
4127 RPM_SMPS(PM8901_S4, 0, 1, 0, 1225000, 1225000, FTS_HMIN, 1p60),
4128
4129 /* ID a_on pd ss */
4130 RPM_VS(PM8901_LVS0, 1, 1, 0),
4131 RPM_VS(PM8901_LVS1, 0, 1, 0),
4132 RPM_VS(PM8901_LVS2, 0, 1, 0),
4133 RPM_VS(PM8901_LVS3, 0, 1, 0),
4134 RPM_VS(PM8901_MVS0, 0, 1, 0),
4135
4136 /* ID a_on pin_func pin_ctrl */
4137 RPM_PC(PM8058_L8, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4138 RPM_PC(PM8058_L20, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4139 RPM_PC(PM8058_L21, 1, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4140 RPM_PC(PM8058_S2, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8058_A0),
4141 RPM_PC(PM8901_L0, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4142 RPM_PC(PM8901_S4, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4143};
4144
4145static struct rpm_regulator_platform_data rpm_regulator_early_pdata = {
4146 .init_data = rpm_regulator_early_init_data,
4147 .num_regulators = ARRAY_SIZE(rpm_regulator_early_init_data),
4148 .version = RPM_VREG_VERSION_8660,
4149 .vreg_id_vdd_mem = RPM_VREG_ID_PM8058_S0,
4150 .vreg_id_vdd_dig = RPM_VREG_ID_PM8058_S1,
4151};
4152
4153static struct rpm_regulator_platform_data rpm_regulator_pdata = {
4154 .init_data = rpm_regulator_init_data,
4155 .num_regulators = ARRAY_SIZE(rpm_regulator_init_data),
4156 .version = RPM_VREG_VERSION_8660,
4157};
4158
4159static struct platform_device rpm_regulator_early_device = {
4160 .name = "rpm-regulator",
4161 .id = 0,
4162 .dev = {
4163 .platform_data = &rpm_regulator_early_pdata,
4164 },
4165};
4166
4167static struct platform_device rpm_regulator_device = {
4168 .name = "rpm-regulator",
4169 .id = 1,
4170 .dev = {
4171 .platform_data = &rpm_regulator_pdata,
4172 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004173};
4174
4175static struct platform_device *early_regulators[] __initdata = {
4176 &msm_device_saw_s0,
4177 &msm_device_saw_s1,
David Collins6f032ba2011-08-31 14:08:15 -07004178 &rpm_regulator_early_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004179};
4180
4181static struct platform_device *early_devices[] __initdata = {
4182#ifdef CONFIG_MSM_BUS_SCALING
4183 &msm_bus_apps_fabric,
4184 &msm_bus_sys_fabric,
4185 &msm_bus_mm_fabric,
4186 &msm_bus_sys_fpb,
4187 &msm_bus_cpss_fpb,
4188#endif
4189 &msm_device_dmov_adm0,
4190 &msm_device_dmov_adm1,
4191};
4192
4193#if (defined(CONFIG_MARIMBA_CORE)) && \
4194 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4195
4196static int bluetooth_power(int);
4197static struct platform_device msm_bt_power_device = {
4198 .name = "bt_power",
4199 .id = -1,
4200 .dev = {
4201 .platform_data = &bluetooth_power,
4202 },
4203};
4204#endif
4205
4206static struct platform_device msm_tsens_device = {
4207 .name = "tsens-tm",
4208 .id = -1,
4209};
4210
4211static struct platform_device *rumi_sim_devices[] __initdata = {
4212 &smc91x_device,
4213 &msm_device_uart_dm12,
4214#ifdef CONFIG_I2C_QUP
4215 &msm_gsbi3_qup_i2c_device,
4216 &msm_gsbi4_qup_i2c_device,
4217 &msm_gsbi7_qup_i2c_device,
4218 &msm_gsbi8_qup_i2c_device,
4219 &msm_gsbi9_qup_i2c_device,
4220 &msm_gsbi12_qup_i2c_device,
4221#endif
4222#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004223 &msm_device_ssbi3,
4224#endif
4225#ifdef CONFIG_ANDROID_PMEM
Laura Abbottdf8b8a82011-11-02 23:13:45 -07004226#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004227 &android_pmem_device,
4228 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004229 &android_pmem_smipool_device,
Laura Abbottdf8b8a82011-11-02 23:13:45 -07004230 &android_pmem_audio_device,
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05304231#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
4232#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004233#ifdef CONFIG_MSM_ROTATOR
4234 &msm_rotator_device,
4235#endif
4236 &msm_fb_device,
4237 &msm_kgsl_3d0,
4238 &msm_kgsl_2d0,
4239 &msm_kgsl_2d1,
4240 &lcdc_samsung_panel_device,
4241#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
4242 &hdmi_msm_device,
4243#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
4244#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07004245#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004246#ifdef CONFIG_MT9E013
4247 &msm_camera_sensor_mt9e013,
4248#endif
4249#ifdef CONFIG_IMX074
4250 &msm_camera_sensor_imx074,
4251#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04004252#ifdef CONFIG_VX6953
4253 &msm_camera_sensor_vx6953,
4254#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004255#ifdef CONFIG_WEBCAM_OV7692
4256 &msm_camera_sensor_webcam_ov7692,
4257#endif
4258#ifdef CONFIG_WEBCAM_OV9726
4259 &msm_camera_sensor_webcam_ov9726,
4260#endif
4261#ifdef CONFIG_QS_S5K4E1
4262 &msm_camera_sensor_qs_s5k4e1,
4263#endif
4264#endif
Kevin Chan3be11612012-03-22 20:05:40 -07004265#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004266#ifdef CONFIG_MSM_GEMINI
4267 &msm_gemini_device,
4268#endif
4269#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07004270#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004271 &msm_vpe_device,
4272#endif
Kevin Chan3be11612012-03-22 20:05:40 -07004273#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004274 &msm_device_vidc,
4275};
4276
4277#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
4278enum {
4279 SX150X_CORE,
4280 SX150X_DOCKING,
4281 SX150X_SURF,
4282 SX150X_LEFT_FHA,
4283 SX150X_RIGHT_FHA,
4284 SX150X_SOUTH,
4285 SX150X_NORTH,
4286 SX150X_CORE_FLUID,
4287};
4288
4289static struct sx150x_platform_data sx150x_data[] __initdata = {
4290 [SX150X_CORE] = {
4291 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4292 .oscio_is_gpo = false,
4293 .io_pullup_ena = 0x0c08,
4294 .io_pulldn_ena = 0x4060,
4295 .io_open_drain_ena = 0x000c,
4296 .io_polarity = 0,
4297 .irq_summary = -1, /* see fixup_i2c_configs() */
4298 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4299 },
4300 [SX150X_DOCKING] = {
4301 .gpio_base = GPIO_DOCKING_EXPANDER_BASE,
4302 .oscio_is_gpo = false,
4303 .io_pullup_ena = 0x5e06,
4304 .io_pulldn_ena = 0x81b8,
4305 .io_open_drain_ena = 0,
4306 .io_polarity = 0,
4307 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4308 UI_INT2_N),
4309 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4310 GPIO_DOCKING_EXPANDER_BASE -
4311 GPIO_EXPANDER_GPIO_BASE,
4312 },
4313 [SX150X_SURF] = {
4314 .gpio_base = GPIO_SURF_EXPANDER_BASE,
4315 .oscio_is_gpo = false,
4316 .io_pullup_ena = 0,
4317 .io_pulldn_ena = 0,
4318 .io_open_drain_ena = 0,
4319 .io_polarity = 0,
4320 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4321 UI_INT1_N),
4322 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4323 GPIO_SURF_EXPANDER_BASE -
4324 GPIO_EXPANDER_GPIO_BASE,
4325 },
4326 [SX150X_LEFT_FHA] = {
4327 .gpio_base = GPIO_LEFT_KB_EXPANDER_BASE,
4328 .oscio_is_gpo = false,
4329 .io_pullup_ena = 0,
4330 .io_pulldn_ena = 0x40,
4331 .io_open_drain_ena = 0,
4332 .io_polarity = 0,
4333 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4334 UI_INT3_N),
4335 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4336 GPIO_LEFT_KB_EXPANDER_BASE -
4337 GPIO_EXPANDER_GPIO_BASE,
4338 },
4339 [SX150X_RIGHT_FHA] = {
4340 .gpio_base = GPIO_RIGHT_KB_EXPANDER_BASE,
4341 .oscio_is_gpo = true,
4342 .io_pullup_ena = 0,
4343 .io_pulldn_ena = 0,
4344 .io_open_drain_ena = 0,
4345 .io_polarity = 0,
4346 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4347 UI_INT3_N),
4348 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4349 GPIO_RIGHT_KB_EXPANDER_BASE -
4350 GPIO_EXPANDER_GPIO_BASE,
4351 },
4352 [SX150X_SOUTH] = {
4353 .gpio_base = GPIO_SOUTH_EXPANDER_BASE,
4354 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4355 GPIO_SOUTH_EXPANDER_BASE -
4356 GPIO_EXPANDER_GPIO_BASE,
4357 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4358 },
4359 [SX150X_NORTH] = {
4360 .gpio_base = GPIO_NORTH_EXPANDER_BASE,
4361 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4362 GPIO_NORTH_EXPANDER_BASE -
4363 GPIO_EXPANDER_GPIO_BASE,
4364 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4365 .oscio_is_gpo = true,
4366 .io_open_drain_ena = 0x30,
4367 },
4368 [SX150X_CORE_FLUID] = {
4369 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4370 .oscio_is_gpo = false,
4371 .io_pullup_ena = 0x0408,
4372 .io_pulldn_ena = 0x4060,
4373 .io_open_drain_ena = 0x0008,
4374 .io_polarity = 0,
4375 .irq_summary = -1, /* see fixup_i2c_configs() */
4376 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4377 },
4378};
4379
4380#ifdef CONFIG_SENSORS_MSM_ADC
4381/* Configuration of EPM expander is done when client
4382 * request an adc read
4383 */
4384static struct sx150x_platform_data sx150x_epmdata = {
4385 .gpio_base = GPIO_EPM_EXPANDER_BASE,
4386 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4387 GPIO_EPM_EXPANDER_BASE -
4388 GPIO_EXPANDER_GPIO_BASE,
4389 .irq_summary = -1,
4390};
4391#endif
4392
4393/* sx150x_low_power_cfg
4394 *
4395 * This data and init function are used to put unused gpio-expander output
4396 * lines into their low-power states at boot. The init
4397 * function must be deferred until a later init stage because the i2c
4398 * gpio expander drivers do not probe until after they are registered
4399 * (see register_i2c_devices) and the work-queues for those registrations
4400 * are processed. Because these lines are unused, there is no risk of
4401 * competing with a device driver for the gpio.
4402 *
4403 * gpio lines whose low-power states are input are naturally in their low-
4404 * power configurations once probed, see the platform data structures above.
4405 */
4406struct sx150x_low_power_cfg {
4407 unsigned gpio;
4408 unsigned val;
4409};
4410
4411static struct sx150x_low_power_cfg
4412common_sx150x_lp_cfgs[] __initdata = {
4413 {GPIO_WLAN_DEEP_SLEEP_N, 0},
4414 {GPIO_EXT_GPS_LNA_EN, 0},
4415 {GPIO_MSM_WAKES_BT, 0},
4416 {GPIO_USB_UICC_EN, 0},
4417 {GPIO_BATT_GAUGE_EN, 0},
4418};
4419
4420static struct sx150x_low_power_cfg
4421surf_ffa_sx150x_lp_cfgs[] __initdata = {
4422 {GPIO_MIPI_DSI_RST_N, 0},
4423 {GPIO_DONGLE_PWR_EN, 0},
4424 {GPIO_CAP_TS_SLEEP, 1},
4425 {GPIO_WEB_CAMIF_RESET_N, 0},
4426};
4427
4428static void __init
4429cfg_gpio_low_power(struct sx150x_low_power_cfg *cfgs, unsigned nelems)
4430{
4431 unsigned n;
4432 int rc;
4433
4434 for (n = 0; n < nelems; ++n) {
4435 rc = gpio_request(cfgs[n].gpio, NULL);
4436 if (!rc) {
4437 rc = gpio_direction_output(cfgs[n].gpio, cfgs[n].val);
4438 gpio_free(cfgs[n].gpio);
4439 }
4440
4441 if (rc) {
4442 printk(KERN_NOTICE "%s: failed to sleep gpio %d: %d\n",
4443 __func__, cfgs[n].gpio, rc);
4444 }
Steve Muckle9161d302010-02-11 11:50:40 -08004445 }
Steve Mucklea55df6e2010-01-07 12:43:24 -08004446}
4447
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004448static int __init cfg_sx150xs_low_power(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08004449{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004450 cfg_gpio_low_power(common_sx150x_lp_cfgs,
4451 ARRAY_SIZE(common_sx150x_lp_cfgs));
4452 if (!machine_is_msm8x60_fluid())
4453 cfg_gpio_low_power(surf_ffa_sx150x_lp_cfgs,
4454 ARRAY_SIZE(surf_ffa_sx150x_lp_cfgs));
4455 return 0;
4456}
4457module_init(cfg_sx150xs_low_power);
4458
4459#ifdef CONFIG_I2C
4460static struct i2c_board_info core_expander_i2c_info[] __initdata = {
4461 {
4462 I2C_BOARD_INFO("sx1509q", 0x3e),
4463 .platform_data = &sx150x_data[SX150X_CORE]
4464 },
4465};
4466
4467static struct i2c_board_info docking_expander_i2c_info[] __initdata = {
4468 {
4469 I2C_BOARD_INFO("sx1509q", 0x3f),
4470 .platform_data = &sx150x_data[SX150X_DOCKING]
4471 },
4472};
4473
4474static struct i2c_board_info surf_expanders_i2c_info[] __initdata = {
4475 {
4476 I2C_BOARD_INFO("sx1509q", 0x70),
4477 .platform_data = &sx150x_data[SX150X_SURF]
4478 }
4479};
4480
4481static struct i2c_board_info fha_expanders_i2c_info[] __initdata = {
4482 {
4483 I2C_BOARD_INFO("sx1508q", 0x21),
4484 .platform_data = &sx150x_data[SX150X_LEFT_FHA]
4485 },
4486 {
4487 I2C_BOARD_INFO("sx1508q", 0x22),
4488 .platform_data = &sx150x_data[SX150X_RIGHT_FHA]
4489 }
4490};
4491
4492static struct i2c_board_info fluid_expanders_i2c_info[] __initdata = {
4493 {
4494 I2C_BOARD_INFO("sx1508q", 0x23),
4495 .platform_data = &sx150x_data[SX150X_SOUTH]
4496 },
4497 {
4498 I2C_BOARD_INFO("sx1508q", 0x20),
4499 .platform_data = &sx150x_data[SX150X_NORTH]
4500 }
4501};
4502
4503static struct i2c_board_info fluid_core_expander_i2c_info[] __initdata = {
4504 {
4505 I2C_BOARD_INFO("sx1509q", 0x3e),
4506 .platform_data = &sx150x_data[SX150X_CORE_FLUID]
4507 },
4508};
4509
4510#ifdef CONFIG_SENSORS_MSM_ADC
4511static struct i2c_board_info fluid_expanders_i2c_epm_info[] = {
4512 {
4513 I2C_BOARD_INFO("sx1509q", 0x3e),
4514 .platform_data = &sx150x_epmdata
4515 },
4516};
4517#endif
4518#endif
4519#endif
4520
4521#ifdef CONFIG_SENSORS_MSM_ADC
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004522
4523static struct adc_access_fn xoadc_fn = {
4524 pm8058_xoadc_select_chan_and_start_conv,
4525 pm8058_xoadc_read_adc_code,
4526 pm8058_xoadc_get_properties,
4527 pm8058_xoadc_slot_request,
4528 pm8058_xoadc_restore_slot,
4529 pm8058_xoadc_calibrate,
4530};
4531
4532#if defined(CONFIG_I2C) && \
4533 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4534static struct regulator *vreg_adc_epm1;
4535
4536static struct i2c_client *epm_expander_i2c_register_board(void)
4537
4538{
4539 struct i2c_adapter *i2c_adap;
4540 struct i2c_client *client = NULL;
4541 i2c_adap = i2c_get_adapter(0x0);
4542
4543 if (i2c_adap == NULL)
4544 printk(KERN_ERR "\nepm_expander_i2c_adapter is NULL\n");
4545
4546 if (i2c_adap != NULL)
4547 client = i2c_new_device(i2c_adap,
4548 &fluid_expanders_i2c_epm_info[0]);
4549 return client;
4550
4551}
4552
4553static unsigned int msm_adc_gpio_configure_expander_enable(void)
4554{
4555 int rc = 0;
4556 static struct i2c_client *epm_i2c_client;
4557
4558 printk(KERN_DEBUG "Enter msm_adc_gpio_configure_expander_enable\n");
4559
4560 vreg_adc_epm1 = regulator_get(NULL, "8058_s3");
4561
4562 if (IS_ERR(vreg_adc_epm1)) {
4563 printk(KERN_ERR "%s: Unable to get 8058_s3\n", __func__);
4564 return 0;
4565 }
4566
4567 rc = regulator_set_voltage(vreg_adc_epm1, 1800000, 1800000);
4568 if (rc)
4569 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4570 "regulator set voltage failed\n");
4571
4572 rc = regulator_enable(vreg_adc_epm1);
4573 if (rc) {
4574 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4575 "Error while enabling regulator for epm s3 %d\n", rc);
4576 return rc;
4577 }
4578
4579 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Start"
4580 " setting the value of the EPM 3.3, 5v and lvlsft\n");
4581
4582 msleep(1000);
4583
4584 rc = gpio_request(GPIO_EPM_5V_BOOST_EN, "boost_epm_5v");
4585 if (!rc) {
4586 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4587 "Configure 5v boost\n");
4588 gpio_direction_output(GPIO_EPM_5V_BOOST_EN, 1);
4589 } else {
4590 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4591 "Error for epm 5v boost en\n");
4592 goto exit_vreg_epm;
4593 }
4594
4595 msleep(500);
4596
4597 rc = gpio_request(GPIO_EPM_3_3V_EN, "epm_3_3v");
4598 if (!rc) {
4599 gpio_direction_output(GPIO_EPM_3_3V_EN, 1);
4600 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4601 "Configure epm 3.3v\n");
4602 } else {
4603 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4604 "Error for gpio 3.3ven\n");
4605 goto exit_vreg_epm;
4606 }
4607 msleep(500);
4608
4609 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4610 "Trying to request EPM LVLSFT_EN\n");
4611 rc = gpio_request(GPIO_EPM_LVLSFT_EN, "lvsft_en");
4612 if (!rc) {
4613 gpio_direction_output(GPIO_EPM_LVLSFT_EN, 1);
4614 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4615 "Configure the lvlsft\n");
4616 } else {
4617 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4618 "Error for epm lvlsft_en\n");
4619 goto exit_vreg_epm;
4620 }
4621
4622 msleep(500);
4623
4624 if (!epm_i2c_client)
4625 epm_i2c_client = epm_expander_i2c_register_board();
4626
4627 rc = gpio_request(GPIO_PWR_MON_ENABLE, "pwr_mon_enable");
4628 if (!rc)
4629 rc = gpio_direction_output(GPIO_PWR_MON_ENABLE, 1);
4630 if (rc) {
4631 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4632 ": GPIO PWR MON Enable issue\n");
4633 goto exit_vreg_epm;
4634 }
4635
4636 msleep(1000);
4637
4638 rc = gpio_request(GPIO_ADC1_PWDN_N, "adc1_pwdn");
4639 if (!rc) {
4640 rc = gpio_direction_output(GPIO_ADC1_PWDN_N, 1);
4641 if (rc) {
4642 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4643 ": ADC1_PWDN error direction out\n");
4644 goto exit_vreg_epm;
4645 }
4646 }
4647
4648 msleep(100);
4649
4650 rc = gpio_request(GPIO_ADC2_PWDN_N, "adc2_pwdn");
4651 if (!rc) {
4652 rc = gpio_direction_output(GPIO_ADC2_PWDN_N, 1);
4653 if (rc) {
4654 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4655 ": ADC2_PWD error direction out\n");
4656 goto exit_vreg_epm;
4657 }
4658 }
4659
4660 msleep(1000);
4661
4662 rc = gpio_request(GPIO_PWR_MON_START, "pwr_mon_start");
4663 if (!rc) {
4664 rc = gpio_direction_output(GPIO_PWR_MON_START, 0);
4665 if (rc) {
4666 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4667 "Gpio request problem %d\n", rc);
4668 goto exit_vreg_epm;
4669 }
4670 }
4671
4672 rc = gpio_request(GPIO_EPM_SPI_ADC1_CS_N, "spi_adc1_cs");
4673 if (!rc) {
4674 rc = gpio_direction_output(GPIO_EPM_SPI_ADC1_CS_N, 0);
4675 if (rc) {
4676 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4677 ": EPM_SPI_ADC1_CS_N error\n");
4678 goto exit_vreg_epm;
4679 }
4680 }
4681
4682 rc = gpio_request(GPIO_EPM_SPI_ADC2_CS_N, "spi_adc2_cs");
4683 if (!rc) {
4684 rc = gpio_direction_output(GPIO_EPM_SPI_ADC2_CS_N, 0);
4685 if (rc) {
4686 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4687 ": EPM_SPI_ADC2_Cs_N error\n");
4688 goto exit_vreg_epm;
4689 }
4690 }
4691
4692 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Set "
4693 "the power monitor reset for epm\n");
4694
4695 rc = gpio_request(GPIO_PWR_MON_RESET_N, "pwr_mon_reset_n");
4696 if (!rc) {
4697 gpio_direction_output(GPIO_PWR_MON_RESET_N, 0);
4698 if (rc) {
4699 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4700 ": Error in the power mon reset\n");
4701 goto exit_vreg_epm;
4702 }
4703 }
4704
4705 msleep(1000);
4706
4707 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 1);
4708
4709 msleep(500);
4710
4711 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4712
4713 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4714
4715 return rc;
4716
4717exit_vreg_epm:
4718 regulator_disable(vreg_adc_epm1);
4719
4720 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: Exit."
4721 " rc = %d.\n", rc);
4722 return rc;
4723};
4724
4725static unsigned int msm_adc_gpio_configure_expander_disable(void)
4726{
4727 int rc = 0;
4728
4729 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 0);
4730 gpio_free(GPIO_PWR_MON_RESET_N);
4731
4732 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4733 gpio_free(GPIO_EPM_SPI_ADC1_CS_N);
4734
4735 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4736 gpio_free(GPIO_EPM_SPI_ADC2_CS_N);
4737
4738 gpio_set_value_cansleep(GPIO_PWR_MON_START, 0);
4739 gpio_free(GPIO_PWR_MON_START);
4740
4741 gpio_direction_output(GPIO_ADC1_PWDN_N, 0);
4742 gpio_free(GPIO_ADC1_PWDN_N);
4743
4744 gpio_direction_output(GPIO_ADC2_PWDN_N, 0);
4745 gpio_free(GPIO_ADC2_PWDN_N);
4746
4747 gpio_set_value_cansleep(GPIO_PWR_MON_ENABLE, 0);
4748 gpio_free(GPIO_PWR_MON_ENABLE);
4749
4750 gpio_set_value_cansleep(GPIO_EPM_LVLSFT_EN, 0);
4751 gpio_free(GPIO_EPM_LVLSFT_EN);
4752
4753 gpio_set_value_cansleep(GPIO_EPM_5V_BOOST_EN, 0);
4754 gpio_free(GPIO_EPM_5V_BOOST_EN);
4755
4756 gpio_set_value_cansleep(GPIO_EPM_3_3V_EN, 0);
4757 gpio_free(GPIO_EPM_3_3V_EN);
4758
4759 rc = regulator_disable(vreg_adc_epm1);
4760 if (rc)
4761 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_disable: "
4762 "Error while enabling regulator for epm s3 %d\n", rc);
4763 regulator_put(vreg_adc_epm1);
4764
4765 printk(KERN_DEBUG "Exi msm_adc_gpio_configure_expander_disable\n");
4766 return rc;
4767};
4768
4769unsigned int msm_adc_gpio_expander_enable(int cs_enable)
4770{
4771 int rc = 0;
4772
4773 printk(KERN_DEBUG "msm_adc_gpio_expander_enable: cs_enable = %d",
4774 cs_enable);
4775
4776 if (cs_enable < 16) {
4777 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4778 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4779 } else {
4780 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4781 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4782 }
4783 return rc;
4784};
4785
4786unsigned int msm_adc_gpio_expander_disable(int cs_disable)
4787{
4788 int rc = 0;
4789
4790 printk(KERN_DEBUG "Enter msm_adc_gpio_expander_disable.\n");
4791
4792 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4793
4794 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4795
4796 return rc;
4797};
4798#endif
4799
4800static struct msm_adc_channels msm_adc_channels_data[] = {
4801 {"vbatt", CHANNEL_ADC_VBATT, 0, &xoadc_fn, CHAN_PATH_TYPE2,
4802 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4803 {"vcoin", CHANNEL_ADC_VCOIN, 0, &xoadc_fn, CHAN_PATH_TYPE1,
4804 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4805 {"vcharger_channel", CHANNEL_ADC_VCHG, 0, &xoadc_fn, CHAN_PATH_TYPE3,
4806 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE4, scale_default},
4807 {"charger_current_monitor", CHANNEL_ADC_CHG_MONITOR, 0, &xoadc_fn,
4808 CHAN_PATH_TYPE4,
4809 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4810 {"vph_pwr", CHANNEL_ADC_VPH_PWR, 0, &xoadc_fn, CHAN_PATH_TYPE5,
4811 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4812 {"usb_vbus", CHANNEL_ADC_USB_VBUS, 0, &xoadc_fn, CHAN_PATH_TYPE11,
4813 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4814 {"pmic_therm", CHANNEL_ADC_DIE_TEMP, 0, &xoadc_fn, CHAN_PATH_TYPE12,
4815 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_pmic_therm},
4816 {"pmic_therm_4K", CHANNEL_ADC_DIE_TEMP_4K, 0, &xoadc_fn,
4817 CHAN_PATH_TYPE12,
4818 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE7, scale_pmic_therm},
4819 {"xo_therm", CHANNEL_ADC_XOTHERM, 0, &xoadc_fn, CHAN_PATH_TYPE_NONE,
4820 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE5, tdkntcgtherm},
4821 {"xo_therm_4K", CHANNEL_ADC_XOTHERM_4K, 0, &xoadc_fn,
4822 CHAN_PATH_TYPE_NONE,
4823 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE6, tdkntcgtherm},
4824 {"hdset_detect", CHANNEL_ADC_HDSET, 0, &xoadc_fn, CHAN_PATH_TYPE6,
4825 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4826 {"chg_batt_amon", CHANNEL_ADC_BATT_AMON, 0, &xoadc_fn, CHAN_PATH_TYPE10,
4827 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1,
4828 scale_xtern_chgr_cur},
4829 {"msm_therm", CHANNEL_ADC_MSM_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE8,
4830 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_msm_therm},
4831 {"batt_therm", CHANNEL_ADC_BATT_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE7,
4832 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_batt_therm},
4833 {"batt_id", CHANNEL_ADC_BATT_ID, 0, &xoadc_fn, CHAN_PATH_TYPE9,
4834 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4835 {"ref_625mv", CHANNEL_ADC_625_REF, 0, &xoadc_fn, CHAN_PATH_TYPE15,
4836 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4837 {"ref_1250mv", CHANNEL_ADC_1250_REF, 0, &xoadc_fn, CHAN_PATH_TYPE13,
4838 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4839 {"ref_325mv", CHANNEL_ADC_325_REF, 0, &xoadc_fn, CHAN_PATH_TYPE14,
4840 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4841};
4842
4843static char *msm_adc_fluid_device_names[] = {
4844 "ADS_ADC1",
4845 "ADS_ADC2",
4846};
4847
4848static struct msm_adc_platform_data msm_adc_pdata = {
4849 .channel = msm_adc_channels_data,
4850 .num_chan_supported = ARRAY_SIZE(msm_adc_channels_data),
4851#if defined(CONFIG_I2C) && \
4852 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4853 .adc_gpio_enable = msm_adc_gpio_expander_enable,
4854 .adc_gpio_disable = msm_adc_gpio_expander_disable,
4855 .adc_fluid_enable = msm_adc_gpio_configure_expander_enable,
4856 .adc_fluid_disable = msm_adc_gpio_configure_expander_disable,
4857#endif
4858};
4859
4860static struct platform_device msm_adc_device = {
4861 .name = "msm_adc",
4862 .id = -1,
4863 .dev = {
4864 .platform_data = &msm_adc_pdata,
4865 },
4866};
4867
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05304868static struct msm_rtb_platform_data msm_rtb_pdata = {
4869 .size = SZ_1M,
4870};
4871
4872static int __init msm_rtb_set_buffer_size(char *p)
4873{
4874 int s;
4875
4876 s = memparse(p, NULL);
4877 msm_rtb_pdata.size = ALIGN(s, SZ_4K);
4878 return 0;
4879}
4880early_param("msm_rtb_size", msm_rtb_set_buffer_size);
4881
4882
4883static struct platform_device msm_rtb_device = {
4884 .name = "msm_rtb",
4885 .id = -1,
4886 .dev = {
4887 .platform_data = &msm_rtb_pdata,
4888 },
4889};
4890
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004891static void pmic8058_xoadc_mpp_config(void)
4892{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304893 int rc, i;
4894 struct pm8xxx_mpp_init_info xoadc_mpps[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304895 PM8058_MPP_INIT(XOADC_MPP_3, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304896 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304897 PM8058_MPP_INIT(XOADC_MPP_5, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH9,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304898 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304899 PM8058_MPP_INIT(XOADC_MPP_7, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH6,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304900 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304901 PM8058_MPP_INIT(XOADC_MPP_8, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304902 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304903 PM8058_MPP_INIT(XOADC_MPP_10, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH7,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304904 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304905 PM8901_MPP_INIT(XOADC_MPP_4, D_OUTPUT, PM8901_MPP_DIG_LEVEL_S4,
4906 DOUT_CTRL_LOW),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304907 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004908
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304909 for (i = 0; i < ARRAY_SIZE(xoadc_mpps); i++) {
4910 rc = pm8xxx_mpp_config(xoadc_mpps[i].mpp,
4911 &xoadc_mpps[i].config);
4912 if (rc) {
4913 pr_err("%s: Config MPP %d of PM8058 failed\n",
4914 __func__, xoadc_mpps[i].mpp);
4915 }
4916 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004917}
4918
4919static struct regulator *vreg_ldo18_adc;
4920
4921static int pmic8058_xoadc_vreg_config(int on)
4922{
4923 int rc;
4924
4925 if (on) {
4926 rc = regulator_enable(vreg_ldo18_adc);
4927 if (rc)
4928 pr_err("%s: Enable of regulator ldo18_adc "
4929 "failed\n", __func__);
4930 } else {
4931 rc = regulator_disable(vreg_ldo18_adc);
4932 if (rc)
4933 pr_err("%s: Disable of regulator ldo18_adc "
4934 "failed\n", __func__);
4935 }
4936
4937 return rc;
4938}
4939
4940static int pmic8058_xoadc_vreg_setup(void)
4941{
4942 int rc;
4943
4944 vreg_ldo18_adc = regulator_get(NULL, "8058_l18");
4945 if (IS_ERR(vreg_ldo18_adc)) {
4946 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
4947 __func__, PTR_ERR(vreg_ldo18_adc));
4948 rc = PTR_ERR(vreg_ldo18_adc);
4949 goto fail;
4950 }
4951
4952 rc = regulator_set_voltage(vreg_ldo18_adc, 2200000, 2200000);
4953 if (rc) {
4954 pr_err("%s: unable to set ldo18 voltage to 2.2V\n", __func__);
4955 goto fail;
4956 }
4957
4958 return rc;
4959fail:
4960 regulator_put(vreg_ldo18_adc);
4961 return rc;
4962}
4963
4964static void pmic8058_xoadc_vreg_shutdown(void)
4965{
4966 regulator_put(vreg_ldo18_adc);
4967}
4968
4969/* usec. For this ADC,
4970 * this time represents clk rate @ txco w/ 1024 decimation ratio.
4971 * Each channel has different configuration, thus at the time of starting
4972 * the conversion, xoadc will return actual conversion time
4973 * */
4974static struct adc_properties pm8058_xoadc_data = {
4975 .adc_reference = 2200, /* milli-voltage for this adc */
4976 .bitresolution = 15,
4977 .bipolar = 0,
4978 .conversiontime = 54,
4979};
4980
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304981static struct xoadc_platform_data pm8058_xoadc_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004982 .xoadc_prop = &pm8058_xoadc_data,
4983 .xoadc_mpp_config = pmic8058_xoadc_mpp_config,
4984 .xoadc_vreg_set = pmic8058_xoadc_vreg_config,
4985 .xoadc_num = XOADC_PMIC_0,
4986 .xoadc_vreg_setup = pmic8058_xoadc_vreg_setup,
4987 .xoadc_vreg_shutdown = pmic8058_xoadc_vreg_shutdown,
4988};
4989#endif
4990
4991#ifdef CONFIG_MSM_SDIO_AL
4992
4993static unsigned mdm2ap_status = 140;
4994
4995static int configure_mdm2ap_status(int on)
4996{
4997 int ret = 0;
4998 if (on)
4999 ret = msm_gpiomux_get(mdm2ap_status);
5000 else
5001 ret = msm_gpiomux_put(mdm2ap_status);
5002
5003 if (ret)
5004 pr_err("%s: mdm2ap_status config failed, on = %d\n", __func__,
5005 on);
5006
5007 return ret;
5008}
5009
5010
5011static int get_mdm2ap_status(void)
5012{
5013 return gpio_get_value(mdm2ap_status);
5014}
5015
5016static struct sdio_al_platform_data sdio_al_pdata = {
5017 .config_mdm2ap_status = configure_mdm2ap_status,
5018 .get_mdm2ap_status = get_mdm2ap_status,
5019 .allow_sdioc_version_major_2 = 0,
Konstantin Dorfmanee2e3082011-08-16 15:12:01 +03005020 .peer_sdioc_version_minor = 0x0202,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005021 .peer_sdioc_version_major = 0x0004,
5022 .peer_sdioc_boot_version_minor = 0x0001,
5023 .peer_sdioc_boot_version_major = 0x0003
5024};
5025
5026struct platform_device msm_device_sdio_al = {
5027 .name = "msm_sdio_al",
5028 .id = -1,
5029 .dev = {
Maya Erez6862b142011-08-22 09:07:07 +03005030 .parent = &msm_charm_modem.dev,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005031 .platform_data = &sdio_al_pdata,
5032 },
5033};
5034
5035#endif /* CONFIG_MSM_SDIO_AL */
5036
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305037#define GPIO_VREG_ID_EXT_5V 0
5038
5039static struct regulator_consumer_supply vreg_consumers_EXT_5V[] = {
5040 REGULATOR_SUPPLY("ext_5v", NULL),
5041 REGULATOR_SUPPLY("8901_mpp0", NULL),
5042};
5043
5044#define GPIO_VREG_INIT(_id, _reg_name, _gpio_label, _gpio, _active_low) \
5045 [GPIO_VREG_ID_##_id] = { \
5046 .init_data = { \
5047 .constraints = { \
5048 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
5049 }, \
5050 .num_consumer_supplies = \
5051 ARRAY_SIZE(vreg_consumers_##_id), \
5052 .consumer_supplies = vreg_consumers_##_id, \
5053 }, \
5054 .regulator_name = _reg_name, \
5055 .active_low = _active_low, \
5056 .gpio_label = _gpio_label, \
5057 .gpio = _gpio, \
5058 }
5059
5060/* GPIO regulator constraints */
5061static struct gpio_regulator_platform_data msm_gpio_regulator_pdata[] = {
5062 GPIO_VREG_INIT(EXT_5V, "ext_5v", "ext_5v_en",
5063 PM8901_MPP_PM_TO_SYS(0), 0),
5064};
5065
5066/* GPIO regulator */
5067static struct platform_device msm8x60_8901_mpp_vreg __devinitdata = {
5068 .name = GPIO_REGULATOR_DEV_NAME,
5069 .id = PM8901_MPP_PM_TO_SYS(0),
5070 .dev = {
5071 .platform_data =
5072 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
5073 },
5074};
5075
5076static void __init pm8901_vreg_mpp0_init(void)
5077{
5078 int rc;
5079
5080 struct pm8xxx_mpp_init_info pm8901_vreg_mpp0 = {
5081 .mpp = PM8901_MPP_PM_TO_SYS(0),
5082 .config = {
5083 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
5084 .level = PM8901_MPP_DIG_LEVEL_VPH,
5085 },
5086 };
5087
5088 /*
5089 * Set PMIC 8901 MPP0 active_high to 0 for surf and charm_surf. This
5090 * implies that the regulator connected to MPP0 is enabled when
5091 * MPP0 is low.
5092 */
5093 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion()) {
5094 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 1;
5095 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
5096 } else {
5097 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 0;
5098 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_LOW;
5099 }
5100
5101 rc = pm8xxx_mpp_config(pm8901_vreg_mpp0.mpp, &pm8901_vreg_mpp0.config);
5102 if (rc)
5103 pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc);
5104}
5105
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005106static struct platform_device *charm_devices[] __initdata = {
5107 &msm_charm_modem,
5108#ifdef CONFIG_MSM_SDIO_AL
5109 &msm_device_sdio_al,
5110#endif
5111};
5112
Lei Zhou338cab82011-08-19 13:38:17 -04005113#ifdef CONFIG_SND_SOC_MSM8660_APQ
5114static struct platform_device *dragon_alsa_devices[] __initdata = {
5115 &msm_pcm,
5116 &msm_pcm_routing,
5117 &msm_cpudai0,
5118 &msm_cpudai1,
5119 &msm_cpudai_hdmi_rx,
5120 &msm_cpudai_bt_rx,
5121 &msm_cpudai_bt_tx,
5122 &msm_cpudai_fm_rx,
5123 &msm_cpudai_fm_tx,
5124 &msm_cpu_fe,
5125 &msm_stub_codec,
5126 &msm_lpa_pcm,
5127};
5128#endif
5129
5130static struct platform_device *asoc_devices[] __initdata = {
5131 &asoc_msm_pcm,
5132 &asoc_msm_dai0,
5133 &asoc_msm_dai1,
5134};
5135
Riaz Rahaman0bd72172012-06-26 18:42:36 +05305136/* qseecom bus scaling */
5137static struct msm_bus_vectors qseecom_clks_init_vectors[] = {
5138 {
5139 .src = MSM_BUS_MASTER_SPS,
5140 .dst = MSM_BUS_SLAVE_EBI_CH0,
5141 .ib = 0,
5142 .ab = 0,
5143 },
5144 {
5145 .src = MSM_BUS_MASTER_SPDM,
5146 .dst = MSM_BUS_SLAVE_SPDM,
5147 .ib = 0,
5148 .ab = 0,
5149 },
5150};
5151
5152static struct msm_bus_vectors qseecom_enable_dfab_vectors[] = {
5153 {
5154 .src = MSM_BUS_MASTER_SPS,
5155 .dst = MSM_BUS_SLAVE_EBI_CH0,
5156 .ib = (492 * 8) * 1000000UL,
5157 .ab = (492 * 8) * 100000UL,
5158 },
5159 {
5160 .src = MSM_BUS_MASTER_SPDM,
5161 .dst = MSM_BUS_SLAVE_SPDM,
5162 .ib = 0,
5163 .ab = 0,
5164 },
5165};
5166
5167static struct msm_bus_vectors qseecom_enable_sfpb_vectors[] = {
5168 {
5169 .src = MSM_BUS_MASTER_SPS,
5170 .dst = MSM_BUS_SLAVE_EBI_CH0,
5171 .ib = 0,
5172 .ab = 0,
5173 },
5174 {
5175 .src = MSM_BUS_MASTER_SPDM,
5176 .dst = MSM_BUS_SLAVE_SPDM,
5177 .ib = (64 * 8) * 1000000UL,
5178 .ab = (64 * 8) * 100000UL,
5179 },
5180};
5181
5182static struct msm_bus_paths qseecom_hw_bus_scale_usecases[] = {
5183 {
5184 ARRAY_SIZE(qseecom_clks_init_vectors),
5185 qseecom_clks_init_vectors,
5186 },
5187 {
5188 ARRAY_SIZE(qseecom_enable_dfab_vectors),
5189 qseecom_enable_sfpb_vectors,
5190 },
5191 {
5192 ARRAY_SIZE(qseecom_enable_sfpb_vectors),
5193 qseecom_enable_sfpb_vectors,
5194 },
5195};
5196
5197static struct msm_bus_scale_pdata qseecom_bus_pdata = {
5198 .usecase = qseecom_hw_bus_scale_usecases,
5199 .num_usecases = ARRAY_SIZE(qseecom_hw_bus_scale_usecases),
5200 .name = "qsee",
5201};
5202
5203static struct platform_device qseecom_device = {
5204 .name = "qseecom",
5205 .id = -1,
5206 .dev = {
5207 .platform_data = &qseecom_bus_pdata,
5208 },
5209};
5210
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005211static struct platform_device *surf_devices[] __initdata = {
Matt Wagantallbf430eb2012-03-22 11:45:49 -07005212 &msm8x60_device_acpuclk,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005213 &msm_device_smd,
5214 &msm_device_uart_dm12,
Stephen Boyd3acc9e42011-09-28 16:46:40 -07005215 &msm_pil_q6v3,
Stephen Boyd4eb885b2011-09-29 01:16:03 -07005216 &msm_pil_modem,
Stephen Boydd89eebe2011-09-28 23:28:11 -07005217 &msm_pil_tzapps,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07005218 &msm_pil_dsps,
Riaz Rahamandd18ebf2012-06-27 16:06:34 +05305219 &msm_pil_vidc,
Riaz Rahaman0bd72172012-06-26 18:42:36 +05305220 &qseecom_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005221#ifdef CONFIG_I2C_QUP
5222 &msm_gsbi3_qup_i2c_device,
5223 &msm_gsbi4_qup_i2c_device,
5224 &msm_gsbi7_qup_i2c_device,
5225 &msm_gsbi8_qup_i2c_device,
5226 &msm_gsbi9_qup_i2c_device,
5227 &msm_gsbi12_qup_i2c_device,
5228#endif
5229#ifdef CONFIG_SERIAL_MSM_HS
5230 &msm_device_uart_dm1,
5231#endif
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305232#ifdef CONFIG_MSM_SSBI
5233 &msm_device_ssbi_pmic1,
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05305234 &msm_device_ssbi_pmic2,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305235#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005236#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005237 &msm_device_ssbi3,
5238#endif
5239#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
5240 &isp1763_device,
5241#endif
5242
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005243#if defined (CONFIG_MSM_8x60_VOIP)
5244 &asoc_msm_mvs,
5245 &asoc_mvs_dai0,
5246 &asoc_mvs_dai1,
5247#endif
Lei Zhou338cab82011-08-19 13:38:17 -04005248
Lena Salman57d167e2012-03-21 19:46:38 +02005249#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005250 &msm_device_otg,
5251#endif
Lena Salman57d167e2012-03-21 19:46:38 +02005252#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005253 &msm_device_gadget_peripheral,
5254#endif
5255#ifdef CONFIG_USB_G_ANDROID
5256 &android_usb_device,
5257#endif
5258#ifdef CONFIG_BATTERY_MSM
5259 &msm_batt_device,
5260#endif
5261#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005262#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005263 &android_pmem_device,
5264 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005265 &android_pmem_smipool_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005266 &android_pmem_audio_device,
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305267#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5268#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005269#ifdef CONFIG_MSM_ROTATOR
5270 &msm_rotator_device,
5271#endif
5272 &msm_fb_device,
5273 &msm_kgsl_3d0,
5274 &msm_kgsl_2d0,
5275 &msm_kgsl_2d1,
5276 &lcdc_samsung_panel_device,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005277#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5278 &lcdc_nt35582_panel_device,
5279#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005280#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
5281 &lcdc_samsung_oled_panel_device,
5282#endif
5283#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
5284 &lcdc_auo_wvga_panel_device,
5285#endif
5286#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
5287 &hdmi_msm_device,
5288#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
5289#ifdef CONFIG_FB_MSM_MIPI_DSI
5290 &mipi_dsi_toshiba_panel_device,
5291 &mipi_dsi_novatek_panel_device,
5292#endif
5293#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07005294#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005295#ifdef CONFIG_MT9E013
5296 &msm_camera_sensor_mt9e013,
5297#endif
5298#ifdef CONFIG_IMX074
5299 &msm_camera_sensor_imx074,
5300#endif
5301#ifdef CONFIG_WEBCAM_OV7692
5302 &msm_camera_sensor_webcam_ov7692,
5303#endif
5304#ifdef CONFIG_WEBCAM_OV9726
5305 &msm_camera_sensor_webcam_ov9726,
5306#endif
5307#ifdef CONFIG_QS_S5K4E1
5308 &msm_camera_sensor_qs_s5k4e1,
5309#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04005310#ifdef CONFIG_VX6953
5311 &msm_camera_sensor_vx6953,
5312#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005313#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005314#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005315#ifdef CONFIG_MSM_GEMINI
5316 &msm_gemini_device,
5317#endif
5318#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07005319#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005320 &msm_vpe_device,
5321#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005322#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005323
5324#if defined(CONFIG_MSM_RPM_LOG) || defined(CONFIG_MSM_RPM_LOG_MODULE)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005325 &msm8660_rpm_log_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005326#endif
5327#if defined(CONFIG_MSM_RPM_STATS_LOG)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005328 &msm8660_rpm_stat_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005329#endif
5330 &msm_device_vidc,
5331#if (defined(CONFIG_MARIMBA_CORE)) && \
5332 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5333 &msm_bt_power_device,
5334#endif
5335#ifdef CONFIG_SENSORS_MSM_ADC
5336 &msm_adc_device,
5337#endif
David Collins6f032ba2011-08-31 14:08:15 -07005338 &rpm_regulator_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005339
5340#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5341 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5342 &qcrypto_device,
5343#endif
5344
5345#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5346 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5347 &qcedev_device,
5348#endif
5349
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005350
5351#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5352#ifdef CONFIG_MSM_USE_TSIF1
5353 &msm_device_tsif[1],
5354#else
5355 &msm_device_tsif[0],
5356#endif /* CONFIG_MSM_USE_TSIF1 */
5357#endif /* CONFIG_TSIF */
5358
5359#ifdef CONFIG_HW_RANDOM_MSM
5360 &msm_device_rng,
5361#endif
5362
5363 &msm_tsens_device,
Praveen Chidambaram78499012011-11-01 17:15:17 -06005364 &msm8660_rpm_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005365#ifdef CONFIG_ION_MSM
5366 &ion_dev,
5367#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -07005368 &msm8660_device_watchdog,
Mona Hossainceca6152012-04-10 09:55:41 -07005369 &msm_device_tz_log,
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305370 &msm_rtb_device,
Laura Abbottd92be422012-06-04 15:11:09 -07005371 &msm8660_iommu_domain_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005372};
5373
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005374#ifdef CONFIG_ION_MSM
Olav Haugan0703dbf2011-12-19 17:53:38 -08005375#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5376static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
5377 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugan8726caf2012-05-10 15:11:35 -07005378 .align = SZ_64K,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005379 .request_region = request_smi_region,
5380 .release_region = release_smi_region,
5381 .setup_region = setup_smi_region,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305382 .secure_base = MSM_ION_HOLE_BASE,
5383 .secure_size = MSM_ION_HOLE_SIZE + MSM_ION_MM_SIZE,
Olav Haugan8726caf2012-05-10 15:11:35 -07005384 .iommu_map_all = 1,
5385 .iommu_2x_map_domain = VIDEO_DOMAIN,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005386};
5387
5388static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
5389 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugan42ebe712012-01-10 16:30:58 -08005390 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005391 .request_region = request_smi_region,
5392 .release_region = release_smi_region,
5393 .setup_region = setup_smi_region,
5394};
5395
5396static struct ion_cp_heap_pdata cp_wb_ion_pdata = {
5397 .permission_type = IPT_TYPE_MDP_WRITEBACK,
Olav Haugan42ebe712012-01-10 16:30:58 -08005398 .align = PAGE_SIZE,
5399};
5400
Chintan Pandya7c2b9cb2012-06-25 14:35:02 +05305401static struct ion_co_heap_pdata mm_fw_co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005402 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005403};
5404
5405static struct ion_co_heap_pdata co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005406 .adjacent_mem_id = INVALID_HEAP_ID,
5407 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005408};
5409#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005410
5411/**
5412 * These heaps are listed in the order they will be allocated. Due to
5413 * video hardware restrictions and content protection the FW heap has to
5414 * be allocated adjacent (below) the MM heap and the MFC heap has to be
5415 * allocated after the MM heap to ensure MFC heap is not more than 256MB
5416 * away from the base address of the FW heap.
5417 * However, the order of FW heap and MM heap doesn't matter since these
5418 * two heaps are taken care of by separate code to ensure they are adjacent
5419 * to each other.
5420 * Don't swap the order unless you know what you are doing!
5421 */
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005422static struct ion_platform_data ion_pdata = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005423 .nr = MSM_ION_HEAP_NUM,
5424 .heaps = {
5425 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005426 .id = ION_SYSTEM_HEAP_ID,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005427 .type = ION_HEAP_TYPE_SYSTEM,
5428 .name = ION_VMALLOC_HEAP_NAME,
5429 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005430#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5431 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005432 .id = ION_CP_MM_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005433 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005434 .name = ION_MM_HEAP_NAME,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305435 .base = MSM_ION_MM_BASE,
Olav Hauganb5be7992011-11-18 14:29:02 -08005436 .size = MSM_ION_MM_SIZE,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005437 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005438 .extra_data = (void *) &cp_mm_ion_pdata,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005439 },
Olav Hauganb5be7992011-11-18 14:29:02 -08005440 {
Olav Haugan42ebe712012-01-10 16:30:58 -08005441 .id = ION_MM_FIRMWARE_HEAP_ID,
5442 .type = ION_HEAP_TYPE_CARVEOUT,
5443 .name = ION_MM_FIRMWARE_HEAP_NAME,
Chintan Pandya7c2b9cb2012-06-25 14:35:02 +05305444 .base = MSM_MM_FW_BASE,
5445 .size = MSM_MM_FW_SIZE,
Olav Haugan42ebe712012-01-10 16:30:58 -08005446 .memory_type = ION_SMI_TYPE,
Chintan Pandya7c2b9cb2012-06-25 14:35:02 +05305447 .extra_data = (void *) &mm_fw_co_ion_pdata,
Olav Haugan42ebe712012-01-10 16:30:58 -08005448 },
5449 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005450 .id = ION_CP_MFC_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005451 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005452 .name = ION_MFC_HEAP_NAME,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305453 .base = MSM_ION_MFC_BASE,
Olav Hauganb5be7992011-11-18 14:29:02 -08005454 .size = MSM_ION_MFC_SIZE,
5455 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005456 .extra_data = (void *) &cp_mfc_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005457 },
5458 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005459 .id = ION_SF_HEAP_ID,
5460 .type = ION_HEAP_TYPE_CARVEOUT,
5461 .name = ION_SF_HEAP_NAME,
5462 .size = MSM_ION_SF_SIZE,
5463 .memory_type = ION_EBI_TYPE,
5464 .extra_data = (void *)&co_ion_pdata,
5465 },
5466 {
5467 .id = ION_CAMERA_HEAP_ID,
5468 .type = ION_HEAP_TYPE_CARVEOUT,
5469 .name = ION_CAMERA_HEAP_NAME,
5470 .size = MSM_ION_CAMERA_SIZE,
5471 .memory_type = ION_EBI_TYPE,
5472 .extra_data = &co_ion_pdata,
5473 },
5474 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005475 .id = ION_CP_WB_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005476 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005477 .name = ION_WB_HEAP_NAME,
5478 .size = MSM_ION_WB_SIZE,
5479 .memory_type = ION_EBI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005480 .extra_data = (void *) &cp_wb_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005481 },
Olav Haugan3a55e322012-01-23 14:24:01 -08005482 {
Olav Haugan6ab47252012-02-15 14:46:49 -08005483 .id = ION_QSECOM_HEAP_ID,
5484 .type = ION_HEAP_TYPE_CARVEOUT,
5485 .name = ION_QSECOM_HEAP_NAME,
5486 .size = MSM_ION_QSECOM_SIZE,
5487 .memory_type = ION_EBI_TYPE,
5488 .extra_data = (void *) &co_ion_pdata,
5489 },
5490 {
Olav Haugan3a55e322012-01-23 14:24:01 -08005491 .id = ION_AUDIO_HEAP_ID,
5492 .type = ION_HEAP_TYPE_CARVEOUT,
5493 .name = ION_AUDIO_HEAP_NAME,
5494 .size = MSM_ION_AUDIO_SIZE,
5495 .memory_type = ION_EBI_TYPE,
5496 .extra_data = (void *)&co_ion_pdata,
5497 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005498#endif
5499 }
5500};
5501
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005502static struct platform_device ion_dev = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005503 .name = "ion-msm",
5504 .id = 1,
5505 .dev = { .platform_data = &ion_pdata },
5506};
5507#endif
5508
5509
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005510static struct memtype_reserve msm8x60_reserve_table[] __initdata = {
5511 /* Kernel SMI memory pool for video core, used for firmware */
5512 /* and encoder, decoder scratch buffers */
5513 /* Kernel SMI memory pool should always precede the user space */
5514 /* SMI memory pool, as the video core will use offset address */
5515 /* from the Firmware base */
5516 [MEMTYPE_SMI_KERNEL] = {
5517 .start = KERNEL_SMI_BASE,
5518 .limit = KERNEL_SMI_SIZE,
5519 .size = KERNEL_SMI_SIZE,
5520 .flags = MEMTYPE_FLAGS_FIXED,
5521 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005522 [MEMTYPE_SMI] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005523 },
5524 [MEMTYPE_EBI0] = {
5525 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5526 },
5527 [MEMTYPE_EBI1] = {
5528 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5529 },
5530};
5531
Stephen Boyd668d7652012-04-25 11:31:01 -07005532static void __init reserve_ion_memory(void)
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005533{
5534#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005535 unsigned int i;
5536
5537 if (hdmi_is_primary) {
5538 msm_ion_sf_size = MSM_HDMI_PRIM_ION_SF_SIZE;
5539 for (i = 0; i < ion_pdata.nr; i++) {
5540 if (ion_pdata.heaps[i].id == ION_SF_HEAP_ID) {
5541 ion_pdata.heaps[i].size = msm_ion_sf_size;
5542 pr_debug("msm_ion_sf_size 0x%x\n",
5543 msm_ion_sf_size);
5544 break;
5545 }
5546 }
5547 }
5548
Olav Haugan8726caf2012-05-10 15:11:35 -07005549 /* Verify size of heap is a multiple of 64K */
5550 for (i = 0; i < ion_pdata.nr; i++) {
5551 struct ion_platform_heap *heap = &(ion_pdata.heaps[i]);
5552
5553 if (heap->extra_data && heap->type == ION_HEAP_TYPE_CP) {
5554 int map_all = ((struct ion_cp_heap_pdata *)
5555 heap->extra_data)->iommu_map_all;
5556
5557 if (map_all && (heap->size & (SZ_64K-1))) {
5558 heap->size = ALIGN(heap->size, SZ_64K);
5559 pr_err("Heap %s size is not a multiple of 64K. Adjusting size to %x\n",
5560 heap->name, heap->size);
5561
5562 }
5563 }
5564 }
5565
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005566 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_ion_sf_size;
Olav Hauganb5be7992011-11-18 14:29:02 -08005567 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_CAMERA_SIZE;
5568 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_WB_SIZE;
Olav Haugan3a55e322012-01-23 14:24:01 -08005569 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE;
Olav Haugan8d8c2d12012-04-02 12:01:44 -07005570 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_QSECOM_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005571#endif
5572}
5573
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005574static void __init size_pmem_devices(void)
5575{
5576#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005577#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005578 android_pmem_adsp_pdata.size = pmem_adsp_size;
5579 android_pmem_smipool_pdata.size = MSM_PMEM_SMIPOOL_SIZE;
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005580
5581 if (hdmi_is_primary)
5582 pmem_sf_size = MSM_HDMI_PRIM_PMEM_SF_SIZE;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005583 android_pmem_pdata.size = pmem_sf_size;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005584 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305585#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5586#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005587}
5588
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305589#ifdef CONFIG_ANDROID_PMEM
5590#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005591static void __init reserve_memory_for(struct android_pmem_platform_data *p)
5592{
5593 msm8x60_reserve_table[p->memory_type].size += p->size;
5594}
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305595#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5596#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005597
5598static void __init reserve_pmem_memory(void)
5599{
5600#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005601#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005602 reserve_memory_for(&android_pmem_adsp_pdata);
5603 reserve_memory_for(&android_pmem_smipool_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005604 reserve_memory_for(&android_pmem_pdata);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005605 reserve_memory_for(&android_pmem_audio_pdata);
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305606#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005607 msm8x60_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305608#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005609}
5610
Huaibin Yanga5419422011-12-08 23:52:10 -08005611static void __init reserve_mdp_memory(void);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005612
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305613static void __init reserve_rtb_memory(void)
5614{
5615#if defined(CONFIG_MSM_RTB)
5616 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_rtb_pdata.size;
5617#endif
5618}
5619
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005620static void __init msm8x60_calculate_reserve_sizes(void)
5621{
5622 size_pmem_devices();
5623 reserve_pmem_memory();
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005624 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -08005625 reserve_mdp_memory();
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305626 reserve_rtb_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005627}
5628
5629static int msm8x60_paddr_to_memtype(unsigned int paddr)
5630{
5631 if (paddr >= 0x40000000 && paddr < 0x60000000)
5632 return MEMTYPE_EBI1;
5633 if (paddr >= 0x38000000 && paddr < 0x40000000)
5634 return MEMTYPE_SMI;
5635 return MEMTYPE_NONE;
5636}
5637
5638static struct reserve_info msm8x60_reserve_info __initdata = {
5639 .memtype_reserve_table = msm8x60_reserve_table,
5640 .calculate_reserve_sizes = msm8x60_calculate_reserve_sizes,
5641 .paddr_to_memtype = msm8x60_paddr_to_memtype,
5642};
5643
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005644static char prim_panel_name[PANEL_NAME_MAX_LEN];
5645static char ext_panel_name[PANEL_NAME_MAX_LEN];
5646static int __init prim_display_setup(char *param)
5647{
5648 if (strnlen(param, PANEL_NAME_MAX_LEN))
5649 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
5650 return 0;
5651}
5652early_param("prim_display", prim_display_setup);
5653
5654static int __init ext_display_setup(char *param)
5655{
5656 if (strnlen(param, PANEL_NAME_MAX_LEN))
5657 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
5658 return 0;
5659}
5660early_param("ext_display", ext_display_setup);
5661
Stephen Boyd9e775ad2011-08-12 00:14:28 +01005662static void __init msm8x60_reserve(void)
5663{
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005664 msm8x60_set_display_params(prim_panel_name, ext_panel_name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005665 reserve_info = &msm8x60_reserve_info;
5666 msm_reserve();
5667}
5668
5669#define EXT_CHG_VALID_MPP 10
5670#define EXT_CHG_VALID_MPP_2 11
5671
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305672static struct pm8xxx_mpp_init_info isl_mpp[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305673 PM8058_MPP_INIT(EXT_CHG_VALID_MPP, D_INPUT,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305674 PM8058_MPP_DIG_LEVEL_S3, DIN_TO_INT),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305675 PM8058_MPP_INIT(EXT_CHG_VALID_MPP_2, D_BI_DIR,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305676 PM8058_MPP_DIG_LEVEL_S3, BI_PULLUP_10KOHM),
5677};
5678
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005679#ifdef CONFIG_ISL9519_CHARGER
5680static int isl_detection_setup(void)
5681{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305682 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005683
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305684 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5685 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5686 &isl_mpp[i].config);
5687 if (ret) {
5688 pr_err("%s: Config MPP %d of PM8058 failed\n",
5689 __func__, isl_mpp[i].mpp);
5690 return ret;
5691 }
5692 }
5693
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005694 return ret;
5695}
5696
5697static struct isl_platform_data isl_data __initdata = {
5698 .chgcurrent = 700,
5699 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5700 .chg_detection_config = isl_detection_setup,
5701 .max_system_voltage = 4200,
5702 .min_system_voltage = 3200,
5703 .term_current = 120,
5704 .input_current = 2048,
5705};
5706
5707static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
5708 {
5709 I2C_BOARD_INFO("isl9519q", 0x9),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305710 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005711 .platform_data = &isl_data,
5712 },
5713};
5714#endif
5715
5716#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
5717static int smb137b_detection_setup(void)
5718{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305719 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005720
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305721 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5722 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5723 &isl_mpp[i].config);
5724 if (ret) {
5725 pr_err("%s: Config MPP %d of PM8058 failed\n",
5726 __func__, isl_mpp[i].mpp);
5727 return ret;
5728 }
5729 }
5730
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005731 return ret;
5732}
5733
5734static struct smb137b_platform_data smb137b_data __initdata = {
5735 .chg_detection_config = smb137b_detection_setup,
5736 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5737 .batt_mah_rating = 950,
5738};
5739
5740static struct i2c_board_info smb137b_charger_i2c_info[] __initdata = {
5741 {
5742 I2C_BOARD_INFO("smb137b", 0x08),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305743 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005744 .platform_data = &smb137b_data,
5745 },
5746};
5747#endif
5748
5749#ifdef CONFIG_PMIC8058
5750#define PMIC_GPIO_SDC3_DET 22
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305751#define PMIC_GPIO_TOUCH_DISC_INTR 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005752
5753static int pm8058_gpios_init(void)
5754{
5755 int i;
5756 int rc;
5757 struct pm8058_gpio_cfg {
5758 int gpio;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305759 struct pm_gpio cfg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005760 };
5761
5762 struct pm8058_gpio_cfg gpio_cfgs[] = {
5763 { /* FFA ethernet */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305764 PM8058_GPIO_PM_TO_SYS(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005765 {
5766 .direction = PM_GPIO_DIR_IN,
5767 .pull = PM_GPIO_PULL_DN,
5768 .vin_sel = 2,
5769 .function = PM_GPIO_FUNC_NORMAL,
5770 .inv_int_pol = 0,
5771 },
5772 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005773 {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305774 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005775 {
5776 .direction = PM_GPIO_DIR_IN,
5777 .pull = PM_GPIO_PULL_UP_30,
5778 .vin_sel = 2,
5779 .function = PM_GPIO_FUNC_NORMAL,
5780 .inv_int_pol = 0,
5781 },
5782 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005783 { /* core&surf gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305784 PM8058_GPIO_PM_TO_SYS(UI_INT1_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005785 {
5786 .direction = PM_GPIO_DIR_IN,
5787 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305788 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005789 .function = PM_GPIO_FUNC_NORMAL,
5790 .inv_int_pol = 0,
5791 },
5792 },
5793 { /* docking gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305794 PM8058_GPIO_PM_TO_SYS(UI_INT2_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005795 {
5796 .direction = PM_GPIO_DIR_IN,
5797 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305798 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005799 .function = PM_GPIO_FUNC_NORMAL,
5800 .inv_int_pol = 0,
5801 },
5802 },
5803 { /* FHA/keypad gpio expanders */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305804 PM8058_GPIO_PM_TO_SYS(UI_INT3_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005805 {
5806 .direction = PM_GPIO_DIR_IN,
5807 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305808 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005809 .function = PM_GPIO_FUNC_NORMAL,
5810 .inv_int_pol = 0,
5811 },
5812 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005813 { /* Timpani Reset */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305814 PM8058_GPIO_PM_TO_SYS(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005815 {
5816 .direction = PM_GPIO_DIR_OUT,
5817 .output_value = 1,
5818 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5819 .pull = PM_GPIO_PULL_DN,
5820 .out_strength = PM_GPIO_STRENGTH_HIGH,
5821 .function = PM_GPIO_FUNC_NORMAL,
5822 .vin_sel = 2,
5823 .inv_int_pol = 0,
5824 }
5825 },
5826 { /* PMIC ID interrupt */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305827 PM8058_GPIO_PM_TO_SYS(36),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005828 {
5829 .direction = PM_GPIO_DIR_IN,
Anji jonnalaae745e92011-11-14 18:34:31 +05305830 .pull = PM_GPIO_PULL_NO,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005831 .function = PM_GPIO_FUNC_NORMAL,
5832 .vin_sel = 2,
5833 .inv_int_pol = 0,
5834 }
5835 },
5836 };
5837
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305838#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5839 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305840 struct pm_gpio touchdisc_intr_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305841 .direction = PM_GPIO_DIR_IN,
5842 .pull = PM_GPIO_PULL_UP_1P5,
5843 .vin_sel = 2,
5844 .function = PM_GPIO_FUNC_NORMAL,
5845 };
5846#endif
5847
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005848#if defined(CONFIG_HAPTIC_ISA1200) || \
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305849 defined(CONFIG_HAPTIC_ISA1200_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305850 struct pm_gpio en_hap_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305851 .direction = PM_GPIO_DIR_OUT,
5852 .pull = PM_GPIO_PULL_NO,
5853 .out_strength = PM_GPIO_STRENGTH_HIGH,
5854 .function = PM_GPIO_FUNC_NORMAL,
5855 .inv_int_pol = 0,
5856 .vin_sel = 2,
5857 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5858 .output_value = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005859 };
5860#endif
5861
5862#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5863 struct pm8058_gpio_cfg line_in_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305864 PM8058_GPIO_PM_TO_SYS(18),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005865 {
5866 .direction = PM_GPIO_DIR_IN,
5867 .pull = PM_GPIO_PULL_UP_1P5,
5868 .vin_sel = 2,
5869 .function = PM_GPIO_FUNC_NORMAL,
5870 .inv_int_pol = 0,
5871 }
5872 };
5873#endif
5874
5875#if defined(CONFIG_QS_S5K4E1)
5876 {
5877 struct pm8058_gpio_cfg qs_hc37_cam_pd_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305878 PM8058_GPIO_PM_TO_SYS(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005879 {
5880 .direction = PM_GPIO_DIR_OUT,
5881 .output_value = 0,
5882 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5883 .pull = PM_GPIO_PULL_DN,
5884 .out_strength = PM_GPIO_STRENGTH_HIGH,
5885 .function = PM_GPIO_FUNC_NORMAL,
5886 .vin_sel = 2,
5887 .inv_int_pol = 0,
5888 }
5889 };
5890#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005891#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5892 struct pm8058_gpio_cfg pmic_lcdc_nt35582_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305893 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1),
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005894 {
5895 .direction = PM_GPIO_DIR_OUT,
5896 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5897 .output_value = 1,
5898 .pull = PM_GPIO_PULL_UP_30,
5899 /* 2.9V PM_GPIO_VIN_L2, which gives 2.6V */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305900 .vin_sel = PM8058_GPIO_VIN_L5,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005901 .out_strength = PM_GPIO_STRENGTH_HIGH,
5902 .function = PM_GPIO_FUNC_NORMAL,
5903 .inv_int_pol = 0,
5904 }
5905 };
5906#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005907#if defined(CONFIG_HAPTIC_ISA1200) || \
5908 defined(CONFIG_HAPTIC_ISA1200_MODULE)
5909 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305910 rc = pm8xxx_gpio_config(
5911 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
5912 &en_hap_gpio_cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005913 if (rc < 0) {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305914 pr_err("%s: pmic haptics gpio config failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005915 __func__);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305916 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305917 rc = pm8xxx_gpio_config(
5918 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
5919 &en_hap_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305920 if (rc < 0) {
5921 pr_err("%s: pmic haptics ldo gpio config failed\n",
5922 __func__);
5923 }
5924
5925 }
5926#endif
5927
5928#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5929 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
5930 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
5931 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305932 rc = pm8xxx_gpio_config(
5933 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_TOUCH_DISC_INTR),
5934 &touchdisc_intr_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305935 if (rc < 0) {
5936 pr_err("%s: Touchdisc interrupt gpio config failed\n",
5937 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005938 }
5939 }
5940#endif
5941
5942#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5943 /* Line_in only for 8660 ffa & surf */
5944 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04005945 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005946 machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305947 rc = pm8xxx_gpio_config(line_in_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005948 &line_in_gpio_cfg.cfg);
5949 if (rc < 0) {
5950 pr_err("%s pmic line_in gpio config failed\n",
5951 __func__);
5952 return rc;
5953 }
5954 }
5955#endif
5956
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005957#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5958 if (machine_is_msm8x60_dragon()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305959 rc = pm8xxx_gpio_config(pmic_lcdc_nt35582_gpio_cfg.gpio,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005960 &pmic_lcdc_nt35582_gpio_cfg.cfg);
5961 if (rc < 0) {
5962 pr_err("%s pmic gpio config failed\n", __func__);
5963 return rc;
5964 }
5965 }
5966#endif
5967
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005968#if defined(CONFIG_QS_S5K4E1)
5969 /* qs_cam_hc37_cam_pd only for 8660 fluid qs camera*/
5970 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305971 rc = pm8xxx_gpio_config(qs_hc37_cam_pd_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005972 &qs_hc37_cam_pd_gpio_cfg.cfg);
5973 if (rc < 0) {
5974 pr_err("%s pmic qs_hc37_cam_pd gpio config failed\n",
5975 __func__);
5976 return rc;
5977 }
5978 }
5979 }
5980#endif
5981
5982 for (i = 0; i < ARRAY_SIZE(gpio_cfgs); ++i) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305983 rc = pm8xxx_gpio_config(gpio_cfgs[i].gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005984 &gpio_cfgs[i].cfg);
5985 if (rc < 0) {
5986 pr_err("%s pmic gpio config failed\n",
5987 __func__);
5988 return rc;
5989 }
5990 }
5991
5992 return 0;
5993}
5994
5995static const unsigned int ffa_keymap[] = {
5996 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5997 KEY(0, 1, KEY_UP), /* NAV - UP */
5998 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5999 KEY(0, 3, KEY_VOLUMEUP), /* Shuttle SW_UP */
6000
6001 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
6002 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
6003 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
6004 KEY(1, 3, KEY_VOLUMEDOWN),
6005
6006 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
6007
6008 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
6009 KEY(4, 1, KEY_UP), /* USER_UP */
6010 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
6011 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
6012 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
6013
6014 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
6015 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
6016 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
6017 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
6018 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
6019};
6020
Zhang Chang Ken683be172011-08-10 17:45:34 -04006021static const unsigned int dragon_keymap[] = {
6022 KEY(0, 0, KEY_MENU),
6023 KEY(0, 2, KEY_1),
6024 KEY(0, 3, KEY_4),
6025 KEY(0, 4, KEY_7),
6026
6027 KEY(1, 0, KEY_UP),
6028 KEY(1, 1, KEY_LEFT),
6029 KEY(1, 2, KEY_DOWN),
6030 KEY(1, 3, KEY_5),
6031 KEY(1, 4, KEY_8),
6032
6033 KEY(2, 0, KEY_HOME),
6034 KEY(2, 1, KEY_REPLY),
6035 KEY(2, 2, KEY_2),
6036 KEY(2, 3, KEY_6),
6037 KEY(2, 4, KEY_0),
6038
6039 KEY(3, 0, KEY_VOLUMEUP),
6040 KEY(3, 1, KEY_RIGHT),
6041 KEY(3, 2, KEY_3),
6042 KEY(3, 3, KEY_9),
6043 KEY(3, 4, KEY_SWITCHVIDEOMODE),
6044
6045 KEY(4, 0, KEY_VOLUMEDOWN),
6046 KEY(4, 1, KEY_BACK),
6047 KEY(4, 2, KEY_CAMERA),
6048 KEY(4, 3, KEY_KBDILLUMTOGGLE),
6049};
6050
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006051static struct matrix_keymap_data ffa_keymap_data = {
6052 .keymap_size = ARRAY_SIZE(ffa_keymap),
6053 .keymap = ffa_keymap,
6054};
6055
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306056static struct pm8xxx_keypad_platform_data ffa_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006057 .input_name = "ffa-keypad",
6058 .input_phys_device = "ffa-keypad/input0",
6059 .num_rows = 6,
6060 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306061 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
6062 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
6063 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006064 .scan_delay_ms = 32,
6065 .row_hold_ns = 91500,
6066 .wakeup = 1,
6067 .keymap_data = &ffa_keymap_data,
6068};
6069
Zhang Chang Ken683be172011-08-10 17:45:34 -04006070static struct matrix_keymap_data dragon_keymap_data = {
6071 .keymap_size = ARRAY_SIZE(dragon_keymap),
6072 .keymap = dragon_keymap,
6073};
6074
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306075static struct pm8xxx_keypad_platform_data dragon_keypad_data = {
Zhang Chang Ken683be172011-08-10 17:45:34 -04006076 .input_name = "dragon-keypad",
6077 .input_phys_device = "dragon-keypad/input0",
6078 .num_rows = 6,
6079 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306080 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
6081 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
6082 .debounce_ms = 15,
Zhang Chang Ken683be172011-08-10 17:45:34 -04006083 .scan_delay_ms = 32,
6084 .row_hold_ns = 91500,
6085 .wakeup = 1,
6086 .keymap_data = &dragon_keymap_data,
6087};
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306088
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006089static const unsigned int fluid_keymap[] = {
6090 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
6091 KEY(0, 1, KEY_UP), /* NAV - UP */
6092 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
6093 KEY(0, 3, KEY_VOLUMEDOWN), /* Shuttle SW_UP */
6094
6095 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
6096 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
6097 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
6098 KEY(1, 3, KEY_VOLUMEUP),
6099
6100 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
6101
6102 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
6103 KEY(4, 1, KEY_UP), /* USER_UP */
6104 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
6105 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
6106 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
6107
Jilai Wang9a895102011-07-12 14:00:35 -04006108 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006109 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
6110 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
6111 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
6112 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
6113};
6114
6115static struct matrix_keymap_data fluid_keymap_data = {
6116 .keymap_size = ARRAY_SIZE(fluid_keymap),
6117 .keymap = fluid_keymap,
6118};
6119
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306120static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006121 .input_name = "fluid-keypad",
6122 .input_phys_device = "fluid-keypad/input0",
6123 .num_rows = 6,
6124 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306125 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
6126 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
6127 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006128 .scan_delay_ms = 32,
6129 .row_hold_ns = 91500,
6130 .wakeup = 1,
6131 .keymap_data = &fluid_keymap_data,
6132};
6133
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306134static struct pm8xxx_vibrator_platform_data pm8058_vib_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006135 .initial_vibrate_ms = 500,
6136 .level_mV = 3000,
6137 .max_timeout_ms = 15000,
6138};
6139
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306140static struct pm8xxx_rtc_platform_data pm8058_rtc_pdata = {
6141 .rtc_write_enable = false,
6142 .rtc_alarm_powerup = false,
6143};
6144
6145static struct pm8xxx_pwrkey_platform_data pm8058_pwrkey_pdata = {
6146 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -08006147 .kpd_trigger_delay_us = 15625,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306148 .wakeup = 1,
6149};
6150
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006151#define PM8058_LINE_IN_DET_GPIO PM8058_GPIO_PM_TO_SYS(18)
6152
6153static struct othc_accessory_info othc_accessories[] = {
6154 {
6155 .accessory = OTHC_SVIDEO_OUT,
6156 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT
6157 | OTHC_ADC_DETECT,
6158 .key_code = SW_VIDEOOUT_INSERT,
6159 .enabled = false,
6160 .adc_thres = {
6161 .min_threshold = 20,
6162 .max_threshold = 40,
6163 },
6164 },
6165 {
6166 .accessory = OTHC_ANC_HEADPHONE,
6167 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT |
6168 OTHC_SWITCH_DETECT,
6169 .gpio = PM8058_LINE_IN_DET_GPIO,
6170 .active_low = 1,
6171 .key_code = SW_HEADPHONE_INSERT,
6172 .enabled = true,
6173 },
6174 {
6175 .accessory = OTHC_ANC_HEADSET,
6176 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT,
6177 .gpio = PM8058_LINE_IN_DET_GPIO,
6178 .active_low = 1,
6179 .key_code = SW_HEADPHONE_INSERT,
6180 .enabled = true,
6181 },
6182 {
6183 .accessory = OTHC_HEADPHONE,
6184 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT,
6185 .key_code = SW_HEADPHONE_INSERT,
6186 .enabled = true,
6187 },
6188 {
6189 .accessory = OTHC_MICROPHONE,
6190 .detect_flags = OTHC_GPIO_DETECT,
6191 .gpio = PM8058_LINE_IN_DET_GPIO,
6192 .active_low = 1,
6193 .key_code = SW_MICROPHONE_INSERT,
6194 .enabled = true,
6195 },
6196 {
6197 .accessory = OTHC_HEADSET,
6198 .detect_flags = OTHC_MICBIAS_DETECT,
6199 .key_code = SW_HEADPHONE_INSERT,
6200 .enabled = true,
6201 },
6202};
6203
6204static struct othc_switch_info switch_info[] = {
6205 {
6206 .min_adc_threshold = 0,
6207 .max_adc_threshold = 100,
6208 .key_code = KEY_PLAYPAUSE,
6209 },
6210 {
6211 .min_adc_threshold = 100,
6212 .max_adc_threshold = 200,
6213 .key_code = KEY_REWIND,
6214 },
6215 {
6216 .min_adc_threshold = 200,
6217 .max_adc_threshold = 500,
6218 .key_code = KEY_FASTFORWARD,
6219 },
6220};
6221
6222static struct othc_n_switch_config switch_config = {
6223 .voltage_settling_time_ms = 0,
6224 .num_adc_samples = 3,
6225 .adc_channel = CHANNEL_ADC_HDSET,
6226 .switch_info = switch_info,
6227 .num_keys = ARRAY_SIZE(switch_info),
6228 .default_sw_en = true,
6229 .default_sw_idx = 0,
6230};
6231
6232static struct hsed_bias_config hsed_bias_config = {
6233 /* HSED mic bias config info */
6234 .othc_headset = OTHC_HEADSET_NO,
6235 .othc_lowcurr_thresh_uA = 100,
6236 .othc_highcurr_thresh_uA = 600,
6237 .othc_hyst_prediv_us = 7800,
6238 .othc_period_clkdiv_us = 62500,
6239 .othc_hyst_clk_us = 121000,
6240 .othc_period_clk_us = 312500,
6241 .othc_wakeup = 1,
6242};
6243
6244static struct othc_hsed_config hsed_config_1 = {
6245 .hsed_bias_config = &hsed_bias_config,
6246 /*
6247 * The detection delay and switch reporting delay are
6248 * required to encounter a hardware bug (spurious switch
6249 * interrupts on slow insertion/removal of the headset).
6250 * This will introduce a delay in reporting the accessory
6251 * insertion and removal to the userspace.
6252 */
6253 .detection_delay_ms = 1500,
6254 /* Switch info */
6255 .switch_debounce_ms = 1500,
6256 .othc_support_n_switch = false,
6257 .switch_config = &switch_config,
6258 .ir_gpio = -1,
6259 /* Accessory info */
6260 .accessories_support = true,
6261 .accessories = othc_accessories,
6262 .othc_num_accessories = ARRAY_SIZE(othc_accessories),
6263};
6264
6265static struct othc_regulator_config othc_reg = {
6266 .regulator = "8058_l5",
6267 .max_uV = 2850000,
6268 .min_uV = 2850000,
6269};
6270
6271/* MIC_BIAS0 is configured as normal MIC BIAS */
6272static struct pmic8058_othc_config_pdata othc_config_pdata_0 = {
6273 .micbias_select = OTHC_MICBIAS_0,
6274 .micbias_capability = OTHC_MICBIAS,
6275 .micbias_enable = OTHC_SIGNAL_OFF,
6276 .micbias_regulator = &othc_reg,
6277};
6278
6279/* MIC_BIAS1 is configured as HSED_BIAS for OTHC */
6280static struct pmic8058_othc_config_pdata othc_config_pdata_1 = {
6281 .micbias_select = OTHC_MICBIAS_1,
6282 .micbias_capability = OTHC_MICBIAS_HSED,
6283 .micbias_enable = OTHC_SIGNAL_PWM_TCXO,
6284 .micbias_regulator = &othc_reg,
6285 .hsed_config = &hsed_config_1,
6286 .hsed_name = "8660_handset",
6287};
6288
6289/* MIC_BIAS2 is configured as normal MIC BIAS */
6290static struct pmic8058_othc_config_pdata othc_config_pdata_2 = {
6291 .micbias_select = OTHC_MICBIAS_2,
6292 .micbias_capability = OTHC_MICBIAS,
6293 .micbias_enable = OTHC_SIGNAL_OFF,
6294 .micbias_regulator = &othc_reg,
6295};
6296
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006297
6298static void __init msm8x60_init_pm8058_othc(void)
6299{
6300 int i;
6301
6302 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 ||
6303 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
6304 machine_is_msm8x60_fusn_ffa()) {
6305 /* 3-switch headset supported only by V2 FFA and FLUID */
6306 hsed_config_1.accessories_adc_support = true,
6307 /* ADC based accessory detection works only on V2 and FLUID */
6308 hsed_config_1.accessories_adc_channel = CHANNEL_ADC_HDSET,
6309 hsed_config_1.othc_support_n_switch = true;
6310 }
6311
6312 /* IR GPIO is absent on FLUID */
6313 if (machine_is_msm8x60_fluid())
6314 hsed_config_1.ir_gpio = -1;
6315
6316 for (i = 0; i < ARRAY_SIZE(othc_accessories); i++) {
6317 if (machine_is_msm8x60_fluid()) {
6318 switch (othc_accessories[i].accessory) {
6319 case OTHC_ANC_HEADPHONE:
6320 case OTHC_ANC_HEADSET:
6321 othc_accessories[i].gpio = GPIO_HEADSET_DET_N;
6322 break;
6323 case OTHC_MICROPHONE:
6324 othc_accessories[i].enabled = false;
6325 break;
6326 case OTHC_SVIDEO_OUT:
6327 othc_accessories[i].enabled = true;
6328 hsed_config_1.video_out_gpio = GPIO_HS_SW_DIR;
6329 break;
6330 }
6331 }
6332 }
6333}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006334
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006335
6336static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
6337{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306338 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006339 .direction = PM_GPIO_DIR_OUT,
6340 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
6341 .output_value = 0,
6342 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306343 .vin_sel = PM8058_GPIO_VIN_VPH,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006344 .out_strength = PM_GPIO_STRENGTH_HIGH,
6345 .function = PM_GPIO_FUNC_2,
6346 };
6347
6348 int rc = -EINVAL;
6349 int id, mode, max_mA;
6350
6351 id = mode = max_mA = 0;
6352 switch (ch) {
6353 case 0:
6354 case 1:
6355 case 2:
6356 if (on) {
6357 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306358 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
6359 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006360 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306361 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006362 __func__, id, rc);
6363 }
6364 break;
6365
6366 case 6:
6367 id = PM_PWM_LED_FLASH;
6368 mode = PM_PWM_CONF_PWM1;
6369 max_mA = 300;
6370 break;
6371
6372 case 7:
6373 id = PM_PWM_LED_FLASH1;
6374 mode = PM_PWM_CONF_PWM1;
6375 max_mA = 300;
6376 break;
6377
6378 default:
6379 break;
6380 }
6381
6382 if (ch >= 6 && ch <= 7) {
6383 if (!on) {
6384 mode = PM_PWM_CONF_NONE;
6385 max_mA = 0;
6386 }
6387 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
6388 if (rc)
6389 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
6390 __func__, ch, rc);
6391 }
6392 return rc;
6393
6394}
6395
6396static struct pm8058_pwm_pdata pm8058_pwm_data = {
6397 .config = pm8058_pwm_config,
6398};
6399
6400#define PM8058_GPIO_INT 88
6401
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006402static struct pmic8058_led pmic8058_flash_leds[] = {
6403 [0] = {
6404 .name = "camera:flash0",
6405 .max_brightness = 15,
6406 .id = PMIC8058_ID_FLASH_LED_0,
6407 },
6408 [1] = {
6409 .name = "camera:flash1",
6410 .max_brightness = 15,
6411 .id = PMIC8058_ID_FLASH_LED_1,
6412 },
6413};
6414
6415static struct pmic8058_leds_platform_data pm8058_flash_leds_data = {
6416 .num_leds = ARRAY_SIZE(pmic8058_flash_leds),
6417 .leds = pmic8058_flash_leds,
6418};
6419
Terence Hampsonc0b6dfb2011-07-15 11:07:17 -04006420static struct pmic8058_led pmic8058_dragon_leds[] = {
6421 [0] = {
6422 /* RED */
6423 .name = "led_drv0",
6424 .max_brightness = 15,
6425 .id = PMIC8058_ID_LED_0,
6426 },/* 300 mA flash led0 drv sink */
6427 [1] = {
6428 /* Yellow */
6429 .name = "led_drv1",
6430 .max_brightness = 15,
6431 .id = PMIC8058_ID_LED_1,
6432 },/* 300 mA flash led0 drv sink */
6433 [2] = {
6434 /* Green */
6435 .name = "led_drv2",
6436 .max_brightness = 15,
6437 .id = PMIC8058_ID_LED_2,
6438 },/* 300 mA flash led0 drv sink */
6439 [3] = {
6440 .name = "led_psensor",
6441 .max_brightness = 15,
6442 .id = PMIC8058_ID_LED_KB_LIGHT,
6443 },/* 300 mA flash led0 drv sink */
6444};
6445
6446static struct pmic8058_leds_platform_data pm8058_dragon_leds_data = {
6447 .num_leds = ARRAY_SIZE(pmic8058_dragon_leds),
6448 .leds = pmic8058_dragon_leds,
6449};
6450
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006451static struct pmic8058_led pmic8058_fluid_flash_leds[] = {
6452 [0] = {
6453 .name = "led:drv0",
6454 .max_brightness = 15,
6455 .id = PMIC8058_ID_FLASH_LED_0,
6456 },/* 300 mA flash led0 drv sink */
6457 [1] = {
6458 .name = "led:drv1",
6459 .max_brightness = 15,
6460 .id = PMIC8058_ID_FLASH_LED_1,
6461 },/* 300 mA flash led1 sink */
6462 [2] = {
6463 .name = "led:drv2",
6464 .max_brightness = 20,
6465 .id = PMIC8058_ID_LED_0,
6466 },/* 40 mA led0 sink */
6467 [3] = {
6468 .name = "keypad:drv",
6469 .max_brightness = 15,
6470 .id = PMIC8058_ID_LED_KB_LIGHT,
6471 },/* 300 mA keypad drv sink */
6472};
6473
6474static struct pmic8058_leds_platform_data pm8058_fluid_flash_leds_data = {
6475 .num_leds = ARRAY_SIZE(pmic8058_fluid_flash_leds),
6476 .leds = pmic8058_fluid_flash_leds,
6477};
6478
Terence Hampson90508a92011-08-09 10:40:08 -04006479static struct pmic8058_charger_data pmic8058_charger_dragon = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306480 .charger_data_valid = true,
Terence Hampson90508a92011-08-09 10:40:08 -04006481 .max_source_current = 1800,
6482 .charger_type = CHG_TYPE_AC,
6483};
6484
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306485static struct pmic8058_charger_data pmic8058_charger_ffa_surf = {
6486 .charger_data_valid = false,
6487};
6488
6489static struct pm8xxx_misc_platform_data pm8058_misc_pdata = {
6490 .priority = 0,
6491};
6492
6493static struct pm8xxx_irq_platform_data pm8058_irq_pdata = {
6494 .irq_base = PM8058_IRQ_BASE,
6495 .devirq = MSM_GPIO_TO_INT(PM8058_GPIO_INT),
6496 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6497};
6498
6499static struct pm8xxx_gpio_platform_data pm8058_gpio_pdata = {
6500 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
6501};
6502
6503static struct pm8xxx_mpp_platform_data pm8058_mpp_pdata = {
6504 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006505};
6506
6507static struct pm8058_platform_data pm8058_platform_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306508 .irq_pdata = &pm8058_irq_pdata,
6509 .gpio_pdata = &pm8058_gpio_pdata,
6510 .mpp_pdata = &pm8058_mpp_pdata,
6511 .rtc_pdata = &pm8058_rtc_pdata,
6512 .pwrkey_pdata = &pm8058_pwrkey_pdata,
6513 .othc0_pdata = &othc_config_pdata_0,
6514 .othc1_pdata = &othc_config_pdata_1,
6515 .othc2_pdata = &othc_config_pdata_2,
6516 .pwm_pdata = &pm8058_pwm_data,
6517 .misc_pdata = &pm8058_misc_pdata,
6518#ifdef CONFIG_SENSORS_MSM_ADC
6519 .xoadc_pdata = &pm8058_xoadc_pdata,
6520#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006521};
6522
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306523#ifdef CONFIG_MSM_SSBI
6524static struct msm_ssbi_platform_data msm8x60_ssbi_pm8058_pdata __devinitdata = {
6525 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6526 .slave = {
6527 .name = "pm8058-core",
6528 .platform_data = &pm8058_platform_data,
6529 },
6530};
6531#endif
6532#endif /* CONFIG_PMIC8058 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006533
6534#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
6535 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
6536#define TDISC_I2C_SLAVE_ADDR 0x67
6537#define PMIC_GPIO_TDISC PM8058_GPIO_PM_TO_SYS(5)
6538#define TDISC_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 5)
6539
6540static const char *vregs_tdisc_name[] = {
6541 "8058_l5",
6542 "8058_s3",
6543};
6544
6545static const int vregs_tdisc_val[] = {
6546 2850000,/* uV */
6547 1800000,
6548};
6549static struct regulator *vregs_tdisc[ARRAY_SIZE(vregs_tdisc_name)];
6550
6551static int tdisc_shinetsu_setup(void)
6552{
6553 int rc, i;
6554
6555 rc = gpio_request(PMIC_GPIO_TDISC, "tdisc_interrupt");
6556 if (rc) {
6557 pr_err("%s: gpio_request failed for PMIC_GPIO_TDISC\n",
6558 __func__);
6559 return rc;
6560 }
6561
6562 rc = gpio_request(GPIO_JOYSTICK_EN, "tdisc_oe");
6563 if (rc) {
6564 pr_err("%s: gpio_request failed for GPIO_JOYSTICK_EN\n",
6565 __func__);
6566 goto fail_gpio_oe;
6567 }
6568
6569 rc = gpio_direction_output(GPIO_JOYSTICK_EN, 1);
6570 if (rc) {
6571 pr_err("%s: gpio_direction_output failed for GPIO_JOYSTICK_EN\n",
6572 __func__);
6573 gpio_free(GPIO_JOYSTICK_EN);
6574 goto fail_gpio_oe;
6575 }
6576
6577 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6578 vregs_tdisc[i] = regulator_get(NULL, vregs_tdisc_name[i]);
6579 if (IS_ERR(vregs_tdisc[i])) {
6580 printk(KERN_ERR "%s: regulator get %s failed (%ld)\n",
6581 __func__, vregs_tdisc_name[i],
6582 PTR_ERR(vregs_tdisc[i]));
6583 rc = PTR_ERR(vregs_tdisc[i]);
6584 goto vreg_get_fail;
6585 }
6586
6587 rc = regulator_set_voltage(vregs_tdisc[i],
6588 vregs_tdisc_val[i], vregs_tdisc_val[i]);
6589 if (rc) {
6590 printk(KERN_ERR "%s: regulator_set_voltage() = %d\n",
6591 __func__, rc);
6592 goto vreg_set_voltage_fail;
6593 }
6594 }
6595
6596 return rc;
6597vreg_set_voltage_fail:
6598 i++;
6599vreg_get_fail:
6600 while (i)
6601 regulator_put(vregs_tdisc[--i]);
6602fail_gpio_oe:
6603 gpio_free(PMIC_GPIO_TDISC);
6604 return rc;
6605}
6606
6607static void tdisc_shinetsu_release(void)
6608{
6609 int i;
6610
6611 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++)
6612 regulator_put(vregs_tdisc[i]);
6613
6614 gpio_free(PMIC_GPIO_TDISC);
6615 gpio_free(GPIO_JOYSTICK_EN);
6616}
6617
6618static int tdisc_shinetsu_enable(void)
6619{
6620 int i, rc = -EINVAL;
6621
6622 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6623 rc = regulator_enable(vregs_tdisc[i]);
6624 if (rc < 0) {
6625 printk(KERN_ERR "%s: vreg %s enable failed (%d)\n",
6626 __func__, vregs_tdisc_name[i], rc);
6627 goto vreg_fail;
6628 }
6629 }
6630
6631 /* Enable the OE (output enable) gpio */
6632 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 1);
6633 /* voltage and gpio stabilization delay */
6634 msleep(50);
6635
6636 return 0;
6637vreg_fail:
6638 while (i)
6639 regulator_disable(vregs_tdisc[--i]);
6640 return rc;
6641}
6642
6643static int tdisc_shinetsu_disable(void)
6644{
6645 int i, rc;
6646
6647 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6648 rc = regulator_disable(vregs_tdisc[i]);
6649 if (rc < 0) {
6650 printk(KERN_ERR "%s: vreg %s disable failed (%d)\n",
6651 __func__, vregs_tdisc_name[i], rc);
6652 goto tdisc_reg_fail;
6653 }
6654 }
6655
6656 /* Disable the OE (output enable) gpio */
6657 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 0);
6658
6659 return 0;
6660
6661tdisc_reg_fail:
6662 while (i)
6663 regulator_enable(vregs_tdisc[--i]);
6664 return rc;
6665}
6666
6667static struct tdisc_abs_values tdisc_abs = {
6668 .x_max = 32,
6669 .y_max = 32,
6670 .x_min = -32,
6671 .y_min = -32,
6672 .pressure_max = 32,
6673 .pressure_min = 0,
6674};
6675
6676static struct tdisc_platform_data tdisc_data = {
6677 .tdisc_setup = tdisc_shinetsu_setup,
6678 .tdisc_release = tdisc_shinetsu_release,
6679 .tdisc_enable = tdisc_shinetsu_enable,
6680 .tdisc_disable = tdisc_shinetsu_disable,
6681 .tdisc_wakeup = 0,
6682 .tdisc_gpio = PMIC_GPIO_TDISC,
6683 .tdisc_report_keys = true,
6684 .tdisc_report_relative = true,
6685 .tdisc_report_absolute = false,
6686 .tdisc_report_wheel = false,
6687 .tdisc_reverse_x = false,
6688 .tdisc_reverse_y = true,
6689 .tdisc_abs = &tdisc_abs,
6690};
6691
6692static struct i2c_board_info msm_i2c_gsbi3_tdisc_info[] = {
6693 {
6694 I2C_BOARD_INFO("vtd518", TDISC_I2C_SLAVE_ADDR),
6695 .irq = TDISC_INT,
6696 .platform_data = &tdisc_data,
6697 },
6698};
6699#endif
6700
6701#define PM_GPIO_CDC_RST_N 20
6702#define GPIO_CDC_RST_N PM8058_GPIO_PM_TO_SYS(PM_GPIO_CDC_RST_N)
6703
6704static struct regulator *vreg_timpani_1;
6705static struct regulator *vreg_timpani_2;
6706
6707static unsigned int msm_timpani_setup_power(void)
6708{
6709 int rc;
6710
6711 vreg_timpani_1 = regulator_get(NULL, "8058_l0");
6712 if (IS_ERR(vreg_timpani_1)) {
6713 pr_err("%s: Unable to get 8058_l0\n", __func__);
6714 return -ENODEV;
6715 }
6716
6717 vreg_timpani_2 = regulator_get(NULL, "8058_s3");
6718 if (IS_ERR(vreg_timpani_2)) {
6719 pr_err("%s: Unable to get 8058_s3\n", __func__);
6720 regulator_put(vreg_timpani_1);
6721 return -ENODEV;
6722 }
6723
6724 rc = regulator_set_voltage(vreg_timpani_1, 1200000, 1200000);
6725 if (rc) {
6726 pr_err("%s: unable to set L0 voltage to 1.2V\n", __func__);
6727 goto fail;
6728 }
6729
6730 rc = regulator_set_voltage(vreg_timpani_2, 1800000, 1800000);
6731 if (rc) {
6732 pr_err("%s: unable to set S3 voltage to 1.8V\n", __func__);
6733 goto fail;
6734 }
6735
6736 rc = regulator_enable(vreg_timpani_1);
6737 if (rc) {
6738 pr_err("%s: Enable regulator 8058_l0 failed\n", __func__);
6739 goto fail;
6740 }
6741
6742 /* The settings for LDO0 should be set such that
6743 * it doesn't require to reset the timpani. */
6744 rc = regulator_set_optimum_mode(vreg_timpani_1, 5000);
6745 if (rc < 0) {
6746 pr_err("Timpani regulator optimum mode setting failed\n");
6747 goto fail;
6748 }
6749
6750 rc = regulator_enable(vreg_timpani_2);
6751 if (rc) {
6752 pr_err("%s: Enable regulator 8058_s3 failed\n", __func__);
6753 regulator_disable(vreg_timpani_1);
6754 goto fail;
6755 }
6756
6757 rc = gpio_request(GPIO_CDC_RST_N, "CDC_RST_N");
6758 if (rc) {
6759 pr_err("%s: GPIO Request %d failed\n", __func__,
6760 GPIO_CDC_RST_N);
6761 regulator_disable(vreg_timpani_1);
6762 regulator_disable(vreg_timpani_2);
6763 goto fail;
6764 } else {
6765 gpio_direction_output(GPIO_CDC_RST_N, 1);
6766 usleep_range(1000, 1050);
6767 gpio_direction_output(GPIO_CDC_RST_N, 0);
6768 usleep_range(1000, 1050);
6769 gpio_direction_output(GPIO_CDC_RST_N, 1);
6770 gpio_free(GPIO_CDC_RST_N);
6771 }
6772 return rc;
6773
6774fail:
6775 regulator_put(vreg_timpani_1);
6776 regulator_put(vreg_timpani_2);
6777 return rc;
6778}
6779
6780static void msm_timpani_shutdown_power(void)
6781{
6782 int rc;
6783
6784 rc = regulator_disable(vreg_timpani_1);
6785 if (rc)
6786 pr_err("%s: Disable regulator 8058_l0 failed\n", __func__);
6787
6788 regulator_put(vreg_timpani_1);
6789
6790 rc = regulator_disable(vreg_timpani_2);
6791 if (rc)
6792 pr_err("%s: Disable regulator 8058_s3 failed\n", __func__);
6793
6794 regulator_put(vreg_timpani_2);
6795}
6796
6797/* Power analog function of codec */
6798static struct regulator *vreg_timpani_cdc_apwr;
6799static int msm_timpani_codec_power(int vreg_on)
6800{
6801 int rc = 0;
6802
6803 if (!vreg_timpani_cdc_apwr) {
6804
6805 vreg_timpani_cdc_apwr = regulator_get(NULL, "8058_s4");
6806
6807 if (IS_ERR(vreg_timpani_cdc_apwr)) {
6808 pr_err("%s: vreg_get failed (%ld)\n",
6809 __func__, PTR_ERR(vreg_timpani_cdc_apwr));
6810 rc = PTR_ERR(vreg_timpani_cdc_apwr);
6811 return rc;
6812 }
6813 }
6814
6815 if (vreg_on) {
6816
6817 rc = regulator_set_voltage(vreg_timpani_cdc_apwr,
6818 2200000, 2200000);
6819 if (rc) {
6820 pr_err("%s: unable to set 8058_s4 voltage to 2.2 V\n",
6821 __func__);
6822 goto vreg_fail;
6823 }
6824
6825 rc = regulator_enable(vreg_timpani_cdc_apwr);
6826 if (rc) {
6827 pr_err("%s: vreg_enable failed %d\n", __func__, rc);
6828 goto vreg_fail;
6829 }
6830 } else {
6831 rc = regulator_disable(vreg_timpani_cdc_apwr);
6832 if (rc) {
6833 pr_err("%s: vreg_disable failed %d\n",
6834 __func__, rc);
6835 goto vreg_fail;
6836 }
6837 }
6838
6839 return 0;
6840
6841vreg_fail:
6842 regulator_put(vreg_timpani_cdc_apwr);
6843 vreg_timpani_cdc_apwr = NULL;
6844 return rc;
6845}
6846
6847static struct marimba_codec_platform_data timpani_codec_pdata = {
6848 .marimba_codec_power = msm_timpani_codec_power,
6849};
6850
6851#define TIMPANI_SLAVE_ID_CDC_ADDR 0X77
6852#define TIMPANI_SLAVE_ID_QMEMBIST_ADDR 0X66
6853
6854static struct marimba_platform_data timpani_pdata = {
6855 .slave_id[MARIMBA_SLAVE_ID_CDC] = TIMPANI_SLAVE_ID_CDC_ADDR,
6856 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = TIMPANI_SLAVE_ID_QMEMBIST_ADDR,
6857 .marimba_setup = msm_timpani_setup_power,
6858 .marimba_shutdown = msm_timpani_shutdown_power,
6859 .codec = &timpani_codec_pdata,
6860 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6861};
6862
6863#define TIMPANI_I2C_SLAVE_ADDR 0xD
6864
6865static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
6866 {
6867 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
6868 .platform_data = &timpani_pdata,
6869 },
6870};
6871
Lei Zhou338cab82011-08-19 13:38:17 -04006872#ifdef CONFIG_SND_SOC_WM8903
6873static struct wm8903_platform_data wm8903_pdata = {
6874 .gpio_cfg[2] = 0x3A8,
6875};
6876
6877#define WM8903_I2C_SLAVE_ADDR 0x34
6878static struct i2c_board_info wm8903_codec_i2c_info[] = {
6879 {
6880 I2C_BOARD_INFO("wm8903", WM8903_I2C_SLAVE_ADDR >> 1),
6881 .platform_data = &wm8903_pdata,
6882 },
6883};
6884#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006885#ifdef CONFIG_PMIC8901
6886
6887#define PM8901_GPIO_INT 91
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006888/*
6889 * Consumer specific regulator names:
6890 * regulator name consumer dev_name
6891 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006892static struct regulator_consumer_supply vreg_consumers_8901_USB_OTG[] = {
6893 REGULATOR_SUPPLY("8901_usb_otg", NULL),
6894};
6895static struct regulator_consumer_supply vreg_consumers_8901_HDMI_MVS[] = {
6896 REGULATOR_SUPPLY("8901_hdmi_mvs", NULL),
6897};
6898
6899#define PM8901_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306900 _always_on) \
6901 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006902 .init_data = { \
6903 .constraints = { \
6904 .valid_modes_mask = _modes, \
6905 .valid_ops_mask = _ops, \
6906 .min_uV = _min_uV, \
6907 .max_uV = _max_uV, \
6908 .input_uV = _min_uV, \
6909 .apply_uV = _apply_uV, \
6910 .always_on = _always_on, \
6911 }, \
6912 .consumer_supplies = vreg_consumers_8901_##_id, \
6913 .num_consumer_supplies = \
6914 ARRAY_SIZE(vreg_consumers_8901_##_id), \
6915 }, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306916 .id = PM8901_VREG_ID_##_id, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006917 }
6918
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006919#define PM8901_VREG_INIT_VS(_id) \
6920 PM8901_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306921 REGULATOR_CHANGE_STATUS, 0, 0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006922
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306923static struct pm8901_vreg_pdata pm8901_vreg_init[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006924 PM8901_VREG_INIT_VS(USB_OTG),
6925 PM8901_VREG_INIT_VS(HDMI_MVS),
6926};
6927
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306928static struct pm8xxx_misc_platform_data pm8901_misc_pdata = {
6929 .priority = 1,
6930};
6931
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306932static struct pm8xxx_irq_platform_data pm8901_irq_pdata = {
6933 .irq_base = PM8901_IRQ_BASE,
6934 .devirq = MSM_GPIO_TO_INT(PM8901_GPIO_INT),
6935 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6936};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006937
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306938static struct pm8xxx_mpp_platform_data pm8901_mpp_pdata = {
6939 .mpp_base = PM8901_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006940};
6941
6942static struct pm8901_platform_data pm8901_platform_data = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306943 .irq_pdata = &pm8901_irq_pdata,
6944 .mpp_pdata = &pm8901_mpp_pdata,
6945 .regulator_pdatas = pm8901_vreg_init,
6946 .num_regulators = ARRAY_SIZE(pm8901_vreg_init),
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306947 .misc_pdata = &pm8901_misc_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006948};
6949
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05306950static struct msm_ssbi_platform_data msm8x60_ssbi_pm8901_pdata __devinitdata = {
6951 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6952 .slave = {
6953 .name = "pm8901-core",
6954 .platform_data = &pm8901_platform_data,
6955 },
6956};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006957#endif /* CONFIG_PMIC8901 */
6958
6959#if defined(CONFIG_MARIMBA_CORE) && (defined(CONFIG_GPIO_SX150X) \
6960 || defined(CONFIG_GPIO_SX150X_MODULE))
6961
6962static struct regulator *vreg_bahama;
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006963static int msm_bahama_sys_rst = GPIO_MS_SYS_RESET_N;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006964
6965struct bahama_config_register{
6966 u8 reg;
6967 u8 value;
6968 u8 mask;
6969};
6970
6971enum version{
6972 VER_1_0,
6973 VER_2_0,
6974 VER_UNSUPPORTED = 0xFF
6975};
6976
6977static u8 read_bahama_ver(void)
6978{
6979 int rc;
6980 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6981 u8 bahama_version;
6982
6983 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
6984 if (rc < 0) {
6985 printk(KERN_ERR
6986 "%s: version read failed: %d\n",
6987 __func__, rc);
6988 return VER_UNSUPPORTED;
6989 } else {
6990 printk(KERN_INFO
6991 "%s: version read got: 0x%x\n",
6992 __func__, bahama_version);
6993 }
6994
6995 switch (bahama_version) {
6996 case 0x08: /* varient of bahama v1 */
6997 case 0x10:
6998 case 0x00:
6999 return VER_1_0;
7000 case 0x09: /* variant of bahama v2 */
7001 return VER_2_0;
7002 default:
7003 return VER_UNSUPPORTED;
7004 }
7005}
7006
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07007007static int msm_bahama_setup_power_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007008static unsigned int msm_bahama_setup_power(void)
7009{
7010 int rc = 0;
7011 const char *msm_bahama_regulator = "8058_s3";
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04007012
7013 if (machine_is_msm8x60_dragon())
7014 msm_bahama_sys_rst = GPIO_CDC_RST_N;
7015
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007016 vreg_bahama = regulator_get(NULL, msm_bahama_regulator);
7017
7018 if (IS_ERR(vreg_bahama)) {
7019 rc = PTR_ERR(vreg_bahama);
7020 pr_err("%s: regulator_get %s = %d\n", __func__,
7021 msm_bahama_regulator, rc);
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07007022 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007023 }
7024
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07007025 rc = regulator_set_voltage(vreg_bahama, 1800000, 1800000);
7026 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007027 pr_err("%s: regulator_set_voltage %s = %d\n", __func__,
7028 msm_bahama_regulator, rc);
7029 goto unget;
7030 }
7031
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07007032 rc = regulator_enable(vreg_bahama);
7033 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007034 pr_err("%s: regulator_enable %s = %d\n", __func__,
7035 msm_bahama_regulator, rc);
7036 goto unget;
7037 }
7038
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07007039 rc = gpio_request(msm_bahama_sys_rst, "bahama sys_rst_n");
7040 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007041 pr_err("%s: gpio_request %d = %d\n", __func__,
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04007042 msm_bahama_sys_rst, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007043 goto unenable;
7044 }
7045
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07007046 gpio_direction_output(msm_bahama_sys_rst, 0);
7047 usleep_range(1000, 1050);
7048 gpio_set_value_cansleep(msm_bahama_sys_rst, 1);
7049 usleep_range(1000, 1050);
7050 msm_bahama_setup_power_enable = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007051 return rc;
7052
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007053unenable:
7054 regulator_disable(vreg_bahama);
7055unget:
7056 regulator_put(vreg_bahama);
7057 return rc;
7058};
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07007059
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007060static unsigned int msm_bahama_shutdown_power(int value)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007061{
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07007062 if (msm_bahama_setup_power_enable) {
7063 gpio_set_value_cansleep(msm_bahama_sys_rst, 0);
7064 gpio_free(msm_bahama_sys_rst);
7065 regulator_disable(vreg_bahama);
7066 regulator_put(vreg_bahama);
7067 msm_bahama_setup_power_enable = 0;
7068 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007069
7070 return 0;
7071};
7072
7073static unsigned int msm_bahama_core_config(int type)
7074{
7075 int rc = 0;
7076
7077 if (type == BAHAMA_ID) {
7078
7079 int i;
7080 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
7081
7082 const struct bahama_config_register v20_init[] = {
7083 /* reg, value, mask */
7084 { 0xF4, 0x84, 0xFF }, /* AREG */
7085 { 0xF0, 0x04, 0xFF } /* DREG */
7086 };
7087
7088 if (read_bahama_ver() == VER_2_0) {
7089 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
7090 u8 value = v20_init[i].value;
7091 rc = marimba_write_bit_mask(&config,
7092 v20_init[i].reg,
7093 &value,
7094 sizeof(v20_init[i].value),
7095 v20_init[i].mask);
7096 if (rc < 0) {
7097 printk(KERN_ERR
7098 "%s: reg %d write failed: %d\n",
7099 __func__, v20_init[i].reg, rc);
7100 return rc;
7101 }
7102 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
7103 " mask 0x%02x\n",
7104 __func__, v20_init[i].reg,
7105 v20_init[i].value, v20_init[i].mask);
7106 }
7107 }
7108 }
7109 printk(KERN_INFO "core type: %d\n", type);
7110
7111 return rc;
7112}
7113
7114static struct regulator *fm_regulator_s3;
7115static struct msm_xo_voter *fm_clock;
7116
7117static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
7118{
7119 int rc = 0;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307120 struct pm_gpio cfg = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007121 .direction = PM_GPIO_DIR_IN,
7122 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307123 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007124 .function = PM_GPIO_FUNC_NORMAL,
7125 .inv_int_pol = 0,
7126 };
7127
7128 if (!fm_regulator_s3) {
7129 fm_regulator_s3 = regulator_get(NULL, "8058_s3");
7130 if (IS_ERR(fm_regulator_s3)) {
7131 rc = PTR_ERR(fm_regulator_s3);
7132 printk(KERN_ERR "%s: regulator get s3 (%d)\n",
7133 __func__, rc);
7134 goto out;
7135 }
7136 }
7137
7138
7139 rc = regulator_set_voltage(fm_regulator_s3, 1800000, 1800000);
7140 if (rc < 0) {
7141 printk(KERN_ERR "%s: regulator set voltage failed (%d)\n",
7142 __func__, rc);
7143 goto fm_fail_put;
7144 }
7145
7146 rc = regulator_enable(fm_regulator_s3);
7147 if (rc < 0) {
7148 printk(KERN_ERR "%s: regulator s3 enable failed (%d)\n",
7149 __func__, rc);
7150 goto fm_fail_put;
7151 }
7152
7153 /*Vote for XO clock*/
7154 fm_clock = msm_xo_get(MSM_XO_TCXO_D0, "fm_power");
7155
7156 if (IS_ERR(fm_clock)) {
7157 rc = PTR_ERR(fm_clock);
7158 printk(KERN_ERR "%s: Couldn't get TCXO_D0 vote for FM (%d)\n",
7159 __func__, rc);
7160 goto fm_fail_switch;
7161 }
7162
7163 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_ON);
7164 if (rc < 0) {
7165 printk(KERN_ERR "%s: Failed to vote for TCX0_D0 ON (%d)\n",
7166 __func__, rc);
7167 goto fm_fail_vote;
7168 }
7169
7170 /*GPIO 18 on PMIC is FM_IRQ*/
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307171 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(FM_GPIO), &cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007172 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307173 printk(KERN_ERR "%s: return val of pm8xxx_gpio_config: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007174 __func__, rc);
7175 goto fm_fail_clock;
7176 }
7177 goto out;
7178
7179fm_fail_clock:
7180 msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7181fm_fail_vote:
7182 msm_xo_put(fm_clock);
7183fm_fail_switch:
7184 regulator_disable(fm_regulator_s3);
7185fm_fail_put:
7186 regulator_put(fm_regulator_s3);
7187out:
7188 return rc;
7189};
7190
7191static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
7192{
7193 int rc = 0;
7194 if (fm_regulator_s3 != NULL) {
7195 rc = regulator_disable(fm_regulator_s3);
7196 if (rc < 0) {
7197 printk(KERN_ERR "%s: regulator s3 disable (%d)\n",
7198 __func__, rc);
7199 }
7200 regulator_put(fm_regulator_s3);
7201 fm_regulator_s3 = NULL;
7202 }
7203 printk(KERN_ERR "%s: Voting off for XO", __func__);
7204
7205 if (fm_clock != NULL) {
7206 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7207 if (rc < 0) {
7208 printk(KERN_ERR "%s: Voting off XO clock (%d)\n",
7209 __func__, rc);
7210 }
7211 msm_xo_put(fm_clock);
7212 }
7213 printk(KERN_ERR "%s: coming out of fm_radio_shutdown", __func__);
7214}
7215
7216/* Slave id address for FM/CDC/QMEMBIST
7217 * Values can be programmed using Marimba slave id 0
7218 * should there be a conflict with other I2C devices
7219 * */
7220#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
7221#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
7222
7223static struct marimba_fm_platform_data marimba_fm_pdata = {
7224 .fm_setup = fm_radio_setup,
7225 .fm_shutdown = fm_radio_shutdown,
7226 .irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, FM_GPIO),
7227 .is_fm_soc_i2s_master = false,
7228 .config_i2s_gpio = NULL,
7229};
7230
7231/*
7232Just initializing the BAHAMA related slave
7233*/
7234static struct marimba_platform_data marimba_pdata = {
7235 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
7236 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
7237 .bahama_setup = msm_bahama_setup_power,
7238 .bahama_shutdown = msm_bahama_shutdown_power,
7239 .bahama_core_config = msm_bahama_core_config,
7240 .fm = &marimba_fm_pdata,
7241 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
7242};
7243
7244
7245static struct i2c_board_info msm_marimba_board_info[] = {
7246 {
7247 I2C_BOARD_INFO("marimba", 0xc),
7248 .platform_data = &marimba_pdata,
7249 }
7250};
7251#endif /* CONFIG_MAIMBA_CORE */
7252
7253#ifdef CONFIG_I2C
7254#define I2C_SURF 1
7255#define I2C_FFA (1 << 1)
7256#define I2C_RUMI (1 << 2)
7257#define I2C_SIM (1 << 3)
7258#define I2C_FLUID (1 << 4)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007259#define I2C_DRAGON (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007260
7261struct i2c_registry {
7262 u8 machs;
7263 int bus;
7264 struct i2c_board_info *info;
7265 int len;
7266};
7267
7268static struct i2c_registry msm8x60_i2c_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007269#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7270 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007271 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007272 MSM_GSBI8_QUP_I2C_BUS_ID,
7273 core_expander_i2c_info,
7274 ARRAY_SIZE(core_expander_i2c_info),
7275 },
7276 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007277 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007278 MSM_GSBI8_QUP_I2C_BUS_ID,
7279 docking_expander_i2c_info,
7280 ARRAY_SIZE(docking_expander_i2c_info),
7281 },
7282 {
7283 I2C_SURF,
7284 MSM_GSBI8_QUP_I2C_BUS_ID,
7285 surf_expanders_i2c_info,
7286 ARRAY_SIZE(surf_expanders_i2c_info),
7287 },
7288 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007289 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007290 MSM_GSBI3_QUP_I2C_BUS_ID,
7291 fha_expanders_i2c_info,
7292 ARRAY_SIZE(fha_expanders_i2c_info),
7293 },
7294 {
7295 I2C_FLUID,
7296 MSM_GSBI3_QUP_I2C_BUS_ID,
7297 fluid_expanders_i2c_info,
7298 ARRAY_SIZE(fluid_expanders_i2c_info),
7299 },
7300 {
7301 I2C_FLUID,
7302 MSM_GSBI8_QUP_I2C_BUS_ID,
7303 fluid_core_expander_i2c_info,
7304 ARRAY_SIZE(fluid_core_expander_i2c_info),
7305 },
7306#endif
7307#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
7308 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
7309 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007310 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007311 MSM_GSBI3_QUP_I2C_BUS_ID,
7312 msm_i2c_gsbi3_tdisc_info,
7313 ARRAY_SIZE(msm_i2c_gsbi3_tdisc_info),
7314 },
7315#endif
7316 {
Zhang Chang Ken211df572011-07-05 19:16:39 -04007317 I2C_SURF | I2C_FFA | I2C_FLUID,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007318 MSM_GSBI3_QUP_I2C_BUS_ID,
7319 cy8ctmg200_board_info,
7320 ARRAY_SIZE(cy8ctmg200_board_info),
7321 },
Zhang Chang Ken211df572011-07-05 19:16:39 -04007322 {
7323 I2C_DRAGON,
7324 MSM_GSBI3_QUP_I2C_BUS_ID,
7325 cy8ctma340_dragon_board_info,
7326 ARRAY_SIZE(cy8ctma340_dragon_board_info),
7327 },
Steve Mucklef132c6c2012-06-06 18:30:57 -07007328#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
7329 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007330 {
7331 I2C_FLUID,
7332 MSM_GSBI3_QUP_I2C_BUS_ID,
7333 cyttsp_fluid_info,
7334 ARRAY_SIZE(cyttsp_fluid_info),
7335 },
7336 {
7337 I2C_FFA | I2C_SURF,
7338 MSM_GSBI3_QUP_I2C_BUS_ID,
7339 cyttsp_ffa_info,
7340 ARRAY_SIZE(cyttsp_ffa_info),
7341 },
7342#endif
7343#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07007344#ifndef CONFIG_MSM_CAMERA_V4L2
Jilai Wang971f97f2011-07-13 14:25:25 -04007345 {
7346 I2C_SURF | I2C_FFA | I2C_FLUID ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007347 MSM_GSBI4_QUP_I2C_BUS_ID,
7348 msm_camera_boardinfo,
7349 ARRAY_SIZE(msm_camera_boardinfo),
7350 },
Jilai Wang971f97f2011-07-13 14:25:25 -04007351 {
7352 I2C_DRAGON,
7353 MSM_GSBI4_QUP_I2C_BUS_ID,
7354 msm_camera_dragon_boardinfo,
7355 ARRAY_SIZE(msm_camera_dragon_boardinfo),
7356 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007357#endif
Kevin Chan3be11612012-03-22 20:05:40 -07007358#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007359 {
7360 I2C_SURF | I2C_FFA | I2C_FLUID,
7361 MSM_GSBI7_QUP_I2C_BUS_ID,
7362 msm_i2c_gsbi7_timpani_info,
7363 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info),
7364 },
7365#if defined(CONFIG_MARIMBA_CORE)
7366 {
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04007367 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007368 MSM_GSBI7_QUP_I2C_BUS_ID,
7369 msm_marimba_board_info,
7370 ARRAY_SIZE(msm_marimba_board_info),
7371 },
7372#endif /* CONFIG_MARIMBA_CORE */
7373#ifdef CONFIG_ISL9519_CHARGER
7374 {
7375 I2C_SURF | I2C_FFA,
7376 MSM_GSBI8_QUP_I2C_BUS_ID,
7377 isl_charger_i2c_info,
7378 ARRAY_SIZE(isl_charger_i2c_info),
7379 },
7380#endif
7381#if defined(CONFIG_HAPTIC_ISA1200) || \
7382 defined(CONFIG_HAPTIC_ISA1200_MODULE)
7383 {
7384 I2C_FLUID,
7385 MSM_GSBI8_QUP_I2C_BUS_ID,
7386 msm_isa1200_board_info,
7387 ARRAY_SIZE(msm_isa1200_board_info),
7388 },
7389#endif
7390#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
7391 {
7392 I2C_FLUID,
7393 MSM_GSBI8_QUP_I2C_BUS_ID,
7394 smb137b_charger_i2c_info,
7395 ARRAY_SIZE(smb137b_charger_i2c_info),
7396 },
7397#endif
7398#if defined(CONFIG_BATTERY_BQ27520) || \
7399 defined(CONFIG_BATTERY_BQ27520_MODULE)
7400 {
7401 I2C_FLUID,
7402 MSM_GSBI8_QUP_I2C_BUS_ID,
7403 msm_bq27520_board_info,
7404 ARRAY_SIZE(msm_bq27520_board_info),
7405 },
7406#endif
Lei Zhou338cab82011-08-19 13:38:17 -04007407#if defined(CONFIG_SND_SOC_WM8903) || defined(CONFIG_SND_SOC_WM8903_MODULE)
7408 {
7409 I2C_DRAGON,
7410 MSM_GSBI8_QUP_I2C_BUS_ID,
7411 wm8903_codec_i2c_info,
7412 ARRAY_SIZE(wm8903_codec_i2c_info),
7413 },
7414#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007415};
7416#endif /* CONFIG_I2C */
7417
Stephen Boyd668d7652012-04-25 11:31:01 -07007418static void __init fixup_i2c_configs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007419{
7420#ifdef CONFIG_I2C
7421#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7422 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7423 sx150x_data[SX150X_CORE].irq_summary =
7424 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT2_N);
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007425 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
7426 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007427 sx150x_data[SX150X_CORE].irq_summary =
7428 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7429 else if (machine_is_msm8x60_fluid())
7430 sx150x_data[SX150X_CORE_FLUID].irq_summary =
7431 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7432#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007433#endif
7434}
7435
Stephen Boyd668d7652012-04-25 11:31:01 -07007436static void __init register_i2c_devices(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007437{
7438#ifdef CONFIG_I2C
7439 u8 mach_mask = 0;
7440 int i;
Kevin Chan3be11612012-03-22 20:05:40 -07007441#ifdef CONFIG_MSM_CAMERA_V4L2
7442 struct i2c_registry msm8x60_camera_i2c_devices = {
7443 I2C_SURF | I2C_FFA | I2C_FLUID,
7444 MSM_GSBI4_QUP_I2C_BUS_ID,
7445 msm8x60_camera_board_info.board_info,
7446 msm8x60_camera_board_info.num_i2c_board_info,
7447 };
7448#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007449
7450 /* Build the matching 'supported_machs' bitmask */
7451 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7452 mach_mask = I2C_SURF;
7453 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
7454 mach_mask = I2C_FFA;
7455 else if (machine_is_msm8x60_rumi3())
7456 mach_mask = I2C_RUMI;
7457 else if (machine_is_msm8x60_sim())
7458 mach_mask = I2C_SIM;
7459 else if (machine_is_msm8x60_fluid())
7460 mach_mask = I2C_FLUID;
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007461 else if (machine_is_msm8x60_dragon())
7462 mach_mask = I2C_DRAGON;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007463 else
7464 pr_err("unmatched machine ID in register_i2c_devices\n");
7465
7466 /* Run the array and install devices as appropriate */
7467 for (i = 0; i < ARRAY_SIZE(msm8x60_i2c_devices); ++i) {
7468 if (msm8x60_i2c_devices[i].machs & mach_mask)
7469 i2c_register_board_info(msm8x60_i2c_devices[i].bus,
7470 msm8x60_i2c_devices[i].info,
7471 msm8x60_i2c_devices[i].len);
7472 }
Kevin Chan3be11612012-03-22 20:05:40 -07007473#ifdef CONFIG_MSM_CAMERA_V4L2
7474 if (msm8x60_camera_i2c_devices.machs & mach_mask)
7475 i2c_register_board_info(msm8x60_camera_i2c_devices.bus,
7476 msm8x60_camera_i2c_devices.info,
7477 msm8x60_camera_i2c_devices.len);
7478#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007479#endif
7480}
7481
7482static void __init msm8x60_init_uart12dm(void)
7483{
7484#if !defined(CONFIG_USB_PEHCI_HCD) && !defined(CONFIG_USB_PEHCI_HCD_MODULE)
7485 /* 0x1D000000 now belongs to EBI2:CS3 i.e. USB ISP Controller */
7486 void *fpga_mem = ioremap_nocache(0x1D000000, SZ_4K);
7487
7488 if (!fpga_mem)
7489 pr_err("%s(): Error getting memory\n", __func__);
7490
7491 /* Advanced mode */
7492 writew(0xFFFF, fpga_mem + 0x15C);
7493 /* FPGA_UART_SEL */
7494 writew(0, fpga_mem + 0x172);
7495 /* FPGA_GPIO_CONFIG_117 */
7496 writew(1, fpga_mem + 0xEA);
7497 /* FPGA_GPIO_CONFIG_118 */
7498 writew(1, fpga_mem + 0xEC);
7499 mb();
7500 iounmap(fpga_mem);
7501#endif
7502}
7503
7504#define MSM_GSBI9_PHYS 0x19900000
7505#define GSBI_DUAL_MODE_CODE 0x60
7506
7507static void __init msm8x60_init_buses(void)
7508{
7509#ifdef CONFIG_I2C_QUP
7510 void *gsbi_mem = ioremap_nocache(0x19C00000, 4);
7511 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI12 */
7512 writel_relaxed(0x6 << 4, gsbi_mem);
7513 /* Ensure protocol code is written before proceeding further */
7514 mb();
7515 iounmap(gsbi_mem);
7516
7517 msm_gsbi3_qup_i2c_device.dev.platform_data = &msm_gsbi3_qup_i2c_pdata;
7518 msm_gsbi4_qup_i2c_device.dev.platform_data = &msm_gsbi4_qup_i2c_pdata;
7519 msm_gsbi7_qup_i2c_device.dev.platform_data = &msm_gsbi7_qup_i2c_pdata;
7520 msm_gsbi8_qup_i2c_device.dev.platform_data = &msm_gsbi8_qup_i2c_pdata;
7521
7522#ifdef CONFIG_MSM_GSBI9_UART
7523 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7524 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI9 */
7525 gsbi_mem = ioremap_nocache(MSM_GSBI9_PHYS, 4);
7526 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
7527 iounmap(gsbi_mem);
7528 msm_gsbi9_qup_i2c_pdata.use_gsbi_shared_mode = 1;
7529 }
7530#endif
7531 msm_gsbi9_qup_i2c_device.dev.platform_data = &msm_gsbi9_qup_i2c_pdata;
7532 msm_gsbi12_qup_i2c_device.dev.platform_data = &msm_gsbi12_qup_i2c_pdata;
7533#endif
7534#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7535 msm_gsbi1_qup_spi_device.dev.platform_data = &msm_gsbi1_qup_spi_pdata;
7536#endif
7537#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007538 msm_device_ssbi3.dev.platform_data = &msm_ssbi3_pdata;
7539#endif
7540
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307541#ifdef CONFIG_MSM_SSBI
7542 msm_device_ssbi_pmic1.dev.platform_data =
7543 &msm8x60_ssbi_pm8058_pdata;
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05307544 msm_device_ssbi_pmic2.dev.platform_data =
7545 &msm8x60_ssbi_pm8901_pdata;
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307546#endif
7547
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007548 if (machine_is_msm8x60_fluid()) {
7549#if (defined(CONFIG_USB_EHCI_MSM_72K) && \
7550 (defined(CONFIG_SMB137B_CHARGER) || \
7551 defined(CONFIG_SMB137B_CHARGER_MODULE)))
7552 msm_otg_pdata.vbus_power = msm_hsusb_smb137b_vbus_power;
7553#endif
7554#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7555 msm_gsbi10_qup_spi_device.dev.platform_data =
7556 &msm_gsbi10_qup_spi_pdata;
7557#endif
7558 }
7559
Lena Salman57d167e2012-03-21 19:46:38 +02007560#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007561 /*
7562 * We can not put USB regulators (8058_l6 and 8058_l7) in LPM
7563 * when we depend on USB PHY for VBUS/ID notifications. VBUS
7564 * and ID notifications are available only on V2 surf and FFA
7565 * with a hardware workaround.
7566 */
7567 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 &&
7568 (machine_is_msm8x60_surf() ||
7569 (machine_is_msm8x60_ffa() &&
7570 pmic_id_notif_supported)))
7571 msm_otg_pdata.phy_can_powercollapse = 1;
7572 msm_device_otg.dev.platform_data = &msm_otg_pdata;
7573#endif
7574
Lena Salman57d167e2012-03-21 19:46:38 +02007575#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007576 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
7577#endif
7578
7579#ifdef CONFIG_SERIAL_MSM_HS
7580 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(54); /* GSBI6(2) */
7581 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
7582#endif
7583#ifdef CONFIG_MSM_GSBI9_UART
7584 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7585 msm_device_uart_gsbi9 = msm_add_gsbi9_uart();
7586 if (IS_ERR(msm_device_uart_gsbi9))
7587 pr_err("%s(): Failed to create uart gsbi9 device\n",
7588 __func__);
7589 }
7590#endif
7591
7592#ifdef CONFIG_MSM_BUS_SCALING
7593
7594 /* RPM calls are only enabled on V2 */
7595 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2) {
7596 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
7597 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
7598 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
7599 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
7600 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
7601 }
7602
7603 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
7604 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
7605 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
7606 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
7607 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
7608#endif
Stephen Boyd9e775ad2011-08-12 00:14:28 +01007609}
Steve Mucklea55df6e2010-01-07 12:43:24 -08007610
7611static void __init msm8x60_map_io(void)
7612{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007613 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Steve Mucklea55df6e2010-01-07 12:43:24 -08007614 msm_map_msm8x60_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007615
7616 if (socinfo_init() < 0)
7617 pr_err("socinfo_init() failed!\n");
Steve Mucklea55df6e2010-01-07 12:43:24 -08007618}
7619
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007620/*
7621 * Most segments of the EBI2 bus are disabled by default.
7622 */
7623static void __init msm8x60_init_ebi2(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08007624{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007625 uint32_t ebi2_cfg;
7626 void *ebi2_cfg_ptr;
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007627 struct clk *mem_clk = clk_get_sys("msm_ebi2", "mem_clk");
Steve Mucklea55df6e2010-01-07 12:43:24 -08007628
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007629 if (IS_ERR(mem_clk)) {
7630 pr_err("%s: clk_get_sys(%s,%s), failed", __func__,
7631 "msm_ebi2", "mem_clk");
7632 return;
7633 }
Stephen Boyd818a3f62012-05-08 12:12:18 -07007634 clk_prepare_enable(mem_clk);
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007635 clk_put(mem_clk);
Steve Mucklea55df6e2010-01-07 12:43:24 -08007636
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007637 ebi2_cfg_ptr = ioremap_nocache(0x1a100000, sizeof(uint32_t));
7638 if (ebi2_cfg_ptr != 0) {
7639 ebi2_cfg = readl_relaxed(ebi2_cfg_ptr);
Steve Mucklea55df6e2010-01-07 12:43:24 -08007640
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007641 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007642 machine_is_msm8x60_fluid() ||
7643 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007644 ebi2_cfg |= (1 << 4) | (1 << 5); /* CS2, CS3 */
7645 else if (machine_is_msm8x60_sim())
7646 ebi2_cfg |= (1 << 4); /* CS2 */
7647 else if (machine_is_msm8x60_rumi3())
7648 ebi2_cfg |= (1 << 5); /* CS3 */
Steve Mucklea55df6e2010-01-07 12:43:24 -08007649
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007650 writel_relaxed(ebi2_cfg, ebi2_cfg_ptr);
7651 iounmap(ebi2_cfg_ptr);
David Brown56e2d8a2011-08-04 02:01:02 -07007652 }
7653
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007654 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007655 machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007656 ebi2_cfg_ptr = ioremap_nocache(0x1a110000, SZ_4K);
7657 if (ebi2_cfg_ptr != 0) {
7658 /* EBI2_XMEM_CFG:PWRSAVE_MODE off */
7659 writel_relaxed(0UL, ebi2_cfg_ptr);
7660
7661 /* CS2: Delay 9 cycles (140ns@64MHz) between SMSC
7662 * LAN9221 Ethernet controller reads and writes.
7663 * The lowest 4 bits are the read delay, the next
7664 * 4 are the write delay. */
7665 writel_relaxed(0x031F1C99, ebi2_cfg_ptr + 0x10);
7666#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
7667 /*
7668 * RECOVERY=5, HOLD_WR=1
7669 * INIT_LATENCY_WR=1, INIT_LATENCY_RD=1
7670 * WAIT_WR=1, WAIT_RD=2
7671 */
7672 writel_relaxed(0x51010112, ebi2_cfg_ptr + 0x14);
7673 /*
7674 * HOLD_RD=1
7675 * ADV_OE_RECOVERY=0, ADDR_HOLD_ENA=1
7676 */
7677 writel_relaxed(0x01000020, ebi2_cfg_ptr + 0x34);
7678#else
7679 /* EBI2 CS3 muxed address/data,
7680 * two cyc addr enable */
7681 writel_relaxed(0xA3030020, ebi2_cfg_ptr + 0x34);
7682
7683#endif
7684 iounmap(ebi2_cfg_ptr);
7685 }
7686 }
David Brown56e2d8a2011-08-04 02:01:02 -07007687}
7688
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007689static void __init msm8x60_configure_smc91x(void)
7690{
7691 if (machine_is_msm8x60_sim()) {
7692
7693 smc91x_resources[0].start = 0x1b800300;
7694 smc91x_resources[0].end = 0x1b8003ff;
7695
7696 smc91x_resources[1].start = (NR_MSM_IRQS + 40);
7697 smc91x_resources[1].end = (NR_MSM_IRQS + 40);
7698
7699 } else if (machine_is_msm8x60_rumi3()) {
7700
7701 smc91x_resources[0].start = 0x1d000300;
7702 smc91x_resources[0].end = 0x1d0003ff;
7703
7704 smc91x_resources[1].start = TLMM_MSM_DIR_CONN_IRQ_0;
7705 smc91x_resources[1].end = TLMM_MSM_DIR_CONN_IRQ_0;
7706 }
7707}
7708
7709static void __init msm8x60_init_tlmm(void)
7710{
7711 if (machine_is_msm8x60_rumi3())
7712 msm_gpio_install_direct_irq(0, 0, 1);
7713}
7714
7715#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
7716 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
7717 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
7718 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\
7719 || defined(CONFIG_MMC_MSM_SDC5_SUPPORT))
7720
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007721/* 8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007722#define MAX_SDCC_CONTROLLER 5
7723
7724struct msm_sdcc_gpio {
7725 /* maximum 10 GPIOs per SDCC controller */
7726 s16 no;
7727 /* name of this GPIO */
7728 const char *name;
7729 bool always_on;
7730 bool is_enabled;
David Brown56e2d8a2011-08-04 02:01:02 -07007731};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007732
7733#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7734static struct msm_sdcc_gpio sdc1_gpio_cfg[] = {
7735 {159, "sdc1_dat_0"},
7736 {160, "sdc1_dat_1"},
7737 {161, "sdc1_dat_2"},
7738 {162, "sdc1_dat_3"},
7739#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
7740 {163, "sdc1_dat_4"},
7741 {164, "sdc1_dat_5"},
7742 {165, "sdc1_dat_6"},
7743 {166, "sdc1_dat_7"},
7744#endif
7745 {167, "sdc1_clk"},
7746 {168, "sdc1_cmd"}
7747};
7748#endif
7749
7750#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7751static struct msm_sdcc_gpio sdc2_gpio_cfg[] = {
7752 {143, "sdc2_dat_0"},
7753 {144, "sdc2_dat_1", 1},
7754 {145, "sdc2_dat_2"},
7755 {146, "sdc2_dat_3"},
7756#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
7757 {147, "sdc2_dat_4"},
7758 {148, "sdc2_dat_5"},
7759 {149, "sdc2_dat_6"},
7760 {150, "sdc2_dat_7"},
7761#endif
7762 {151, "sdc2_cmd"},
7763 {152, "sdc2_clk", 1}
7764};
7765#endif
7766
7767#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7768static struct msm_sdcc_gpio sdc5_gpio_cfg[] = {
7769 {95, "sdc5_cmd"},
7770 {96, "sdc5_dat_3"},
7771 {97, "sdc5_clk", 1},
7772 {98, "sdc5_dat_2"},
7773 {99, "sdc5_dat_1", 1},
7774 {100, "sdc5_dat_0"}
7775};
7776#endif
7777
7778struct msm_sdcc_pad_pull_cfg {
7779 enum msm_tlmm_pull_tgt pull;
7780 u32 pull_val;
7781};
7782
7783struct msm_sdcc_pad_drv_cfg {
7784 enum msm_tlmm_hdrive_tgt drv;
7785 u32 drv_val;
7786};
7787
7788#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7789static struct msm_sdcc_pad_drv_cfg sdc3_pad_on_drv_cfg[] = {
7790 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
7791 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
7792 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
7793};
7794
7795static struct msm_sdcc_pad_pull_cfg sdc3_pad_on_pull_cfg[] = {
7796 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
7797 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
7798};
7799
7800static struct msm_sdcc_pad_drv_cfg sdc3_pad_off_drv_cfg[] = {
7801 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
7802 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
7803 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
7804};
7805
7806static struct msm_sdcc_pad_pull_cfg sdc3_pad_off_pull_cfg[] = {
7807 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
7808 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
7809};
7810#endif
7811
7812#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7813static struct msm_sdcc_pad_drv_cfg sdc4_pad_on_drv_cfg[] = {
7814 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_8MA},
7815 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_8MA},
7816 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_8MA}
7817};
7818
7819static struct msm_sdcc_pad_pull_cfg sdc4_pad_on_pull_cfg[] = {
7820 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_UP},
7821 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_UP}
7822};
7823
7824static struct msm_sdcc_pad_drv_cfg sdc4_pad_off_drv_cfg[] = {
7825 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_2MA},
7826 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_2MA},
7827 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_2MA}
7828};
7829
7830static struct msm_sdcc_pad_pull_cfg sdc4_pad_off_pull_cfg[] = {
7831 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_DOWN},
7832 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_DOWN}
7833};
7834#endif
7835
7836struct msm_sdcc_pin_cfg {
7837 /*
7838 * = 1 if controller pins are using gpios
7839 * = 0 if controller has dedicated MSM pins
7840 */
7841 u8 is_gpio;
7842 u8 cfg_sts;
7843 u8 gpio_data_size;
7844 struct msm_sdcc_gpio *gpio_data;
7845 struct msm_sdcc_pad_drv_cfg *pad_drv_on_data;
7846 struct msm_sdcc_pad_drv_cfg *pad_drv_off_data;
7847 struct msm_sdcc_pad_pull_cfg *pad_pull_on_data;
7848 struct msm_sdcc_pad_pull_cfg *pad_pull_off_data;
7849 u8 pad_drv_data_size;
7850 u8 pad_pull_data_size;
7851 u8 sdio_lpm_gpio_cfg;
7852};
7853
7854
7855static struct msm_sdcc_pin_cfg sdcc_pin_cfg_data[MAX_SDCC_CONTROLLER] = {
7856#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7857 [0] = {
7858 .is_gpio = 1,
7859 .gpio_data_size = ARRAY_SIZE(sdc1_gpio_cfg),
7860 .gpio_data = sdc1_gpio_cfg
7861 },
7862#endif
7863#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7864 [1] = {
7865 .is_gpio = 1,
7866 .gpio_data_size = ARRAY_SIZE(sdc2_gpio_cfg),
7867 .gpio_data = sdc2_gpio_cfg
7868 },
7869#endif
7870#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7871 [2] = {
7872 .is_gpio = 0,
7873 .pad_drv_on_data = sdc3_pad_on_drv_cfg,
7874 .pad_drv_off_data = sdc3_pad_off_drv_cfg,
7875 .pad_pull_on_data = sdc3_pad_on_pull_cfg,
7876 .pad_pull_off_data = sdc3_pad_off_pull_cfg,
7877 .pad_drv_data_size = ARRAY_SIZE(sdc3_pad_on_drv_cfg),
7878 .pad_pull_data_size = ARRAY_SIZE(sdc3_pad_on_pull_cfg)
7879 },
7880#endif
7881#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7882 [3] = {
7883 .is_gpio = 0,
7884 .pad_drv_on_data = sdc4_pad_on_drv_cfg,
7885 .pad_drv_off_data = sdc4_pad_off_drv_cfg,
7886 .pad_pull_on_data = sdc4_pad_on_pull_cfg,
7887 .pad_pull_off_data = sdc4_pad_off_pull_cfg,
7888 .pad_drv_data_size = ARRAY_SIZE(sdc4_pad_on_drv_cfg),
7889 .pad_pull_data_size = ARRAY_SIZE(sdc4_pad_on_pull_cfg)
7890 },
7891#endif
7892#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7893 [4] = {
7894 .is_gpio = 1,
7895 .gpio_data_size = ARRAY_SIZE(sdc5_gpio_cfg),
7896 .gpio_data = sdc5_gpio_cfg
7897 }
7898#endif
7899};
7900
7901static int msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
7902{
7903 int rc = 0;
7904 struct msm_sdcc_pin_cfg *curr;
7905 int n;
7906
7907 curr = &sdcc_pin_cfg_data[dev_id - 1];
7908 if (!curr->gpio_data)
7909 goto out;
7910
7911 for (n = 0; n < curr->gpio_data_size; n++) {
7912 if (enable) {
7913
7914 if (curr->gpio_data[n].always_on &&
7915 curr->gpio_data[n].is_enabled)
7916 continue;
7917 pr_debug("%s: enable: %s\n", __func__,
7918 curr->gpio_data[n].name);
7919 rc = gpio_request(curr->gpio_data[n].no,
7920 curr->gpio_data[n].name);
7921 if (rc) {
7922 pr_err("%s: gpio_request(%d, %s)"
7923 "failed", __func__,
7924 curr->gpio_data[n].no,
7925 curr->gpio_data[n].name);
7926 goto free_gpios;
7927 }
7928 /* set direction as output for all GPIOs */
7929 rc = gpio_direction_output(
7930 curr->gpio_data[n].no, 1);
7931 if (rc) {
7932 pr_err("%s: gpio_direction_output"
7933 "(%d, 1) failed\n", __func__,
7934 curr->gpio_data[n].no);
7935 goto free_gpios;
7936 }
7937 curr->gpio_data[n].is_enabled = 1;
7938 } else {
7939 /*
7940 * now free this GPIO which will put GPIO
7941 * in low power mode and will also put GPIO
7942 * in input mode
7943 */
7944 if (curr->gpio_data[n].always_on)
7945 continue;
7946 pr_debug("%s: disable: %s\n", __func__,
7947 curr->gpio_data[n].name);
7948 gpio_free(curr->gpio_data[n].no);
7949 curr->gpio_data[n].is_enabled = 0;
7950 }
7951 }
7952 curr->cfg_sts = enable;
7953 goto out;
7954
7955free_gpios:
7956 for (; n >= 0; n--)
7957 gpio_free(curr->gpio_data[n].no);
7958out:
7959 return rc;
7960}
7961
7962static int msm_sdcc_setup_pad(int dev_id, unsigned int enable)
7963{
7964 int rc = 0;
7965 struct msm_sdcc_pin_cfg *curr;
7966 int n;
7967
7968 curr = &sdcc_pin_cfg_data[dev_id - 1];
7969 if (!curr->pad_drv_on_data || !curr->pad_pull_on_data)
7970 goto out;
7971
7972 if (enable) {
7973 /*
7974 * set up the normal driver strength and
7975 * pull config for pads
7976 */
7977 for (n = 0; n < curr->pad_drv_data_size; n++) {
7978 if (curr->sdio_lpm_gpio_cfg) {
7979 if (curr->pad_drv_on_data[n].drv ==
7980 TLMM_HDRV_SDC4_DATA)
7981 continue;
7982 }
7983 msm_tlmm_set_hdrive(curr->pad_drv_on_data[n].drv,
7984 curr->pad_drv_on_data[n].drv_val);
7985 }
7986 for (n = 0; n < curr->pad_pull_data_size; n++) {
7987 if (curr->sdio_lpm_gpio_cfg) {
7988 if (curr->pad_pull_on_data[n].pull ==
7989 TLMM_PULL_SDC4_DATA)
7990 continue;
7991 }
7992 msm_tlmm_set_pull(curr->pad_pull_on_data[n].pull,
7993 curr->pad_pull_on_data[n].pull_val);
7994 }
7995 } else {
7996 /* set the low power config for pads */
7997 for (n = 0; n < curr->pad_drv_data_size; n++) {
7998 if (curr->sdio_lpm_gpio_cfg) {
7999 if (curr->pad_drv_off_data[n].drv ==
8000 TLMM_HDRV_SDC4_DATA)
8001 continue;
8002 }
8003 msm_tlmm_set_hdrive(
8004 curr->pad_drv_off_data[n].drv,
8005 curr->pad_drv_off_data[n].drv_val);
8006 }
8007 for (n = 0; n < curr->pad_pull_data_size; n++) {
8008 if (curr->sdio_lpm_gpio_cfg) {
8009 if (curr->pad_pull_off_data[n].pull ==
8010 TLMM_PULL_SDC4_DATA)
8011 continue;
8012 }
8013 msm_tlmm_set_pull(
8014 curr->pad_pull_off_data[n].pull,
8015 curr->pad_pull_off_data[n].pull_val);
8016 }
8017 }
8018 curr->cfg_sts = enable;
8019out:
8020 return rc;
8021}
8022
8023struct sdcc_reg {
8024 /* VDD/VCC/VCCQ regulator name on PMIC8058/PMIC8089*/
8025 const char *reg_name;
8026 /*
8027 * is set voltage supported for this regulator?
8028 * 0 = not supported, 1 = supported
8029 */
8030 unsigned char set_voltage_sup;
8031 /* voltage level to be set */
8032 unsigned int level;
8033 /* VDD/VCC/VCCQ voltage regulator handle */
8034 struct regulator *reg;
8035 /* is this regulator enabled? */
8036 bool enabled;
8037 /* is this regulator needs to be always on? */
8038 bool always_on;
8039 /* is operating power mode setting required for this regulator? */
8040 bool op_pwr_mode_sup;
8041 /* Load values for low power and high power mode */
8042 unsigned int lpm_uA;
8043 unsigned int hpm_uA;
8044};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07008045/* all SDCC controllers require VDD/VCC voltage */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008046static struct sdcc_reg sdcc_vdd_reg_data[MAX_SDCC_CONTROLLER];
8047/* only SDCC1 requires VCCQ voltage */
8048static struct sdcc_reg sdcc_vccq_reg_data[1];
8049/* all SDCC controllers may require voting for VDD PAD voltage */
8050static struct sdcc_reg sdcc_vddp_reg_data[MAX_SDCC_CONTROLLER];
8051
8052struct sdcc_reg_data {
8053 struct sdcc_reg *vdd_data; /* keeps VDD/VCC regulator info */
8054 struct sdcc_reg *vccq_data; /* keeps VCCQ regulator info */
8055 struct sdcc_reg *vddp_data; /* keeps VDD Pad regulator info */
8056 unsigned char sts; /* regulator enable/disable status */
8057};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07008058/* msm8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008059static struct sdcc_reg_data sdcc_vreg_data[MAX_SDCC_CONTROLLER];
8060
8061static int msm_sdcc_vreg_init_reg(struct sdcc_reg *vreg)
8062{
8063 int rc = 0;
8064
8065 /* Get the regulator handle */
8066 vreg->reg = regulator_get(NULL, vreg->reg_name);
8067 if (IS_ERR(vreg->reg)) {
8068 rc = PTR_ERR(vreg->reg);
8069 pr_err("%s: regulator_get(%s) failed. rc=%d\n",
8070 __func__, vreg->reg_name, rc);
8071 goto out;
8072 }
8073
8074 /* Set the voltage level if required */
8075 if (vreg->set_voltage_sup) {
8076 rc = regulator_set_voltage(vreg->reg, vreg->level,
8077 vreg->level);
8078 if (rc) {
8079 pr_err("%s: regulator_set_voltage(%s) failed rc=%d\n",
8080 __func__, vreg->reg_name, rc);
8081 goto vreg_put;
8082 }
8083 }
8084 goto out;
8085
8086vreg_put:
8087 regulator_put(vreg->reg);
8088out:
8089 return rc;
8090}
8091
8092static inline void msm_sdcc_vreg_deinit_reg(struct sdcc_reg *vreg)
8093{
8094 regulator_put(vreg->reg);
8095}
8096
8097/* this init function should be called only once for each SDCC */
8098static int msm_sdcc_vreg_init(int dev_id, unsigned char init)
8099{
8100 int rc = 0;
8101 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
8102 struct sdcc_reg_data *curr;
8103
8104 curr = &sdcc_vreg_data[dev_id - 1];
8105 curr_vdd_reg = curr->vdd_data;
8106 curr_vccq_reg = curr->vccq_data;
8107 curr_vddp_reg = curr->vddp_data;
8108
8109 if (init) {
8110 /*
8111 * get the regulator handle from voltage regulator framework
8112 * and then try to set the voltage level for the regulator
8113 */
8114 if (curr_vdd_reg) {
8115 rc = msm_sdcc_vreg_init_reg(curr_vdd_reg);
8116 if (rc)
8117 goto out;
8118 }
8119 if (curr_vccq_reg) {
8120 rc = msm_sdcc_vreg_init_reg(curr_vccq_reg);
8121 if (rc)
8122 goto vdd_reg_deinit;
8123 }
8124 if (curr_vddp_reg) {
8125 rc = msm_sdcc_vreg_init_reg(curr_vddp_reg);
8126 if (rc)
8127 goto vccq_reg_deinit;
8128 }
8129 goto out;
8130 } else
8131 /* deregister with all regulators from regulator framework */
8132 goto vddp_reg_deinit;
8133
8134vddp_reg_deinit:
8135 if (curr_vddp_reg)
8136 msm_sdcc_vreg_deinit_reg(curr_vddp_reg);
8137vccq_reg_deinit:
8138 if (curr_vccq_reg)
8139 msm_sdcc_vreg_deinit_reg(curr_vccq_reg);
8140vdd_reg_deinit:
8141 if (curr_vdd_reg)
8142 msm_sdcc_vreg_deinit_reg(curr_vdd_reg);
8143out:
8144 return rc;
8145}
8146
8147static int msm_sdcc_vreg_enable(struct sdcc_reg *vreg)
8148{
8149 int rc;
8150
8151 if (!vreg->enabled) {
8152 rc = regulator_enable(vreg->reg);
8153 if (rc) {
8154 pr_err("%s: regulator_enable(%s) failed. rc=%d\n",
8155 __func__, vreg->reg_name, rc);
8156 goto out;
8157 }
8158 vreg->enabled = 1;
8159 }
8160
8161 /* Put always_on regulator in HPM (high power mode) */
8162 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8163 rc = regulator_set_optimum_mode(vreg->reg, vreg->hpm_uA);
8164 if (rc < 0) {
8165 pr_err("%s: reg=%s: HPM setting failed"
8166 " hpm_uA=%d, rc=%d\n",
8167 __func__, vreg->reg_name,
8168 vreg->hpm_uA, rc);
8169 goto vreg_disable;
8170 }
8171 rc = 0;
8172 }
8173 goto out;
8174
8175vreg_disable:
8176 regulator_disable(vreg->reg);
8177 vreg->enabled = 0;
8178out:
8179 return rc;
8180}
8181
8182static int msm_sdcc_vreg_disable(struct sdcc_reg *vreg)
8183{
8184 int rc;
8185
8186 /* Never disable always_on regulator */
8187 if (!vreg->always_on) {
8188 rc = regulator_disable(vreg->reg);
8189 if (rc) {
8190 pr_err("%s: regulator_disable(%s) failed. rc=%d\n",
8191 __func__, vreg->reg_name, rc);
8192 goto out;
8193 }
8194 vreg->enabled = 0;
8195 }
8196
8197 /* Put always_on regulator in LPM (low power mode) */
8198 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8199 rc = regulator_set_optimum_mode(vreg->reg, vreg->lpm_uA);
8200 if (rc < 0) {
8201 pr_err("%s: reg=%s: LPM setting failed"
8202 " lpm_uA=%d, rc=%d\n",
8203 __func__,
8204 vreg->reg_name,
8205 vreg->lpm_uA, rc);
8206 goto out;
8207 }
8208 rc = 0;
8209 }
8210
8211out:
8212 return rc;
8213}
8214
8215static int msm_sdcc_setup_vreg(int dev_id, unsigned char enable)
8216{
8217 int rc = 0;
8218 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
8219 struct sdcc_reg_data *curr;
8220
8221 curr = &sdcc_vreg_data[dev_id - 1];
8222 curr_vdd_reg = curr->vdd_data;
8223 curr_vccq_reg = curr->vccq_data;
8224 curr_vddp_reg = curr->vddp_data;
8225
8226 /* check if regulators are initialized or not? */
8227 if ((curr_vdd_reg && !curr_vdd_reg->reg) ||
8228 (curr_vccq_reg && !curr_vccq_reg->reg) ||
8229 (curr_vddp_reg && !curr_vddp_reg->reg)) {
8230 /* initialize voltage regulators required for this SDCC */
8231 rc = msm_sdcc_vreg_init(dev_id, 1);
8232 if (rc) {
8233 pr_err("%s: regulator init failed = %d\n",
8234 __func__, rc);
8235 goto out;
8236 }
8237 }
8238
8239 if (curr->sts == enable)
8240 goto out;
8241
8242 if (curr_vdd_reg) {
8243 if (enable)
8244 rc = msm_sdcc_vreg_enable(curr_vdd_reg);
8245 else
8246 rc = msm_sdcc_vreg_disable(curr_vdd_reg);
8247 if (rc)
8248 goto out;
8249 }
8250
8251 if (curr_vccq_reg) {
8252 if (enable)
8253 rc = msm_sdcc_vreg_enable(curr_vccq_reg);
8254 else
8255 rc = msm_sdcc_vreg_disable(curr_vccq_reg);
8256 if (rc)
8257 goto out;
8258 }
8259
8260 if (curr_vddp_reg) {
8261 if (enable)
8262 rc = msm_sdcc_vreg_enable(curr_vddp_reg);
8263 else
8264 rc = msm_sdcc_vreg_disable(curr_vddp_reg);
8265 if (rc)
8266 goto out;
8267 }
8268 curr->sts = enable;
8269
8270out:
8271 return rc;
8272}
8273
8274static u32 msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
8275{
8276 u32 rc_pin_cfg = 0;
8277 u32 rc_vreg_cfg = 0;
8278 u32 rc = 0;
8279 struct platform_device *pdev;
8280 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8281
8282 pdev = container_of(dv, struct platform_device, dev);
8283
8284 /* setup gpio/pad */
8285 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8286 if (curr_pin_cfg->cfg_sts == !!vdd)
8287 goto setup_vreg;
8288
8289 if (curr_pin_cfg->is_gpio)
8290 rc_pin_cfg = msm_sdcc_setup_gpio(pdev->id, !!vdd);
8291 else
8292 rc_pin_cfg = msm_sdcc_setup_pad(pdev->id, !!vdd);
8293
8294setup_vreg:
8295 /* setup voltage regulators */
8296 rc_vreg_cfg = msm_sdcc_setup_vreg(pdev->id, !!vdd);
8297
8298 if (rc_pin_cfg || rc_vreg_cfg)
8299 rc = rc_pin_cfg ? rc_pin_cfg : rc_vreg_cfg;
8300
8301 return rc;
8302}
8303
8304static void msm_sdcc_sdio_lpm_gpio(struct device *dv, unsigned int active)
8305{
8306 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8307 struct platform_device *pdev;
8308
8309 pdev = container_of(dv, struct platform_device, dev);
8310 /* setup gpio/pad */
8311 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8312
8313 if (curr_pin_cfg->cfg_sts == active)
8314 return;
8315
8316 curr_pin_cfg->sdio_lpm_gpio_cfg = 1;
8317 if (curr_pin_cfg->is_gpio)
8318 msm_sdcc_setup_gpio(pdev->id, active);
8319 else
8320 msm_sdcc_setup_pad(pdev->id, active);
8321 curr_pin_cfg->sdio_lpm_gpio_cfg = 0;
8322}
8323
8324static int msm_sdc3_get_wpswitch(struct device *dev)
8325{
8326 struct platform_device *pdev;
8327 int status;
8328 pdev = container_of(dev, struct platform_device, dev);
8329
8330 status = gpio_request(GPIO_SDC_WP, "SD_WP_Switch");
8331 if (status) {
8332 pr_err("%s:Failed to request GPIO %d\n",
8333 __func__, GPIO_SDC_WP);
8334 } else {
8335 status = gpio_direction_input(GPIO_SDC_WP);
8336 if (!status) {
8337 status = gpio_get_value_cansleep(GPIO_SDC_WP);
8338 pr_info("%s: WP Status for Slot %d = %d\n",
8339 __func__, pdev->id, status);
8340 }
8341 gpio_free(GPIO_SDC_WP);
8342 }
8343 return status;
8344}
8345
8346#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8347int sdc5_register_status_notify(void (*callback)(int, void *),
8348 void *dev_id)
8349{
8350 sdc5_status_notify_cb = callback;
8351 sdc5_status_notify_cb_devid = dev_id;
8352 return 0;
8353}
8354#endif
8355
8356#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8357int sdc2_register_status_notify(void (*callback)(int, void *),
8358 void *dev_id)
8359{
8360 sdc2_status_notify_cb = callback;
8361 sdc2_status_notify_cb_devid = dev_id;
8362 return 0;
8363}
8364#endif
8365
8366/* Interrupt handler for SDC2 and SDC5 detection
8367 * This function uses dual-edge interrputs settings in order
8368 * to get SDIO detection when the GPIO is rising and SDIO removal
8369 * when the GPIO is falling */
8370static irqreturn_t msm8x60_multi_sdio_slot_status_irq(int irq, void *dev_id)
8371{
8372 int status;
8373
8374 if (!machine_is_msm8x60_fusion() &&
8375 !machine_is_msm8x60_fusn_ffa())
8376 return IRQ_NONE;
8377
8378 status = gpio_get_value(MDM2AP_SYNC);
8379 pr_info("%s: MDM2AP_SYNC Status = %d\n",
8380 __func__, status);
8381
8382#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8383 if (sdc2_status_notify_cb) {
8384 pr_info("%s: calling sdc2_status_notify_cb\n", __func__);
8385 sdc2_status_notify_cb(status,
8386 sdc2_status_notify_cb_devid);
8387 }
8388#endif
8389
8390#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8391 if (sdc5_status_notify_cb) {
8392 pr_info("%s: calling sdc5_status_notify_cb\n", __func__);
8393 sdc5_status_notify_cb(status,
8394 sdc5_status_notify_cb_devid);
8395 }
8396#endif
8397 return IRQ_HANDLED;
8398}
8399
8400static int msm8x60_multi_sdio_init(void)
8401{
8402 int ret, irq_num;
8403
8404 if (!machine_is_msm8x60_fusion() &&
8405 !machine_is_msm8x60_fusn_ffa())
8406 return 0;
8407
8408 ret = msm_gpiomux_get(MDM2AP_SYNC);
8409 if (ret) {
8410 pr_err("%s:Failed to request GPIO %d, ret=%d\n",
8411 __func__, MDM2AP_SYNC, ret);
8412 return ret;
8413 }
8414
8415 irq_num = gpio_to_irq(MDM2AP_SYNC);
8416
8417 ret = request_irq(irq_num,
8418 msm8x60_multi_sdio_slot_status_irq,
8419 IRQ_TYPE_EDGE_BOTH,
8420 "sdio_multidetection", NULL);
8421
8422 if (ret) {
8423 pr_err("%s:Failed to request irq, ret=%d\n",
8424 __func__, ret);
8425 return ret;
8426 }
8427
8428 return ret;
8429}
8430
8431#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008432static unsigned int msm8x60_sdcc_slot_status(struct device *dev)
8433{
8434 int status;
8435
8436 status = gpio_request(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)
8437 , "SD_HW_Detect");
8438 if (status) {
8439 pr_err("%s:Failed to request GPIO %d\n", __func__,
8440 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8441 } else {
8442 status = gpio_direction_input(
8443 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8444 if (!status)
8445 status = !(gpio_get_value_cansleep(
8446 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)));
8447 gpio_free(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8448 }
8449 return (unsigned int) status;
8450}
8451#endif
8452#endif
8453
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308454#define MSM_MPM_PIN_SDC3_DAT1 21
Subhash Jadavanife608a22012-04-13 10:45:53 +05308455#define MSM_MPM_PIN_SDC4_DAT1 23
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008456
8457#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8458static struct mmc_platform_data msm8x60_sdc1_data = {
8459 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8460 .translate_vdd = msm_sdcc_setup_power,
8461#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
8462 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8463#else
8464 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8465#endif
8466 .msmsdcc_fmin = 400000,
8467 .msmsdcc_fmid = 24000000,
8468 .msmsdcc_fmax = 48000000,
8469 .nonremovable = 1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308470 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008471};
8472#endif
8473
8474#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8475static struct mmc_platform_data msm8x60_sdc2_data = {
8476 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8477 .translate_vdd = msm_sdcc_setup_power,
8478 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8479 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8480 .msmsdcc_fmin = 400000,
8481 .msmsdcc_fmid = 24000000,
8482 .msmsdcc_fmax = 48000000,
8483 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008484 .register_status_notify = sdc2_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008485#ifdef CONFIG_MSM_SDIO_AL
8486 .is_sdio_al_client = 1,
8487#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308488 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008489};
8490#endif
8491
8492#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8493static struct mmc_platform_data msm8x60_sdc3_data = {
8494 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8495 .translate_vdd = msm_sdcc_setup_power,
8496 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8497 .wpswitch = msm_sdc3_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008498 .status = msm8x60_sdcc_slot_status,
8499 .status_irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
8500 PMIC_GPIO_SDC3_DET - 1),
8501 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008502 .msmsdcc_fmin = 400000,
8503 .msmsdcc_fmid = 24000000,
8504 .msmsdcc_fmax = 48000000,
8505 .nonremovable = 0,
Subhash Jadavani55e188e2012-04-13 11:31:08 +05308506 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC3_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308507 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008508};
8509#endif
8510
8511#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8512static struct mmc_platform_data msm8x60_sdc4_data = {
8513 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8514 .translate_vdd = msm_sdcc_setup_power,
8515 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8516 .msmsdcc_fmin = 400000,
8517 .msmsdcc_fmid = 24000000,
8518 .msmsdcc_fmax = 48000000,
8519 .nonremovable = 0,
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308520 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC4_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308521 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008522};
8523#endif
8524
8525#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8526static struct mmc_platform_data msm8x60_sdc5_data = {
8527 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8528 .translate_vdd = msm_sdcc_setup_power,
8529 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8530 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8531 .msmsdcc_fmin = 400000,
8532 .msmsdcc_fmid = 24000000,
8533 .msmsdcc_fmax = 48000000,
8534 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008535 .register_status_notify = sdc5_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008536#ifdef CONFIG_MSM_SDIO_AL
8537 .is_sdio_al_client = 1,
8538#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308539 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008540};
8541#endif
8542
8543static void __init msm8x60_init_mmc(void)
8544{
8545#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8546 /* SDCC1 : eMMC card connected */
8547 sdcc_vreg_data[0].vdd_data = &sdcc_vdd_reg_data[0];
8548 sdcc_vreg_data[0].vdd_data->reg_name = "8901_l5";
8549 sdcc_vreg_data[0].vdd_data->set_voltage_sup = 1;
8550 sdcc_vreg_data[0].vdd_data->level = 2850000;
Subhash Jadavania8482a32011-08-08 11:01:44 +05308551 sdcc_vreg_data[0].vdd_data->always_on = 1;
8552 sdcc_vreg_data[0].vdd_data->op_pwr_mode_sup = 1;
8553 sdcc_vreg_data[0].vdd_data->lpm_uA = 9000;
8554 sdcc_vreg_data[0].vdd_data->hpm_uA = 200000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008555
8556 sdcc_vreg_data[0].vccq_data = &sdcc_vccq_reg_data[0];
8557 sdcc_vreg_data[0].vccq_data->reg_name = "8901_lvs0";
8558 sdcc_vreg_data[0].vccq_data->set_voltage_sup = 0;
8559 sdcc_vreg_data[0].vccq_data->always_on = 1;
8560
8561 msm_add_sdcc(1, &msm8x60_sdc1_data);
8562#endif
8563#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8564 /*
8565 * MDM SDIO client is connected to SDC2 on charm SURF/FFA
8566 * and no card is connected on 8660 SURF/FFA/FLUID.
8567 */
8568 sdcc_vreg_data[1].vdd_data = &sdcc_vdd_reg_data[1];
8569 sdcc_vreg_data[1].vdd_data->reg_name = "8058_s3";
8570 sdcc_vreg_data[1].vdd_data->set_voltage_sup = 1;
8571 sdcc_vreg_data[1].vdd_data->level = 1800000;
8572
8573 sdcc_vreg_data[1].vccq_data = NULL;
8574
8575 if (machine_is_msm8x60_fusion())
8576 msm8x60_sdc2_data.msmsdcc_fmax = 24000000;
8577 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008578 msm8x60_sdc2_data.sdiowakeup_irq = gpio_to_irq(144);
8579 msm_sdcc_setup_gpio(2, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008580 msm_add_sdcc(2, &msm8x60_sdc2_data);
8581 }
8582#endif
8583#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8584 /* SDCC3 : External card slot connected */
8585 sdcc_vreg_data[2].vdd_data = &sdcc_vdd_reg_data[2];
8586 sdcc_vreg_data[2].vdd_data->reg_name = "8058_l14";
8587 sdcc_vreg_data[2].vdd_data->set_voltage_sup = 1;
8588 sdcc_vreg_data[2].vdd_data->level = 2850000;
8589 sdcc_vreg_data[2].vdd_data->always_on = 1;
8590 sdcc_vreg_data[2].vdd_data->op_pwr_mode_sup = 1;
8591 sdcc_vreg_data[2].vdd_data->lpm_uA = 9000;
8592 sdcc_vreg_data[2].vdd_data->hpm_uA = 200000;
8593
8594 sdcc_vreg_data[2].vccq_data = NULL;
8595
8596 sdcc_vreg_data[2].vddp_data = &sdcc_vddp_reg_data[2];
8597 sdcc_vreg_data[2].vddp_data->reg_name = "8058_l5";
8598 sdcc_vreg_data[2].vddp_data->set_voltage_sup = 1;
8599 sdcc_vreg_data[2].vddp_data->level = 2850000;
8600 sdcc_vreg_data[2].vddp_data->always_on = 1;
8601 sdcc_vreg_data[2].vddp_data->op_pwr_mode_sup = 1;
8602 /* Sleep current required is ~300 uA. But min. RPM
8603 * vote can be in terms of mA (min. 1 mA).
8604 * So let's vote for 2 mA during sleep.
8605 */
8606 sdcc_vreg_data[2].vddp_data->lpm_uA = 2000;
8607 /* Max. Active current required is 16 mA */
8608 sdcc_vreg_data[2].vddp_data->hpm_uA = 16000;
8609
8610 if (machine_is_msm8x60_fluid())
8611 msm8x60_sdc3_data.wpswitch = NULL;
8612 msm_add_sdcc(3, &msm8x60_sdc3_data);
8613#endif
8614#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8615 /* SDCC4 : WLAN WCN1314 chip is connected */
8616 sdcc_vreg_data[3].vdd_data = &sdcc_vdd_reg_data[3];
8617 sdcc_vreg_data[3].vdd_data->reg_name = "8058_s3";
8618 sdcc_vreg_data[3].vdd_data->set_voltage_sup = 1;
8619 sdcc_vreg_data[3].vdd_data->level = 1800000;
8620
8621 sdcc_vreg_data[3].vccq_data = NULL;
8622
8623 msm_add_sdcc(4, &msm8x60_sdc4_data);
8624#endif
8625#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8626 /*
8627 * MDM SDIO client is connected to SDC5 on charm SURF/FFA
8628 * and no card is connected on 8660 SURF/FFA/FLUID.
8629 */
8630 sdcc_vreg_data[4].vdd_data = &sdcc_vdd_reg_data[4];
8631 sdcc_vreg_data[4].vdd_data->reg_name = "8058_s3";
8632 sdcc_vreg_data[4].vdd_data->set_voltage_sup = 1;
8633 sdcc_vreg_data[4].vdd_data->level = 1800000;
8634
8635 sdcc_vreg_data[4].vccq_data = NULL;
8636
8637 if (machine_is_msm8x60_fusion())
8638 msm8x60_sdc5_data.msmsdcc_fmax = 24000000;
8639 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008640 msm8x60_sdc5_data.sdiowakeup_irq = gpio_to_irq(99);
8641 msm_sdcc_setup_gpio(5, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008642 msm_add_sdcc(5, &msm8x60_sdc5_data);
8643 }
8644#endif
8645}
8646
8647#if !defined(CONFIG_GPIO_SX150X) && !defined(CONFIG_GPIO_SX150X_MODULE)
8648static inline void display_common_power(int on) {}
8649#else
8650
8651#define _GET_REGULATOR(var, name) do { \
8652 if (var == NULL) { \
8653 var = regulator_get(NULL, name); \
8654 if (IS_ERR(var)) { \
8655 pr_err("'%s' regulator not found, rc=%ld\n", \
8656 name, PTR_ERR(var)); \
8657 var = NULL; \
8658 } \
8659 } \
8660} while (0)
8661
8662static int dsub_regulator(int on)
8663{
8664 static struct regulator *dsub_reg;
8665 static struct regulator *mpp0_reg;
8666 static int dsub_reg_enabled;
8667 int rc = 0;
8668
8669 _GET_REGULATOR(dsub_reg, "8901_l3");
8670 if (IS_ERR(dsub_reg)) {
8671 printk(KERN_ERR "%s: failed to get reg 8901_l3 err=%ld",
8672 __func__, PTR_ERR(dsub_reg));
8673 return PTR_ERR(dsub_reg);
8674 }
8675
8676 _GET_REGULATOR(mpp0_reg, "8901_mpp0");
8677 if (IS_ERR(mpp0_reg)) {
8678 printk(KERN_ERR "%s: failed to get reg 8901_mpp0 err=%ld",
8679 __func__, PTR_ERR(mpp0_reg));
8680 return PTR_ERR(mpp0_reg);
8681 }
8682
8683 if (on && !dsub_reg_enabled) {
8684 rc = regulator_set_voltage(dsub_reg, 3300000, 3300000);
8685 if (rc) {
8686 printk(KERN_ERR "%s: failed to set reg 8901_l3 voltage"
8687 " err=%d", __func__, rc);
8688 goto dsub_regulator_err;
8689 }
8690 rc = regulator_enable(dsub_reg);
8691 if (rc) {
8692 printk(KERN_ERR "%s: failed to enable reg 8901_l3"
8693 " err=%d", __func__, rc);
8694 goto dsub_regulator_err;
8695 }
8696 rc = regulator_enable(mpp0_reg);
8697 if (rc) {
8698 printk(KERN_ERR "%s: failed to enable reg 8901_mpp0"
8699 " err=%d", __func__, rc);
8700 goto dsub_regulator_err;
8701 }
8702 dsub_reg_enabled = 1;
8703 } else if (!on && dsub_reg_enabled) {
8704 rc = regulator_disable(dsub_reg);
8705 if (rc)
8706 printk(KERN_WARNING "%s: failed to disable reg 8901_l3"
8707 " err=%d", __func__, rc);
8708 rc = regulator_disable(mpp0_reg);
8709 if (rc)
8710 printk(KERN_WARNING "%s: failed to disable reg "
8711 "8901_mpp0 err=%d", __func__, rc);
8712 dsub_reg_enabled = 0;
8713 }
8714
8715 return rc;
8716
8717dsub_regulator_err:
8718 regulator_put(mpp0_reg);
8719 regulator_put(dsub_reg);
8720 return rc;
8721}
8722
8723static int display_power_on;
8724static void setup_display_power(void)
8725{
8726 if (display_power_on)
8727 if (lcdc_vga_enabled) {
8728 dsub_regulator(1);
8729 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8730 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8731 if (machine_is_msm8x60_ffa() ||
8732 machine_is_msm8x60_fusn_ffa())
8733 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 1);
8734 } else {
8735 dsub_regulator(0);
8736 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 1);
8737 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 1);
8738 if (machine_is_msm8x60_ffa() ||
8739 machine_is_msm8x60_fusn_ffa())
8740 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8741 }
8742 else {
8743 dsub_regulator(0);
8744 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
8745 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8746 /* BACKLIGHT */
8747 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8748 /* LVDS */
8749 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8750 }
8751}
8752
8753#define _GET_REGULATOR(var, name) do { \
8754 if (var == NULL) { \
8755 var = regulator_get(NULL, name); \
8756 if (IS_ERR(var)) { \
8757 pr_err("'%s' regulator not found, rc=%ld\n", \
8758 name, PTR_ERR(var)); \
8759 var = NULL; \
8760 } \
8761 } \
8762} while (0)
8763
8764#define GPIO_RESX_N (GPIO_EXPANDER_GPIO_BASE + 2)
8765
8766static void display_common_power(int on)
8767{
8768 int rc;
8769 static struct regulator *display_reg;
8770
8771 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
8772 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8773 if (on) {
8774 /* LVDS */
8775 _GET_REGULATOR(display_reg, "8901_l2");
8776 if (!display_reg)
8777 return;
8778 rc = regulator_set_voltage(display_reg,
8779 3300000, 3300000);
8780 if (rc)
8781 goto out;
8782 rc = regulator_enable(display_reg);
8783 if (rc)
8784 goto out;
8785 rc = gpio_request(GPIO_LVDS_SHUTDOWN_N,
8786 "LVDS_STDN_OUT_N");
8787 if (rc) {
8788 printk(KERN_ERR "%s: LVDS gpio %d request"
8789 "failed\n", __func__,
8790 GPIO_LVDS_SHUTDOWN_N);
8791 goto out2;
8792 }
8793
8794 /* BACKLIGHT */
8795 rc = gpio_request(GPIO_BACKLIGHT_EN, "BACKLIGHT_EN");
8796 if (rc) {
8797 printk(KERN_ERR "%s: BACKLIGHT gpio %d request"
8798 "failed\n", __func__,
8799 GPIO_BACKLIGHT_EN);
8800 goto out3;
8801 }
8802
8803 if (machine_is_msm8x60_ffa() ||
8804 machine_is_msm8x60_fusn_ffa()) {
8805 rc = gpio_request(GPIO_DONGLE_PWR_EN,
8806 "DONGLE_PWR_EN");
8807 if (rc) {
8808 printk(KERN_ERR "%s: DONGLE_PWR_EN gpio"
8809 " %d request failed\n", __func__,
8810 GPIO_DONGLE_PWR_EN);
8811 goto out4;
8812 }
8813 }
8814
8815 gpio_direction_output(GPIO_LVDS_SHUTDOWN_N, 0);
8816 gpio_direction_output(GPIO_BACKLIGHT_EN, 0);
8817 if (machine_is_msm8x60_ffa() ||
8818 machine_is_msm8x60_fusn_ffa())
8819 gpio_direction_output(GPIO_DONGLE_PWR_EN, 0);
8820 mdelay(20);
8821 display_power_on = 1;
8822 setup_display_power();
8823 } else {
8824 if (display_power_on) {
8825 display_power_on = 0;
8826 setup_display_power();
8827 mdelay(20);
8828 if (machine_is_msm8x60_ffa() ||
8829 machine_is_msm8x60_fusn_ffa())
8830 gpio_free(GPIO_DONGLE_PWR_EN);
8831 goto out4;
8832 }
8833 }
8834 }
8835#if defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
8836 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA)
8837 else if (machine_is_msm8x60_fluid()) {
8838 static struct regulator *fluid_reg;
8839 static struct regulator *fluid_reg2;
8840
8841 if (on) {
8842 _GET_REGULATOR(fluid_reg, "8901_l2");
8843 if (!fluid_reg)
8844 return;
8845 _GET_REGULATOR(fluid_reg2, "8058_s3");
8846 if (!fluid_reg2) {
8847 regulator_put(fluid_reg);
8848 return;
8849 }
8850 rc = gpio_request(GPIO_RESX_N, "RESX_N");
8851 if (rc) {
8852 regulator_put(fluid_reg2);
8853 regulator_put(fluid_reg);
8854 return;
8855 }
8856 regulator_set_voltage(fluid_reg, 2850000, 2850000);
8857 regulator_set_voltage(fluid_reg2, 1800000, 1800000);
8858 regulator_enable(fluid_reg);
8859 regulator_enable(fluid_reg2);
8860 msleep(20);
8861 gpio_direction_output(GPIO_RESX_N, 0);
8862 udelay(10);
8863 gpio_set_value_cansleep(GPIO_RESX_N, 1);
8864 display_power_on = 1;
8865 setup_display_power();
8866 } else {
8867 gpio_set_value_cansleep(GPIO_RESX_N, 0);
8868 gpio_free(GPIO_RESX_N);
8869 msleep(20);
8870 regulator_disable(fluid_reg2);
8871 regulator_disable(fluid_reg);
8872 regulator_put(fluid_reg2);
8873 regulator_put(fluid_reg);
8874 display_power_on = 0;
8875 setup_display_power();
8876 fluid_reg = NULL;
8877 fluid_reg2 = NULL;
8878 }
8879 }
8880#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04008881#if defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA)
8882 else if (machine_is_msm8x60_dragon()) {
8883 static struct regulator *dragon_reg;
8884 static struct regulator *dragon_reg2;
8885
8886 if (on) {
8887 _GET_REGULATOR(dragon_reg, "8901_l2");
8888 if (!dragon_reg)
8889 return;
8890 _GET_REGULATOR(dragon_reg2, "8058_l16");
8891 if (!dragon_reg2) {
8892 regulator_put(dragon_reg);
8893 dragon_reg = NULL;
8894 return;
8895 }
8896
8897 rc = gpio_request(GPIO_NT35582_BL_EN, "lcdc_bl_en");
8898 if (rc) {
8899 pr_err("%s: gpio %d request failed with rc=%d\n",
8900 __func__, GPIO_NT35582_BL_EN, rc);
8901 regulator_put(dragon_reg);
8902 regulator_put(dragon_reg2);
8903 dragon_reg = NULL;
8904 dragon_reg2 = NULL;
8905 return;
8906 }
8907
8908 if (gpio_tlmm_config(GPIO_CFG(GPIO_NT35582_RESET, 0,
8909 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
8910 GPIO_CFG_16MA), GPIO_CFG_ENABLE)) {
8911 pr_err("%s: config gpio '%d' failed!\n",
8912 __func__, GPIO_NT35582_RESET);
8913 gpio_free(GPIO_NT35582_BL_EN);
8914 regulator_put(dragon_reg);
8915 regulator_put(dragon_reg2);
8916 dragon_reg = NULL;
8917 dragon_reg2 = NULL;
8918 return;
8919 }
8920
8921 rc = gpio_request(GPIO_NT35582_RESET, "lcdc_reset");
8922 if (rc) {
8923 pr_err("%s: unable to request gpio %d (rc=%d)\n",
8924 __func__, GPIO_NT35582_RESET, rc);
8925 gpio_free(GPIO_NT35582_BL_EN);
8926 regulator_put(dragon_reg);
8927 regulator_put(dragon_reg2);
8928 dragon_reg = NULL;
8929 dragon_reg2 = NULL;
8930 return;
8931 }
8932
8933 regulator_set_voltage(dragon_reg, 3300000, 3300000);
8934 regulator_set_voltage(dragon_reg2, 1800000, 1800000);
8935 regulator_enable(dragon_reg);
8936 regulator_enable(dragon_reg2);
8937 msleep(20);
8938
8939 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8940 msleep(20);
8941 gpio_set_value_cansleep(GPIO_NT35582_RESET, 0);
8942 msleep(20);
8943 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8944 msleep(50);
8945
8946 gpio_set_value_cansleep(GPIO_NT35582_BL_EN, 1);
8947
8948 display_power_on = 1;
8949 } else if ((dragon_reg != NULL) && (dragon_reg2 != NULL)) {
8950 gpio_free(GPIO_NT35582_RESET);
8951 gpio_free(GPIO_NT35582_BL_EN);
8952 regulator_disable(dragon_reg2);
8953 regulator_disable(dragon_reg);
8954 regulator_put(dragon_reg2);
8955 regulator_put(dragon_reg);
8956 display_power_on = 0;
8957 dragon_reg = NULL;
8958 dragon_reg2 = NULL;
8959 }
8960 }
8961#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008962 return;
8963
8964out4:
8965 gpio_free(GPIO_BACKLIGHT_EN);
8966out3:
8967 gpio_free(GPIO_LVDS_SHUTDOWN_N);
8968out2:
8969 regulator_disable(display_reg);
8970out:
8971 regulator_put(display_reg);
8972 display_reg = NULL;
8973}
8974#undef _GET_REGULATOR
8975#endif
8976
8977static int mipi_dsi_panel_power(int on);
8978
8979#define LCDC_NUM_GPIO 28
8980#define LCDC_GPIO_START 0
8981
8982static void lcdc_samsung_panel_power(int on)
8983{
8984 int n, ret = 0;
8985
8986 display_common_power(on);
8987
8988 for (n = 0; n < LCDC_NUM_GPIO; n++) {
8989 if (on) {
8990 ret = gpio_request(LCDC_GPIO_START + n, "LCDC_GPIO");
8991 if (unlikely(ret)) {
8992 pr_err("%s not able to get gpio\n", __func__);
8993 break;
8994 }
8995 } else
8996 gpio_free(LCDC_GPIO_START + n);
8997 }
8998
8999 if (ret) {
9000 for (n--; n >= 0; n--)
9001 gpio_free(LCDC_GPIO_START + n);
9002 }
9003
9004 mipi_dsi_panel_power(0); /* set 8058_ldo0 to LPM */
9005}
9006
9007#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
9008#define _GET_REGULATOR(var, name) do { \
9009 var = regulator_get(NULL, name); \
9010 if (IS_ERR(var)) { \
9011 pr_err("'%s' regulator not found, rc=%ld\n", \
9012 name, IS_ERR(var)); \
9013 var = NULL; \
9014 return -ENODEV; \
9015 } \
9016} while (0)
9017
9018static int hdmi_enable_5v(int on)
9019{
9020 static struct regulator *reg_8901_hdmi_mvs; /* HDMI_5V */
9021 static struct regulator *reg_8901_mpp0; /* External 5V */
9022 static int prev_on;
9023 int rc;
9024
9025 if (on == prev_on)
9026 return 0;
9027
9028 if (!reg_8901_hdmi_mvs)
9029 _GET_REGULATOR(reg_8901_hdmi_mvs, "8901_hdmi_mvs");
9030 if (!reg_8901_mpp0)
9031 _GET_REGULATOR(reg_8901_mpp0, "8901_mpp0");
9032
9033 if (on) {
9034 rc = regulator_enable(reg_8901_mpp0);
9035 if (rc) {
9036 pr_err("'%s' regulator enable failed, rc=%d\n",
9037 "reg_8901_mpp0", rc);
9038 return rc;
9039 }
9040 rc = regulator_enable(reg_8901_hdmi_mvs);
9041 if (rc) {
9042 pr_err("'%s' regulator enable failed, rc=%d\n",
9043 "8901_hdmi_mvs", rc);
9044 return rc;
9045 }
9046 pr_info("%s(on): success\n", __func__);
9047 } else {
9048 rc = regulator_disable(reg_8901_hdmi_mvs);
9049 if (rc)
9050 pr_warning("'%s' regulator disable failed, rc=%d\n",
9051 "8901_hdmi_mvs", rc);
9052 rc = regulator_disable(reg_8901_mpp0);
9053 if (rc)
9054 pr_warning("'%s' regulator disable failed, rc=%d\n",
9055 "reg_8901_mpp0", rc);
9056 pr_info("%s(off): success\n", __func__);
9057 }
9058
9059 prev_on = on;
9060
9061 return 0;
9062}
9063
9064static int hdmi_core_power(int on, int show)
9065{
9066 static struct regulator *reg_8058_l16; /* VDD_HDMI */
9067 static int prev_on;
9068 int rc;
9069
9070 if (on == prev_on)
9071 return 0;
9072
9073 if (!reg_8058_l16)
9074 _GET_REGULATOR(reg_8058_l16, "8058_l16");
9075
9076 if (on) {
9077 rc = regulator_set_voltage(reg_8058_l16, 1800000, 1800000);
9078 if (!rc)
9079 rc = regulator_enable(reg_8058_l16);
9080 if (rc) {
9081 pr_err("'%s' regulator enable failed, rc=%d\n",
9082 "8058_l16", rc);
9083 return rc;
9084 }
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309085 pr_debug("%s(on): success\n", __func__);
9086 } else {
9087 rc = regulator_disable(reg_8058_l16);
9088 if (rc)
9089 pr_warning("'%s' regulator disable failed, rc=%d\n",
9090 "8058_l16", rc);
9091 pr_debug("%s(off): success\n", __func__);
9092 }
9093
9094 prev_on = on;
9095
9096 return 0;
9097}
9098
9099static int hdmi_gpio_config(int on)
9100{
9101 int rc = 0;
9102 static int prev_on;
9103
9104 if (on == prev_on)
9105 return 0;
9106
9107 if (on) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009108 rc = gpio_request(170, "HDMI_DDC_CLK");
9109 if (rc) {
9110 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9111 "HDMI_DDC_CLK", 170, rc);
9112 goto error1;
9113 }
9114 rc = gpio_request(171, "HDMI_DDC_DATA");
9115 if (rc) {
9116 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9117 "HDMI_DDC_DATA", 171, rc);
9118 goto error2;
9119 }
9120 rc = gpio_request(172, "HDMI_HPD");
9121 if (rc) {
9122 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9123 "HDMI_HPD", 172, rc);
9124 goto error3;
9125 }
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309126 pr_debug("%s(on): success\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009127 } else {
9128 gpio_free(170);
9129 gpio_free(171);
9130 gpio_free(172);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309131 pr_debug("%s(off): success\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009132 }
9133
9134 prev_on = on;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009135 return 0;
9136
9137error3:
9138 gpio_free(171);
9139error2:
9140 gpio_free(170);
9141error1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009142 return rc;
9143}
9144
9145static int hdmi_cec_power(int on)
9146{
9147 static struct regulator *reg_8901_l3; /* HDMI_CEC */
9148 static int prev_on;
9149 int rc;
9150
9151 if (on == prev_on)
9152 return 0;
9153
9154 if (!reg_8901_l3)
9155 _GET_REGULATOR(reg_8901_l3, "8901_l3");
9156
9157 if (on) {
9158 rc = regulator_set_voltage(reg_8901_l3, 3300000, 3300000);
9159 if (!rc)
9160 rc = regulator_enable(reg_8901_l3);
9161 if (rc) {
9162 pr_err("'%s' regulator enable failed, rc=%d\n",
9163 "8901_l3", rc);
9164 return rc;
9165 }
9166 rc = gpio_request(169, "HDMI_CEC_VAR");
9167 if (rc) {
9168 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9169 "HDMI_CEC_VAR", 169, rc);
9170 goto error;
9171 }
9172 pr_info("%s(on): success\n", __func__);
9173 } else {
9174 gpio_free(169);
9175 rc = regulator_disable(reg_8901_l3);
9176 if (rc)
9177 pr_warning("'%s' regulator disable failed, rc=%d\n",
9178 "8901_l3", rc);
9179 pr_info("%s(off): success\n", __func__);
9180 }
9181
9182 prev_on = on;
9183
9184 return 0;
9185error:
9186 regulator_disable(reg_8901_l3);
9187 return rc;
9188}
9189
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309190static int hdmi_panel_power(int on)
9191{
9192 int rc;
9193
9194 pr_debug("%s: HDMI Core: %s\n", __func__, (on ? "ON" : "OFF"));
9195 rc = hdmi_core_power(on, 1);
9196 if (rc)
9197 rc = hdmi_cec_power(on);
9198
9199 pr_debug("%s: HDMI Core: %s Success\n", __func__, (on ? "ON" : "OFF"));
9200 return rc;
9201}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009202#undef _GET_REGULATOR
9203
9204#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
9205
9206static int lcdc_panel_power(int on)
9207{
9208 int flag_on = !!on;
9209 static int lcdc_power_save_on;
9210
9211 if (lcdc_power_save_on == flag_on)
9212 return 0;
9213
9214 lcdc_power_save_on = flag_on;
9215
9216 lcdc_samsung_panel_power(on);
9217
9218 return 0;
9219}
9220
9221#ifdef CONFIG_MSM_BUS_SCALING
Nagamalleswararao Ganji5fabbd62011-11-06 23:10:43 -08009222
9223static struct msm_bus_vectors rotator_init_vectors[] = {
9224 {
9225 .src = MSM_BUS_MASTER_ROTATOR,
9226 .dst = MSM_BUS_SLAVE_SMI,
9227 .ab = 0,
9228 .ib = 0,
9229 },
9230 {
9231 .src = MSM_BUS_MASTER_ROTATOR,
9232 .dst = MSM_BUS_SLAVE_EBI_CH0,
9233 .ab = 0,
9234 .ib = 0,
9235 },
9236};
9237
9238static struct msm_bus_vectors rotator_ui_vectors[] = {
9239 {
9240 .src = MSM_BUS_MASTER_ROTATOR,
9241 .dst = MSM_BUS_SLAVE_SMI,
9242 .ab = 0,
9243 .ib = 0,
9244 },
9245 {
9246 .src = MSM_BUS_MASTER_ROTATOR,
9247 .dst = MSM_BUS_SLAVE_EBI_CH0,
9248 .ab = (1024 * 600 * 4 * 2 * 60),
9249 .ib = (1024 * 600 * 4 * 2 * 60 * 1.5),
9250 },
9251};
9252
9253static struct msm_bus_vectors rotator_vga_vectors[] = {
9254 {
9255 .src = MSM_BUS_MASTER_ROTATOR,
9256 .dst = MSM_BUS_SLAVE_SMI,
9257 .ab = (640 * 480 * 2 * 2 * 30),
9258 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9259 },
9260 {
9261 .src = MSM_BUS_MASTER_ROTATOR,
9262 .dst = MSM_BUS_SLAVE_EBI_CH0,
9263 .ab = (640 * 480 * 2 * 2 * 30),
9264 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9265 },
9266};
9267
9268static struct msm_bus_vectors rotator_720p_vectors[] = {
9269 {
9270 .src = MSM_BUS_MASTER_ROTATOR,
9271 .dst = MSM_BUS_SLAVE_SMI,
9272 .ab = (1280 * 736 * 2 * 2 * 30),
9273 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9274 },
9275 {
9276 .src = MSM_BUS_MASTER_ROTATOR,
9277 .dst = MSM_BUS_SLAVE_EBI_CH0,
9278 .ab = (1280 * 736 * 2 * 2 * 30),
9279 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9280 },
9281};
9282
9283static struct msm_bus_vectors rotator_1080p_vectors[] = {
9284 {
9285 .src = MSM_BUS_MASTER_ROTATOR,
9286 .dst = MSM_BUS_SLAVE_SMI,
9287 .ab = (1920 * 1088 * 2 * 2 * 30),
9288 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9289 },
9290 {
9291 .src = MSM_BUS_MASTER_ROTATOR,
9292 .dst = MSM_BUS_SLAVE_EBI_CH0,
9293 .ab = (1920 * 1088 * 2 * 2 * 30),
9294 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9295 },
9296};
9297
9298static struct msm_bus_paths rotator_bus_scale_usecases[] = {
9299 {
9300 ARRAY_SIZE(rotator_init_vectors),
9301 rotator_init_vectors,
9302 },
9303 {
9304 ARRAY_SIZE(rotator_ui_vectors),
9305 rotator_ui_vectors,
9306 },
9307 {
9308 ARRAY_SIZE(rotator_vga_vectors),
9309 rotator_vga_vectors,
9310 },
9311 {
9312 ARRAY_SIZE(rotator_720p_vectors),
9313 rotator_720p_vectors,
9314 },
9315 {
9316 ARRAY_SIZE(rotator_1080p_vectors),
9317 rotator_1080p_vectors,
9318 },
9319};
9320
9321struct msm_bus_scale_pdata rotator_bus_scale_pdata = {
9322 rotator_bus_scale_usecases,
9323 ARRAY_SIZE(rotator_bus_scale_usecases),
9324 .name = "rotator",
9325};
9326
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009327static struct msm_bus_vectors mdp_init_vectors[] = {
9328 /* For now, 0th array entry is reserved.
9329 * Please leave 0 as is and don't use it
9330 */
9331 {
9332 .src = MSM_BUS_MASTER_MDP_PORT0,
9333 .dst = MSM_BUS_SLAVE_SMI,
9334 .ab = 0,
9335 .ib = 0,
9336 },
9337 /* Master and slaves can be from different fabrics */
9338 {
9339 .src = MSM_BUS_MASTER_MDP_PORT0,
9340 .dst = MSM_BUS_SLAVE_EBI_CH0,
9341 .ab = 0,
9342 .ib = 0,
9343 },
9344};
9345
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009346#ifdef CONFIG_FB_MSM_LCDC_DSUB
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009347static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9348 /* Default case static display/UI/2d/3d if FB SMI */
9349 {
9350 .src = MSM_BUS_MASTER_MDP_PORT0,
9351 .dst = MSM_BUS_SLAVE_SMI,
9352 .ab = 388800000,
9353 .ib = 486000000,
9354 },
9355 /* Master and slaves can be from different fabrics */
9356 {
9357 .src = MSM_BUS_MASTER_MDP_PORT0,
9358 .dst = MSM_BUS_SLAVE_EBI_CH0,
9359 .ab = 0,
9360 .ib = 0,
9361 },
9362};
9363
9364static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9365 /* Default case static display/UI/2d/3d if FB SMI */
9366 {
9367 .src = MSM_BUS_MASTER_MDP_PORT0,
9368 .dst = MSM_BUS_SLAVE_SMI,
9369 .ab = 0,
9370 .ib = 0,
9371 },
9372 /* Master and slaves can be from different fabrics */
9373 {
9374 .src = MSM_BUS_MASTER_MDP_PORT0,
9375 .dst = MSM_BUS_SLAVE_EBI_CH0,
9376 .ab = 388800000,
9377 .ib = 486000000 * 2,
9378 },
9379};
9380static struct msm_bus_vectors mdp_vga_vectors[] = {
9381 /* VGA and less video */
9382 {
9383 .src = MSM_BUS_MASTER_MDP_PORT0,
9384 .dst = MSM_BUS_SLAVE_SMI,
9385 .ab = 458092800,
9386 .ib = 572616000,
9387 },
9388 {
9389 .src = MSM_BUS_MASTER_MDP_PORT0,
9390 .dst = MSM_BUS_SLAVE_EBI_CH0,
9391 .ab = 458092800,
9392 .ib = 572616000 * 2,
9393 },
9394};
9395static struct msm_bus_vectors mdp_720p_vectors[] = {
9396 /* 720p and less video */
9397 {
9398 .src = MSM_BUS_MASTER_MDP_PORT0,
9399 .dst = MSM_BUS_SLAVE_SMI,
9400 .ab = 471744000,
9401 .ib = 589680000,
9402 },
9403 /* Master and slaves can be from different fabrics */
9404 {
9405 .src = MSM_BUS_MASTER_MDP_PORT0,
9406 .dst = MSM_BUS_SLAVE_EBI_CH0,
9407 .ab = 471744000,
9408 .ib = 589680000 * 2,
9409 },
9410};
9411
9412static struct msm_bus_vectors mdp_1080p_vectors[] = {
9413 /* 1080p and less video */
9414 {
9415 .src = MSM_BUS_MASTER_MDP_PORT0,
9416 .dst = MSM_BUS_SLAVE_SMI,
9417 .ab = 575424000,
9418 .ib = 719280000,
9419 },
9420 /* Master and slaves can be from different fabrics */
9421 {
9422 .src = MSM_BUS_MASTER_MDP_PORT0,
9423 .dst = MSM_BUS_SLAVE_EBI_CH0,
9424 .ab = 575424000,
9425 .ib = 719280000 * 2,
9426 },
9427};
9428
9429#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009430static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9431 /* Default case static display/UI/2d/3d if FB SMI */
9432 {
9433 .src = MSM_BUS_MASTER_MDP_PORT0,
9434 .dst = MSM_BUS_SLAVE_SMI,
9435 .ab = 175110000,
9436 .ib = 218887500,
9437 },
9438 /* Master and slaves can be from different fabrics */
9439 {
9440 .src = MSM_BUS_MASTER_MDP_PORT0,
9441 .dst = MSM_BUS_SLAVE_EBI_CH0,
9442 .ab = 0,
9443 .ib = 0,
9444 },
9445};
9446
9447static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9448 /* Default case static display/UI/2d/3d if FB SMI */
9449 {
9450 .src = MSM_BUS_MASTER_MDP_PORT0,
9451 .dst = MSM_BUS_SLAVE_SMI,
9452 .ab = 0,
9453 .ib = 0,
9454 },
9455 /* Master and slaves can be from different fabrics */
9456 {
9457 .src = MSM_BUS_MASTER_MDP_PORT0,
9458 .dst = MSM_BUS_SLAVE_EBI_CH0,
9459 .ab = 216000000,
9460 .ib = 270000000 * 2,
9461 },
9462};
9463static struct msm_bus_vectors mdp_vga_vectors[] = {
9464 /* VGA and less video */
9465 {
9466 .src = MSM_BUS_MASTER_MDP_PORT0,
9467 .dst = MSM_BUS_SLAVE_SMI,
9468 .ab = 216000000,
9469 .ib = 270000000,
9470 },
9471 {
9472 .src = MSM_BUS_MASTER_MDP_PORT0,
9473 .dst = MSM_BUS_SLAVE_EBI_CH0,
9474 .ab = 216000000,
9475 .ib = 270000000 * 2,
9476 },
9477};
9478
9479static struct msm_bus_vectors mdp_720p_vectors[] = {
9480 /* 720p and less video */
9481 {
9482 .src = MSM_BUS_MASTER_MDP_PORT0,
9483 .dst = MSM_BUS_SLAVE_SMI,
9484 .ab = 230400000,
9485 .ib = 288000000,
9486 },
9487 /* Master and slaves can be from different fabrics */
9488 {
9489 .src = MSM_BUS_MASTER_MDP_PORT0,
9490 .dst = MSM_BUS_SLAVE_EBI_CH0,
9491 .ab = 230400000,
9492 .ib = 288000000 * 2,
9493 },
9494};
9495
9496static struct msm_bus_vectors mdp_1080p_vectors[] = {
9497 /* 1080p and less video */
9498 {
9499 .src = MSM_BUS_MASTER_MDP_PORT0,
9500 .dst = MSM_BUS_SLAVE_SMI,
9501 .ab = 334080000,
9502 .ib = 417600000,
9503 },
9504 /* Master and slaves can be from different fabrics */
9505 {
9506 .src = MSM_BUS_MASTER_MDP_PORT0,
9507 .dst = MSM_BUS_SLAVE_EBI_CH0,
9508 .ab = 334080000,
Ravishangar Kalyanam731beb92011-07-07 18:27:32 -07009509 .ib = 550000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009510 },
9511};
9512
9513#endif
9514static struct msm_bus_paths mdp_bus_scale_usecases[] = {
9515 {
9516 ARRAY_SIZE(mdp_init_vectors),
9517 mdp_init_vectors,
9518 },
9519 {
9520 ARRAY_SIZE(mdp_sd_smi_vectors),
9521 mdp_sd_smi_vectors,
9522 },
9523 {
9524 ARRAY_SIZE(mdp_sd_ebi_vectors),
9525 mdp_sd_ebi_vectors,
9526 },
9527 {
9528 ARRAY_SIZE(mdp_vga_vectors),
9529 mdp_vga_vectors,
9530 },
9531 {
9532 ARRAY_SIZE(mdp_720p_vectors),
9533 mdp_720p_vectors,
9534 },
9535 {
9536 ARRAY_SIZE(mdp_1080p_vectors),
9537 mdp_1080p_vectors,
9538 },
9539};
9540static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
9541 mdp_bus_scale_usecases,
9542 ARRAY_SIZE(mdp_bus_scale_usecases),
9543 .name = "mdp",
9544};
9545
9546#endif
9547#ifdef CONFIG_MSM_BUS_SCALING
9548static struct msm_bus_vectors dtv_bus_init_vectors[] = {
9549 /* For now, 0th array entry is reserved.
9550 * Please leave 0 as is and don't use it
9551 */
9552 {
9553 .src = MSM_BUS_MASTER_MDP_PORT0,
9554 .dst = MSM_BUS_SLAVE_SMI,
9555 .ab = 0,
9556 .ib = 0,
9557 },
9558 /* Master and slaves can be from different fabrics */
9559 {
9560 .src = MSM_BUS_MASTER_MDP_PORT0,
9561 .dst = MSM_BUS_SLAVE_EBI_CH0,
9562 .ab = 0,
9563 .ib = 0,
9564 },
9565};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009566
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009567static struct msm_bus_vectors dtv_bus_def_vectors[] = {
9568 /* For now, 0th array entry is reserved.
9569 * Please leave 0 as is and don't use it
9570 */
9571 {
9572 .src = MSM_BUS_MASTER_MDP_PORT0,
9573 .dst = MSM_BUS_SLAVE_SMI,
9574 .ab = 566092800,
9575 .ib = 707616000,
9576 },
9577 /* Master and slaves can be from different fabrics */
9578 {
9579 .src = MSM_BUS_MASTER_MDP_PORT0,
9580 .dst = MSM_BUS_SLAVE_EBI_CH0,
9581 .ab = 566092800,
9582 .ib = 707616000,
9583 },
9584};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009585
9586static struct msm_bus_vectors dtv_bus_hdmi_prim_vectors[] = {
9587 /* For now, 0th array entry is reserved.
9588 * Please leave 0 as is and don't use it
9589 */
9590 {
9591 .src = MSM_BUS_MASTER_MDP_PORT0,
9592 .dst = MSM_BUS_SLAVE_SMI,
9593 .ab = 2000000000,
9594 .ib = 2000000000,
9595 },
9596 /* Master and slaves can be from different fabrics */
9597 {
9598 .src = MSM_BUS_MASTER_MDP_PORT0,
9599 .dst = MSM_BUS_SLAVE_EBI_CH0,
9600 .ab = 2000000000,
9601 .ib = 2000000000,
9602 },
9603};
9604
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009605static struct msm_bus_paths dtv_bus_scale_usecases[] = {
9606 {
9607 ARRAY_SIZE(dtv_bus_init_vectors),
9608 dtv_bus_init_vectors,
9609 },
9610 {
9611 ARRAY_SIZE(dtv_bus_def_vectors),
9612 dtv_bus_def_vectors,
9613 },
9614};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009615
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009616static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
9617 dtv_bus_scale_usecases,
9618 ARRAY_SIZE(dtv_bus_scale_usecases),
9619 .name = "dtv",
9620};
9621
9622static struct lcdc_platform_data dtv_pdata = {
9623 .bus_scale_table = &dtv_bus_scale_pdata,
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309624 .lcdc_power_save = hdmi_panel_power,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009625};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009626
9627static struct msm_bus_paths dtv_hdmi_prim_bus_scale_usecases[] = {
9628 {
9629 ARRAY_SIZE(dtv_bus_init_vectors),
9630 dtv_bus_init_vectors,
9631 },
9632 {
9633 ARRAY_SIZE(dtv_bus_hdmi_prim_vectors),
9634 dtv_bus_hdmi_prim_vectors,
9635 },
9636};
9637
9638static struct msm_bus_scale_pdata dtv_hdmi_prim_bus_scale_pdata = {
9639 dtv_hdmi_prim_bus_scale_usecases,
9640 ARRAY_SIZE(dtv_hdmi_prim_bus_scale_usecases),
9641 .name = "dtv",
9642};
9643
9644static struct lcdc_platform_data dtv_hdmi_prim_pdata = {
9645 .bus_scale_table = &dtv_hdmi_prim_bus_scale_pdata,
9646};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009647#endif
9648
9649
9650static struct lcdc_platform_data lcdc_pdata = {
9651 .lcdc_power_save = lcdc_panel_power,
9652};
9653
9654
9655#define MDP_VSYNC_GPIO 28
9656
9657/*
9658 * MIPI_DSI only use 8058_LDO0 which need always on
9659 * therefore it need to be put at low power mode if
9660 * it was not used instead of turn it off.
9661 */
9662static int mipi_dsi_panel_power(int on)
9663{
9664 int flag_on = !!on;
9665 static int mipi_dsi_power_save_on;
9666 static struct regulator *ldo0;
9667 int rc = 0;
9668
9669 if (mipi_dsi_power_save_on == flag_on)
9670 return 0;
9671
9672 mipi_dsi_power_save_on = flag_on;
9673
9674 if (ldo0 == NULL) { /* init */
9675 ldo0 = regulator_get(NULL, "8058_l0");
9676 if (IS_ERR(ldo0)) {
9677 pr_debug("%s: LDO0 failed\n", __func__);
9678 rc = PTR_ERR(ldo0);
9679 return rc;
9680 }
9681
9682 rc = regulator_set_voltage(ldo0, 1200000, 1200000);
9683 if (rc)
9684 goto out;
9685
9686 rc = regulator_enable(ldo0);
9687 if (rc)
9688 goto out;
9689 }
9690
9691 if (on) {
9692 /* set ldo0 to HPM */
9693 rc = regulator_set_optimum_mode(ldo0, 100000);
9694 if (rc < 0)
9695 goto out;
9696 } else {
9697 /* set ldo0 to LPM */
Padmanabhan Komanduru0b478ff2011-11-22 19:15:40 +05309698 rc = regulator_set_optimum_mode(ldo0, 1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009699 if (rc < 0)
9700 goto out;
9701 }
9702
9703 return 0;
9704out:
9705 regulator_disable(ldo0);
9706 regulator_put(ldo0);
9707 ldo0 = NULL;
9708 return rc;
9709}
9710
9711static struct mipi_dsi_platform_data mipi_dsi_pdata = {
9712 .vsync_gpio = MDP_VSYNC_GPIO,
9713 .dsi_power_save = mipi_dsi_panel_power,
9714};
9715
9716#ifdef CONFIG_FB_MSM_TVOUT
9717static struct regulator *reg_8058_l13;
9718
9719static int atv_dac_power(int on)
9720{
9721 int rc = 0;
9722 #define _GET_REGULATOR(var, name) do { \
9723 var = regulator_get(NULL, name); \
9724 if (IS_ERR(var)) { \
9725 pr_info("'%s' regulator not found, rc=%ld\n", \
9726 name, IS_ERR(var)); \
9727 var = NULL; \
9728 return -ENODEV; \
9729 } \
9730 } while (0)
9731
9732 if (!reg_8058_l13)
9733 _GET_REGULATOR(reg_8058_l13, "8058_l13");
9734 #undef _GET_REGULATOR
9735
9736 if (on) {
9737 rc = regulator_set_voltage(reg_8058_l13, 2050000, 2050000);
9738 if (rc) {
9739 pr_info("%s: '%s' regulator set voltage failed,\
9740 rc=%d\n", __func__, "8058_l13", rc);
9741 return rc;
9742 }
9743
9744 rc = regulator_enable(reg_8058_l13);
9745 if (rc) {
9746 pr_err("%s: '%s' regulator enable failed,\
9747 rc=%d\n", __func__, "8058_l13", rc);
9748 return rc;
9749 }
9750 } else {
9751 rc = regulator_force_disable(reg_8058_l13);
9752 if (rc)
9753 pr_warning("%s: '%s' regulator disable failed, rc=%d\n",
9754 __func__, "8058_l13", rc);
9755 }
9756 return rc;
9757
9758}
9759#endif
9760
9761#ifdef CONFIG_FB_MSM_MIPI_DSI
9762int mdp_core_clk_rate_table[] = {
9763 85330000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -08009764 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009765 160000000,
9766 200000000,
9767};
9768#else
9769int mdp_core_clk_rate_table[] = {
9770 59080000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -08009771 128000000,
kuogee hsieh26791a92011-08-01 18:35:58 -07009772 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009773 200000000,
9774};
9775#endif
9776
9777static struct msm_panel_common_pdata mdp_pdata = {
9778 .gpio = MDP_VSYNC_GPIO,
9779 .mdp_core_clk_rate = 59080000,
9780 .mdp_core_clk_table = mdp_core_clk_rate_table,
9781 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
9782#ifdef CONFIG_MSM_BUS_SCALING
9783 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
9784#endif
9785 .mdp_rev = MDP_REV_41,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009786#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Ravishangar Kalyanama3b168b2012-03-26 11:13:11 -07009787 .mem_hid = BIT(ION_CP_WB_HEAP_ID),
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009788#else
9789 .mem_hid = MEMTYPE_EBI1,
9790#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009791};
9792
Huaibin Yanga5419422011-12-08 23:52:10 -08009793static void __init reserve_mdp_memory(void)
9794{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009795 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
9796 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
9797#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
9798 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9799 mdp_pdata.ov0_wb_size;
9800 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9801 mdp_pdata.ov1_wb_size;
9802#endif
Huaibin Yanga5419422011-12-08 23:52:10 -08009803}
9804
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009805#ifdef CONFIG_FB_MSM_TVOUT
9806
9807#ifdef CONFIG_MSM_BUS_SCALING
9808static struct msm_bus_vectors atv_bus_init_vectors[] = {
9809 /* For now, 0th array entry is reserved.
9810 * Please leave 0 as is and don't use it
9811 */
9812 {
9813 .src = MSM_BUS_MASTER_MDP_PORT0,
9814 .dst = MSM_BUS_SLAVE_SMI,
9815 .ab = 0,
9816 .ib = 0,
9817 },
9818 /* Master and slaves can be from different fabrics */
9819 {
9820 .src = MSM_BUS_MASTER_MDP_PORT0,
9821 .dst = MSM_BUS_SLAVE_EBI_CH0,
9822 .ab = 0,
9823 .ib = 0,
9824 },
9825};
9826static struct msm_bus_vectors atv_bus_def_vectors[] = {
9827 /* For now, 0th array entry is reserved.
9828 * Please leave 0 as is and don't use it
9829 */
9830 {
9831 .src = MSM_BUS_MASTER_MDP_PORT0,
9832 .dst = MSM_BUS_SLAVE_SMI,
9833 .ab = 236390400,
9834 .ib = 265939200,
9835 },
9836 /* Master and slaves can be from different fabrics */
9837 {
9838 .src = MSM_BUS_MASTER_MDP_PORT0,
9839 .dst = MSM_BUS_SLAVE_EBI_CH0,
9840 .ab = 236390400,
9841 .ib = 265939200,
9842 },
9843};
9844static struct msm_bus_paths atv_bus_scale_usecases[] = {
9845 {
9846 ARRAY_SIZE(atv_bus_init_vectors),
9847 atv_bus_init_vectors,
9848 },
9849 {
9850 ARRAY_SIZE(atv_bus_def_vectors),
9851 atv_bus_def_vectors,
9852 },
9853};
9854static struct msm_bus_scale_pdata atv_bus_scale_pdata = {
9855 atv_bus_scale_usecases,
9856 ARRAY_SIZE(atv_bus_scale_usecases),
9857 .name = "atv",
9858};
9859#endif
9860
9861static struct tvenc_platform_data atv_pdata = {
9862 .poll = 0,
9863 .pm_vid_en = atv_dac_power,
9864#ifdef CONFIG_MSM_BUS_SCALING
9865 .bus_scale_table = &atv_bus_scale_pdata,
9866#endif
9867};
9868#endif
9869
9870static void __init msm_fb_add_devices(void)
9871{
9872#ifdef CONFIG_FB_MSM_LCDC_DSUB
9873 mdp_pdata.mdp_core_clk_table = NULL;
9874 mdp_pdata.num_mdp_clk = 0;
9875 mdp_pdata.mdp_core_clk_rate = 200000000;
9876#endif
9877 if (machine_is_msm8x60_rumi3())
9878 msm_fb_register_device("mdp", NULL);
9879 else
9880 msm_fb_register_device("mdp", &mdp_pdata);
9881
9882 msm_fb_register_device("lcdc", &lcdc_pdata);
9883 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
9884#ifdef CONFIG_MSM_BUS_SCALING
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009885 if (hdmi_is_primary)
9886 msm_fb_register_device("dtv", &dtv_hdmi_prim_pdata);
9887 else
9888 msm_fb_register_device("dtv", &dtv_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009889#endif
9890#ifdef CONFIG_FB_MSM_TVOUT
9891 msm_fb_register_device("tvenc", &atv_pdata);
9892 msm_fb_register_device("tvout_device", NULL);
9893#endif
9894}
9895
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07009896/**
9897 * Set MDP clocks to high frequency to avoid underflow when
9898 * using high resolution 1200x1920 WUXGA/HDMI as primary panels
9899 */
9900static void set_mdp_clocks_for_wuxga(void)
9901{
9902 int i;
9903
9904 mdp_sd_smi_vectors[0].ab = 2000000000;
9905 mdp_sd_smi_vectors[0].ib = 2000000000;
9906 mdp_sd_smi_vectors[1].ab = 2000000000;
9907 mdp_sd_smi_vectors[1].ib = 2000000000;
9908
9909 mdp_sd_ebi_vectors[0].ab = 2000000000;
9910 mdp_sd_ebi_vectors[0].ib = 2000000000;
9911 mdp_sd_ebi_vectors[1].ab = 2000000000;
9912 mdp_sd_ebi_vectors[1].ib = 2000000000;
9913
9914 mdp_vga_vectors[0].ab = 2000000000;
9915 mdp_vga_vectors[0].ib = 2000000000;
9916 mdp_vga_vectors[1].ab = 2000000000;
9917 mdp_vga_vectors[1].ib = 2000000000;
9918
9919 mdp_720p_vectors[0].ab = 2000000000;
9920 mdp_720p_vectors[0].ib = 2000000000;
9921 mdp_720p_vectors[1].ab = 2000000000;
9922 mdp_720p_vectors[1].ib = 2000000000;
9923
9924 mdp_1080p_vectors[0].ab = 2000000000;
9925 mdp_1080p_vectors[0].ib = 2000000000;
9926 mdp_1080p_vectors[1].ab = 2000000000;
9927 mdp_1080p_vectors[1].ib = 2000000000;
9928
9929 mdp_pdata.mdp_core_clk_rate = 200000000;
9930
9931 for (i = 0; i < ARRAY_SIZE(mdp_core_clk_rate_table); i++)
9932 mdp_core_clk_rate_table[i] = 200000000;
9933}
9934
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009935#if (defined(CONFIG_MARIMBA_CORE)) && \
9936 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
9937
9938static const struct {
9939 char *name;
9940 int vmin;
9941 int vmax;
9942} bt_regs_info[] = {
9943 { "8058_s3", 1800000, 1800000 },
9944 { "8058_s2", 1300000, 1300000 },
9945 { "8058_l8", 2900000, 3050000 },
9946};
9947
9948static struct {
9949 bool enabled;
9950} bt_regs_status[] = {
9951 { false },
9952 { false },
9953 { false },
9954};
9955static struct regulator *bt_regs[ARRAY_SIZE(bt_regs_info)];
9956
9957static int bahama_bt(int on)
9958{
9959 int rc;
9960 int i;
9961 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
9962
9963 struct bahama_variant_register {
9964 const size_t size;
9965 const struct bahama_config_register *set;
9966 };
9967
9968 const struct bahama_config_register *p;
9969
9970 u8 version;
9971
9972 const struct bahama_config_register v10_bt_on[] = {
9973 { 0xE9, 0x00, 0xFF },
9974 { 0xF4, 0x80, 0xFF },
9975 { 0xE4, 0x00, 0xFF },
9976 { 0xE5, 0x00, 0x0F },
9977#ifdef CONFIG_WLAN
9978 { 0xE6, 0x38, 0x7F },
9979 { 0xE7, 0x06, 0xFF },
9980#endif
9981 { 0xE9, 0x21, 0xFF },
9982 { 0x01, 0x0C, 0x1F },
9983 { 0x01, 0x08, 0x1F },
9984 };
9985
9986 const struct bahama_config_register v20_bt_on_fm_off[] = {
9987 { 0x11, 0x0C, 0xFF },
9988 { 0x13, 0x01, 0xFF },
9989 { 0xF4, 0x80, 0xFF },
9990 { 0xF0, 0x00, 0xFF },
9991 { 0xE9, 0x00, 0xFF },
9992#ifdef CONFIG_WLAN
9993 { 0x81, 0x00, 0x7F },
9994 { 0x82, 0x00, 0xFF },
9995 { 0xE6, 0x38, 0x7F },
9996 { 0xE7, 0x06, 0xFF },
9997#endif
9998 { 0xE9, 0x21, 0xFF },
9999 };
10000
10001 const struct bahama_config_register v20_bt_on_fm_on[] = {
10002 { 0x11, 0x0C, 0xFF },
10003 { 0x13, 0x01, 0xFF },
10004 { 0xF4, 0x86, 0xFF },
10005 { 0xF0, 0x06, 0xFF },
10006 { 0xE9, 0x00, 0xFF },
10007#ifdef CONFIG_WLAN
10008 { 0x81, 0x00, 0x7F },
10009 { 0x82, 0x00, 0xFF },
10010 { 0xE6, 0x38, 0x7F },
10011 { 0xE7, 0x06, 0xFF },
10012#endif
10013 { 0xE9, 0x21, 0xFF },
10014 };
10015
10016 const struct bahama_config_register v10_bt_off[] = {
10017 { 0xE9, 0x00, 0xFF },
10018 };
10019
10020 const struct bahama_config_register v20_bt_off_fm_off[] = {
10021 { 0xF4, 0x84, 0xFF },
10022 { 0xF0, 0x04, 0xFF },
10023 { 0xE9, 0x00, 0xFF }
10024 };
10025
10026 const struct bahama_config_register v20_bt_off_fm_on[] = {
10027 { 0xF4, 0x86, 0xFF },
10028 { 0xF0, 0x06, 0xFF },
10029 { 0xE9, 0x00, 0xFF }
10030 };
10031 const struct bahama_variant_register bt_bahama[2][3] = {
10032 {
10033 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
10034 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
10035 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
10036 },
10037 {
10038 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
10039 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
10040 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
10041 }
10042 };
10043
10044 u8 offset = 0; /* index into bahama configs */
10045
10046 on = on ? 1 : 0;
10047 version = read_bahama_ver();
10048
10049 if (version == VER_UNSUPPORTED) {
10050 dev_err(&msm_bt_power_device.dev,
10051 "%s: unsupported version\n",
10052 __func__);
10053 return -EIO;
10054 }
10055
10056 if (version == VER_2_0) {
10057 if (marimba_get_fm_status(&config))
10058 offset = 0x01;
10059 }
10060
10061 /* Voting off 1.3V S2 Regulator,BahamaV2 used in Normal mode */
10062 if (on && (version == VER_2_0)) {
10063 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
10064 if ((!strcmp(bt_regs_info[i].name, "8058_s2"))
10065 && (bt_regs_status[i].enabled == true)) {
10066 if (regulator_disable(bt_regs[i])) {
10067 dev_err(&msm_bt_power_device.dev,
10068 "%s: regulator disable failed",
10069 __func__);
10070 }
10071 bt_regs_status[i].enabled = false;
10072 break;
10073 }
10074 }
10075 }
10076
10077 p = bt_bahama[on][version + offset].set;
10078
10079 dev_info(&msm_bt_power_device.dev,
10080 "%s: found version %d\n", __func__, version);
10081
10082 for (i = 0; i < bt_bahama[on][version + offset].size; i++) {
10083 u8 value = (p+i)->value;
10084 rc = marimba_write_bit_mask(&config,
10085 (p+i)->reg,
10086 &value,
10087 sizeof((p+i)->value),
10088 (p+i)->mask);
10089 if (rc < 0) {
10090 dev_err(&msm_bt_power_device.dev,
10091 "%s: reg %d write failed: %d\n",
10092 __func__, (p+i)->reg, rc);
10093 return rc;
10094 }
10095 dev_dbg(&msm_bt_power_device.dev,
10096 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
10097 __func__, (p+i)->reg,
10098 value, (p+i)->mask);
10099 }
10100 /* Update BT Status */
10101 if (on)
10102 marimba_set_bt_status(&config, true);
10103 else
10104 marimba_set_bt_status(&config, false);
10105
10106 return 0;
10107}
10108
10109static int bluetooth_use_regulators(int on)
10110{
10111 int i, recover = -1, rc = 0;
10112
10113 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
10114 bt_regs[i] = on ? regulator_get(&msm_bt_power_device.dev,
10115 bt_regs_info[i].name) :
10116 (regulator_put(bt_regs[i]), NULL);
10117 if (IS_ERR(bt_regs[i])) {
10118 rc = PTR_ERR(bt_regs[i]);
10119 dev_err(&msm_bt_power_device.dev,
10120 "regulator %s get failed (%d)\n",
10121 bt_regs_info[i].name, rc);
10122 recover = i - 1;
10123 bt_regs[i] = NULL;
10124 break;
10125 }
10126
10127 if (!on)
10128 continue;
10129
10130 rc = regulator_set_voltage(bt_regs[i],
10131 bt_regs_info[i].vmin,
10132 bt_regs_info[i].vmax);
10133 if (rc < 0) {
10134 dev_err(&msm_bt_power_device.dev,
10135 "regulator %s voltage set (%d)\n",
10136 bt_regs_info[i].name, rc);
10137 recover = i;
10138 break;
10139 }
10140 }
10141
10142 if (on && (recover > -1))
10143 for (i = recover; i >= 0; i--) {
10144 regulator_put(bt_regs[i]);
10145 bt_regs[i] = NULL;
10146 }
10147
10148 return rc;
10149}
10150
10151static int bluetooth_switch_regulators(int on)
10152{
10153 int i, rc = 0;
10154
10155 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
10156 if (on && (bt_regs_status[i].enabled == false)) {
10157 rc = regulator_enable(bt_regs[i]);
10158 if (rc < 0) {
10159 dev_err(&msm_bt_power_device.dev,
10160 "regulator %s %s failed (%d)\n",
10161 bt_regs_info[i].name,
10162 "enable", rc);
10163 if (i > 0) {
10164 while (--i) {
10165 regulator_disable(bt_regs[i]);
10166 bt_regs_status[i].enabled
10167 = false;
10168 }
10169 break;
10170 }
10171 }
10172 bt_regs_status[i].enabled = true;
10173 } else if (!on && (bt_regs_status[i].enabled == true)) {
10174 rc = regulator_disable(bt_regs[i]);
10175 if (rc < 0) {
10176 dev_err(&msm_bt_power_device.dev,
10177 "regulator %s %s failed (%d)\n",
10178 bt_regs_info[i].name,
10179 "disable", rc);
10180 break;
10181 }
10182 bt_regs_status[i].enabled = false;
10183 }
10184 }
10185 return rc;
10186}
10187
10188static struct msm_xo_voter *bt_clock;
10189
10190static int bluetooth_power(int on)
10191{
10192 int rc = 0;
10193 int id;
10194
10195 /* In case probe function fails, cur_connv_type would be -1 */
10196 id = adie_get_detected_connectivity_type();
10197 if (id != BAHAMA_ID) {
10198 pr_err("%s: unexpected adie connectivity type: %d\n",
10199 __func__, id);
10200 return -ENODEV;
10201 }
10202
10203 if (on) {
10204
10205 rc = bluetooth_use_regulators(1);
10206 if (rc < 0)
10207 goto out;
10208
10209 rc = bluetooth_switch_regulators(1);
10210
10211 if (rc < 0)
10212 goto fail_put;
10213
10214 bt_clock = msm_xo_get(MSM_XO_TCXO_D0, "bt_power");
10215
10216 if (IS_ERR(bt_clock)) {
10217 pr_err("Couldn't get TCXO_D0 voter\n");
10218 goto fail_switch;
10219 }
10220
10221 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_ON);
10222
10223 if (rc < 0) {
10224 pr_err("Failed to vote for TCXO_DO ON\n");
10225 goto fail_vote;
10226 }
10227
10228 rc = bahama_bt(1);
10229
10230 if (rc < 0)
10231 goto fail_clock;
10232
10233 msleep(10);
10234
10235 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_PIN_CTRL);
10236
10237 if (rc < 0) {
10238 pr_err("Failed to vote for TCXO_DO pin control\n");
10239 goto fail_vote;
10240 }
10241 } else {
10242 /* check for initial RFKILL block (power off) */
10243 /* some RFKILL versions/configurations rfkill_register */
10244 /* calls here for an initial set_block */
10245 /* avoid calling i2c and regulator before unblock (on) */
10246 if (platform_get_drvdata(&msm_bt_power_device) == NULL) {
10247 dev_info(&msm_bt_power_device.dev,
10248 "%s: initialized OFF/blocked\n", __func__);
10249 goto out;
10250 }
10251
10252 bahama_bt(0);
10253
10254fail_clock:
10255 msm_xo_mode_vote(bt_clock, MSM_XO_MODE_OFF);
10256fail_vote:
10257 msm_xo_put(bt_clock);
10258fail_switch:
10259 bluetooth_switch_regulators(0);
10260fail_put:
10261 bluetooth_use_regulators(0);
10262 }
10263
10264out:
10265 if (rc < 0)
10266 on = 0;
10267 dev_info(&msm_bt_power_device.dev,
10268 "Bluetooth power switch: state %d result %d\n", on, rc);
10269
10270 return rc;
10271}
10272
10273#endif /*CONFIG_MARIMBA_CORE, CONFIG_MSM_BT_POWER, CONFIG_MSM_BT_POWER_MODULE*/
10274
10275static void __init msm8x60_cfg_smsc911x(void)
10276{
10277 smsc911x_resources[1].start =
10278 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10279 smsc911x_resources[1].end =
10280 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10281}
10282
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010283void msm_fusion_setup_pinctrl(void)
10284{
10285 struct msm_xo_voter *a1;
10286
10287 if (socinfo_get_platform_subtype() == 0x3) {
10288 /*
10289 * Vote for the A1 clock to be in pin control mode before
10290 * the external images are loaded.
10291 */
10292 a1 = msm_xo_get(MSM_XO_TCXO_A1, "mdm");
10293 BUG_ON(!a1);
10294 msm_xo_mode_vote(a1, MSM_XO_MODE_PIN_CTRL);
10295 }
10296}
10297
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010298struct msm_board_data {
10299 struct msm_gpiomux_configs *gpiomux_cfgs;
10300};
10301
10302static struct msm_board_data msm8x60_rumi3_board_data __initdata = {
10303 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10304};
10305
10306static struct msm_board_data msm8x60_sim_board_data __initdata = {
10307 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10308};
10309
10310static struct msm_board_data msm8x60_surf_board_data __initdata = {
10311 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10312};
10313
10314static struct msm_board_data msm8x60_ffa_board_data __initdata = {
10315 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10316};
10317
10318static struct msm_board_data msm8x60_fluid_board_data __initdata = {
10319 .gpiomux_cfgs = msm8x60_fluid_gpiomux_cfgs,
10320};
10321
10322static struct msm_board_data msm8x60_charm_surf_board_data __initdata = {
10323 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10324};
10325
10326static struct msm_board_data msm8x60_charm_ffa_board_data __initdata = {
10327 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10328};
10329
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010330static struct msm_board_data msm8x60_dragon_board_data __initdata = {
10331 .gpiomux_cfgs = msm8x60_dragon_gpiomux_cfgs,
10332};
10333
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010334static void __init msm8x60_init(struct msm_board_data *board_data)
10335{
10336 uint32_t soc_platform_version;
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010337#ifdef CONFIG_USB_EHCI_MSM_72K
10338 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
10339 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
10340 .level = PM8901_MPP_DIG_LEVEL_L5,
10341 .control = PM8XXX_MPP_DOUT_CTRL_HIGH,
10342 };
10343#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010344 pmic_reset_irq = PM8058_IRQ_BASE + PM8058_RESOUT_IRQ;
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070010345
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010346 /*
10347 * Initialize RPM first as other drivers and devices may need
10348 * it for their initialization.
10349 */
Praveen Chidambaram78499012011-11-01 17:15:17 -060010350 BUG_ON(msm_rpm_init(&msm8660_rpm_data));
10351 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010352 if (msm_xo_init())
10353 pr_err("Failed to initialize XO votes\n");
10354
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010355 msm8x60_check_2d_hardware();
10356
10357 /* Change SPM handling of core 1 if PMM 8160 is present. */
10358 soc_platform_version = socinfo_get_platform_version();
10359 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1 &&
10360 SOCINFO_VERSION_MINOR(soc_platform_version) >= 2) {
10361 struct msm_spm_platform_data *spm_data;
10362
10363 spm_data = &msm_spm_data_v1[1];
10364 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10365 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10366
10367 spm_data = &msm_spm_data[1];
10368 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10369 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10370 }
10371
10372 /*
10373 * Initialize SPM before acpuclock as the latter calls into SPM
10374 * driver to set ACPU voltages.
10375 */
10376 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10377 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
10378 else
10379 msm_spm_init(msm_spm_data_v1, ARRAY_SIZE(msm_spm_data_v1));
10380
10381 /*
10382 * Set regulators 8901_l4 and 8901_l6 to be always on in HPM for SURF
10383 * devices so that the RPM doesn't drop into a low power mode that an
10384 * un-reworked SURF cannot resume from.
10385 */
10386 if (machine_is_msm8x60_surf()) {
David Collins6f032ba2011-08-31 14:08:15 -070010387 int i;
10388
10389 for (i = 0; i < ARRAY_SIZE(rpm_regulator_init_data); i++)
10390 if (rpm_regulator_init_data[i].id
10391 == RPM_VREG_ID_PM8901_L4
10392 || rpm_regulator_init_data[i].id
10393 == RPM_VREG_ID_PM8901_L6)
10394 rpm_regulator_init_data[i]
10395 .init_data.constraints.always_on = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010396 }
10397
10398 /*
10399 * Disable regulator info printing so that regulator registration
10400 * messages do not enter the kmsg log.
10401 */
10402 regulator_suppress_info_printing();
10403
10404 /* Initialize regulators needed for clock_init. */
10405 platform_add_devices(early_regulators, ARRAY_SIZE(early_regulators));
10406
Stephen Boydbb600ae2011-08-02 20:11:40 -070010407 msm_clock_init(&msm8x60_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010408
10409 /* Buses need to be initialized before early-device registration
10410 * to get the platform data for fabrics.
10411 */
10412 msm8x60_init_buses();
10413 platform_add_devices(early_devices, ARRAY_SIZE(early_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010414
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010415 /*
10416 * Enable EBI2 only for boards which make use of it. Leave
10417 * it disabled for all others for additional power savings.
10418 */
10419 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10420 machine_is_msm8x60_rumi3() ||
10421 machine_is_msm8x60_sim() ||
10422 machine_is_msm8x60_fluid() ||
10423 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010424 msm8x60_init_ebi2();
10425 msm8x60_init_tlmm();
10426 msm8x60_init_gpiomux(board_data->gpiomux_cfgs);
10427 msm8x60_init_uart12dm();
Kevin Chan3be11612012-03-22 20:05:40 -070010428#ifdef CONFIG_MSM_CAMERA_V4L2
10429 msm8x60_init_cam();
10430#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010431 msm8x60_init_mmc();
10432
Kevin Chan3be11612012-03-22 20:05:40 -070010433
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010434#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
10435 msm8x60_init_pm8058_othc();
10436#endif
10437
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010438 if (machine_is_msm8x60_fluid())
10439 pm8058_platform_data.keypad_pdata = &fluid_keypad_data;
10440 else if (machine_is_msm8x60_dragon())
10441 pm8058_platform_data.keypad_pdata = &dragon_keypad_data;
10442 else
10443 pm8058_platform_data.keypad_pdata = &ffa_keypad_data;
Steve Mucklef132c6c2012-06-06 18:30:57 -070010444#if !defined(CONFIG_MSM_CAMERA_V4L2) && defined(CONFIG_WEBCAM_OV9726)
Jilai Wang53d27a82011-07-13 14:32:58 -040010445 /* Specify reset pin for OV9726 */
10446 if (machine_is_msm8x60_dragon()) {
10447 msm_camera_sensor_ov9726_data.sensor_reset = 62;
10448 ov9726_sensor_8660_info.mount_angle = 270;
10449 }
Kevin Chan3be11612012-03-22 20:05:40 -070010450#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010451#ifdef CONFIG_BATTERY_MSM8X60
10452 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10453 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
10454 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_fluid())
10455 platform_device_register(&msm_charger_device);
10456#endif
10457
10458 if (machine_is_msm8x60_dragon())
10459 pm8058_platform_data.charger_pdata = &pmic8058_charger_dragon;
10460 if (!machine_is_msm8x60_fluid())
10461 pm8058_platform_data.charger_pdata = &pmic8058_charger_ffa_surf;
10462
10463 /* configure pmic leds */
10464 if (machine_is_msm8x60_fluid())
10465 pm8058_platform_data.leds_pdata = &pm8058_fluid_flash_leds_data;
10466 else if (machine_is_msm8x60_dragon())
10467 pm8058_platform_data.leds_pdata = &pm8058_dragon_leds_data;
10468 else
10469 pm8058_platform_data.leds_pdata = &pm8058_flash_leds_data;
10470
10471 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
10472 machine_is_msm8x60_dragon()) {
10473 pm8058_platform_data.vibrator_pdata = &pm8058_vib_pdata;
10474 }
10475
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010476 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10477 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010478 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010479 msm8x60_cfg_smsc911x();
10480 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
Matt Wagantall1f65d9d2012-04-25 14:24:20 -070010481 platform_add_devices(msm8660_footswitch,
10482 msm8660_num_footswitch);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010483 platform_add_devices(surf_devices,
10484 ARRAY_SIZE(surf_devices));
10485
10486#ifdef CONFIG_MSM_DSPS
10487 if (machine_is_msm8x60_fluid()) {
10488 platform_device_unregister(&msm_gsbi12_qup_i2c_device);
10489 msm8x60_init_dsps();
10490 }
10491#endif
10492
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010493 pm8901_vreg_mpp0_init();
10494
10495 platform_device_register(&msm8x60_8901_mpp_vreg);
10496
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010497#ifdef CONFIG_USB_EHCI_MSM_72K
10498 /*
10499 * Drive MPP2 pin HIGH for PHY to generate ID interrupts on 8660
10500 * fluid
10501 */
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010502 if (machine_is_msm8x60_fluid())
10503 pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1), &hsusb_phy_mpp);
10504 msm_add_host(0, &msm_usb_host_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010505#endif
Lei Zhou338cab82011-08-19 13:38:17 -040010506
10507#ifdef CONFIG_SND_SOC_MSM8660_APQ
10508 if (machine_is_msm8x60_dragon())
10509 platform_add_devices(dragon_alsa_devices,
10510 ARRAY_SIZE(dragon_alsa_devices));
10511 else
10512#endif
10513 platform_add_devices(asoc_devices,
10514 ARRAY_SIZE(asoc_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010515 } else {
10516 msm8x60_configure_smc91x();
10517 platform_add_devices(rumi_sim_devices,
10518 ARRAY_SIZE(rumi_sim_devices));
10519 }
10520#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010521 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10522 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010523 msm8x60_cfg_isp1763();
10524#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010525
10526 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10527 platform_add_devices(charm_devices, ARRAY_SIZE(charm_devices));
10528
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010529
10530#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
10531 if (machine_is_msm8x60_fluid())
10532 platform_device_register(&msm_gsbi10_qup_spi_device);
10533 else
10534 platform_device_register(&msm_gsbi1_qup_spi_device);
10535#endif
10536
Steve Mucklef132c6c2012-06-06 18:30:57 -070010537#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
10538 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010539 if (machine_is_msm8x60_fluid())
10540 cyttsp_set_params();
10541#endif
10542 if (!machine_is_msm8x60_sim())
10543 msm_fb_add_devices();
10544 fixup_i2c_configs();
10545 register_i2c_devices();
10546
Terence Hampson1c73fef2011-07-19 17:10:49 -040010547 if (machine_is_msm8x60_dragon())
10548 smsc911x_config.reset_gpio
10549 = GPIO_ETHERNET_RESET_N_DRAGON;
10550
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010551 platform_device_register(&smsc911x_device);
10552
10553#if (defined(CONFIG_SPI_QUP)) && \
10554 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010555 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA) || \
10556 defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010557
10558 if (machine_is_msm8x60_fluid()) {
10559#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
10560 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
10561 spi_register_board_info(lcdc_samsung_spi_board_info,
10562 ARRAY_SIZE(lcdc_samsung_spi_board_info));
10563 } else
10564#endif
10565 {
10566#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
10567 spi_register_board_info(lcdc_auo_spi_board_info,
10568 ARRAY_SIZE(lcdc_auo_spi_board_info));
10569#endif
10570 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010571#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
10572 } else if (machine_is_msm8x60_dragon()) {
10573 spi_register_board_info(lcdc_nt35582_spi_board_info,
10574 ARRAY_SIZE(lcdc_nt35582_spi_board_info));
10575#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010576 }
10577#endif
10578
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060010579 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010580
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010581 pm8058_gpios_init();
10582
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010583#ifdef CONFIG_SENSORS_MSM_ADC
10584 if (machine_is_msm8x60_fluid()) {
10585 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
10586 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
10587 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3)
10588 msm_adc_pdata.gpio_config = APROC_CONFIG;
10589 else
10590 msm_adc_pdata.gpio_config = MPROC_CONFIG;
10591 }
10592 msm_adc_pdata.target_hw = MSM_8x60;
10593#endif
10594#ifdef CONFIG_MSM8X60_AUDIO
10595 msm_snddev_init();
10596#endif
10597#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
10598 if (machine_is_msm8x60_fluid())
10599 platform_device_register(&fluid_leds_gpio);
10600 else
10601 platform_device_register(&gpio_leds);
10602#endif
10603
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010604 msm8x60_multi_sdio_init();
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010605
10606 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10607 msm_fusion_setup_pinctrl();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010608}
10609
10610static void __init msm8x60_rumi3_init(void)
10611{
10612 msm8x60_init(&msm8x60_rumi3_board_data);
10613}
10614
10615static void __init msm8x60_sim_init(void)
10616{
10617 msm8x60_init(&msm8x60_sim_board_data);
10618}
10619
10620static void __init msm8x60_surf_init(void)
10621{
10622 msm8x60_init(&msm8x60_surf_board_data);
10623}
10624
10625static void __init msm8x60_ffa_init(void)
10626{
10627 msm8x60_init(&msm8x60_ffa_board_data);
10628}
10629
10630static void __init msm8x60_fluid_init(void)
10631{
10632 msm8x60_init(&msm8x60_fluid_board_data);
10633}
10634
10635static void __init msm8x60_charm_surf_init(void)
10636{
10637 msm8x60_init(&msm8x60_charm_surf_board_data);
10638}
10639
10640static void __init msm8x60_charm_ffa_init(void)
10641{
10642 msm8x60_init(&msm8x60_charm_ffa_board_data);
10643}
10644
10645static void __init msm8x60_charm_init_early(void)
10646{
10647 msm8x60_allocate_memory_regions();
Steve Mucklea55df6e2010-01-07 12:43:24 -080010648}
10649
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010650static void __init msm8x60_dragon_init(void)
10651{
10652 msm8x60_init(&msm8x60_dragon_board_data);
10653}
David Brown56e2d8a2011-08-04 02:01:02 -070010654
Steve Mucklea55df6e2010-01-07 12:43:24 -080010655MACHINE_START(MSM8X60_RUMI3, "QCT MSM8X60 RUMI3")
10656 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010657 .reserve = msm8x60_reserve,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010658 .init_irq = msm8x60_init_irq,
Marc Zyngier041f7772011-09-06 10:23:45 +010010659 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010660 .init_machine = msm8x60_rumi3_init,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010661 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010662 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010663 .restart = msm_restart,
Steve Muckle49b76f72010-03-19 17:00:08 -070010664MACHINE_END
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010665
10666MACHINE_START(MSM8X60_SIM, "QCT MSM8X60 SIMULATOR")
10667 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010668 .reserve = msm8x60_reserve,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010669 .init_irq = msm8x60_init_irq,
Marc Zyngier041f7772011-09-06 10:23:45 +010010670 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010671 .init_machine = msm8x60_sim_init,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010672 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010673 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010674 .restart = msm_restart,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010675MACHINE_END
10676
10677MACHINE_START(MSM8X60_SURF, "QCT MSM8X60 SURF")
10678 .map_io = msm8x60_map_io,
10679 .reserve = msm8x60_reserve,
10680 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010681 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010682 .init_machine = msm8x60_surf_init,
10683 .timer = &msm_timer,
10684 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010685 .restart = msm_restart,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010686MACHINE_END
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010687
10688MACHINE_START(MSM8X60_FFA, "QCT MSM8X60 FFA")
10689 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010690 .reserve = msm8x60_reserve,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010691 .init_irq = msm8x60_init_irq,
Marc Zyngier041f7772011-09-06 10:23:45 +010010692 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010693 .init_machine = msm8x60_ffa_init,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010694 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010695 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010696 .restart = msm_restart,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010697MACHINE_END
David Brown56e2d8a2011-08-04 02:01:02 -070010698
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010699MACHINE_START(MSM8X60_FLUID, "QCT MSM8X60 FLUID")
David Brown56e2d8a2011-08-04 02:01:02 -070010700 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010701 .reserve = msm8x60_reserve,
David Brown56e2d8a2011-08-04 02:01:02 -070010702 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010703 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010704 .init_machine = msm8x60_fluid_init,
David Brown56e2d8a2011-08-04 02:01:02 -070010705 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010706 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010707 .restart = msm_restart,
David Brown56e2d8a2011-08-04 02:01:02 -070010708MACHINE_END
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010709
10710MACHINE_START(MSM8X60_FUSION, "QCT MSM8X60 FUSION SURF")
10711 .map_io = msm8x60_map_io,
10712 .reserve = msm8x60_reserve,
10713 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010714 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010715 .init_machine = msm8x60_charm_surf_init,
10716 .timer = &msm_timer,
10717 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010718 .restart = msm_restart,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010719MACHINE_END
10720
10721MACHINE_START(MSM8X60_FUSN_FFA, "QCT MSM8X60 FUSION FFA")
10722 .map_io = msm8x60_map_io,
10723 .reserve = msm8x60_reserve,
10724 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010725 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010726 .init_machine = msm8x60_charm_ffa_init,
10727 .timer = &msm_timer,
10728 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010729 .restart = msm_restart,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010730MACHINE_END
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010731
10732MACHINE_START(MSM8X60_DRAGON, "QCT MSM8X60 DRAGON")
10733 .map_io = msm8x60_map_io,
10734 .reserve = msm8x60_reserve,
10735 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010736 .handle_irq = gic_handle_irq,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010737 .init_machine = msm8x60_dragon_init,
10738 .timer = &msm_timer,
10739 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010740 .restart = msm_restart,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010741MACHINE_END