blob: 0459240486f5d3292e1ea9b7631ebbca632ed587 [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,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005371};
5372
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005373#ifdef CONFIG_ION_MSM
Olav Haugan0703dbf2011-12-19 17:53:38 -08005374#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5375static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
5376 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugan8726caf2012-05-10 15:11:35 -07005377 .align = SZ_64K,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005378 .request_region = request_smi_region,
5379 .release_region = release_smi_region,
5380 .setup_region = setup_smi_region,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305381 .secure_base = MSM_ION_HOLE_BASE,
5382 .secure_size = MSM_ION_HOLE_SIZE + MSM_ION_MM_SIZE,
Olav Haugan8726caf2012-05-10 15:11:35 -07005383 .iommu_map_all = 1,
5384 .iommu_2x_map_domain = VIDEO_DOMAIN,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005385};
5386
5387static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
5388 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugan42ebe712012-01-10 16:30:58 -08005389 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005390 .request_region = request_smi_region,
5391 .release_region = release_smi_region,
5392 .setup_region = setup_smi_region,
5393};
5394
5395static struct ion_cp_heap_pdata cp_wb_ion_pdata = {
5396 .permission_type = IPT_TYPE_MDP_WRITEBACK,
Olav Haugan42ebe712012-01-10 16:30:58 -08005397 .align = PAGE_SIZE,
5398};
5399
Chintan Pandya7c2b9cb2012-06-25 14:35:02 +05305400static struct ion_co_heap_pdata mm_fw_co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005401 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005402};
5403
5404static struct ion_co_heap_pdata co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005405 .adjacent_mem_id = INVALID_HEAP_ID,
5406 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005407};
5408#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005409
5410/**
5411 * These heaps are listed in the order they will be allocated. Due to
5412 * video hardware restrictions and content protection the FW heap has to
5413 * be allocated adjacent (below) the MM heap and the MFC heap has to be
5414 * allocated after the MM heap to ensure MFC heap is not more than 256MB
5415 * away from the base address of the FW heap.
5416 * However, the order of FW heap and MM heap doesn't matter since these
5417 * two heaps are taken care of by separate code to ensure they are adjacent
5418 * to each other.
5419 * Don't swap the order unless you know what you are doing!
5420 */
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005421static struct ion_platform_data ion_pdata = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005422 .nr = MSM_ION_HEAP_NUM,
5423 .heaps = {
5424 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005425 .id = ION_SYSTEM_HEAP_ID,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005426 .type = ION_HEAP_TYPE_SYSTEM,
5427 .name = ION_VMALLOC_HEAP_NAME,
5428 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005429#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5430 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005431 .id = ION_CP_MM_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005432 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005433 .name = ION_MM_HEAP_NAME,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305434 .base = MSM_ION_MM_BASE,
Olav Hauganb5be7992011-11-18 14:29:02 -08005435 .size = MSM_ION_MM_SIZE,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005436 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005437 .extra_data = (void *) &cp_mm_ion_pdata,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005438 },
Olav Hauganb5be7992011-11-18 14:29:02 -08005439 {
Olav Haugan42ebe712012-01-10 16:30:58 -08005440 .id = ION_MM_FIRMWARE_HEAP_ID,
5441 .type = ION_HEAP_TYPE_CARVEOUT,
5442 .name = ION_MM_FIRMWARE_HEAP_NAME,
Chintan Pandya7c2b9cb2012-06-25 14:35:02 +05305443 .base = MSM_MM_FW_BASE,
5444 .size = MSM_MM_FW_SIZE,
Olav Haugan42ebe712012-01-10 16:30:58 -08005445 .memory_type = ION_SMI_TYPE,
Chintan Pandya7c2b9cb2012-06-25 14:35:02 +05305446 .extra_data = (void *) &mm_fw_co_ion_pdata,
Olav Haugan42ebe712012-01-10 16:30:58 -08005447 },
5448 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005449 .id = ION_CP_MFC_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005450 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005451 .name = ION_MFC_HEAP_NAME,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305452 .base = MSM_ION_MFC_BASE,
Olav Hauganb5be7992011-11-18 14:29:02 -08005453 .size = MSM_ION_MFC_SIZE,
5454 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005455 .extra_data = (void *) &cp_mfc_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005456 },
5457 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005458 .id = ION_SF_HEAP_ID,
5459 .type = ION_HEAP_TYPE_CARVEOUT,
5460 .name = ION_SF_HEAP_NAME,
5461 .size = MSM_ION_SF_SIZE,
5462 .memory_type = ION_EBI_TYPE,
5463 .extra_data = (void *)&co_ion_pdata,
5464 },
5465 {
5466 .id = ION_CAMERA_HEAP_ID,
5467 .type = ION_HEAP_TYPE_CARVEOUT,
5468 .name = ION_CAMERA_HEAP_NAME,
5469 .size = MSM_ION_CAMERA_SIZE,
5470 .memory_type = ION_EBI_TYPE,
5471 .extra_data = &co_ion_pdata,
5472 },
5473 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005474 .id = ION_CP_WB_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005475 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005476 .name = ION_WB_HEAP_NAME,
5477 .size = MSM_ION_WB_SIZE,
5478 .memory_type = ION_EBI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005479 .extra_data = (void *) &cp_wb_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005480 },
Olav Haugan3a55e322012-01-23 14:24:01 -08005481 {
Olav Haugan6ab47252012-02-15 14:46:49 -08005482 .id = ION_QSECOM_HEAP_ID,
5483 .type = ION_HEAP_TYPE_CARVEOUT,
5484 .name = ION_QSECOM_HEAP_NAME,
5485 .size = MSM_ION_QSECOM_SIZE,
5486 .memory_type = ION_EBI_TYPE,
5487 .extra_data = (void *) &co_ion_pdata,
5488 },
5489 {
Olav Haugan3a55e322012-01-23 14:24:01 -08005490 .id = ION_AUDIO_HEAP_ID,
5491 .type = ION_HEAP_TYPE_CARVEOUT,
5492 .name = ION_AUDIO_HEAP_NAME,
5493 .size = MSM_ION_AUDIO_SIZE,
5494 .memory_type = ION_EBI_TYPE,
5495 .extra_data = (void *)&co_ion_pdata,
5496 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005497#endif
5498 }
5499};
5500
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005501static struct platform_device ion_dev = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005502 .name = "ion-msm",
5503 .id = 1,
5504 .dev = { .platform_data = &ion_pdata },
5505};
5506#endif
5507
5508
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005509static struct memtype_reserve msm8x60_reserve_table[] __initdata = {
5510 /* Kernel SMI memory pool for video core, used for firmware */
5511 /* and encoder, decoder scratch buffers */
5512 /* Kernel SMI memory pool should always precede the user space */
5513 /* SMI memory pool, as the video core will use offset address */
5514 /* from the Firmware base */
5515 [MEMTYPE_SMI_KERNEL] = {
5516 .start = KERNEL_SMI_BASE,
5517 .limit = KERNEL_SMI_SIZE,
5518 .size = KERNEL_SMI_SIZE,
5519 .flags = MEMTYPE_FLAGS_FIXED,
5520 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005521 [MEMTYPE_SMI] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005522 },
5523 [MEMTYPE_EBI0] = {
5524 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5525 },
5526 [MEMTYPE_EBI1] = {
5527 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5528 },
5529};
5530
Stephen Boyd668d7652012-04-25 11:31:01 -07005531static void __init reserve_ion_memory(void)
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005532{
5533#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005534 unsigned int i;
5535
5536 if (hdmi_is_primary) {
5537 msm_ion_sf_size = MSM_HDMI_PRIM_ION_SF_SIZE;
5538 for (i = 0; i < ion_pdata.nr; i++) {
5539 if (ion_pdata.heaps[i].id == ION_SF_HEAP_ID) {
5540 ion_pdata.heaps[i].size = msm_ion_sf_size;
5541 pr_debug("msm_ion_sf_size 0x%x\n",
5542 msm_ion_sf_size);
5543 break;
5544 }
5545 }
5546 }
5547
Olav Haugan8726caf2012-05-10 15:11:35 -07005548 /* Verify size of heap is a multiple of 64K */
5549 for (i = 0; i < ion_pdata.nr; i++) {
5550 struct ion_platform_heap *heap = &(ion_pdata.heaps[i]);
5551
5552 if (heap->extra_data && heap->type == ION_HEAP_TYPE_CP) {
5553 int map_all = ((struct ion_cp_heap_pdata *)
5554 heap->extra_data)->iommu_map_all;
5555
5556 if (map_all && (heap->size & (SZ_64K-1))) {
5557 heap->size = ALIGN(heap->size, SZ_64K);
5558 pr_err("Heap %s size is not a multiple of 64K. Adjusting size to %x\n",
5559 heap->name, heap->size);
5560
5561 }
5562 }
5563 }
5564
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005565 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_ion_sf_size;
Olav Hauganb5be7992011-11-18 14:29:02 -08005566 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_CAMERA_SIZE;
5567 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_WB_SIZE;
Olav Haugan3a55e322012-01-23 14:24:01 -08005568 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE;
Olav Haugan8d8c2d12012-04-02 12:01:44 -07005569 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_QSECOM_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005570#endif
5571}
5572
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005573static void __init size_pmem_devices(void)
5574{
5575#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005576#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005577 android_pmem_adsp_pdata.size = pmem_adsp_size;
5578 android_pmem_smipool_pdata.size = MSM_PMEM_SMIPOOL_SIZE;
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005579
5580 if (hdmi_is_primary)
5581 pmem_sf_size = MSM_HDMI_PRIM_PMEM_SF_SIZE;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005582 android_pmem_pdata.size = pmem_sf_size;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005583 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305584#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5585#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005586}
5587
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305588#ifdef CONFIG_ANDROID_PMEM
5589#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005590static void __init reserve_memory_for(struct android_pmem_platform_data *p)
5591{
5592 msm8x60_reserve_table[p->memory_type].size += p->size;
5593}
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305594#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5595#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005596
5597static void __init reserve_pmem_memory(void)
5598{
5599#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005600#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005601 reserve_memory_for(&android_pmem_adsp_pdata);
5602 reserve_memory_for(&android_pmem_smipool_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005603 reserve_memory_for(&android_pmem_pdata);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005604 reserve_memory_for(&android_pmem_audio_pdata);
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305605#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005606 msm8x60_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305607#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005608}
5609
Huaibin Yanga5419422011-12-08 23:52:10 -08005610static void __init reserve_mdp_memory(void);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005611
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305612static void __init reserve_rtb_memory(void)
5613{
5614#if defined(CONFIG_MSM_RTB)
5615 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_rtb_pdata.size;
5616#endif
5617}
5618
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005619static void __init msm8x60_calculate_reserve_sizes(void)
5620{
5621 size_pmem_devices();
5622 reserve_pmem_memory();
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005623 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -08005624 reserve_mdp_memory();
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305625 reserve_rtb_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005626}
5627
5628static int msm8x60_paddr_to_memtype(unsigned int paddr)
5629{
5630 if (paddr >= 0x40000000 && paddr < 0x60000000)
5631 return MEMTYPE_EBI1;
5632 if (paddr >= 0x38000000 && paddr < 0x40000000)
5633 return MEMTYPE_SMI;
5634 return MEMTYPE_NONE;
5635}
5636
5637static struct reserve_info msm8x60_reserve_info __initdata = {
5638 .memtype_reserve_table = msm8x60_reserve_table,
5639 .calculate_reserve_sizes = msm8x60_calculate_reserve_sizes,
5640 .paddr_to_memtype = msm8x60_paddr_to_memtype,
5641};
5642
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005643static char prim_panel_name[PANEL_NAME_MAX_LEN];
5644static char ext_panel_name[PANEL_NAME_MAX_LEN];
5645static int __init prim_display_setup(char *param)
5646{
5647 if (strnlen(param, PANEL_NAME_MAX_LEN))
5648 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
5649 return 0;
5650}
5651early_param("prim_display", prim_display_setup);
5652
5653static int __init ext_display_setup(char *param)
5654{
5655 if (strnlen(param, PANEL_NAME_MAX_LEN))
5656 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
5657 return 0;
5658}
5659early_param("ext_display", ext_display_setup);
5660
Stephen Boyd9e775ad2011-08-12 00:14:28 +01005661static void __init msm8x60_reserve(void)
5662{
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005663 msm8x60_set_display_params(prim_panel_name, ext_panel_name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005664 reserve_info = &msm8x60_reserve_info;
5665 msm_reserve();
5666}
5667
5668#define EXT_CHG_VALID_MPP 10
5669#define EXT_CHG_VALID_MPP_2 11
5670
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305671static struct pm8xxx_mpp_init_info isl_mpp[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305672 PM8058_MPP_INIT(EXT_CHG_VALID_MPP, D_INPUT,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305673 PM8058_MPP_DIG_LEVEL_S3, DIN_TO_INT),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305674 PM8058_MPP_INIT(EXT_CHG_VALID_MPP_2, D_BI_DIR,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305675 PM8058_MPP_DIG_LEVEL_S3, BI_PULLUP_10KOHM),
5676};
5677
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005678#ifdef CONFIG_ISL9519_CHARGER
5679static int isl_detection_setup(void)
5680{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305681 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005682
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305683 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5684 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5685 &isl_mpp[i].config);
5686 if (ret) {
5687 pr_err("%s: Config MPP %d of PM8058 failed\n",
5688 __func__, isl_mpp[i].mpp);
5689 return ret;
5690 }
5691 }
5692
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005693 return ret;
5694}
5695
5696static struct isl_platform_data isl_data __initdata = {
5697 .chgcurrent = 700,
5698 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5699 .chg_detection_config = isl_detection_setup,
5700 .max_system_voltage = 4200,
5701 .min_system_voltage = 3200,
5702 .term_current = 120,
5703 .input_current = 2048,
5704};
5705
5706static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
5707 {
5708 I2C_BOARD_INFO("isl9519q", 0x9),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305709 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005710 .platform_data = &isl_data,
5711 },
5712};
5713#endif
5714
5715#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
5716static int smb137b_detection_setup(void)
5717{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305718 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005719
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305720 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5721 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5722 &isl_mpp[i].config);
5723 if (ret) {
5724 pr_err("%s: Config MPP %d of PM8058 failed\n",
5725 __func__, isl_mpp[i].mpp);
5726 return ret;
5727 }
5728 }
5729
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005730 return ret;
5731}
5732
5733static struct smb137b_platform_data smb137b_data __initdata = {
5734 .chg_detection_config = smb137b_detection_setup,
5735 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5736 .batt_mah_rating = 950,
5737};
5738
5739static struct i2c_board_info smb137b_charger_i2c_info[] __initdata = {
5740 {
5741 I2C_BOARD_INFO("smb137b", 0x08),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305742 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005743 .platform_data = &smb137b_data,
5744 },
5745};
5746#endif
5747
5748#ifdef CONFIG_PMIC8058
5749#define PMIC_GPIO_SDC3_DET 22
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305750#define PMIC_GPIO_TOUCH_DISC_INTR 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005751
5752static int pm8058_gpios_init(void)
5753{
5754 int i;
5755 int rc;
5756 struct pm8058_gpio_cfg {
5757 int gpio;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305758 struct pm_gpio cfg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005759 };
5760
5761 struct pm8058_gpio_cfg gpio_cfgs[] = {
5762 { /* FFA ethernet */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305763 PM8058_GPIO_PM_TO_SYS(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005764 {
5765 .direction = PM_GPIO_DIR_IN,
5766 .pull = PM_GPIO_PULL_DN,
5767 .vin_sel = 2,
5768 .function = PM_GPIO_FUNC_NORMAL,
5769 .inv_int_pol = 0,
5770 },
5771 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005772 {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305773 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005774 {
5775 .direction = PM_GPIO_DIR_IN,
5776 .pull = PM_GPIO_PULL_UP_30,
5777 .vin_sel = 2,
5778 .function = PM_GPIO_FUNC_NORMAL,
5779 .inv_int_pol = 0,
5780 },
5781 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005782 { /* core&surf gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305783 PM8058_GPIO_PM_TO_SYS(UI_INT1_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005784 {
5785 .direction = PM_GPIO_DIR_IN,
5786 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305787 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005788 .function = PM_GPIO_FUNC_NORMAL,
5789 .inv_int_pol = 0,
5790 },
5791 },
5792 { /* docking gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305793 PM8058_GPIO_PM_TO_SYS(UI_INT2_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005794 {
5795 .direction = PM_GPIO_DIR_IN,
5796 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305797 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005798 .function = PM_GPIO_FUNC_NORMAL,
5799 .inv_int_pol = 0,
5800 },
5801 },
5802 { /* FHA/keypad gpio expanders */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305803 PM8058_GPIO_PM_TO_SYS(UI_INT3_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005804 {
5805 .direction = PM_GPIO_DIR_IN,
5806 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305807 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005808 .function = PM_GPIO_FUNC_NORMAL,
5809 .inv_int_pol = 0,
5810 },
5811 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005812 { /* Timpani Reset */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305813 PM8058_GPIO_PM_TO_SYS(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005814 {
5815 .direction = PM_GPIO_DIR_OUT,
5816 .output_value = 1,
5817 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5818 .pull = PM_GPIO_PULL_DN,
5819 .out_strength = PM_GPIO_STRENGTH_HIGH,
5820 .function = PM_GPIO_FUNC_NORMAL,
5821 .vin_sel = 2,
5822 .inv_int_pol = 0,
5823 }
5824 },
5825 { /* PMIC ID interrupt */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305826 PM8058_GPIO_PM_TO_SYS(36),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005827 {
5828 .direction = PM_GPIO_DIR_IN,
Anji jonnalaae745e92011-11-14 18:34:31 +05305829 .pull = PM_GPIO_PULL_NO,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005830 .function = PM_GPIO_FUNC_NORMAL,
5831 .vin_sel = 2,
5832 .inv_int_pol = 0,
5833 }
5834 },
5835 };
5836
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305837#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5838 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305839 struct pm_gpio touchdisc_intr_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305840 .direction = PM_GPIO_DIR_IN,
5841 .pull = PM_GPIO_PULL_UP_1P5,
5842 .vin_sel = 2,
5843 .function = PM_GPIO_FUNC_NORMAL,
5844 };
5845#endif
5846
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005847#if defined(CONFIG_HAPTIC_ISA1200) || \
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305848 defined(CONFIG_HAPTIC_ISA1200_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305849 struct pm_gpio en_hap_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305850 .direction = PM_GPIO_DIR_OUT,
5851 .pull = PM_GPIO_PULL_NO,
5852 .out_strength = PM_GPIO_STRENGTH_HIGH,
5853 .function = PM_GPIO_FUNC_NORMAL,
5854 .inv_int_pol = 0,
5855 .vin_sel = 2,
5856 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5857 .output_value = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005858 };
5859#endif
5860
5861#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5862 struct pm8058_gpio_cfg line_in_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305863 PM8058_GPIO_PM_TO_SYS(18),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005864 {
5865 .direction = PM_GPIO_DIR_IN,
5866 .pull = PM_GPIO_PULL_UP_1P5,
5867 .vin_sel = 2,
5868 .function = PM_GPIO_FUNC_NORMAL,
5869 .inv_int_pol = 0,
5870 }
5871 };
5872#endif
5873
5874#if defined(CONFIG_QS_S5K4E1)
5875 {
5876 struct pm8058_gpio_cfg qs_hc37_cam_pd_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305877 PM8058_GPIO_PM_TO_SYS(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005878 {
5879 .direction = PM_GPIO_DIR_OUT,
5880 .output_value = 0,
5881 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5882 .pull = PM_GPIO_PULL_DN,
5883 .out_strength = PM_GPIO_STRENGTH_HIGH,
5884 .function = PM_GPIO_FUNC_NORMAL,
5885 .vin_sel = 2,
5886 .inv_int_pol = 0,
5887 }
5888 };
5889#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005890#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5891 struct pm8058_gpio_cfg pmic_lcdc_nt35582_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305892 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1),
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005893 {
5894 .direction = PM_GPIO_DIR_OUT,
5895 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5896 .output_value = 1,
5897 .pull = PM_GPIO_PULL_UP_30,
5898 /* 2.9V PM_GPIO_VIN_L2, which gives 2.6V */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305899 .vin_sel = PM8058_GPIO_VIN_L5,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005900 .out_strength = PM_GPIO_STRENGTH_HIGH,
5901 .function = PM_GPIO_FUNC_NORMAL,
5902 .inv_int_pol = 0,
5903 }
5904 };
5905#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005906#if defined(CONFIG_HAPTIC_ISA1200) || \
5907 defined(CONFIG_HAPTIC_ISA1200_MODULE)
5908 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305909 rc = pm8xxx_gpio_config(
5910 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
5911 &en_hap_gpio_cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005912 if (rc < 0) {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305913 pr_err("%s: pmic haptics gpio config failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005914 __func__);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305915 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305916 rc = pm8xxx_gpio_config(
5917 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
5918 &en_hap_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305919 if (rc < 0) {
5920 pr_err("%s: pmic haptics ldo gpio config failed\n",
5921 __func__);
5922 }
5923
5924 }
5925#endif
5926
5927#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5928 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
5929 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
5930 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305931 rc = pm8xxx_gpio_config(
5932 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_TOUCH_DISC_INTR),
5933 &touchdisc_intr_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305934 if (rc < 0) {
5935 pr_err("%s: Touchdisc interrupt gpio config failed\n",
5936 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005937 }
5938 }
5939#endif
5940
5941#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5942 /* Line_in only for 8660 ffa & surf */
5943 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04005944 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005945 machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305946 rc = pm8xxx_gpio_config(line_in_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005947 &line_in_gpio_cfg.cfg);
5948 if (rc < 0) {
5949 pr_err("%s pmic line_in gpio config failed\n",
5950 __func__);
5951 return rc;
5952 }
5953 }
5954#endif
5955
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005956#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5957 if (machine_is_msm8x60_dragon()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305958 rc = pm8xxx_gpio_config(pmic_lcdc_nt35582_gpio_cfg.gpio,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005959 &pmic_lcdc_nt35582_gpio_cfg.cfg);
5960 if (rc < 0) {
5961 pr_err("%s pmic gpio config failed\n", __func__);
5962 return rc;
5963 }
5964 }
5965#endif
5966
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005967#if defined(CONFIG_QS_S5K4E1)
5968 /* qs_cam_hc37_cam_pd only for 8660 fluid qs camera*/
5969 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305970 rc = pm8xxx_gpio_config(qs_hc37_cam_pd_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005971 &qs_hc37_cam_pd_gpio_cfg.cfg);
5972 if (rc < 0) {
5973 pr_err("%s pmic qs_hc37_cam_pd gpio config failed\n",
5974 __func__);
5975 return rc;
5976 }
5977 }
5978 }
5979#endif
5980
5981 for (i = 0; i < ARRAY_SIZE(gpio_cfgs); ++i) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305982 rc = pm8xxx_gpio_config(gpio_cfgs[i].gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005983 &gpio_cfgs[i].cfg);
5984 if (rc < 0) {
5985 pr_err("%s pmic gpio config failed\n",
5986 __func__);
5987 return rc;
5988 }
5989 }
5990
5991 return 0;
5992}
5993
5994static const unsigned int ffa_keymap[] = {
5995 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5996 KEY(0, 1, KEY_UP), /* NAV - UP */
5997 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5998 KEY(0, 3, KEY_VOLUMEUP), /* Shuttle SW_UP */
5999
6000 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
6001 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
6002 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
6003 KEY(1, 3, KEY_VOLUMEDOWN),
6004
6005 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
6006
6007 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
6008 KEY(4, 1, KEY_UP), /* USER_UP */
6009 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
6010 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
6011 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
6012
6013 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
6014 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
6015 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
6016 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
6017 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
6018};
6019
Zhang Chang Ken683be172011-08-10 17:45:34 -04006020static const unsigned int dragon_keymap[] = {
6021 KEY(0, 0, KEY_MENU),
6022 KEY(0, 2, KEY_1),
6023 KEY(0, 3, KEY_4),
6024 KEY(0, 4, KEY_7),
6025
6026 KEY(1, 0, KEY_UP),
6027 KEY(1, 1, KEY_LEFT),
6028 KEY(1, 2, KEY_DOWN),
6029 KEY(1, 3, KEY_5),
6030 KEY(1, 4, KEY_8),
6031
6032 KEY(2, 0, KEY_HOME),
6033 KEY(2, 1, KEY_REPLY),
6034 KEY(2, 2, KEY_2),
6035 KEY(2, 3, KEY_6),
6036 KEY(2, 4, KEY_0),
6037
6038 KEY(3, 0, KEY_VOLUMEUP),
6039 KEY(3, 1, KEY_RIGHT),
6040 KEY(3, 2, KEY_3),
6041 KEY(3, 3, KEY_9),
6042 KEY(3, 4, KEY_SWITCHVIDEOMODE),
6043
6044 KEY(4, 0, KEY_VOLUMEDOWN),
6045 KEY(4, 1, KEY_BACK),
6046 KEY(4, 2, KEY_CAMERA),
6047 KEY(4, 3, KEY_KBDILLUMTOGGLE),
6048};
6049
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006050static struct matrix_keymap_data ffa_keymap_data = {
6051 .keymap_size = ARRAY_SIZE(ffa_keymap),
6052 .keymap = ffa_keymap,
6053};
6054
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306055static struct pm8xxx_keypad_platform_data ffa_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006056 .input_name = "ffa-keypad",
6057 .input_phys_device = "ffa-keypad/input0",
6058 .num_rows = 6,
6059 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306060 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
6061 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
6062 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006063 .scan_delay_ms = 32,
6064 .row_hold_ns = 91500,
6065 .wakeup = 1,
6066 .keymap_data = &ffa_keymap_data,
6067};
6068
Zhang Chang Ken683be172011-08-10 17:45:34 -04006069static struct matrix_keymap_data dragon_keymap_data = {
6070 .keymap_size = ARRAY_SIZE(dragon_keymap),
6071 .keymap = dragon_keymap,
6072};
6073
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306074static struct pm8xxx_keypad_platform_data dragon_keypad_data = {
Zhang Chang Ken683be172011-08-10 17:45:34 -04006075 .input_name = "dragon-keypad",
6076 .input_phys_device = "dragon-keypad/input0",
6077 .num_rows = 6,
6078 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306079 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
6080 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
6081 .debounce_ms = 15,
Zhang Chang Ken683be172011-08-10 17:45:34 -04006082 .scan_delay_ms = 32,
6083 .row_hold_ns = 91500,
6084 .wakeup = 1,
6085 .keymap_data = &dragon_keymap_data,
6086};
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306087
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006088static const unsigned int fluid_keymap[] = {
6089 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
6090 KEY(0, 1, KEY_UP), /* NAV - UP */
6091 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
6092 KEY(0, 3, KEY_VOLUMEDOWN), /* Shuttle SW_UP */
6093
6094 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
6095 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
6096 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
6097 KEY(1, 3, KEY_VOLUMEUP),
6098
6099 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
6100
6101 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
6102 KEY(4, 1, KEY_UP), /* USER_UP */
6103 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
6104 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
6105 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
6106
Jilai Wang9a895102011-07-12 14:00:35 -04006107 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006108 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
6109 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
6110 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
6111 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
6112};
6113
6114static struct matrix_keymap_data fluid_keymap_data = {
6115 .keymap_size = ARRAY_SIZE(fluid_keymap),
6116 .keymap = fluid_keymap,
6117};
6118
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306119static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006120 .input_name = "fluid-keypad",
6121 .input_phys_device = "fluid-keypad/input0",
6122 .num_rows = 6,
6123 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306124 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
6125 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
6126 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006127 .scan_delay_ms = 32,
6128 .row_hold_ns = 91500,
6129 .wakeup = 1,
6130 .keymap_data = &fluid_keymap_data,
6131};
6132
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306133static struct pm8xxx_vibrator_platform_data pm8058_vib_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006134 .initial_vibrate_ms = 500,
6135 .level_mV = 3000,
6136 .max_timeout_ms = 15000,
6137};
6138
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306139static struct pm8xxx_rtc_platform_data pm8058_rtc_pdata = {
6140 .rtc_write_enable = false,
6141 .rtc_alarm_powerup = false,
6142};
6143
6144static struct pm8xxx_pwrkey_platform_data pm8058_pwrkey_pdata = {
6145 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -08006146 .kpd_trigger_delay_us = 15625,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306147 .wakeup = 1,
6148};
6149
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006150#define PM8058_LINE_IN_DET_GPIO PM8058_GPIO_PM_TO_SYS(18)
6151
6152static struct othc_accessory_info othc_accessories[] = {
6153 {
6154 .accessory = OTHC_SVIDEO_OUT,
6155 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT
6156 | OTHC_ADC_DETECT,
6157 .key_code = SW_VIDEOOUT_INSERT,
6158 .enabled = false,
6159 .adc_thres = {
6160 .min_threshold = 20,
6161 .max_threshold = 40,
6162 },
6163 },
6164 {
6165 .accessory = OTHC_ANC_HEADPHONE,
6166 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT |
6167 OTHC_SWITCH_DETECT,
6168 .gpio = PM8058_LINE_IN_DET_GPIO,
6169 .active_low = 1,
6170 .key_code = SW_HEADPHONE_INSERT,
6171 .enabled = true,
6172 },
6173 {
6174 .accessory = OTHC_ANC_HEADSET,
6175 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT,
6176 .gpio = PM8058_LINE_IN_DET_GPIO,
6177 .active_low = 1,
6178 .key_code = SW_HEADPHONE_INSERT,
6179 .enabled = true,
6180 },
6181 {
6182 .accessory = OTHC_HEADPHONE,
6183 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT,
6184 .key_code = SW_HEADPHONE_INSERT,
6185 .enabled = true,
6186 },
6187 {
6188 .accessory = OTHC_MICROPHONE,
6189 .detect_flags = OTHC_GPIO_DETECT,
6190 .gpio = PM8058_LINE_IN_DET_GPIO,
6191 .active_low = 1,
6192 .key_code = SW_MICROPHONE_INSERT,
6193 .enabled = true,
6194 },
6195 {
6196 .accessory = OTHC_HEADSET,
6197 .detect_flags = OTHC_MICBIAS_DETECT,
6198 .key_code = SW_HEADPHONE_INSERT,
6199 .enabled = true,
6200 },
6201};
6202
6203static struct othc_switch_info switch_info[] = {
6204 {
6205 .min_adc_threshold = 0,
6206 .max_adc_threshold = 100,
6207 .key_code = KEY_PLAYPAUSE,
6208 },
6209 {
6210 .min_adc_threshold = 100,
6211 .max_adc_threshold = 200,
6212 .key_code = KEY_REWIND,
6213 },
6214 {
6215 .min_adc_threshold = 200,
6216 .max_adc_threshold = 500,
6217 .key_code = KEY_FASTFORWARD,
6218 },
6219};
6220
6221static struct othc_n_switch_config switch_config = {
6222 .voltage_settling_time_ms = 0,
6223 .num_adc_samples = 3,
6224 .adc_channel = CHANNEL_ADC_HDSET,
6225 .switch_info = switch_info,
6226 .num_keys = ARRAY_SIZE(switch_info),
6227 .default_sw_en = true,
6228 .default_sw_idx = 0,
6229};
6230
6231static struct hsed_bias_config hsed_bias_config = {
6232 /* HSED mic bias config info */
6233 .othc_headset = OTHC_HEADSET_NO,
6234 .othc_lowcurr_thresh_uA = 100,
6235 .othc_highcurr_thresh_uA = 600,
6236 .othc_hyst_prediv_us = 7800,
6237 .othc_period_clkdiv_us = 62500,
6238 .othc_hyst_clk_us = 121000,
6239 .othc_period_clk_us = 312500,
6240 .othc_wakeup = 1,
6241};
6242
6243static struct othc_hsed_config hsed_config_1 = {
6244 .hsed_bias_config = &hsed_bias_config,
6245 /*
6246 * The detection delay and switch reporting delay are
6247 * required to encounter a hardware bug (spurious switch
6248 * interrupts on slow insertion/removal of the headset).
6249 * This will introduce a delay in reporting the accessory
6250 * insertion and removal to the userspace.
6251 */
6252 .detection_delay_ms = 1500,
6253 /* Switch info */
6254 .switch_debounce_ms = 1500,
6255 .othc_support_n_switch = false,
6256 .switch_config = &switch_config,
6257 .ir_gpio = -1,
6258 /* Accessory info */
6259 .accessories_support = true,
6260 .accessories = othc_accessories,
6261 .othc_num_accessories = ARRAY_SIZE(othc_accessories),
6262};
6263
6264static struct othc_regulator_config othc_reg = {
6265 .regulator = "8058_l5",
6266 .max_uV = 2850000,
6267 .min_uV = 2850000,
6268};
6269
6270/* MIC_BIAS0 is configured as normal MIC BIAS */
6271static struct pmic8058_othc_config_pdata othc_config_pdata_0 = {
6272 .micbias_select = OTHC_MICBIAS_0,
6273 .micbias_capability = OTHC_MICBIAS,
6274 .micbias_enable = OTHC_SIGNAL_OFF,
6275 .micbias_regulator = &othc_reg,
6276};
6277
6278/* MIC_BIAS1 is configured as HSED_BIAS for OTHC */
6279static struct pmic8058_othc_config_pdata othc_config_pdata_1 = {
6280 .micbias_select = OTHC_MICBIAS_1,
6281 .micbias_capability = OTHC_MICBIAS_HSED,
6282 .micbias_enable = OTHC_SIGNAL_PWM_TCXO,
6283 .micbias_regulator = &othc_reg,
6284 .hsed_config = &hsed_config_1,
6285 .hsed_name = "8660_handset",
6286};
6287
6288/* MIC_BIAS2 is configured as normal MIC BIAS */
6289static struct pmic8058_othc_config_pdata othc_config_pdata_2 = {
6290 .micbias_select = OTHC_MICBIAS_2,
6291 .micbias_capability = OTHC_MICBIAS,
6292 .micbias_enable = OTHC_SIGNAL_OFF,
6293 .micbias_regulator = &othc_reg,
6294};
6295
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006296
6297static void __init msm8x60_init_pm8058_othc(void)
6298{
6299 int i;
6300
6301 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 ||
6302 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
6303 machine_is_msm8x60_fusn_ffa()) {
6304 /* 3-switch headset supported only by V2 FFA and FLUID */
6305 hsed_config_1.accessories_adc_support = true,
6306 /* ADC based accessory detection works only on V2 and FLUID */
6307 hsed_config_1.accessories_adc_channel = CHANNEL_ADC_HDSET,
6308 hsed_config_1.othc_support_n_switch = true;
6309 }
6310
6311 /* IR GPIO is absent on FLUID */
6312 if (machine_is_msm8x60_fluid())
6313 hsed_config_1.ir_gpio = -1;
6314
6315 for (i = 0; i < ARRAY_SIZE(othc_accessories); i++) {
6316 if (machine_is_msm8x60_fluid()) {
6317 switch (othc_accessories[i].accessory) {
6318 case OTHC_ANC_HEADPHONE:
6319 case OTHC_ANC_HEADSET:
6320 othc_accessories[i].gpio = GPIO_HEADSET_DET_N;
6321 break;
6322 case OTHC_MICROPHONE:
6323 othc_accessories[i].enabled = false;
6324 break;
6325 case OTHC_SVIDEO_OUT:
6326 othc_accessories[i].enabled = true;
6327 hsed_config_1.video_out_gpio = GPIO_HS_SW_DIR;
6328 break;
6329 }
6330 }
6331 }
6332}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006333
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006334
6335static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
6336{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306337 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006338 .direction = PM_GPIO_DIR_OUT,
6339 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
6340 .output_value = 0,
6341 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306342 .vin_sel = PM8058_GPIO_VIN_VPH,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006343 .out_strength = PM_GPIO_STRENGTH_HIGH,
6344 .function = PM_GPIO_FUNC_2,
6345 };
6346
6347 int rc = -EINVAL;
6348 int id, mode, max_mA;
6349
6350 id = mode = max_mA = 0;
6351 switch (ch) {
6352 case 0:
6353 case 1:
6354 case 2:
6355 if (on) {
6356 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306357 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
6358 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006359 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306360 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006361 __func__, id, rc);
6362 }
6363 break;
6364
6365 case 6:
6366 id = PM_PWM_LED_FLASH;
6367 mode = PM_PWM_CONF_PWM1;
6368 max_mA = 300;
6369 break;
6370
6371 case 7:
6372 id = PM_PWM_LED_FLASH1;
6373 mode = PM_PWM_CONF_PWM1;
6374 max_mA = 300;
6375 break;
6376
6377 default:
6378 break;
6379 }
6380
6381 if (ch >= 6 && ch <= 7) {
6382 if (!on) {
6383 mode = PM_PWM_CONF_NONE;
6384 max_mA = 0;
6385 }
6386 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
6387 if (rc)
6388 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
6389 __func__, ch, rc);
6390 }
6391 return rc;
6392
6393}
6394
6395static struct pm8058_pwm_pdata pm8058_pwm_data = {
6396 .config = pm8058_pwm_config,
6397};
6398
6399#define PM8058_GPIO_INT 88
6400
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006401static struct pmic8058_led pmic8058_flash_leds[] = {
6402 [0] = {
6403 .name = "camera:flash0",
6404 .max_brightness = 15,
6405 .id = PMIC8058_ID_FLASH_LED_0,
6406 },
6407 [1] = {
6408 .name = "camera:flash1",
6409 .max_brightness = 15,
6410 .id = PMIC8058_ID_FLASH_LED_1,
6411 },
6412};
6413
6414static struct pmic8058_leds_platform_data pm8058_flash_leds_data = {
6415 .num_leds = ARRAY_SIZE(pmic8058_flash_leds),
6416 .leds = pmic8058_flash_leds,
6417};
6418
Terence Hampsonc0b6dfb2011-07-15 11:07:17 -04006419static struct pmic8058_led pmic8058_dragon_leds[] = {
6420 [0] = {
6421 /* RED */
6422 .name = "led_drv0",
6423 .max_brightness = 15,
6424 .id = PMIC8058_ID_LED_0,
6425 },/* 300 mA flash led0 drv sink */
6426 [1] = {
6427 /* Yellow */
6428 .name = "led_drv1",
6429 .max_brightness = 15,
6430 .id = PMIC8058_ID_LED_1,
6431 },/* 300 mA flash led0 drv sink */
6432 [2] = {
6433 /* Green */
6434 .name = "led_drv2",
6435 .max_brightness = 15,
6436 .id = PMIC8058_ID_LED_2,
6437 },/* 300 mA flash led0 drv sink */
6438 [3] = {
6439 .name = "led_psensor",
6440 .max_brightness = 15,
6441 .id = PMIC8058_ID_LED_KB_LIGHT,
6442 },/* 300 mA flash led0 drv sink */
6443};
6444
6445static struct pmic8058_leds_platform_data pm8058_dragon_leds_data = {
6446 .num_leds = ARRAY_SIZE(pmic8058_dragon_leds),
6447 .leds = pmic8058_dragon_leds,
6448};
6449
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006450static struct pmic8058_led pmic8058_fluid_flash_leds[] = {
6451 [0] = {
6452 .name = "led:drv0",
6453 .max_brightness = 15,
6454 .id = PMIC8058_ID_FLASH_LED_0,
6455 },/* 300 mA flash led0 drv sink */
6456 [1] = {
6457 .name = "led:drv1",
6458 .max_brightness = 15,
6459 .id = PMIC8058_ID_FLASH_LED_1,
6460 },/* 300 mA flash led1 sink */
6461 [2] = {
6462 .name = "led:drv2",
6463 .max_brightness = 20,
6464 .id = PMIC8058_ID_LED_0,
6465 },/* 40 mA led0 sink */
6466 [3] = {
6467 .name = "keypad:drv",
6468 .max_brightness = 15,
6469 .id = PMIC8058_ID_LED_KB_LIGHT,
6470 },/* 300 mA keypad drv sink */
6471};
6472
6473static struct pmic8058_leds_platform_data pm8058_fluid_flash_leds_data = {
6474 .num_leds = ARRAY_SIZE(pmic8058_fluid_flash_leds),
6475 .leds = pmic8058_fluid_flash_leds,
6476};
6477
Terence Hampson90508a92011-08-09 10:40:08 -04006478static struct pmic8058_charger_data pmic8058_charger_dragon = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306479 .charger_data_valid = true,
Terence Hampson90508a92011-08-09 10:40:08 -04006480 .max_source_current = 1800,
6481 .charger_type = CHG_TYPE_AC,
6482};
6483
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306484static struct pmic8058_charger_data pmic8058_charger_ffa_surf = {
6485 .charger_data_valid = false,
6486};
6487
6488static struct pm8xxx_misc_platform_data pm8058_misc_pdata = {
6489 .priority = 0,
6490};
6491
6492static struct pm8xxx_irq_platform_data pm8058_irq_pdata = {
6493 .irq_base = PM8058_IRQ_BASE,
6494 .devirq = MSM_GPIO_TO_INT(PM8058_GPIO_INT),
6495 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6496};
6497
6498static struct pm8xxx_gpio_platform_data pm8058_gpio_pdata = {
6499 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
6500};
6501
6502static struct pm8xxx_mpp_platform_data pm8058_mpp_pdata = {
6503 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006504};
6505
6506static struct pm8058_platform_data pm8058_platform_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306507 .irq_pdata = &pm8058_irq_pdata,
6508 .gpio_pdata = &pm8058_gpio_pdata,
6509 .mpp_pdata = &pm8058_mpp_pdata,
6510 .rtc_pdata = &pm8058_rtc_pdata,
6511 .pwrkey_pdata = &pm8058_pwrkey_pdata,
6512 .othc0_pdata = &othc_config_pdata_0,
6513 .othc1_pdata = &othc_config_pdata_1,
6514 .othc2_pdata = &othc_config_pdata_2,
6515 .pwm_pdata = &pm8058_pwm_data,
6516 .misc_pdata = &pm8058_misc_pdata,
6517#ifdef CONFIG_SENSORS_MSM_ADC
6518 .xoadc_pdata = &pm8058_xoadc_pdata,
6519#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006520};
6521
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306522#ifdef CONFIG_MSM_SSBI
6523static struct msm_ssbi_platform_data msm8x60_ssbi_pm8058_pdata __devinitdata = {
6524 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6525 .slave = {
6526 .name = "pm8058-core",
6527 .platform_data = &pm8058_platform_data,
6528 },
6529};
6530#endif
6531#endif /* CONFIG_PMIC8058 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006532
6533#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
6534 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
6535#define TDISC_I2C_SLAVE_ADDR 0x67
6536#define PMIC_GPIO_TDISC PM8058_GPIO_PM_TO_SYS(5)
6537#define TDISC_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 5)
6538
6539static const char *vregs_tdisc_name[] = {
6540 "8058_l5",
6541 "8058_s3",
6542};
6543
6544static const int vregs_tdisc_val[] = {
6545 2850000,/* uV */
6546 1800000,
6547};
6548static struct regulator *vregs_tdisc[ARRAY_SIZE(vregs_tdisc_name)];
6549
6550static int tdisc_shinetsu_setup(void)
6551{
6552 int rc, i;
6553
6554 rc = gpio_request(PMIC_GPIO_TDISC, "tdisc_interrupt");
6555 if (rc) {
6556 pr_err("%s: gpio_request failed for PMIC_GPIO_TDISC\n",
6557 __func__);
6558 return rc;
6559 }
6560
6561 rc = gpio_request(GPIO_JOYSTICK_EN, "tdisc_oe");
6562 if (rc) {
6563 pr_err("%s: gpio_request failed for GPIO_JOYSTICK_EN\n",
6564 __func__);
6565 goto fail_gpio_oe;
6566 }
6567
6568 rc = gpio_direction_output(GPIO_JOYSTICK_EN, 1);
6569 if (rc) {
6570 pr_err("%s: gpio_direction_output failed for GPIO_JOYSTICK_EN\n",
6571 __func__);
6572 gpio_free(GPIO_JOYSTICK_EN);
6573 goto fail_gpio_oe;
6574 }
6575
6576 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6577 vregs_tdisc[i] = regulator_get(NULL, vregs_tdisc_name[i]);
6578 if (IS_ERR(vregs_tdisc[i])) {
6579 printk(KERN_ERR "%s: regulator get %s failed (%ld)\n",
6580 __func__, vregs_tdisc_name[i],
6581 PTR_ERR(vregs_tdisc[i]));
6582 rc = PTR_ERR(vregs_tdisc[i]);
6583 goto vreg_get_fail;
6584 }
6585
6586 rc = regulator_set_voltage(vregs_tdisc[i],
6587 vregs_tdisc_val[i], vregs_tdisc_val[i]);
6588 if (rc) {
6589 printk(KERN_ERR "%s: regulator_set_voltage() = %d\n",
6590 __func__, rc);
6591 goto vreg_set_voltage_fail;
6592 }
6593 }
6594
6595 return rc;
6596vreg_set_voltage_fail:
6597 i++;
6598vreg_get_fail:
6599 while (i)
6600 regulator_put(vregs_tdisc[--i]);
6601fail_gpio_oe:
6602 gpio_free(PMIC_GPIO_TDISC);
6603 return rc;
6604}
6605
6606static void tdisc_shinetsu_release(void)
6607{
6608 int i;
6609
6610 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++)
6611 regulator_put(vregs_tdisc[i]);
6612
6613 gpio_free(PMIC_GPIO_TDISC);
6614 gpio_free(GPIO_JOYSTICK_EN);
6615}
6616
6617static int tdisc_shinetsu_enable(void)
6618{
6619 int i, rc = -EINVAL;
6620
6621 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6622 rc = regulator_enable(vregs_tdisc[i]);
6623 if (rc < 0) {
6624 printk(KERN_ERR "%s: vreg %s enable failed (%d)\n",
6625 __func__, vregs_tdisc_name[i], rc);
6626 goto vreg_fail;
6627 }
6628 }
6629
6630 /* Enable the OE (output enable) gpio */
6631 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 1);
6632 /* voltage and gpio stabilization delay */
6633 msleep(50);
6634
6635 return 0;
6636vreg_fail:
6637 while (i)
6638 regulator_disable(vregs_tdisc[--i]);
6639 return rc;
6640}
6641
6642static int tdisc_shinetsu_disable(void)
6643{
6644 int i, rc;
6645
6646 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6647 rc = regulator_disable(vregs_tdisc[i]);
6648 if (rc < 0) {
6649 printk(KERN_ERR "%s: vreg %s disable failed (%d)\n",
6650 __func__, vregs_tdisc_name[i], rc);
6651 goto tdisc_reg_fail;
6652 }
6653 }
6654
6655 /* Disable the OE (output enable) gpio */
6656 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 0);
6657
6658 return 0;
6659
6660tdisc_reg_fail:
6661 while (i)
6662 regulator_enable(vregs_tdisc[--i]);
6663 return rc;
6664}
6665
6666static struct tdisc_abs_values tdisc_abs = {
6667 .x_max = 32,
6668 .y_max = 32,
6669 .x_min = -32,
6670 .y_min = -32,
6671 .pressure_max = 32,
6672 .pressure_min = 0,
6673};
6674
6675static struct tdisc_platform_data tdisc_data = {
6676 .tdisc_setup = tdisc_shinetsu_setup,
6677 .tdisc_release = tdisc_shinetsu_release,
6678 .tdisc_enable = tdisc_shinetsu_enable,
6679 .tdisc_disable = tdisc_shinetsu_disable,
6680 .tdisc_wakeup = 0,
6681 .tdisc_gpio = PMIC_GPIO_TDISC,
6682 .tdisc_report_keys = true,
6683 .tdisc_report_relative = true,
6684 .tdisc_report_absolute = false,
6685 .tdisc_report_wheel = false,
6686 .tdisc_reverse_x = false,
6687 .tdisc_reverse_y = true,
6688 .tdisc_abs = &tdisc_abs,
6689};
6690
6691static struct i2c_board_info msm_i2c_gsbi3_tdisc_info[] = {
6692 {
6693 I2C_BOARD_INFO("vtd518", TDISC_I2C_SLAVE_ADDR),
6694 .irq = TDISC_INT,
6695 .platform_data = &tdisc_data,
6696 },
6697};
6698#endif
6699
6700#define PM_GPIO_CDC_RST_N 20
6701#define GPIO_CDC_RST_N PM8058_GPIO_PM_TO_SYS(PM_GPIO_CDC_RST_N)
6702
6703static struct regulator *vreg_timpani_1;
6704static struct regulator *vreg_timpani_2;
6705
6706static unsigned int msm_timpani_setup_power(void)
6707{
6708 int rc;
6709
6710 vreg_timpani_1 = regulator_get(NULL, "8058_l0");
6711 if (IS_ERR(vreg_timpani_1)) {
6712 pr_err("%s: Unable to get 8058_l0\n", __func__);
6713 return -ENODEV;
6714 }
6715
6716 vreg_timpani_2 = regulator_get(NULL, "8058_s3");
6717 if (IS_ERR(vreg_timpani_2)) {
6718 pr_err("%s: Unable to get 8058_s3\n", __func__);
6719 regulator_put(vreg_timpani_1);
6720 return -ENODEV;
6721 }
6722
6723 rc = regulator_set_voltage(vreg_timpani_1, 1200000, 1200000);
6724 if (rc) {
6725 pr_err("%s: unable to set L0 voltage to 1.2V\n", __func__);
6726 goto fail;
6727 }
6728
6729 rc = regulator_set_voltage(vreg_timpani_2, 1800000, 1800000);
6730 if (rc) {
6731 pr_err("%s: unable to set S3 voltage to 1.8V\n", __func__);
6732 goto fail;
6733 }
6734
6735 rc = regulator_enable(vreg_timpani_1);
6736 if (rc) {
6737 pr_err("%s: Enable regulator 8058_l0 failed\n", __func__);
6738 goto fail;
6739 }
6740
6741 /* The settings for LDO0 should be set such that
6742 * it doesn't require to reset the timpani. */
6743 rc = regulator_set_optimum_mode(vreg_timpani_1, 5000);
6744 if (rc < 0) {
6745 pr_err("Timpani regulator optimum mode setting failed\n");
6746 goto fail;
6747 }
6748
6749 rc = regulator_enable(vreg_timpani_2);
6750 if (rc) {
6751 pr_err("%s: Enable regulator 8058_s3 failed\n", __func__);
6752 regulator_disable(vreg_timpani_1);
6753 goto fail;
6754 }
6755
6756 rc = gpio_request(GPIO_CDC_RST_N, "CDC_RST_N");
6757 if (rc) {
6758 pr_err("%s: GPIO Request %d failed\n", __func__,
6759 GPIO_CDC_RST_N);
6760 regulator_disable(vreg_timpani_1);
6761 regulator_disable(vreg_timpani_2);
6762 goto fail;
6763 } else {
6764 gpio_direction_output(GPIO_CDC_RST_N, 1);
6765 usleep_range(1000, 1050);
6766 gpio_direction_output(GPIO_CDC_RST_N, 0);
6767 usleep_range(1000, 1050);
6768 gpio_direction_output(GPIO_CDC_RST_N, 1);
6769 gpio_free(GPIO_CDC_RST_N);
6770 }
6771 return rc;
6772
6773fail:
6774 regulator_put(vreg_timpani_1);
6775 regulator_put(vreg_timpani_2);
6776 return rc;
6777}
6778
6779static void msm_timpani_shutdown_power(void)
6780{
6781 int rc;
6782
6783 rc = regulator_disable(vreg_timpani_1);
6784 if (rc)
6785 pr_err("%s: Disable regulator 8058_l0 failed\n", __func__);
6786
6787 regulator_put(vreg_timpani_1);
6788
6789 rc = regulator_disable(vreg_timpani_2);
6790 if (rc)
6791 pr_err("%s: Disable regulator 8058_s3 failed\n", __func__);
6792
6793 regulator_put(vreg_timpani_2);
6794}
6795
6796/* Power analog function of codec */
6797static struct regulator *vreg_timpani_cdc_apwr;
6798static int msm_timpani_codec_power(int vreg_on)
6799{
6800 int rc = 0;
6801
6802 if (!vreg_timpani_cdc_apwr) {
6803
6804 vreg_timpani_cdc_apwr = regulator_get(NULL, "8058_s4");
6805
6806 if (IS_ERR(vreg_timpani_cdc_apwr)) {
6807 pr_err("%s: vreg_get failed (%ld)\n",
6808 __func__, PTR_ERR(vreg_timpani_cdc_apwr));
6809 rc = PTR_ERR(vreg_timpani_cdc_apwr);
6810 return rc;
6811 }
6812 }
6813
6814 if (vreg_on) {
6815
6816 rc = regulator_set_voltage(vreg_timpani_cdc_apwr,
6817 2200000, 2200000);
6818 if (rc) {
6819 pr_err("%s: unable to set 8058_s4 voltage to 2.2 V\n",
6820 __func__);
6821 goto vreg_fail;
6822 }
6823
6824 rc = regulator_enable(vreg_timpani_cdc_apwr);
6825 if (rc) {
6826 pr_err("%s: vreg_enable failed %d\n", __func__, rc);
6827 goto vreg_fail;
6828 }
6829 } else {
6830 rc = regulator_disable(vreg_timpani_cdc_apwr);
6831 if (rc) {
6832 pr_err("%s: vreg_disable failed %d\n",
6833 __func__, rc);
6834 goto vreg_fail;
6835 }
6836 }
6837
6838 return 0;
6839
6840vreg_fail:
6841 regulator_put(vreg_timpani_cdc_apwr);
6842 vreg_timpani_cdc_apwr = NULL;
6843 return rc;
6844}
6845
6846static struct marimba_codec_platform_data timpani_codec_pdata = {
6847 .marimba_codec_power = msm_timpani_codec_power,
6848};
6849
6850#define TIMPANI_SLAVE_ID_CDC_ADDR 0X77
6851#define TIMPANI_SLAVE_ID_QMEMBIST_ADDR 0X66
6852
6853static struct marimba_platform_data timpani_pdata = {
6854 .slave_id[MARIMBA_SLAVE_ID_CDC] = TIMPANI_SLAVE_ID_CDC_ADDR,
6855 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = TIMPANI_SLAVE_ID_QMEMBIST_ADDR,
6856 .marimba_setup = msm_timpani_setup_power,
6857 .marimba_shutdown = msm_timpani_shutdown_power,
6858 .codec = &timpani_codec_pdata,
6859 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6860};
6861
6862#define TIMPANI_I2C_SLAVE_ADDR 0xD
6863
6864static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
6865 {
6866 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
6867 .platform_data = &timpani_pdata,
6868 },
6869};
6870
Lei Zhou338cab82011-08-19 13:38:17 -04006871#ifdef CONFIG_SND_SOC_WM8903
6872static struct wm8903_platform_data wm8903_pdata = {
6873 .gpio_cfg[2] = 0x3A8,
6874};
6875
6876#define WM8903_I2C_SLAVE_ADDR 0x34
6877static struct i2c_board_info wm8903_codec_i2c_info[] = {
6878 {
6879 I2C_BOARD_INFO("wm8903", WM8903_I2C_SLAVE_ADDR >> 1),
6880 .platform_data = &wm8903_pdata,
6881 },
6882};
6883#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006884#ifdef CONFIG_PMIC8901
6885
6886#define PM8901_GPIO_INT 91
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006887/*
6888 * Consumer specific regulator names:
6889 * regulator name consumer dev_name
6890 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006891static struct regulator_consumer_supply vreg_consumers_8901_USB_OTG[] = {
6892 REGULATOR_SUPPLY("8901_usb_otg", NULL),
6893};
6894static struct regulator_consumer_supply vreg_consumers_8901_HDMI_MVS[] = {
6895 REGULATOR_SUPPLY("8901_hdmi_mvs", NULL),
6896};
6897
6898#define PM8901_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306899 _always_on) \
6900 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006901 .init_data = { \
6902 .constraints = { \
6903 .valid_modes_mask = _modes, \
6904 .valid_ops_mask = _ops, \
6905 .min_uV = _min_uV, \
6906 .max_uV = _max_uV, \
6907 .input_uV = _min_uV, \
6908 .apply_uV = _apply_uV, \
6909 .always_on = _always_on, \
6910 }, \
6911 .consumer_supplies = vreg_consumers_8901_##_id, \
6912 .num_consumer_supplies = \
6913 ARRAY_SIZE(vreg_consumers_8901_##_id), \
6914 }, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306915 .id = PM8901_VREG_ID_##_id, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006916 }
6917
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006918#define PM8901_VREG_INIT_VS(_id) \
6919 PM8901_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306920 REGULATOR_CHANGE_STATUS, 0, 0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006921
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306922static struct pm8901_vreg_pdata pm8901_vreg_init[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006923 PM8901_VREG_INIT_VS(USB_OTG),
6924 PM8901_VREG_INIT_VS(HDMI_MVS),
6925};
6926
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306927static struct pm8xxx_misc_platform_data pm8901_misc_pdata = {
6928 .priority = 1,
6929};
6930
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306931static struct pm8xxx_irq_platform_data pm8901_irq_pdata = {
6932 .irq_base = PM8901_IRQ_BASE,
6933 .devirq = MSM_GPIO_TO_INT(PM8901_GPIO_INT),
6934 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6935};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006936
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306937static struct pm8xxx_mpp_platform_data pm8901_mpp_pdata = {
6938 .mpp_base = PM8901_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006939};
6940
6941static struct pm8901_platform_data pm8901_platform_data = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306942 .irq_pdata = &pm8901_irq_pdata,
6943 .mpp_pdata = &pm8901_mpp_pdata,
6944 .regulator_pdatas = pm8901_vreg_init,
6945 .num_regulators = ARRAY_SIZE(pm8901_vreg_init),
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306946 .misc_pdata = &pm8901_misc_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006947};
6948
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05306949static struct msm_ssbi_platform_data msm8x60_ssbi_pm8901_pdata __devinitdata = {
6950 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6951 .slave = {
6952 .name = "pm8901-core",
6953 .platform_data = &pm8901_platform_data,
6954 },
6955};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006956#endif /* CONFIG_PMIC8901 */
6957
6958#if defined(CONFIG_MARIMBA_CORE) && (defined(CONFIG_GPIO_SX150X) \
6959 || defined(CONFIG_GPIO_SX150X_MODULE))
6960
6961static struct regulator *vreg_bahama;
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006962static int msm_bahama_sys_rst = GPIO_MS_SYS_RESET_N;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006963
6964struct bahama_config_register{
6965 u8 reg;
6966 u8 value;
6967 u8 mask;
6968};
6969
6970enum version{
6971 VER_1_0,
6972 VER_2_0,
6973 VER_UNSUPPORTED = 0xFF
6974};
6975
6976static u8 read_bahama_ver(void)
6977{
6978 int rc;
6979 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6980 u8 bahama_version;
6981
6982 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
6983 if (rc < 0) {
6984 printk(KERN_ERR
6985 "%s: version read failed: %d\n",
6986 __func__, rc);
6987 return VER_UNSUPPORTED;
6988 } else {
6989 printk(KERN_INFO
6990 "%s: version read got: 0x%x\n",
6991 __func__, bahama_version);
6992 }
6993
6994 switch (bahama_version) {
6995 case 0x08: /* varient of bahama v1 */
6996 case 0x10:
6997 case 0x00:
6998 return VER_1_0;
6999 case 0x09: /* variant of bahama v2 */
7000 return VER_2_0;
7001 default:
7002 return VER_UNSUPPORTED;
7003 }
7004}
7005
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07007006static int msm_bahama_setup_power_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007007static unsigned int msm_bahama_setup_power(void)
7008{
7009 int rc = 0;
7010 const char *msm_bahama_regulator = "8058_s3";
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04007011
7012 if (machine_is_msm8x60_dragon())
7013 msm_bahama_sys_rst = GPIO_CDC_RST_N;
7014
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007015 vreg_bahama = regulator_get(NULL, msm_bahama_regulator);
7016
7017 if (IS_ERR(vreg_bahama)) {
7018 rc = PTR_ERR(vreg_bahama);
7019 pr_err("%s: regulator_get %s = %d\n", __func__,
7020 msm_bahama_regulator, rc);
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07007021 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007022 }
7023
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07007024 rc = regulator_set_voltage(vreg_bahama, 1800000, 1800000);
7025 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007026 pr_err("%s: regulator_set_voltage %s = %d\n", __func__,
7027 msm_bahama_regulator, rc);
7028 goto unget;
7029 }
7030
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07007031 rc = regulator_enable(vreg_bahama);
7032 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007033 pr_err("%s: regulator_enable %s = %d\n", __func__,
7034 msm_bahama_regulator, rc);
7035 goto unget;
7036 }
7037
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07007038 rc = gpio_request(msm_bahama_sys_rst, "bahama sys_rst_n");
7039 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007040 pr_err("%s: gpio_request %d = %d\n", __func__,
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04007041 msm_bahama_sys_rst, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007042 goto unenable;
7043 }
7044
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07007045 gpio_direction_output(msm_bahama_sys_rst, 0);
7046 usleep_range(1000, 1050);
7047 gpio_set_value_cansleep(msm_bahama_sys_rst, 1);
7048 usleep_range(1000, 1050);
7049 msm_bahama_setup_power_enable = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007050 return rc;
7051
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007052unenable:
7053 regulator_disable(vreg_bahama);
7054unget:
7055 regulator_put(vreg_bahama);
7056 return rc;
7057};
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07007058
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007059static unsigned int msm_bahama_shutdown_power(int value)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007060{
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07007061 if (msm_bahama_setup_power_enable) {
7062 gpio_set_value_cansleep(msm_bahama_sys_rst, 0);
7063 gpio_free(msm_bahama_sys_rst);
7064 regulator_disable(vreg_bahama);
7065 regulator_put(vreg_bahama);
7066 msm_bahama_setup_power_enable = 0;
7067 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007068
7069 return 0;
7070};
7071
7072static unsigned int msm_bahama_core_config(int type)
7073{
7074 int rc = 0;
7075
7076 if (type == BAHAMA_ID) {
7077
7078 int i;
7079 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
7080
7081 const struct bahama_config_register v20_init[] = {
7082 /* reg, value, mask */
7083 { 0xF4, 0x84, 0xFF }, /* AREG */
7084 { 0xF0, 0x04, 0xFF } /* DREG */
7085 };
7086
7087 if (read_bahama_ver() == VER_2_0) {
7088 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
7089 u8 value = v20_init[i].value;
7090 rc = marimba_write_bit_mask(&config,
7091 v20_init[i].reg,
7092 &value,
7093 sizeof(v20_init[i].value),
7094 v20_init[i].mask);
7095 if (rc < 0) {
7096 printk(KERN_ERR
7097 "%s: reg %d write failed: %d\n",
7098 __func__, v20_init[i].reg, rc);
7099 return rc;
7100 }
7101 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
7102 " mask 0x%02x\n",
7103 __func__, v20_init[i].reg,
7104 v20_init[i].value, v20_init[i].mask);
7105 }
7106 }
7107 }
7108 printk(KERN_INFO "core type: %d\n", type);
7109
7110 return rc;
7111}
7112
7113static struct regulator *fm_regulator_s3;
7114static struct msm_xo_voter *fm_clock;
7115
7116static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
7117{
7118 int rc = 0;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307119 struct pm_gpio cfg = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007120 .direction = PM_GPIO_DIR_IN,
7121 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307122 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007123 .function = PM_GPIO_FUNC_NORMAL,
7124 .inv_int_pol = 0,
7125 };
7126
7127 if (!fm_regulator_s3) {
7128 fm_regulator_s3 = regulator_get(NULL, "8058_s3");
7129 if (IS_ERR(fm_regulator_s3)) {
7130 rc = PTR_ERR(fm_regulator_s3);
7131 printk(KERN_ERR "%s: regulator get s3 (%d)\n",
7132 __func__, rc);
7133 goto out;
7134 }
7135 }
7136
7137
7138 rc = regulator_set_voltage(fm_regulator_s3, 1800000, 1800000);
7139 if (rc < 0) {
7140 printk(KERN_ERR "%s: regulator set voltage failed (%d)\n",
7141 __func__, rc);
7142 goto fm_fail_put;
7143 }
7144
7145 rc = regulator_enable(fm_regulator_s3);
7146 if (rc < 0) {
7147 printk(KERN_ERR "%s: regulator s3 enable failed (%d)\n",
7148 __func__, rc);
7149 goto fm_fail_put;
7150 }
7151
7152 /*Vote for XO clock*/
7153 fm_clock = msm_xo_get(MSM_XO_TCXO_D0, "fm_power");
7154
7155 if (IS_ERR(fm_clock)) {
7156 rc = PTR_ERR(fm_clock);
7157 printk(KERN_ERR "%s: Couldn't get TCXO_D0 vote for FM (%d)\n",
7158 __func__, rc);
7159 goto fm_fail_switch;
7160 }
7161
7162 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_ON);
7163 if (rc < 0) {
7164 printk(KERN_ERR "%s: Failed to vote for TCX0_D0 ON (%d)\n",
7165 __func__, rc);
7166 goto fm_fail_vote;
7167 }
7168
7169 /*GPIO 18 on PMIC is FM_IRQ*/
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307170 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(FM_GPIO), &cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007171 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307172 printk(KERN_ERR "%s: return val of pm8xxx_gpio_config: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007173 __func__, rc);
7174 goto fm_fail_clock;
7175 }
7176 goto out;
7177
7178fm_fail_clock:
7179 msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7180fm_fail_vote:
7181 msm_xo_put(fm_clock);
7182fm_fail_switch:
7183 regulator_disable(fm_regulator_s3);
7184fm_fail_put:
7185 regulator_put(fm_regulator_s3);
7186out:
7187 return rc;
7188};
7189
7190static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
7191{
7192 int rc = 0;
7193 if (fm_regulator_s3 != NULL) {
7194 rc = regulator_disable(fm_regulator_s3);
7195 if (rc < 0) {
7196 printk(KERN_ERR "%s: regulator s3 disable (%d)\n",
7197 __func__, rc);
7198 }
7199 regulator_put(fm_regulator_s3);
7200 fm_regulator_s3 = NULL;
7201 }
7202 printk(KERN_ERR "%s: Voting off for XO", __func__);
7203
7204 if (fm_clock != NULL) {
7205 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7206 if (rc < 0) {
7207 printk(KERN_ERR "%s: Voting off XO clock (%d)\n",
7208 __func__, rc);
7209 }
7210 msm_xo_put(fm_clock);
7211 }
7212 printk(KERN_ERR "%s: coming out of fm_radio_shutdown", __func__);
7213}
7214
7215/* Slave id address for FM/CDC/QMEMBIST
7216 * Values can be programmed using Marimba slave id 0
7217 * should there be a conflict with other I2C devices
7218 * */
7219#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
7220#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
7221
7222static struct marimba_fm_platform_data marimba_fm_pdata = {
7223 .fm_setup = fm_radio_setup,
7224 .fm_shutdown = fm_radio_shutdown,
7225 .irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, FM_GPIO),
7226 .is_fm_soc_i2s_master = false,
7227 .config_i2s_gpio = NULL,
7228};
7229
7230/*
7231Just initializing the BAHAMA related slave
7232*/
7233static struct marimba_platform_data marimba_pdata = {
7234 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
7235 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
7236 .bahama_setup = msm_bahama_setup_power,
7237 .bahama_shutdown = msm_bahama_shutdown_power,
7238 .bahama_core_config = msm_bahama_core_config,
7239 .fm = &marimba_fm_pdata,
7240 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
7241};
7242
7243
7244static struct i2c_board_info msm_marimba_board_info[] = {
7245 {
7246 I2C_BOARD_INFO("marimba", 0xc),
7247 .platform_data = &marimba_pdata,
7248 }
7249};
7250#endif /* CONFIG_MAIMBA_CORE */
7251
7252#ifdef CONFIG_I2C
7253#define I2C_SURF 1
7254#define I2C_FFA (1 << 1)
7255#define I2C_RUMI (1 << 2)
7256#define I2C_SIM (1 << 3)
7257#define I2C_FLUID (1 << 4)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007258#define I2C_DRAGON (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007259
7260struct i2c_registry {
7261 u8 machs;
7262 int bus;
7263 struct i2c_board_info *info;
7264 int len;
7265};
7266
7267static struct i2c_registry msm8x60_i2c_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007268#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7269 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007270 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007271 MSM_GSBI8_QUP_I2C_BUS_ID,
7272 core_expander_i2c_info,
7273 ARRAY_SIZE(core_expander_i2c_info),
7274 },
7275 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007276 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007277 MSM_GSBI8_QUP_I2C_BUS_ID,
7278 docking_expander_i2c_info,
7279 ARRAY_SIZE(docking_expander_i2c_info),
7280 },
7281 {
7282 I2C_SURF,
7283 MSM_GSBI8_QUP_I2C_BUS_ID,
7284 surf_expanders_i2c_info,
7285 ARRAY_SIZE(surf_expanders_i2c_info),
7286 },
7287 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007288 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007289 MSM_GSBI3_QUP_I2C_BUS_ID,
7290 fha_expanders_i2c_info,
7291 ARRAY_SIZE(fha_expanders_i2c_info),
7292 },
7293 {
7294 I2C_FLUID,
7295 MSM_GSBI3_QUP_I2C_BUS_ID,
7296 fluid_expanders_i2c_info,
7297 ARRAY_SIZE(fluid_expanders_i2c_info),
7298 },
7299 {
7300 I2C_FLUID,
7301 MSM_GSBI8_QUP_I2C_BUS_ID,
7302 fluid_core_expander_i2c_info,
7303 ARRAY_SIZE(fluid_core_expander_i2c_info),
7304 },
7305#endif
7306#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
7307 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
7308 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007309 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007310 MSM_GSBI3_QUP_I2C_BUS_ID,
7311 msm_i2c_gsbi3_tdisc_info,
7312 ARRAY_SIZE(msm_i2c_gsbi3_tdisc_info),
7313 },
7314#endif
7315 {
Zhang Chang Ken211df572011-07-05 19:16:39 -04007316 I2C_SURF | I2C_FFA | I2C_FLUID,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007317 MSM_GSBI3_QUP_I2C_BUS_ID,
7318 cy8ctmg200_board_info,
7319 ARRAY_SIZE(cy8ctmg200_board_info),
7320 },
Zhang Chang Ken211df572011-07-05 19:16:39 -04007321 {
7322 I2C_DRAGON,
7323 MSM_GSBI3_QUP_I2C_BUS_ID,
7324 cy8ctma340_dragon_board_info,
7325 ARRAY_SIZE(cy8ctma340_dragon_board_info),
7326 },
Steve Mucklef132c6c2012-06-06 18:30:57 -07007327#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
7328 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007329 {
7330 I2C_FLUID,
7331 MSM_GSBI3_QUP_I2C_BUS_ID,
7332 cyttsp_fluid_info,
7333 ARRAY_SIZE(cyttsp_fluid_info),
7334 },
7335 {
7336 I2C_FFA | I2C_SURF,
7337 MSM_GSBI3_QUP_I2C_BUS_ID,
7338 cyttsp_ffa_info,
7339 ARRAY_SIZE(cyttsp_ffa_info),
7340 },
7341#endif
7342#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07007343#ifndef CONFIG_MSM_CAMERA_V4L2
Jilai Wang971f97f2011-07-13 14:25:25 -04007344 {
7345 I2C_SURF | I2C_FFA | I2C_FLUID ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007346 MSM_GSBI4_QUP_I2C_BUS_ID,
7347 msm_camera_boardinfo,
7348 ARRAY_SIZE(msm_camera_boardinfo),
7349 },
Jilai Wang971f97f2011-07-13 14:25:25 -04007350 {
7351 I2C_DRAGON,
7352 MSM_GSBI4_QUP_I2C_BUS_ID,
7353 msm_camera_dragon_boardinfo,
7354 ARRAY_SIZE(msm_camera_dragon_boardinfo),
7355 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007356#endif
Kevin Chan3be11612012-03-22 20:05:40 -07007357#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007358 {
7359 I2C_SURF | I2C_FFA | I2C_FLUID,
7360 MSM_GSBI7_QUP_I2C_BUS_ID,
7361 msm_i2c_gsbi7_timpani_info,
7362 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info),
7363 },
7364#if defined(CONFIG_MARIMBA_CORE)
7365 {
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04007366 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007367 MSM_GSBI7_QUP_I2C_BUS_ID,
7368 msm_marimba_board_info,
7369 ARRAY_SIZE(msm_marimba_board_info),
7370 },
7371#endif /* CONFIG_MARIMBA_CORE */
7372#ifdef CONFIG_ISL9519_CHARGER
7373 {
7374 I2C_SURF | I2C_FFA,
7375 MSM_GSBI8_QUP_I2C_BUS_ID,
7376 isl_charger_i2c_info,
7377 ARRAY_SIZE(isl_charger_i2c_info),
7378 },
7379#endif
7380#if defined(CONFIG_HAPTIC_ISA1200) || \
7381 defined(CONFIG_HAPTIC_ISA1200_MODULE)
7382 {
7383 I2C_FLUID,
7384 MSM_GSBI8_QUP_I2C_BUS_ID,
7385 msm_isa1200_board_info,
7386 ARRAY_SIZE(msm_isa1200_board_info),
7387 },
7388#endif
7389#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
7390 {
7391 I2C_FLUID,
7392 MSM_GSBI8_QUP_I2C_BUS_ID,
7393 smb137b_charger_i2c_info,
7394 ARRAY_SIZE(smb137b_charger_i2c_info),
7395 },
7396#endif
7397#if defined(CONFIG_BATTERY_BQ27520) || \
7398 defined(CONFIG_BATTERY_BQ27520_MODULE)
7399 {
7400 I2C_FLUID,
7401 MSM_GSBI8_QUP_I2C_BUS_ID,
7402 msm_bq27520_board_info,
7403 ARRAY_SIZE(msm_bq27520_board_info),
7404 },
7405#endif
Lei Zhou338cab82011-08-19 13:38:17 -04007406#if defined(CONFIG_SND_SOC_WM8903) || defined(CONFIG_SND_SOC_WM8903_MODULE)
7407 {
7408 I2C_DRAGON,
7409 MSM_GSBI8_QUP_I2C_BUS_ID,
7410 wm8903_codec_i2c_info,
7411 ARRAY_SIZE(wm8903_codec_i2c_info),
7412 },
7413#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007414};
7415#endif /* CONFIG_I2C */
7416
Stephen Boyd668d7652012-04-25 11:31:01 -07007417static void __init fixup_i2c_configs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007418{
7419#ifdef CONFIG_I2C
7420#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7421 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7422 sx150x_data[SX150X_CORE].irq_summary =
7423 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT2_N);
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007424 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
7425 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007426 sx150x_data[SX150X_CORE].irq_summary =
7427 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7428 else if (machine_is_msm8x60_fluid())
7429 sx150x_data[SX150X_CORE_FLUID].irq_summary =
7430 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7431#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007432#endif
7433}
7434
Stephen Boyd668d7652012-04-25 11:31:01 -07007435static void __init register_i2c_devices(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007436{
7437#ifdef CONFIG_I2C
7438 u8 mach_mask = 0;
7439 int i;
Kevin Chan3be11612012-03-22 20:05:40 -07007440#ifdef CONFIG_MSM_CAMERA_V4L2
7441 struct i2c_registry msm8x60_camera_i2c_devices = {
7442 I2C_SURF | I2C_FFA | I2C_FLUID,
7443 MSM_GSBI4_QUP_I2C_BUS_ID,
7444 msm8x60_camera_board_info.board_info,
7445 msm8x60_camera_board_info.num_i2c_board_info,
7446 };
7447#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007448
7449 /* Build the matching 'supported_machs' bitmask */
7450 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7451 mach_mask = I2C_SURF;
7452 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
7453 mach_mask = I2C_FFA;
7454 else if (machine_is_msm8x60_rumi3())
7455 mach_mask = I2C_RUMI;
7456 else if (machine_is_msm8x60_sim())
7457 mach_mask = I2C_SIM;
7458 else if (machine_is_msm8x60_fluid())
7459 mach_mask = I2C_FLUID;
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007460 else if (machine_is_msm8x60_dragon())
7461 mach_mask = I2C_DRAGON;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007462 else
7463 pr_err("unmatched machine ID in register_i2c_devices\n");
7464
7465 /* Run the array and install devices as appropriate */
7466 for (i = 0; i < ARRAY_SIZE(msm8x60_i2c_devices); ++i) {
7467 if (msm8x60_i2c_devices[i].machs & mach_mask)
7468 i2c_register_board_info(msm8x60_i2c_devices[i].bus,
7469 msm8x60_i2c_devices[i].info,
7470 msm8x60_i2c_devices[i].len);
7471 }
Kevin Chan3be11612012-03-22 20:05:40 -07007472#ifdef CONFIG_MSM_CAMERA_V4L2
7473 if (msm8x60_camera_i2c_devices.machs & mach_mask)
7474 i2c_register_board_info(msm8x60_camera_i2c_devices.bus,
7475 msm8x60_camera_i2c_devices.info,
7476 msm8x60_camera_i2c_devices.len);
7477#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007478#endif
7479}
7480
7481static void __init msm8x60_init_uart12dm(void)
7482{
7483#if !defined(CONFIG_USB_PEHCI_HCD) && !defined(CONFIG_USB_PEHCI_HCD_MODULE)
7484 /* 0x1D000000 now belongs to EBI2:CS3 i.e. USB ISP Controller */
7485 void *fpga_mem = ioremap_nocache(0x1D000000, SZ_4K);
7486
7487 if (!fpga_mem)
7488 pr_err("%s(): Error getting memory\n", __func__);
7489
7490 /* Advanced mode */
7491 writew(0xFFFF, fpga_mem + 0x15C);
7492 /* FPGA_UART_SEL */
7493 writew(0, fpga_mem + 0x172);
7494 /* FPGA_GPIO_CONFIG_117 */
7495 writew(1, fpga_mem + 0xEA);
7496 /* FPGA_GPIO_CONFIG_118 */
7497 writew(1, fpga_mem + 0xEC);
7498 mb();
7499 iounmap(fpga_mem);
7500#endif
7501}
7502
7503#define MSM_GSBI9_PHYS 0x19900000
7504#define GSBI_DUAL_MODE_CODE 0x60
7505
7506static void __init msm8x60_init_buses(void)
7507{
7508#ifdef CONFIG_I2C_QUP
7509 void *gsbi_mem = ioremap_nocache(0x19C00000, 4);
7510 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI12 */
7511 writel_relaxed(0x6 << 4, gsbi_mem);
7512 /* Ensure protocol code is written before proceeding further */
7513 mb();
7514 iounmap(gsbi_mem);
7515
7516 msm_gsbi3_qup_i2c_device.dev.platform_data = &msm_gsbi3_qup_i2c_pdata;
7517 msm_gsbi4_qup_i2c_device.dev.platform_data = &msm_gsbi4_qup_i2c_pdata;
7518 msm_gsbi7_qup_i2c_device.dev.platform_data = &msm_gsbi7_qup_i2c_pdata;
7519 msm_gsbi8_qup_i2c_device.dev.platform_data = &msm_gsbi8_qup_i2c_pdata;
7520
7521#ifdef CONFIG_MSM_GSBI9_UART
7522 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7523 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI9 */
7524 gsbi_mem = ioremap_nocache(MSM_GSBI9_PHYS, 4);
7525 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
7526 iounmap(gsbi_mem);
7527 msm_gsbi9_qup_i2c_pdata.use_gsbi_shared_mode = 1;
7528 }
7529#endif
7530 msm_gsbi9_qup_i2c_device.dev.platform_data = &msm_gsbi9_qup_i2c_pdata;
7531 msm_gsbi12_qup_i2c_device.dev.platform_data = &msm_gsbi12_qup_i2c_pdata;
7532#endif
7533#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7534 msm_gsbi1_qup_spi_device.dev.platform_data = &msm_gsbi1_qup_spi_pdata;
7535#endif
7536#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007537 msm_device_ssbi3.dev.platform_data = &msm_ssbi3_pdata;
7538#endif
7539
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307540#ifdef CONFIG_MSM_SSBI
7541 msm_device_ssbi_pmic1.dev.platform_data =
7542 &msm8x60_ssbi_pm8058_pdata;
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05307543 msm_device_ssbi_pmic2.dev.platform_data =
7544 &msm8x60_ssbi_pm8901_pdata;
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307545#endif
7546
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007547 if (machine_is_msm8x60_fluid()) {
7548#if (defined(CONFIG_USB_EHCI_MSM_72K) && \
7549 (defined(CONFIG_SMB137B_CHARGER) || \
7550 defined(CONFIG_SMB137B_CHARGER_MODULE)))
7551 msm_otg_pdata.vbus_power = msm_hsusb_smb137b_vbus_power;
7552#endif
7553#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7554 msm_gsbi10_qup_spi_device.dev.platform_data =
7555 &msm_gsbi10_qup_spi_pdata;
7556#endif
7557 }
7558
Lena Salman57d167e2012-03-21 19:46:38 +02007559#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007560 /*
7561 * We can not put USB regulators (8058_l6 and 8058_l7) in LPM
7562 * when we depend on USB PHY for VBUS/ID notifications. VBUS
7563 * and ID notifications are available only on V2 surf and FFA
7564 * with a hardware workaround.
7565 */
7566 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 &&
7567 (machine_is_msm8x60_surf() ||
7568 (machine_is_msm8x60_ffa() &&
7569 pmic_id_notif_supported)))
7570 msm_otg_pdata.phy_can_powercollapse = 1;
7571 msm_device_otg.dev.platform_data = &msm_otg_pdata;
7572#endif
7573
Lena Salman57d167e2012-03-21 19:46:38 +02007574#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007575 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
7576#endif
7577
7578#ifdef CONFIG_SERIAL_MSM_HS
7579 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(54); /* GSBI6(2) */
7580 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
7581#endif
7582#ifdef CONFIG_MSM_GSBI9_UART
7583 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7584 msm_device_uart_gsbi9 = msm_add_gsbi9_uart();
7585 if (IS_ERR(msm_device_uart_gsbi9))
7586 pr_err("%s(): Failed to create uart gsbi9 device\n",
7587 __func__);
7588 }
7589#endif
7590
7591#ifdef CONFIG_MSM_BUS_SCALING
7592
7593 /* RPM calls are only enabled on V2 */
7594 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2) {
7595 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
7596 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
7597 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
7598 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
7599 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
7600 }
7601
7602 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
7603 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
7604 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
7605 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
7606 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
7607#endif
Stephen Boyd9e775ad2011-08-12 00:14:28 +01007608}
Steve Mucklea55df6e2010-01-07 12:43:24 -08007609
7610static void __init msm8x60_map_io(void)
7611{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007612 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Steve Mucklea55df6e2010-01-07 12:43:24 -08007613 msm_map_msm8x60_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007614
7615 if (socinfo_init() < 0)
7616 pr_err("socinfo_init() failed!\n");
Steve Mucklea55df6e2010-01-07 12:43:24 -08007617}
7618
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007619/*
7620 * Most segments of the EBI2 bus are disabled by default.
7621 */
7622static void __init msm8x60_init_ebi2(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08007623{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007624 uint32_t ebi2_cfg;
7625 void *ebi2_cfg_ptr;
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007626 struct clk *mem_clk = clk_get_sys("msm_ebi2", "mem_clk");
Steve Mucklea55df6e2010-01-07 12:43:24 -08007627
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007628 if (IS_ERR(mem_clk)) {
7629 pr_err("%s: clk_get_sys(%s,%s), failed", __func__,
7630 "msm_ebi2", "mem_clk");
7631 return;
7632 }
Stephen Boyd818a3f62012-05-08 12:12:18 -07007633 clk_prepare_enable(mem_clk);
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007634 clk_put(mem_clk);
Steve Mucklea55df6e2010-01-07 12:43:24 -08007635
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007636 ebi2_cfg_ptr = ioremap_nocache(0x1a100000, sizeof(uint32_t));
7637 if (ebi2_cfg_ptr != 0) {
7638 ebi2_cfg = readl_relaxed(ebi2_cfg_ptr);
Steve Mucklea55df6e2010-01-07 12:43:24 -08007639
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007640 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007641 machine_is_msm8x60_fluid() ||
7642 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007643 ebi2_cfg |= (1 << 4) | (1 << 5); /* CS2, CS3 */
7644 else if (machine_is_msm8x60_sim())
7645 ebi2_cfg |= (1 << 4); /* CS2 */
7646 else if (machine_is_msm8x60_rumi3())
7647 ebi2_cfg |= (1 << 5); /* CS3 */
Steve Mucklea55df6e2010-01-07 12:43:24 -08007648
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007649 writel_relaxed(ebi2_cfg, ebi2_cfg_ptr);
7650 iounmap(ebi2_cfg_ptr);
David Brown56e2d8a2011-08-04 02:01:02 -07007651 }
7652
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007653 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007654 machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007655 ebi2_cfg_ptr = ioremap_nocache(0x1a110000, SZ_4K);
7656 if (ebi2_cfg_ptr != 0) {
7657 /* EBI2_XMEM_CFG:PWRSAVE_MODE off */
7658 writel_relaxed(0UL, ebi2_cfg_ptr);
7659
7660 /* CS2: Delay 9 cycles (140ns@64MHz) between SMSC
7661 * LAN9221 Ethernet controller reads and writes.
7662 * The lowest 4 bits are the read delay, the next
7663 * 4 are the write delay. */
7664 writel_relaxed(0x031F1C99, ebi2_cfg_ptr + 0x10);
7665#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
7666 /*
7667 * RECOVERY=5, HOLD_WR=1
7668 * INIT_LATENCY_WR=1, INIT_LATENCY_RD=1
7669 * WAIT_WR=1, WAIT_RD=2
7670 */
7671 writel_relaxed(0x51010112, ebi2_cfg_ptr + 0x14);
7672 /*
7673 * HOLD_RD=1
7674 * ADV_OE_RECOVERY=0, ADDR_HOLD_ENA=1
7675 */
7676 writel_relaxed(0x01000020, ebi2_cfg_ptr + 0x34);
7677#else
7678 /* EBI2 CS3 muxed address/data,
7679 * two cyc addr enable */
7680 writel_relaxed(0xA3030020, ebi2_cfg_ptr + 0x34);
7681
7682#endif
7683 iounmap(ebi2_cfg_ptr);
7684 }
7685 }
David Brown56e2d8a2011-08-04 02:01:02 -07007686}
7687
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007688static void __init msm8x60_configure_smc91x(void)
7689{
7690 if (machine_is_msm8x60_sim()) {
7691
7692 smc91x_resources[0].start = 0x1b800300;
7693 smc91x_resources[0].end = 0x1b8003ff;
7694
7695 smc91x_resources[1].start = (NR_MSM_IRQS + 40);
7696 smc91x_resources[1].end = (NR_MSM_IRQS + 40);
7697
7698 } else if (machine_is_msm8x60_rumi3()) {
7699
7700 smc91x_resources[0].start = 0x1d000300;
7701 smc91x_resources[0].end = 0x1d0003ff;
7702
7703 smc91x_resources[1].start = TLMM_MSM_DIR_CONN_IRQ_0;
7704 smc91x_resources[1].end = TLMM_MSM_DIR_CONN_IRQ_0;
7705 }
7706}
7707
7708static void __init msm8x60_init_tlmm(void)
7709{
7710 if (machine_is_msm8x60_rumi3())
7711 msm_gpio_install_direct_irq(0, 0, 1);
7712}
7713
7714#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
7715 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
7716 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
7717 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\
7718 || defined(CONFIG_MMC_MSM_SDC5_SUPPORT))
7719
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007720/* 8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007721#define MAX_SDCC_CONTROLLER 5
7722
7723struct msm_sdcc_gpio {
7724 /* maximum 10 GPIOs per SDCC controller */
7725 s16 no;
7726 /* name of this GPIO */
7727 const char *name;
7728 bool always_on;
7729 bool is_enabled;
David Brown56e2d8a2011-08-04 02:01:02 -07007730};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007731
7732#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7733static struct msm_sdcc_gpio sdc1_gpio_cfg[] = {
7734 {159, "sdc1_dat_0"},
7735 {160, "sdc1_dat_1"},
7736 {161, "sdc1_dat_2"},
7737 {162, "sdc1_dat_3"},
7738#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
7739 {163, "sdc1_dat_4"},
7740 {164, "sdc1_dat_5"},
7741 {165, "sdc1_dat_6"},
7742 {166, "sdc1_dat_7"},
7743#endif
7744 {167, "sdc1_clk"},
7745 {168, "sdc1_cmd"}
7746};
7747#endif
7748
7749#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7750static struct msm_sdcc_gpio sdc2_gpio_cfg[] = {
7751 {143, "sdc2_dat_0"},
7752 {144, "sdc2_dat_1", 1},
7753 {145, "sdc2_dat_2"},
7754 {146, "sdc2_dat_3"},
7755#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
7756 {147, "sdc2_dat_4"},
7757 {148, "sdc2_dat_5"},
7758 {149, "sdc2_dat_6"},
7759 {150, "sdc2_dat_7"},
7760#endif
7761 {151, "sdc2_cmd"},
7762 {152, "sdc2_clk", 1}
7763};
7764#endif
7765
7766#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7767static struct msm_sdcc_gpio sdc5_gpio_cfg[] = {
7768 {95, "sdc5_cmd"},
7769 {96, "sdc5_dat_3"},
7770 {97, "sdc5_clk", 1},
7771 {98, "sdc5_dat_2"},
7772 {99, "sdc5_dat_1", 1},
7773 {100, "sdc5_dat_0"}
7774};
7775#endif
7776
7777struct msm_sdcc_pad_pull_cfg {
7778 enum msm_tlmm_pull_tgt pull;
7779 u32 pull_val;
7780};
7781
7782struct msm_sdcc_pad_drv_cfg {
7783 enum msm_tlmm_hdrive_tgt drv;
7784 u32 drv_val;
7785};
7786
7787#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7788static struct msm_sdcc_pad_drv_cfg sdc3_pad_on_drv_cfg[] = {
7789 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
7790 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
7791 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
7792};
7793
7794static struct msm_sdcc_pad_pull_cfg sdc3_pad_on_pull_cfg[] = {
7795 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
7796 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
7797};
7798
7799static struct msm_sdcc_pad_drv_cfg sdc3_pad_off_drv_cfg[] = {
7800 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
7801 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
7802 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
7803};
7804
7805static struct msm_sdcc_pad_pull_cfg sdc3_pad_off_pull_cfg[] = {
7806 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
7807 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
7808};
7809#endif
7810
7811#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7812static struct msm_sdcc_pad_drv_cfg sdc4_pad_on_drv_cfg[] = {
7813 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_8MA},
7814 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_8MA},
7815 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_8MA}
7816};
7817
7818static struct msm_sdcc_pad_pull_cfg sdc4_pad_on_pull_cfg[] = {
7819 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_UP},
7820 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_UP}
7821};
7822
7823static struct msm_sdcc_pad_drv_cfg sdc4_pad_off_drv_cfg[] = {
7824 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_2MA},
7825 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_2MA},
7826 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_2MA}
7827};
7828
7829static struct msm_sdcc_pad_pull_cfg sdc4_pad_off_pull_cfg[] = {
7830 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_DOWN},
7831 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_DOWN}
7832};
7833#endif
7834
7835struct msm_sdcc_pin_cfg {
7836 /*
7837 * = 1 if controller pins are using gpios
7838 * = 0 if controller has dedicated MSM pins
7839 */
7840 u8 is_gpio;
7841 u8 cfg_sts;
7842 u8 gpio_data_size;
7843 struct msm_sdcc_gpio *gpio_data;
7844 struct msm_sdcc_pad_drv_cfg *pad_drv_on_data;
7845 struct msm_sdcc_pad_drv_cfg *pad_drv_off_data;
7846 struct msm_sdcc_pad_pull_cfg *pad_pull_on_data;
7847 struct msm_sdcc_pad_pull_cfg *pad_pull_off_data;
7848 u8 pad_drv_data_size;
7849 u8 pad_pull_data_size;
7850 u8 sdio_lpm_gpio_cfg;
7851};
7852
7853
7854static struct msm_sdcc_pin_cfg sdcc_pin_cfg_data[MAX_SDCC_CONTROLLER] = {
7855#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7856 [0] = {
7857 .is_gpio = 1,
7858 .gpio_data_size = ARRAY_SIZE(sdc1_gpio_cfg),
7859 .gpio_data = sdc1_gpio_cfg
7860 },
7861#endif
7862#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7863 [1] = {
7864 .is_gpio = 1,
7865 .gpio_data_size = ARRAY_SIZE(sdc2_gpio_cfg),
7866 .gpio_data = sdc2_gpio_cfg
7867 },
7868#endif
7869#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7870 [2] = {
7871 .is_gpio = 0,
7872 .pad_drv_on_data = sdc3_pad_on_drv_cfg,
7873 .pad_drv_off_data = sdc3_pad_off_drv_cfg,
7874 .pad_pull_on_data = sdc3_pad_on_pull_cfg,
7875 .pad_pull_off_data = sdc3_pad_off_pull_cfg,
7876 .pad_drv_data_size = ARRAY_SIZE(sdc3_pad_on_drv_cfg),
7877 .pad_pull_data_size = ARRAY_SIZE(sdc3_pad_on_pull_cfg)
7878 },
7879#endif
7880#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7881 [3] = {
7882 .is_gpio = 0,
7883 .pad_drv_on_data = sdc4_pad_on_drv_cfg,
7884 .pad_drv_off_data = sdc4_pad_off_drv_cfg,
7885 .pad_pull_on_data = sdc4_pad_on_pull_cfg,
7886 .pad_pull_off_data = sdc4_pad_off_pull_cfg,
7887 .pad_drv_data_size = ARRAY_SIZE(sdc4_pad_on_drv_cfg),
7888 .pad_pull_data_size = ARRAY_SIZE(sdc4_pad_on_pull_cfg)
7889 },
7890#endif
7891#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7892 [4] = {
7893 .is_gpio = 1,
7894 .gpio_data_size = ARRAY_SIZE(sdc5_gpio_cfg),
7895 .gpio_data = sdc5_gpio_cfg
7896 }
7897#endif
7898};
7899
7900static int msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
7901{
7902 int rc = 0;
7903 struct msm_sdcc_pin_cfg *curr;
7904 int n;
7905
7906 curr = &sdcc_pin_cfg_data[dev_id - 1];
7907 if (!curr->gpio_data)
7908 goto out;
7909
7910 for (n = 0; n < curr->gpio_data_size; n++) {
7911 if (enable) {
7912
7913 if (curr->gpio_data[n].always_on &&
7914 curr->gpio_data[n].is_enabled)
7915 continue;
7916 pr_debug("%s: enable: %s\n", __func__,
7917 curr->gpio_data[n].name);
7918 rc = gpio_request(curr->gpio_data[n].no,
7919 curr->gpio_data[n].name);
7920 if (rc) {
7921 pr_err("%s: gpio_request(%d, %s)"
7922 "failed", __func__,
7923 curr->gpio_data[n].no,
7924 curr->gpio_data[n].name);
7925 goto free_gpios;
7926 }
7927 /* set direction as output for all GPIOs */
7928 rc = gpio_direction_output(
7929 curr->gpio_data[n].no, 1);
7930 if (rc) {
7931 pr_err("%s: gpio_direction_output"
7932 "(%d, 1) failed\n", __func__,
7933 curr->gpio_data[n].no);
7934 goto free_gpios;
7935 }
7936 curr->gpio_data[n].is_enabled = 1;
7937 } else {
7938 /*
7939 * now free this GPIO which will put GPIO
7940 * in low power mode and will also put GPIO
7941 * in input mode
7942 */
7943 if (curr->gpio_data[n].always_on)
7944 continue;
7945 pr_debug("%s: disable: %s\n", __func__,
7946 curr->gpio_data[n].name);
7947 gpio_free(curr->gpio_data[n].no);
7948 curr->gpio_data[n].is_enabled = 0;
7949 }
7950 }
7951 curr->cfg_sts = enable;
7952 goto out;
7953
7954free_gpios:
7955 for (; n >= 0; n--)
7956 gpio_free(curr->gpio_data[n].no);
7957out:
7958 return rc;
7959}
7960
7961static int msm_sdcc_setup_pad(int dev_id, unsigned int enable)
7962{
7963 int rc = 0;
7964 struct msm_sdcc_pin_cfg *curr;
7965 int n;
7966
7967 curr = &sdcc_pin_cfg_data[dev_id - 1];
7968 if (!curr->pad_drv_on_data || !curr->pad_pull_on_data)
7969 goto out;
7970
7971 if (enable) {
7972 /*
7973 * set up the normal driver strength and
7974 * pull config for pads
7975 */
7976 for (n = 0; n < curr->pad_drv_data_size; n++) {
7977 if (curr->sdio_lpm_gpio_cfg) {
7978 if (curr->pad_drv_on_data[n].drv ==
7979 TLMM_HDRV_SDC4_DATA)
7980 continue;
7981 }
7982 msm_tlmm_set_hdrive(curr->pad_drv_on_data[n].drv,
7983 curr->pad_drv_on_data[n].drv_val);
7984 }
7985 for (n = 0; n < curr->pad_pull_data_size; n++) {
7986 if (curr->sdio_lpm_gpio_cfg) {
7987 if (curr->pad_pull_on_data[n].pull ==
7988 TLMM_PULL_SDC4_DATA)
7989 continue;
7990 }
7991 msm_tlmm_set_pull(curr->pad_pull_on_data[n].pull,
7992 curr->pad_pull_on_data[n].pull_val);
7993 }
7994 } else {
7995 /* set the low power config for pads */
7996 for (n = 0; n < curr->pad_drv_data_size; n++) {
7997 if (curr->sdio_lpm_gpio_cfg) {
7998 if (curr->pad_drv_off_data[n].drv ==
7999 TLMM_HDRV_SDC4_DATA)
8000 continue;
8001 }
8002 msm_tlmm_set_hdrive(
8003 curr->pad_drv_off_data[n].drv,
8004 curr->pad_drv_off_data[n].drv_val);
8005 }
8006 for (n = 0; n < curr->pad_pull_data_size; n++) {
8007 if (curr->sdio_lpm_gpio_cfg) {
8008 if (curr->pad_pull_off_data[n].pull ==
8009 TLMM_PULL_SDC4_DATA)
8010 continue;
8011 }
8012 msm_tlmm_set_pull(
8013 curr->pad_pull_off_data[n].pull,
8014 curr->pad_pull_off_data[n].pull_val);
8015 }
8016 }
8017 curr->cfg_sts = enable;
8018out:
8019 return rc;
8020}
8021
8022struct sdcc_reg {
8023 /* VDD/VCC/VCCQ regulator name on PMIC8058/PMIC8089*/
8024 const char *reg_name;
8025 /*
8026 * is set voltage supported for this regulator?
8027 * 0 = not supported, 1 = supported
8028 */
8029 unsigned char set_voltage_sup;
8030 /* voltage level to be set */
8031 unsigned int level;
8032 /* VDD/VCC/VCCQ voltage regulator handle */
8033 struct regulator *reg;
8034 /* is this regulator enabled? */
8035 bool enabled;
8036 /* is this regulator needs to be always on? */
8037 bool always_on;
8038 /* is operating power mode setting required for this regulator? */
8039 bool op_pwr_mode_sup;
8040 /* Load values for low power and high power mode */
8041 unsigned int lpm_uA;
8042 unsigned int hpm_uA;
8043};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07008044/* all SDCC controllers require VDD/VCC voltage */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008045static struct sdcc_reg sdcc_vdd_reg_data[MAX_SDCC_CONTROLLER];
8046/* only SDCC1 requires VCCQ voltage */
8047static struct sdcc_reg sdcc_vccq_reg_data[1];
8048/* all SDCC controllers may require voting for VDD PAD voltage */
8049static struct sdcc_reg sdcc_vddp_reg_data[MAX_SDCC_CONTROLLER];
8050
8051struct sdcc_reg_data {
8052 struct sdcc_reg *vdd_data; /* keeps VDD/VCC regulator info */
8053 struct sdcc_reg *vccq_data; /* keeps VCCQ regulator info */
8054 struct sdcc_reg *vddp_data; /* keeps VDD Pad regulator info */
8055 unsigned char sts; /* regulator enable/disable status */
8056};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07008057/* msm8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008058static struct sdcc_reg_data sdcc_vreg_data[MAX_SDCC_CONTROLLER];
8059
8060static int msm_sdcc_vreg_init_reg(struct sdcc_reg *vreg)
8061{
8062 int rc = 0;
8063
8064 /* Get the regulator handle */
8065 vreg->reg = regulator_get(NULL, vreg->reg_name);
8066 if (IS_ERR(vreg->reg)) {
8067 rc = PTR_ERR(vreg->reg);
8068 pr_err("%s: regulator_get(%s) failed. rc=%d\n",
8069 __func__, vreg->reg_name, rc);
8070 goto out;
8071 }
8072
8073 /* Set the voltage level if required */
8074 if (vreg->set_voltage_sup) {
8075 rc = regulator_set_voltage(vreg->reg, vreg->level,
8076 vreg->level);
8077 if (rc) {
8078 pr_err("%s: regulator_set_voltage(%s) failed rc=%d\n",
8079 __func__, vreg->reg_name, rc);
8080 goto vreg_put;
8081 }
8082 }
8083 goto out;
8084
8085vreg_put:
8086 regulator_put(vreg->reg);
8087out:
8088 return rc;
8089}
8090
8091static inline void msm_sdcc_vreg_deinit_reg(struct sdcc_reg *vreg)
8092{
8093 regulator_put(vreg->reg);
8094}
8095
8096/* this init function should be called only once for each SDCC */
8097static int msm_sdcc_vreg_init(int dev_id, unsigned char init)
8098{
8099 int rc = 0;
8100 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
8101 struct sdcc_reg_data *curr;
8102
8103 curr = &sdcc_vreg_data[dev_id - 1];
8104 curr_vdd_reg = curr->vdd_data;
8105 curr_vccq_reg = curr->vccq_data;
8106 curr_vddp_reg = curr->vddp_data;
8107
8108 if (init) {
8109 /*
8110 * get the regulator handle from voltage regulator framework
8111 * and then try to set the voltage level for the regulator
8112 */
8113 if (curr_vdd_reg) {
8114 rc = msm_sdcc_vreg_init_reg(curr_vdd_reg);
8115 if (rc)
8116 goto out;
8117 }
8118 if (curr_vccq_reg) {
8119 rc = msm_sdcc_vreg_init_reg(curr_vccq_reg);
8120 if (rc)
8121 goto vdd_reg_deinit;
8122 }
8123 if (curr_vddp_reg) {
8124 rc = msm_sdcc_vreg_init_reg(curr_vddp_reg);
8125 if (rc)
8126 goto vccq_reg_deinit;
8127 }
8128 goto out;
8129 } else
8130 /* deregister with all regulators from regulator framework */
8131 goto vddp_reg_deinit;
8132
8133vddp_reg_deinit:
8134 if (curr_vddp_reg)
8135 msm_sdcc_vreg_deinit_reg(curr_vddp_reg);
8136vccq_reg_deinit:
8137 if (curr_vccq_reg)
8138 msm_sdcc_vreg_deinit_reg(curr_vccq_reg);
8139vdd_reg_deinit:
8140 if (curr_vdd_reg)
8141 msm_sdcc_vreg_deinit_reg(curr_vdd_reg);
8142out:
8143 return rc;
8144}
8145
8146static int msm_sdcc_vreg_enable(struct sdcc_reg *vreg)
8147{
8148 int rc;
8149
8150 if (!vreg->enabled) {
8151 rc = regulator_enable(vreg->reg);
8152 if (rc) {
8153 pr_err("%s: regulator_enable(%s) failed. rc=%d\n",
8154 __func__, vreg->reg_name, rc);
8155 goto out;
8156 }
8157 vreg->enabled = 1;
8158 }
8159
8160 /* Put always_on regulator in HPM (high power mode) */
8161 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8162 rc = regulator_set_optimum_mode(vreg->reg, vreg->hpm_uA);
8163 if (rc < 0) {
8164 pr_err("%s: reg=%s: HPM setting failed"
8165 " hpm_uA=%d, rc=%d\n",
8166 __func__, vreg->reg_name,
8167 vreg->hpm_uA, rc);
8168 goto vreg_disable;
8169 }
8170 rc = 0;
8171 }
8172 goto out;
8173
8174vreg_disable:
8175 regulator_disable(vreg->reg);
8176 vreg->enabled = 0;
8177out:
8178 return rc;
8179}
8180
8181static int msm_sdcc_vreg_disable(struct sdcc_reg *vreg)
8182{
8183 int rc;
8184
8185 /* Never disable always_on regulator */
8186 if (!vreg->always_on) {
8187 rc = regulator_disable(vreg->reg);
8188 if (rc) {
8189 pr_err("%s: regulator_disable(%s) failed. rc=%d\n",
8190 __func__, vreg->reg_name, rc);
8191 goto out;
8192 }
8193 vreg->enabled = 0;
8194 }
8195
8196 /* Put always_on regulator in LPM (low power mode) */
8197 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8198 rc = regulator_set_optimum_mode(vreg->reg, vreg->lpm_uA);
8199 if (rc < 0) {
8200 pr_err("%s: reg=%s: LPM setting failed"
8201 " lpm_uA=%d, rc=%d\n",
8202 __func__,
8203 vreg->reg_name,
8204 vreg->lpm_uA, rc);
8205 goto out;
8206 }
8207 rc = 0;
8208 }
8209
8210out:
8211 return rc;
8212}
8213
8214static int msm_sdcc_setup_vreg(int dev_id, unsigned char enable)
8215{
8216 int rc = 0;
8217 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
8218 struct sdcc_reg_data *curr;
8219
8220 curr = &sdcc_vreg_data[dev_id - 1];
8221 curr_vdd_reg = curr->vdd_data;
8222 curr_vccq_reg = curr->vccq_data;
8223 curr_vddp_reg = curr->vddp_data;
8224
8225 /* check if regulators are initialized or not? */
8226 if ((curr_vdd_reg && !curr_vdd_reg->reg) ||
8227 (curr_vccq_reg && !curr_vccq_reg->reg) ||
8228 (curr_vddp_reg && !curr_vddp_reg->reg)) {
8229 /* initialize voltage regulators required for this SDCC */
8230 rc = msm_sdcc_vreg_init(dev_id, 1);
8231 if (rc) {
8232 pr_err("%s: regulator init failed = %d\n",
8233 __func__, rc);
8234 goto out;
8235 }
8236 }
8237
8238 if (curr->sts == enable)
8239 goto out;
8240
8241 if (curr_vdd_reg) {
8242 if (enable)
8243 rc = msm_sdcc_vreg_enable(curr_vdd_reg);
8244 else
8245 rc = msm_sdcc_vreg_disable(curr_vdd_reg);
8246 if (rc)
8247 goto out;
8248 }
8249
8250 if (curr_vccq_reg) {
8251 if (enable)
8252 rc = msm_sdcc_vreg_enable(curr_vccq_reg);
8253 else
8254 rc = msm_sdcc_vreg_disable(curr_vccq_reg);
8255 if (rc)
8256 goto out;
8257 }
8258
8259 if (curr_vddp_reg) {
8260 if (enable)
8261 rc = msm_sdcc_vreg_enable(curr_vddp_reg);
8262 else
8263 rc = msm_sdcc_vreg_disable(curr_vddp_reg);
8264 if (rc)
8265 goto out;
8266 }
8267 curr->sts = enable;
8268
8269out:
8270 return rc;
8271}
8272
8273static u32 msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
8274{
8275 u32 rc_pin_cfg = 0;
8276 u32 rc_vreg_cfg = 0;
8277 u32 rc = 0;
8278 struct platform_device *pdev;
8279 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8280
8281 pdev = container_of(dv, struct platform_device, dev);
8282
8283 /* setup gpio/pad */
8284 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8285 if (curr_pin_cfg->cfg_sts == !!vdd)
8286 goto setup_vreg;
8287
8288 if (curr_pin_cfg->is_gpio)
8289 rc_pin_cfg = msm_sdcc_setup_gpio(pdev->id, !!vdd);
8290 else
8291 rc_pin_cfg = msm_sdcc_setup_pad(pdev->id, !!vdd);
8292
8293setup_vreg:
8294 /* setup voltage regulators */
8295 rc_vreg_cfg = msm_sdcc_setup_vreg(pdev->id, !!vdd);
8296
8297 if (rc_pin_cfg || rc_vreg_cfg)
8298 rc = rc_pin_cfg ? rc_pin_cfg : rc_vreg_cfg;
8299
8300 return rc;
8301}
8302
8303static void msm_sdcc_sdio_lpm_gpio(struct device *dv, unsigned int active)
8304{
8305 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8306 struct platform_device *pdev;
8307
8308 pdev = container_of(dv, struct platform_device, dev);
8309 /* setup gpio/pad */
8310 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8311
8312 if (curr_pin_cfg->cfg_sts == active)
8313 return;
8314
8315 curr_pin_cfg->sdio_lpm_gpio_cfg = 1;
8316 if (curr_pin_cfg->is_gpio)
8317 msm_sdcc_setup_gpio(pdev->id, active);
8318 else
8319 msm_sdcc_setup_pad(pdev->id, active);
8320 curr_pin_cfg->sdio_lpm_gpio_cfg = 0;
8321}
8322
8323static int msm_sdc3_get_wpswitch(struct device *dev)
8324{
8325 struct platform_device *pdev;
8326 int status;
8327 pdev = container_of(dev, struct platform_device, dev);
8328
8329 status = gpio_request(GPIO_SDC_WP, "SD_WP_Switch");
8330 if (status) {
8331 pr_err("%s:Failed to request GPIO %d\n",
8332 __func__, GPIO_SDC_WP);
8333 } else {
8334 status = gpio_direction_input(GPIO_SDC_WP);
8335 if (!status) {
8336 status = gpio_get_value_cansleep(GPIO_SDC_WP);
8337 pr_info("%s: WP Status for Slot %d = %d\n",
8338 __func__, pdev->id, status);
8339 }
8340 gpio_free(GPIO_SDC_WP);
8341 }
8342 return status;
8343}
8344
8345#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8346int sdc5_register_status_notify(void (*callback)(int, void *),
8347 void *dev_id)
8348{
8349 sdc5_status_notify_cb = callback;
8350 sdc5_status_notify_cb_devid = dev_id;
8351 return 0;
8352}
8353#endif
8354
8355#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8356int sdc2_register_status_notify(void (*callback)(int, void *),
8357 void *dev_id)
8358{
8359 sdc2_status_notify_cb = callback;
8360 sdc2_status_notify_cb_devid = dev_id;
8361 return 0;
8362}
8363#endif
8364
8365/* Interrupt handler for SDC2 and SDC5 detection
8366 * This function uses dual-edge interrputs settings in order
8367 * to get SDIO detection when the GPIO is rising and SDIO removal
8368 * when the GPIO is falling */
8369static irqreturn_t msm8x60_multi_sdio_slot_status_irq(int irq, void *dev_id)
8370{
8371 int status;
8372
8373 if (!machine_is_msm8x60_fusion() &&
8374 !machine_is_msm8x60_fusn_ffa())
8375 return IRQ_NONE;
8376
8377 status = gpio_get_value(MDM2AP_SYNC);
8378 pr_info("%s: MDM2AP_SYNC Status = %d\n",
8379 __func__, status);
8380
8381#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8382 if (sdc2_status_notify_cb) {
8383 pr_info("%s: calling sdc2_status_notify_cb\n", __func__);
8384 sdc2_status_notify_cb(status,
8385 sdc2_status_notify_cb_devid);
8386 }
8387#endif
8388
8389#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8390 if (sdc5_status_notify_cb) {
8391 pr_info("%s: calling sdc5_status_notify_cb\n", __func__);
8392 sdc5_status_notify_cb(status,
8393 sdc5_status_notify_cb_devid);
8394 }
8395#endif
8396 return IRQ_HANDLED;
8397}
8398
8399static int msm8x60_multi_sdio_init(void)
8400{
8401 int ret, irq_num;
8402
8403 if (!machine_is_msm8x60_fusion() &&
8404 !machine_is_msm8x60_fusn_ffa())
8405 return 0;
8406
8407 ret = msm_gpiomux_get(MDM2AP_SYNC);
8408 if (ret) {
8409 pr_err("%s:Failed to request GPIO %d, ret=%d\n",
8410 __func__, MDM2AP_SYNC, ret);
8411 return ret;
8412 }
8413
8414 irq_num = gpio_to_irq(MDM2AP_SYNC);
8415
8416 ret = request_irq(irq_num,
8417 msm8x60_multi_sdio_slot_status_irq,
8418 IRQ_TYPE_EDGE_BOTH,
8419 "sdio_multidetection", NULL);
8420
8421 if (ret) {
8422 pr_err("%s:Failed to request irq, ret=%d\n",
8423 __func__, ret);
8424 return ret;
8425 }
8426
8427 return ret;
8428}
8429
8430#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008431static unsigned int msm8x60_sdcc_slot_status(struct device *dev)
8432{
8433 int status;
8434
8435 status = gpio_request(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)
8436 , "SD_HW_Detect");
8437 if (status) {
8438 pr_err("%s:Failed to request GPIO %d\n", __func__,
8439 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8440 } else {
8441 status = gpio_direction_input(
8442 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8443 if (!status)
8444 status = !(gpio_get_value_cansleep(
8445 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)));
8446 gpio_free(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8447 }
8448 return (unsigned int) status;
8449}
8450#endif
8451#endif
8452
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308453#define MSM_MPM_PIN_SDC3_DAT1 21
Subhash Jadavanife608a22012-04-13 10:45:53 +05308454#define MSM_MPM_PIN_SDC4_DAT1 23
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008455
8456#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8457static struct mmc_platform_data msm8x60_sdc1_data = {
8458 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8459 .translate_vdd = msm_sdcc_setup_power,
8460#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
8461 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8462#else
8463 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8464#endif
8465 .msmsdcc_fmin = 400000,
8466 .msmsdcc_fmid = 24000000,
8467 .msmsdcc_fmax = 48000000,
8468 .nonremovable = 1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308469 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008470};
8471#endif
8472
8473#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8474static struct mmc_platform_data msm8x60_sdc2_data = {
8475 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8476 .translate_vdd = msm_sdcc_setup_power,
8477 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8478 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8479 .msmsdcc_fmin = 400000,
8480 .msmsdcc_fmid = 24000000,
8481 .msmsdcc_fmax = 48000000,
8482 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008483 .register_status_notify = sdc2_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008484#ifdef CONFIG_MSM_SDIO_AL
8485 .is_sdio_al_client = 1,
8486#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308487 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008488};
8489#endif
8490
8491#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8492static struct mmc_platform_data msm8x60_sdc3_data = {
8493 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8494 .translate_vdd = msm_sdcc_setup_power,
8495 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8496 .wpswitch = msm_sdc3_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008497 .status = msm8x60_sdcc_slot_status,
8498 .status_irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
8499 PMIC_GPIO_SDC3_DET - 1),
8500 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008501 .msmsdcc_fmin = 400000,
8502 .msmsdcc_fmid = 24000000,
8503 .msmsdcc_fmax = 48000000,
8504 .nonremovable = 0,
Subhash Jadavani55e188e2012-04-13 11:31:08 +05308505 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC3_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308506 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008507};
8508#endif
8509
8510#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8511static struct mmc_platform_data msm8x60_sdc4_data = {
8512 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8513 .translate_vdd = msm_sdcc_setup_power,
8514 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8515 .msmsdcc_fmin = 400000,
8516 .msmsdcc_fmid = 24000000,
8517 .msmsdcc_fmax = 48000000,
8518 .nonremovable = 0,
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308519 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC4_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308520 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008521};
8522#endif
8523
8524#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8525static struct mmc_platform_data msm8x60_sdc5_data = {
8526 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8527 .translate_vdd = msm_sdcc_setup_power,
8528 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8529 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8530 .msmsdcc_fmin = 400000,
8531 .msmsdcc_fmid = 24000000,
8532 .msmsdcc_fmax = 48000000,
8533 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008534 .register_status_notify = sdc5_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008535#ifdef CONFIG_MSM_SDIO_AL
8536 .is_sdio_al_client = 1,
8537#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308538 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008539};
8540#endif
8541
8542static void __init msm8x60_init_mmc(void)
8543{
8544#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8545 /* SDCC1 : eMMC card connected */
8546 sdcc_vreg_data[0].vdd_data = &sdcc_vdd_reg_data[0];
8547 sdcc_vreg_data[0].vdd_data->reg_name = "8901_l5";
8548 sdcc_vreg_data[0].vdd_data->set_voltage_sup = 1;
8549 sdcc_vreg_data[0].vdd_data->level = 2850000;
Subhash Jadavania8482a32011-08-08 11:01:44 +05308550 sdcc_vreg_data[0].vdd_data->always_on = 1;
8551 sdcc_vreg_data[0].vdd_data->op_pwr_mode_sup = 1;
8552 sdcc_vreg_data[0].vdd_data->lpm_uA = 9000;
8553 sdcc_vreg_data[0].vdd_data->hpm_uA = 200000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008554
8555 sdcc_vreg_data[0].vccq_data = &sdcc_vccq_reg_data[0];
8556 sdcc_vreg_data[0].vccq_data->reg_name = "8901_lvs0";
8557 sdcc_vreg_data[0].vccq_data->set_voltage_sup = 0;
8558 sdcc_vreg_data[0].vccq_data->always_on = 1;
8559
8560 msm_add_sdcc(1, &msm8x60_sdc1_data);
8561#endif
8562#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8563 /*
8564 * MDM SDIO client is connected to SDC2 on charm SURF/FFA
8565 * and no card is connected on 8660 SURF/FFA/FLUID.
8566 */
8567 sdcc_vreg_data[1].vdd_data = &sdcc_vdd_reg_data[1];
8568 sdcc_vreg_data[1].vdd_data->reg_name = "8058_s3";
8569 sdcc_vreg_data[1].vdd_data->set_voltage_sup = 1;
8570 sdcc_vreg_data[1].vdd_data->level = 1800000;
8571
8572 sdcc_vreg_data[1].vccq_data = NULL;
8573
8574 if (machine_is_msm8x60_fusion())
8575 msm8x60_sdc2_data.msmsdcc_fmax = 24000000;
8576 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008577 msm8x60_sdc2_data.sdiowakeup_irq = gpio_to_irq(144);
8578 msm_sdcc_setup_gpio(2, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008579 msm_add_sdcc(2, &msm8x60_sdc2_data);
8580 }
8581#endif
8582#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8583 /* SDCC3 : External card slot connected */
8584 sdcc_vreg_data[2].vdd_data = &sdcc_vdd_reg_data[2];
8585 sdcc_vreg_data[2].vdd_data->reg_name = "8058_l14";
8586 sdcc_vreg_data[2].vdd_data->set_voltage_sup = 1;
8587 sdcc_vreg_data[2].vdd_data->level = 2850000;
8588 sdcc_vreg_data[2].vdd_data->always_on = 1;
8589 sdcc_vreg_data[2].vdd_data->op_pwr_mode_sup = 1;
8590 sdcc_vreg_data[2].vdd_data->lpm_uA = 9000;
8591 sdcc_vreg_data[2].vdd_data->hpm_uA = 200000;
8592
8593 sdcc_vreg_data[2].vccq_data = NULL;
8594
8595 sdcc_vreg_data[2].vddp_data = &sdcc_vddp_reg_data[2];
8596 sdcc_vreg_data[2].vddp_data->reg_name = "8058_l5";
8597 sdcc_vreg_data[2].vddp_data->set_voltage_sup = 1;
8598 sdcc_vreg_data[2].vddp_data->level = 2850000;
8599 sdcc_vreg_data[2].vddp_data->always_on = 1;
8600 sdcc_vreg_data[2].vddp_data->op_pwr_mode_sup = 1;
8601 /* Sleep current required is ~300 uA. But min. RPM
8602 * vote can be in terms of mA (min. 1 mA).
8603 * So let's vote for 2 mA during sleep.
8604 */
8605 sdcc_vreg_data[2].vddp_data->lpm_uA = 2000;
8606 /* Max. Active current required is 16 mA */
8607 sdcc_vreg_data[2].vddp_data->hpm_uA = 16000;
8608
8609 if (machine_is_msm8x60_fluid())
8610 msm8x60_sdc3_data.wpswitch = NULL;
8611 msm_add_sdcc(3, &msm8x60_sdc3_data);
8612#endif
8613#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8614 /* SDCC4 : WLAN WCN1314 chip is connected */
8615 sdcc_vreg_data[3].vdd_data = &sdcc_vdd_reg_data[3];
8616 sdcc_vreg_data[3].vdd_data->reg_name = "8058_s3";
8617 sdcc_vreg_data[3].vdd_data->set_voltage_sup = 1;
8618 sdcc_vreg_data[3].vdd_data->level = 1800000;
8619
8620 sdcc_vreg_data[3].vccq_data = NULL;
8621
8622 msm_add_sdcc(4, &msm8x60_sdc4_data);
8623#endif
8624#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8625 /*
8626 * MDM SDIO client is connected to SDC5 on charm SURF/FFA
8627 * and no card is connected on 8660 SURF/FFA/FLUID.
8628 */
8629 sdcc_vreg_data[4].vdd_data = &sdcc_vdd_reg_data[4];
8630 sdcc_vreg_data[4].vdd_data->reg_name = "8058_s3";
8631 sdcc_vreg_data[4].vdd_data->set_voltage_sup = 1;
8632 sdcc_vreg_data[4].vdd_data->level = 1800000;
8633
8634 sdcc_vreg_data[4].vccq_data = NULL;
8635
8636 if (machine_is_msm8x60_fusion())
8637 msm8x60_sdc5_data.msmsdcc_fmax = 24000000;
8638 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008639 msm8x60_sdc5_data.sdiowakeup_irq = gpio_to_irq(99);
8640 msm_sdcc_setup_gpio(5, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008641 msm_add_sdcc(5, &msm8x60_sdc5_data);
8642 }
8643#endif
8644}
8645
8646#if !defined(CONFIG_GPIO_SX150X) && !defined(CONFIG_GPIO_SX150X_MODULE)
8647static inline void display_common_power(int on) {}
8648#else
8649
8650#define _GET_REGULATOR(var, name) do { \
8651 if (var == NULL) { \
8652 var = regulator_get(NULL, name); \
8653 if (IS_ERR(var)) { \
8654 pr_err("'%s' regulator not found, rc=%ld\n", \
8655 name, PTR_ERR(var)); \
8656 var = NULL; \
8657 } \
8658 } \
8659} while (0)
8660
8661static int dsub_regulator(int on)
8662{
8663 static struct regulator *dsub_reg;
8664 static struct regulator *mpp0_reg;
8665 static int dsub_reg_enabled;
8666 int rc = 0;
8667
8668 _GET_REGULATOR(dsub_reg, "8901_l3");
8669 if (IS_ERR(dsub_reg)) {
8670 printk(KERN_ERR "%s: failed to get reg 8901_l3 err=%ld",
8671 __func__, PTR_ERR(dsub_reg));
8672 return PTR_ERR(dsub_reg);
8673 }
8674
8675 _GET_REGULATOR(mpp0_reg, "8901_mpp0");
8676 if (IS_ERR(mpp0_reg)) {
8677 printk(KERN_ERR "%s: failed to get reg 8901_mpp0 err=%ld",
8678 __func__, PTR_ERR(mpp0_reg));
8679 return PTR_ERR(mpp0_reg);
8680 }
8681
8682 if (on && !dsub_reg_enabled) {
8683 rc = regulator_set_voltage(dsub_reg, 3300000, 3300000);
8684 if (rc) {
8685 printk(KERN_ERR "%s: failed to set reg 8901_l3 voltage"
8686 " err=%d", __func__, rc);
8687 goto dsub_regulator_err;
8688 }
8689 rc = regulator_enable(dsub_reg);
8690 if (rc) {
8691 printk(KERN_ERR "%s: failed to enable reg 8901_l3"
8692 " err=%d", __func__, rc);
8693 goto dsub_regulator_err;
8694 }
8695 rc = regulator_enable(mpp0_reg);
8696 if (rc) {
8697 printk(KERN_ERR "%s: failed to enable reg 8901_mpp0"
8698 " err=%d", __func__, rc);
8699 goto dsub_regulator_err;
8700 }
8701 dsub_reg_enabled = 1;
8702 } else if (!on && dsub_reg_enabled) {
8703 rc = regulator_disable(dsub_reg);
8704 if (rc)
8705 printk(KERN_WARNING "%s: failed to disable reg 8901_l3"
8706 " err=%d", __func__, rc);
8707 rc = regulator_disable(mpp0_reg);
8708 if (rc)
8709 printk(KERN_WARNING "%s: failed to disable reg "
8710 "8901_mpp0 err=%d", __func__, rc);
8711 dsub_reg_enabled = 0;
8712 }
8713
8714 return rc;
8715
8716dsub_regulator_err:
8717 regulator_put(mpp0_reg);
8718 regulator_put(dsub_reg);
8719 return rc;
8720}
8721
8722static int display_power_on;
8723static void setup_display_power(void)
8724{
8725 if (display_power_on)
8726 if (lcdc_vga_enabled) {
8727 dsub_regulator(1);
8728 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8729 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8730 if (machine_is_msm8x60_ffa() ||
8731 machine_is_msm8x60_fusn_ffa())
8732 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 1);
8733 } else {
8734 dsub_regulator(0);
8735 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 1);
8736 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 1);
8737 if (machine_is_msm8x60_ffa() ||
8738 machine_is_msm8x60_fusn_ffa())
8739 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8740 }
8741 else {
8742 dsub_regulator(0);
8743 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
8744 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8745 /* BACKLIGHT */
8746 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8747 /* LVDS */
8748 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8749 }
8750}
8751
8752#define _GET_REGULATOR(var, name) do { \
8753 if (var == NULL) { \
8754 var = regulator_get(NULL, name); \
8755 if (IS_ERR(var)) { \
8756 pr_err("'%s' regulator not found, rc=%ld\n", \
8757 name, PTR_ERR(var)); \
8758 var = NULL; \
8759 } \
8760 } \
8761} while (0)
8762
8763#define GPIO_RESX_N (GPIO_EXPANDER_GPIO_BASE + 2)
8764
8765static void display_common_power(int on)
8766{
8767 int rc;
8768 static struct regulator *display_reg;
8769
8770 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
8771 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8772 if (on) {
8773 /* LVDS */
8774 _GET_REGULATOR(display_reg, "8901_l2");
8775 if (!display_reg)
8776 return;
8777 rc = regulator_set_voltage(display_reg,
8778 3300000, 3300000);
8779 if (rc)
8780 goto out;
8781 rc = regulator_enable(display_reg);
8782 if (rc)
8783 goto out;
8784 rc = gpio_request(GPIO_LVDS_SHUTDOWN_N,
8785 "LVDS_STDN_OUT_N");
8786 if (rc) {
8787 printk(KERN_ERR "%s: LVDS gpio %d request"
8788 "failed\n", __func__,
8789 GPIO_LVDS_SHUTDOWN_N);
8790 goto out2;
8791 }
8792
8793 /* BACKLIGHT */
8794 rc = gpio_request(GPIO_BACKLIGHT_EN, "BACKLIGHT_EN");
8795 if (rc) {
8796 printk(KERN_ERR "%s: BACKLIGHT gpio %d request"
8797 "failed\n", __func__,
8798 GPIO_BACKLIGHT_EN);
8799 goto out3;
8800 }
8801
8802 if (machine_is_msm8x60_ffa() ||
8803 machine_is_msm8x60_fusn_ffa()) {
8804 rc = gpio_request(GPIO_DONGLE_PWR_EN,
8805 "DONGLE_PWR_EN");
8806 if (rc) {
8807 printk(KERN_ERR "%s: DONGLE_PWR_EN gpio"
8808 " %d request failed\n", __func__,
8809 GPIO_DONGLE_PWR_EN);
8810 goto out4;
8811 }
8812 }
8813
8814 gpio_direction_output(GPIO_LVDS_SHUTDOWN_N, 0);
8815 gpio_direction_output(GPIO_BACKLIGHT_EN, 0);
8816 if (machine_is_msm8x60_ffa() ||
8817 machine_is_msm8x60_fusn_ffa())
8818 gpio_direction_output(GPIO_DONGLE_PWR_EN, 0);
8819 mdelay(20);
8820 display_power_on = 1;
8821 setup_display_power();
8822 } else {
8823 if (display_power_on) {
8824 display_power_on = 0;
8825 setup_display_power();
8826 mdelay(20);
8827 if (machine_is_msm8x60_ffa() ||
8828 machine_is_msm8x60_fusn_ffa())
8829 gpio_free(GPIO_DONGLE_PWR_EN);
8830 goto out4;
8831 }
8832 }
8833 }
8834#if defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
8835 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA)
8836 else if (machine_is_msm8x60_fluid()) {
8837 static struct regulator *fluid_reg;
8838 static struct regulator *fluid_reg2;
8839
8840 if (on) {
8841 _GET_REGULATOR(fluid_reg, "8901_l2");
8842 if (!fluid_reg)
8843 return;
8844 _GET_REGULATOR(fluid_reg2, "8058_s3");
8845 if (!fluid_reg2) {
8846 regulator_put(fluid_reg);
8847 return;
8848 }
8849 rc = gpio_request(GPIO_RESX_N, "RESX_N");
8850 if (rc) {
8851 regulator_put(fluid_reg2);
8852 regulator_put(fluid_reg);
8853 return;
8854 }
8855 regulator_set_voltage(fluid_reg, 2850000, 2850000);
8856 regulator_set_voltage(fluid_reg2, 1800000, 1800000);
8857 regulator_enable(fluid_reg);
8858 regulator_enable(fluid_reg2);
8859 msleep(20);
8860 gpio_direction_output(GPIO_RESX_N, 0);
8861 udelay(10);
8862 gpio_set_value_cansleep(GPIO_RESX_N, 1);
8863 display_power_on = 1;
8864 setup_display_power();
8865 } else {
8866 gpio_set_value_cansleep(GPIO_RESX_N, 0);
8867 gpio_free(GPIO_RESX_N);
8868 msleep(20);
8869 regulator_disable(fluid_reg2);
8870 regulator_disable(fluid_reg);
8871 regulator_put(fluid_reg2);
8872 regulator_put(fluid_reg);
8873 display_power_on = 0;
8874 setup_display_power();
8875 fluid_reg = NULL;
8876 fluid_reg2 = NULL;
8877 }
8878 }
8879#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04008880#if defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA)
8881 else if (machine_is_msm8x60_dragon()) {
8882 static struct regulator *dragon_reg;
8883 static struct regulator *dragon_reg2;
8884
8885 if (on) {
8886 _GET_REGULATOR(dragon_reg, "8901_l2");
8887 if (!dragon_reg)
8888 return;
8889 _GET_REGULATOR(dragon_reg2, "8058_l16");
8890 if (!dragon_reg2) {
8891 regulator_put(dragon_reg);
8892 dragon_reg = NULL;
8893 return;
8894 }
8895
8896 rc = gpio_request(GPIO_NT35582_BL_EN, "lcdc_bl_en");
8897 if (rc) {
8898 pr_err("%s: gpio %d request failed with rc=%d\n",
8899 __func__, GPIO_NT35582_BL_EN, rc);
8900 regulator_put(dragon_reg);
8901 regulator_put(dragon_reg2);
8902 dragon_reg = NULL;
8903 dragon_reg2 = NULL;
8904 return;
8905 }
8906
8907 if (gpio_tlmm_config(GPIO_CFG(GPIO_NT35582_RESET, 0,
8908 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
8909 GPIO_CFG_16MA), GPIO_CFG_ENABLE)) {
8910 pr_err("%s: config gpio '%d' failed!\n",
8911 __func__, GPIO_NT35582_RESET);
8912 gpio_free(GPIO_NT35582_BL_EN);
8913 regulator_put(dragon_reg);
8914 regulator_put(dragon_reg2);
8915 dragon_reg = NULL;
8916 dragon_reg2 = NULL;
8917 return;
8918 }
8919
8920 rc = gpio_request(GPIO_NT35582_RESET, "lcdc_reset");
8921 if (rc) {
8922 pr_err("%s: unable to request gpio %d (rc=%d)\n",
8923 __func__, GPIO_NT35582_RESET, rc);
8924 gpio_free(GPIO_NT35582_BL_EN);
8925 regulator_put(dragon_reg);
8926 regulator_put(dragon_reg2);
8927 dragon_reg = NULL;
8928 dragon_reg2 = NULL;
8929 return;
8930 }
8931
8932 regulator_set_voltage(dragon_reg, 3300000, 3300000);
8933 regulator_set_voltage(dragon_reg2, 1800000, 1800000);
8934 regulator_enable(dragon_reg);
8935 regulator_enable(dragon_reg2);
8936 msleep(20);
8937
8938 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8939 msleep(20);
8940 gpio_set_value_cansleep(GPIO_NT35582_RESET, 0);
8941 msleep(20);
8942 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8943 msleep(50);
8944
8945 gpio_set_value_cansleep(GPIO_NT35582_BL_EN, 1);
8946
8947 display_power_on = 1;
8948 } else if ((dragon_reg != NULL) && (dragon_reg2 != NULL)) {
8949 gpio_free(GPIO_NT35582_RESET);
8950 gpio_free(GPIO_NT35582_BL_EN);
8951 regulator_disable(dragon_reg2);
8952 regulator_disable(dragon_reg);
8953 regulator_put(dragon_reg2);
8954 regulator_put(dragon_reg);
8955 display_power_on = 0;
8956 dragon_reg = NULL;
8957 dragon_reg2 = NULL;
8958 }
8959 }
8960#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008961 return;
8962
8963out4:
8964 gpio_free(GPIO_BACKLIGHT_EN);
8965out3:
8966 gpio_free(GPIO_LVDS_SHUTDOWN_N);
8967out2:
8968 regulator_disable(display_reg);
8969out:
8970 regulator_put(display_reg);
8971 display_reg = NULL;
8972}
8973#undef _GET_REGULATOR
8974#endif
8975
8976static int mipi_dsi_panel_power(int on);
8977
8978#define LCDC_NUM_GPIO 28
8979#define LCDC_GPIO_START 0
8980
8981static void lcdc_samsung_panel_power(int on)
8982{
8983 int n, ret = 0;
8984
8985 display_common_power(on);
8986
8987 for (n = 0; n < LCDC_NUM_GPIO; n++) {
8988 if (on) {
8989 ret = gpio_request(LCDC_GPIO_START + n, "LCDC_GPIO");
8990 if (unlikely(ret)) {
8991 pr_err("%s not able to get gpio\n", __func__);
8992 break;
8993 }
8994 } else
8995 gpio_free(LCDC_GPIO_START + n);
8996 }
8997
8998 if (ret) {
8999 for (n--; n >= 0; n--)
9000 gpio_free(LCDC_GPIO_START + n);
9001 }
9002
9003 mipi_dsi_panel_power(0); /* set 8058_ldo0 to LPM */
9004}
9005
9006#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
9007#define _GET_REGULATOR(var, name) do { \
9008 var = regulator_get(NULL, name); \
9009 if (IS_ERR(var)) { \
9010 pr_err("'%s' regulator not found, rc=%ld\n", \
9011 name, IS_ERR(var)); \
9012 var = NULL; \
9013 return -ENODEV; \
9014 } \
9015} while (0)
9016
9017static int hdmi_enable_5v(int on)
9018{
9019 static struct regulator *reg_8901_hdmi_mvs; /* HDMI_5V */
9020 static struct regulator *reg_8901_mpp0; /* External 5V */
9021 static int prev_on;
9022 int rc;
9023
9024 if (on == prev_on)
9025 return 0;
9026
9027 if (!reg_8901_hdmi_mvs)
9028 _GET_REGULATOR(reg_8901_hdmi_mvs, "8901_hdmi_mvs");
9029 if (!reg_8901_mpp0)
9030 _GET_REGULATOR(reg_8901_mpp0, "8901_mpp0");
9031
9032 if (on) {
9033 rc = regulator_enable(reg_8901_mpp0);
9034 if (rc) {
9035 pr_err("'%s' regulator enable failed, rc=%d\n",
9036 "reg_8901_mpp0", rc);
9037 return rc;
9038 }
9039 rc = regulator_enable(reg_8901_hdmi_mvs);
9040 if (rc) {
9041 pr_err("'%s' regulator enable failed, rc=%d\n",
9042 "8901_hdmi_mvs", rc);
9043 return rc;
9044 }
9045 pr_info("%s(on): success\n", __func__);
9046 } else {
9047 rc = regulator_disable(reg_8901_hdmi_mvs);
9048 if (rc)
9049 pr_warning("'%s' regulator disable failed, rc=%d\n",
9050 "8901_hdmi_mvs", rc);
9051 rc = regulator_disable(reg_8901_mpp0);
9052 if (rc)
9053 pr_warning("'%s' regulator disable failed, rc=%d\n",
9054 "reg_8901_mpp0", rc);
9055 pr_info("%s(off): success\n", __func__);
9056 }
9057
9058 prev_on = on;
9059
9060 return 0;
9061}
9062
9063static int hdmi_core_power(int on, int show)
9064{
9065 static struct regulator *reg_8058_l16; /* VDD_HDMI */
9066 static int prev_on;
9067 int rc;
9068
9069 if (on == prev_on)
9070 return 0;
9071
9072 if (!reg_8058_l16)
9073 _GET_REGULATOR(reg_8058_l16, "8058_l16");
9074
9075 if (on) {
9076 rc = regulator_set_voltage(reg_8058_l16, 1800000, 1800000);
9077 if (!rc)
9078 rc = regulator_enable(reg_8058_l16);
9079 if (rc) {
9080 pr_err("'%s' regulator enable failed, rc=%d\n",
9081 "8058_l16", rc);
9082 return rc;
9083 }
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309084 pr_debug("%s(on): success\n", __func__);
9085 } else {
9086 rc = regulator_disable(reg_8058_l16);
9087 if (rc)
9088 pr_warning("'%s' regulator disable failed, rc=%d\n",
9089 "8058_l16", rc);
9090 pr_debug("%s(off): success\n", __func__);
9091 }
9092
9093 prev_on = on;
9094
9095 return 0;
9096}
9097
9098static int hdmi_gpio_config(int on)
9099{
9100 int rc = 0;
9101 static int prev_on;
9102
9103 if (on == prev_on)
9104 return 0;
9105
9106 if (on) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009107 rc = gpio_request(170, "HDMI_DDC_CLK");
9108 if (rc) {
9109 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9110 "HDMI_DDC_CLK", 170, rc);
9111 goto error1;
9112 }
9113 rc = gpio_request(171, "HDMI_DDC_DATA");
9114 if (rc) {
9115 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9116 "HDMI_DDC_DATA", 171, rc);
9117 goto error2;
9118 }
9119 rc = gpio_request(172, "HDMI_HPD");
9120 if (rc) {
9121 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9122 "HDMI_HPD", 172, rc);
9123 goto error3;
9124 }
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309125 pr_debug("%s(on): success\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009126 } else {
9127 gpio_free(170);
9128 gpio_free(171);
9129 gpio_free(172);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309130 pr_debug("%s(off): success\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009131 }
9132
9133 prev_on = on;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009134 return 0;
9135
9136error3:
9137 gpio_free(171);
9138error2:
9139 gpio_free(170);
9140error1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009141 return rc;
9142}
9143
9144static int hdmi_cec_power(int on)
9145{
9146 static struct regulator *reg_8901_l3; /* HDMI_CEC */
9147 static int prev_on;
9148 int rc;
9149
9150 if (on == prev_on)
9151 return 0;
9152
9153 if (!reg_8901_l3)
9154 _GET_REGULATOR(reg_8901_l3, "8901_l3");
9155
9156 if (on) {
9157 rc = regulator_set_voltage(reg_8901_l3, 3300000, 3300000);
9158 if (!rc)
9159 rc = regulator_enable(reg_8901_l3);
9160 if (rc) {
9161 pr_err("'%s' regulator enable failed, rc=%d\n",
9162 "8901_l3", rc);
9163 return rc;
9164 }
9165 rc = gpio_request(169, "HDMI_CEC_VAR");
9166 if (rc) {
9167 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9168 "HDMI_CEC_VAR", 169, rc);
9169 goto error;
9170 }
9171 pr_info("%s(on): success\n", __func__);
9172 } else {
9173 gpio_free(169);
9174 rc = regulator_disable(reg_8901_l3);
9175 if (rc)
9176 pr_warning("'%s' regulator disable failed, rc=%d\n",
9177 "8901_l3", rc);
9178 pr_info("%s(off): success\n", __func__);
9179 }
9180
9181 prev_on = on;
9182
9183 return 0;
9184error:
9185 regulator_disable(reg_8901_l3);
9186 return rc;
9187}
9188
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309189static int hdmi_panel_power(int on)
9190{
9191 int rc;
9192
9193 pr_debug("%s: HDMI Core: %s\n", __func__, (on ? "ON" : "OFF"));
9194 rc = hdmi_core_power(on, 1);
9195 if (rc)
9196 rc = hdmi_cec_power(on);
9197
9198 pr_debug("%s: HDMI Core: %s Success\n", __func__, (on ? "ON" : "OFF"));
9199 return rc;
9200}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009201#undef _GET_REGULATOR
9202
9203#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
9204
9205static int lcdc_panel_power(int on)
9206{
9207 int flag_on = !!on;
9208 static int lcdc_power_save_on;
9209
9210 if (lcdc_power_save_on == flag_on)
9211 return 0;
9212
9213 lcdc_power_save_on = flag_on;
9214
9215 lcdc_samsung_panel_power(on);
9216
9217 return 0;
9218}
9219
9220#ifdef CONFIG_MSM_BUS_SCALING
Nagamalleswararao Ganji5fabbd62011-11-06 23:10:43 -08009221
9222static struct msm_bus_vectors rotator_init_vectors[] = {
9223 {
9224 .src = MSM_BUS_MASTER_ROTATOR,
9225 .dst = MSM_BUS_SLAVE_SMI,
9226 .ab = 0,
9227 .ib = 0,
9228 },
9229 {
9230 .src = MSM_BUS_MASTER_ROTATOR,
9231 .dst = MSM_BUS_SLAVE_EBI_CH0,
9232 .ab = 0,
9233 .ib = 0,
9234 },
9235};
9236
9237static struct msm_bus_vectors rotator_ui_vectors[] = {
9238 {
9239 .src = MSM_BUS_MASTER_ROTATOR,
9240 .dst = MSM_BUS_SLAVE_SMI,
9241 .ab = 0,
9242 .ib = 0,
9243 },
9244 {
9245 .src = MSM_BUS_MASTER_ROTATOR,
9246 .dst = MSM_BUS_SLAVE_EBI_CH0,
9247 .ab = (1024 * 600 * 4 * 2 * 60),
9248 .ib = (1024 * 600 * 4 * 2 * 60 * 1.5),
9249 },
9250};
9251
9252static struct msm_bus_vectors rotator_vga_vectors[] = {
9253 {
9254 .src = MSM_BUS_MASTER_ROTATOR,
9255 .dst = MSM_BUS_SLAVE_SMI,
9256 .ab = (640 * 480 * 2 * 2 * 30),
9257 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9258 },
9259 {
9260 .src = MSM_BUS_MASTER_ROTATOR,
9261 .dst = MSM_BUS_SLAVE_EBI_CH0,
9262 .ab = (640 * 480 * 2 * 2 * 30),
9263 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9264 },
9265};
9266
9267static struct msm_bus_vectors rotator_720p_vectors[] = {
9268 {
9269 .src = MSM_BUS_MASTER_ROTATOR,
9270 .dst = MSM_BUS_SLAVE_SMI,
9271 .ab = (1280 * 736 * 2 * 2 * 30),
9272 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9273 },
9274 {
9275 .src = MSM_BUS_MASTER_ROTATOR,
9276 .dst = MSM_BUS_SLAVE_EBI_CH0,
9277 .ab = (1280 * 736 * 2 * 2 * 30),
9278 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9279 },
9280};
9281
9282static struct msm_bus_vectors rotator_1080p_vectors[] = {
9283 {
9284 .src = MSM_BUS_MASTER_ROTATOR,
9285 .dst = MSM_BUS_SLAVE_SMI,
9286 .ab = (1920 * 1088 * 2 * 2 * 30),
9287 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9288 },
9289 {
9290 .src = MSM_BUS_MASTER_ROTATOR,
9291 .dst = MSM_BUS_SLAVE_EBI_CH0,
9292 .ab = (1920 * 1088 * 2 * 2 * 30),
9293 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9294 },
9295};
9296
9297static struct msm_bus_paths rotator_bus_scale_usecases[] = {
9298 {
9299 ARRAY_SIZE(rotator_init_vectors),
9300 rotator_init_vectors,
9301 },
9302 {
9303 ARRAY_SIZE(rotator_ui_vectors),
9304 rotator_ui_vectors,
9305 },
9306 {
9307 ARRAY_SIZE(rotator_vga_vectors),
9308 rotator_vga_vectors,
9309 },
9310 {
9311 ARRAY_SIZE(rotator_720p_vectors),
9312 rotator_720p_vectors,
9313 },
9314 {
9315 ARRAY_SIZE(rotator_1080p_vectors),
9316 rotator_1080p_vectors,
9317 },
9318};
9319
9320struct msm_bus_scale_pdata rotator_bus_scale_pdata = {
9321 rotator_bus_scale_usecases,
9322 ARRAY_SIZE(rotator_bus_scale_usecases),
9323 .name = "rotator",
9324};
9325
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009326static struct msm_bus_vectors mdp_init_vectors[] = {
9327 /* For now, 0th array entry is reserved.
9328 * Please leave 0 as is and don't use it
9329 */
9330 {
9331 .src = MSM_BUS_MASTER_MDP_PORT0,
9332 .dst = MSM_BUS_SLAVE_SMI,
9333 .ab = 0,
9334 .ib = 0,
9335 },
9336 /* Master and slaves can be from different fabrics */
9337 {
9338 .src = MSM_BUS_MASTER_MDP_PORT0,
9339 .dst = MSM_BUS_SLAVE_EBI_CH0,
9340 .ab = 0,
9341 .ib = 0,
9342 },
9343};
9344
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009345#ifdef CONFIG_FB_MSM_LCDC_DSUB
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009346static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9347 /* Default case static display/UI/2d/3d if FB SMI */
9348 {
9349 .src = MSM_BUS_MASTER_MDP_PORT0,
9350 .dst = MSM_BUS_SLAVE_SMI,
9351 .ab = 388800000,
9352 .ib = 486000000,
9353 },
9354 /* Master and slaves can be from different fabrics */
9355 {
9356 .src = MSM_BUS_MASTER_MDP_PORT0,
9357 .dst = MSM_BUS_SLAVE_EBI_CH0,
9358 .ab = 0,
9359 .ib = 0,
9360 },
9361};
9362
9363static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9364 /* Default case static display/UI/2d/3d if FB SMI */
9365 {
9366 .src = MSM_BUS_MASTER_MDP_PORT0,
9367 .dst = MSM_BUS_SLAVE_SMI,
9368 .ab = 0,
9369 .ib = 0,
9370 },
9371 /* Master and slaves can be from different fabrics */
9372 {
9373 .src = MSM_BUS_MASTER_MDP_PORT0,
9374 .dst = MSM_BUS_SLAVE_EBI_CH0,
9375 .ab = 388800000,
9376 .ib = 486000000 * 2,
9377 },
9378};
9379static struct msm_bus_vectors mdp_vga_vectors[] = {
9380 /* VGA and less video */
9381 {
9382 .src = MSM_BUS_MASTER_MDP_PORT0,
9383 .dst = MSM_BUS_SLAVE_SMI,
9384 .ab = 458092800,
9385 .ib = 572616000,
9386 },
9387 {
9388 .src = MSM_BUS_MASTER_MDP_PORT0,
9389 .dst = MSM_BUS_SLAVE_EBI_CH0,
9390 .ab = 458092800,
9391 .ib = 572616000 * 2,
9392 },
9393};
9394static struct msm_bus_vectors mdp_720p_vectors[] = {
9395 /* 720p and less video */
9396 {
9397 .src = MSM_BUS_MASTER_MDP_PORT0,
9398 .dst = MSM_BUS_SLAVE_SMI,
9399 .ab = 471744000,
9400 .ib = 589680000,
9401 },
9402 /* Master and slaves can be from different fabrics */
9403 {
9404 .src = MSM_BUS_MASTER_MDP_PORT0,
9405 .dst = MSM_BUS_SLAVE_EBI_CH0,
9406 .ab = 471744000,
9407 .ib = 589680000 * 2,
9408 },
9409};
9410
9411static struct msm_bus_vectors mdp_1080p_vectors[] = {
9412 /* 1080p and less video */
9413 {
9414 .src = MSM_BUS_MASTER_MDP_PORT0,
9415 .dst = MSM_BUS_SLAVE_SMI,
9416 .ab = 575424000,
9417 .ib = 719280000,
9418 },
9419 /* Master and slaves can be from different fabrics */
9420 {
9421 .src = MSM_BUS_MASTER_MDP_PORT0,
9422 .dst = MSM_BUS_SLAVE_EBI_CH0,
9423 .ab = 575424000,
9424 .ib = 719280000 * 2,
9425 },
9426};
9427
9428#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009429static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9430 /* Default case static display/UI/2d/3d if FB SMI */
9431 {
9432 .src = MSM_BUS_MASTER_MDP_PORT0,
9433 .dst = MSM_BUS_SLAVE_SMI,
9434 .ab = 175110000,
9435 .ib = 218887500,
9436 },
9437 /* Master and slaves can be from different fabrics */
9438 {
9439 .src = MSM_BUS_MASTER_MDP_PORT0,
9440 .dst = MSM_BUS_SLAVE_EBI_CH0,
9441 .ab = 0,
9442 .ib = 0,
9443 },
9444};
9445
9446static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9447 /* Default case static display/UI/2d/3d if FB SMI */
9448 {
9449 .src = MSM_BUS_MASTER_MDP_PORT0,
9450 .dst = MSM_BUS_SLAVE_SMI,
9451 .ab = 0,
9452 .ib = 0,
9453 },
9454 /* Master and slaves can be from different fabrics */
9455 {
9456 .src = MSM_BUS_MASTER_MDP_PORT0,
9457 .dst = MSM_BUS_SLAVE_EBI_CH0,
9458 .ab = 216000000,
9459 .ib = 270000000 * 2,
9460 },
9461};
9462static struct msm_bus_vectors mdp_vga_vectors[] = {
9463 /* VGA and less video */
9464 {
9465 .src = MSM_BUS_MASTER_MDP_PORT0,
9466 .dst = MSM_BUS_SLAVE_SMI,
9467 .ab = 216000000,
9468 .ib = 270000000,
9469 },
9470 {
9471 .src = MSM_BUS_MASTER_MDP_PORT0,
9472 .dst = MSM_BUS_SLAVE_EBI_CH0,
9473 .ab = 216000000,
9474 .ib = 270000000 * 2,
9475 },
9476};
9477
9478static struct msm_bus_vectors mdp_720p_vectors[] = {
9479 /* 720p and less video */
9480 {
9481 .src = MSM_BUS_MASTER_MDP_PORT0,
9482 .dst = MSM_BUS_SLAVE_SMI,
9483 .ab = 230400000,
9484 .ib = 288000000,
9485 },
9486 /* Master and slaves can be from different fabrics */
9487 {
9488 .src = MSM_BUS_MASTER_MDP_PORT0,
9489 .dst = MSM_BUS_SLAVE_EBI_CH0,
9490 .ab = 230400000,
9491 .ib = 288000000 * 2,
9492 },
9493};
9494
9495static struct msm_bus_vectors mdp_1080p_vectors[] = {
9496 /* 1080p and less video */
9497 {
9498 .src = MSM_BUS_MASTER_MDP_PORT0,
9499 .dst = MSM_BUS_SLAVE_SMI,
9500 .ab = 334080000,
9501 .ib = 417600000,
9502 },
9503 /* Master and slaves can be from different fabrics */
9504 {
9505 .src = MSM_BUS_MASTER_MDP_PORT0,
9506 .dst = MSM_BUS_SLAVE_EBI_CH0,
9507 .ab = 334080000,
Ravishangar Kalyanam731beb92011-07-07 18:27:32 -07009508 .ib = 550000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009509 },
9510};
9511
9512#endif
9513static struct msm_bus_paths mdp_bus_scale_usecases[] = {
9514 {
9515 ARRAY_SIZE(mdp_init_vectors),
9516 mdp_init_vectors,
9517 },
9518 {
9519 ARRAY_SIZE(mdp_sd_smi_vectors),
9520 mdp_sd_smi_vectors,
9521 },
9522 {
9523 ARRAY_SIZE(mdp_sd_ebi_vectors),
9524 mdp_sd_ebi_vectors,
9525 },
9526 {
9527 ARRAY_SIZE(mdp_vga_vectors),
9528 mdp_vga_vectors,
9529 },
9530 {
9531 ARRAY_SIZE(mdp_720p_vectors),
9532 mdp_720p_vectors,
9533 },
9534 {
9535 ARRAY_SIZE(mdp_1080p_vectors),
9536 mdp_1080p_vectors,
9537 },
9538};
9539static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
9540 mdp_bus_scale_usecases,
9541 ARRAY_SIZE(mdp_bus_scale_usecases),
9542 .name = "mdp",
9543};
9544
9545#endif
9546#ifdef CONFIG_MSM_BUS_SCALING
9547static struct msm_bus_vectors dtv_bus_init_vectors[] = {
9548 /* For now, 0th array entry is reserved.
9549 * Please leave 0 as is and don't use it
9550 */
9551 {
9552 .src = MSM_BUS_MASTER_MDP_PORT0,
9553 .dst = MSM_BUS_SLAVE_SMI,
9554 .ab = 0,
9555 .ib = 0,
9556 },
9557 /* Master and slaves can be from different fabrics */
9558 {
9559 .src = MSM_BUS_MASTER_MDP_PORT0,
9560 .dst = MSM_BUS_SLAVE_EBI_CH0,
9561 .ab = 0,
9562 .ib = 0,
9563 },
9564};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009565
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009566static struct msm_bus_vectors dtv_bus_def_vectors[] = {
9567 /* For now, 0th array entry is reserved.
9568 * Please leave 0 as is and don't use it
9569 */
9570 {
9571 .src = MSM_BUS_MASTER_MDP_PORT0,
9572 .dst = MSM_BUS_SLAVE_SMI,
9573 .ab = 566092800,
9574 .ib = 707616000,
9575 },
9576 /* Master and slaves can be from different fabrics */
9577 {
9578 .src = MSM_BUS_MASTER_MDP_PORT0,
9579 .dst = MSM_BUS_SLAVE_EBI_CH0,
9580 .ab = 566092800,
9581 .ib = 707616000,
9582 },
9583};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009584
9585static struct msm_bus_vectors dtv_bus_hdmi_prim_vectors[] = {
9586 /* For now, 0th array entry is reserved.
9587 * Please leave 0 as is and don't use it
9588 */
9589 {
9590 .src = MSM_BUS_MASTER_MDP_PORT0,
9591 .dst = MSM_BUS_SLAVE_SMI,
9592 .ab = 2000000000,
9593 .ib = 2000000000,
9594 },
9595 /* Master and slaves can be from different fabrics */
9596 {
9597 .src = MSM_BUS_MASTER_MDP_PORT0,
9598 .dst = MSM_BUS_SLAVE_EBI_CH0,
9599 .ab = 2000000000,
9600 .ib = 2000000000,
9601 },
9602};
9603
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009604static struct msm_bus_paths dtv_bus_scale_usecases[] = {
9605 {
9606 ARRAY_SIZE(dtv_bus_init_vectors),
9607 dtv_bus_init_vectors,
9608 },
9609 {
9610 ARRAY_SIZE(dtv_bus_def_vectors),
9611 dtv_bus_def_vectors,
9612 },
9613};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009614
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009615static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
9616 dtv_bus_scale_usecases,
9617 ARRAY_SIZE(dtv_bus_scale_usecases),
9618 .name = "dtv",
9619};
9620
9621static struct lcdc_platform_data dtv_pdata = {
9622 .bus_scale_table = &dtv_bus_scale_pdata,
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309623 .lcdc_power_save = hdmi_panel_power,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009624};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009625
9626static struct msm_bus_paths dtv_hdmi_prim_bus_scale_usecases[] = {
9627 {
9628 ARRAY_SIZE(dtv_bus_init_vectors),
9629 dtv_bus_init_vectors,
9630 },
9631 {
9632 ARRAY_SIZE(dtv_bus_hdmi_prim_vectors),
9633 dtv_bus_hdmi_prim_vectors,
9634 },
9635};
9636
9637static struct msm_bus_scale_pdata dtv_hdmi_prim_bus_scale_pdata = {
9638 dtv_hdmi_prim_bus_scale_usecases,
9639 ARRAY_SIZE(dtv_hdmi_prim_bus_scale_usecases),
9640 .name = "dtv",
9641};
9642
9643static struct lcdc_platform_data dtv_hdmi_prim_pdata = {
9644 .bus_scale_table = &dtv_hdmi_prim_bus_scale_pdata,
9645};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009646#endif
9647
9648
9649static struct lcdc_platform_data lcdc_pdata = {
9650 .lcdc_power_save = lcdc_panel_power,
9651};
9652
9653
9654#define MDP_VSYNC_GPIO 28
9655
9656/*
9657 * MIPI_DSI only use 8058_LDO0 which need always on
9658 * therefore it need to be put at low power mode if
9659 * it was not used instead of turn it off.
9660 */
9661static int mipi_dsi_panel_power(int on)
9662{
9663 int flag_on = !!on;
9664 static int mipi_dsi_power_save_on;
9665 static struct regulator *ldo0;
9666 int rc = 0;
9667
9668 if (mipi_dsi_power_save_on == flag_on)
9669 return 0;
9670
9671 mipi_dsi_power_save_on = flag_on;
9672
9673 if (ldo0 == NULL) { /* init */
9674 ldo0 = regulator_get(NULL, "8058_l0");
9675 if (IS_ERR(ldo0)) {
9676 pr_debug("%s: LDO0 failed\n", __func__);
9677 rc = PTR_ERR(ldo0);
9678 return rc;
9679 }
9680
9681 rc = regulator_set_voltage(ldo0, 1200000, 1200000);
9682 if (rc)
9683 goto out;
9684
9685 rc = regulator_enable(ldo0);
9686 if (rc)
9687 goto out;
9688 }
9689
9690 if (on) {
9691 /* set ldo0 to HPM */
9692 rc = regulator_set_optimum_mode(ldo0, 100000);
9693 if (rc < 0)
9694 goto out;
9695 } else {
9696 /* set ldo0 to LPM */
Padmanabhan Komanduru0b478ff2011-11-22 19:15:40 +05309697 rc = regulator_set_optimum_mode(ldo0, 1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009698 if (rc < 0)
9699 goto out;
9700 }
9701
9702 return 0;
9703out:
9704 regulator_disable(ldo0);
9705 regulator_put(ldo0);
9706 ldo0 = NULL;
9707 return rc;
9708}
9709
9710static struct mipi_dsi_platform_data mipi_dsi_pdata = {
9711 .vsync_gpio = MDP_VSYNC_GPIO,
9712 .dsi_power_save = mipi_dsi_panel_power,
9713};
9714
9715#ifdef CONFIG_FB_MSM_TVOUT
9716static struct regulator *reg_8058_l13;
9717
9718static int atv_dac_power(int on)
9719{
9720 int rc = 0;
9721 #define _GET_REGULATOR(var, name) do { \
9722 var = regulator_get(NULL, name); \
9723 if (IS_ERR(var)) { \
9724 pr_info("'%s' regulator not found, rc=%ld\n", \
9725 name, IS_ERR(var)); \
9726 var = NULL; \
9727 return -ENODEV; \
9728 } \
9729 } while (0)
9730
9731 if (!reg_8058_l13)
9732 _GET_REGULATOR(reg_8058_l13, "8058_l13");
9733 #undef _GET_REGULATOR
9734
9735 if (on) {
9736 rc = regulator_set_voltage(reg_8058_l13, 2050000, 2050000);
9737 if (rc) {
9738 pr_info("%s: '%s' regulator set voltage failed,\
9739 rc=%d\n", __func__, "8058_l13", rc);
9740 return rc;
9741 }
9742
9743 rc = regulator_enable(reg_8058_l13);
9744 if (rc) {
9745 pr_err("%s: '%s' regulator enable failed,\
9746 rc=%d\n", __func__, "8058_l13", rc);
9747 return rc;
9748 }
9749 } else {
9750 rc = regulator_force_disable(reg_8058_l13);
9751 if (rc)
9752 pr_warning("%s: '%s' regulator disable failed, rc=%d\n",
9753 __func__, "8058_l13", rc);
9754 }
9755 return rc;
9756
9757}
9758#endif
9759
9760#ifdef CONFIG_FB_MSM_MIPI_DSI
9761int mdp_core_clk_rate_table[] = {
9762 85330000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -08009763 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009764 160000000,
9765 200000000,
9766};
9767#else
9768int mdp_core_clk_rate_table[] = {
9769 59080000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -08009770 128000000,
kuogee hsieh26791a92011-08-01 18:35:58 -07009771 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009772 200000000,
9773};
9774#endif
9775
9776static struct msm_panel_common_pdata mdp_pdata = {
9777 .gpio = MDP_VSYNC_GPIO,
9778 .mdp_core_clk_rate = 59080000,
9779 .mdp_core_clk_table = mdp_core_clk_rate_table,
9780 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
9781#ifdef CONFIG_MSM_BUS_SCALING
9782 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
9783#endif
9784 .mdp_rev = MDP_REV_41,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009785#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Ravishangar Kalyanama3b168b2012-03-26 11:13:11 -07009786 .mem_hid = BIT(ION_CP_WB_HEAP_ID),
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009787#else
9788 .mem_hid = MEMTYPE_EBI1,
9789#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009790};
9791
Huaibin Yanga5419422011-12-08 23:52:10 -08009792static void __init reserve_mdp_memory(void)
9793{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009794 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
9795 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
9796#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
9797 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9798 mdp_pdata.ov0_wb_size;
9799 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9800 mdp_pdata.ov1_wb_size;
9801#endif
Huaibin Yanga5419422011-12-08 23:52:10 -08009802}
9803
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009804#ifdef CONFIG_FB_MSM_TVOUT
9805
9806#ifdef CONFIG_MSM_BUS_SCALING
9807static struct msm_bus_vectors atv_bus_init_vectors[] = {
9808 /* For now, 0th array entry is reserved.
9809 * Please leave 0 as is and don't use it
9810 */
9811 {
9812 .src = MSM_BUS_MASTER_MDP_PORT0,
9813 .dst = MSM_BUS_SLAVE_SMI,
9814 .ab = 0,
9815 .ib = 0,
9816 },
9817 /* Master and slaves can be from different fabrics */
9818 {
9819 .src = MSM_BUS_MASTER_MDP_PORT0,
9820 .dst = MSM_BUS_SLAVE_EBI_CH0,
9821 .ab = 0,
9822 .ib = 0,
9823 },
9824};
9825static struct msm_bus_vectors atv_bus_def_vectors[] = {
9826 /* For now, 0th array entry is reserved.
9827 * Please leave 0 as is and don't use it
9828 */
9829 {
9830 .src = MSM_BUS_MASTER_MDP_PORT0,
9831 .dst = MSM_BUS_SLAVE_SMI,
9832 .ab = 236390400,
9833 .ib = 265939200,
9834 },
9835 /* Master and slaves can be from different fabrics */
9836 {
9837 .src = MSM_BUS_MASTER_MDP_PORT0,
9838 .dst = MSM_BUS_SLAVE_EBI_CH0,
9839 .ab = 236390400,
9840 .ib = 265939200,
9841 },
9842};
9843static struct msm_bus_paths atv_bus_scale_usecases[] = {
9844 {
9845 ARRAY_SIZE(atv_bus_init_vectors),
9846 atv_bus_init_vectors,
9847 },
9848 {
9849 ARRAY_SIZE(atv_bus_def_vectors),
9850 atv_bus_def_vectors,
9851 },
9852};
9853static struct msm_bus_scale_pdata atv_bus_scale_pdata = {
9854 atv_bus_scale_usecases,
9855 ARRAY_SIZE(atv_bus_scale_usecases),
9856 .name = "atv",
9857};
9858#endif
9859
9860static struct tvenc_platform_data atv_pdata = {
9861 .poll = 0,
9862 .pm_vid_en = atv_dac_power,
9863#ifdef CONFIG_MSM_BUS_SCALING
9864 .bus_scale_table = &atv_bus_scale_pdata,
9865#endif
9866};
9867#endif
9868
9869static void __init msm_fb_add_devices(void)
9870{
9871#ifdef CONFIG_FB_MSM_LCDC_DSUB
9872 mdp_pdata.mdp_core_clk_table = NULL;
9873 mdp_pdata.num_mdp_clk = 0;
9874 mdp_pdata.mdp_core_clk_rate = 200000000;
9875#endif
9876 if (machine_is_msm8x60_rumi3())
9877 msm_fb_register_device("mdp", NULL);
9878 else
9879 msm_fb_register_device("mdp", &mdp_pdata);
9880
9881 msm_fb_register_device("lcdc", &lcdc_pdata);
9882 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
9883#ifdef CONFIG_MSM_BUS_SCALING
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009884 if (hdmi_is_primary)
9885 msm_fb_register_device("dtv", &dtv_hdmi_prim_pdata);
9886 else
9887 msm_fb_register_device("dtv", &dtv_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009888#endif
9889#ifdef CONFIG_FB_MSM_TVOUT
9890 msm_fb_register_device("tvenc", &atv_pdata);
9891 msm_fb_register_device("tvout_device", NULL);
9892#endif
9893}
9894
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07009895/**
9896 * Set MDP clocks to high frequency to avoid underflow when
9897 * using high resolution 1200x1920 WUXGA/HDMI as primary panels
9898 */
9899static void set_mdp_clocks_for_wuxga(void)
9900{
9901 int i;
9902
9903 mdp_sd_smi_vectors[0].ab = 2000000000;
9904 mdp_sd_smi_vectors[0].ib = 2000000000;
9905 mdp_sd_smi_vectors[1].ab = 2000000000;
9906 mdp_sd_smi_vectors[1].ib = 2000000000;
9907
9908 mdp_sd_ebi_vectors[0].ab = 2000000000;
9909 mdp_sd_ebi_vectors[0].ib = 2000000000;
9910 mdp_sd_ebi_vectors[1].ab = 2000000000;
9911 mdp_sd_ebi_vectors[1].ib = 2000000000;
9912
9913 mdp_vga_vectors[0].ab = 2000000000;
9914 mdp_vga_vectors[0].ib = 2000000000;
9915 mdp_vga_vectors[1].ab = 2000000000;
9916 mdp_vga_vectors[1].ib = 2000000000;
9917
9918 mdp_720p_vectors[0].ab = 2000000000;
9919 mdp_720p_vectors[0].ib = 2000000000;
9920 mdp_720p_vectors[1].ab = 2000000000;
9921 mdp_720p_vectors[1].ib = 2000000000;
9922
9923 mdp_1080p_vectors[0].ab = 2000000000;
9924 mdp_1080p_vectors[0].ib = 2000000000;
9925 mdp_1080p_vectors[1].ab = 2000000000;
9926 mdp_1080p_vectors[1].ib = 2000000000;
9927
9928 mdp_pdata.mdp_core_clk_rate = 200000000;
9929
9930 for (i = 0; i < ARRAY_SIZE(mdp_core_clk_rate_table); i++)
9931 mdp_core_clk_rate_table[i] = 200000000;
9932}
9933
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009934#if (defined(CONFIG_MARIMBA_CORE)) && \
9935 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
9936
9937static const struct {
9938 char *name;
9939 int vmin;
9940 int vmax;
9941} bt_regs_info[] = {
9942 { "8058_s3", 1800000, 1800000 },
9943 { "8058_s2", 1300000, 1300000 },
9944 { "8058_l8", 2900000, 3050000 },
9945};
9946
9947static struct {
9948 bool enabled;
9949} bt_regs_status[] = {
9950 { false },
9951 { false },
9952 { false },
9953};
9954static struct regulator *bt_regs[ARRAY_SIZE(bt_regs_info)];
9955
9956static int bahama_bt(int on)
9957{
9958 int rc;
9959 int i;
9960 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
9961
9962 struct bahama_variant_register {
9963 const size_t size;
9964 const struct bahama_config_register *set;
9965 };
9966
9967 const struct bahama_config_register *p;
9968
9969 u8 version;
9970
9971 const struct bahama_config_register v10_bt_on[] = {
9972 { 0xE9, 0x00, 0xFF },
9973 { 0xF4, 0x80, 0xFF },
9974 { 0xE4, 0x00, 0xFF },
9975 { 0xE5, 0x00, 0x0F },
9976#ifdef CONFIG_WLAN
9977 { 0xE6, 0x38, 0x7F },
9978 { 0xE7, 0x06, 0xFF },
9979#endif
9980 { 0xE9, 0x21, 0xFF },
9981 { 0x01, 0x0C, 0x1F },
9982 { 0x01, 0x08, 0x1F },
9983 };
9984
9985 const struct bahama_config_register v20_bt_on_fm_off[] = {
9986 { 0x11, 0x0C, 0xFF },
9987 { 0x13, 0x01, 0xFF },
9988 { 0xF4, 0x80, 0xFF },
9989 { 0xF0, 0x00, 0xFF },
9990 { 0xE9, 0x00, 0xFF },
9991#ifdef CONFIG_WLAN
9992 { 0x81, 0x00, 0x7F },
9993 { 0x82, 0x00, 0xFF },
9994 { 0xE6, 0x38, 0x7F },
9995 { 0xE7, 0x06, 0xFF },
9996#endif
9997 { 0xE9, 0x21, 0xFF },
9998 };
9999
10000 const struct bahama_config_register v20_bt_on_fm_on[] = {
10001 { 0x11, 0x0C, 0xFF },
10002 { 0x13, 0x01, 0xFF },
10003 { 0xF4, 0x86, 0xFF },
10004 { 0xF0, 0x06, 0xFF },
10005 { 0xE9, 0x00, 0xFF },
10006#ifdef CONFIG_WLAN
10007 { 0x81, 0x00, 0x7F },
10008 { 0x82, 0x00, 0xFF },
10009 { 0xE6, 0x38, 0x7F },
10010 { 0xE7, 0x06, 0xFF },
10011#endif
10012 { 0xE9, 0x21, 0xFF },
10013 };
10014
10015 const struct bahama_config_register v10_bt_off[] = {
10016 { 0xE9, 0x00, 0xFF },
10017 };
10018
10019 const struct bahama_config_register v20_bt_off_fm_off[] = {
10020 { 0xF4, 0x84, 0xFF },
10021 { 0xF0, 0x04, 0xFF },
10022 { 0xE9, 0x00, 0xFF }
10023 };
10024
10025 const struct bahama_config_register v20_bt_off_fm_on[] = {
10026 { 0xF4, 0x86, 0xFF },
10027 { 0xF0, 0x06, 0xFF },
10028 { 0xE9, 0x00, 0xFF }
10029 };
10030 const struct bahama_variant_register bt_bahama[2][3] = {
10031 {
10032 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
10033 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
10034 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
10035 },
10036 {
10037 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
10038 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
10039 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
10040 }
10041 };
10042
10043 u8 offset = 0; /* index into bahama configs */
10044
10045 on = on ? 1 : 0;
10046 version = read_bahama_ver();
10047
10048 if (version == VER_UNSUPPORTED) {
10049 dev_err(&msm_bt_power_device.dev,
10050 "%s: unsupported version\n",
10051 __func__);
10052 return -EIO;
10053 }
10054
10055 if (version == VER_2_0) {
10056 if (marimba_get_fm_status(&config))
10057 offset = 0x01;
10058 }
10059
10060 /* Voting off 1.3V S2 Regulator,BahamaV2 used in Normal mode */
10061 if (on && (version == VER_2_0)) {
10062 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
10063 if ((!strcmp(bt_regs_info[i].name, "8058_s2"))
10064 && (bt_regs_status[i].enabled == true)) {
10065 if (regulator_disable(bt_regs[i])) {
10066 dev_err(&msm_bt_power_device.dev,
10067 "%s: regulator disable failed",
10068 __func__);
10069 }
10070 bt_regs_status[i].enabled = false;
10071 break;
10072 }
10073 }
10074 }
10075
10076 p = bt_bahama[on][version + offset].set;
10077
10078 dev_info(&msm_bt_power_device.dev,
10079 "%s: found version %d\n", __func__, version);
10080
10081 for (i = 0; i < bt_bahama[on][version + offset].size; i++) {
10082 u8 value = (p+i)->value;
10083 rc = marimba_write_bit_mask(&config,
10084 (p+i)->reg,
10085 &value,
10086 sizeof((p+i)->value),
10087 (p+i)->mask);
10088 if (rc < 0) {
10089 dev_err(&msm_bt_power_device.dev,
10090 "%s: reg %d write failed: %d\n",
10091 __func__, (p+i)->reg, rc);
10092 return rc;
10093 }
10094 dev_dbg(&msm_bt_power_device.dev,
10095 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
10096 __func__, (p+i)->reg,
10097 value, (p+i)->mask);
10098 }
10099 /* Update BT Status */
10100 if (on)
10101 marimba_set_bt_status(&config, true);
10102 else
10103 marimba_set_bt_status(&config, false);
10104
10105 return 0;
10106}
10107
10108static int bluetooth_use_regulators(int on)
10109{
10110 int i, recover = -1, rc = 0;
10111
10112 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
10113 bt_regs[i] = on ? regulator_get(&msm_bt_power_device.dev,
10114 bt_regs_info[i].name) :
10115 (regulator_put(bt_regs[i]), NULL);
10116 if (IS_ERR(bt_regs[i])) {
10117 rc = PTR_ERR(bt_regs[i]);
10118 dev_err(&msm_bt_power_device.dev,
10119 "regulator %s get failed (%d)\n",
10120 bt_regs_info[i].name, rc);
10121 recover = i - 1;
10122 bt_regs[i] = NULL;
10123 break;
10124 }
10125
10126 if (!on)
10127 continue;
10128
10129 rc = regulator_set_voltage(bt_regs[i],
10130 bt_regs_info[i].vmin,
10131 bt_regs_info[i].vmax);
10132 if (rc < 0) {
10133 dev_err(&msm_bt_power_device.dev,
10134 "regulator %s voltage set (%d)\n",
10135 bt_regs_info[i].name, rc);
10136 recover = i;
10137 break;
10138 }
10139 }
10140
10141 if (on && (recover > -1))
10142 for (i = recover; i >= 0; i--) {
10143 regulator_put(bt_regs[i]);
10144 bt_regs[i] = NULL;
10145 }
10146
10147 return rc;
10148}
10149
10150static int bluetooth_switch_regulators(int on)
10151{
10152 int i, rc = 0;
10153
10154 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
10155 if (on && (bt_regs_status[i].enabled == false)) {
10156 rc = regulator_enable(bt_regs[i]);
10157 if (rc < 0) {
10158 dev_err(&msm_bt_power_device.dev,
10159 "regulator %s %s failed (%d)\n",
10160 bt_regs_info[i].name,
10161 "enable", rc);
10162 if (i > 0) {
10163 while (--i) {
10164 regulator_disable(bt_regs[i]);
10165 bt_regs_status[i].enabled
10166 = false;
10167 }
10168 break;
10169 }
10170 }
10171 bt_regs_status[i].enabled = true;
10172 } else if (!on && (bt_regs_status[i].enabled == true)) {
10173 rc = regulator_disable(bt_regs[i]);
10174 if (rc < 0) {
10175 dev_err(&msm_bt_power_device.dev,
10176 "regulator %s %s failed (%d)\n",
10177 bt_regs_info[i].name,
10178 "disable", rc);
10179 break;
10180 }
10181 bt_regs_status[i].enabled = false;
10182 }
10183 }
10184 return rc;
10185}
10186
10187static struct msm_xo_voter *bt_clock;
10188
10189static int bluetooth_power(int on)
10190{
10191 int rc = 0;
10192 int id;
10193
10194 /* In case probe function fails, cur_connv_type would be -1 */
10195 id = adie_get_detected_connectivity_type();
10196 if (id != BAHAMA_ID) {
10197 pr_err("%s: unexpected adie connectivity type: %d\n",
10198 __func__, id);
10199 return -ENODEV;
10200 }
10201
10202 if (on) {
10203
10204 rc = bluetooth_use_regulators(1);
10205 if (rc < 0)
10206 goto out;
10207
10208 rc = bluetooth_switch_regulators(1);
10209
10210 if (rc < 0)
10211 goto fail_put;
10212
10213 bt_clock = msm_xo_get(MSM_XO_TCXO_D0, "bt_power");
10214
10215 if (IS_ERR(bt_clock)) {
10216 pr_err("Couldn't get TCXO_D0 voter\n");
10217 goto fail_switch;
10218 }
10219
10220 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_ON);
10221
10222 if (rc < 0) {
10223 pr_err("Failed to vote for TCXO_DO ON\n");
10224 goto fail_vote;
10225 }
10226
10227 rc = bahama_bt(1);
10228
10229 if (rc < 0)
10230 goto fail_clock;
10231
10232 msleep(10);
10233
10234 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_PIN_CTRL);
10235
10236 if (rc < 0) {
10237 pr_err("Failed to vote for TCXO_DO pin control\n");
10238 goto fail_vote;
10239 }
10240 } else {
10241 /* check for initial RFKILL block (power off) */
10242 /* some RFKILL versions/configurations rfkill_register */
10243 /* calls here for an initial set_block */
10244 /* avoid calling i2c and regulator before unblock (on) */
10245 if (platform_get_drvdata(&msm_bt_power_device) == NULL) {
10246 dev_info(&msm_bt_power_device.dev,
10247 "%s: initialized OFF/blocked\n", __func__);
10248 goto out;
10249 }
10250
10251 bahama_bt(0);
10252
10253fail_clock:
10254 msm_xo_mode_vote(bt_clock, MSM_XO_MODE_OFF);
10255fail_vote:
10256 msm_xo_put(bt_clock);
10257fail_switch:
10258 bluetooth_switch_regulators(0);
10259fail_put:
10260 bluetooth_use_regulators(0);
10261 }
10262
10263out:
10264 if (rc < 0)
10265 on = 0;
10266 dev_info(&msm_bt_power_device.dev,
10267 "Bluetooth power switch: state %d result %d\n", on, rc);
10268
10269 return rc;
10270}
10271
10272#endif /*CONFIG_MARIMBA_CORE, CONFIG_MSM_BT_POWER, CONFIG_MSM_BT_POWER_MODULE*/
10273
10274static void __init msm8x60_cfg_smsc911x(void)
10275{
10276 smsc911x_resources[1].start =
10277 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10278 smsc911x_resources[1].end =
10279 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10280}
10281
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010282void msm_fusion_setup_pinctrl(void)
10283{
10284 struct msm_xo_voter *a1;
10285
10286 if (socinfo_get_platform_subtype() == 0x3) {
10287 /*
10288 * Vote for the A1 clock to be in pin control mode before
10289 * the external images are loaded.
10290 */
10291 a1 = msm_xo_get(MSM_XO_TCXO_A1, "mdm");
10292 BUG_ON(!a1);
10293 msm_xo_mode_vote(a1, MSM_XO_MODE_PIN_CTRL);
10294 }
10295}
10296
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010297struct msm_board_data {
10298 struct msm_gpiomux_configs *gpiomux_cfgs;
10299};
10300
10301static struct msm_board_data msm8x60_rumi3_board_data __initdata = {
10302 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10303};
10304
10305static struct msm_board_data msm8x60_sim_board_data __initdata = {
10306 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10307};
10308
10309static struct msm_board_data msm8x60_surf_board_data __initdata = {
10310 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10311};
10312
10313static struct msm_board_data msm8x60_ffa_board_data __initdata = {
10314 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10315};
10316
10317static struct msm_board_data msm8x60_fluid_board_data __initdata = {
10318 .gpiomux_cfgs = msm8x60_fluid_gpiomux_cfgs,
10319};
10320
10321static struct msm_board_data msm8x60_charm_surf_board_data __initdata = {
10322 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10323};
10324
10325static struct msm_board_data msm8x60_charm_ffa_board_data __initdata = {
10326 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10327};
10328
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010329static struct msm_board_data msm8x60_dragon_board_data __initdata = {
10330 .gpiomux_cfgs = msm8x60_dragon_gpiomux_cfgs,
10331};
10332
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010333static void __init msm8x60_init(struct msm_board_data *board_data)
10334{
10335 uint32_t soc_platform_version;
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010336#ifdef CONFIG_USB_EHCI_MSM_72K
10337 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
10338 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
10339 .level = PM8901_MPP_DIG_LEVEL_L5,
10340 .control = PM8XXX_MPP_DOUT_CTRL_HIGH,
10341 };
10342#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010343 pmic_reset_irq = PM8058_IRQ_BASE + PM8058_RESOUT_IRQ;
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070010344
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010345 /*
10346 * Initialize RPM first as other drivers and devices may need
10347 * it for their initialization.
10348 */
Praveen Chidambaram78499012011-11-01 17:15:17 -060010349 BUG_ON(msm_rpm_init(&msm8660_rpm_data));
10350 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010351 if (msm_xo_init())
10352 pr_err("Failed to initialize XO votes\n");
10353
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010354 msm8x60_check_2d_hardware();
10355
10356 /* Change SPM handling of core 1 if PMM 8160 is present. */
10357 soc_platform_version = socinfo_get_platform_version();
10358 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1 &&
10359 SOCINFO_VERSION_MINOR(soc_platform_version) >= 2) {
10360 struct msm_spm_platform_data *spm_data;
10361
10362 spm_data = &msm_spm_data_v1[1];
10363 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10364 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10365
10366 spm_data = &msm_spm_data[1];
10367 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10368 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10369 }
10370
10371 /*
10372 * Initialize SPM before acpuclock as the latter calls into SPM
10373 * driver to set ACPU voltages.
10374 */
10375 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10376 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
10377 else
10378 msm_spm_init(msm_spm_data_v1, ARRAY_SIZE(msm_spm_data_v1));
10379
10380 /*
10381 * Set regulators 8901_l4 and 8901_l6 to be always on in HPM for SURF
10382 * devices so that the RPM doesn't drop into a low power mode that an
10383 * un-reworked SURF cannot resume from.
10384 */
10385 if (machine_is_msm8x60_surf()) {
David Collins6f032ba2011-08-31 14:08:15 -070010386 int i;
10387
10388 for (i = 0; i < ARRAY_SIZE(rpm_regulator_init_data); i++)
10389 if (rpm_regulator_init_data[i].id
10390 == RPM_VREG_ID_PM8901_L4
10391 || rpm_regulator_init_data[i].id
10392 == RPM_VREG_ID_PM8901_L6)
10393 rpm_regulator_init_data[i]
10394 .init_data.constraints.always_on = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010395 }
10396
10397 /*
10398 * Disable regulator info printing so that regulator registration
10399 * messages do not enter the kmsg log.
10400 */
10401 regulator_suppress_info_printing();
10402
10403 /* Initialize regulators needed for clock_init. */
10404 platform_add_devices(early_regulators, ARRAY_SIZE(early_regulators));
10405
Stephen Boydbb600ae2011-08-02 20:11:40 -070010406 msm_clock_init(&msm8x60_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010407
10408 /* Buses need to be initialized before early-device registration
10409 * to get the platform data for fabrics.
10410 */
10411 msm8x60_init_buses();
10412 platform_add_devices(early_devices, ARRAY_SIZE(early_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010413
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010414 /*
10415 * Enable EBI2 only for boards which make use of it. Leave
10416 * it disabled for all others for additional power savings.
10417 */
10418 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10419 machine_is_msm8x60_rumi3() ||
10420 machine_is_msm8x60_sim() ||
10421 machine_is_msm8x60_fluid() ||
10422 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010423 msm8x60_init_ebi2();
10424 msm8x60_init_tlmm();
10425 msm8x60_init_gpiomux(board_data->gpiomux_cfgs);
10426 msm8x60_init_uart12dm();
Kevin Chan3be11612012-03-22 20:05:40 -070010427#ifdef CONFIG_MSM_CAMERA_V4L2
10428 msm8x60_init_cam();
10429#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010430 msm8x60_init_mmc();
10431
Kevin Chan3be11612012-03-22 20:05:40 -070010432
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010433#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
10434 msm8x60_init_pm8058_othc();
10435#endif
10436
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010437 if (machine_is_msm8x60_fluid())
10438 pm8058_platform_data.keypad_pdata = &fluid_keypad_data;
10439 else if (machine_is_msm8x60_dragon())
10440 pm8058_platform_data.keypad_pdata = &dragon_keypad_data;
10441 else
10442 pm8058_platform_data.keypad_pdata = &ffa_keypad_data;
Steve Mucklef132c6c2012-06-06 18:30:57 -070010443#if !defined(CONFIG_MSM_CAMERA_V4L2) && defined(CONFIG_WEBCAM_OV9726)
Jilai Wang53d27a82011-07-13 14:32:58 -040010444 /* Specify reset pin for OV9726 */
10445 if (machine_is_msm8x60_dragon()) {
10446 msm_camera_sensor_ov9726_data.sensor_reset = 62;
10447 ov9726_sensor_8660_info.mount_angle = 270;
10448 }
Kevin Chan3be11612012-03-22 20:05:40 -070010449#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010450#ifdef CONFIG_BATTERY_MSM8X60
10451 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10452 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
10453 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_fluid())
10454 platform_device_register(&msm_charger_device);
10455#endif
10456
10457 if (machine_is_msm8x60_dragon())
10458 pm8058_platform_data.charger_pdata = &pmic8058_charger_dragon;
10459 if (!machine_is_msm8x60_fluid())
10460 pm8058_platform_data.charger_pdata = &pmic8058_charger_ffa_surf;
10461
10462 /* configure pmic leds */
10463 if (machine_is_msm8x60_fluid())
10464 pm8058_platform_data.leds_pdata = &pm8058_fluid_flash_leds_data;
10465 else if (machine_is_msm8x60_dragon())
10466 pm8058_platform_data.leds_pdata = &pm8058_dragon_leds_data;
10467 else
10468 pm8058_platform_data.leds_pdata = &pm8058_flash_leds_data;
10469
10470 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
10471 machine_is_msm8x60_dragon()) {
10472 pm8058_platform_data.vibrator_pdata = &pm8058_vib_pdata;
10473 }
10474
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010475 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10476 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010477 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010478 msm8x60_cfg_smsc911x();
10479 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
Matt Wagantall1f65d9d2012-04-25 14:24:20 -070010480 platform_add_devices(msm8660_footswitch,
10481 msm8660_num_footswitch);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010482 platform_add_devices(surf_devices,
10483 ARRAY_SIZE(surf_devices));
10484
10485#ifdef CONFIG_MSM_DSPS
10486 if (machine_is_msm8x60_fluid()) {
10487 platform_device_unregister(&msm_gsbi12_qup_i2c_device);
10488 msm8x60_init_dsps();
10489 }
10490#endif
10491
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010492 pm8901_vreg_mpp0_init();
10493
10494 platform_device_register(&msm8x60_8901_mpp_vreg);
10495
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010496#ifdef CONFIG_USB_EHCI_MSM_72K
10497 /*
10498 * Drive MPP2 pin HIGH for PHY to generate ID interrupts on 8660
10499 * fluid
10500 */
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010501 if (machine_is_msm8x60_fluid())
10502 pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1), &hsusb_phy_mpp);
10503 msm_add_host(0, &msm_usb_host_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010504#endif
Lei Zhou338cab82011-08-19 13:38:17 -040010505
10506#ifdef CONFIG_SND_SOC_MSM8660_APQ
10507 if (machine_is_msm8x60_dragon())
10508 platform_add_devices(dragon_alsa_devices,
10509 ARRAY_SIZE(dragon_alsa_devices));
10510 else
10511#endif
10512 platform_add_devices(asoc_devices,
10513 ARRAY_SIZE(asoc_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010514 } else {
10515 msm8x60_configure_smc91x();
10516 platform_add_devices(rumi_sim_devices,
10517 ARRAY_SIZE(rumi_sim_devices));
10518 }
10519#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010520 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10521 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010522 msm8x60_cfg_isp1763();
10523#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010524
10525 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10526 platform_add_devices(charm_devices, ARRAY_SIZE(charm_devices));
10527
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010528
10529#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
10530 if (machine_is_msm8x60_fluid())
10531 platform_device_register(&msm_gsbi10_qup_spi_device);
10532 else
10533 platform_device_register(&msm_gsbi1_qup_spi_device);
10534#endif
10535
Steve Mucklef132c6c2012-06-06 18:30:57 -070010536#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
10537 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010538 if (machine_is_msm8x60_fluid())
10539 cyttsp_set_params();
10540#endif
10541 if (!machine_is_msm8x60_sim())
10542 msm_fb_add_devices();
10543 fixup_i2c_configs();
10544 register_i2c_devices();
10545
Terence Hampson1c73fef2011-07-19 17:10:49 -040010546 if (machine_is_msm8x60_dragon())
10547 smsc911x_config.reset_gpio
10548 = GPIO_ETHERNET_RESET_N_DRAGON;
10549
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010550 platform_device_register(&smsc911x_device);
10551
10552#if (defined(CONFIG_SPI_QUP)) && \
10553 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010554 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA) || \
10555 defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010556
10557 if (machine_is_msm8x60_fluid()) {
10558#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
10559 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
10560 spi_register_board_info(lcdc_samsung_spi_board_info,
10561 ARRAY_SIZE(lcdc_samsung_spi_board_info));
10562 } else
10563#endif
10564 {
10565#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
10566 spi_register_board_info(lcdc_auo_spi_board_info,
10567 ARRAY_SIZE(lcdc_auo_spi_board_info));
10568#endif
10569 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010570#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
10571 } else if (machine_is_msm8x60_dragon()) {
10572 spi_register_board_info(lcdc_nt35582_spi_board_info,
10573 ARRAY_SIZE(lcdc_nt35582_spi_board_info));
10574#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010575 }
10576#endif
10577
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060010578 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010579
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010580 pm8058_gpios_init();
10581
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010582#ifdef CONFIG_SENSORS_MSM_ADC
10583 if (machine_is_msm8x60_fluid()) {
10584 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
10585 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
10586 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3)
10587 msm_adc_pdata.gpio_config = APROC_CONFIG;
10588 else
10589 msm_adc_pdata.gpio_config = MPROC_CONFIG;
10590 }
10591 msm_adc_pdata.target_hw = MSM_8x60;
10592#endif
10593#ifdef CONFIG_MSM8X60_AUDIO
10594 msm_snddev_init();
10595#endif
10596#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
10597 if (machine_is_msm8x60_fluid())
10598 platform_device_register(&fluid_leds_gpio);
10599 else
10600 platform_device_register(&gpio_leds);
10601#endif
10602
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010603 msm8x60_multi_sdio_init();
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010604
10605 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10606 msm_fusion_setup_pinctrl();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010607}
10608
10609static void __init msm8x60_rumi3_init(void)
10610{
10611 msm8x60_init(&msm8x60_rumi3_board_data);
10612}
10613
10614static void __init msm8x60_sim_init(void)
10615{
10616 msm8x60_init(&msm8x60_sim_board_data);
10617}
10618
10619static void __init msm8x60_surf_init(void)
10620{
10621 msm8x60_init(&msm8x60_surf_board_data);
10622}
10623
10624static void __init msm8x60_ffa_init(void)
10625{
10626 msm8x60_init(&msm8x60_ffa_board_data);
10627}
10628
10629static void __init msm8x60_fluid_init(void)
10630{
10631 msm8x60_init(&msm8x60_fluid_board_data);
10632}
10633
10634static void __init msm8x60_charm_surf_init(void)
10635{
10636 msm8x60_init(&msm8x60_charm_surf_board_data);
10637}
10638
10639static void __init msm8x60_charm_ffa_init(void)
10640{
10641 msm8x60_init(&msm8x60_charm_ffa_board_data);
10642}
10643
10644static void __init msm8x60_charm_init_early(void)
10645{
10646 msm8x60_allocate_memory_regions();
Steve Mucklea55df6e2010-01-07 12:43:24 -080010647}
10648
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010649static void __init msm8x60_dragon_init(void)
10650{
10651 msm8x60_init(&msm8x60_dragon_board_data);
10652}
David Brown56e2d8a2011-08-04 02:01:02 -070010653
Steve Mucklea55df6e2010-01-07 12:43:24 -080010654MACHINE_START(MSM8X60_RUMI3, "QCT MSM8X60 RUMI3")
10655 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010656 .reserve = msm8x60_reserve,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010657 .init_irq = msm8x60_init_irq,
Marc Zyngier041f7772011-09-06 10:23:45 +010010658 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010659 .init_machine = msm8x60_rumi3_init,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010660 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010661 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010662 .restart = msm_restart,
Steve Muckle49b76f72010-03-19 17:00:08 -070010663MACHINE_END
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010664
10665MACHINE_START(MSM8X60_SIM, "QCT MSM8X60 SIMULATOR")
10666 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010667 .reserve = msm8x60_reserve,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010668 .init_irq = msm8x60_init_irq,
Marc Zyngier041f7772011-09-06 10:23:45 +010010669 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010670 .init_machine = msm8x60_sim_init,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010671 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010672 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010673 .restart = msm_restart,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010674MACHINE_END
10675
10676MACHINE_START(MSM8X60_SURF, "QCT MSM8X60 SURF")
10677 .map_io = msm8x60_map_io,
10678 .reserve = msm8x60_reserve,
10679 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010680 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010681 .init_machine = msm8x60_surf_init,
10682 .timer = &msm_timer,
10683 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010684 .restart = msm_restart,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010685MACHINE_END
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010686
10687MACHINE_START(MSM8X60_FFA, "QCT MSM8X60 FFA")
10688 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010689 .reserve = msm8x60_reserve,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010690 .init_irq = msm8x60_init_irq,
Marc Zyngier041f7772011-09-06 10:23:45 +010010691 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010692 .init_machine = msm8x60_ffa_init,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010693 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010694 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010695 .restart = msm_restart,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010696MACHINE_END
David Brown56e2d8a2011-08-04 02:01:02 -070010697
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010698MACHINE_START(MSM8X60_FLUID, "QCT MSM8X60 FLUID")
David Brown56e2d8a2011-08-04 02:01:02 -070010699 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010700 .reserve = msm8x60_reserve,
David Brown56e2d8a2011-08-04 02:01:02 -070010701 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010702 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010703 .init_machine = msm8x60_fluid_init,
David Brown56e2d8a2011-08-04 02:01:02 -070010704 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010705 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010706 .restart = msm_restart,
David Brown56e2d8a2011-08-04 02:01:02 -070010707MACHINE_END
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010708
10709MACHINE_START(MSM8X60_FUSION, "QCT MSM8X60 FUSION SURF")
10710 .map_io = msm8x60_map_io,
10711 .reserve = msm8x60_reserve,
10712 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010713 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010714 .init_machine = msm8x60_charm_surf_init,
10715 .timer = &msm_timer,
10716 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010717 .restart = msm_restart,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010718MACHINE_END
10719
10720MACHINE_START(MSM8X60_FUSN_FFA, "QCT MSM8X60 FUSION FFA")
10721 .map_io = msm8x60_map_io,
10722 .reserve = msm8x60_reserve,
10723 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010724 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010725 .init_machine = msm8x60_charm_ffa_init,
10726 .timer = &msm_timer,
10727 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010728 .restart = msm_restart,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010729MACHINE_END
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010730
10731MACHINE_START(MSM8X60_DRAGON, "QCT MSM8X60 DRAGON")
10732 .map_io = msm8x60_map_io,
10733 .reserve = msm8x60_reserve,
10734 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010735 .handle_irq = gic_handle_irq,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010736 .init_machine = msm8x60_dragon_init,
10737 .timer = &msm_timer,
10738 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010739 .restart = msm_restart,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010740MACHINE_END