blob: 02a753aa2e76e647823ea378168288b9822733fe [file] [log] [blame]
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -08001/* Copyright (c) 2010-2013, The Linux Foundation. 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
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -080014#include <linux/err.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080015#include <linux/kernel.h>
16#include <linux/platform_device.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070017#include <linux/gpio.h>
Steve Muckle9161d302010-02-11 11:50:40 -080018#include <linux/irq.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070019#include <linux/io.h>
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +053020#include <linux/msm_ssbi.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070021#include <linux/mfd/pmic8058.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080022
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070023#include <linux/leds.h>
24#include <linux/pmic8058-othc.h>
25#include <linux/mfd/pmic8901.h>
Steve Mucklef132c6c2012-06-06 18:30:57 -070026#include <linux/regulator/msm-gpio-regulator.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070027#include <linux/regulator/pmic8901-regulator.h>
28#include <linux/bootmem.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070029#include <linux/msm_adc.h>
30#include <linux/m_adcproc.h>
31#include <linux/mfd/marimba.h>
32#include <linux/msm-charger.h>
33#include <linux/i2c.h>
34#include <linux/i2c/sx150x.h>
35#include <linux/smsc911x.h>
36#include <linux/spi/spi.h>
37#include <linux/input/tdisc_shinetsu.h>
38#include <linux/input/cy8c_ts.h>
Steve Mucklef132c6c2012-06-06 18:30:57 -070039#include <linux/cyttsp-qc.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070040#include <linux/i2c/isa1200.h>
41#include <linux/dma-mapping.h>
42#include <linux/i2c/bq27520.h>
43
44#ifdef CONFIG_ANDROID_PMEM
45#include <linux/android_pmem.h>
46#endif
47
48#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
49#include <linux/i2c/smb137b.h>
50#endif
Lei Zhou338cab82011-08-19 13:38:17 -040051#ifdef CONFIG_SND_SOC_WM8903
52#include <sound/wm8903.h>
53#endif
Steve Mucklea55df6e2010-01-07 12:43:24 -080054#include <asm/mach-types.h>
55#include <asm/mach/arch.h>
Stephen Boyd9e775ad2011-08-12 00:14:28 +010056#include <asm/setup.h>
Marc Zyngier89bdafd12011-12-22 11:39:20 +053057#include <asm/hardware/gic.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080058
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070059#include <mach/dma.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080060#include <mach/board.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070061#include <mach/irqs.h>
62#include <mach/msm_spi.h>
63#include <mach/msm_serial_hs.h>
64#include <mach/msm_serial_hs_lite.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080065#include <mach/msm_iomap.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070066#include <mach/msm_memtypes.h>
67#include <asm/mach/mmc.h>
68#include <mach/msm_battery.h>
69#include <mach/msm_hsusb.h>
Rohit Vaswania513aa8d2011-07-18 15:14:28 -070070#include <mach/gpiomux.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070071#ifdef CONFIG_MSM_DSPS
72#include <mach/msm_dsps.h>
73#endif
74#include <mach/msm_xo.h>
75#include <mach/msm_bus_board.h>
76#include <mach/socinfo.h>
77#include <linux/i2c/isl9519.h>
78#ifdef CONFIG_USB_G_ANDROID
79#include <linux/usb/android.h>
80#include <mach/usbdiag.h>
81#endif
82#include <linux/regulator/consumer.h>
83#include <linux/regulator/machine.h>
84#include <mach/sdio_al.h>
85#include <mach/rpm.h>
86#include <mach/rpm-regulator.h>
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070087#include <mach/restart.h>
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053088#include <mach/board-msm8660.h>
Olav Haugan8726caf2012-05-10 15:11:35 -070089#include <mach/iommu_domains.h>
Steve Mucklea55df6e2010-01-07 12:43:24 -080090
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070091#include "devices.h"
92#include "devices-msm8x60.h"
Abhijeet Dharmapurikarefaca4f2011-12-27 16:24:07 -080093#include <mach/cpuidle.h>
Matt Wagantall7cca4642012-02-01 16:43:24 -080094#include "pm.h"
Subhash Jadavani909e04f2012-04-12 10:52:50 +053095#include <mach/mpm.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070096#include "spm.h"
97#include "rpm_log.h"
98#include "timer.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070099#include "gpiomux-8x60.h"
100#include "rpm_stats.h"
101#include "peripheral-loader.h"
102#include <linux/platform_data/qcom_crypto_device.h>
103#include "rpm_resources.h"
Matt Wagantall33d01f52012-02-23 23:27:44 -0800104#include "clock.h"
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -0600105#include "pm-boot.h"
Subhash Jadavanibcd435f2012-04-24 18:26:49 +0530106#include "board-storage-common-a.h"
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -0800107#include "platsmp.h"
Laura Abbott63cfd7e2011-10-10 18:21:01 -0700108
Mitchel Humpherysc7b4fff2012-09-06 11:35:07 -0700109#include <linux/msm_ion.h>
Laura Abbott63cfd7e2011-10-10 18:21:01 -0700110#include <mach/ion.h>
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +0530111#include <mach/msm_rtb.h>
Laura Abbott63cfd7e2011-10-10 18:21:01 -0700112
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700113#define MSM_SHARED_RAM_PHYS 0x40000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700114#define MDM2AP_SYNC 129
115
Terence Hampson1c73fef2011-07-19 17:10:49 -0400116#define GPIO_ETHERNET_RESET_N_DRAGON 30
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700117#define LCDC_SPI_GPIO_CLK 73
118#define LCDC_SPI_GPIO_CS 72
119#define LCDC_SPI_GPIO_MOSI 70
120#define LCDC_AUO_PANEL_NAME "lcdc_auo_wvga"
121#define LCDC_SAMSUNG_OLED_PANEL_NAME "lcdc_samsung_oled"
122#define LCDC_SAMSUNG_WSVGA_PANEL_NAME "lcdc_samsung_wsvga"
123#define LCDC_SAMSUNG_SPI_DEVICE_NAME "lcdc_samsung_ams367pe02"
124#define LCDC_AUO_SPI_DEVICE_NAME "lcdc_auo_nt35582"
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -0400125#define LCDC_NT35582_PANEL_NAME "lcdc_nt35582_wvga"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700126
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -0700127#define MIPI_CMD_NOVATEK_QHD_PANEL_NAME "mipi_cmd_novatek_qhd"
128#define MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME "mipi_video_novatek_qhd"
129#define MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME "mipi_video_toshiba_wvga"
130#define HDMI_PANEL_NAME "hdmi_msm"
131#define TVOUT_PANEL_NAME "tvout_msm"
132
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700133#define DSPS_PIL_GENERIC_NAME "dsps"
134#define DSPS_PIL_FLUID_NAME "dsps_fluid"
135
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -0800136#ifdef CONFIG_ION_MSM
137static struct platform_device ion_dev;
138#endif
139
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700140enum {
141 GPIO_EXPANDER_IRQ_BASE = PM8901_IRQ_BASE + NR_PMIC8901_IRQS,
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530142 GPIO_EXPANDER_GPIO_BASE = PM8901_MPP_BASE + PM8901_MPPS,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700143 /* CORE expander */
144 GPIO_CORE_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE,
145 GPIO_CLASS_D1_EN = GPIO_CORE_EXPANDER_BASE,
146 GPIO_WLAN_DEEP_SLEEP_N,
147 GPIO_LVDS_SHUTDOWN_N,
148 GPIO_DISP_RESX_N = GPIO_LVDS_SHUTDOWN_N,
149 GPIO_MS_SYS_RESET_N,
150 GPIO_CAP_TS_RESOUT_N,
151 GPIO_CAP_GAUGE_BI_TOUT,
152 GPIO_ETHERNET_PME,
153 GPIO_EXT_GPS_LNA_EN,
154 GPIO_MSM_WAKES_BT,
155 GPIO_ETHERNET_RESET_N,
156 GPIO_HEADSET_DET_N,
157 GPIO_USB_UICC_EN,
158 GPIO_BACKLIGHT_EN,
159 GPIO_EXT_CAMIF_PWR_EN,
160 GPIO_BATT_GAUGE_INT_N,
161 GPIO_BATT_GAUGE_EN,
162 /* DOCKING expander */
163 GPIO_DOCKING_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + 16,
164 GPIO_MIPI_DSI_RST_N = GPIO_DOCKING_EXPANDER_BASE,
165 GPIO_AUX_JTAG_DET_N,
166 GPIO_DONGLE_DET_N,
167 GPIO_SVIDEO_LOAD_DET,
168 GPIO_SVID_AMP_SHUTDOWN1_N,
169 GPIO_SVID_AMP_SHUTDOWN0_N,
170 GPIO_SDC_WP,
171 GPIO_IRDA_PWDN,
172 GPIO_IRDA_RESET_N,
173 GPIO_DONGLE_GPIO0,
174 GPIO_DONGLE_GPIO1,
175 GPIO_DONGLE_GPIO2,
176 GPIO_DONGLE_GPIO3,
177 GPIO_DONGLE_PWR_EN,
178 GPIO_EMMC_RESET_N,
179 GPIO_TP_EXP2_IO15,
180 /* SURF expander */
181 GPIO_SURF_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + (16 * 2),
182 GPIO_SD_CARD_DET_1 = GPIO_SURF_EXPANDER_BASE,
183 GPIO_SD_CARD_DET_2,
184 GPIO_SD_CARD_DET_4,
185 GPIO_SD_CARD_DET_5,
186 GPIO_UIM3_RST,
187 GPIO_SURF_EXPANDER_IO5,
188 GPIO_SURF_EXPANDER_IO6,
189 GPIO_ADC_I2C_EN,
190 GPIO_SURF_EXPANDER_IO8,
191 GPIO_SURF_EXPANDER_IO9,
192 GPIO_SURF_EXPANDER_IO10,
193 GPIO_SURF_EXPANDER_IO11,
194 GPIO_SURF_EXPANDER_IO12,
195 GPIO_SURF_EXPANDER_IO13,
196 GPIO_SURF_EXPANDER_IO14,
197 GPIO_SURF_EXPANDER_IO15,
198 /* LEFT KB IO expander */
199 GPIO_LEFT_KB_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + (16 * 3),
200 GPIO_LEFT_LED_1 = GPIO_LEFT_KB_EXPANDER_BASE,
201 GPIO_LEFT_LED_2,
202 GPIO_LEFT_LED_3,
203 GPIO_LEFT_LED_WLAN,
204 GPIO_JOYSTICK_EN,
205 GPIO_CAP_TS_SLEEP,
206 GPIO_LEFT_KB_IO6,
207 GPIO_LEFT_LED_5,
208 /* RIGHT KB IO expander */
209 GPIO_RIGHT_KB_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE + (16 * 3) + 8,
210 GPIO_RIGHT_LED_1 = GPIO_RIGHT_KB_EXPANDER_BASE,
211 GPIO_RIGHT_LED_2,
212 GPIO_RIGHT_LED_3,
213 GPIO_RIGHT_LED_BT,
214 GPIO_WEB_CAMIF_STANDBY,
215 GPIO_COMPASS_RST_N,
216 GPIO_WEB_CAMIF_RESET_N,
217 GPIO_RIGHT_LED_5,
218 GPIO_R_ALTIMETER_RESET_N,
219 /* FLUID S IO expander */
220 GPIO_SOUTH_EXPANDER_BASE,
221 GPIO_MIC2_ANCR_SEL = GPIO_SOUTH_EXPANDER_BASE,
222 GPIO_MIC1_ANCL_SEL,
223 GPIO_HS_MIC4_SEL,
224 GPIO_FML_MIC3_SEL,
225 GPIO_FMR_MIC5_SEL,
226 GPIO_TS_SLEEP,
227 GPIO_HAP_SHIFT_LVL_OE,
228 GPIO_HS_SW_DIR,
229 /* FLUID N IO expander */
230 GPIO_NORTH_EXPANDER_BASE,
231 GPIO_EPM_3_3V_EN = GPIO_NORTH_EXPANDER_BASE,
232 GPIO_EPM_5V_BOOST_EN,
233 GPIO_AUX_CAM_2P7_EN,
234 GPIO_LED_FLASH_EN,
235 GPIO_LED1_GREEN_N,
236 GPIO_LED2_RED_N,
237 GPIO_FRONT_CAM_RESET_N,
238 GPIO_EPM_LVLSFT_EN,
239 GPIO_N_ALTIMETER_RESET_N,
240 /* EPM expander */
241 GPIO_EPM_EXPANDER_BASE,
242 GPIO_PWR_MON_START = GPIO_EPM_EXPANDER_BASE,
243 GPIO_PWR_MON_RESET_N,
244 GPIO_ADC1_PWDN_N,
245 GPIO_ADC2_PWDN_N,
246 GPIO_EPM_EXPANDER_IO4,
247 GPIO_ADC1_MUX_SPI_INT_N_3_3V,
248 GPIO_ADC2_MUX_SPI_INT_N,
249 GPIO_EPM_EXPANDER_IO7,
250 GPIO_PWR_MON_ENABLE,
251 GPIO_EPM_SPI_ADC1_CS_N,
252 GPIO_EPM_SPI_ADC2_CS_N,
253 GPIO_EPM_EXPANDER_IO11,
254 GPIO_EPM_EXPANDER_IO12,
255 GPIO_EPM_EXPANDER_IO13,
256 GPIO_EPM_EXPANDER_IO14,
257 GPIO_EPM_EXPANDER_IO15,
258};
259
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530260struct pm8xxx_mpp_init_info {
261 unsigned mpp;
262 struct pm8xxx_mpp_config_data config;
263};
264
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530265#define PM8058_MPP_INIT(_mpp, _type, _level, _control) \
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530266{ \
267 .mpp = PM8058_MPP_PM_TO_SYS(_mpp), \
268 .config = { \
269 .type = PM8XXX_MPP_TYPE_##_type, \
270 .level = _level, \
271 .control = PM8XXX_MPP_##_control, \
272 } \
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100273}
274
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530275#define PM8901_MPP_INIT(_mpp, _type, _level, _control) \
276{ \
277 .mpp = PM8901_MPP_PM_TO_SYS(_mpp), \
278 .config = { \
279 .type = PM8XXX_MPP_TYPE_##_type, \
280 .level = _level, \
281 .control = PM8XXX_MPP_##_control, \
282 } \
283}
284
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700285/*
286 * The UI_INTx_N lines are pmic gpio lines which connect i2c
287 * gpio expanders to the pm8058.
288 */
289#define UI_INT1_N 25
290#define UI_INT2_N 34
291#define UI_INT3_N 14
292/*
293FM GPIO is GPIO 18 on PMIC 8058.
294As the index starts from 0 in the PMIC driver, and hence 17
295corresponds to GPIO 18 on PMIC 8058.
296*/
297#define FM_GPIO 17
298
299#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
300static void (*sdc2_status_notify_cb)(int card_present, void *dev_id);
301static void *sdc2_status_notify_cb_devid;
302#endif
303
304#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
305static void (*sdc5_status_notify_cb)(int card_present, void *dev_id);
306static void *sdc5_status_notify_cb_devid;
307#endif
308
309static struct msm_spm_platform_data msm_spm_data_v1[] __initdata = {
310 [0] = {
311 .reg_base_addr = MSM_SAW0_BASE,
312
313#ifdef CONFIG_MSM_AVS_HW
314 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
315#endif
316 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x0F,
317 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
318 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0xFFFFFFFF,
319 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFFFFFFFF,
320
321 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
322 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
323 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
324
325 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
326 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
327 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
328
329 .awake_vlevel = 0x94,
330 .retention_vlevel = 0x81,
331 .collapse_vlevel = 0x20,
332 .retention_mid_vlevel = 0x94,
333 .collapse_mid_vlevel = 0x8C,
334
335 .vctl_timeout_us = 50,
336 },
337
338 [1] = {
339 .reg_base_addr = MSM_SAW1_BASE,
340
341#ifdef CONFIG_MSM_AVS_HW
342 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
343#endif
344 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x0F,
345 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
346 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0xFFFFFFFF,
347 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFFFFFFFF,
348
349 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x13,
350 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
351 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
352
353 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
354 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
355 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
356
357 .awake_vlevel = 0x94,
358 .retention_vlevel = 0x81,
359 .collapse_vlevel = 0x20,
360 .retention_mid_vlevel = 0x94,
361 .collapse_mid_vlevel = 0x8C,
362
363 .vctl_timeout_us = 50,
364 },
365};
366
367static struct msm_spm_platform_data msm_spm_data[] __initdata = {
368 [0] = {
369 .reg_base_addr = MSM_SAW0_BASE,
370
371#ifdef CONFIG_MSM_AVS_HW
372 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
373#endif
374 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x1C,
375 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
376 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x0C0CFFFF,
377 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0x78780FFF,
378
379 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
380 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
381 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
382
383 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
384 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
385 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
386
387 .awake_vlevel = 0xA0,
388 .retention_vlevel = 0x89,
389 .collapse_vlevel = 0x20,
390 .retention_mid_vlevel = 0x89,
391 .collapse_mid_vlevel = 0x89,
392
393 .vctl_timeout_us = 50,
394 },
395
396 [1] = {
397 .reg_base_addr = MSM_SAW1_BASE,
398
399#ifdef CONFIG_MSM_AVS_HW
400 .reg_init_values[MSM_SPM_REG_SAW_AVS_CTL] = 0x586020FF,
401#endif
402 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x1C,
403 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x68,
404 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x0C0CFFFF,
405 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0x78780FFF,
406
407 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x13,
408 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x07,
409 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
410
411 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
412 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
413 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
414
415 .awake_vlevel = 0xA0,
416 .retention_vlevel = 0x89,
417 .collapse_vlevel = 0x20,
418 .retention_mid_vlevel = 0x89,
419 .collapse_mid_vlevel = 0x89,
420
421 .vctl_timeout_us = 50,
422 },
423};
424
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700425/*
426 * Consumer specific regulator names:
427 * regulator name consumer dev_name
428 */
429static struct regulator_consumer_supply vreg_consumers_8901_S0[] = {
430 REGULATOR_SUPPLY("8901_s0", NULL),
431};
432static struct regulator_consumer_supply vreg_consumers_8901_S1[] = {
433 REGULATOR_SUPPLY("8901_s1", NULL),
434};
435
436static struct regulator_init_data saw_s0_init_data = {
437 .constraints = {
438 .name = "8901_s0",
439 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
Tianyi Gou7c81dfa2011-07-27 12:15:24 -0700440 .min_uV = 800000,
Matt Wagantall2ecbec22012-03-13 23:18:07 -0700441 .max_uV = 1325000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700442 },
443 .consumer_supplies = vreg_consumers_8901_S0,
444 .num_consumer_supplies = ARRAY_SIZE(vreg_consumers_8901_S0),
445};
446
447static struct regulator_init_data saw_s1_init_data = {
448 .constraints = {
449 .name = "8901_s1",
450 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
Tianyi Gou7c81dfa2011-07-27 12:15:24 -0700451 .min_uV = 800000,
Matt Wagantall2ecbec22012-03-13 23:18:07 -0700452 .max_uV = 1325000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700453 },
454 .consumer_supplies = vreg_consumers_8901_S1,
455 .num_consumer_supplies = ARRAY_SIZE(vreg_consumers_8901_S1),
456};
457
458static struct platform_device msm_device_saw_s0 = {
459 .name = "saw-regulator",
460 .id = 0,
461 .dev = {
462 .platform_data = &saw_s0_init_data,
463 },
464};
465
466static struct platform_device msm_device_saw_s1 = {
467 .name = "saw-regulator",
468 .id = 1,
469 .dev = {
470 .platform_data = &saw_s1_init_data,
471 },
472};
473
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700474static struct resource smsc911x_resources[] = {
475 [0] = {
476 .flags = IORESOURCE_MEM,
477 .start = 0x1b800000,
478 .end = 0x1b8000ff
479 },
480 [1] = {
481 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
482 },
483};
484
485static struct smsc911x_platform_config smsc911x_config = {
486 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
487 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
488 .flags = SMSC911X_USE_16BIT,
489 .has_reset_gpio = 1,
490 .reset_gpio = GPIO_ETHERNET_RESET_N
491};
492
493static struct platform_device smsc911x_device = {
494 .name = "smsc911x",
495 .id = 0,
496 .num_resources = ARRAY_SIZE(smsc911x_resources),
497 .resource = smsc911x_resources,
498 .dev = {
499 .platform_data = &smsc911x_config
500 }
501};
502
503#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
504 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
505 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
506 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
507
508#define QCE_SIZE 0x10000
509#define QCE_0_BASE 0x18500000
510
511#define QCE_HW_KEY_SUPPORT 0
512#define QCE_SHA_HMAC_SUPPORT 0
513#define QCE_SHARE_CE_RESOURCE 2
514#define QCE_CE_SHARED 1
515
516static struct resource qcrypto_resources[] = {
517 [0] = {
518 .start = QCE_0_BASE,
519 .end = QCE_0_BASE + QCE_SIZE - 1,
520 .flags = IORESOURCE_MEM,
521 },
522 [1] = {
523 .name = "crypto_channels",
524 .start = DMOV_CE_IN_CHAN,
525 .end = DMOV_CE_OUT_CHAN,
526 .flags = IORESOURCE_DMA,
527 },
528 [2] = {
529 .name = "crypto_crci_in",
530 .start = DMOV_CE_IN_CRCI,
531 .end = DMOV_CE_IN_CRCI,
532 .flags = IORESOURCE_DMA,
533 },
534 [3] = {
535 .name = "crypto_crci_out",
536 .start = DMOV_CE_OUT_CRCI,
537 .end = DMOV_CE_OUT_CRCI,
538 .flags = IORESOURCE_DMA,
539 },
540 [4] = {
541 .name = "crypto_crci_hash",
542 .start = DMOV_CE_HASH_CRCI,
543 .end = DMOV_CE_HASH_CRCI,
544 .flags = IORESOURCE_DMA,
545 },
546};
547
548static struct resource qcedev_resources[] = {
549 [0] = {
550 .start = QCE_0_BASE,
551 .end = QCE_0_BASE + QCE_SIZE - 1,
552 .flags = IORESOURCE_MEM,
553 },
554 [1] = {
555 .name = "crypto_channels",
556 .start = DMOV_CE_IN_CHAN,
557 .end = DMOV_CE_OUT_CHAN,
558 .flags = IORESOURCE_DMA,
559 },
560 [2] = {
561 .name = "crypto_crci_in",
562 .start = DMOV_CE_IN_CRCI,
563 .end = DMOV_CE_IN_CRCI,
564 .flags = IORESOURCE_DMA,
565 },
566 [3] = {
567 .name = "crypto_crci_out",
568 .start = DMOV_CE_OUT_CRCI,
569 .end = DMOV_CE_OUT_CRCI,
570 .flags = IORESOURCE_DMA,
571 },
572 [4] = {
573 .name = "crypto_crci_hash",
574 .start = DMOV_CE_HASH_CRCI,
575 .end = DMOV_CE_HASH_CRCI,
576 .flags = IORESOURCE_DMA,
577 },
578};
579
580#endif
581
582#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
583 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
584
585static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
586 .ce_shared = QCE_CE_SHARED,
587 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
588 .hw_key_support = QCE_HW_KEY_SUPPORT,
589 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800590 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700591};
592
593static struct platform_device qcrypto_device = {
594 .name = "qcrypto",
595 .id = 0,
596 .num_resources = ARRAY_SIZE(qcrypto_resources),
597 .resource = qcrypto_resources,
598 .dev = {
599 .coherent_dma_mask = DMA_BIT_MASK(32),
600 .platform_data = &qcrypto_ce_hw_suppport,
601 },
602};
603#endif
604
605#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
606 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
607
608static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
609 .ce_shared = QCE_CE_SHARED,
610 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
611 .hw_key_support = QCE_HW_KEY_SUPPORT,
612 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -0800613 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700614};
615
616static struct platform_device qcedev_device = {
617 .name = "qce",
618 .id = 0,
619 .num_resources = ARRAY_SIZE(qcedev_resources),
620 .resource = qcedev_resources,
621 .dev = {
622 .coherent_dma_mask = DMA_BIT_MASK(32),
623 .platform_data = &qcedev_ce_hw_suppport,
624 },
625};
626#endif
627
628#if defined(CONFIG_HAPTIC_ISA1200) || \
629 defined(CONFIG_HAPTIC_ISA1200_MODULE)
630
631static const char *vregs_isa1200_name[] = {
632 "8058_s3",
633 "8901_l4",
634};
635
636static const int vregs_isa1200_val[] = {
637 1800000,/* uV */
638 2600000,
639};
640static struct regulator *vregs_isa1200[ARRAY_SIZE(vregs_isa1200_name)];
641static struct msm_xo_voter *xo_handle_a1;
642
643static int isa1200_power(int vreg_on)
Steve Mucklea55df6e2010-01-07 12:43:24 -0800644{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700645 int i, rc = 0;
646
647 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++) {
648 rc = vreg_on ? regulator_enable(vregs_isa1200[i]) :
649 regulator_disable(vregs_isa1200[i]);
650 if (rc < 0) {
651 pr_err("%s: vreg %s %s failed (%d)\n",
652 __func__, vregs_isa1200_name[i],
653 vreg_on ? "enable" : "disable", rc);
654 goto vreg_fail;
655 }
656 }
657
658 rc = vreg_on ? msm_xo_mode_vote(xo_handle_a1, MSM_XO_MODE_ON) :
659 msm_xo_mode_vote(xo_handle_a1, MSM_XO_MODE_OFF);
660 if (rc < 0) {
661 pr_err("%s: failed to %svote for TCXO A1 buffer%d\n",
662 __func__, vreg_on ? "" : "de-", rc);
663 goto vreg_fail;
664 }
665 return 0;
666
667vreg_fail:
668 while (i--)
669 !vreg_on ? regulator_enable(vregs_isa1200[i]) :
670 regulator_disable(vregs_isa1200[i]);
671 return rc;
Steve Mucklea55df6e2010-01-07 12:43:24 -0800672}
673
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700674static int isa1200_dev_setup(bool enable)
Steve Mucklea55df6e2010-01-07 12:43:24 -0800675{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700676 int i, rc;
Steve Muckle9161d302010-02-11 11:50:40 -0800677
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700678 if (enable == true) {
679 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++) {
680 vregs_isa1200[i] = regulator_get(NULL,
681 vregs_isa1200_name[i]);
682 if (IS_ERR(vregs_isa1200[i])) {
683 pr_err("%s: regulator get of %s failed (%ld)\n",
684 __func__, vregs_isa1200_name[i],
685 PTR_ERR(vregs_isa1200[i]));
686 rc = PTR_ERR(vregs_isa1200[i]);
687 goto vreg_get_fail;
688 }
689 rc = regulator_set_voltage(vregs_isa1200[i],
690 vregs_isa1200_val[i], vregs_isa1200_val[i]);
691 if (rc) {
692 pr_err("%s: regulator_set_voltage(%s) failed\n",
693 __func__, vregs_isa1200_name[i]);
694 goto vreg_get_fail;
695 }
696 }
Steve Muckle9161d302010-02-11 11:50:40 -0800697
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700698 rc = gpio_request(GPIO_HAP_SHIFT_LVL_OE, "haptics_shft_lvl_oe");
699 if (rc) {
700 pr_err("%s: unable to request gpio %d (%d)\n",
701 __func__, GPIO_HAP_SHIFT_LVL_OE, rc);
702 goto vreg_get_fail;
703 }
Steve Muckle9161d302010-02-11 11:50:40 -0800704
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700705 rc = gpio_direction_output(GPIO_HAP_SHIFT_LVL_OE, 1);
706 if (rc) {
707 pr_err("%s: Unable to set direction\n", __func__);;
708 goto free_gpio;
709 }
710
711 xo_handle_a1 = msm_xo_get(MSM_XO_TCXO_A1, "isa1200");
712 if (IS_ERR(xo_handle_a1)) {
713 rc = PTR_ERR(xo_handle_a1);
714 pr_err("%s: failed to get the handle for A1(%d)\n",
715 __func__, rc);
716 goto gpio_set_dir;
717 }
718 } else {
719 gpio_set_value(GPIO_HAP_SHIFT_LVL_OE, 0);
720 gpio_free(GPIO_HAP_SHIFT_LVL_OE);
721
722 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++)
723 regulator_put(vregs_isa1200[i]);
724
725 msm_xo_put(xo_handle_a1);
726 }
727
728 return 0;
729gpio_set_dir:
730 gpio_set_value(GPIO_HAP_SHIFT_LVL_OE, 0);
731free_gpio:
732 gpio_free(GPIO_HAP_SHIFT_LVL_OE);
733vreg_get_fail:
734 while (i)
735 regulator_put(vregs_isa1200[--i]);
736 return rc;
737}
738
739#define PMIC_GPIO_HAP_ENABLE 18 /* PMIC GPIO Number 19 */
Mohan Pallaka4a1160d2011-09-09 15:17:45 +0530740#define PMIC_GPIO_HAP_LDO_ENABLE 5 /* PMIC GPIO Number 6 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700741static struct isa1200_platform_data isa1200_1_pdata = {
742 .name = "vibrator",
743 .power_on = isa1200_power,
744 .dev_setup = isa1200_dev_setup,
745 /*gpio to enable haptic*/
746 .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
Mohan Pallaka4a1160d2011-09-09 15:17:45 +0530747 .hap_len_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700748 .max_timeout = 15000,
749 .mode_ctrl = PWM_GEN_MODE,
750 .pwm_fd = {
751 .pwm_div = 256,
752 },
753 .is_erm = false,
754 .smart_en = true,
755 .ext_clk_en = true,
756 .chip_en = 1,
757};
758
759static struct i2c_board_info msm_isa1200_board_info[] = {
760 {
761 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
762 .platform_data = &isa1200_1_pdata,
763 },
764};
765#endif
766
767#if defined(CONFIG_BATTERY_BQ27520) || \
768 defined(CONFIG_BATTERY_BQ27520_MODULE)
769static struct bq27520_platform_data bq27520_pdata = {
770 .name = "fuel-gauge",
771 .vreg_name = "8058_s3",
772 .vreg_value = 1800000,
773 .soc_int = GPIO_BATT_GAUGE_INT_N,
774 .bi_tout = GPIO_CAP_GAUGE_BI_TOUT,
775 .chip_en = GPIO_BATT_GAUGE_EN,
776 .enable_dlog = 0, /* if enable coulomb counter logger */
777};
778
779static struct i2c_board_info msm_bq27520_board_info[] = {
780 {
781 I2C_BOARD_INFO("bq27520", 0xaa>>1),
782 .platform_data = &bq27520_pdata,
783 },
784};
785#endif
786
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700787static struct msm_rpmrs_level msm_rpmrs_levels[] __initdata = {
788 {
789 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
790 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
791 true,
792 1, 8000, 100000, 1,
793 },
794
795 {
796 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
797 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
798 true,
799 1500, 5000, 60100000, 3000,
800 },
801
802 {
803 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
804 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
805 false,
806 1800, 5000, 60350000, 3500,
807 },
808 {
809 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
810 MSM_RPMRS_LIMITS(OFF, ACTIVE, MAX, ACTIVE),
811 false,
812 3800, 4500, 65350000, 5500,
813 },
814
815 {
816 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
817 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, MAX, ACTIVE),
818 false,
819 2800, 2500, 66850000, 4800,
820 },
821
822 {
823 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
824 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
825 false,
826 4800, 2000, 71850000, 6800,
827 },
828
829 {
830 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
831 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
832 false,
833 6800, 500, 75850000, 8800,
834 },
835
836 {
837 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
838 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
839 false,
840 7800, 0, 76350000, 9800,
841 },
842};
843
Praveen Chidambaram78499012011-11-01 17:15:17 -0600844static struct msm_rpmrs_platform_data msm_rpmrs_data __initdata = {
845 .levels = &msm_rpmrs_levels[0],
846 .num_levels = ARRAY_SIZE(msm_rpmrs_levels),
847 .vdd_mem_levels = {
848 [MSM_RPMRS_VDD_MEM_RET_LOW] = 500,
849 [MSM_RPMRS_VDD_MEM_RET_HIGH] = 750,
850 [MSM_RPMRS_VDD_MEM_ACTIVE] = 1000,
Matt Wagantall2ecbec22012-03-13 23:18:07 -0700851 [MSM_RPMRS_VDD_MEM_MAX] = 1325,
Praveen Chidambaram78499012011-11-01 17:15:17 -0600852 },
853 .vdd_dig_levels = {
854 [MSM_RPMRS_VDD_DIG_RET_LOW] = 500,
855 [MSM_RPMRS_VDD_DIG_RET_HIGH] = 750,
856 [MSM_RPMRS_VDD_DIG_ACTIVE] = 1000,
857 [MSM_RPMRS_VDD_DIG_MAX] = 1250,
858 },
859 .vdd_mask = 0xFFF,
860 .rpmrs_target_id = {
861 [MSM_RPMRS_ID_PXO_CLK] = MSM_RPM_ID_PXO_CLK,
862 [MSM_RPMRS_ID_L2_CACHE_CTL] = MSM_RPM_ID_APPS_L2_CACHE_CTL,
863 [MSM_RPMRS_ID_VDD_DIG_0] = MSM_RPM_ID_SMPS1_0,
864 [MSM_RPMRS_ID_VDD_DIG_1] = MSM_RPM_ID_SMPS1_1,
865 [MSM_RPMRS_ID_VDD_MEM_0] = MSM_RPM_ID_SMPS0_0,
866 [MSM_RPMRS_ID_VDD_MEM_1] = MSM_RPM_ID_SMPS0_1,
867 [MSM_RPMRS_ID_RPM_CTL] = MSM_RPM_ID_TRIGGER_SET_FROM,
868 },
869};
870
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600871static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
872 .mode = MSM_PM_BOOT_CONFIG_TZ,
873};
874
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700875#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
876
877#define ISP1763_INT_GPIO 117
878#define ISP1763_RST_GPIO 152
879static struct resource isp1763_resources[] = {
880 [0] = {
881 .flags = IORESOURCE_MEM,
882 .start = 0x1D000000,
883 .end = 0x1D005FFF, /* 24KB */
884 },
885 [1] = {
886 .flags = IORESOURCE_IRQ,
887 },
888};
889static void __init msm8x60_cfg_isp1763(void)
890{
891 isp1763_resources[1].start = gpio_to_irq(ISP1763_INT_GPIO);
892 isp1763_resources[1].end = gpio_to_irq(ISP1763_INT_GPIO);
893}
894
895static int isp1763_setup_gpio(int enable)
896{
897 int status = 0;
898
899 if (enable) {
900 status = gpio_request(ISP1763_INT_GPIO, "isp1763_usb");
901 if (status) {
902 pr_err("%s:Failed to request GPIO %d\n",
903 __func__, ISP1763_INT_GPIO);
904 return status;
905 }
906 status = gpio_direction_input(ISP1763_INT_GPIO);
907 if (status) {
908 pr_err("%s:Failed to configure GPIO %d\n",
909 __func__, ISP1763_INT_GPIO);
910 goto gpio_free_int;
911 }
912 status = gpio_request(ISP1763_RST_GPIO, "isp1763_usb");
913 if (status) {
914 pr_err("%s:Failed to request GPIO %d\n",
915 __func__, ISP1763_RST_GPIO);
916 goto gpio_free_int;
917 }
918 status = gpio_direction_output(ISP1763_RST_GPIO, 1);
919 if (status) {
920 pr_err("%s:Failed to configure GPIO %d\n",
921 __func__, ISP1763_RST_GPIO);
922 goto gpio_free_rst;
923 }
924 pr_debug("\nISP GPIO configuration done\n");
925 return status;
926 }
927
928gpio_free_rst:
929 gpio_free(ISP1763_RST_GPIO);
930gpio_free_int:
931 gpio_free(ISP1763_INT_GPIO);
932
933 return status;
934}
935static struct isp1763_platform_data isp1763_pdata = {
936 .reset_gpio = ISP1763_RST_GPIO,
937 .setup_gpio = isp1763_setup_gpio
938};
939
940static struct platform_device isp1763_device = {
941 .name = "isp1763_usb",
942 .num_resources = ARRAY_SIZE(isp1763_resources),
943 .resource = isp1763_resources,
944 .dev = {
945 .platform_data = &isp1763_pdata
946 }
947};
948#endif
949
Lena Salman57d167e2012-03-21 19:46:38 +0200950#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_MSM_72K)
Anji jonnalaeb9e60d2011-10-05 12:19:46 +0530951static struct msm_otg_platform_data msm_otg_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700952static struct regulator *ldo6_3p3;
953static struct regulator *ldo7_1p8;
954static struct regulator *vdd_cx;
955#define PMICID_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 36)
Anji jonnalaae745e92011-11-14 18:34:31 +0530956#define PMIC_ID_GPIO 36
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700957notify_vbus_state notify_vbus_state_func_ptr;
958static int usb_phy_susp_dig_vol = 750000;
959static int pmic_id_notif_supported;
960
961#ifdef CONFIG_USB_EHCI_MSM_72K
962#define USB_PMIC_ID_DET_DELAY msecs_to_jiffies(100)
963struct delayed_work pmic_id_det;
964
965static int __init usb_id_pin_rework_setup(char *support)
966{
967 if (strncmp(support, "true", 4) == 0)
968 pmic_id_notif_supported = 1;
969
970 return 1;
971}
972__setup("usb_id_pin_rework=", usb_id_pin_rework_setup);
973
974static void pmic_id_detect(struct work_struct *w)
975{
976 int val = gpio_get_value_cansleep(PM8058_GPIO_PM_TO_SYS(36));
977 pr_debug("%s(): gpio_read_value = %d\n", __func__, val);
978
979 if (notify_vbus_state_func_ptr)
980 (*notify_vbus_state_func_ptr) (val);
981}
982
983static irqreturn_t pmic_id_on_irq(int irq, void *data)
984{
985 /*
986 * Spurious interrupts are observed on pmic gpio line
987 * even though there is no state change on USB ID. Schedule the
988 * work to to allow debounce on gpio
Steve Muckle9161d302010-02-11 11:50:40 -0800989 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700990 schedule_delayed_work(&pmic_id_det, USB_PMIC_ID_DET_DELAY);
Steve Muckle9161d302010-02-11 11:50:40 -0800991
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700992 return IRQ_HANDLED;
993}
994
Anji jonnalaae745e92011-11-14 18:34:31 +0530995static int msm_hsusb_phy_id_setup_init(int init)
996{
997 unsigned ret;
998
Anirudh Ghayal9f77e962011-12-06 12:38:21 +0530999 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
1000 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
1001 .level = PM8901_MPP_DIG_LEVEL_L5,
1002 };
1003
Anji jonnalaae745e92011-11-14 18:34:31 +05301004 if (init) {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301005 hsusb_phy_mpp.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
1006 ret = pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1),
1007 &hsusb_phy_mpp);
Anji jonnalaae745e92011-11-14 18:34:31 +05301008 if (ret < 0)
1009 pr_err("%s:MPP2 configuration failed\n", __func__);
1010 } else {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05301011 hsusb_phy_mpp.control = PM8XXX_MPP_DOUT_CTRL_LOW;
1012 ret = pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1),
1013 &hsusb_phy_mpp);
Anji jonnalaae745e92011-11-14 18:34:31 +05301014 if (ret < 0)
1015 pr_err("%s:MPP2 un config failed\n", __func__);
1016 }
1017 return ret;
1018}
1019
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001020static int msm_hsusb_pmic_id_notif_init(void (*callback)(int online), int init)
1021{
1022 unsigned ret = -ENODEV;
1023
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301024 struct pm_gpio pmic_id_cfg = {
Anji jonnalaae745e92011-11-14 18:34:31 +05301025 .direction = PM_GPIO_DIR_IN,
1026 .pull = PM_GPIO_PULL_UP_1P5,
1027 .function = PM_GPIO_FUNC_NORMAL,
1028 .vin_sel = 2,
1029 .inv_int_pol = 0,
1030 };
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301031 struct pm_gpio pmic_id_uncfg = {
Anji jonnalaae745e92011-11-14 18:34:31 +05301032 .direction = PM_GPIO_DIR_IN,
1033 .pull = PM_GPIO_PULL_NO,
1034 .function = PM_GPIO_FUNC_NORMAL,
1035 .vin_sel = 2,
1036 .inv_int_pol = 0,
1037 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001038 if (!callback)
1039 return -EINVAL;
1040
1041 if (machine_is_msm8x60_fluid())
1042 return -ENOTSUPP;
1043
1044 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 2) {
1045 pr_debug("%s: USB_ID pin is not routed to PMIC"
1046 "on V1 surf/ffa\n", __func__);
1047 return -ENOTSUPP;
1048 }
1049
Manu Gautam62158eb2011-11-24 16:20:46 +05301050 if ((machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa() ||
1051 machine_is_msm8x60_ffa()) && !pmic_id_notif_supported) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001052 pr_debug("%s: USB_ID is not routed to PMIC"
1053 "on V2 ffa\n", __func__);
1054 return -ENOTSUPP;
1055 }
1056
1057 usb_phy_susp_dig_vol = 500000;
1058
1059 if (init) {
1060 notify_vbus_state_func_ptr = callback;
Manu Gautame8420ef2011-11-11 15:37:21 +05301061 INIT_DELAYED_WORK(&pmic_id_det, pmic_id_detect);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301062 ret = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(PMIC_ID_GPIO),
1063 &pmic_id_cfg);
Anji jonnalaae745e92011-11-14 18:34:31 +05301064 if (ret) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301065 pr_err("%s:return val of pm8xxx_gpio_config: %d\n",
Anji jonnalaae745e92011-11-14 18:34:31 +05301066 __func__, ret);
1067 return ret;
1068 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001069 ret = request_threaded_irq(PMICID_INT, NULL, pmic_id_on_irq,
1070 (IRQF_TRIGGER_RISING|IRQF_TRIGGER_FALLING),
1071 "msm_otg_id", NULL);
1072 if (ret) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001073 pr_err("%s:pmic_usb_id interrupt registration failed",
1074 __func__);
1075 return ret;
1076 }
Anji jonnalaeb9e60d2011-10-05 12:19:46 +05301077 msm_otg_pdata.pmic_id_irq = PMICID_INT;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001078 } else {
Anji jonnalaae745e92011-11-14 18:34:31 +05301079 usb_phy_susp_dig_vol = 750000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001080 free_irq(PMICID_INT, 0);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301081 ret = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(PMIC_ID_GPIO),
1082 &pmic_id_uncfg);
Anji jonnalaae745e92011-11-14 18:34:31 +05301083 if (ret) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301084 pr_err("%s: return val of pm8xxx_gpio_config: %d\n",
Anji jonnalaae745e92011-11-14 18:34:31 +05301085 __func__, ret);
1086 return ret;
1087 }
Anji jonnalaeb9e60d2011-10-05 12:19:46 +05301088 msm_otg_pdata.pmic_id_irq = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001089 cancel_delayed_work_sync(&pmic_id_det);
1090 notify_vbus_state_func_ptr = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001091 }
1092 return 0;
1093}
1094#endif
1095
1096#define USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL 1000000
1097#define USB_PHY_MAX_VDD_DIG_VOL 1320000
1098static int msm_hsusb_init_vddcx(int init)
1099{
1100 int ret = 0;
1101
1102 if (init) {
1103 vdd_cx = regulator_get(NULL, "8058_s1");
1104 if (IS_ERR(vdd_cx)) {
1105 return PTR_ERR(vdd_cx);
1106 }
1107
1108 ret = regulator_set_voltage(vdd_cx,
1109 USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL,
1110 USB_PHY_MAX_VDD_DIG_VOL);
1111 if (ret) {
1112 pr_err("%s: unable to set the voltage for regulator"
1113 "vdd_cx\n", __func__);
1114 regulator_put(vdd_cx);
1115 return ret;
1116 }
1117
1118 ret = regulator_enable(vdd_cx);
1119 if (ret) {
1120 pr_err("%s: unable to enable regulator"
1121 "vdd_cx\n", __func__);
1122 regulator_put(vdd_cx);
1123 }
1124 } else {
1125 ret = regulator_disable(vdd_cx);
1126 if (ret) {
1127 pr_err("%s: Unable to disable the regulator:"
1128 "vdd_cx\n", __func__);
1129 return ret;
1130 }
1131
1132 regulator_put(vdd_cx);
1133 }
1134
1135 return ret;
1136}
1137
1138static int msm_hsusb_config_vddcx(int high)
1139{
1140 int max_vol = USB_PHY_MAX_VDD_DIG_VOL;
1141 int min_vol;
1142 int ret;
1143
1144 if (high)
1145 min_vol = USB_PHY_OPERATIONAL_MIN_VDD_DIG_VOL;
1146 else
1147 min_vol = usb_phy_susp_dig_vol;
1148
1149 ret = regulator_set_voltage(vdd_cx, min_vol, max_vol);
1150 if (ret) {
1151 pr_err("%s: unable to set the voltage for regulator"
1152 "vdd_cx\n", __func__);
1153 return ret;
1154 }
1155
1156 pr_debug("%s: min_vol:%d max_vol:%d\n", __func__, min_vol, max_vol);
1157
1158 return ret;
1159}
1160
1161#define USB_PHY_3P3_VOL_MIN 3050000 /* uV */
1162#define USB_PHY_3P3_VOL_MAX 3050000 /* uV */
1163#define USB_PHY_3P3_HPM_LOAD 50000 /* uA */
1164#define USB_PHY_3P3_LPM_LOAD 4000 /* uA */
1165
1166#define USB_PHY_1P8_VOL_MIN 1800000 /* uV */
1167#define USB_PHY_1P8_VOL_MAX 1800000 /* uV */
1168#define USB_PHY_1P8_HPM_LOAD 50000 /* uA */
1169#define USB_PHY_1P8_LPM_LOAD 4000 /* uA */
1170static int msm_hsusb_ldo_init(int init)
1171{
1172 int rc = 0;
1173
1174 if (init) {
1175 ldo6_3p3 = regulator_get(NULL, "8058_l6");
1176 if (IS_ERR(ldo6_3p3))
1177 return PTR_ERR(ldo6_3p3);
1178
1179 ldo7_1p8 = regulator_get(NULL, "8058_l7");
1180 if (IS_ERR(ldo7_1p8)) {
1181 rc = PTR_ERR(ldo7_1p8);
1182 goto put_3p3;
1183 }
1184
1185 rc = regulator_set_voltage(ldo6_3p3, USB_PHY_3P3_VOL_MIN,
1186 USB_PHY_3P3_VOL_MAX);
1187 if (rc) {
1188 pr_err("%s: Unable to set voltage level for"
1189 "ldo6_3p3 regulator\n", __func__);
1190 goto put_1p8;
1191 }
1192 rc = regulator_enable(ldo6_3p3);
1193 if (rc) {
1194 pr_err("%s: Unable to enable the regulator:"
1195 "ldo6_3p3\n", __func__);
1196 goto put_1p8;
1197 }
1198 rc = regulator_set_voltage(ldo7_1p8, USB_PHY_1P8_VOL_MIN,
1199 USB_PHY_1P8_VOL_MAX);
1200 if (rc) {
1201 pr_err("%s: Unable to set voltage level for"
1202 "ldo7_1p8 regulator\n", __func__);
1203 goto disable_3p3;
1204 }
1205 rc = regulator_enable(ldo7_1p8);
1206 if (rc) {
1207 pr_err("%s: Unable to enable the regulator:"
1208 "ldo7_1p8\n", __func__);
1209 goto disable_3p3;
1210 }
1211
1212 return 0;
1213 }
1214
1215 regulator_disable(ldo7_1p8);
1216disable_3p3:
1217 regulator_disable(ldo6_3p3);
1218put_1p8:
1219 regulator_put(ldo7_1p8);
1220put_3p3:
1221 regulator_put(ldo6_3p3);
1222 return rc;
1223}
1224
1225static int msm_hsusb_ldo_enable(int on)
1226{
1227 int ret = 0;
1228
1229 if (!ldo7_1p8 || IS_ERR(ldo7_1p8)) {
1230 pr_err("%s: ldo7_1p8 is not initialized\n", __func__);
1231 return -ENODEV;
1232 }
1233
1234 if (!ldo6_3p3 || IS_ERR(ldo6_3p3)) {
1235 pr_err("%s: ldo6_3p3 is not initialized\n", __func__);
1236 return -ENODEV;
1237 }
1238
1239 if (on) {
1240 ret = regulator_set_optimum_mode(ldo7_1p8,
1241 USB_PHY_1P8_HPM_LOAD);
1242 if (ret < 0) {
1243 pr_err("%s: Unable to set HPM of the regulator:"
1244 "ldo7_1p8\n", __func__);
1245 return ret;
1246 }
1247 ret = regulator_set_optimum_mode(ldo6_3p3,
1248 USB_PHY_3P3_HPM_LOAD);
1249 if (ret < 0) {
1250 pr_err("%s: Unable to set HPM of the regulator:"
1251 "ldo6_3p3\n", __func__);
1252 regulator_set_optimum_mode(ldo7_1p8,
1253 USB_PHY_1P8_LPM_LOAD);
1254 return ret;
1255 }
1256 } else {
1257 ret = regulator_set_optimum_mode(ldo7_1p8,
1258 USB_PHY_1P8_LPM_LOAD);
1259 if (ret < 0)
1260 pr_err("%s: Unable to set LPM of the regulator:"
1261 "ldo7_1p8\n", __func__);
1262 ret = regulator_set_optimum_mode(ldo6_3p3,
1263 USB_PHY_3P3_LPM_LOAD);
1264 if (ret < 0)
1265 pr_err("%s: Unable to set LPM of the regulator:"
1266 "ldo6_3p3\n", __func__);
1267 }
1268
1269 pr_debug("reg (%s)\n", on ? "HPM" : "LPM");
1270 return ret < 0 ? ret : 0;
1271 }
1272#endif
1273#ifdef CONFIG_USB_EHCI_MSM_72K
1274#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
1275static void msm_hsusb_smb137b_vbus_power(unsigned phy_info, int on)
1276{
1277 static int vbus_is_on;
1278
1279 /* If VBUS is already on (or off), do nothing. */
1280 if (on == vbus_is_on)
1281 return;
1282 smb137b_otg_power(on);
1283 vbus_is_on = on;
1284}
1285#endif
1286static void msm_hsusb_vbus_power(unsigned phy_info, int on)
1287{
1288 static struct regulator *votg_5v_switch;
1289 static struct regulator *ext_5v_reg;
1290 static int vbus_is_on;
1291
1292 /* If VBUS is already on (or off), do nothing. */
1293 if (on == vbus_is_on)
1294 return;
1295
1296 if (!votg_5v_switch) {
1297 votg_5v_switch = regulator_get(NULL, "8901_usb_otg");
1298 if (IS_ERR(votg_5v_switch)) {
1299 pr_err("%s: unable to get votg_5v_switch\n", __func__);
1300 return;
1301 }
1302 }
1303 if (!ext_5v_reg) {
1304 ext_5v_reg = regulator_get(NULL, "8901_mpp0");
1305 if (IS_ERR(ext_5v_reg)) {
1306 pr_err("%s: unable to get ext_5v_reg\n", __func__);
1307 return;
1308 }
1309 }
1310 if (on) {
1311 if (regulator_enable(ext_5v_reg)) {
1312 pr_err("%s: Unable to enable the regulator:"
1313 " ext_5v_reg\n", __func__);
1314 return;
1315 }
1316 if (regulator_enable(votg_5v_switch)) {
1317 pr_err("%s: Unable to enable the regulator:"
1318 " votg_5v_switch\n", __func__);
1319 return;
1320 }
1321 } else {
1322 if (regulator_disable(votg_5v_switch))
1323 pr_err("%s: Unable to enable the regulator:"
1324 " votg_5v_switch\n", __func__);
1325 if (regulator_disable(ext_5v_reg))
1326 pr_err("%s: Unable to enable the regulator:"
1327 " ext_5v_reg\n", __func__);
1328 }
1329
1330 vbus_is_on = on;
1331}
1332
1333static struct msm_usb_host_platform_data msm_usb_host_pdata = {
1334 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
1335 .power_budget = 390,
1336};
1337#endif
1338
1339#ifdef CONFIG_BATTERY_MSM8X60
1340static int msm_hsusb_pmic_vbus_notif_init(void (*callback)(int online),
1341 int init)
1342{
1343 int ret = -ENOTSUPP;
1344
1345#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
1346 if (machine_is_msm8x60_fluid()) {
1347 if (init)
1348 msm_charger_register_vbus_sn(callback);
1349 else
1350 msm_charger_unregister_vbus_sn(callback);
1351 return 0;
1352 }
1353#endif
1354 /* ID and VBUS lines are connected to pmic on 8660.V2.SURF,
1355 * hence, irrespective of either peripheral only mode or
1356 * OTG (host and peripheral) modes, can depend on pmic for
1357 * vbus notifications
Steve Muckle9161d302010-02-11 11:50:40 -08001358 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001359 if ((SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2)
1360 && (machine_is_msm8x60_surf() ||
1361 pmic_id_notif_supported)) {
1362 if (init)
1363 ret = msm_charger_register_vbus_sn(callback);
1364 else {
1365 msm_charger_unregister_vbus_sn(callback);
1366 ret = 0;
1367 }
1368 } else {
1369#if !defined(CONFIG_USB_EHCI_MSM_72K)
1370 if (init)
1371 ret = msm_charger_register_vbus_sn(callback);
1372 else {
1373 msm_charger_unregister_vbus_sn(callback);
1374 ret = 0;
1375 }
1376#endif
1377 }
1378 return ret;
1379}
1380#endif
1381
Lena Salman57d167e2012-03-21 19:46:38 +02001382#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_MSM_72K)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001383static struct msm_otg_platform_data msm_otg_pdata = {
1384 /* if usb link is in sps there is no need for
1385 * usb pclk as dayatona fabric clock will be
1386 * used instead
1387 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001388 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
1389 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
1390 .se1_gating = SE1_GATING_DISABLE,
Chandra Devireddyb3fc78c2011-08-30 17:25:55 +05301391 .bam_disable = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001392#ifdef CONFIG_USB_EHCI_MSM_72K
1393 .pmic_id_notif_init = msm_hsusb_pmic_id_notif_init,
Anji jonnalaae745e92011-11-14 18:34:31 +05301394 .phy_id_setup_init = msm_hsusb_phy_id_setup_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001395#endif
1396#ifdef CONFIG_USB_EHCI_MSM_72K
1397 .vbus_power = msm_hsusb_vbus_power,
1398#endif
1399#ifdef CONFIG_BATTERY_MSM8X60
1400 .pmic_vbus_notif_init = msm_hsusb_pmic_vbus_notif_init,
1401#endif
1402 .ldo_init = msm_hsusb_ldo_init,
1403 .ldo_enable = msm_hsusb_ldo_enable,
1404 .config_vddcx = msm_hsusb_config_vddcx,
1405 .init_vddcx = msm_hsusb_init_vddcx,
1406#ifdef CONFIG_BATTERY_MSM8X60
1407 .chg_vbus_draw = msm_charger_vbus_draw,
1408#endif
1409};
1410#endif
1411
Lena Salman57d167e2012-03-21 19:46:38 +02001412#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001413static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
1414 .is_phy_status_timer_on = 1,
1415};
1416#endif
1417
1418#ifdef CONFIG_USB_G_ANDROID
1419
1420#define PID_MAGIC_ID 0x71432909
1421#define SERIAL_NUM_MAGIC_ID 0x61945374
1422#define SERIAL_NUMBER_LENGTH 127
1423#define DLOAD_USB_BASE_ADD 0x2A05F0C8
1424
1425struct magic_num_struct {
1426 uint32_t pid;
1427 uint32_t serial_num;
1428};
1429
1430struct dload_struct {
1431 uint32_t reserved1;
1432 uint32_t reserved2;
1433 uint32_t reserved3;
1434 uint16_t reserved4;
1435 uint16_t pid;
1436 char serial_number[SERIAL_NUMBER_LENGTH];
1437 uint16_t reserved5;
1438 struct magic_num_struct
1439 magic_struct;
1440};
1441
1442static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
1443{
1444 struct dload_struct __iomem *dload = 0;
1445
1446 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
1447 if (!dload) {
1448 pr_err("%s: cannot remap I/O memory region: %08x\n",
1449 __func__, DLOAD_USB_BASE_ADD);
1450 return -ENXIO;
1451 }
1452
1453 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
1454 __func__, dload, pid, snum);
1455 /* update pid */
1456 dload->magic_struct.pid = PID_MAGIC_ID;
1457 dload->pid = pid;
1458
1459 /* update serial number */
1460 dload->magic_struct.serial_num = 0;
1461 if (!snum)
1462 return 0;
1463
1464 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
1465 strncpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
1466 dload->serial_number[SERIAL_NUMBER_LENGTH - 1] = '\0';
1467
1468 iounmap(dload);
1469
1470 return 0;
1471}
1472
1473static struct android_usb_platform_data android_usb_pdata = {
1474 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
1475};
1476
1477static struct platform_device android_usb_device = {
1478 .name = "android_usb",
1479 .id = -1,
1480 .dev = {
1481 .platform_data = &android_usb_pdata,
1482 },
1483};
1484
1485
1486#endif
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08001487
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001488#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07001489#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001490static struct resource msm_vpe_resources[] = {
1491 {
1492 .start = 0x05300000,
1493 .end = 0x05300000 + SZ_1M - 1,
1494 .flags = IORESOURCE_MEM,
1495 },
1496 {
1497 .start = INT_VPE,
1498 .end = INT_VPE,
1499 .flags = IORESOURCE_IRQ,
1500 },
1501};
1502
1503static struct platform_device msm_vpe_device = {
1504 .name = "msm_vpe",
1505 .id = 0,
1506 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1507 .resource = msm_vpe_resources,
1508};
1509#endif
Kevin Chan3be11612012-03-22 20:05:40 -07001510#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001511
1512#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07001513#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001514#ifdef CONFIG_MSM_CAMERA_FLASH
1515#define VFE_CAMIF_TIMER1_GPIO 29
1516#define VFE_CAMIF_TIMER2_GPIO 30
1517#define VFE_CAMIF_TIMER3_GPIO_INT 31
1518#define FUSION_VFE_CAMIF_TIMER1_GPIO 42
1519static struct msm_camera_sensor_flash_src msm_flash_src = {
1520 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PMIC,
1521 ._fsrc.pmic_src.num_of_src = 2,
1522 ._fsrc.pmic_src.low_current = 100,
1523 ._fsrc.pmic_src.high_current = 300,
1524 ._fsrc.pmic_src.led_src_1 = PMIC8058_ID_FLASH_LED_0,
1525 ._fsrc.pmic_src.led_src_2 = PMIC8058_ID_FLASH_LED_1,
1526 ._fsrc.pmic_src.pmic_set_current = pm8058_set_flash_led_current,
1527};
1528#ifdef CONFIG_IMX074
1529static struct msm_camera_sensor_strobe_flash_data strobe_flash_xenon = {
1530 .flash_trigger = VFE_CAMIF_TIMER2_GPIO,
1531 .flash_charge = VFE_CAMIF_TIMER1_GPIO,
1532 .flash_charge_done = VFE_CAMIF_TIMER3_GPIO_INT,
1533 .flash_recharge_duration = 50000,
1534 .irq = MSM_GPIO_TO_INT(VFE_CAMIF_TIMER3_GPIO_INT),
1535};
1536#endif
1537#endif
1538
1539int msm_cam_gpio_tbl[] = {
1540 32,/*CAMIF_MCLK*/
1541 47,/*CAMIF_I2C_DATA*/
1542 48,/*CAMIF_I2C_CLK*/
1543 105,/*STANDBY*/
1544};
1545
1546enum msm_cam_stat{
1547 MSM_CAM_OFF,
1548 MSM_CAM_ON,
1549};
1550
1551static int config_gpio_table(enum msm_cam_stat stat)
1552{
1553 int rc = 0, i = 0;
1554 if (stat == MSM_CAM_ON) {
1555 for (i = 0; i < ARRAY_SIZE(msm_cam_gpio_tbl); i++) {
1556 rc = gpio_request(msm_cam_gpio_tbl[i], "CAM_GPIO");
1557 if (unlikely(rc < 0)) {
1558 pr_err("%s not able to get gpio\n", __func__);
1559 for (i--; i >= 0; i--)
1560 gpio_free(msm_cam_gpio_tbl[i]);
1561 break;
1562 }
1563 }
1564 } else {
1565 for (i = 0; i < ARRAY_SIZE(msm_cam_gpio_tbl); i++)
1566 gpio_free(msm_cam_gpio_tbl[i]);
1567 }
1568 return rc;
1569}
1570
1571static struct msm_camera_sensor_platform_info sensor_board_info = {
1572 .mount_angle = 0
1573};
1574
1575/*external regulator VREG_5V*/
1576static struct regulator *reg_flash_5V;
1577
1578static int config_camera_on_gpios_fluid(void)
1579{
1580 int rc = 0;
1581
1582 reg_flash_5V = regulator_get(NULL, "8901_mpp0");
1583 if (IS_ERR(reg_flash_5V)) {
1584 pr_err("'%s' regulator not found, rc=%ld\n",
1585 "8901_mpp0", IS_ERR(reg_flash_5V));
1586 return -ENODEV;
1587 }
1588
1589 rc = regulator_enable(reg_flash_5V);
1590 if (rc) {
1591 pr_err("'%s' regulator enable failed, rc=%d\n",
1592 "8901_mpp0", rc);
1593 regulator_put(reg_flash_5V);
1594 return rc;
1595 }
1596
1597#ifdef CONFIG_IMX074
1598 sensor_board_info.mount_angle = 90;
1599#endif
1600 rc = config_gpio_table(MSM_CAM_ON);
1601 if (rc < 0) {
1602 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1603 "failed\n", __func__);
1604 return rc;
1605 }
1606
1607 rc = gpio_request(GPIO_EXT_CAMIF_PWR_EN, "CAM_EN");
1608 if (rc < 0) {
1609 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1610 "failed\n", __func__, GPIO_EXT_CAMIF_PWR_EN);
1611 regulator_disable(reg_flash_5V);
1612 regulator_put(reg_flash_5V);
1613 return rc;
1614 }
1615 gpio_direction_output(GPIO_EXT_CAMIF_PWR_EN, 0);
1616 msleep(20);
1617 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 1);
1618
1619
1620 /*Enable LED_FLASH_EN*/
1621 rc = gpio_request(GPIO_LED_FLASH_EN, "LED_FLASH_EN");
1622 if (rc < 0) {
1623 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1624 "failed\n", __func__, GPIO_LED_FLASH_EN);
1625
1626 regulator_disable(reg_flash_5V);
1627 regulator_put(reg_flash_5V);
1628 config_gpio_table(MSM_CAM_OFF);
1629 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1630 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1631 return rc;
1632 }
1633 gpio_direction_output(GPIO_LED_FLASH_EN, 1);
1634 msleep(20);
1635 return rc;
1636}
1637
1638
1639static void config_camera_off_gpios_fluid(void)
1640{
1641 regulator_disable(reg_flash_5V);
1642 regulator_put(reg_flash_5V);
1643
1644 gpio_direction_output(GPIO_LED_FLASH_EN, 0);
1645 gpio_free(GPIO_LED_FLASH_EN);
1646
1647 config_gpio_table(MSM_CAM_OFF);
1648
1649 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1650 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1651}
1652static int config_camera_on_gpios(void)
1653{
1654 int rc = 0;
1655
1656 if (machine_is_msm8x60_fluid())
1657 return config_camera_on_gpios_fluid();
1658
1659 rc = config_gpio_table(MSM_CAM_ON);
1660 if (rc < 0) {
1661 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1662 "failed\n", __func__);
1663 return rc;
1664 }
1665
Jilai Wang971f97f2011-07-13 14:25:25 -04001666 if (!machine_is_msm8x60_dragon()) {
1667 rc = gpio_request(GPIO_EXT_CAMIF_PWR_EN, "CAM_EN");
1668 if (rc < 0) {
1669 config_gpio_table(MSM_CAM_OFF);
1670 pr_err("%s: CAMSENSOR gpio %d request"
1671 "failed\n", __func__, GPIO_EXT_CAMIF_PWR_EN);
1672 return rc;
1673 }
1674 gpio_direction_output(GPIO_EXT_CAMIF_PWR_EN, 0);
1675 msleep(20);
1676 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001677 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001678
1679#ifdef CONFIG_MSM_CAMERA_FLASH
1680#ifdef CONFIG_IMX074
1681 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
1682 strobe_flash_xenon.flash_charge = FUSION_VFE_CAMIF_TIMER1_GPIO;
1683#endif
1684#endif
1685 return rc;
1686}
1687
1688static void config_camera_off_gpios(void)
1689{
1690 if (machine_is_msm8x60_fluid())
1691 return config_camera_off_gpios_fluid();
1692
1693
1694 config_gpio_table(MSM_CAM_OFF);
1695
Jilai Wang971f97f2011-07-13 14:25:25 -04001696 if (!machine_is_msm8x60_dragon()) {
1697 gpio_set_value_cansleep(GPIO_EXT_CAMIF_PWR_EN, 0);
1698 gpio_free(GPIO_EXT_CAMIF_PWR_EN);
1699 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001700}
1701
1702#ifdef CONFIG_QS_S5K4E1
1703
1704#define QS_CAM_HC37_CAM_PD PM8058_GPIO_PM_TO_SYS(26)
1705
1706static int config_camera_on_gpios_qs_cam_fluid(void)
1707{
1708 int rc = 0;
1709
1710 /* request QS_CAM_HC37_CAM_PD as an output to HC37 ASIC pin CAM_PD */
1711 rc = gpio_request(QS_CAM_HC37_CAM_PD, "QS_CAM_HC37_CAM_PD");
1712 if (rc < 0) {
1713 printk(KERN_ERR "%s: QS_CAM_HC37_CAM_PD gpio %d request"
1714 " failed\n", __func__, QS_CAM_HC37_CAM_PD);
1715 return rc;
1716 }
1717 gpio_direction_output(QS_CAM_HC37_CAM_PD, 0);
1718 msleep(20);
1719 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 1);
1720 msleep(20);
1721
1722 /*
1723 * Set GPIO_AUX_CAM_2P7_EN to 1 on North Expander IO2
1724 * to enable 2.7V power to Camera
1725 */
1726 rc = gpio_request(GPIO_AUX_CAM_2P7_EN, "CAM_2P7_EN");
1727 if (rc < 0) {
1728 printk(KERN_ERR "%s: CAMSENSOR gpio %d request"
1729 " failed\n", __func__, GPIO_AUX_CAM_2P7_EN);
1730 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1731 gpio_free(QS_CAM_HC37_CAM_PD);
1732 return rc;
1733 }
1734 gpio_direction_output(GPIO_AUX_CAM_2P7_EN, 0);
1735 msleep(20);
1736 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 1);
1737 msleep(20);
1738
1739 rc = config_camera_on_gpios_fluid();
1740 if (rc < 0) {
1741 printk(KERN_ERR "%s: config_camera_on_gpios_fluid"
1742 " failed\n", __func__);
1743 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1744 gpio_free(QS_CAM_HC37_CAM_PD);
1745 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 0);
1746 gpio_free(GPIO_AUX_CAM_2P7_EN);
1747 return rc;
1748 }
1749 return rc;
1750}
1751
1752static void config_camera_off_gpios_qs_cam_fluid(void)
1753{
1754 /*
1755 * Set GPIO_AUX_CAM_2P7_EN to 0 on North Expander IO2
1756 * to disable 2.7V power to Camera
1757 */
1758 gpio_set_value_cansleep(GPIO_AUX_CAM_2P7_EN, 0);
1759 gpio_free(GPIO_AUX_CAM_2P7_EN);
1760
1761 /* set QS_CAM_HC37_CAM_PD to 0 to power off HC37 ASIC*/
1762 gpio_set_value_cansleep(QS_CAM_HC37_CAM_PD, 0);
1763 gpio_free(QS_CAM_HC37_CAM_PD);
1764
1765 config_camera_off_gpios_fluid();
1766 return;
1767}
1768
1769static int config_camera_on_gpios_qs_cam(void)
1770{
1771 int rc = 0;
1772
1773 if (machine_is_msm8x60_fluid())
1774 return config_camera_on_gpios_qs_cam_fluid();
1775
1776 rc = config_camera_on_gpios();
1777 return rc;
1778}
1779
1780static void config_camera_off_gpios_qs_cam(void)
1781{
1782 if (machine_is_msm8x60_fluid())
1783 return config_camera_off_gpios_qs_cam_fluid();
1784
1785 config_camera_off_gpios();
1786 return;
1787}
1788#endif
1789
1790static int config_camera_on_gpios_web_cam(void)
1791{
1792 int rc = 0;
1793 rc = config_gpio_table(MSM_CAM_ON);
1794 if (rc < 0) {
1795 printk(KERN_ERR "%s: CAMSENSOR gpio table request"
1796 "failed\n", __func__);
1797 return rc;
1798 }
1799
Jilai Wang53d27a82011-07-13 14:32:58 -04001800 if (!(machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon())) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001801 rc = gpio_request(GPIO_WEB_CAMIF_STANDBY, "CAM_EN");
1802 if (rc < 0) {
1803 config_gpio_table(MSM_CAM_OFF);
1804 pr_err(KERN_ERR "%s: CAMSENSOR gpio %d request"
1805 "failed\n", __func__, GPIO_WEB_CAMIF_STANDBY);
1806 return rc;
1807 }
1808 gpio_direction_output(GPIO_WEB_CAMIF_STANDBY, 0);
1809 }
1810 return rc;
1811}
1812
1813static void config_camera_off_gpios_web_cam(void)
1814{
1815 config_gpio_table(MSM_CAM_OFF);
Jilai Wang53d27a82011-07-13 14:32:58 -04001816 if (!(machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon())) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001817 gpio_set_value_cansleep(GPIO_WEB_CAMIF_STANDBY, 1);
1818 gpio_free(GPIO_WEB_CAMIF_STANDBY);
1819 }
1820 return;
1821}
1822
1823#ifdef CONFIG_MSM_BUS_SCALING
1824static struct msm_bus_vectors cam_init_vectors[] = {
1825 {
1826 .src = MSM_BUS_MASTER_VFE,
1827 .dst = MSM_BUS_SLAVE_SMI,
1828 .ab = 0,
1829 .ib = 0,
1830 },
1831 {
1832 .src = MSM_BUS_MASTER_VFE,
1833 .dst = MSM_BUS_SLAVE_EBI_CH0,
1834 .ab = 0,
1835 .ib = 0,
1836 },
1837 {
1838 .src = MSM_BUS_MASTER_VPE,
1839 .dst = MSM_BUS_SLAVE_SMI,
1840 .ab = 0,
1841 .ib = 0,
1842 },
1843 {
1844 .src = MSM_BUS_MASTER_VPE,
1845 .dst = MSM_BUS_SLAVE_EBI_CH0,
1846 .ab = 0,
1847 .ib = 0,
1848 },
1849 {
1850 .src = MSM_BUS_MASTER_JPEG_ENC,
1851 .dst = MSM_BUS_SLAVE_SMI,
1852 .ab = 0,
1853 .ib = 0,
1854 },
1855 {
1856 .src = MSM_BUS_MASTER_JPEG_ENC,
1857 .dst = MSM_BUS_SLAVE_EBI_CH0,
1858 .ab = 0,
1859 .ib = 0,
1860 },
1861};
1862
1863static struct msm_bus_vectors cam_preview_vectors[] = {
1864 {
1865 .src = MSM_BUS_MASTER_VFE,
1866 .dst = MSM_BUS_SLAVE_SMI,
1867 .ab = 0,
1868 .ib = 0,
1869 },
1870 {
1871 .src = MSM_BUS_MASTER_VFE,
1872 .dst = MSM_BUS_SLAVE_EBI_CH0,
1873 .ab = 283115520,
1874 .ib = 452984832,
1875 },
1876 {
1877 .src = MSM_BUS_MASTER_VPE,
1878 .dst = MSM_BUS_SLAVE_SMI,
1879 .ab = 0,
1880 .ib = 0,
1881 },
1882 {
1883 .src = MSM_BUS_MASTER_VPE,
1884 .dst = MSM_BUS_SLAVE_EBI_CH0,
1885 .ab = 0,
1886 .ib = 0,
1887 },
1888 {
1889 .src = MSM_BUS_MASTER_JPEG_ENC,
1890 .dst = MSM_BUS_SLAVE_SMI,
1891 .ab = 0,
1892 .ib = 0,
1893 },
1894 {
1895 .src = MSM_BUS_MASTER_JPEG_ENC,
1896 .dst = MSM_BUS_SLAVE_EBI_CH0,
1897 .ab = 0,
1898 .ib = 0,
1899 },
1900};
1901
1902static struct msm_bus_vectors cam_video_vectors[] = {
1903 {
1904 .src = MSM_BUS_MASTER_VFE,
1905 .dst = MSM_BUS_SLAVE_SMI,
1906 .ab = 283115520,
1907 .ib = 452984832,
1908 },
1909 {
1910 .src = MSM_BUS_MASTER_VFE,
1911 .dst = MSM_BUS_SLAVE_EBI_CH0,
1912 .ab = 283115520,
1913 .ib = 452984832,
1914 },
1915 {
1916 .src = MSM_BUS_MASTER_VPE,
1917 .dst = MSM_BUS_SLAVE_SMI,
1918 .ab = 319610880,
1919 .ib = 511377408,
1920 },
1921 {
1922 .src = MSM_BUS_MASTER_VPE,
1923 .dst = MSM_BUS_SLAVE_EBI_CH0,
1924 .ab = 0,
1925 .ib = 0,
1926 },
1927 {
1928 .src = MSM_BUS_MASTER_JPEG_ENC,
1929 .dst = MSM_BUS_SLAVE_SMI,
1930 .ab = 0,
1931 .ib = 0,
1932 },
1933 {
1934 .src = MSM_BUS_MASTER_JPEG_ENC,
1935 .dst = MSM_BUS_SLAVE_EBI_CH0,
1936 .ab = 0,
1937 .ib = 0,
1938 },
1939};
1940
1941static struct msm_bus_vectors cam_snapshot_vectors[] = {
1942 {
1943 .src = MSM_BUS_MASTER_VFE,
1944 .dst = MSM_BUS_SLAVE_SMI,
1945 .ab = 566231040,
1946 .ib = 905969664,
1947 },
1948 {
1949 .src = MSM_BUS_MASTER_VFE,
1950 .dst = MSM_BUS_SLAVE_EBI_CH0,
1951 .ab = 69984000,
1952 .ib = 111974400,
1953 },
1954 {
1955 .src = MSM_BUS_MASTER_VPE,
1956 .dst = MSM_BUS_SLAVE_SMI,
1957 .ab = 0,
1958 .ib = 0,
1959 },
1960 {
1961 .src = MSM_BUS_MASTER_VPE,
1962 .dst = MSM_BUS_SLAVE_EBI_CH0,
1963 .ab = 0,
1964 .ib = 0,
1965 },
1966 {
1967 .src = MSM_BUS_MASTER_JPEG_ENC,
1968 .dst = MSM_BUS_SLAVE_SMI,
1969 .ab = 320864256,
1970 .ib = 513382810,
1971 },
1972 {
1973 .src = MSM_BUS_MASTER_JPEG_ENC,
1974 .dst = MSM_BUS_SLAVE_EBI_CH0,
1975 .ab = 320864256,
1976 .ib = 513382810,
1977 },
1978};
1979
1980static struct msm_bus_vectors cam_zsl_vectors[] = {
1981 {
1982 .src = MSM_BUS_MASTER_VFE,
1983 .dst = MSM_BUS_SLAVE_SMI,
1984 .ab = 566231040,
1985 .ib = 905969664,
1986 },
1987 {
1988 .src = MSM_BUS_MASTER_VFE,
1989 .dst = MSM_BUS_SLAVE_EBI_CH0,
1990 .ab = 706199040,
1991 .ib = 1129918464,
1992 },
1993 {
1994 .src = MSM_BUS_MASTER_VPE,
1995 .dst = MSM_BUS_SLAVE_SMI,
1996 .ab = 0,
1997 .ib = 0,
1998 },
1999 {
2000 .src = MSM_BUS_MASTER_VPE,
2001 .dst = MSM_BUS_SLAVE_EBI_CH0,
2002 .ab = 0,
2003 .ib = 0,
2004 },
2005 {
2006 .src = MSM_BUS_MASTER_JPEG_ENC,
2007 .dst = MSM_BUS_SLAVE_SMI,
2008 .ab = 320864256,
2009 .ib = 513382810,
2010 },
2011 {
2012 .src = MSM_BUS_MASTER_JPEG_ENC,
2013 .dst = MSM_BUS_SLAVE_EBI_CH0,
2014 .ab = 320864256,
2015 .ib = 513382810,
2016 },
2017};
2018
2019static struct msm_bus_vectors cam_stereo_video_vectors[] = {
2020 {
2021 .src = MSM_BUS_MASTER_VFE,
2022 .dst = MSM_BUS_SLAVE_SMI,
2023 .ab = 212336640,
2024 .ib = 339738624,
2025 },
2026 {
2027 .src = MSM_BUS_MASTER_VFE,
2028 .dst = MSM_BUS_SLAVE_EBI_CH0,
2029 .ab = 25090560,
2030 .ib = 40144896,
2031 },
2032 {
2033 .src = MSM_BUS_MASTER_VPE,
2034 .dst = MSM_BUS_SLAVE_SMI,
2035 .ab = 239708160,
2036 .ib = 383533056,
2037 },
2038 {
2039 .src = MSM_BUS_MASTER_VPE,
2040 .dst = MSM_BUS_SLAVE_EBI_CH0,
2041 .ab = 79902720,
2042 .ib = 127844352,
2043 },
2044 {
2045 .src = MSM_BUS_MASTER_JPEG_ENC,
2046 .dst = MSM_BUS_SLAVE_SMI,
2047 .ab = 0,
2048 .ib = 0,
2049 },
2050 {
2051 .src = MSM_BUS_MASTER_JPEG_ENC,
2052 .dst = MSM_BUS_SLAVE_EBI_CH0,
2053 .ab = 0,
2054 .ib = 0,
2055 },
2056};
2057
2058static struct msm_bus_vectors cam_stereo_snapshot_vectors[] = {
2059 {
2060 .src = MSM_BUS_MASTER_VFE,
2061 .dst = MSM_BUS_SLAVE_SMI,
2062 .ab = 0,
2063 .ib = 0,
2064 },
2065 {
2066 .src = MSM_BUS_MASTER_VFE,
2067 .dst = MSM_BUS_SLAVE_EBI_CH0,
2068 .ab = 300902400,
2069 .ib = 481443840,
2070 },
2071 {
2072 .src = MSM_BUS_MASTER_VPE,
2073 .dst = MSM_BUS_SLAVE_SMI,
2074 .ab = 230307840,
2075 .ib = 368492544,
2076 },
2077 {
2078 .src = MSM_BUS_MASTER_VPE,
2079 .dst = MSM_BUS_SLAVE_EBI_CH0,
2080 .ab = 245113344,
2081 .ib = 392181351,
2082 },
2083 {
2084 .src = MSM_BUS_MASTER_JPEG_ENC,
2085 .dst = MSM_BUS_SLAVE_SMI,
2086 .ab = 106536960,
2087 .ib = 170459136,
2088 },
2089 {
2090 .src = MSM_BUS_MASTER_JPEG_ENC,
2091 .dst = MSM_BUS_SLAVE_EBI_CH0,
2092 .ab = 106536960,
2093 .ib = 170459136,
2094 },
2095};
2096
2097static struct msm_bus_paths cam_bus_client_config[] = {
2098 {
2099 ARRAY_SIZE(cam_init_vectors),
2100 cam_init_vectors,
2101 },
2102 {
2103 ARRAY_SIZE(cam_preview_vectors),
2104 cam_preview_vectors,
2105 },
2106 {
2107 ARRAY_SIZE(cam_video_vectors),
2108 cam_video_vectors,
2109 },
2110 {
2111 ARRAY_SIZE(cam_snapshot_vectors),
2112 cam_snapshot_vectors,
2113 },
2114 {
2115 ARRAY_SIZE(cam_zsl_vectors),
2116 cam_zsl_vectors,
2117 },
2118 {
2119 ARRAY_SIZE(cam_stereo_video_vectors),
2120 cam_stereo_video_vectors,
2121 },
2122 {
2123 ARRAY_SIZE(cam_stereo_snapshot_vectors),
2124 cam_stereo_snapshot_vectors,
2125 },
2126};
2127
2128static struct msm_bus_scale_pdata cam_bus_client_pdata = {
2129 cam_bus_client_config,
2130 ARRAY_SIZE(cam_bus_client_config),
2131 .name = "msm_camera",
2132};
2133#endif
2134
2135struct msm_camera_device_platform_data msm_camera_device_data = {
2136 .camera_gpio_on = config_camera_on_gpios,
2137 .camera_gpio_off = config_camera_off_gpios,
2138 .ioext.csiphy = 0x04800000,
2139 .ioext.csisz = 0x00000400,
2140 .ioext.csiirq = CSI_0_IRQ,
2141 .ioclk.mclk_clk_rate = 24000000,
2142 .ioclk.vfe_clk_rate = 228570000,
2143#ifdef CONFIG_MSM_BUS_SCALING
2144 .cam_bus_scale_table = &cam_bus_client_pdata,
2145#endif
2146};
2147
2148#ifdef CONFIG_QS_S5K4E1
2149struct msm_camera_device_platform_data msm_camera_device_data_qs_cam = {
2150 .camera_gpio_on = config_camera_on_gpios_qs_cam,
2151 .camera_gpio_off = config_camera_off_gpios_qs_cam,
2152 .ioext.csiphy = 0x04800000,
2153 .ioext.csisz = 0x00000400,
2154 .ioext.csiirq = CSI_0_IRQ,
2155 .ioclk.mclk_clk_rate = 24000000,
2156 .ioclk.vfe_clk_rate = 228570000,
2157#ifdef CONFIG_MSM_BUS_SCALING
2158 .cam_bus_scale_table = &cam_bus_client_pdata,
2159#endif
2160};
2161#endif
2162
2163struct msm_camera_device_platform_data msm_camera_device_data_web_cam = {
2164 .camera_gpio_on = config_camera_on_gpios_web_cam,
2165 .camera_gpio_off = config_camera_off_gpios_web_cam,
2166 .ioext.csiphy = 0x04900000,
2167 .ioext.csisz = 0x00000400,
2168 .ioext.csiirq = CSI_1_IRQ,
2169 .ioclk.mclk_clk_rate = 24000000,
2170 .ioclk.vfe_clk_rate = 228570000,
2171#ifdef CONFIG_MSM_BUS_SCALING
2172 .cam_bus_scale_table = &cam_bus_client_pdata,
2173#endif
2174};
2175
2176struct resource msm_camera_resources[] = {
2177 {
2178 .start = 0x04500000,
2179 .end = 0x04500000 + SZ_1M - 1,
2180 .flags = IORESOURCE_MEM,
2181 },
2182 {
2183 .start = VFE_IRQ,
2184 .end = VFE_IRQ,
2185 .flags = IORESOURCE_IRQ,
2186 },
2187};
2188#ifdef CONFIG_MT9E013
2189static struct msm_camera_sensor_platform_info mt9e013_sensor_8660_info = {
2190 .mount_angle = 0
2191};
2192
2193static struct msm_camera_sensor_flash_data flash_mt9e013 = {
2194 .flash_type = MSM_CAMERA_FLASH_LED,
2195 .flash_src = &msm_flash_src
2196};
2197
2198static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
2199 .sensor_name = "mt9e013",
2200 .sensor_reset = 106,
2201 .sensor_pwd = 85,
2202 .vcm_pwd = 1,
2203 .vcm_enable = 0,
2204 .pdata = &msm_camera_device_data,
2205 .resource = msm_camera_resources,
2206 .num_resources = ARRAY_SIZE(msm_camera_resources),
2207 .flash_data = &flash_mt9e013,
2208 .strobe_flash_data = &strobe_flash_xenon,
2209 .sensor_platform_info = &mt9e013_sensor_8660_info,
2210 .csi_if = 1
2211};
2212struct platform_device msm_camera_sensor_mt9e013 = {
2213 .name = "msm_camera_mt9e013",
2214 .dev = {
2215 .platform_data = &msm_camera_sensor_mt9e013_data,
2216 },
2217};
2218#endif
2219
2220#ifdef CONFIG_IMX074
Roja Rani Yarubandi68ebb4d2011-10-20 10:33:16 +05302221static struct msm_camera_sensor_platform_info imx074_sensor_board_info = {
2222 .mount_angle = 180
2223};
2224
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002225static struct msm_camera_sensor_flash_data flash_imx074 = {
2226 .flash_type = MSM_CAMERA_FLASH_LED,
2227 .flash_src = &msm_flash_src
2228};
2229
2230static struct msm_camera_sensor_info msm_camera_sensor_imx074_data = {
2231 .sensor_name = "imx074",
2232 .sensor_reset = 106,
2233 .sensor_pwd = 85,
2234 .vcm_pwd = GPIO_AUX_CAM_2P7_EN,
2235 .vcm_enable = 1,
2236 .pdata = &msm_camera_device_data,
2237 .resource = msm_camera_resources,
2238 .num_resources = ARRAY_SIZE(msm_camera_resources),
2239 .flash_data = &flash_imx074,
2240 .strobe_flash_data = &strobe_flash_xenon,
Roja Rani Yarubandi68ebb4d2011-10-20 10:33:16 +05302241 .sensor_platform_info = &imx074_sensor_board_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002242 .csi_if = 1
2243};
2244struct platform_device msm_camera_sensor_imx074 = {
2245 .name = "msm_camera_imx074",
2246 .dev = {
2247 .platform_data = &msm_camera_sensor_imx074_data,
2248 },
2249};
2250#endif
2251#ifdef CONFIG_WEBCAM_OV9726
2252
2253static struct msm_camera_sensor_platform_info ov9726_sensor_8660_info = {
2254 .mount_angle = 0
2255};
2256
2257static struct msm_camera_sensor_flash_data flash_ov9726 = {
2258 .flash_type = MSM_CAMERA_FLASH_LED,
2259 .flash_src = &msm_flash_src
2260};
2261static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
2262 .sensor_name = "ov9726",
Kevin Chan3382c512011-07-19 21:00:45 -07002263 .sensor_reset_enable = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002264 .sensor_reset = GPIO_FRONT_CAM_RESET_N,
2265 .sensor_pwd = 85,
2266 .vcm_pwd = 1,
2267 .vcm_enable = 0,
2268 .pdata = &msm_camera_device_data_web_cam,
2269 .resource = msm_camera_resources,
2270 .num_resources = ARRAY_SIZE(msm_camera_resources),
2271 .flash_data = &flash_ov9726,
2272 .sensor_platform_info = &ov9726_sensor_8660_info,
2273 .csi_if = 1
2274};
2275struct platform_device msm_camera_sensor_webcam_ov9726 = {
2276 .name = "msm_camera_ov9726",
2277 .dev = {
2278 .platform_data = &msm_camera_sensor_ov9726_data,
2279 },
2280};
2281#endif
2282#ifdef CONFIG_WEBCAM_OV7692
2283static struct msm_camera_sensor_flash_data flash_ov7692 = {
2284 .flash_type = MSM_CAMERA_FLASH_LED,
2285 .flash_src = &msm_flash_src
2286};
2287static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
2288 .sensor_name = "ov7692",
2289 .sensor_reset = GPIO_WEB_CAMIF_RESET_N,
2290 .sensor_pwd = 85,
2291 .vcm_pwd = 1,
2292 .vcm_enable = 0,
2293 .pdata = &msm_camera_device_data_web_cam,
2294 .resource = msm_camera_resources,
2295 .num_resources = ARRAY_SIZE(msm_camera_resources),
2296 .flash_data = &flash_ov7692,
2297 .csi_if = 1
2298};
2299
2300static struct platform_device msm_camera_sensor_webcam_ov7692 = {
2301 .name = "msm_camera_ov7692",
2302 .dev = {
2303 .platform_data = &msm_camera_sensor_ov7692_data,
2304 },
2305};
2306#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04002307#ifdef CONFIG_VX6953
2308static struct msm_camera_sensor_platform_info vx6953_sensor_8660_info = {
2309 .mount_angle = 270
2310};
2311
2312static struct msm_camera_sensor_flash_data flash_vx6953 = {
2313 .flash_type = MSM_CAMERA_FLASH_NONE,
2314 .flash_src = &msm_flash_src
2315};
2316
2317static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
2318 .sensor_name = "vx6953",
2319 .sensor_reset = 63,
2320 .sensor_pwd = 63,
2321 .vcm_pwd = GPIO_AUX_CAM_2P7_EN,
2322 .vcm_enable = 1,
2323 .pdata = &msm_camera_device_data,
2324 .resource = msm_camera_resources,
2325 .num_resources = ARRAY_SIZE(msm_camera_resources),
2326 .flash_data = &flash_vx6953,
2327 .sensor_platform_info = &vx6953_sensor_8660_info,
2328 .csi_if = 1
2329};
2330struct platform_device msm_camera_sensor_vx6953 = {
2331 .name = "msm_camera_vx6953",
2332 .dev = {
2333 .platform_data = &msm_camera_sensor_vx6953_data,
2334 },
2335};
2336#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002337#ifdef CONFIG_QS_S5K4E1
2338
Nishant Pandit613ab7a2011-09-02 03:36:01 +05302339static struct msm_camera_sensor_platform_info qs_s5k4e1_sensor_8660_info = {
2340#ifdef CONFIG_FB_MSM_MIPI_NOVATEK_CMD_QHD_PT
2341 .mount_angle = 90
2342#else
2343 .mount_angle = 0
2344#endif
2345};
2346
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002347static char eeprom_data[864];
2348static struct msm_camera_sensor_flash_data flash_qs_s5k4e1 = {
2349 .flash_type = MSM_CAMERA_FLASH_LED,
2350 .flash_src = &msm_flash_src
2351};
2352
2353static struct msm_camera_sensor_info msm_camera_sensor_qs_s5k4e1_data = {
2354 .sensor_name = "qs_s5k4e1",
2355 .sensor_reset = 106,
2356 .sensor_pwd = 85,
2357 .vcm_pwd = 1,
2358 .vcm_enable = 0,
2359 .pdata = &msm_camera_device_data_qs_cam,
2360 .resource = msm_camera_resources,
2361 .num_resources = ARRAY_SIZE(msm_camera_resources),
2362 .flash_data = &flash_qs_s5k4e1,
2363 .strobe_flash_data = &strobe_flash_xenon,
Nishant Pandit613ab7a2011-09-02 03:36:01 +05302364 .sensor_platform_info = &qs_s5k4e1_sensor_8660_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002365 .csi_if = 1,
2366 .eeprom_data = eeprom_data,
2367};
2368struct platform_device msm_camera_sensor_qs_s5k4e1 = {
2369 .name = "msm_camera_qs_s5k4e1",
2370 .dev = {
2371 .platform_data = &msm_camera_sensor_qs_s5k4e1_data,
2372 },
2373};
2374#endif
2375static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
2376 #ifdef CONFIG_MT9E013
2377 {
2378 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
2379 },
2380 #endif
2381 #ifdef CONFIG_IMX074
2382 {
2383 I2C_BOARD_INFO("imx074", 0x1A),
2384 },
2385 #endif
2386 #ifdef CONFIG_WEBCAM_OV7692
2387 {
2388 I2C_BOARD_INFO("ov7692", 0x78),
2389 },
2390 #endif
2391 #ifdef CONFIG_WEBCAM_OV9726
2392 {
2393 I2C_BOARD_INFO("ov9726", 0x10),
2394 },
2395 #endif
2396 #ifdef CONFIG_QS_S5K4E1
2397 {
2398 I2C_BOARD_INFO("qs_s5k4e1", 0x20),
2399 },
2400 #endif
2401};
Jilai Wang971f97f2011-07-13 14:25:25 -04002402
2403static struct i2c_board_info msm_camera_dragon_boardinfo[] __initdata = {
Jilai Wang53d27a82011-07-13 14:32:58 -04002404 #ifdef CONFIG_WEBCAM_OV9726
2405 {
2406 I2C_BOARD_INFO("ov9726", 0x10),
2407 },
2408 #endif
Jilai Wang971f97f2011-07-13 14:25:25 -04002409 #ifdef CONFIG_VX6953
2410 {
2411 I2C_BOARD_INFO("vx6953", 0x20),
2412 },
2413 #endif
2414};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002415#endif
Kevin Chan3be11612012-03-22 20:05:40 -07002416#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002417
2418#ifdef CONFIG_MSM_GEMINI
2419static struct resource msm_gemini_resources[] = {
2420 {
2421 .start = 0x04600000,
2422 .end = 0x04600000 + SZ_1M - 1,
2423 .flags = IORESOURCE_MEM,
2424 },
2425 {
2426 .start = INT_JPEG,
2427 .end = INT_JPEG,
2428 .flags = IORESOURCE_IRQ,
2429 },
2430};
2431
2432static struct platform_device msm_gemini_device = {
2433 .name = "msm_gemini",
2434 .resource = msm_gemini_resources,
2435 .num_resources = ARRAY_SIZE(msm_gemini_resources),
2436};
2437#endif
2438
2439#ifdef CONFIG_I2C_QUP
2440static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
2441{
2442}
2443
2444static struct msm_i2c_platform_data msm_gsbi3_qup_i2c_pdata = {
2445 .clk_freq = 384000,
2446 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002447 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2448};
2449
2450static struct msm_i2c_platform_data msm_gsbi4_qup_i2c_pdata = {
2451 .clk_freq = 100000,
2452 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002453 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2454};
2455
2456static struct msm_i2c_platform_data msm_gsbi7_qup_i2c_pdata = {
2457 .clk_freq = 100000,
2458 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002459 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2460};
2461
2462static struct msm_i2c_platform_data msm_gsbi8_qup_i2c_pdata = {
2463 .clk_freq = 100000,
2464 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002465 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2466};
2467
2468static struct msm_i2c_platform_data msm_gsbi9_qup_i2c_pdata = {
2469 .clk_freq = 100000,
2470 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002471 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2472};
2473
2474static struct msm_i2c_platform_data msm_gsbi12_qup_i2c_pdata = {
2475 .clk_freq = 100000,
2476 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002477 .use_gsbi_shared_mode = 1,
2478 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2479};
2480#endif
2481
2482#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
2483static struct msm_spi_platform_data msm_gsbi1_qup_spi_pdata = {
2484 .max_clock_speed = 24000000,
2485};
2486
2487static struct msm_spi_platform_data msm_gsbi10_qup_spi_pdata = {
2488 .max_clock_speed = 24000000,
2489};
2490#endif
2491
2492#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002493/* CODEC/TSSC SSBI */
2494static struct msm_i2c_ssbi_platform_data msm_ssbi3_pdata = {
2495 .controller_type = MSM_SBI_CTRL_SSBI,
2496};
2497#endif
2498
2499#ifdef CONFIG_BATTERY_MSM
2500/* Use basic value for fake MSM battery */
2501static struct msm_psy_batt_pdata msm_psy_batt_data = {
2502 .avail_chg_sources = AC_CHG,
2503};
2504
2505static struct platform_device msm_batt_device = {
2506 .name = "msm-battery",
2507 .id = -1,
2508 .dev.platform_data = &msm_psy_batt_data,
2509};
2510#endif
2511
2512#ifdef CONFIG_FB_MSM_LCDC_DSUB
2513/* VGA = 1440 x 900 x 4(bpp) x 2(pages)
2514 prim = 1024 x 600 x 4(bpp) x 2(pages)
2515 This is the difference. */
2516#define MSM_FB_DSUB_PMEM_ADDER (0xA32000-0x4B0000)
2517#else
2518#define MSM_FB_DSUB_PMEM_ADDER (0)
2519#endif
2520
2521/* Sensors DSPS platform data */
2522#ifdef CONFIG_MSM_DSPS
2523
2524static struct dsps_gpio_info dsps_surf_gpios[] = {
2525 {
2526 .name = "compass_rst_n",
2527 .num = GPIO_COMPASS_RST_N,
2528 .on_val = 1, /* device not in reset */
2529 .off_val = 0, /* device in reset */
2530 },
2531 {
2532 .name = "gpio_r_altimeter_reset_n",
2533 .num = GPIO_R_ALTIMETER_RESET_N,
2534 .on_val = 1, /* device not in reset */
2535 .off_val = 0, /* device in reset */
2536 }
2537};
2538
2539static struct dsps_gpio_info dsps_fluid_gpios[] = {
2540 {
2541 .name = "gpio_n_altimeter_reset_n",
2542 .num = GPIO_N_ALTIMETER_RESET_N,
2543 .on_val = 1, /* device not in reset */
2544 .off_val = 0, /* device in reset */
2545 }
2546};
2547
2548static void __init msm8x60_init_dsps(void)
2549{
2550 struct msm_dsps_platform_data *pdata =
2551 msm_dsps_device.dev.platform_data;
2552 /*
2553 * On Fluid the Compass sensor Chip-Select (CS) is directly connected
2554 * to the power supply and not controled via GPIOs. Fluid uses a
2555 * different IO-Expender (north) than used on surf/ffa.
2556 */
2557 if (machine_is_msm8x60_fluid()) {
2558 /* fluid has different firmware, gpios */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002559 pdata->pil_name = DSPS_PIL_FLUID_NAME;
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002560 msm_pil_dsps.dev.platform_data = DSPS_PIL_FLUID_NAME;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002561 pdata->gpios = dsps_fluid_gpios;
2562 pdata->gpios_num = ARRAY_SIZE(dsps_fluid_gpios);
2563 } else {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002564 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07002565 msm_pil_dsps.dev.platform_data = DSPS_PIL_GENERIC_NAME;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002566 pdata->gpios = dsps_surf_gpios;
2567 pdata->gpios_num = ARRAY_SIZE(dsps_surf_gpios);
2568 }
2569
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002570 platform_device_register(&msm_dsps_device);
2571}
2572#endif /* CONFIG_MSM_DSPS */
2573
2574#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302575#define MSM_FB_PRIM_BUF_SIZE \
2576 (roundup((1024 * 600 * 4), 4096) * 3) /* 4 bpp x 3 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002577#else
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302578#define MSM_FB_PRIM_BUF_SIZE \
2579 (roundup((1024 * 600 * 4), 4096) * 2) /* 4 bpp x 2 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002580#endif
2581
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002582#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302583#define MSM_FB_EXT_BUF_SIZE \
2584 (roundup((1920 * 1080 * 2), 4096) * 1) /* 2 bpp x 1 page */
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002585#elif defined(CONFIG_FB_MSM_TVOUT)
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +05302586#define MSM_FB_EXT_BUF_SIZE \
2587 (roundup((720 * 576 * 2), 4096) * 2) /* 2 bpp x 2 pages */
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002588#else
Ajay Singh Parmardf694562012-06-05 15:06:21 +05302589#define MSM_FB_EXT_BUF_SIZE 0
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002590#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002591
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002592/* Note: must be multiple of 4096 */
2593#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE + \
kuogee hsiehc9a2e6d2011-09-12 15:27:01 -07002594 MSM_FB_DSUB_PMEM_ADDER, 4096)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002595
2596#define MSM_PMEM_SF_SIZE 0x4000000 /* 64 Mbytes */
Sravan Kumar D.V.Nb4d77dd2012-03-16 12:25:37 +05302597#define MSM_HDMI_PRIM_PMEM_SF_SIZE 0x8000000 /* 128 Mbytes */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002598
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002599#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002600unsigned char hdmi_is_primary = 1;
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002601#else
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002602unsigned char hdmi_is_primary;
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07002603#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002604
Huaibin Yanga5419422011-12-08 23:52:10 -08002605#ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK
2606#define MSM_FB_OVERLAY0_WRITEBACK_SIZE roundup((1376 * 768 * 3 * 2), 4096)
2607#else
2608#define MSM_FB_OVERLAY0_WRITEBACK_SIZE (0)
2609#endif /* CONFIG_FB_MSM_OVERLAY0_WRITEBACK */
2610
2611#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
2612#define MSM_FB_OVERLAY1_WRITEBACK_SIZE roundup((1920 * 1088 * 3 * 2), 4096)
2613#else
2614#define MSM_FB_OVERLAY1_WRITEBACK_SIZE (0)
2615#endif /* CONFIG_FB_MSM_OVERLAY1_WRITEBACK */
2616
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302617#define MSM_PMEM_KERNEL_EBI1_SIZE 0x3BC000
Ankit Premrajkaaee8f562012-04-09 03:57:53 -07002618#define MSM_PMEM_ADSP_SIZE 0x4200000
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302619#define MSM_PMEM_AUDIO_SIZE 0x4CF000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002620
2621#define MSM_SMI_BASE 0x38000000
2622#define MSM_SMI_SIZE 0x4000000
2623
2624#define KERNEL_SMI_BASE (MSM_SMI_BASE)
Sravan Kumar D.V.Nad046702012-05-23 11:25:42 +05302625#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
2626#define KERNEL_SMI_SIZE 0x000000
2627#else
Maheshwar Ajjac60c0462011-11-29 17:46:57 -08002628#define KERNEL_SMI_SIZE 0x600000
Sravan Kumar D.V.Nad046702012-05-23 11:25:42 +05302629#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002630
2631#define USER_SMI_BASE (KERNEL_SMI_BASE + KERNEL_SMI_SIZE)
2632#define USER_SMI_SIZE (MSM_SMI_SIZE - KERNEL_SMI_SIZE)
2633#define MSM_PMEM_SMIPOOL_SIZE USER_SMI_SIZE
2634
Chintan Pandya490c9712012-08-07 17:19:59 +05302635#ifdef CONFIG_MSM_CP
Chintan Pandyafda5bc42012-05-08 14:15:33 +05302636#define MSM_ION_HOLE_SIZE SZ_128K /* (128KB) */
Chintan Pandya490c9712012-08-07 17:19:59 +05302637#else
2638#define MSM_ION_HOLE_SIZE 0
2639#endif
2640
Chintan Pandyafda5bc42012-05-08 14:15:33 +05302641#define MSM_MM_FW_SIZE (0x200000 - MSM_ION_HOLE_SIZE) /*(2MB-128KB)*/
2642#define MSM_ION_MM_SIZE 0x3800000 /* (56MB) */
2643#define MSM_ION_MFC_SIZE SZ_8K
2644
2645#define MSM_MM_FW_BASE MSM_SMI_BASE
2646#define MSM_ION_HOLE_BASE (MSM_MM_FW_BASE + MSM_MM_FW_SIZE)
2647#define MSM_ION_MM_BASE (MSM_ION_HOLE_BASE + MSM_ION_HOLE_SIZE)
2648#define MSM_ION_MFC_BASE (MSM_ION_MM_BASE + MSM_ION_MM_SIZE)
2649
Chintan Pandya490c9712012-08-07 17:19:59 +05302650#ifdef CONFIG_MSM_CP
2651#define SECURE_BASE (MSM_ION_HOLE_BASE)
2652#define SECURE_SIZE (MSM_ION_MM_SIZE + MSM_ION_HOLE_SIZE)
2653#else
2654#define SECURE_BASE (MSM_MM_FW_BASE)
2655#define SECURE_SIZE (MSM_ION_MM_SIZE + MSM_MM_FW_SIZE)
2656#endif
2657
Naseer Ahmed51860b02012-02-07 18:53:29 +05302658#define MSM_ION_SF_SIZE 0x4000000 /* 64MB */
Olav Hauganb5be7992011-11-18 14:29:02 -08002659#define MSM_ION_CAMERA_SIZE MSM_PMEM_ADSP_SIZE
Chintan Pandyafda5bc42012-05-08 14:15:33 +05302660
Mayank Choprac22ace32012-03-03 00:45:04 +05302661#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
2662#define MSM_ION_WB_SIZE 0xC00000 /* 12MB */
2663#else
Olav Hauganb5be7992011-11-18 14:29:02 -08002664#define MSM_ION_WB_SIZE 0x600000 /* 6MB */
Mayank Choprac22ace32012-03-03 00:45:04 +05302665#endif
2666
Olav Haugan424ff492012-03-13 11:41:23 -07002667#define MSM_ION_QSECOM_SIZE 0x600000 /* (6MB) */
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002668
2669#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Chaithanya Krishna Bacharaju1844c7c2012-03-19 11:25:43 +05302670#define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
Olav Haugan6ab47252012-02-15 14:46:49 -08002671#define MSM_ION_HEAP_NUM 9
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08002672#define MSM_HDMI_PRIM_ION_SF_SIZE MSM_HDMI_PRIM_PMEM_SF_SIZE
2673static unsigned msm_ion_sf_size = MSM_ION_SF_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002674#else
Olav Hauganb5be7992011-11-18 14:29:02 -08002675#define MSM_ION_HEAP_NUM 1
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002676#endif
2677
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002678static unsigned fb_size;
2679static int __init fb_size_setup(char *p)
2680{
2681 fb_size = memparse(p, NULL);
2682 return 0;
2683}
2684early_param("fb_size", fb_size_setup);
2685
2686static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
2687static int __init pmem_kernel_ebi1_size_setup(char *p)
2688{
2689 pmem_kernel_ebi1_size = memparse(p, NULL);
2690 return 0;
2691}
2692early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
2693
2694#ifdef CONFIG_ANDROID_PMEM
2695static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
2696static int __init pmem_sf_size_setup(char *p)
2697{
2698 pmem_sf_size = memparse(p, NULL);
2699 return 0;
2700}
2701early_param("pmem_sf_size", pmem_sf_size_setup);
2702
2703static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
2704
2705static int __init pmem_adsp_size_setup(char *p)
2706{
2707 pmem_adsp_size = memparse(p, NULL);
2708 return 0;
2709}
2710early_param("pmem_adsp_size", pmem_adsp_size_setup);
2711
2712static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
2713
2714static int __init pmem_audio_size_setup(char *p)
2715{
2716 pmem_audio_size = memparse(p, NULL);
2717 return 0;
2718}
2719early_param("pmem_audio_size", pmem_audio_size_setup);
2720#endif
2721
2722static struct resource msm_fb_resources[] = {
2723 {
2724 .flags = IORESOURCE_DMA,
2725 }
2726};
2727
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002728static void set_mdp_clocks_for_wuxga(void);
2729
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002730static int msm_fb_detect_panel(const char *name)
2731{
2732 if (machine_is_msm8x60_fluid()) {
2733 uint32_t soc_platform_version = socinfo_get_platform_version();
2734 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
2735#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2736 if (!strncmp(name, LCDC_SAMSUNG_OLED_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002737 strnlen(LCDC_SAMSUNG_OLED_PANEL_NAME,
2738 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002739 return 0;
2740#endif
2741 } else { /*P3 and up use AUO panel */
2742#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
2743 if (!strncmp(name, LCDC_AUO_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002744 strnlen(LCDC_AUO_PANEL_NAME,
2745 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002746 return 0;
2747#endif
2748 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002749#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
2750 } else if machine_is_msm8x60_dragon() {
2751 if (!strncmp(name, LCDC_NT35582_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002752 strnlen(LCDC_NT35582_PANEL_NAME,
2753 PANEL_NAME_MAX_LEN)))
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04002754 return 0;
2755#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002756 } else {
2757 if (!strncmp(name, LCDC_SAMSUNG_WSVGA_PANEL_NAME,
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002758 strnlen(LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2759 PANEL_NAME_MAX_LEN)))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002760 return 0;
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002761
2762#if !defined(CONFIG_FB_MSM_LCDC_AUTO_DETECT) && \
2763 !defined(CONFIG_FB_MSM_MIPI_PANEL_AUTO_DETECT) && \
2764 !defined(CONFIG_FB_MSM_LCDC_MIPI_PANEL_AUTO_DETECT)
2765 if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2766 strnlen(MIPI_VIDEO_TOSHIBA_WVGA_PANEL_NAME,
2767 PANEL_NAME_MAX_LEN)))
2768 return 0;
2769
2770 if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2771 strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
2772 PANEL_NAME_MAX_LEN)))
2773 return 0;
2774
2775 if (!strncmp(name, MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2776 strnlen(MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
2777 PANEL_NAME_MAX_LEN)))
2778 return 0;
2779#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002780 }
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002781
2782 if (!strncmp(name, HDMI_PANEL_NAME,
2783 strnlen(HDMI_PANEL_NAME,
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002784 PANEL_NAME_MAX_LEN))) {
2785 if (hdmi_is_primary)
2786 set_mdp_clocks_for_wuxga();
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002787 return 0;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07002788 }
Ravishangar Kalyanam61a7bd12011-07-28 16:48:36 -07002789
2790 if (!strncmp(name, TVOUT_PANEL_NAME,
2791 strnlen(TVOUT_PANEL_NAME,
2792 PANEL_NAME_MAX_LEN)))
2793 return 0;
2794
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002795 pr_warning("%s: not supported '%s'", __func__, name);
2796 return -ENODEV;
2797}
2798
2799static struct msm_fb_platform_data msm_fb_pdata = {
2800 .detect_client = msm_fb_detect_panel,
2801};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002802
2803static struct platform_device msm_fb_device = {
2804 .name = "msm_fb",
2805 .id = 0,
2806 .num_resources = ARRAY_SIZE(msm_fb_resources),
2807 .resource = msm_fb_resources,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002808 .dev.platform_data = &msm_fb_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002809};
2810
2811#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07002812#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002813static struct android_pmem_platform_data android_pmem_pdata = {
2814 .name = "pmem",
2815 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
2816 .cached = 1,
2817 .memory_type = MEMTYPE_EBI1,
2818};
2819
2820static struct platform_device android_pmem_device = {
2821 .name = "android_pmem",
2822 .id = 0,
2823 .dev = {.platform_data = &android_pmem_pdata},
2824};
2825
2826static struct android_pmem_platform_data android_pmem_adsp_pdata = {
2827 .name = "pmem_adsp",
2828 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2829 .cached = 0,
2830 .memory_type = MEMTYPE_EBI1,
2831};
2832
2833static struct platform_device android_pmem_adsp_device = {
2834 .name = "android_pmem",
2835 .id = 2,
2836 .dev = { .platform_data = &android_pmem_adsp_pdata },
2837};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302838
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002839static struct android_pmem_platform_data android_pmem_audio_pdata = {
2840 .name = "pmem_audio",
2841 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2842 .cached = 0,
2843 .memory_type = MEMTYPE_EBI1,
2844};
2845
2846static struct platform_device android_pmem_audio_device = {
2847 .name = "android_pmem",
2848 .id = 4,
2849 .dev = { .platform_data = &android_pmem_audio_pdata },
2850};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302851#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Laura Abbott1e36a022011-06-22 17:08:13 -07002852#define PMEM_BUS_WIDTH(_bw) \
2853 { \
2854 .vectors = &(struct msm_bus_vectors){ \
2855 .src = MSM_BUS_MASTER_AMPSS_M0, \
2856 .dst = MSM_BUS_SLAVE_SMI, \
2857 .ib = (_bw), \
2858 .ab = 0, \
2859 }, \
2860 .num_paths = 1, \
2861 }
Olav Hauganee0f7802011-12-19 13:28:57 -08002862
2863static struct msm_bus_paths mem_smi_table[] = {
Laura Abbott1e36a022011-06-22 17:08:13 -07002864 [0] = PMEM_BUS_WIDTH(0), /* Off */
2865 [1] = PMEM_BUS_WIDTH(1), /* On */
2866};
2867
2868static struct msm_bus_scale_pdata smi_client_pdata = {
Olav Hauganee0f7802011-12-19 13:28:57 -08002869 .usecase = mem_smi_table,
2870 .num_usecases = ARRAY_SIZE(mem_smi_table),
2871 .name = "mem_smi",
Laura Abbott1e36a022011-06-22 17:08:13 -07002872};
2873
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002874int request_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002875{
2876 int bus_id = (int) data;
2877
2878 msm_bus_scale_client_update_request(bus_id, 1);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002879 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002880}
2881
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002882int release_smi_region(void *data)
Laura Abbott1e36a022011-06-22 17:08:13 -07002883{
2884 int bus_id = (int) data;
2885
2886 msm_bus_scale_client_update_request(bus_id, 0);
Laura Abbott72ae4bf2011-12-14 14:01:43 -08002887 return 0;
Laura Abbott1e36a022011-06-22 17:08:13 -07002888}
2889
Alex Bird199980e2011-10-21 11:29:27 -07002890void *setup_smi_region(void)
Laura Abbott1e36a022011-06-22 17:08:13 -07002891{
2892 return (void *)msm_bus_scale_register_client(&smi_client_pdata);
2893}
Olav Hauganee0f7802011-12-19 13:28:57 -08002894#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002895static struct android_pmem_platform_data android_pmem_smipool_pdata = {
2896 .name = "pmem_smipool",
2897 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
2898 .cached = 0,
2899 .memory_type = MEMTYPE_SMI,
Alex Bird199980e2011-10-21 11:29:27 -07002900 .request_region = request_smi_region,
2901 .release_region = release_smi_region,
2902 .setup_region = setup_smi_region,
Laura Abbott1e36a022011-06-22 17:08:13 -07002903 .map_on_demand = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002904};
2905static struct platform_device android_pmem_smipool_device = {
2906 .name = "android_pmem",
2907 .id = 7,
2908 .dev = { .platform_data = &android_pmem_smipool_pdata },
2909};
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05302910#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
2911#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002912
2913#define GPIO_DONGLE_PWR_EN 258
2914static void setup_display_power(void);
2915static int lcdc_vga_enabled;
2916static int vga_enable_request(int enable)
2917{
2918 if (enable)
2919 lcdc_vga_enabled = 1;
2920 else
2921 lcdc_vga_enabled = 0;
2922 setup_display_power();
2923
2924 return 0;
2925}
2926
2927#define GPIO_BACKLIGHT_PWM0 0
2928#define GPIO_BACKLIGHT_PWM1 1
2929
2930static int pmic_backlight_gpio[2]
2931 = { GPIO_BACKLIGHT_PWM0, GPIO_BACKLIGHT_PWM1 };
2932static struct msm_panel_common_pdata lcdc_samsung_panel_data = {
2933 .gpio_num = pmic_backlight_gpio, /* two LPG CHANNELS for backlight */
2934 .vga_switch = vga_enable_request,
2935};
2936
2937static struct platform_device lcdc_samsung_panel_device = {
2938 .name = LCDC_SAMSUNG_WSVGA_PANEL_NAME,
2939 .id = 0,
2940 .dev = {
2941 .platform_data = &lcdc_samsung_panel_data,
2942 }
2943};
2944#if (!defined(CONFIG_SPI_QUP)) && \
2945 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
2946 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA))
2947
2948static int lcdc_spi_gpio_array_num[] = {
2949 LCDC_SPI_GPIO_CLK,
2950 LCDC_SPI_GPIO_CS,
2951 LCDC_SPI_GPIO_MOSI,
2952};
2953
2954static uint32_t lcdc_spi_gpio_config_data[] = {
2955 GPIO_CFG(LCDC_SPI_GPIO_CLK, 0,
2956 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2957 GPIO_CFG(LCDC_SPI_GPIO_CS, 0,
2958 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2959 GPIO_CFG(LCDC_SPI_GPIO_MOSI, 0,
2960 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2961};
2962
2963static void lcdc_config_spi_gpios(int enable)
2964{
2965 int n;
2966 for (n = 0; n < ARRAY_SIZE(lcdc_spi_gpio_config_data); ++n)
2967 gpio_tlmm_config(lcdc_spi_gpio_config_data[n], 0);
2968}
2969#endif
2970
2971#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
2972#ifdef CONFIG_SPI_QUP
2973static struct spi_board_info lcdc_samsung_spi_board_info[] __initdata = {
2974 {
2975 .modalias = LCDC_SAMSUNG_SPI_DEVICE_NAME,
2976 .mode = SPI_MODE_3,
2977 .bus_num = 1,
2978 .chip_select = 0,
2979 .max_speed_hz = 10800000,
2980 }
2981};
2982#endif /* CONFIG_SPI_QUP */
2983
2984static struct msm_panel_common_pdata lcdc_samsung_oled_panel_data = {
2985#ifndef CONFIG_SPI_QUP
2986 .panel_config_gpio = lcdc_config_spi_gpios,
2987 .gpio_num = lcdc_spi_gpio_array_num,
2988#endif
2989};
2990
2991static struct platform_device lcdc_samsung_oled_panel_device = {
2992 .name = LCDC_SAMSUNG_OLED_PANEL_NAME,
2993 .id = 0,
2994 .dev.platform_data = &lcdc_samsung_oled_panel_data,
2995};
2996#endif /*CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT */
2997
2998#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
2999#ifdef CONFIG_SPI_QUP
3000static struct spi_board_info lcdc_auo_spi_board_info[] __initdata = {
3001 {
3002 .modalias = LCDC_AUO_SPI_DEVICE_NAME,
3003 .mode = SPI_MODE_3,
3004 .bus_num = 1,
3005 .chip_select = 0,
3006 .max_speed_hz = 10800000,
3007 }
3008};
3009#endif
3010
3011static struct msm_panel_common_pdata lcdc_auo_wvga_panel_data = {
3012#ifndef CONFIG_SPI_QUP
3013 .panel_config_gpio = lcdc_config_spi_gpios,
3014 .gpio_num = lcdc_spi_gpio_array_num,
3015#endif
3016};
3017
3018static struct platform_device lcdc_auo_wvga_panel_device = {
3019 .name = LCDC_AUO_PANEL_NAME,
3020 .id = 0,
3021 .dev.platform_data = &lcdc_auo_wvga_panel_data,
3022};
3023#endif /*CONFIG_FB_MSM_LCDC_AUO_WVGA*/
3024
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04003025#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
3026
3027#define GPIO_NT35582_RESET 94
3028#define GPIO_NT35582_BL_EN_HW_PIN 24
3029#define GPIO_NT35582_BL_EN \
3030 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1)
3031
3032static int lcdc_nt35582_pmic_gpio[] = {GPIO_NT35582_BL_EN };
3033
3034static struct msm_panel_common_pdata lcdc_nt35582_panel_data = {
3035 .gpio_num = lcdc_nt35582_pmic_gpio,
3036};
3037
3038static struct platform_device lcdc_nt35582_panel_device = {
3039 .name = LCDC_NT35582_PANEL_NAME,
3040 .id = 0,
3041 .dev = {
3042 .platform_data = &lcdc_nt35582_panel_data,
3043 }
3044};
3045
3046static struct spi_board_info lcdc_nt35582_spi_board_info[] __initdata = {
3047 {
3048 .modalias = "lcdc_nt35582_spi",
3049 .mode = SPI_MODE_0,
3050 .bus_num = 0,
3051 .chip_select = 0,
3052 .max_speed_hz = 1100000,
3053 }
3054};
3055#endif
3056
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003057#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
3058static struct resource hdmi_msm_resources[] = {
3059 {
3060 .name = "hdmi_msm_qfprom_addr",
3061 .start = 0x00700000,
3062 .end = 0x007060FF,
3063 .flags = IORESOURCE_MEM,
3064 },
3065 {
3066 .name = "hdmi_msm_hdmi_addr",
3067 .start = 0x04A00000,
3068 .end = 0x04A00FFF,
3069 .flags = IORESOURCE_MEM,
3070 },
3071 {
3072 .name = "hdmi_msm_irq",
3073 .start = HDMI_IRQ,
3074 .end = HDMI_IRQ,
3075 .flags = IORESOURCE_IRQ,
3076 },
3077};
3078
3079static int hdmi_enable_5v(int on);
3080static int hdmi_core_power(int on, int show);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05303081static int hdmi_gpio_config(int on);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003082static int hdmi_cec_power(int on);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05303083static int hdmi_panel_power(int on);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003084
3085static struct msm_hdmi_platform_data hdmi_msm_data = {
3086 .irq = HDMI_IRQ,
3087 .enable_5v = hdmi_enable_5v,
3088 .core_power = hdmi_core_power,
3089 .cec_power = hdmi_cec_power,
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05303090 .panel_power = hdmi_panel_power,
3091 .gpio_config = hdmi_gpio_config,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003092};
3093
3094static struct platform_device hdmi_msm_device = {
3095 .name = "hdmi_msm",
3096 .id = 0,
3097 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
3098 .resource = hdmi_msm_resources,
3099 .dev.platform_data = &hdmi_msm_data,
3100};
3101#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
3102
3103#ifdef CONFIG_FB_MSM_MIPI_DSI
3104static struct platform_device mipi_dsi_toshiba_panel_device = {
3105 .name = "mipi_toshiba",
3106 .id = 0,
3107};
3108
3109#define FPGA_3D_GPIO_CONFIG_ADDR 0x1D00017A
3110
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07003111static struct mipi_dsi_panel_platform_data novatek_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003112 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
Chandan Uddaraju83eac3c2011-09-11 18:32:23 -07003113 .fpga_ctrl_mode = FPGA_EBI2_INTF,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003114};
3115
3116static struct platform_device mipi_dsi_novatek_panel_device = {
3117 .name = "mipi_novatek",
3118 .id = 0,
3119 .dev = {
3120 .platform_data = &novatek_pdata,
3121 }
3122};
3123#endif
3124
3125static void __init msm8x60_allocate_memory_regions(void)
3126{
3127 void *addr;
3128 unsigned long size;
3129
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003130 if (hdmi_is_primary)
3131 size = roundup((1920 * 1088 * 4 * 2), 4096);
3132 else
3133 size = MSM_FB_SIZE;
3134
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003135 addr = alloc_bootmem_align(size, 0x1000);
3136 msm_fb_resources[0].start = __pa(addr);
3137 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
3138 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
3139 size, addr, __pa(addr));
3140
3141}
3142
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003143void __init msm8x60_set_display_params(char *prim_panel, char *ext_panel)
3144{
3145 if (strnlen(prim_panel, PANEL_NAME_MAX_LEN)) {
3146 strlcpy(msm_fb_pdata.prim_panel_name, prim_panel,
3147 PANEL_NAME_MAX_LEN);
3148 pr_debug("msm_fb_pdata.prim_panel_name %s\n",
3149 msm_fb_pdata.prim_panel_name);
3150
3151 if (!strncmp((char *)msm_fb_pdata.prim_panel_name,
3152 HDMI_PANEL_NAME, strnlen(HDMI_PANEL_NAME,
3153 PANEL_NAME_MAX_LEN))) {
3154 pr_debug("HDMI is the primary display by"
3155 " boot parameter\n");
3156 hdmi_is_primary = 1;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07003157 set_mdp_clocks_for_wuxga();
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08003158 }
3159 }
3160 if (strnlen(ext_panel, PANEL_NAME_MAX_LEN)) {
3161 strlcpy(msm_fb_pdata.ext_panel_name, ext_panel,
3162 PANEL_NAME_MAX_LEN);
3163 pr_debug("msm_fb_pdata.ext_panel_name %s\n",
3164 msm_fb_pdata.ext_panel_name);
3165 }
3166}
3167
Steve Mucklef132c6c2012-06-06 18:30:57 -07003168#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
3169 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003170/*virtual key support */
3171static ssize_t tma300_vkeys_show(struct kobject *kobj,
3172 struct kobj_attribute *attr, char *buf)
3173{
3174 return sprintf(buf,
3175 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":60:900:90:120"
3176 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":180:900:90:120"
3177 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":300:900:90:120"
3178 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":420:900:90:120"
3179 "\n");
3180}
3181
3182static struct kobj_attribute tma300_vkeys_attr = {
3183 .attr = {
3184 .mode = S_IRUGO,
3185 },
3186 .show = &tma300_vkeys_show,
3187};
3188
3189static struct attribute *tma300_properties_attrs[] = {
3190 &tma300_vkeys_attr.attr,
3191 NULL
3192};
3193
3194static struct attribute_group tma300_properties_attr_group = {
3195 .attrs = tma300_properties_attrs,
3196};
3197
3198static struct kobject *properties_kobj;
3199
3200
3201
3202#define CYTTSP_TS_GPIO_IRQ 61
3203static int cyttsp_platform_init(struct i2c_client *client)
3204{
3205 int rc = -EINVAL;
3206 struct regulator *pm8058_l5 = NULL, *pm8058_s3;
3207
3208 if (machine_is_msm8x60_fluid()) {
3209 pm8058_l5 = regulator_get(NULL, "8058_l5");
3210 if (IS_ERR(pm8058_l5)) {
3211 pr_err("%s: regulator get of 8058_l5 failed (%ld)\n",
3212 __func__, PTR_ERR(pm8058_l5));
3213 rc = PTR_ERR(pm8058_l5);
3214 return rc;
3215 }
3216 rc = regulator_set_voltage(pm8058_l5, 2850000, 2850000);
3217 if (rc) {
3218 pr_err("%s: regulator_set_voltage of 8058_l5 failed(%d)\n",
3219 __func__, rc);
3220 goto reg_l5_put;
3221 }
3222
3223 rc = regulator_enable(pm8058_l5);
3224 if (rc) {
3225 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3226 __func__, rc);
3227 goto reg_l5_put;
3228 }
3229 }
3230 /* vote for s3 to enable i2c communication lines */
3231 pm8058_s3 = regulator_get(NULL, "8058_s3");
3232 if (IS_ERR(pm8058_s3)) {
3233 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3234 __func__, PTR_ERR(pm8058_s3));
3235 rc = PTR_ERR(pm8058_s3);
3236 goto reg_l5_disable;
3237 }
3238
3239 rc = regulator_set_voltage(pm8058_s3, 1800000, 1800000);
3240 if (rc) {
3241 pr_err("%s: regulator_set_voltage() = %d\n",
3242 __func__, rc);
3243 goto reg_s3_put;
3244 }
3245
3246 rc = regulator_enable(pm8058_s3);
3247 if (rc) {
3248 pr_err("%s: regulator_enable of 8058_l5 failed(%d)\n",
3249 __func__, rc);
3250 goto reg_s3_put;
3251 }
3252
3253 /* wait for vregs to stabilize */
3254 usleep_range(10000, 10000);
3255
3256 /* check this device active by reading first byte/register */
3257 rc = i2c_smbus_read_byte_data(client, 0x01);
3258 if (rc < 0) {
3259 pr_err("%s: i2c sanity check failed\n", __func__);
3260 goto reg_s3_disable;
3261 }
3262
3263 /* virtual keys */
3264 if (machine_is_msm8x60_fluid()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003265 properties_kobj = kobject_create_and_add("board_properties",
3266 NULL);
Steve Mucklef132c6c2012-06-06 18:30:57 -07003267 if (properties_kobj);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003268 if (!properties_kobj || rc)
3269 pr_err("%s: failed to create board_properties\n",
3270 __func__);
3271 }
3272 return CY_OK;
3273
3274reg_s3_disable:
3275 regulator_disable(pm8058_s3);
3276reg_s3_put:
3277 regulator_put(pm8058_s3);
3278reg_l5_disable:
3279 if (machine_is_msm8x60_fluid())
3280 regulator_disable(pm8058_l5);
3281reg_l5_put:
3282 if (machine_is_msm8x60_fluid())
3283 regulator_put(pm8058_l5);
3284 return rc;
3285}
3286
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303287/* TODO: Put the regulator to LPM / HPM in suspend/resume*/
3288static int cyttsp_platform_suspend(struct i2c_client *client)
3289{
3290 msleep(20);
3291
3292 return CY_OK;
3293}
3294
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003295static int cyttsp_platform_resume(struct i2c_client *client)
3296{
3297 /* add any special code to strobe a wakeup pin or chip reset */
3298 msleep(10);
3299
3300 return CY_OK;
3301}
3302
3303static struct cyttsp_platform_data cyttsp_fluid_pdata = {
3304 .flags = 0x04,
3305 .gen = CY_GEN3, /* or */
3306 .use_st = CY_USE_ST,
3307 .use_mt = CY_USE_MT,
3308 .use_hndshk = CY_SEND_HNDSHK,
3309 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303310 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003311 .use_gestures = CY_USE_GESTURES,
3312 /* activate up to 4 groups
3313 * and set active distance
3314 */
3315 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3316 CY_GEST_GRP3 | CY_GEST_GRP4 |
3317 CY_ACT_DIST,
3318 /* change act_intrvl to customize the Active power state
3319 * scanning/processing refresh interval for Operating mode
3320 */
3321 .act_intrvl = CY_ACT_INTRVL_DFLT,
3322 /* change tch_tmout to customize the touch timeout for the
3323 * Active power state for Operating mode
3324 */
3325 .tch_tmout = CY_TCH_TMOUT_DFLT,
3326 /* change lp_intrvl to customize the Low Power power state
3327 * scanning/processing refresh interval for Operating mode
3328 */
3329 .lp_intrvl = CY_LP_INTRVL_DFLT,
3330 .sleep_gpio = -1,
3331 .resout_gpio = -1,
3332 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3333 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303334 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003335 .init = cyttsp_platform_init,
3336};
3337
3338static struct cyttsp_platform_data cyttsp_tmg240_pdata = {
3339 .panel_maxx = 1083,
3340 .panel_maxy = 659,
3341 .disp_minx = 30,
3342 .disp_maxx = 1053,
3343 .disp_miny = 30,
3344 .disp_maxy = 629,
3345 .correct_fw_ver = 8,
3346 .fw_fname = "cyttsp_8660_ffa.hex",
3347 .flags = 0x00,
3348 .gen = CY_GEN2, /* or */
3349 .use_st = CY_USE_ST,
3350 .use_mt = CY_USE_MT,
3351 .use_hndshk = CY_SEND_HNDSHK,
3352 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +05303353 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003354 .use_gestures = CY_USE_GESTURES,
3355 /* activate up to 4 groups
3356 * and set active distance
3357 */
3358 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3359 CY_GEST_GRP3 | CY_GEST_GRP4 |
3360 CY_ACT_DIST,
3361 /* change act_intrvl to customize the Active power state
3362 * scanning/processing refresh interval for Operating mode
3363 */
3364 .act_intrvl = CY_ACT_INTRVL_DFLT,
3365 /* change tch_tmout to customize the touch timeout for the
3366 * Active power state for Operating mode
3367 */
3368 .tch_tmout = CY_TCH_TMOUT_DFLT,
3369 /* change lp_intrvl to customize the Low Power power state
3370 * scanning/processing refresh interval for Operating mode
3371 */
3372 .lp_intrvl = CY_LP_INTRVL_DFLT,
3373 .sleep_gpio = -1,
3374 .resout_gpio = -1,
3375 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3376 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +05303377 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003378 .init = cyttsp_platform_init,
Mohan Pallaka1ea7d8a2011-08-18 15:06:00 +05303379 .disable_ghost_det = true,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003380};
3381static void cyttsp_set_params(void)
3382{
3383 if (SOCINFO_VERSION_MAJOR(socinfo_get_platform_version()) < 3) {
3384 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p2.hex";
3385 cyttsp_fluid_pdata.panel_maxx = 539;
3386 cyttsp_fluid_pdata.panel_maxy = 994;
3387 cyttsp_fluid_pdata.disp_minx = 30;
3388 cyttsp_fluid_pdata.disp_maxx = 509;
3389 cyttsp_fluid_pdata.disp_miny = 60;
3390 cyttsp_fluid_pdata.disp_maxy = 859;
3391 cyttsp_fluid_pdata.correct_fw_ver = 4;
3392 } else {
3393 cyttsp_fluid_pdata.fw_fname = "cyttsp_8660_fluid_p3.hex";
3394 cyttsp_fluid_pdata.panel_maxx = 550;
3395 cyttsp_fluid_pdata.panel_maxy = 1013;
3396 cyttsp_fluid_pdata.disp_minx = 35;
3397 cyttsp_fluid_pdata.disp_maxx = 515;
3398 cyttsp_fluid_pdata.disp_miny = 69;
3399 cyttsp_fluid_pdata.disp_maxy = 869;
3400 cyttsp_fluid_pdata.correct_fw_ver = 5;
3401 }
3402
3403}
3404
3405static struct i2c_board_info cyttsp_fluid_info[] __initdata = {
3406 {
3407 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
3408 .platform_data = &cyttsp_fluid_pdata,
3409#ifndef CY_USE_TIMER
3410 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3411#endif /* CY_USE_TIMER */
3412 },
3413};
3414
3415static struct i2c_board_info cyttsp_ffa_info[] __initdata = {
3416 {
3417 I2C_BOARD_INFO(CY_I2C_NAME, 0x3b),
3418 .platform_data = &cyttsp_tmg240_pdata,
3419#ifndef CY_USE_TIMER
3420 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3421#endif /* CY_USE_TIMER */
3422 },
3423};
3424#endif
3425
3426static struct regulator *vreg_tmg200;
3427
3428#define TS_PEN_IRQ_GPIO 61
3429static int tmg200_power(int vreg_on)
3430{
3431 int rc = -EINVAL;
3432
3433 if (!vreg_tmg200) {
3434 printk(KERN_ERR "%s: regulator 8058_s3 not found (%d)\n",
3435 __func__, rc);
3436 return rc;
3437 }
3438
3439 rc = vreg_on ? regulator_enable(vreg_tmg200) :
3440 regulator_disable(vreg_tmg200);
3441 if (rc < 0)
3442 printk(KERN_ERR "%s: vreg 8058_s3 %s failed (%d)\n",
3443 __func__, vreg_on ? "enable" : "disable", rc);
3444
3445 /* wait for vregs to stabilize */
Amy Maloche12b5d4e2011-08-03 15:42:28 -07003446 msleep(20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003447
3448 return rc;
3449}
3450
3451static int tmg200_dev_setup(bool enable)
3452{
3453 int rc;
3454
3455 if (enable) {
3456 vreg_tmg200 = regulator_get(NULL, "8058_s3");
3457 if (IS_ERR(vreg_tmg200)) {
3458 pr_err("%s: regulator get of 8058_s3 failed (%ld)\n",
3459 __func__, PTR_ERR(vreg_tmg200));
3460 rc = PTR_ERR(vreg_tmg200);
3461 return rc;
3462 }
3463
3464 rc = regulator_set_voltage(vreg_tmg200, 1800000, 1800000);
3465 if (rc) {
3466 pr_err("%s: regulator_set_voltage() = %d\n",
3467 __func__, rc);
3468 goto reg_put;
3469 }
3470 } else {
3471 /* put voltage sources */
3472 regulator_put(vreg_tmg200);
3473 }
3474 return 0;
3475reg_put:
3476 regulator_put(vreg_tmg200);
3477 return rc;
3478}
3479
3480static struct cy8c_ts_platform_data cy8ctmg200_pdata = {
3481 .ts_name = "msm_tmg200_ts",
3482 .dis_min_x = 0,
3483 .dis_max_x = 1023,
3484 .dis_min_y = 0,
3485 .dis_max_y = 599,
3486 .min_tid = 0,
3487 .max_tid = 255,
3488 .min_touch = 0,
3489 .max_touch = 255,
3490 .min_width = 0,
3491 .max_width = 255,
3492 .power_on = tmg200_power,
3493 .dev_setup = tmg200_dev_setup,
3494 .nfingers = 2,
3495 .irq_gpio = TS_PEN_IRQ_GPIO,
3496 .resout_gpio = GPIO_CAP_TS_RESOUT_N,
3497};
3498
3499static struct i2c_board_info cy8ctmg200_board_info[] = {
3500 {
3501 I2C_BOARD_INFO("cy8ctmg200", 0x2),
3502 .platform_data = &cy8ctmg200_pdata,
3503 }
3504};
3505
Zhang Chang Ken211df572011-07-05 19:16:39 -04003506static struct regulator *vreg_tma340;
3507
3508static int tma340_power(int vreg_on)
3509{
3510 int rc = -EINVAL;
3511
3512 if (!vreg_tma340) {
3513 pr_err("%s: regulator 8901_l2 not found (%d)\n",
3514 __func__, rc);
3515 return rc;
3516 }
3517
3518 rc = vreg_on ? regulator_enable(vreg_tma340) :
3519 regulator_disable(vreg_tma340);
3520 if (rc < 0)
3521 pr_err("%s: vreg 8901_l2 %s failed (%d)\n",
3522 __func__, vreg_on ? "enable" : "disable", rc);
3523
3524 /* wait for vregs to stabilize */
Amy Malocheb5c67e8d2011-08-18 16:39:35 -07003525 msleep(100);
Zhang Chang Ken211df572011-07-05 19:16:39 -04003526
3527 return rc;
3528}
3529
3530static struct kobject *tma340_prop_kobj;
3531
3532static int tma340_dragon_dev_setup(bool enable)
3533{
3534 int rc;
3535
3536 if (enable) {
3537 vreg_tma340 = regulator_get(NULL, "8901_l2");
3538 if (IS_ERR(vreg_tma340)) {
3539 pr_err("%s: regulator get of 8901_l2 failed (%ld)\n",
3540 __func__, PTR_ERR(vreg_tma340));
3541 rc = PTR_ERR(vreg_tma340);
3542 return rc;
3543 }
3544
3545 rc = regulator_set_voltage(vreg_tma340, 3300000, 3300000);
3546 if (rc) {
3547 pr_err("%s: regulator_set_voltage() = %d\n",
3548 __func__, rc);
3549 goto reg_put;
3550 }
Zhang Chang Ken211df572011-07-05 19:16:39 -04003551 tma340_prop_kobj = kobject_create_and_add("board_properties",
3552 NULL);
3553 if (tma340_prop_kobj) {
Steve Mucklef132c6c2012-06-06 18:30:57 -07003554 ;
Zhang Chang Ken211df572011-07-05 19:16:39 -04003555 if (rc) {
3556 kobject_put(tma340_prop_kobj);
3557 pr_err("%s: failed to create board_properties\n",
3558 __func__);
3559 goto reg_put;
3560 }
3561 }
3562
3563 } else {
3564 /* put voltage sources */
3565 regulator_put(vreg_tma340);
3566 /* destroy virtual keys */
3567 if (tma340_prop_kobj) {
Zhang Chang Ken211df572011-07-05 19:16:39 -04003568 kobject_put(tma340_prop_kobj);
3569 }
3570 }
3571 return 0;
3572reg_put:
3573 regulator_put(vreg_tma340);
3574 return rc;
3575}
3576
3577
3578static struct cy8c_ts_platform_data cy8ctma340_dragon_pdata = {
3579 .ts_name = "cy8ctma340",
3580 .dis_min_x = 0,
3581 .dis_max_x = 479,
3582 .dis_min_y = 0,
3583 .dis_max_y = 799,
3584 .min_tid = 0,
3585 .max_tid = 255,
3586 .min_touch = 0,
3587 .max_touch = 255,
3588 .min_width = 0,
3589 .max_width = 255,
3590 .power_on = tma340_power,
3591 .dev_setup = tma340_dragon_dev_setup,
3592 .nfingers = 2,
3593 .irq_gpio = TS_PEN_IRQ_GPIO,
3594 .resout_gpio = -1,
3595};
3596
3597static struct i2c_board_info cy8ctma340_dragon_board_info[] = {
3598 {
3599 I2C_BOARD_INFO("cy8ctma340", 0x24),
3600 .platform_data = &cy8ctma340_dragon_pdata,
3601 }
3602};
3603
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003604#ifdef CONFIG_SERIAL_MSM_HS
3605static int configure_uart_gpios(int on)
3606{
3607 int ret = 0, i;
3608 int uart_gpios[] = {53, 54, 55, 56};
3609 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
3610 if (on) {
3611 ret = msm_gpiomux_get(uart_gpios[i]);
3612 if (unlikely(ret))
3613 break;
3614 } else {
3615 ret = msm_gpiomux_put(uart_gpios[i]);
3616 if (unlikely(ret))
3617 return ret;
3618 }
3619 }
3620 if (ret)
3621 for (; i >= 0; i--)
3622 msm_gpiomux_put(uart_gpios[i]);
3623 return ret;
3624}
3625static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3626 .inject_rx_on_wakeup = 1,
3627 .rx_to_inject = 0xFD,
3628 .gpio_config = configure_uart_gpios,
3629};
3630#endif
3631
3632
3633#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
3634
3635static struct gpio_led gpio_exp_leds_config[] = {
3636 {
3637 .name = "left_led1:green",
3638 .gpio = GPIO_LEFT_LED_1,
3639 .active_low = 1,
3640 .retain_state_suspended = 0,
3641 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3642 },
3643 {
3644 .name = "left_led2:red",
3645 .gpio = GPIO_LEFT_LED_2,
3646 .active_low = 1,
3647 .retain_state_suspended = 0,
3648 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3649 },
3650 {
3651 .name = "left_led3:green",
3652 .gpio = GPIO_LEFT_LED_3,
3653 .active_low = 1,
3654 .retain_state_suspended = 0,
3655 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3656 },
3657 {
3658 .name = "wlan_led:orange",
3659 .gpio = GPIO_LEFT_LED_WLAN,
3660 .active_low = 1,
3661 .retain_state_suspended = 0,
3662 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3663 },
3664 {
3665 .name = "left_led5:green",
3666 .gpio = GPIO_LEFT_LED_5,
3667 .active_low = 1,
3668 .retain_state_suspended = 0,
3669 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3670 },
3671 {
3672 .name = "right_led1:green",
3673 .gpio = GPIO_RIGHT_LED_1,
3674 .active_low = 1,
3675 .retain_state_suspended = 0,
3676 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3677 },
3678 {
3679 .name = "right_led2:red",
3680 .gpio = GPIO_RIGHT_LED_2,
3681 .active_low = 1,
3682 .retain_state_suspended = 0,
3683 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3684 },
3685 {
3686 .name = "right_led3:green",
3687 .gpio = GPIO_RIGHT_LED_3,
3688 .active_low = 1,
3689 .retain_state_suspended = 0,
3690 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3691 },
3692 {
3693 .name = "bt_led:blue",
3694 .gpio = GPIO_RIGHT_LED_BT,
3695 .active_low = 1,
3696 .retain_state_suspended = 0,
3697 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3698 },
3699 {
3700 .name = "right_led5:green",
3701 .gpio = GPIO_RIGHT_LED_5,
3702 .active_low = 1,
3703 .retain_state_suspended = 0,
3704 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3705 },
3706};
3707
3708static struct gpio_led_platform_data gpio_leds_pdata = {
3709 .num_leds = ARRAY_SIZE(gpio_exp_leds_config),
3710 .leds = gpio_exp_leds_config,
3711};
3712
3713static struct platform_device gpio_leds = {
3714 .name = "leds-gpio",
3715 .id = -1,
3716 .dev = {
3717 .platform_data = &gpio_leds_pdata,
3718 },
3719};
3720
3721static struct gpio_led fluid_gpio_leds[] = {
3722 {
3723 .name = "dual_led:green",
3724 .gpio = GPIO_LED1_GREEN_N,
3725 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3726 .active_low = 1,
3727 .retain_state_suspended = 0,
3728 },
3729 {
3730 .name = "dual_led:red",
3731 .gpio = GPIO_LED2_RED_N,
3732 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3733 .active_low = 1,
3734 .retain_state_suspended = 0,
3735 },
3736};
3737
3738static struct gpio_led_platform_data gpio_led_pdata = {
3739 .leds = fluid_gpio_leds,
3740 .num_leds = ARRAY_SIZE(fluid_gpio_leds),
3741};
3742
3743static struct platform_device fluid_leds_gpio = {
3744 .name = "leds-gpio",
3745 .id = -1,
3746 .dev = {
3747 .platform_data = &gpio_led_pdata,
3748 },
3749};
3750
3751#endif
3752
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003753#ifdef CONFIG_BATTERY_MSM8X60
3754static struct msm_charger_platform_data msm_charger_data = {
3755 .safety_time = 180,
3756 .update_time = 1,
3757 .max_voltage = 4200,
3758 .min_voltage = 3200,
3759};
3760
3761static struct platform_device msm_charger_device = {
3762 .name = "msm-charger",
3763 .id = -1,
3764 .dev = {
3765 .platform_data = &msm_charger_data,
3766 }
3767};
3768#endif
3769
3770/*
3771 * Consumer specific regulator names:
3772 * regulator name consumer dev_name
3773 */
3774static struct regulator_consumer_supply vreg_consumers_PM8058_L0[] = {
3775 REGULATOR_SUPPLY("8058_l0", NULL),
3776};
3777static struct regulator_consumer_supply vreg_consumers_PM8058_L1[] = {
3778 REGULATOR_SUPPLY("8058_l1", NULL),
3779};
3780static struct regulator_consumer_supply vreg_consumers_PM8058_L2[] = {
3781 REGULATOR_SUPPLY("8058_l2", NULL),
3782};
3783static struct regulator_consumer_supply vreg_consumers_PM8058_L3[] = {
3784 REGULATOR_SUPPLY("8058_l3", NULL),
3785};
3786static struct regulator_consumer_supply vreg_consumers_PM8058_L4[] = {
3787 REGULATOR_SUPPLY("8058_l4", NULL),
3788};
3789static struct regulator_consumer_supply vreg_consumers_PM8058_L5[] = {
3790 REGULATOR_SUPPLY("8058_l5", NULL),
3791};
3792static struct regulator_consumer_supply vreg_consumers_PM8058_L6[] = {
3793 REGULATOR_SUPPLY("8058_l6", NULL),
3794};
3795static struct regulator_consumer_supply vreg_consumers_PM8058_L7[] = {
3796 REGULATOR_SUPPLY("8058_l7", NULL),
3797};
3798static struct regulator_consumer_supply vreg_consumers_PM8058_L8[] = {
3799 REGULATOR_SUPPLY("8058_l8", NULL),
3800};
3801static struct regulator_consumer_supply vreg_consumers_PM8058_L9[] = {
3802 REGULATOR_SUPPLY("8058_l9", NULL),
3803};
3804static struct regulator_consumer_supply vreg_consumers_PM8058_L10[] = {
3805 REGULATOR_SUPPLY("8058_l10", NULL),
3806};
3807static struct regulator_consumer_supply vreg_consumers_PM8058_L11[] = {
3808 REGULATOR_SUPPLY("8058_l11", NULL),
3809};
3810static struct regulator_consumer_supply vreg_consumers_PM8058_L12[] = {
3811 REGULATOR_SUPPLY("8058_l12", NULL),
3812};
3813static struct regulator_consumer_supply vreg_consumers_PM8058_L13[] = {
3814 REGULATOR_SUPPLY("8058_l13", NULL),
3815};
3816static struct regulator_consumer_supply vreg_consumers_PM8058_L14[] = {
3817 REGULATOR_SUPPLY("8058_l14", NULL),
3818};
3819static struct regulator_consumer_supply vreg_consumers_PM8058_L15[] = {
3820 REGULATOR_SUPPLY("8058_l15", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003821 REGULATOR_SUPPLY("cam_vana", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003822 REGULATOR_SUPPLY("cam_vana", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003823 REGULATOR_SUPPLY("cam_vana", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003824};
3825static struct regulator_consumer_supply vreg_consumers_PM8058_L16[] = {
3826 REGULATOR_SUPPLY("8058_l16", NULL),
3827};
3828static struct regulator_consumer_supply vreg_consumers_PM8058_L17[] = {
3829 REGULATOR_SUPPLY("8058_l17", NULL),
3830};
3831static struct regulator_consumer_supply vreg_consumers_PM8058_L18[] = {
3832 REGULATOR_SUPPLY("8058_l18", NULL),
3833};
3834static struct regulator_consumer_supply vreg_consumers_PM8058_L19[] = {
3835 REGULATOR_SUPPLY("8058_l19", NULL),
3836};
3837static struct regulator_consumer_supply vreg_consumers_PM8058_L20[] = {
3838 REGULATOR_SUPPLY("8058_l20", NULL),
3839};
3840static struct regulator_consumer_supply vreg_consumers_PM8058_L21[] = {
3841 REGULATOR_SUPPLY("8058_l21", NULL),
3842};
3843static struct regulator_consumer_supply vreg_consumers_PM8058_L22[] = {
3844 REGULATOR_SUPPLY("8058_l22", NULL),
3845};
3846static struct regulator_consumer_supply vreg_consumers_PM8058_L23[] = {
3847 REGULATOR_SUPPLY("8058_l23", NULL),
3848};
3849static struct regulator_consumer_supply vreg_consumers_PM8058_L24[] = {
3850 REGULATOR_SUPPLY("8058_l24", NULL),
3851};
3852static struct regulator_consumer_supply vreg_consumers_PM8058_L25[] = {
3853 REGULATOR_SUPPLY("8058_l25", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003854 REGULATOR_SUPPLY("cam_vdig", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003855 REGULATOR_SUPPLY("cam_vdig", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003856 REGULATOR_SUPPLY("cam_vdig", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003857};
3858static struct regulator_consumer_supply vreg_consumers_PM8058_S0[] = {
3859 REGULATOR_SUPPLY("8058_s0", NULL),
3860};
3861static struct regulator_consumer_supply vreg_consumers_PM8058_S1[] = {
3862 REGULATOR_SUPPLY("8058_s1", NULL),
3863};
3864static struct regulator_consumer_supply vreg_consumers_PM8058_S2[] = {
3865 REGULATOR_SUPPLY("8058_s2", NULL),
3866};
3867static struct regulator_consumer_supply vreg_consumers_PM8058_S3[] = {
3868 REGULATOR_SUPPLY("8058_s3", NULL),
3869};
3870static struct regulator_consumer_supply vreg_consumers_PM8058_S4[] = {
3871 REGULATOR_SUPPLY("8058_s4", NULL),
3872};
3873static struct regulator_consumer_supply vreg_consumers_PM8058_LVS0[] = {
3874 REGULATOR_SUPPLY("8058_lvs0", NULL),
Kevin Chan3be11612012-03-22 20:05:40 -07003875 REGULATOR_SUPPLY("cam_vio", "1-001a"),
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -07003876 REGULATOR_SUPPLY("cam_vio", "1-006c"),
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -07003877 REGULATOR_SUPPLY("cam_vio", "1-0078"),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003878};
3879static struct regulator_consumer_supply vreg_consumers_PM8058_LVS1[] = {
3880 REGULATOR_SUPPLY("8058_lvs1", NULL),
3881};
3882static struct regulator_consumer_supply vreg_consumers_PM8058_NCP[] = {
3883 REGULATOR_SUPPLY("8058_ncp", NULL),
3884};
3885
3886static struct regulator_consumer_supply vreg_consumers_PM8901_L0[] = {
3887 REGULATOR_SUPPLY("8901_l0", NULL),
3888};
3889static struct regulator_consumer_supply vreg_consumers_PM8901_L1[] = {
3890 REGULATOR_SUPPLY("8901_l1", NULL),
3891};
3892static struct regulator_consumer_supply vreg_consumers_PM8901_L2[] = {
3893 REGULATOR_SUPPLY("8901_l2", NULL),
3894};
3895static struct regulator_consumer_supply vreg_consumers_PM8901_L3[] = {
3896 REGULATOR_SUPPLY("8901_l3", NULL),
3897};
3898static struct regulator_consumer_supply vreg_consumers_PM8901_L4[] = {
3899 REGULATOR_SUPPLY("8901_l4", NULL),
3900};
3901static struct regulator_consumer_supply vreg_consumers_PM8901_L5[] = {
3902 REGULATOR_SUPPLY("8901_l5", NULL),
3903};
3904static struct regulator_consumer_supply vreg_consumers_PM8901_L6[] = {
3905 REGULATOR_SUPPLY("8901_l6", NULL),
3906};
3907static struct regulator_consumer_supply vreg_consumers_PM8901_S2[] = {
3908 REGULATOR_SUPPLY("8901_s2", NULL),
3909};
3910static struct regulator_consumer_supply vreg_consumers_PM8901_S3[] = {
3911 REGULATOR_SUPPLY("8901_s3", NULL),
3912};
3913static struct regulator_consumer_supply vreg_consumers_PM8901_S4[] = {
3914 REGULATOR_SUPPLY("8901_s4", NULL),
3915};
3916static struct regulator_consumer_supply vreg_consumers_PM8901_LVS0[] = {
3917 REGULATOR_SUPPLY("8901_lvs0", NULL),
3918};
3919static struct regulator_consumer_supply vreg_consumers_PM8901_LVS1[] = {
3920 REGULATOR_SUPPLY("8901_lvs1", NULL),
3921};
3922static struct regulator_consumer_supply vreg_consumers_PM8901_LVS2[] = {
3923 REGULATOR_SUPPLY("8901_lvs2", NULL),
3924};
3925static struct regulator_consumer_supply vreg_consumers_PM8901_LVS3[] = {
3926 REGULATOR_SUPPLY("8901_lvs3", NULL),
3927};
3928static struct regulator_consumer_supply vreg_consumers_PM8901_MVS0[] = {
3929 REGULATOR_SUPPLY("8901_mvs0", NULL),
3930};
3931
David Collins6f032ba2011-08-31 14:08:15 -07003932/* Pin control regulators */
3933static struct regulator_consumer_supply vreg_consumers_PM8058_L8_PC[] = {
3934 REGULATOR_SUPPLY("8058_l8_pc", NULL),
3935};
3936static struct regulator_consumer_supply vreg_consumers_PM8058_L20_PC[] = {
3937 REGULATOR_SUPPLY("8058_l20_pc", NULL),
3938};
3939static struct regulator_consumer_supply vreg_consumers_PM8058_L21_PC[] = {
3940 REGULATOR_SUPPLY("8058_l21_pc", NULL),
3941};
3942static struct regulator_consumer_supply vreg_consumers_PM8058_S2_PC[] = {
3943 REGULATOR_SUPPLY("8058_s2_pc", NULL),
3944};
3945static struct regulator_consumer_supply vreg_consumers_PM8901_L0_PC[] = {
3946 REGULATOR_SUPPLY("8901_l0_pc", NULL),
3947};
3948static struct regulator_consumer_supply vreg_consumers_PM8901_S4_PC[] = {
3949 REGULATOR_SUPPLY("8901_s4_pc", NULL),
3950};
3951
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003952#define RPM_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
3953 _default_uV, _peak_uA, _avg_uA, _pull_down, _pin_ctrl, \
David Collins15789042012-03-19 10:44:36 -07003954 _freq, _pin_fn, _force_mode, _sleep_set_force_mode, \
3955 _state, _sleep_selectable, _always_on) \
David Collins6f032ba2011-08-31 14:08:15 -07003956 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003957 .init_data = { \
3958 .constraints = { \
David Collins6f032ba2011-08-31 14:08:15 -07003959 .valid_modes_mask = _modes, \
3960 .valid_ops_mask = _ops, \
3961 .min_uV = _min_uV, \
3962 .max_uV = _max_uV, \
3963 .input_uV = _min_uV, \
3964 .apply_uV = _apply_uV, \
3965 .always_on = _always_on, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003966 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003967 .consumer_supplies = vreg_consumers_##_id, \
3968 .num_consumer_supplies = \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003969 ARRAY_SIZE(vreg_consumers_##_id), \
3970 }, \
David Collins6f032ba2011-08-31 14:08:15 -07003971 .id = RPM_VREG_ID_##_id, \
3972 .default_uV = _default_uV, \
3973 .peak_uA = _peak_uA, \
3974 .avg_uA = _avg_uA, \
3975 .pull_down_enable = _pull_down, \
3976 .pin_ctrl = _pin_ctrl, \
3977 .freq = RPM_VREG_FREQ_##_freq, \
3978 .pin_fn = _pin_fn, \
3979 .force_mode = _force_mode, \
David Collins15789042012-03-19 10:44:36 -07003980 .sleep_set_force_mode = _sleep_set_force_mode, \
David Collins6f032ba2011-08-31 14:08:15 -07003981 .state = _state, \
3982 .sleep_selectable = _sleep_selectable, \
3983 }
3984
3985/* Pin control initialization */
3986#define RPM_PC(_id, _always_on, _pin_fn, _pin_ctrl) \
3987 { \
3988 .init_data = { \
3989 .constraints = { \
3990 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
3991 .always_on = _always_on, \
3992 }, \
3993 .num_consumer_supplies = \
3994 ARRAY_SIZE(vreg_consumers_##_id##_PC), \
3995 .consumer_supplies = vreg_consumers_##_id##_PC, \
3996 }, \
3997 .id = RPM_VREG_ID_##_id##_PC, \
3998 .pin_fn = RPM_VREG_PIN_FN_8660_##_pin_fn, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003999 .pin_ctrl = _pin_ctrl, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004000 }
4001
4002/*
4003 * The default LPM/HPM state of an RPM controlled regulator can be controlled
4004 * via the peak_uA value specified in the table below. If the value is less
4005 * than the high power min threshold for the regulator, then the regulator will
4006 * be set to LPM. Otherwise, it will be set to HPM.
4007 *
4008 * This value can be further overridden by specifying an initial mode via
4009 * .init_data.constraints.initial_mode.
4010 */
4011
David Collins6f032ba2011-08-31 14:08:15 -07004012#define RPM_LDO(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4013 _init_peak_uA) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004014 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4015 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4016 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4017 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4018 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004019 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4020 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004021 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004022 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004023 _sleep_selectable, _always_on)
4024
David Collins6f032ba2011-08-31 14:08:15 -07004025#define RPM_SMPS(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
4026 _init_peak_uA, _freq) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004027 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
4028 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
4029 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
4030 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
4031 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
David Collins6f032ba2011-08-31 14:08:15 -07004032 _init_peak_uA, _pd, RPM_VREG_PIN_CTRL_NONE, _freq, \
4033 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004034 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004035 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4036 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004037
David Collins6f032ba2011-08-31 14:08:15 -07004038#define RPM_VS(_id, _always_on, _pd, _sleep_selectable) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004039 RPM_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE, \
4040 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE, 0, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004041 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4042 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004043 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004044 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4045 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004046
David Collins6f032ba2011-08-31 14:08:15 -07004047#define RPM_NCP(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004048 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL, \
4049 REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS, 0, \
David Collins6f032ba2011-08-31 14:08:15 -07004050 _min_uV, 1000, 1000, _pd, RPM_VREG_PIN_CTRL_NONE, NONE, \
4051 RPM_VREG_PIN_FN_8660_ENABLE, \
David Collins15789042012-03-19 10:44:36 -07004052 RPM_VREG_FORCE_MODE_8660_NONE, \
David Collins6f032ba2011-08-31 14:08:15 -07004053 RPM_VREG_FORCE_MODE_8660_NONE, RPM_VREG_STATE_OFF, \
4054 _sleep_selectable, _always_on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004055
David Collins6f032ba2011-08-31 14:08:15 -07004056#define LDO50HMIN RPM_VREG_8660_LDO_50_HPM_MIN_LOAD
4057#define LDO150HMIN RPM_VREG_8660_LDO_150_HPM_MIN_LOAD
4058#define LDO300HMIN RPM_VREG_8660_LDO_300_HPM_MIN_LOAD
4059#define SMPS_HMIN RPM_VREG_8660_SMPS_HPM_MIN_LOAD
4060#define FTS_HMIN RPM_VREG_8660_FTSMPS_HPM_MIN_LOAD
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004061
David Collins6f032ba2011-08-31 14:08:15 -07004062/* RPM early regulator constraints */
4063static struct rpm_regulator_init_data rpm_regulator_early_init_data[] = {
4064 /* ID a_on pd ss min_uV max_uV init_ip freq */
Matt Wagantall2ecbec22012-03-13 23:18:07 -07004065 RPM_SMPS(PM8058_S0, 0, 1, 1, 500000, 1325000, SMPS_HMIN, 1p60),
David Collins6f032ba2011-08-31 14:08:15 -07004066 RPM_SMPS(PM8058_S1, 0, 1, 1, 500000, 1250000, SMPS_HMIN, 1p60),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004067};
4068
David Collins6f032ba2011-08-31 14:08:15 -07004069/* RPM regulator constraints */
4070static struct rpm_regulator_init_data rpm_regulator_init_data[] = {
4071 /* ID a_on pd ss min_uV max_uV init_ip */
4072 RPM_LDO(PM8058_L0, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4073 RPM_LDO(PM8058_L1, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4074 RPM_LDO(PM8058_L2, 0, 1, 0, 1800000, 2600000, LDO300HMIN),
4075 RPM_LDO(PM8058_L3, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4076 RPM_LDO(PM8058_L4, 0, 1, 0, 2850000, 2850000, LDO50HMIN),
4077 RPM_LDO(PM8058_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4078 RPM_LDO(PM8058_L6, 0, 1, 0, 3000000, 3600000, LDO50HMIN),
4079 RPM_LDO(PM8058_L7, 0, 1, 0, 1800000, 1800000, LDO50HMIN),
4080 RPM_LDO(PM8058_L8, 0, 1, 0, 2900000, 3050000, LDO300HMIN),
4081 RPM_LDO(PM8058_L9, 0, 1, 0, 1800000, 1800000, LDO300HMIN),
4082 RPM_LDO(PM8058_L10, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4083 RPM_LDO(PM8058_L11, 0, 1, 0, 1500000, 1500000, LDO150HMIN),
4084 RPM_LDO(PM8058_L12, 0, 1, 0, 2900000, 2900000, LDO150HMIN),
4085 RPM_LDO(PM8058_L13, 0, 1, 0, 2050000, 2050000, LDO300HMIN),
4086 RPM_LDO(PM8058_L14, 0, 0, 0, 2850000, 2850000, LDO300HMIN),
4087 RPM_LDO(PM8058_L15, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4088 RPM_LDO(PM8058_L16, 1, 1, 0, 1800000, 1800000, LDO300HMIN),
4089 RPM_LDO(PM8058_L17, 0, 1, 0, 2600000, 2600000, LDO150HMIN),
4090 RPM_LDO(PM8058_L18, 0, 1, 0, 2200000, 2200000, LDO150HMIN),
4091 RPM_LDO(PM8058_L19, 0, 1, 0, 2500000, 2500000, LDO150HMIN),
4092 RPM_LDO(PM8058_L20, 0, 1, 0, 1800000, 1800000, LDO150HMIN),
4093 RPM_LDO(PM8058_L21, 1, 1, 0, 1200000, 1200000, LDO150HMIN),
4094 RPM_LDO(PM8058_L22, 0, 1, 0, 1150000, 1150000, LDO300HMIN),
4095 RPM_LDO(PM8058_L23, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4096 RPM_LDO(PM8058_L24, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
4097 RPM_LDO(PM8058_L25, 0, 1, 0, 1200000, 1200000, LDO150HMIN),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004098
David Collins6f032ba2011-08-31 14:08:15 -07004099 /* ID a_on pd ss min_uV max_uV init_ip freq */
4100 RPM_SMPS(PM8058_S2, 0, 1, 1, 1200000, 1400000, SMPS_HMIN, 1p60),
4101 RPM_SMPS(PM8058_S3, 1, 1, 0, 1800000, 1800000, SMPS_HMIN, 1p60),
4102 RPM_SMPS(PM8058_S4, 1, 1, 0, 2200000, 2200000, SMPS_HMIN, 1p60),
4103
4104 /* ID a_on pd ss */
4105 RPM_VS(PM8058_LVS0, 0, 1, 0),
4106 RPM_VS(PM8058_LVS1, 0, 1, 0),
4107
4108 /* ID a_on pd ss min_uV max_uV */
4109 RPM_NCP(PM8058_NCP, 0, 1, 0, 1800000, 1800000),
4110
4111 /* ID a_on pd ss min_uV max_uV init_ip */
4112 RPM_LDO(PM8901_L0, 0, 1, 0, 1200000, 1200000, LDO300HMIN),
4113 RPM_LDO(PM8901_L1, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4114 RPM_LDO(PM8901_L2, 0, 1, 0, 2850000, 3300000, LDO300HMIN),
4115 RPM_LDO(PM8901_L3, 0, 1, 0, 3300000, 3300000, LDO300HMIN),
4116 RPM_LDO(PM8901_L4, 0, 1, 0, 2600000, 2600000, LDO300HMIN),
4117 RPM_LDO(PM8901_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN),
4118 RPM_LDO(PM8901_L6, 0, 1, 0, 2200000, 2200000, LDO300HMIN),
4119
4120 /* ID a_on pd ss min_uV max_uV init_ip freq */
4121 RPM_SMPS(PM8901_S2, 0, 1, 0, 1300000, 1300000, FTS_HMIN, 1p60),
4122 RPM_SMPS(PM8901_S3, 0, 1, 0, 1100000, 1100000, FTS_HMIN, 1p60),
4123 RPM_SMPS(PM8901_S4, 0, 1, 0, 1225000, 1225000, FTS_HMIN, 1p60),
4124
4125 /* ID a_on pd ss */
4126 RPM_VS(PM8901_LVS0, 1, 1, 0),
4127 RPM_VS(PM8901_LVS1, 0, 1, 0),
4128 RPM_VS(PM8901_LVS2, 0, 1, 0),
4129 RPM_VS(PM8901_LVS3, 0, 1, 0),
4130 RPM_VS(PM8901_MVS0, 0, 1, 0),
4131
4132 /* ID a_on pin_func pin_ctrl */
4133 RPM_PC(PM8058_L8, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4134 RPM_PC(PM8058_L20, 0, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4135 RPM_PC(PM8058_L21, 1, SLEEP_B, RPM_VREG_PIN_CTRL_NONE),
4136 RPM_PC(PM8058_S2, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8058_A0),
4137 RPM_PC(PM8901_L0, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4138 RPM_PC(PM8901_S4, 0, ENABLE, RPM_VREG_PIN_CTRL_PM8901_A0),
4139};
4140
4141static struct rpm_regulator_platform_data rpm_regulator_early_pdata = {
4142 .init_data = rpm_regulator_early_init_data,
4143 .num_regulators = ARRAY_SIZE(rpm_regulator_early_init_data),
4144 .version = RPM_VREG_VERSION_8660,
4145 .vreg_id_vdd_mem = RPM_VREG_ID_PM8058_S0,
4146 .vreg_id_vdd_dig = RPM_VREG_ID_PM8058_S1,
4147};
4148
4149static struct rpm_regulator_platform_data rpm_regulator_pdata = {
4150 .init_data = rpm_regulator_init_data,
4151 .num_regulators = ARRAY_SIZE(rpm_regulator_init_data),
4152 .version = RPM_VREG_VERSION_8660,
4153};
4154
4155static struct platform_device rpm_regulator_early_device = {
4156 .name = "rpm-regulator",
4157 .id = 0,
4158 .dev = {
4159 .platform_data = &rpm_regulator_early_pdata,
4160 },
4161};
4162
4163static struct platform_device rpm_regulator_device = {
4164 .name = "rpm-regulator",
4165 .id = 1,
4166 .dev = {
4167 .platform_data = &rpm_regulator_pdata,
4168 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004169};
4170
4171static struct platform_device *early_regulators[] __initdata = {
4172 &msm_device_saw_s0,
4173 &msm_device_saw_s1,
David Collins6f032ba2011-08-31 14:08:15 -07004174 &rpm_regulator_early_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004175};
4176
4177static struct platform_device *early_devices[] __initdata = {
4178#ifdef CONFIG_MSM_BUS_SCALING
4179 &msm_bus_apps_fabric,
4180 &msm_bus_sys_fabric,
4181 &msm_bus_mm_fabric,
4182 &msm_bus_sys_fpb,
4183 &msm_bus_cpss_fpb,
4184#endif
4185 &msm_device_dmov_adm0,
4186 &msm_device_dmov_adm1,
4187};
4188
4189#if (defined(CONFIG_MARIMBA_CORE)) && \
4190 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4191
4192static int bluetooth_power(int);
4193static struct platform_device msm_bt_power_device = {
4194 .name = "bt_power",
4195 .id = -1,
4196 .dev = {
4197 .platform_data = &bluetooth_power,
4198 },
4199};
4200#endif
4201
4202static struct platform_device msm_tsens_device = {
4203 .name = "tsens-tm",
4204 .id = -1,
4205};
4206
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004207#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
4208enum {
4209 SX150X_CORE,
4210 SX150X_DOCKING,
4211 SX150X_SURF,
4212 SX150X_LEFT_FHA,
4213 SX150X_RIGHT_FHA,
4214 SX150X_SOUTH,
4215 SX150X_NORTH,
4216 SX150X_CORE_FLUID,
4217};
4218
4219static struct sx150x_platform_data sx150x_data[] __initdata = {
4220 [SX150X_CORE] = {
4221 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4222 .oscio_is_gpo = false,
4223 .io_pullup_ena = 0x0c08,
4224 .io_pulldn_ena = 0x4060,
4225 .io_open_drain_ena = 0x000c,
4226 .io_polarity = 0,
4227 .irq_summary = -1, /* see fixup_i2c_configs() */
4228 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4229 },
4230 [SX150X_DOCKING] = {
4231 .gpio_base = GPIO_DOCKING_EXPANDER_BASE,
4232 .oscio_is_gpo = false,
4233 .io_pullup_ena = 0x5e06,
4234 .io_pulldn_ena = 0x81b8,
4235 .io_open_drain_ena = 0,
4236 .io_polarity = 0,
4237 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4238 UI_INT2_N),
4239 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4240 GPIO_DOCKING_EXPANDER_BASE -
4241 GPIO_EXPANDER_GPIO_BASE,
4242 },
4243 [SX150X_SURF] = {
4244 .gpio_base = GPIO_SURF_EXPANDER_BASE,
4245 .oscio_is_gpo = false,
4246 .io_pullup_ena = 0,
4247 .io_pulldn_ena = 0,
4248 .io_open_drain_ena = 0,
4249 .io_polarity = 0,
4250 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4251 UI_INT1_N),
4252 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4253 GPIO_SURF_EXPANDER_BASE -
4254 GPIO_EXPANDER_GPIO_BASE,
4255 },
4256 [SX150X_LEFT_FHA] = {
4257 .gpio_base = GPIO_LEFT_KB_EXPANDER_BASE,
4258 .oscio_is_gpo = false,
4259 .io_pullup_ena = 0,
4260 .io_pulldn_ena = 0x40,
4261 .io_open_drain_ena = 0,
4262 .io_polarity = 0,
4263 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4264 UI_INT3_N),
4265 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4266 GPIO_LEFT_KB_EXPANDER_BASE -
4267 GPIO_EXPANDER_GPIO_BASE,
4268 },
4269 [SX150X_RIGHT_FHA] = {
4270 .gpio_base = GPIO_RIGHT_KB_EXPANDER_BASE,
4271 .oscio_is_gpo = true,
4272 .io_pullup_ena = 0,
4273 .io_pulldn_ena = 0,
4274 .io_open_drain_ena = 0,
4275 .io_polarity = 0,
4276 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4277 UI_INT3_N),
4278 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4279 GPIO_RIGHT_KB_EXPANDER_BASE -
4280 GPIO_EXPANDER_GPIO_BASE,
4281 },
4282 [SX150X_SOUTH] = {
4283 .gpio_base = GPIO_SOUTH_EXPANDER_BASE,
4284 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4285 GPIO_SOUTH_EXPANDER_BASE -
4286 GPIO_EXPANDER_GPIO_BASE,
4287 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4288 },
4289 [SX150X_NORTH] = {
4290 .gpio_base = GPIO_NORTH_EXPANDER_BASE,
4291 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4292 GPIO_NORTH_EXPANDER_BASE -
4293 GPIO_EXPANDER_GPIO_BASE,
4294 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4295 .oscio_is_gpo = true,
4296 .io_open_drain_ena = 0x30,
4297 },
4298 [SX150X_CORE_FLUID] = {
4299 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4300 .oscio_is_gpo = false,
4301 .io_pullup_ena = 0x0408,
4302 .io_pulldn_ena = 0x4060,
4303 .io_open_drain_ena = 0x0008,
4304 .io_polarity = 0,
4305 .irq_summary = -1, /* see fixup_i2c_configs() */
4306 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4307 },
4308};
4309
4310#ifdef CONFIG_SENSORS_MSM_ADC
4311/* Configuration of EPM expander is done when client
4312 * request an adc read
4313 */
4314static struct sx150x_platform_data sx150x_epmdata = {
4315 .gpio_base = GPIO_EPM_EXPANDER_BASE,
4316 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4317 GPIO_EPM_EXPANDER_BASE -
4318 GPIO_EXPANDER_GPIO_BASE,
4319 .irq_summary = -1,
4320};
4321#endif
4322
4323/* sx150x_low_power_cfg
4324 *
4325 * This data and init function are used to put unused gpio-expander output
4326 * lines into their low-power states at boot. The init
4327 * function must be deferred until a later init stage because the i2c
4328 * gpio expander drivers do not probe until after they are registered
4329 * (see register_i2c_devices) and the work-queues for those registrations
4330 * are processed. Because these lines are unused, there is no risk of
4331 * competing with a device driver for the gpio.
4332 *
4333 * gpio lines whose low-power states are input are naturally in their low-
4334 * power configurations once probed, see the platform data structures above.
4335 */
4336struct sx150x_low_power_cfg {
4337 unsigned gpio;
4338 unsigned val;
4339};
4340
4341static struct sx150x_low_power_cfg
4342common_sx150x_lp_cfgs[] __initdata = {
4343 {GPIO_WLAN_DEEP_SLEEP_N, 0},
4344 {GPIO_EXT_GPS_LNA_EN, 0},
4345 {GPIO_MSM_WAKES_BT, 0},
4346 {GPIO_USB_UICC_EN, 0},
4347 {GPIO_BATT_GAUGE_EN, 0},
4348};
4349
4350static struct sx150x_low_power_cfg
4351surf_ffa_sx150x_lp_cfgs[] __initdata = {
4352 {GPIO_MIPI_DSI_RST_N, 0},
4353 {GPIO_DONGLE_PWR_EN, 0},
4354 {GPIO_CAP_TS_SLEEP, 1},
4355 {GPIO_WEB_CAMIF_RESET_N, 0},
4356};
4357
4358static void __init
4359cfg_gpio_low_power(struct sx150x_low_power_cfg *cfgs, unsigned nelems)
4360{
4361 unsigned n;
4362 int rc;
4363
4364 for (n = 0; n < nelems; ++n) {
4365 rc = gpio_request(cfgs[n].gpio, NULL);
4366 if (!rc) {
4367 rc = gpio_direction_output(cfgs[n].gpio, cfgs[n].val);
4368 gpio_free(cfgs[n].gpio);
4369 }
4370
4371 if (rc) {
4372 printk(KERN_NOTICE "%s: failed to sleep gpio %d: %d\n",
4373 __func__, cfgs[n].gpio, rc);
4374 }
Steve Muckle9161d302010-02-11 11:50:40 -08004375 }
Steve Mucklea55df6e2010-01-07 12:43:24 -08004376}
4377
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004378static int __init cfg_sx150xs_low_power(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08004379{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004380 cfg_gpio_low_power(common_sx150x_lp_cfgs,
4381 ARRAY_SIZE(common_sx150x_lp_cfgs));
4382 if (!machine_is_msm8x60_fluid())
4383 cfg_gpio_low_power(surf_ffa_sx150x_lp_cfgs,
4384 ARRAY_SIZE(surf_ffa_sx150x_lp_cfgs));
4385 return 0;
4386}
4387module_init(cfg_sx150xs_low_power);
4388
4389#ifdef CONFIG_I2C
4390static struct i2c_board_info core_expander_i2c_info[] __initdata = {
4391 {
4392 I2C_BOARD_INFO("sx1509q", 0x3e),
4393 .platform_data = &sx150x_data[SX150X_CORE]
4394 },
4395};
4396
4397static struct i2c_board_info docking_expander_i2c_info[] __initdata = {
4398 {
4399 I2C_BOARD_INFO("sx1509q", 0x3f),
4400 .platform_data = &sx150x_data[SX150X_DOCKING]
4401 },
4402};
4403
4404static struct i2c_board_info surf_expanders_i2c_info[] __initdata = {
4405 {
4406 I2C_BOARD_INFO("sx1509q", 0x70),
4407 .platform_data = &sx150x_data[SX150X_SURF]
4408 }
4409};
4410
4411static struct i2c_board_info fha_expanders_i2c_info[] __initdata = {
4412 {
4413 I2C_BOARD_INFO("sx1508q", 0x21),
4414 .platform_data = &sx150x_data[SX150X_LEFT_FHA]
4415 },
4416 {
4417 I2C_BOARD_INFO("sx1508q", 0x22),
4418 .platform_data = &sx150x_data[SX150X_RIGHT_FHA]
4419 }
4420};
4421
4422static struct i2c_board_info fluid_expanders_i2c_info[] __initdata = {
4423 {
4424 I2C_BOARD_INFO("sx1508q", 0x23),
4425 .platform_data = &sx150x_data[SX150X_SOUTH]
4426 },
4427 {
4428 I2C_BOARD_INFO("sx1508q", 0x20),
4429 .platform_data = &sx150x_data[SX150X_NORTH]
4430 }
4431};
4432
4433static struct i2c_board_info fluid_core_expander_i2c_info[] __initdata = {
4434 {
4435 I2C_BOARD_INFO("sx1509q", 0x3e),
4436 .platform_data = &sx150x_data[SX150X_CORE_FLUID]
4437 },
4438};
4439
4440#ifdef CONFIG_SENSORS_MSM_ADC
4441static struct i2c_board_info fluid_expanders_i2c_epm_info[] = {
4442 {
4443 I2C_BOARD_INFO("sx1509q", 0x3e),
4444 .platform_data = &sx150x_epmdata
4445 },
4446};
4447#endif
4448#endif
4449#endif
4450
4451#ifdef CONFIG_SENSORS_MSM_ADC
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004452
4453static struct adc_access_fn xoadc_fn = {
4454 pm8058_xoadc_select_chan_and_start_conv,
4455 pm8058_xoadc_read_adc_code,
4456 pm8058_xoadc_get_properties,
4457 pm8058_xoadc_slot_request,
4458 pm8058_xoadc_restore_slot,
4459 pm8058_xoadc_calibrate,
4460};
4461
4462#if defined(CONFIG_I2C) && \
4463 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4464static struct regulator *vreg_adc_epm1;
4465
4466static struct i2c_client *epm_expander_i2c_register_board(void)
4467
4468{
4469 struct i2c_adapter *i2c_adap;
4470 struct i2c_client *client = NULL;
4471 i2c_adap = i2c_get_adapter(0x0);
4472
4473 if (i2c_adap == NULL)
4474 printk(KERN_ERR "\nepm_expander_i2c_adapter is NULL\n");
4475
4476 if (i2c_adap != NULL)
4477 client = i2c_new_device(i2c_adap,
4478 &fluid_expanders_i2c_epm_info[0]);
4479 return client;
4480
4481}
4482
4483static unsigned int msm_adc_gpio_configure_expander_enable(void)
4484{
4485 int rc = 0;
4486 static struct i2c_client *epm_i2c_client;
4487
4488 printk(KERN_DEBUG "Enter msm_adc_gpio_configure_expander_enable\n");
4489
4490 vreg_adc_epm1 = regulator_get(NULL, "8058_s3");
4491
4492 if (IS_ERR(vreg_adc_epm1)) {
4493 printk(KERN_ERR "%s: Unable to get 8058_s3\n", __func__);
4494 return 0;
4495 }
4496
4497 rc = regulator_set_voltage(vreg_adc_epm1, 1800000, 1800000);
4498 if (rc)
4499 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4500 "regulator set voltage failed\n");
4501
4502 rc = regulator_enable(vreg_adc_epm1);
4503 if (rc) {
4504 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4505 "Error while enabling regulator for epm s3 %d\n", rc);
4506 return rc;
4507 }
4508
4509 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Start"
4510 " setting the value of the EPM 3.3, 5v and lvlsft\n");
4511
4512 msleep(1000);
4513
4514 rc = gpio_request(GPIO_EPM_5V_BOOST_EN, "boost_epm_5v");
4515 if (!rc) {
4516 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4517 "Configure 5v boost\n");
4518 gpio_direction_output(GPIO_EPM_5V_BOOST_EN, 1);
4519 } else {
4520 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4521 "Error for epm 5v boost en\n");
4522 goto exit_vreg_epm;
4523 }
4524
4525 msleep(500);
4526
4527 rc = gpio_request(GPIO_EPM_3_3V_EN, "epm_3_3v");
4528 if (!rc) {
4529 gpio_direction_output(GPIO_EPM_3_3V_EN, 1);
4530 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4531 "Configure epm 3.3v\n");
4532 } else {
4533 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4534 "Error for gpio 3.3ven\n");
4535 goto exit_vreg_epm;
4536 }
4537 msleep(500);
4538
4539 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4540 "Trying to request EPM LVLSFT_EN\n");
4541 rc = gpio_request(GPIO_EPM_LVLSFT_EN, "lvsft_en");
4542 if (!rc) {
4543 gpio_direction_output(GPIO_EPM_LVLSFT_EN, 1);
4544 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4545 "Configure the lvlsft\n");
4546 } else {
4547 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4548 "Error for epm lvlsft_en\n");
4549 goto exit_vreg_epm;
4550 }
4551
4552 msleep(500);
4553
4554 if (!epm_i2c_client)
4555 epm_i2c_client = epm_expander_i2c_register_board();
4556
4557 rc = gpio_request(GPIO_PWR_MON_ENABLE, "pwr_mon_enable");
4558 if (!rc)
4559 rc = gpio_direction_output(GPIO_PWR_MON_ENABLE, 1);
4560 if (rc) {
4561 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4562 ": GPIO PWR MON Enable issue\n");
4563 goto exit_vreg_epm;
4564 }
4565
4566 msleep(1000);
4567
4568 rc = gpio_request(GPIO_ADC1_PWDN_N, "adc1_pwdn");
4569 if (!rc) {
4570 rc = gpio_direction_output(GPIO_ADC1_PWDN_N, 1);
4571 if (rc) {
4572 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4573 ": ADC1_PWDN error direction out\n");
4574 goto exit_vreg_epm;
4575 }
4576 }
4577
4578 msleep(100);
4579
4580 rc = gpio_request(GPIO_ADC2_PWDN_N, "adc2_pwdn");
4581 if (!rc) {
4582 rc = gpio_direction_output(GPIO_ADC2_PWDN_N, 1);
4583 if (rc) {
4584 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4585 ": ADC2_PWD error direction out\n");
4586 goto exit_vreg_epm;
4587 }
4588 }
4589
4590 msleep(1000);
4591
4592 rc = gpio_request(GPIO_PWR_MON_START, "pwr_mon_start");
4593 if (!rc) {
4594 rc = gpio_direction_output(GPIO_PWR_MON_START, 0);
4595 if (rc) {
4596 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4597 "Gpio request problem %d\n", rc);
4598 goto exit_vreg_epm;
4599 }
4600 }
4601
4602 rc = gpio_request(GPIO_EPM_SPI_ADC1_CS_N, "spi_adc1_cs");
4603 if (!rc) {
4604 rc = gpio_direction_output(GPIO_EPM_SPI_ADC1_CS_N, 0);
4605 if (rc) {
4606 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4607 ": EPM_SPI_ADC1_CS_N error\n");
4608 goto exit_vreg_epm;
4609 }
4610 }
4611
4612 rc = gpio_request(GPIO_EPM_SPI_ADC2_CS_N, "spi_adc2_cs");
4613 if (!rc) {
4614 rc = gpio_direction_output(GPIO_EPM_SPI_ADC2_CS_N, 0);
4615 if (rc) {
4616 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4617 ": EPM_SPI_ADC2_Cs_N error\n");
4618 goto exit_vreg_epm;
4619 }
4620 }
4621
4622 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Set "
4623 "the power monitor reset for epm\n");
4624
4625 rc = gpio_request(GPIO_PWR_MON_RESET_N, "pwr_mon_reset_n");
4626 if (!rc) {
4627 gpio_direction_output(GPIO_PWR_MON_RESET_N, 0);
4628 if (rc) {
4629 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4630 ": Error in the power mon reset\n");
4631 goto exit_vreg_epm;
4632 }
4633 }
4634
4635 msleep(1000);
4636
4637 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 1);
4638
4639 msleep(500);
4640
4641 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4642
4643 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4644
4645 return rc;
4646
4647exit_vreg_epm:
4648 regulator_disable(vreg_adc_epm1);
4649
4650 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: Exit."
4651 " rc = %d.\n", rc);
4652 return rc;
4653};
4654
4655static unsigned int msm_adc_gpio_configure_expander_disable(void)
4656{
4657 int rc = 0;
4658
4659 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 0);
4660 gpio_free(GPIO_PWR_MON_RESET_N);
4661
4662 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4663 gpio_free(GPIO_EPM_SPI_ADC1_CS_N);
4664
4665 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4666 gpio_free(GPIO_EPM_SPI_ADC2_CS_N);
4667
4668 gpio_set_value_cansleep(GPIO_PWR_MON_START, 0);
4669 gpio_free(GPIO_PWR_MON_START);
4670
4671 gpio_direction_output(GPIO_ADC1_PWDN_N, 0);
4672 gpio_free(GPIO_ADC1_PWDN_N);
4673
4674 gpio_direction_output(GPIO_ADC2_PWDN_N, 0);
4675 gpio_free(GPIO_ADC2_PWDN_N);
4676
4677 gpio_set_value_cansleep(GPIO_PWR_MON_ENABLE, 0);
4678 gpio_free(GPIO_PWR_MON_ENABLE);
4679
4680 gpio_set_value_cansleep(GPIO_EPM_LVLSFT_EN, 0);
4681 gpio_free(GPIO_EPM_LVLSFT_EN);
4682
4683 gpio_set_value_cansleep(GPIO_EPM_5V_BOOST_EN, 0);
4684 gpio_free(GPIO_EPM_5V_BOOST_EN);
4685
4686 gpio_set_value_cansleep(GPIO_EPM_3_3V_EN, 0);
4687 gpio_free(GPIO_EPM_3_3V_EN);
4688
4689 rc = regulator_disable(vreg_adc_epm1);
4690 if (rc)
4691 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_disable: "
4692 "Error while enabling regulator for epm s3 %d\n", rc);
4693 regulator_put(vreg_adc_epm1);
4694
4695 printk(KERN_DEBUG "Exi msm_adc_gpio_configure_expander_disable\n");
4696 return rc;
4697};
4698
4699unsigned int msm_adc_gpio_expander_enable(int cs_enable)
4700{
4701 int rc = 0;
4702
4703 printk(KERN_DEBUG "msm_adc_gpio_expander_enable: cs_enable = %d",
4704 cs_enable);
4705
4706 if (cs_enable < 16) {
4707 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4708 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4709 } else {
4710 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4711 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4712 }
4713 return rc;
4714};
4715
4716unsigned int msm_adc_gpio_expander_disable(int cs_disable)
4717{
4718 int rc = 0;
4719
4720 printk(KERN_DEBUG "Enter msm_adc_gpio_expander_disable.\n");
4721
4722 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4723
4724 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4725
4726 return rc;
4727};
4728#endif
4729
4730static struct msm_adc_channels msm_adc_channels_data[] = {
4731 {"vbatt", CHANNEL_ADC_VBATT, 0, &xoadc_fn, CHAN_PATH_TYPE2,
4732 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4733 {"vcoin", CHANNEL_ADC_VCOIN, 0, &xoadc_fn, CHAN_PATH_TYPE1,
4734 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4735 {"vcharger_channel", CHANNEL_ADC_VCHG, 0, &xoadc_fn, CHAN_PATH_TYPE3,
4736 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE4, scale_default},
4737 {"charger_current_monitor", CHANNEL_ADC_CHG_MONITOR, 0, &xoadc_fn,
4738 CHAN_PATH_TYPE4,
4739 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4740 {"vph_pwr", CHANNEL_ADC_VPH_PWR, 0, &xoadc_fn, CHAN_PATH_TYPE5,
4741 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4742 {"usb_vbus", CHANNEL_ADC_USB_VBUS, 0, &xoadc_fn, CHAN_PATH_TYPE11,
4743 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4744 {"pmic_therm", CHANNEL_ADC_DIE_TEMP, 0, &xoadc_fn, CHAN_PATH_TYPE12,
4745 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_pmic_therm},
4746 {"pmic_therm_4K", CHANNEL_ADC_DIE_TEMP_4K, 0, &xoadc_fn,
4747 CHAN_PATH_TYPE12,
4748 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE7, scale_pmic_therm},
4749 {"xo_therm", CHANNEL_ADC_XOTHERM, 0, &xoadc_fn, CHAN_PATH_TYPE_NONE,
4750 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE5, tdkntcgtherm},
4751 {"xo_therm_4K", CHANNEL_ADC_XOTHERM_4K, 0, &xoadc_fn,
4752 CHAN_PATH_TYPE_NONE,
4753 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE6, tdkntcgtherm},
4754 {"hdset_detect", CHANNEL_ADC_HDSET, 0, &xoadc_fn, CHAN_PATH_TYPE6,
4755 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4756 {"chg_batt_amon", CHANNEL_ADC_BATT_AMON, 0, &xoadc_fn, CHAN_PATH_TYPE10,
4757 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1,
4758 scale_xtern_chgr_cur},
4759 {"msm_therm", CHANNEL_ADC_MSM_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE8,
4760 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_msm_therm},
4761 {"batt_therm", CHANNEL_ADC_BATT_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE7,
4762 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_batt_therm},
4763 {"batt_id", CHANNEL_ADC_BATT_ID, 0, &xoadc_fn, CHAN_PATH_TYPE9,
4764 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4765 {"ref_625mv", CHANNEL_ADC_625_REF, 0, &xoadc_fn, CHAN_PATH_TYPE15,
4766 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4767 {"ref_1250mv", CHANNEL_ADC_1250_REF, 0, &xoadc_fn, CHAN_PATH_TYPE13,
4768 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4769 {"ref_325mv", CHANNEL_ADC_325_REF, 0, &xoadc_fn, CHAN_PATH_TYPE14,
4770 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4771};
4772
4773static char *msm_adc_fluid_device_names[] = {
4774 "ADS_ADC1",
4775 "ADS_ADC2",
4776};
4777
4778static struct msm_adc_platform_data msm_adc_pdata = {
4779 .channel = msm_adc_channels_data,
4780 .num_chan_supported = ARRAY_SIZE(msm_adc_channels_data),
4781#if defined(CONFIG_I2C) && \
4782 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4783 .adc_gpio_enable = msm_adc_gpio_expander_enable,
4784 .adc_gpio_disable = msm_adc_gpio_expander_disable,
4785 .adc_fluid_enable = msm_adc_gpio_configure_expander_enable,
4786 .adc_fluid_disable = msm_adc_gpio_configure_expander_disable,
4787#endif
4788};
4789
4790static struct platform_device msm_adc_device = {
4791 .name = "msm_adc",
4792 .id = -1,
4793 .dev = {
4794 .platform_data = &msm_adc_pdata,
4795 },
4796};
4797
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05304798static struct msm_rtb_platform_data msm_rtb_pdata = {
4799 .size = SZ_1M,
4800};
4801
4802static int __init msm_rtb_set_buffer_size(char *p)
4803{
4804 int s;
4805
4806 s = memparse(p, NULL);
4807 msm_rtb_pdata.size = ALIGN(s, SZ_4K);
4808 return 0;
4809}
4810early_param("msm_rtb_size", msm_rtb_set_buffer_size);
4811
4812
4813static struct platform_device msm_rtb_device = {
4814 .name = "msm_rtb",
4815 .id = -1,
4816 .dev = {
4817 .platform_data = &msm_rtb_pdata,
4818 },
4819};
4820
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004821static void pmic8058_xoadc_mpp_config(void)
4822{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304823 int rc, i;
4824 struct pm8xxx_mpp_init_info xoadc_mpps[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304825 PM8058_MPP_INIT(XOADC_MPP_3, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304826 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304827 PM8058_MPP_INIT(XOADC_MPP_5, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH9,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304828 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304829 PM8058_MPP_INIT(XOADC_MPP_7, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH6,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304830 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304831 PM8058_MPP_INIT(XOADC_MPP_8, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304832 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304833 PM8058_MPP_INIT(XOADC_MPP_10, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH7,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304834 AOUT_CTRL_DISABLE),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304835 PM8901_MPP_INIT(XOADC_MPP_4, D_OUTPUT, PM8901_MPP_DIG_LEVEL_S4,
4836 DOUT_CTRL_LOW),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304837 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004838
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304839 for (i = 0; i < ARRAY_SIZE(xoadc_mpps); i++) {
4840 rc = pm8xxx_mpp_config(xoadc_mpps[i].mpp,
4841 &xoadc_mpps[i].config);
4842 if (rc) {
4843 pr_err("%s: Config MPP %d of PM8058 failed\n",
4844 __func__, xoadc_mpps[i].mpp);
4845 }
4846 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004847}
4848
4849static struct regulator *vreg_ldo18_adc;
4850
4851static int pmic8058_xoadc_vreg_config(int on)
4852{
4853 int rc;
4854
4855 if (on) {
4856 rc = regulator_enable(vreg_ldo18_adc);
4857 if (rc)
4858 pr_err("%s: Enable of regulator ldo18_adc "
4859 "failed\n", __func__);
4860 } else {
4861 rc = regulator_disable(vreg_ldo18_adc);
4862 if (rc)
4863 pr_err("%s: Disable of regulator ldo18_adc "
4864 "failed\n", __func__);
4865 }
4866
4867 return rc;
4868}
4869
4870static int pmic8058_xoadc_vreg_setup(void)
4871{
4872 int rc;
4873
4874 vreg_ldo18_adc = regulator_get(NULL, "8058_l18");
4875 if (IS_ERR(vreg_ldo18_adc)) {
4876 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
4877 __func__, PTR_ERR(vreg_ldo18_adc));
4878 rc = PTR_ERR(vreg_ldo18_adc);
4879 goto fail;
4880 }
4881
4882 rc = regulator_set_voltage(vreg_ldo18_adc, 2200000, 2200000);
4883 if (rc) {
4884 pr_err("%s: unable to set ldo18 voltage to 2.2V\n", __func__);
4885 goto fail;
4886 }
4887
4888 return rc;
4889fail:
4890 regulator_put(vreg_ldo18_adc);
4891 return rc;
4892}
4893
4894static void pmic8058_xoadc_vreg_shutdown(void)
4895{
4896 regulator_put(vreg_ldo18_adc);
4897}
4898
4899/* usec. For this ADC,
4900 * this time represents clk rate @ txco w/ 1024 decimation ratio.
4901 * Each channel has different configuration, thus at the time of starting
4902 * the conversion, xoadc will return actual conversion time
4903 * */
4904static struct adc_properties pm8058_xoadc_data = {
4905 .adc_reference = 2200, /* milli-voltage for this adc */
4906 .bitresolution = 15,
4907 .bipolar = 0,
4908 .conversiontime = 54,
4909};
4910
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304911static struct xoadc_platform_data pm8058_xoadc_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004912 .xoadc_prop = &pm8058_xoadc_data,
4913 .xoadc_mpp_config = pmic8058_xoadc_mpp_config,
4914 .xoadc_vreg_set = pmic8058_xoadc_vreg_config,
4915 .xoadc_num = XOADC_PMIC_0,
4916 .xoadc_vreg_setup = pmic8058_xoadc_vreg_setup,
4917 .xoadc_vreg_shutdown = pmic8058_xoadc_vreg_shutdown,
4918};
4919#endif
4920
4921#ifdef CONFIG_MSM_SDIO_AL
4922
4923static unsigned mdm2ap_status = 140;
4924
4925static int configure_mdm2ap_status(int on)
4926{
4927 int ret = 0;
4928 if (on)
4929 ret = msm_gpiomux_get(mdm2ap_status);
4930 else
4931 ret = msm_gpiomux_put(mdm2ap_status);
4932
4933 if (ret)
4934 pr_err("%s: mdm2ap_status config failed, on = %d\n", __func__,
4935 on);
4936
4937 return ret;
4938}
4939
4940
4941static int get_mdm2ap_status(void)
4942{
4943 return gpio_get_value(mdm2ap_status);
4944}
4945
4946static struct sdio_al_platform_data sdio_al_pdata = {
4947 .config_mdm2ap_status = configure_mdm2ap_status,
4948 .get_mdm2ap_status = get_mdm2ap_status,
4949 .allow_sdioc_version_major_2 = 0,
Konstantin Dorfmanee2e3082011-08-16 15:12:01 +03004950 .peer_sdioc_version_minor = 0x0202,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004951 .peer_sdioc_version_major = 0x0004,
4952 .peer_sdioc_boot_version_minor = 0x0001,
4953 .peer_sdioc_boot_version_major = 0x0003
4954};
4955
4956struct platform_device msm_device_sdio_al = {
4957 .name = "msm_sdio_al",
4958 .id = -1,
4959 .dev = {
Maya Erez6862b142011-08-22 09:07:07 +03004960 .parent = &msm_charm_modem.dev,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004961 .platform_data = &sdio_al_pdata,
4962 },
4963};
4964
4965#endif /* CONFIG_MSM_SDIO_AL */
4966
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05304967#define GPIO_VREG_ID_EXT_5V 0
4968
4969static struct regulator_consumer_supply vreg_consumers_EXT_5V[] = {
4970 REGULATOR_SUPPLY("ext_5v", NULL),
4971 REGULATOR_SUPPLY("8901_mpp0", NULL),
4972};
4973
4974#define GPIO_VREG_INIT(_id, _reg_name, _gpio_label, _gpio, _active_low) \
4975 [GPIO_VREG_ID_##_id] = { \
4976 .init_data = { \
4977 .constraints = { \
4978 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
4979 }, \
4980 .num_consumer_supplies = \
4981 ARRAY_SIZE(vreg_consumers_##_id), \
4982 .consumer_supplies = vreg_consumers_##_id, \
4983 }, \
4984 .regulator_name = _reg_name, \
4985 .active_low = _active_low, \
4986 .gpio_label = _gpio_label, \
4987 .gpio = _gpio, \
4988 }
4989
4990/* GPIO regulator constraints */
4991static struct gpio_regulator_platform_data msm_gpio_regulator_pdata[] = {
4992 GPIO_VREG_INIT(EXT_5V, "ext_5v", "ext_5v_en",
4993 PM8901_MPP_PM_TO_SYS(0), 0),
4994};
4995
4996/* GPIO regulator */
4997static struct platform_device msm8x60_8901_mpp_vreg __devinitdata = {
4998 .name = GPIO_REGULATOR_DEV_NAME,
4999 .id = PM8901_MPP_PM_TO_SYS(0),
5000 .dev = {
5001 .platform_data =
5002 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
5003 },
5004};
5005
5006static void __init pm8901_vreg_mpp0_init(void)
5007{
5008 int rc;
5009
5010 struct pm8xxx_mpp_init_info pm8901_vreg_mpp0 = {
5011 .mpp = PM8901_MPP_PM_TO_SYS(0),
5012 .config = {
5013 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
5014 .level = PM8901_MPP_DIG_LEVEL_VPH,
5015 },
5016 };
5017
5018 /*
5019 * Set PMIC 8901 MPP0 active_high to 0 for surf and charm_surf. This
5020 * implies that the regulator connected to MPP0 is enabled when
5021 * MPP0 is low.
5022 */
5023 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion()) {
5024 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 1;
5025 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_HIGH;
5026 } else {
5027 msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V].active_low = 0;
5028 pm8901_vreg_mpp0.config.control = PM8XXX_MPP_DOUT_CTRL_LOW;
5029 }
5030
5031 rc = pm8xxx_mpp_config(pm8901_vreg_mpp0.mpp, &pm8901_vreg_mpp0.config);
5032 if (rc)
5033 pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc);
5034}
5035
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005036static struct platform_device *charm_devices[] __initdata = {
5037 &msm_charm_modem,
5038#ifdef CONFIG_MSM_SDIO_AL
5039 &msm_device_sdio_al,
5040#endif
5041};
5042
Lei Zhou338cab82011-08-19 13:38:17 -04005043#ifdef CONFIG_SND_SOC_MSM8660_APQ
5044static struct platform_device *dragon_alsa_devices[] __initdata = {
5045 &msm_pcm,
5046 &msm_pcm_routing,
5047 &msm_cpudai0,
5048 &msm_cpudai1,
5049 &msm_cpudai_hdmi_rx,
5050 &msm_cpudai_bt_rx,
5051 &msm_cpudai_bt_tx,
5052 &msm_cpudai_fm_rx,
5053 &msm_cpudai_fm_tx,
5054 &msm_cpu_fe,
5055 &msm_stub_codec,
5056 &msm_lpa_pcm,
5057};
5058#endif
5059
5060static struct platform_device *asoc_devices[] __initdata = {
5061 &asoc_msm_pcm,
5062 &asoc_msm_dai0,
5063 &asoc_msm_dai1,
5064};
5065
Riaz Rahaman0bd72172012-06-26 18:42:36 +05305066/* qseecom bus scaling */
5067static struct msm_bus_vectors qseecom_clks_init_vectors[] = {
5068 {
5069 .src = MSM_BUS_MASTER_SPS,
5070 .dst = MSM_BUS_SLAVE_EBI_CH0,
5071 .ib = 0,
5072 .ab = 0,
5073 },
5074 {
5075 .src = MSM_BUS_MASTER_SPDM,
5076 .dst = MSM_BUS_SLAVE_SPDM,
5077 .ib = 0,
5078 .ab = 0,
5079 },
5080};
5081
5082static struct msm_bus_vectors qseecom_enable_dfab_vectors[] = {
5083 {
5084 .src = MSM_BUS_MASTER_SPS,
5085 .dst = MSM_BUS_SLAVE_EBI_CH0,
5086 .ib = (492 * 8) * 1000000UL,
5087 .ab = (492 * 8) * 100000UL,
5088 },
5089 {
5090 .src = MSM_BUS_MASTER_SPDM,
5091 .dst = MSM_BUS_SLAVE_SPDM,
5092 .ib = 0,
5093 .ab = 0,
5094 },
5095};
5096
5097static struct msm_bus_vectors qseecom_enable_sfpb_vectors[] = {
5098 {
5099 .src = MSM_BUS_MASTER_SPS,
5100 .dst = MSM_BUS_SLAVE_EBI_CH0,
5101 .ib = 0,
5102 .ab = 0,
5103 },
5104 {
5105 .src = MSM_BUS_MASTER_SPDM,
5106 .dst = MSM_BUS_SLAVE_SPDM,
5107 .ib = (64 * 8) * 1000000UL,
5108 .ab = (64 * 8) * 100000UL,
5109 },
5110};
5111
5112static struct msm_bus_paths qseecom_hw_bus_scale_usecases[] = {
5113 {
5114 ARRAY_SIZE(qseecom_clks_init_vectors),
5115 qseecom_clks_init_vectors,
5116 },
5117 {
5118 ARRAY_SIZE(qseecom_enable_dfab_vectors),
5119 qseecom_enable_sfpb_vectors,
5120 },
5121 {
5122 ARRAY_SIZE(qseecom_enable_sfpb_vectors),
5123 qseecom_enable_sfpb_vectors,
5124 },
5125};
5126
5127static struct msm_bus_scale_pdata qseecom_bus_pdata = {
5128 .usecase = qseecom_hw_bus_scale_usecases,
5129 .num_usecases = ARRAY_SIZE(qseecom_hw_bus_scale_usecases),
5130 .name = "qsee",
5131};
5132
5133static struct platform_device qseecom_device = {
5134 .name = "qseecom",
5135 .id = -1,
5136 .dev = {
5137 .platform_data = &qseecom_bus_pdata,
5138 },
5139};
5140
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005141static struct platform_device *surf_devices[] __initdata = {
Matt Wagantallbf430eb2012-03-22 11:45:49 -07005142 &msm8x60_device_acpuclk,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005143 &msm_device_smd,
5144 &msm_device_uart_dm12,
Stephen Boyd3acc9e42011-09-28 16:46:40 -07005145 &msm_pil_q6v3,
Stephen Boyd4eb885b2011-09-29 01:16:03 -07005146 &msm_pil_modem,
Stephen Boydd89eebe2011-09-28 23:28:11 -07005147 &msm_pil_tzapps,
Stephen Boyd25c4a0b2011-09-20 00:12:36 -07005148 &msm_pil_dsps,
Riaz Rahamandd18ebf2012-06-27 16:06:34 +05305149 &msm_pil_vidc,
Riaz Rahaman0bd72172012-06-26 18:42:36 +05305150 &qseecom_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005151#ifdef CONFIG_I2C_QUP
5152 &msm_gsbi3_qup_i2c_device,
5153 &msm_gsbi4_qup_i2c_device,
5154 &msm_gsbi7_qup_i2c_device,
5155 &msm_gsbi8_qup_i2c_device,
5156 &msm_gsbi9_qup_i2c_device,
5157 &msm_gsbi12_qup_i2c_device,
5158#endif
5159#ifdef CONFIG_SERIAL_MSM_HS
5160 &msm_device_uart_dm1,
5161#endif
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305162#ifdef CONFIG_MSM_SSBI
5163 &msm_device_ssbi_pmic1,
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05305164 &msm_device_ssbi_pmic2,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305165#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005166#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005167 &msm_device_ssbi3,
5168#endif
5169#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
5170 &isp1763_device,
5171#endif
5172
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005173#if defined (CONFIG_MSM_8x60_VOIP)
5174 &asoc_msm_mvs,
5175 &asoc_mvs_dai0,
5176 &asoc_mvs_dai1,
5177#endif
Lei Zhou338cab82011-08-19 13:38:17 -04005178
Lena Salman57d167e2012-03-21 19:46:38 +02005179#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005180 &msm_device_otg,
5181#endif
Lena Salman57d167e2012-03-21 19:46:38 +02005182#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005183 &msm_device_gadget_peripheral,
5184#endif
5185#ifdef CONFIG_USB_G_ANDROID
5186 &android_usb_device,
5187#endif
5188#ifdef CONFIG_BATTERY_MSM
5189 &msm_batt_device,
5190#endif
5191#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005192#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005193 &android_pmem_device,
5194 &android_pmem_adsp_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005195 &android_pmem_smipool_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005196 &android_pmem_audio_device,
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305197#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5198#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005199#ifdef CONFIG_MSM_ROTATOR
5200 &msm_rotator_device,
5201#endif
5202 &msm_fb_device,
5203 &msm_kgsl_3d0,
5204 &msm_kgsl_2d0,
5205 &msm_kgsl_2d1,
5206 &lcdc_samsung_panel_device,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005207#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5208 &lcdc_nt35582_panel_device,
5209#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005210#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
5211 &lcdc_samsung_oled_panel_device,
5212#endif
5213#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
5214 &lcdc_auo_wvga_panel_device,
5215#endif
5216#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
5217 &hdmi_msm_device,
5218#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
5219#ifdef CONFIG_FB_MSM_MIPI_DSI
5220 &mipi_dsi_toshiba_panel_device,
5221 &mipi_dsi_novatek_panel_device,
5222#endif
5223#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07005224#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005225#ifdef CONFIG_MT9E013
5226 &msm_camera_sensor_mt9e013,
5227#endif
5228#ifdef CONFIG_IMX074
5229 &msm_camera_sensor_imx074,
5230#endif
5231#ifdef CONFIG_WEBCAM_OV7692
5232 &msm_camera_sensor_webcam_ov7692,
5233#endif
5234#ifdef CONFIG_WEBCAM_OV9726
5235 &msm_camera_sensor_webcam_ov9726,
5236#endif
5237#ifdef CONFIG_QS_S5K4E1
5238 &msm_camera_sensor_qs_s5k4e1,
5239#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04005240#ifdef CONFIG_VX6953
5241 &msm_camera_sensor_vx6953,
5242#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005243#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005244#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005245#ifdef CONFIG_MSM_GEMINI
5246 &msm_gemini_device,
5247#endif
5248#ifdef CONFIG_MSM_VPE
Kevin Chan3be11612012-03-22 20:05:40 -07005249#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005250 &msm_vpe_device,
5251#endif
Kevin Chan3be11612012-03-22 20:05:40 -07005252#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005253
5254#if defined(CONFIG_MSM_RPM_LOG) || defined(CONFIG_MSM_RPM_LOG_MODULE)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005255 &msm8660_rpm_log_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005256#endif
5257#if defined(CONFIG_MSM_RPM_STATS_LOG)
Praveen Chidambaram78499012011-11-01 17:15:17 -06005258 &msm8660_rpm_stat_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005259#endif
5260 &msm_device_vidc,
5261#if (defined(CONFIG_MARIMBA_CORE)) && \
5262 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5263 &msm_bt_power_device,
5264#endif
5265#ifdef CONFIG_SENSORS_MSM_ADC
5266 &msm_adc_device,
5267#endif
David Collins6f032ba2011-08-31 14:08:15 -07005268 &rpm_regulator_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005269
5270#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5271 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5272 &qcrypto_device,
5273#endif
5274
5275#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5276 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5277 &qcedev_device,
5278#endif
5279
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005280
5281#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5282#ifdef CONFIG_MSM_USE_TSIF1
5283 &msm_device_tsif[1],
5284#else
5285 &msm_device_tsif[0],
5286#endif /* CONFIG_MSM_USE_TSIF1 */
5287#endif /* CONFIG_TSIF */
5288
5289#ifdef CONFIG_HW_RANDOM_MSM
5290 &msm_device_rng,
5291#endif
5292
5293 &msm_tsens_device,
Praveen Chidambaram78499012011-11-01 17:15:17 -06005294 &msm8660_rpm_device,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005295#ifdef CONFIG_ION_MSM
5296 &ion_dev,
5297#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -07005298 &msm8660_device_watchdog,
Mona Hossainceca6152012-04-10 09:55:41 -07005299 &msm_device_tz_log,
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305300 &msm_rtb_device,
Laura Abbottd92be422012-06-04 15:11:09 -07005301 &msm8660_iommu_domain_device,
Praveen Chidambaramf27a5152013-02-01 11:44:53 -07005302 &msm8660_pm_8x60,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005303};
5304
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005305#ifdef CONFIG_ION_MSM
Olav Haugan0703dbf2011-12-19 17:53:38 -08005306#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5307static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
5308 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugan8726caf2012-05-10 15:11:35 -07005309 .align = SZ_64K,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005310 .request_region = request_smi_region,
5311 .release_region = release_smi_region,
5312 .setup_region = setup_smi_region,
Chintan Pandya490c9712012-08-07 17:19:59 +05305313 .secure_base = SECURE_BASE,
5314 .secure_size = SECURE_SIZE,
Olav Haugan8726caf2012-05-10 15:11:35 -07005315 .iommu_map_all = 1,
5316 .iommu_2x_map_domain = VIDEO_DOMAIN,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005317};
5318
5319static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
5320 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugan42ebe712012-01-10 16:30:58 -08005321 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005322 .request_region = request_smi_region,
5323 .release_region = release_smi_region,
5324 .setup_region = setup_smi_region,
5325};
5326
5327static struct ion_cp_heap_pdata cp_wb_ion_pdata = {
5328 .permission_type = IPT_TYPE_MDP_WRITEBACK,
Olav Haugan42ebe712012-01-10 16:30:58 -08005329 .align = PAGE_SIZE,
5330};
5331
Chintan Pandya7c2b9cb2012-06-25 14:35:02 +05305332static struct ion_co_heap_pdata mm_fw_co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005333 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005334};
5335
5336static struct ion_co_heap_pdata co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005337 .adjacent_mem_id = INVALID_HEAP_ID,
5338 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005339};
5340#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005341
5342/**
5343 * These heaps are listed in the order they will be allocated. Due to
5344 * video hardware restrictions and content protection the FW heap has to
5345 * be allocated adjacent (below) the MM heap and the MFC heap has to be
5346 * allocated after the MM heap to ensure MFC heap is not more than 256MB
5347 * away from the base address of the FW heap.
5348 * However, the order of FW heap and MM heap doesn't matter since these
5349 * two heaps are taken care of by separate code to ensure they are adjacent
5350 * to each other.
5351 * Don't swap the order unless you know what you are doing!
5352 */
Benjamin Gaignard63d81032012-06-25 15:27:30 -07005353struct ion_platform_heap msm8x60_heaps [] = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005354 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005355 .id = ION_SYSTEM_HEAP_ID,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005356 .type = ION_HEAP_TYPE_SYSTEM,
5357 .name = ION_VMALLOC_HEAP_NAME,
5358 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005359#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5360 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005361 .id = ION_CP_MM_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005362 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005363 .name = ION_MM_HEAP_NAME,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305364 .base = MSM_ION_MM_BASE,
Olav Hauganb5be7992011-11-18 14:29:02 -08005365 .size = MSM_ION_MM_SIZE,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005366 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005367 .extra_data = (void *) &cp_mm_ion_pdata,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005368 },
Olav Hauganb5be7992011-11-18 14:29:02 -08005369 {
Olav Haugan42ebe712012-01-10 16:30:58 -08005370 .id = ION_MM_FIRMWARE_HEAP_ID,
5371 .type = ION_HEAP_TYPE_CARVEOUT,
5372 .name = ION_MM_FIRMWARE_HEAP_NAME,
Chintan Pandya7c2b9cb2012-06-25 14:35:02 +05305373 .base = MSM_MM_FW_BASE,
5374 .size = MSM_MM_FW_SIZE,
Olav Haugan42ebe712012-01-10 16:30:58 -08005375 .memory_type = ION_SMI_TYPE,
Chintan Pandya7c2b9cb2012-06-25 14:35:02 +05305376 .extra_data = (void *) &mm_fw_co_ion_pdata,
Olav Haugan42ebe712012-01-10 16:30:58 -08005377 },
5378 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005379 .id = ION_CP_MFC_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005380 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005381 .name = ION_MFC_HEAP_NAME,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305382 .base = MSM_ION_MFC_BASE,
Olav Hauganb5be7992011-11-18 14:29:02 -08005383 .size = MSM_ION_MFC_SIZE,
5384 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005385 .extra_data = (void *) &cp_mfc_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005386 },
5387 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005388 .id = ION_SF_HEAP_ID,
5389 .type = ION_HEAP_TYPE_CARVEOUT,
5390 .name = ION_SF_HEAP_NAME,
5391 .size = MSM_ION_SF_SIZE,
5392 .memory_type = ION_EBI_TYPE,
5393 .extra_data = (void *)&co_ion_pdata,
5394 },
5395 {
5396 .id = ION_CAMERA_HEAP_ID,
5397 .type = ION_HEAP_TYPE_CARVEOUT,
5398 .name = ION_CAMERA_HEAP_NAME,
5399 .size = MSM_ION_CAMERA_SIZE,
5400 .memory_type = ION_EBI_TYPE,
5401 .extra_data = &co_ion_pdata,
5402 },
5403 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005404 .id = ION_CP_WB_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005405 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005406 .name = ION_WB_HEAP_NAME,
5407 .size = MSM_ION_WB_SIZE,
5408 .memory_type = ION_EBI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005409 .extra_data = (void *) &cp_wb_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005410 },
Olav Haugan3a55e322012-01-23 14:24:01 -08005411 {
Olav Haugan6ab47252012-02-15 14:46:49 -08005412 .id = ION_QSECOM_HEAP_ID,
5413 .type = ION_HEAP_TYPE_CARVEOUT,
5414 .name = ION_QSECOM_HEAP_NAME,
5415 .size = MSM_ION_QSECOM_SIZE,
5416 .memory_type = ION_EBI_TYPE,
5417 .extra_data = (void *) &co_ion_pdata,
5418 },
5419 {
Olav Haugan3a55e322012-01-23 14:24:01 -08005420 .id = ION_AUDIO_HEAP_ID,
5421 .type = ION_HEAP_TYPE_CARVEOUT,
5422 .name = ION_AUDIO_HEAP_NAME,
5423 .size = MSM_ION_AUDIO_SIZE,
5424 .memory_type = ION_EBI_TYPE,
5425 .extra_data = (void *)&co_ion_pdata,
5426 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005427#endif
Benjamin Gaignard63d81032012-06-25 15:27:30 -07005428};
5429
5430static struct ion_platform_data ion_pdata = {
5431 .nr = MSM_ION_HEAP_NUM,
5432 .heaps = msm8x60_heaps,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005433};
5434
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005435static struct platform_device ion_dev = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005436 .name = "ion-msm",
5437 .id = 1,
5438 .dev = { .platform_data = &ion_pdata },
5439};
5440#endif
5441
5442
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005443static struct memtype_reserve msm8x60_reserve_table[] __initdata = {
5444 /* Kernel SMI memory pool for video core, used for firmware */
5445 /* and encoder, decoder scratch buffers */
5446 /* Kernel SMI memory pool should always precede the user space */
5447 /* SMI memory pool, as the video core will use offset address */
5448 /* from the Firmware base */
5449 [MEMTYPE_SMI_KERNEL] = {
5450 .start = KERNEL_SMI_BASE,
5451 .limit = KERNEL_SMI_SIZE,
5452 .size = KERNEL_SMI_SIZE,
5453 .flags = MEMTYPE_FLAGS_FIXED,
5454 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005455 [MEMTYPE_SMI] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005456 },
5457 [MEMTYPE_EBI0] = {
5458 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5459 },
5460 [MEMTYPE_EBI1] = {
5461 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5462 },
5463};
5464
Stephen Boyd668d7652012-04-25 11:31:01 -07005465static void __init reserve_ion_memory(void)
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005466{
5467#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005468 unsigned int i;
5469
5470 if (hdmi_is_primary) {
5471 msm_ion_sf_size = MSM_HDMI_PRIM_ION_SF_SIZE;
5472 for (i = 0; i < ion_pdata.nr; i++) {
5473 if (ion_pdata.heaps[i].id == ION_SF_HEAP_ID) {
5474 ion_pdata.heaps[i].size = msm_ion_sf_size;
5475 pr_debug("msm_ion_sf_size 0x%x\n",
5476 msm_ion_sf_size);
5477 break;
5478 }
5479 }
5480 }
5481
Olav Haugan8726caf2012-05-10 15:11:35 -07005482 /* Verify size of heap is a multiple of 64K */
5483 for (i = 0; i < ion_pdata.nr; i++) {
5484 struct ion_platform_heap *heap = &(ion_pdata.heaps[i]);
5485
Mitchel Humpherys362b52b2012-09-13 10:53:22 -07005486 if (heap->extra_data &&
5487 heap->type == (enum ion_heap_type) ION_HEAP_TYPE_CP) {
Olav Haugan8726caf2012-05-10 15:11:35 -07005488 int map_all = ((struct ion_cp_heap_pdata *)
5489 heap->extra_data)->iommu_map_all;
5490
5491 if (map_all && (heap->size & (SZ_64K-1))) {
5492 heap->size = ALIGN(heap->size, SZ_64K);
5493 pr_err("Heap %s size is not a multiple of 64K. Adjusting size to %x\n",
5494 heap->name, heap->size);
5495
5496 }
5497 }
5498 }
5499
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005500 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_ion_sf_size;
Olav Hauganb5be7992011-11-18 14:29:02 -08005501 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_CAMERA_SIZE;
5502 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_WB_SIZE;
Olav Haugan3a55e322012-01-23 14:24:01 -08005503 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE;
Olav Haugan8d8c2d12012-04-02 12:01:44 -07005504 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_QSECOM_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005505#endif
5506}
5507
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005508static void __init size_pmem_devices(void)
5509{
5510#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005511#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005512 android_pmem_adsp_pdata.size = pmem_adsp_size;
5513 android_pmem_smipool_pdata.size = MSM_PMEM_SMIPOOL_SIZE;
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005514
5515 if (hdmi_is_primary)
5516 pmem_sf_size = MSM_HDMI_PRIM_PMEM_SF_SIZE;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005517 android_pmem_pdata.size = pmem_sf_size;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005518 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305519#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5520#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005521}
5522
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305523#ifdef CONFIG_ANDROID_PMEM
5524#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005525static void __init reserve_memory_for(struct android_pmem_platform_data *p)
5526{
5527 msm8x60_reserve_table[p->memory_type].size += p->size;
5528}
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305529#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5530#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005531
5532static void __init reserve_pmem_memory(void)
5533{
5534#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005535#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005536 reserve_memory_for(&android_pmem_adsp_pdata);
5537 reserve_memory_for(&android_pmem_smipool_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005538 reserve_memory_for(&android_pmem_pdata);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005539 reserve_memory_for(&android_pmem_audio_pdata);
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305540#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005541 msm8x60_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305542#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005543}
5544
Huaibin Yanga5419422011-12-08 23:52:10 -08005545static void __init reserve_mdp_memory(void);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005546
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305547static void __init reserve_rtb_memory(void)
5548{
5549#if defined(CONFIG_MSM_RTB)
5550 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_rtb_pdata.size;
5551#endif
5552}
5553
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005554static void __init msm8x60_calculate_reserve_sizes(void)
5555{
5556 size_pmem_devices();
5557 reserve_pmem_memory();
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005558 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -08005559 reserve_mdp_memory();
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305560 reserve_rtb_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005561}
5562
5563static int msm8x60_paddr_to_memtype(unsigned int paddr)
5564{
5565 if (paddr >= 0x40000000 && paddr < 0x60000000)
5566 return MEMTYPE_EBI1;
5567 if (paddr >= 0x38000000 && paddr < 0x40000000)
5568 return MEMTYPE_SMI;
5569 return MEMTYPE_NONE;
5570}
5571
5572static struct reserve_info msm8x60_reserve_info __initdata = {
5573 .memtype_reserve_table = msm8x60_reserve_table,
5574 .calculate_reserve_sizes = msm8x60_calculate_reserve_sizes,
5575 .paddr_to_memtype = msm8x60_paddr_to_memtype,
5576};
5577
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005578static char prim_panel_name[PANEL_NAME_MAX_LEN];
5579static char ext_panel_name[PANEL_NAME_MAX_LEN];
5580static int __init prim_display_setup(char *param)
5581{
5582 if (strnlen(param, PANEL_NAME_MAX_LEN))
5583 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
5584 return 0;
5585}
5586early_param("prim_display", prim_display_setup);
5587
5588static int __init ext_display_setup(char *param)
5589{
5590 if (strnlen(param, PANEL_NAME_MAX_LEN))
5591 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
5592 return 0;
5593}
5594early_param("ext_display", ext_display_setup);
5595
Stephen Boyd9e775ad2011-08-12 00:14:28 +01005596static void __init msm8x60_reserve(void)
5597{
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005598 msm8x60_set_display_params(prim_panel_name, ext_panel_name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005599 reserve_info = &msm8x60_reserve_info;
5600 msm_reserve();
5601}
5602
5603#define EXT_CHG_VALID_MPP 10
5604#define EXT_CHG_VALID_MPP_2 11
5605
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305606static struct pm8xxx_mpp_init_info isl_mpp[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305607 PM8058_MPP_INIT(EXT_CHG_VALID_MPP, D_INPUT,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305608 PM8058_MPP_DIG_LEVEL_S3, DIN_TO_INT),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305609 PM8058_MPP_INIT(EXT_CHG_VALID_MPP_2, D_BI_DIR,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305610 PM8058_MPP_DIG_LEVEL_S3, BI_PULLUP_10KOHM),
5611};
5612
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005613#ifdef CONFIG_ISL9519_CHARGER
5614static int isl_detection_setup(void)
5615{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305616 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005617
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305618 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5619 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5620 &isl_mpp[i].config);
5621 if (ret) {
5622 pr_err("%s: Config MPP %d of PM8058 failed\n",
5623 __func__, isl_mpp[i].mpp);
5624 return ret;
5625 }
5626 }
5627
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005628 return ret;
5629}
5630
5631static struct isl_platform_data isl_data __initdata = {
5632 .chgcurrent = 700,
5633 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5634 .chg_detection_config = isl_detection_setup,
5635 .max_system_voltage = 4200,
5636 .min_system_voltage = 3200,
5637 .term_current = 120,
5638 .input_current = 2048,
5639};
5640
5641static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
5642 {
5643 I2C_BOARD_INFO("isl9519q", 0x9),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305644 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005645 .platform_data = &isl_data,
5646 },
5647};
5648#endif
5649
5650#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
5651static int smb137b_detection_setup(void)
5652{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305653 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005654
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305655 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5656 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5657 &isl_mpp[i].config);
5658 if (ret) {
5659 pr_err("%s: Config MPP %d of PM8058 failed\n",
5660 __func__, isl_mpp[i].mpp);
5661 return ret;
5662 }
5663 }
5664
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005665 return ret;
5666}
5667
5668static struct smb137b_platform_data smb137b_data __initdata = {
5669 .chg_detection_config = smb137b_detection_setup,
5670 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5671 .batt_mah_rating = 950,
5672};
5673
5674static struct i2c_board_info smb137b_charger_i2c_info[] __initdata = {
5675 {
5676 I2C_BOARD_INFO("smb137b", 0x08),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305677 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005678 .platform_data = &smb137b_data,
5679 },
5680};
5681#endif
5682
5683#ifdef CONFIG_PMIC8058
5684#define PMIC_GPIO_SDC3_DET 22
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305685#define PMIC_GPIO_TOUCH_DISC_INTR 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005686
5687static int pm8058_gpios_init(void)
5688{
5689 int i;
5690 int rc;
5691 struct pm8058_gpio_cfg {
5692 int gpio;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305693 struct pm_gpio cfg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005694 };
5695
5696 struct pm8058_gpio_cfg gpio_cfgs[] = {
5697 { /* FFA ethernet */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305698 PM8058_GPIO_PM_TO_SYS(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005699 {
5700 .direction = PM_GPIO_DIR_IN,
5701 .pull = PM_GPIO_PULL_DN,
5702 .vin_sel = 2,
5703 .function = PM_GPIO_FUNC_NORMAL,
5704 .inv_int_pol = 0,
5705 },
5706 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005707 {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305708 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005709 {
5710 .direction = PM_GPIO_DIR_IN,
5711 .pull = PM_GPIO_PULL_UP_30,
5712 .vin_sel = 2,
5713 .function = PM_GPIO_FUNC_NORMAL,
5714 .inv_int_pol = 0,
5715 },
5716 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005717 { /* core&surf gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305718 PM8058_GPIO_PM_TO_SYS(UI_INT1_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005719 {
5720 .direction = PM_GPIO_DIR_IN,
5721 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305722 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005723 .function = PM_GPIO_FUNC_NORMAL,
5724 .inv_int_pol = 0,
5725 },
5726 },
5727 { /* docking gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305728 PM8058_GPIO_PM_TO_SYS(UI_INT2_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005729 {
5730 .direction = PM_GPIO_DIR_IN,
5731 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305732 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005733 .function = PM_GPIO_FUNC_NORMAL,
5734 .inv_int_pol = 0,
5735 },
5736 },
5737 { /* FHA/keypad gpio expanders */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305738 PM8058_GPIO_PM_TO_SYS(UI_INT3_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005739 {
5740 .direction = PM_GPIO_DIR_IN,
5741 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305742 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005743 .function = PM_GPIO_FUNC_NORMAL,
5744 .inv_int_pol = 0,
5745 },
5746 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005747 { /* Timpani Reset */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305748 PM8058_GPIO_PM_TO_SYS(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005749 {
5750 .direction = PM_GPIO_DIR_OUT,
5751 .output_value = 1,
5752 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5753 .pull = PM_GPIO_PULL_DN,
5754 .out_strength = PM_GPIO_STRENGTH_HIGH,
5755 .function = PM_GPIO_FUNC_NORMAL,
5756 .vin_sel = 2,
5757 .inv_int_pol = 0,
5758 }
5759 },
5760 { /* PMIC ID interrupt */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305761 PM8058_GPIO_PM_TO_SYS(36),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005762 {
5763 .direction = PM_GPIO_DIR_IN,
Anji jonnalaae745e92011-11-14 18:34:31 +05305764 .pull = PM_GPIO_PULL_NO,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005765 .function = PM_GPIO_FUNC_NORMAL,
5766 .vin_sel = 2,
5767 .inv_int_pol = 0,
5768 }
5769 },
5770 };
5771
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305772#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5773 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305774 struct pm_gpio touchdisc_intr_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305775 .direction = PM_GPIO_DIR_IN,
5776 .pull = PM_GPIO_PULL_UP_1P5,
5777 .vin_sel = 2,
5778 .function = PM_GPIO_FUNC_NORMAL,
5779 };
5780#endif
5781
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005782#if defined(CONFIG_HAPTIC_ISA1200) || \
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305783 defined(CONFIG_HAPTIC_ISA1200_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305784 struct pm_gpio en_hap_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305785 .direction = PM_GPIO_DIR_OUT,
5786 .pull = PM_GPIO_PULL_NO,
5787 .out_strength = PM_GPIO_STRENGTH_HIGH,
5788 .function = PM_GPIO_FUNC_NORMAL,
5789 .inv_int_pol = 0,
5790 .vin_sel = 2,
5791 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5792 .output_value = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005793 };
5794#endif
5795
5796#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5797 struct pm8058_gpio_cfg line_in_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305798 PM8058_GPIO_PM_TO_SYS(18),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005799 {
5800 .direction = PM_GPIO_DIR_IN,
5801 .pull = PM_GPIO_PULL_UP_1P5,
5802 .vin_sel = 2,
5803 .function = PM_GPIO_FUNC_NORMAL,
5804 .inv_int_pol = 0,
5805 }
5806 };
5807#endif
5808
5809#if defined(CONFIG_QS_S5K4E1)
5810 {
5811 struct pm8058_gpio_cfg qs_hc37_cam_pd_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305812 PM8058_GPIO_PM_TO_SYS(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005813 {
5814 .direction = PM_GPIO_DIR_OUT,
5815 .output_value = 0,
5816 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5817 .pull = PM_GPIO_PULL_DN,
5818 .out_strength = PM_GPIO_STRENGTH_HIGH,
5819 .function = PM_GPIO_FUNC_NORMAL,
5820 .vin_sel = 2,
5821 .inv_int_pol = 0,
5822 }
5823 };
5824#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005825#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5826 struct pm8058_gpio_cfg pmic_lcdc_nt35582_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305827 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1),
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005828 {
5829 .direction = PM_GPIO_DIR_OUT,
5830 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5831 .output_value = 1,
5832 .pull = PM_GPIO_PULL_UP_30,
5833 /* 2.9V PM_GPIO_VIN_L2, which gives 2.6V */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305834 .vin_sel = PM8058_GPIO_VIN_L5,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005835 .out_strength = PM_GPIO_STRENGTH_HIGH,
5836 .function = PM_GPIO_FUNC_NORMAL,
5837 .inv_int_pol = 0,
5838 }
5839 };
5840#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005841#if defined(CONFIG_HAPTIC_ISA1200) || \
5842 defined(CONFIG_HAPTIC_ISA1200_MODULE)
5843 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305844 rc = pm8xxx_gpio_config(
5845 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
5846 &en_hap_gpio_cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005847 if (rc < 0) {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305848 pr_err("%s: pmic haptics gpio config failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005849 __func__);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305850 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305851 rc = pm8xxx_gpio_config(
5852 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
5853 &en_hap_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305854 if (rc < 0) {
5855 pr_err("%s: pmic haptics ldo gpio config failed\n",
5856 __func__);
5857 }
5858
5859 }
5860#endif
5861
5862#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5863 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
5864 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
5865 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305866 rc = pm8xxx_gpio_config(
5867 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_TOUCH_DISC_INTR),
5868 &touchdisc_intr_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305869 if (rc < 0) {
5870 pr_err("%s: Touchdisc interrupt gpio config failed\n",
5871 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005872 }
5873 }
5874#endif
5875
5876#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5877 /* Line_in only for 8660 ffa & surf */
5878 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04005879 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005880 machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305881 rc = pm8xxx_gpio_config(line_in_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005882 &line_in_gpio_cfg.cfg);
5883 if (rc < 0) {
5884 pr_err("%s pmic line_in gpio config failed\n",
5885 __func__);
5886 return rc;
5887 }
5888 }
5889#endif
5890
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005891#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5892 if (machine_is_msm8x60_dragon()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305893 rc = pm8xxx_gpio_config(pmic_lcdc_nt35582_gpio_cfg.gpio,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005894 &pmic_lcdc_nt35582_gpio_cfg.cfg);
5895 if (rc < 0) {
5896 pr_err("%s pmic gpio config failed\n", __func__);
5897 return rc;
5898 }
5899 }
5900#endif
5901
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005902#if defined(CONFIG_QS_S5K4E1)
5903 /* qs_cam_hc37_cam_pd only for 8660 fluid qs camera*/
5904 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305905 rc = pm8xxx_gpio_config(qs_hc37_cam_pd_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005906 &qs_hc37_cam_pd_gpio_cfg.cfg);
5907 if (rc < 0) {
5908 pr_err("%s pmic qs_hc37_cam_pd gpio config failed\n",
5909 __func__);
5910 return rc;
5911 }
5912 }
5913 }
5914#endif
5915
5916 for (i = 0; i < ARRAY_SIZE(gpio_cfgs); ++i) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305917 rc = pm8xxx_gpio_config(gpio_cfgs[i].gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005918 &gpio_cfgs[i].cfg);
5919 if (rc < 0) {
5920 pr_err("%s pmic gpio config failed\n",
5921 __func__);
5922 return rc;
5923 }
5924 }
5925
5926 return 0;
5927}
5928
5929static const unsigned int ffa_keymap[] = {
5930 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5931 KEY(0, 1, KEY_UP), /* NAV - UP */
5932 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5933 KEY(0, 3, KEY_VOLUMEUP), /* Shuttle SW_UP */
5934
5935 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5936 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5937 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5938 KEY(1, 3, KEY_VOLUMEDOWN),
5939
5940 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5941
5942 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5943 KEY(4, 1, KEY_UP), /* USER_UP */
5944 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5945 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5946 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5947
5948 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
5949 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5950 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5951 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5952 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5953};
5954
Zhang Chang Ken683be172011-08-10 17:45:34 -04005955static const unsigned int dragon_keymap[] = {
5956 KEY(0, 0, KEY_MENU),
5957 KEY(0, 2, KEY_1),
5958 KEY(0, 3, KEY_4),
5959 KEY(0, 4, KEY_7),
5960
5961 KEY(1, 0, KEY_UP),
5962 KEY(1, 1, KEY_LEFT),
5963 KEY(1, 2, KEY_DOWN),
5964 KEY(1, 3, KEY_5),
5965 KEY(1, 4, KEY_8),
5966
5967 KEY(2, 0, KEY_HOME),
5968 KEY(2, 1, KEY_REPLY),
5969 KEY(2, 2, KEY_2),
5970 KEY(2, 3, KEY_6),
5971 KEY(2, 4, KEY_0),
5972
5973 KEY(3, 0, KEY_VOLUMEUP),
5974 KEY(3, 1, KEY_RIGHT),
5975 KEY(3, 2, KEY_3),
5976 KEY(3, 3, KEY_9),
5977 KEY(3, 4, KEY_SWITCHVIDEOMODE),
5978
5979 KEY(4, 0, KEY_VOLUMEDOWN),
5980 KEY(4, 1, KEY_BACK),
5981 KEY(4, 2, KEY_CAMERA),
5982 KEY(4, 3, KEY_KBDILLUMTOGGLE),
5983};
5984
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005985static struct matrix_keymap_data ffa_keymap_data = {
5986 .keymap_size = ARRAY_SIZE(ffa_keymap),
5987 .keymap = ffa_keymap,
5988};
5989
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305990static struct pm8xxx_keypad_platform_data ffa_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005991 .input_name = "ffa-keypad",
5992 .input_phys_device = "ffa-keypad/input0",
5993 .num_rows = 6,
5994 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305995 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5996 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5997 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005998 .scan_delay_ms = 32,
5999 .row_hold_ns = 91500,
6000 .wakeup = 1,
6001 .keymap_data = &ffa_keymap_data,
6002};
6003
Zhang Chang Ken683be172011-08-10 17:45:34 -04006004static struct matrix_keymap_data dragon_keymap_data = {
6005 .keymap_size = ARRAY_SIZE(dragon_keymap),
6006 .keymap = dragon_keymap,
6007};
6008
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306009static struct pm8xxx_keypad_platform_data dragon_keypad_data = {
Zhang Chang Ken683be172011-08-10 17:45:34 -04006010 .input_name = "dragon-keypad",
6011 .input_phys_device = "dragon-keypad/input0",
6012 .num_rows = 6,
6013 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306014 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
6015 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
6016 .debounce_ms = 15,
Zhang Chang Ken683be172011-08-10 17:45:34 -04006017 .scan_delay_ms = 32,
6018 .row_hold_ns = 91500,
6019 .wakeup = 1,
6020 .keymap_data = &dragon_keymap_data,
6021};
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306022
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006023static const unsigned int fluid_keymap[] = {
6024 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
6025 KEY(0, 1, KEY_UP), /* NAV - UP */
6026 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
6027 KEY(0, 3, KEY_VOLUMEDOWN), /* Shuttle SW_UP */
6028
6029 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
6030 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
6031 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
6032 KEY(1, 3, KEY_VOLUMEUP),
6033
6034 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
6035
6036 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
6037 KEY(4, 1, KEY_UP), /* USER_UP */
6038 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
6039 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
6040 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
6041
Jilai Wang9a895102011-07-12 14:00:35 -04006042 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006043 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
6044 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
6045 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
6046 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
6047};
6048
6049static struct matrix_keymap_data fluid_keymap_data = {
6050 .keymap_size = ARRAY_SIZE(fluid_keymap),
6051 .keymap = fluid_keymap,
6052};
6053
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306054static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006055 .input_name = "fluid-keypad",
6056 .input_phys_device = "fluid-keypad/input0",
6057 .num_rows = 6,
6058 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306059 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
6060 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
6061 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006062 .scan_delay_ms = 32,
6063 .row_hold_ns = 91500,
6064 .wakeup = 1,
6065 .keymap_data = &fluid_keymap_data,
6066};
6067
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306068static struct pm8xxx_vibrator_platform_data pm8058_vib_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006069 .initial_vibrate_ms = 500,
6070 .level_mV = 3000,
6071 .max_timeout_ms = 15000,
6072};
6073
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306074static struct pm8xxx_rtc_platform_data pm8058_rtc_pdata = {
6075 .rtc_write_enable = false,
6076 .rtc_alarm_powerup = false,
6077};
6078
6079static struct pm8xxx_pwrkey_platform_data pm8058_pwrkey_pdata = {
6080 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -08006081 .kpd_trigger_delay_us = 15625,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306082 .wakeup = 1,
6083};
6084
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006085#define PM8058_LINE_IN_DET_GPIO PM8058_GPIO_PM_TO_SYS(18)
6086
6087static struct othc_accessory_info othc_accessories[] = {
6088 {
6089 .accessory = OTHC_SVIDEO_OUT,
6090 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT
6091 | OTHC_ADC_DETECT,
6092 .key_code = SW_VIDEOOUT_INSERT,
6093 .enabled = false,
6094 .adc_thres = {
6095 .min_threshold = 20,
6096 .max_threshold = 40,
6097 },
6098 },
6099 {
6100 .accessory = OTHC_ANC_HEADPHONE,
6101 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT |
6102 OTHC_SWITCH_DETECT,
6103 .gpio = PM8058_LINE_IN_DET_GPIO,
6104 .active_low = 1,
6105 .key_code = SW_HEADPHONE_INSERT,
6106 .enabled = true,
6107 },
6108 {
6109 .accessory = OTHC_ANC_HEADSET,
6110 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT,
6111 .gpio = PM8058_LINE_IN_DET_GPIO,
6112 .active_low = 1,
6113 .key_code = SW_HEADPHONE_INSERT,
6114 .enabled = true,
6115 },
6116 {
6117 .accessory = OTHC_HEADPHONE,
6118 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT,
6119 .key_code = SW_HEADPHONE_INSERT,
6120 .enabled = true,
6121 },
6122 {
6123 .accessory = OTHC_MICROPHONE,
6124 .detect_flags = OTHC_GPIO_DETECT,
6125 .gpio = PM8058_LINE_IN_DET_GPIO,
6126 .active_low = 1,
6127 .key_code = SW_MICROPHONE_INSERT,
6128 .enabled = true,
6129 },
6130 {
6131 .accessory = OTHC_HEADSET,
6132 .detect_flags = OTHC_MICBIAS_DETECT,
6133 .key_code = SW_HEADPHONE_INSERT,
6134 .enabled = true,
6135 },
6136};
6137
6138static struct othc_switch_info switch_info[] = {
6139 {
6140 .min_adc_threshold = 0,
6141 .max_adc_threshold = 100,
6142 .key_code = KEY_PLAYPAUSE,
6143 },
6144 {
6145 .min_adc_threshold = 100,
6146 .max_adc_threshold = 200,
6147 .key_code = KEY_REWIND,
6148 },
6149 {
6150 .min_adc_threshold = 200,
6151 .max_adc_threshold = 500,
6152 .key_code = KEY_FASTFORWARD,
6153 },
6154};
6155
6156static struct othc_n_switch_config switch_config = {
6157 .voltage_settling_time_ms = 0,
6158 .num_adc_samples = 3,
6159 .adc_channel = CHANNEL_ADC_HDSET,
6160 .switch_info = switch_info,
6161 .num_keys = ARRAY_SIZE(switch_info),
6162 .default_sw_en = true,
6163 .default_sw_idx = 0,
6164};
6165
6166static struct hsed_bias_config hsed_bias_config = {
6167 /* HSED mic bias config info */
6168 .othc_headset = OTHC_HEADSET_NO,
6169 .othc_lowcurr_thresh_uA = 100,
6170 .othc_highcurr_thresh_uA = 600,
6171 .othc_hyst_prediv_us = 7800,
6172 .othc_period_clkdiv_us = 62500,
6173 .othc_hyst_clk_us = 121000,
6174 .othc_period_clk_us = 312500,
6175 .othc_wakeup = 1,
6176};
6177
6178static struct othc_hsed_config hsed_config_1 = {
6179 .hsed_bias_config = &hsed_bias_config,
6180 /*
6181 * The detection delay and switch reporting delay are
6182 * required to encounter a hardware bug (spurious switch
6183 * interrupts on slow insertion/removal of the headset).
6184 * This will introduce a delay in reporting the accessory
6185 * insertion and removal to the userspace.
6186 */
6187 .detection_delay_ms = 1500,
6188 /* Switch info */
6189 .switch_debounce_ms = 1500,
6190 .othc_support_n_switch = false,
6191 .switch_config = &switch_config,
6192 .ir_gpio = -1,
6193 /* Accessory info */
6194 .accessories_support = true,
6195 .accessories = othc_accessories,
6196 .othc_num_accessories = ARRAY_SIZE(othc_accessories),
6197};
6198
6199static struct othc_regulator_config othc_reg = {
6200 .regulator = "8058_l5",
6201 .max_uV = 2850000,
6202 .min_uV = 2850000,
6203};
6204
6205/* MIC_BIAS0 is configured as normal MIC BIAS */
6206static struct pmic8058_othc_config_pdata othc_config_pdata_0 = {
6207 .micbias_select = OTHC_MICBIAS_0,
6208 .micbias_capability = OTHC_MICBIAS,
6209 .micbias_enable = OTHC_SIGNAL_OFF,
6210 .micbias_regulator = &othc_reg,
6211};
6212
6213/* MIC_BIAS1 is configured as HSED_BIAS for OTHC */
6214static struct pmic8058_othc_config_pdata othc_config_pdata_1 = {
6215 .micbias_select = OTHC_MICBIAS_1,
6216 .micbias_capability = OTHC_MICBIAS_HSED,
6217 .micbias_enable = OTHC_SIGNAL_PWM_TCXO,
6218 .micbias_regulator = &othc_reg,
6219 .hsed_config = &hsed_config_1,
6220 .hsed_name = "8660_handset",
6221};
6222
6223/* MIC_BIAS2 is configured as normal MIC BIAS */
6224static struct pmic8058_othc_config_pdata othc_config_pdata_2 = {
6225 .micbias_select = OTHC_MICBIAS_2,
6226 .micbias_capability = OTHC_MICBIAS,
6227 .micbias_enable = OTHC_SIGNAL_OFF,
6228 .micbias_regulator = &othc_reg,
6229};
6230
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006231
6232static void __init msm8x60_init_pm8058_othc(void)
6233{
6234 int i;
6235
6236 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 ||
6237 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
6238 machine_is_msm8x60_fusn_ffa()) {
6239 /* 3-switch headset supported only by V2 FFA and FLUID */
6240 hsed_config_1.accessories_adc_support = true,
6241 /* ADC based accessory detection works only on V2 and FLUID */
6242 hsed_config_1.accessories_adc_channel = CHANNEL_ADC_HDSET,
6243 hsed_config_1.othc_support_n_switch = true;
6244 }
6245
6246 /* IR GPIO is absent on FLUID */
6247 if (machine_is_msm8x60_fluid())
6248 hsed_config_1.ir_gpio = -1;
6249
6250 for (i = 0; i < ARRAY_SIZE(othc_accessories); i++) {
6251 if (machine_is_msm8x60_fluid()) {
6252 switch (othc_accessories[i].accessory) {
6253 case OTHC_ANC_HEADPHONE:
6254 case OTHC_ANC_HEADSET:
6255 othc_accessories[i].gpio = GPIO_HEADSET_DET_N;
6256 break;
6257 case OTHC_MICROPHONE:
6258 othc_accessories[i].enabled = false;
6259 break;
6260 case OTHC_SVIDEO_OUT:
6261 othc_accessories[i].enabled = true;
6262 hsed_config_1.video_out_gpio = GPIO_HS_SW_DIR;
6263 break;
6264 }
6265 }
6266 }
6267}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006268
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006269
6270static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
6271{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306272 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006273 .direction = PM_GPIO_DIR_OUT,
6274 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
6275 .output_value = 0,
6276 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306277 .vin_sel = PM8058_GPIO_VIN_VPH,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006278 .out_strength = PM_GPIO_STRENGTH_HIGH,
6279 .function = PM_GPIO_FUNC_2,
6280 };
6281
6282 int rc = -EINVAL;
6283 int id, mode, max_mA;
6284
6285 id = mode = max_mA = 0;
6286 switch (ch) {
6287 case 0:
6288 case 1:
6289 case 2:
6290 if (on) {
6291 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306292 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
6293 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006294 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306295 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006296 __func__, id, rc);
6297 }
6298 break;
6299
6300 case 6:
6301 id = PM_PWM_LED_FLASH;
6302 mode = PM_PWM_CONF_PWM1;
6303 max_mA = 300;
6304 break;
6305
6306 case 7:
6307 id = PM_PWM_LED_FLASH1;
6308 mode = PM_PWM_CONF_PWM1;
6309 max_mA = 300;
6310 break;
6311
6312 default:
6313 break;
6314 }
6315
6316 if (ch >= 6 && ch <= 7) {
6317 if (!on) {
6318 mode = PM_PWM_CONF_NONE;
6319 max_mA = 0;
6320 }
6321 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
6322 if (rc)
6323 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
6324 __func__, ch, rc);
6325 }
6326 return rc;
6327
6328}
6329
6330static struct pm8058_pwm_pdata pm8058_pwm_data = {
6331 .config = pm8058_pwm_config,
6332};
6333
6334#define PM8058_GPIO_INT 88
6335
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006336static struct pmic8058_led pmic8058_flash_leds[] = {
6337 [0] = {
6338 .name = "camera:flash0",
6339 .max_brightness = 15,
6340 .id = PMIC8058_ID_FLASH_LED_0,
6341 },
6342 [1] = {
6343 .name = "camera:flash1",
6344 .max_brightness = 15,
6345 .id = PMIC8058_ID_FLASH_LED_1,
6346 },
6347};
6348
6349static struct pmic8058_leds_platform_data pm8058_flash_leds_data = {
6350 .num_leds = ARRAY_SIZE(pmic8058_flash_leds),
6351 .leds = pmic8058_flash_leds,
6352};
6353
Terence Hampsonc0b6dfb2011-07-15 11:07:17 -04006354static struct pmic8058_led pmic8058_dragon_leds[] = {
6355 [0] = {
6356 /* RED */
6357 .name = "led_drv0",
6358 .max_brightness = 15,
6359 .id = PMIC8058_ID_LED_0,
6360 },/* 300 mA flash led0 drv sink */
6361 [1] = {
6362 /* Yellow */
6363 .name = "led_drv1",
6364 .max_brightness = 15,
6365 .id = PMIC8058_ID_LED_1,
6366 },/* 300 mA flash led0 drv sink */
6367 [2] = {
6368 /* Green */
6369 .name = "led_drv2",
6370 .max_brightness = 15,
6371 .id = PMIC8058_ID_LED_2,
6372 },/* 300 mA flash led0 drv sink */
6373 [3] = {
6374 .name = "led_psensor",
6375 .max_brightness = 15,
6376 .id = PMIC8058_ID_LED_KB_LIGHT,
6377 },/* 300 mA flash led0 drv sink */
6378};
6379
6380static struct pmic8058_leds_platform_data pm8058_dragon_leds_data = {
6381 .num_leds = ARRAY_SIZE(pmic8058_dragon_leds),
6382 .leds = pmic8058_dragon_leds,
6383};
6384
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006385static struct pmic8058_led pmic8058_fluid_flash_leds[] = {
6386 [0] = {
6387 .name = "led:drv0",
6388 .max_brightness = 15,
6389 .id = PMIC8058_ID_FLASH_LED_0,
6390 },/* 300 mA flash led0 drv sink */
6391 [1] = {
6392 .name = "led:drv1",
6393 .max_brightness = 15,
6394 .id = PMIC8058_ID_FLASH_LED_1,
6395 },/* 300 mA flash led1 sink */
6396 [2] = {
6397 .name = "led:drv2",
6398 .max_brightness = 20,
6399 .id = PMIC8058_ID_LED_0,
6400 },/* 40 mA led0 sink */
6401 [3] = {
6402 .name = "keypad:drv",
6403 .max_brightness = 15,
6404 .id = PMIC8058_ID_LED_KB_LIGHT,
6405 },/* 300 mA keypad drv sink */
6406};
6407
6408static struct pmic8058_leds_platform_data pm8058_fluid_flash_leds_data = {
6409 .num_leds = ARRAY_SIZE(pmic8058_fluid_flash_leds),
6410 .leds = pmic8058_fluid_flash_leds,
6411};
6412
Terence Hampson90508a92011-08-09 10:40:08 -04006413static struct pmic8058_charger_data pmic8058_charger_dragon = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306414 .charger_data_valid = true,
Terence Hampson90508a92011-08-09 10:40:08 -04006415 .max_source_current = 1800,
6416 .charger_type = CHG_TYPE_AC,
6417};
6418
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306419static struct pmic8058_charger_data pmic8058_charger_ffa_surf = {
6420 .charger_data_valid = false,
6421};
6422
6423static struct pm8xxx_misc_platform_data pm8058_misc_pdata = {
6424 .priority = 0,
6425};
6426
6427static struct pm8xxx_irq_platform_data pm8058_irq_pdata = {
6428 .irq_base = PM8058_IRQ_BASE,
6429 .devirq = MSM_GPIO_TO_INT(PM8058_GPIO_INT),
6430 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6431};
6432
6433static struct pm8xxx_gpio_platform_data pm8058_gpio_pdata = {
6434 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
6435};
6436
6437static struct pm8xxx_mpp_platform_data pm8058_mpp_pdata = {
6438 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006439};
6440
6441static struct pm8058_platform_data pm8058_platform_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306442 .irq_pdata = &pm8058_irq_pdata,
6443 .gpio_pdata = &pm8058_gpio_pdata,
6444 .mpp_pdata = &pm8058_mpp_pdata,
6445 .rtc_pdata = &pm8058_rtc_pdata,
6446 .pwrkey_pdata = &pm8058_pwrkey_pdata,
6447 .othc0_pdata = &othc_config_pdata_0,
6448 .othc1_pdata = &othc_config_pdata_1,
6449 .othc2_pdata = &othc_config_pdata_2,
6450 .pwm_pdata = &pm8058_pwm_data,
6451 .misc_pdata = &pm8058_misc_pdata,
6452#ifdef CONFIG_SENSORS_MSM_ADC
6453 .xoadc_pdata = &pm8058_xoadc_pdata,
6454#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006455};
6456
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306457#ifdef CONFIG_MSM_SSBI
6458static struct msm_ssbi_platform_data msm8x60_ssbi_pm8058_pdata __devinitdata = {
6459 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6460 .slave = {
6461 .name = "pm8058-core",
6462 .platform_data = &pm8058_platform_data,
6463 },
6464};
6465#endif
6466#endif /* CONFIG_PMIC8058 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006467
6468#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
6469 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
6470#define TDISC_I2C_SLAVE_ADDR 0x67
6471#define PMIC_GPIO_TDISC PM8058_GPIO_PM_TO_SYS(5)
6472#define TDISC_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 5)
6473
6474static const char *vregs_tdisc_name[] = {
6475 "8058_l5",
6476 "8058_s3",
6477};
6478
6479static const int vregs_tdisc_val[] = {
6480 2850000,/* uV */
6481 1800000,
6482};
6483static struct regulator *vregs_tdisc[ARRAY_SIZE(vregs_tdisc_name)];
6484
6485static int tdisc_shinetsu_setup(void)
6486{
6487 int rc, i;
6488
6489 rc = gpio_request(PMIC_GPIO_TDISC, "tdisc_interrupt");
6490 if (rc) {
6491 pr_err("%s: gpio_request failed for PMIC_GPIO_TDISC\n",
6492 __func__);
6493 return rc;
6494 }
6495
6496 rc = gpio_request(GPIO_JOYSTICK_EN, "tdisc_oe");
6497 if (rc) {
6498 pr_err("%s: gpio_request failed for GPIO_JOYSTICK_EN\n",
6499 __func__);
6500 goto fail_gpio_oe;
6501 }
6502
6503 rc = gpio_direction_output(GPIO_JOYSTICK_EN, 1);
6504 if (rc) {
6505 pr_err("%s: gpio_direction_output failed for GPIO_JOYSTICK_EN\n",
6506 __func__);
6507 gpio_free(GPIO_JOYSTICK_EN);
6508 goto fail_gpio_oe;
6509 }
6510
6511 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6512 vregs_tdisc[i] = regulator_get(NULL, vregs_tdisc_name[i]);
6513 if (IS_ERR(vregs_tdisc[i])) {
6514 printk(KERN_ERR "%s: regulator get %s failed (%ld)\n",
6515 __func__, vregs_tdisc_name[i],
6516 PTR_ERR(vregs_tdisc[i]));
6517 rc = PTR_ERR(vregs_tdisc[i]);
6518 goto vreg_get_fail;
6519 }
6520
6521 rc = regulator_set_voltage(vregs_tdisc[i],
6522 vregs_tdisc_val[i], vregs_tdisc_val[i]);
6523 if (rc) {
6524 printk(KERN_ERR "%s: regulator_set_voltage() = %d\n",
6525 __func__, rc);
6526 goto vreg_set_voltage_fail;
6527 }
6528 }
6529
6530 return rc;
6531vreg_set_voltage_fail:
6532 i++;
6533vreg_get_fail:
6534 while (i)
6535 regulator_put(vregs_tdisc[--i]);
6536fail_gpio_oe:
6537 gpio_free(PMIC_GPIO_TDISC);
6538 return rc;
6539}
6540
6541static void tdisc_shinetsu_release(void)
6542{
6543 int i;
6544
6545 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++)
6546 regulator_put(vregs_tdisc[i]);
6547
6548 gpio_free(PMIC_GPIO_TDISC);
6549 gpio_free(GPIO_JOYSTICK_EN);
6550}
6551
6552static int tdisc_shinetsu_enable(void)
6553{
6554 int i, rc = -EINVAL;
6555
6556 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6557 rc = regulator_enable(vregs_tdisc[i]);
6558 if (rc < 0) {
6559 printk(KERN_ERR "%s: vreg %s enable failed (%d)\n",
6560 __func__, vregs_tdisc_name[i], rc);
6561 goto vreg_fail;
6562 }
6563 }
6564
6565 /* Enable the OE (output enable) gpio */
6566 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 1);
6567 /* voltage and gpio stabilization delay */
6568 msleep(50);
6569
6570 return 0;
6571vreg_fail:
6572 while (i)
6573 regulator_disable(vregs_tdisc[--i]);
6574 return rc;
6575}
6576
6577static int tdisc_shinetsu_disable(void)
6578{
6579 int i, rc;
6580
6581 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6582 rc = regulator_disable(vregs_tdisc[i]);
6583 if (rc < 0) {
6584 printk(KERN_ERR "%s: vreg %s disable failed (%d)\n",
6585 __func__, vregs_tdisc_name[i], rc);
6586 goto tdisc_reg_fail;
6587 }
6588 }
6589
6590 /* Disable the OE (output enable) gpio */
6591 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 0);
6592
6593 return 0;
6594
6595tdisc_reg_fail:
6596 while (i)
6597 regulator_enable(vregs_tdisc[--i]);
6598 return rc;
6599}
6600
6601static struct tdisc_abs_values tdisc_abs = {
6602 .x_max = 32,
6603 .y_max = 32,
6604 .x_min = -32,
6605 .y_min = -32,
6606 .pressure_max = 32,
6607 .pressure_min = 0,
6608};
6609
6610static struct tdisc_platform_data tdisc_data = {
6611 .tdisc_setup = tdisc_shinetsu_setup,
6612 .tdisc_release = tdisc_shinetsu_release,
6613 .tdisc_enable = tdisc_shinetsu_enable,
6614 .tdisc_disable = tdisc_shinetsu_disable,
6615 .tdisc_wakeup = 0,
6616 .tdisc_gpio = PMIC_GPIO_TDISC,
6617 .tdisc_report_keys = true,
6618 .tdisc_report_relative = true,
6619 .tdisc_report_absolute = false,
6620 .tdisc_report_wheel = false,
6621 .tdisc_reverse_x = false,
6622 .tdisc_reverse_y = true,
6623 .tdisc_abs = &tdisc_abs,
6624};
6625
6626static struct i2c_board_info msm_i2c_gsbi3_tdisc_info[] = {
6627 {
6628 I2C_BOARD_INFO("vtd518", TDISC_I2C_SLAVE_ADDR),
6629 .irq = TDISC_INT,
6630 .platform_data = &tdisc_data,
6631 },
6632};
6633#endif
6634
6635#define PM_GPIO_CDC_RST_N 20
6636#define GPIO_CDC_RST_N PM8058_GPIO_PM_TO_SYS(PM_GPIO_CDC_RST_N)
6637
6638static struct regulator *vreg_timpani_1;
6639static struct regulator *vreg_timpani_2;
6640
6641static unsigned int msm_timpani_setup_power(void)
6642{
6643 int rc;
6644
6645 vreg_timpani_1 = regulator_get(NULL, "8058_l0");
6646 if (IS_ERR(vreg_timpani_1)) {
6647 pr_err("%s: Unable to get 8058_l0\n", __func__);
6648 return -ENODEV;
6649 }
6650
6651 vreg_timpani_2 = regulator_get(NULL, "8058_s3");
6652 if (IS_ERR(vreg_timpani_2)) {
6653 pr_err("%s: Unable to get 8058_s3\n", __func__);
6654 regulator_put(vreg_timpani_1);
6655 return -ENODEV;
6656 }
6657
6658 rc = regulator_set_voltage(vreg_timpani_1, 1200000, 1200000);
6659 if (rc) {
6660 pr_err("%s: unable to set L0 voltage to 1.2V\n", __func__);
6661 goto fail;
6662 }
6663
6664 rc = regulator_set_voltage(vreg_timpani_2, 1800000, 1800000);
6665 if (rc) {
6666 pr_err("%s: unable to set S3 voltage to 1.8V\n", __func__);
6667 goto fail;
6668 }
6669
6670 rc = regulator_enable(vreg_timpani_1);
6671 if (rc) {
6672 pr_err("%s: Enable regulator 8058_l0 failed\n", __func__);
6673 goto fail;
6674 }
6675
6676 /* The settings for LDO0 should be set such that
6677 * it doesn't require to reset the timpani. */
6678 rc = regulator_set_optimum_mode(vreg_timpani_1, 5000);
6679 if (rc < 0) {
6680 pr_err("Timpani regulator optimum mode setting failed\n");
6681 goto fail;
6682 }
6683
6684 rc = regulator_enable(vreg_timpani_2);
6685 if (rc) {
6686 pr_err("%s: Enable regulator 8058_s3 failed\n", __func__);
6687 regulator_disable(vreg_timpani_1);
6688 goto fail;
6689 }
6690
6691 rc = gpio_request(GPIO_CDC_RST_N, "CDC_RST_N");
6692 if (rc) {
6693 pr_err("%s: GPIO Request %d failed\n", __func__,
6694 GPIO_CDC_RST_N);
6695 regulator_disable(vreg_timpani_1);
6696 regulator_disable(vreg_timpani_2);
6697 goto fail;
6698 } else {
6699 gpio_direction_output(GPIO_CDC_RST_N, 1);
6700 usleep_range(1000, 1050);
6701 gpio_direction_output(GPIO_CDC_RST_N, 0);
6702 usleep_range(1000, 1050);
6703 gpio_direction_output(GPIO_CDC_RST_N, 1);
6704 gpio_free(GPIO_CDC_RST_N);
6705 }
6706 return rc;
6707
6708fail:
6709 regulator_put(vreg_timpani_1);
6710 regulator_put(vreg_timpani_2);
6711 return rc;
6712}
6713
6714static void msm_timpani_shutdown_power(void)
6715{
6716 int rc;
6717
6718 rc = regulator_disable(vreg_timpani_1);
6719 if (rc)
6720 pr_err("%s: Disable regulator 8058_l0 failed\n", __func__);
6721
6722 regulator_put(vreg_timpani_1);
6723
6724 rc = regulator_disable(vreg_timpani_2);
6725 if (rc)
6726 pr_err("%s: Disable regulator 8058_s3 failed\n", __func__);
6727
6728 regulator_put(vreg_timpani_2);
6729}
6730
6731/* Power analog function of codec */
6732static struct regulator *vreg_timpani_cdc_apwr;
6733static int msm_timpani_codec_power(int vreg_on)
6734{
6735 int rc = 0;
6736
6737 if (!vreg_timpani_cdc_apwr) {
6738
6739 vreg_timpani_cdc_apwr = regulator_get(NULL, "8058_s4");
6740
6741 if (IS_ERR(vreg_timpani_cdc_apwr)) {
6742 pr_err("%s: vreg_get failed (%ld)\n",
6743 __func__, PTR_ERR(vreg_timpani_cdc_apwr));
6744 rc = PTR_ERR(vreg_timpani_cdc_apwr);
6745 return rc;
6746 }
6747 }
6748
6749 if (vreg_on) {
6750
6751 rc = regulator_set_voltage(vreg_timpani_cdc_apwr,
6752 2200000, 2200000);
6753 if (rc) {
6754 pr_err("%s: unable to set 8058_s4 voltage to 2.2 V\n",
6755 __func__);
6756 goto vreg_fail;
6757 }
6758
6759 rc = regulator_enable(vreg_timpani_cdc_apwr);
6760 if (rc) {
6761 pr_err("%s: vreg_enable failed %d\n", __func__, rc);
6762 goto vreg_fail;
6763 }
6764 } else {
6765 rc = regulator_disable(vreg_timpani_cdc_apwr);
6766 if (rc) {
6767 pr_err("%s: vreg_disable failed %d\n",
6768 __func__, rc);
6769 goto vreg_fail;
6770 }
6771 }
6772
6773 return 0;
6774
6775vreg_fail:
6776 regulator_put(vreg_timpani_cdc_apwr);
6777 vreg_timpani_cdc_apwr = NULL;
6778 return rc;
6779}
6780
6781static struct marimba_codec_platform_data timpani_codec_pdata = {
6782 .marimba_codec_power = msm_timpani_codec_power,
6783};
6784
6785#define TIMPANI_SLAVE_ID_CDC_ADDR 0X77
6786#define TIMPANI_SLAVE_ID_QMEMBIST_ADDR 0X66
6787
6788static struct marimba_platform_data timpani_pdata = {
6789 .slave_id[MARIMBA_SLAVE_ID_CDC] = TIMPANI_SLAVE_ID_CDC_ADDR,
6790 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = TIMPANI_SLAVE_ID_QMEMBIST_ADDR,
6791 .marimba_setup = msm_timpani_setup_power,
6792 .marimba_shutdown = msm_timpani_shutdown_power,
6793 .codec = &timpani_codec_pdata,
6794 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6795};
6796
6797#define TIMPANI_I2C_SLAVE_ADDR 0xD
6798
6799static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
6800 {
6801 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
6802 .platform_data = &timpani_pdata,
6803 },
6804};
6805
Lei Zhou338cab82011-08-19 13:38:17 -04006806#ifdef CONFIG_SND_SOC_WM8903
6807static struct wm8903_platform_data wm8903_pdata = {
6808 .gpio_cfg[2] = 0x3A8,
6809};
6810
6811#define WM8903_I2C_SLAVE_ADDR 0x34
6812static struct i2c_board_info wm8903_codec_i2c_info[] = {
6813 {
6814 I2C_BOARD_INFO("wm8903", WM8903_I2C_SLAVE_ADDR >> 1),
6815 .platform_data = &wm8903_pdata,
6816 },
6817};
6818#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006819#ifdef CONFIG_PMIC8901
6820
6821#define PM8901_GPIO_INT 91
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006822/*
6823 * Consumer specific regulator names:
6824 * regulator name consumer dev_name
6825 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006826static struct regulator_consumer_supply vreg_consumers_8901_USB_OTG[] = {
6827 REGULATOR_SUPPLY("8901_usb_otg", NULL),
6828};
6829static struct regulator_consumer_supply vreg_consumers_8901_HDMI_MVS[] = {
6830 REGULATOR_SUPPLY("8901_hdmi_mvs", NULL),
6831};
6832
6833#define PM8901_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306834 _always_on) \
6835 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006836 .init_data = { \
6837 .constraints = { \
6838 .valid_modes_mask = _modes, \
6839 .valid_ops_mask = _ops, \
6840 .min_uV = _min_uV, \
6841 .max_uV = _max_uV, \
6842 .input_uV = _min_uV, \
6843 .apply_uV = _apply_uV, \
6844 .always_on = _always_on, \
6845 }, \
6846 .consumer_supplies = vreg_consumers_8901_##_id, \
6847 .num_consumer_supplies = \
6848 ARRAY_SIZE(vreg_consumers_8901_##_id), \
6849 }, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306850 .id = PM8901_VREG_ID_##_id, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006851 }
6852
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006853#define PM8901_VREG_INIT_VS(_id) \
6854 PM8901_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306855 REGULATOR_CHANGE_STATUS, 0, 0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006856
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306857static struct pm8901_vreg_pdata pm8901_vreg_init[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006858 PM8901_VREG_INIT_VS(USB_OTG),
6859 PM8901_VREG_INIT_VS(HDMI_MVS),
6860};
6861
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306862static struct pm8xxx_misc_platform_data pm8901_misc_pdata = {
6863 .priority = 1,
6864};
6865
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306866static struct pm8xxx_irq_platform_data pm8901_irq_pdata = {
6867 .irq_base = PM8901_IRQ_BASE,
6868 .devirq = MSM_GPIO_TO_INT(PM8901_GPIO_INT),
6869 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6870};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006871
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306872static struct pm8xxx_mpp_platform_data pm8901_mpp_pdata = {
6873 .mpp_base = PM8901_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006874};
6875
6876static struct pm8901_platform_data pm8901_platform_data = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306877 .irq_pdata = &pm8901_irq_pdata,
6878 .mpp_pdata = &pm8901_mpp_pdata,
6879 .regulator_pdatas = pm8901_vreg_init,
6880 .num_regulators = ARRAY_SIZE(pm8901_vreg_init),
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306881 .misc_pdata = &pm8901_misc_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006882};
6883
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05306884static struct msm_ssbi_platform_data msm8x60_ssbi_pm8901_pdata __devinitdata = {
6885 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6886 .slave = {
6887 .name = "pm8901-core",
6888 .platform_data = &pm8901_platform_data,
6889 },
6890};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006891#endif /* CONFIG_PMIC8901 */
6892
6893#if defined(CONFIG_MARIMBA_CORE) && (defined(CONFIG_GPIO_SX150X) \
6894 || defined(CONFIG_GPIO_SX150X_MODULE))
6895
6896static struct regulator *vreg_bahama;
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006897static int msm_bahama_sys_rst = GPIO_MS_SYS_RESET_N;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006898
6899struct bahama_config_register{
6900 u8 reg;
6901 u8 value;
6902 u8 mask;
6903};
6904
6905enum version{
6906 VER_1_0,
6907 VER_2_0,
6908 VER_UNSUPPORTED = 0xFF
6909};
6910
6911static u8 read_bahama_ver(void)
6912{
6913 int rc;
6914 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6915 u8 bahama_version;
6916
6917 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
6918 if (rc < 0) {
6919 printk(KERN_ERR
6920 "%s: version read failed: %d\n",
6921 __func__, rc);
6922 return VER_UNSUPPORTED;
6923 } else {
6924 printk(KERN_INFO
6925 "%s: version read got: 0x%x\n",
6926 __func__, bahama_version);
6927 }
6928
6929 switch (bahama_version) {
6930 case 0x08: /* varient of bahama v1 */
6931 case 0x10:
6932 case 0x00:
6933 return VER_1_0;
6934 case 0x09: /* variant of bahama v2 */
6935 return VER_2_0;
6936 default:
6937 return VER_UNSUPPORTED;
6938 }
6939}
6940
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006941static int msm_bahama_setup_power_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006942static unsigned int msm_bahama_setup_power(void)
6943{
6944 int rc = 0;
6945 const char *msm_bahama_regulator = "8058_s3";
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006946
6947 if (machine_is_msm8x60_dragon())
6948 msm_bahama_sys_rst = GPIO_CDC_RST_N;
6949
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006950 vreg_bahama = regulator_get(NULL, msm_bahama_regulator);
6951
6952 if (IS_ERR(vreg_bahama)) {
6953 rc = PTR_ERR(vreg_bahama);
6954 pr_err("%s: regulator_get %s = %d\n", __func__,
6955 msm_bahama_regulator, rc);
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006956 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006957 }
6958
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006959 rc = regulator_set_voltage(vreg_bahama, 1800000, 1800000);
6960 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006961 pr_err("%s: regulator_set_voltage %s = %d\n", __func__,
6962 msm_bahama_regulator, rc);
6963 goto unget;
6964 }
6965
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006966 rc = regulator_enable(vreg_bahama);
6967 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006968 pr_err("%s: regulator_enable %s = %d\n", __func__,
6969 msm_bahama_regulator, rc);
6970 goto unget;
6971 }
6972
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006973 rc = gpio_request(msm_bahama_sys_rst, "bahama sys_rst_n");
6974 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006975 pr_err("%s: gpio_request %d = %d\n", __func__,
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006976 msm_bahama_sys_rst, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006977 goto unenable;
6978 }
6979
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006980 gpio_direction_output(msm_bahama_sys_rst, 0);
6981 usleep_range(1000, 1050);
6982 gpio_set_value_cansleep(msm_bahama_sys_rst, 1);
6983 usleep_range(1000, 1050);
6984 msm_bahama_setup_power_enable = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006985 return rc;
6986
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006987unenable:
6988 regulator_disable(vreg_bahama);
6989unget:
6990 regulator_put(vreg_bahama);
6991 return rc;
6992};
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006993
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006994static unsigned int msm_bahama_shutdown_power(int value)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006995{
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006996 if (msm_bahama_setup_power_enable) {
6997 gpio_set_value_cansleep(msm_bahama_sys_rst, 0);
6998 gpio_free(msm_bahama_sys_rst);
6999 regulator_disable(vreg_bahama);
7000 regulator_put(vreg_bahama);
7001 msm_bahama_setup_power_enable = 0;
7002 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007003
7004 return 0;
7005};
7006
7007static unsigned int msm_bahama_core_config(int type)
7008{
7009 int rc = 0;
7010
7011 if (type == BAHAMA_ID) {
7012
7013 int i;
7014 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
7015
7016 const struct bahama_config_register v20_init[] = {
7017 /* reg, value, mask */
7018 { 0xF4, 0x84, 0xFF }, /* AREG */
7019 { 0xF0, 0x04, 0xFF } /* DREG */
7020 };
7021
7022 if (read_bahama_ver() == VER_2_0) {
7023 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
7024 u8 value = v20_init[i].value;
7025 rc = marimba_write_bit_mask(&config,
7026 v20_init[i].reg,
7027 &value,
7028 sizeof(v20_init[i].value),
7029 v20_init[i].mask);
7030 if (rc < 0) {
7031 printk(KERN_ERR
7032 "%s: reg %d write failed: %d\n",
7033 __func__, v20_init[i].reg, rc);
7034 return rc;
7035 }
7036 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
7037 " mask 0x%02x\n",
7038 __func__, v20_init[i].reg,
7039 v20_init[i].value, v20_init[i].mask);
7040 }
7041 }
7042 }
7043 printk(KERN_INFO "core type: %d\n", type);
7044
7045 return rc;
7046}
7047
7048static struct regulator *fm_regulator_s3;
7049static struct msm_xo_voter *fm_clock;
7050
7051static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
7052{
7053 int rc = 0;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307054 struct pm_gpio cfg = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007055 .direction = PM_GPIO_DIR_IN,
7056 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307057 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007058 .function = PM_GPIO_FUNC_NORMAL,
7059 .inv_int_pol = 0,
7060 };
7061
7062 if (!fm_regulator_s3) {
7063 fm_regulator_s3 = regulator_get(NULL, "8058_s3");
7064 if (IS_ERR(fm_regulator_s3)) {
7065 rc = PTR_ERR(fm_regulator_s3);
7066 printk(KERN_ERR "%s: regulator get s3 (%d)\n",
7067 __func__, rc);
7068 goto out;
7069 }
7070 }
7071
7072
7073 rc = regulator_set_voltage(fm_regulator_s3, 1800000, 1800000);
7074 if (rc < 0) {
7075 printk(KERN_ERR "%s: regulator set voltage failed (%d)\n",
7076 __func__, rc);
7077 goto fm_fail_put;
7078 }
7079
7080 rc = regulator_enable(fm_regulator_s3);
7081 if (rc < 0) {
7082 printk(KERN_ERR "%s: regulator s3 enable failed (%d)\n",
7083 __func__, rc);
7084 goto fm_fail_put;
7085 }
7086
7087 /*Vote for XO clock*/
7088 fm_clock = msm_xo_get(MSM_XO_TCXO_D0, "fm_power");
7089
7090 if (IS_ERR(fm_clock)) {
7091 rc = PTR_ERR(fm_clock);
7092 printk(KERN_ERR "%s: Couldn't get TCXO_D0 vote for FM (%d)\n",
7093 __func__, rc);
7094 goto fm_fail_switch;
7095 }
7096
7097 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_ON);
7098 if (rc < 0) {
7099 printk(KERN_ERR "%s: Failed to vote for TCX0_D0 ON (%d)\n",
7100 __func__, rc);
7101 goto fm_fail_vote;
7102 }
7103
7104 /*GPIO 18 on PMIC is FM_IRQ*/
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307105 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(FM_GPIO), &cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007106 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307107 printk(KERN_ERR "%s: return val of pm8xxx_gpio_config: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007108 __func__, rc);
7109 goto fm_fail_clock;
7110 }
7111 goto out;
7112
7113fm_fail_clock:
7114 msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7115fm_fail_vote:
7116 msm_xo_put(fm_clock);
7117fm_fail_switch:
7118 regulator_disable(fm_regulator_s3);
7119fm_fail_put:
7120 regulator_put(fm_regulator_s3);
7121out:
7122 return rc;
7123};
7124
7125static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
7126{
7127 int rc = 0;
7128 if (fm_regulator_s3 != NULL) {
7129 rc = regulator_disable(fm_regulator_s3);
7130 if (rc < 0) {
7131 printk(KERN_ERR "%s: regulator s3 disable (%d)\n",
7132 __func__, rc);
7133 }
7134 regulator_put(fm_regulator_s3);
7135 fm_regulator_s3 = NULL;
7136 }
7137 printk(KERN_ERR "%s: Voting off for XO", __func__);
7138
7139 if (fm_clock != NULL) {
7140 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7141 if (rc < 0) {
7142 printk(KERN_ERR "%s: Voting off XO clock (%d)\n",
7143 __func__, rc);
7144 }
7145 msm_xo_put(fm_clock);
7146 }
7147 printk(KERN_ERR "%s: coming out of fm_radio_shutdown", __func__);
7148}
7149
7150/* Slave id address for FM/CDC/QMEMBIST
7151 * Values can be programmed using Marimba slave id 0
7152 * should there be a conflict with other I2C devices
7153 * */
7154#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
7155#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
7156
7157static struct marimba_fm_platform_data marimba_fm_pdata = {
7158 .fm_setup = fm_radio_setup,
7159 .fm_shutdown = fm_radio_shutdown,
7160 .irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, FM_GPIO),
7161 .is_fm_soc_i2s_master = false,
7162 .config_i2s_gpio = NULL,
7163};
7164
7165/*
7166Just initializing the BAHAMA related slave
7167*/
7168static struct marimba_platform_data marimba_pdata = {
7169 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
7170 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
7171 .bahama_setup = msm_bahama_setup_power,
7172 .bahama_shutdown = msm_bahama_shutdown_power,
7173 .bahama_core_config = msm_bahama_core_config,
7174 .fm = &marimba_fm_pdata,
7175 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
7176};
7177
7178
7179static struct i2c_board_info msm_marimba_board_info[] = {
7180 {
7181 I2C_BOARD_INFO("marimba", 0xc),
7182 .platform_data = &marimba_pdata,
7183 }
7184};
7185#endif /* CONFIG_MAIMBA_CORE */
7186
7187#ifdef CONFIG_I2C
7188#define I2C_SURF 1
7189#define I2C_FFA (1 << 1)
7190#define I2C_RUMI (1 << 2)
7191#define I2C_SIM (1 << 3)
7192#define I2C_FLUID (1 << 4)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007193#define I2C_DRAGON (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007194
7195struct i2c_registry {
7196 u8 machs;
7197 int bus;
7198 struct i2c_board_info *info;
7199 int len;
7200};
7201
7202static struct i2c_registry msm8x60_i2c_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007203#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7204 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007205 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007206 MSM_GSBI8_QUP_I2C_BUS_ID,
7207 core_expander_i2c_info,
7208 ARRAY_SIZE(core_expander_i2c_info),
7209 },
7210 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007211 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007212 MSM_GSBI8_QUP_I2C_BUS_ID,
7213 docking_expander_i2c_info,
7214 ARRAY_SIZE(docking_expander_i2c_info),
7215 },
7216 {
7217 I2C_SURF,
7218 MSM_GSBI8_QUP_I2C_BUS_ID,
7219 surf_expanders_i2c_info,
7220 ARRAY_SIZE(surf_expanders_i2c_info),
7221 },
7222 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007223 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007224 MSM_GSBI3_QUP_I2C_BUS_ID,
7225 fha_expanders_i2c_info,
7226 ARRAY_SIZE(fha_expanders_i2c_info),
7227 },
7228 {
7229 I2C_FLUID,
7230 MSM_GSBI3_QUP_I2C_BUS_ID,
7231 fluid_expanders_i2c_info,
7232 ARRAY_SIZE(fluid_expanders_i2c_info),
7233 },
7234 {
7235 I2C_FLUID,
7236 MSM_GSBI8_QUP_I2C_BUS_ID,
7237 fluid_core_expander_i2c_info,
7238 ARRAY_SIZE(fluid_core_expander_i2c_info),
7239 },
7240#endif
7241#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
7242 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
7243 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007244 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007245 MSM_GSBI3_QUP_I2C_BUS_ID,
7246 msm_i2c_gsbi3_tdisc_info,
7247 ARRAY_SIZE(msm_i2c_gsbi3_tdisc_info),
7248 },
7249#endif
7250 {
Zhang Chang Ken211df572011-07-05 19:16:39 -04007251 I2C_SURF | I2C_FFA | I2C_FLUID,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007252 MSM_GSBI3_QUP_I2C_BUS_ID,
7253 cy8ctmg200_board_info,
7254 ARRAY_SIZE(cy8ctmg200_board_info),
7255 },
Zhang Chang Ken211df572011-07-05 19:16:39 -04007256 {
7257 I2C_DRAGON,
7258 MSM_GSBI3_QUP_I2C_BUS_ID,
7259 cy8ctma340_dragon_board_info,
7260 ARRAY_SIZE(cy8ctma340_dragon_board_info),
7261 },
Steve Mucklef132c6c2012-06-06 18:30:57 -07007262#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
7263 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007264 {
7265 I2C_FLUID,
7266 MSM_GSBI3_QUP_I2C_BUS_ID,
7267 cyttsp_fluid_info,
7268 ARRAY_SIZE(cyttsp_fluid_info),
7269 },
7270 {
7271 I2C_FFA | I2C_SURF,
7272 MSM_GSBI3_QUP_I2C_BUS_ID,
7273 cyttsp_ffa_info,
7274 ARRAY_SIZE(cyttsp_ffa_info),
7275 },
7276#endif
7277#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07007278#ifndef CONFIG_MSM_CAMERA_V4L2
Jilai Wang971f97f2011-07-13 14:25:25 -04007279 {
7280 I2C_SURF | I2C_FFA | I2C_FLUID ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007281 MSM_GSBI4_QUP_I2C_BUS_ID,
7282 msm_camera_boardinfo,
7283 ARRAY_SIZE(msm_camera_boardinfo),
7284 },
Jilai Wang971f97f2011-07-13 14:25:25 -04007285 {
7286 I2C_DRAGON,
7287 MSM_GSBI4_QUP_I2C_BUS_ID,
7288 msm_camera_dragon_boardinfo,
7289 ARRAY_SIZE(msm_camera_dragon_boardinfo),
7290 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007291#endif
Kevin Chan3be11612012-03-22 20:05:40 -07007292#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007293 {
7294 I2C_SURF | I2C_FFA | I2C_FLUID,
7295 MSM_GSBI7_QUP_I2C_BUS_ID,
7296 msm_i2c_gsbi7_timpani_info,
7297 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info),
7298 },
7299#if defined(CONFIG_MARIMBA_CORE)
7300 {
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04007301 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007302 MSM_GSBI7_QUP_I2C_BUS_ID,
7303 msm_marimba_board_info,
7304 ARRAY_SIZE(msm_marimba_board_info),
7305 },
7306#endif /* CONFIG_MARIMBA_CORE */
7307#ifdef CONFIG_ISL9519_CHARGER
7308 {
7309 I2C_SURF | I2C_FFA,
7310 MSM_GSBI8_QUP_I2C_BUS_ID,
7311 isl_charger_i2c_info,
7312 ARRAY_SIZE(isl_charger_i2c_info),
7313 },
7314#endif
7315#if defined(CONFIG_HAPTIC_ISA1200) || \
7316 defined(CONFIG_HAPTIC_ISA1200_MODULE)
7317 {
7318 I2C_FLUID,
7319 MSM_GSBI8_QUP_I2C_BUS_ID,
7320 msm_isa1200_board_info,
7321 ARRAY_SIZE(msm_isa1200_board_info),
7322 },
7323#endif
7324#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
7325 {
7326 I2C_FLUID,
7327 MSM_GSBI8_QUP_I2C_BUS_ID,
7328 smb137b_charger_i2c_info,
7329 ARRAY_SIZE(smb137b_charger_i2c_info),
7330 },
7331#endif
7332#if defined(CONFIG_BATTERY_BQ27520) || \
7333 defined(CONFIG_BATTERY_BQ27520_MODULE)
7334 {
7335 I2C_FLUID,
7336 MSM_GSBI8_QUP_I2C_BUS_ID,
7337 msm_bq27520_board_info,
7338 ARRAY_SIZE(msm_bq27520_board_info),
7339 },
7340#endif
Lei Zhou338cab82011-08-19 13:38:17 -04007341#if defined(CONFIG_SND_SOC_WM8903) || defined(CONFIG_SND_SOC_WM8903_MODULE)
7342 {
7343 I2C_DRAGON,
7344 MSM_GSBI8_QUP_I2C_BUS_ID,
7345 wm8903_codec_i2c_info,
7346 ARRAY_SIZE(wm8903_codec_i2c_info),
7347 },
7348#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007349};
7350#endif /* CONFIG_I2C */
7351
Stephen Boyd668d7652012-04-25 11:31:01 -07007352static void __init fixup_i2c_configs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007353{
7354#ifdef CONFIG_I2C
7355#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7356 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7357 sx150x_data[SX150X_CORE].irq_summary =
7358 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT2_N);
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007359 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
7360 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007361 sx150x_data[SX150X_CORE].irq_summary =
7362 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7363 else if (machine_is_msm8x60_fluid())
7364 sx150x_data[SX150X_CORE_FLUID].irq_summary =
7365 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7366#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007367#endif
7368}
7369
Stephen Boyd668d7652012-04-25 11:31:01 -07007370static void __init register_i2c_devices(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007371{
7372#ifdef CONFIG_I2C
7373 u8 mach_mask = 0;
7374 int i;
Kevin Chan3be11612012-03-22 20:05:40 -07007375#ifdef CONFIG_MSM_CAMERA_V4L2
7376 struct i2c_registry msm8x60_camera_i2c_devices = {
7377 I2C_SURF | I2C_FFA | I2C_FLUID,
7378 MSM_GSBI4_QUP_I2C_BUS_ID,
7379 msm8x60_camera_board_info.board_info,
7380 msm8x60_camera_board_info.num_i2c_board_info,
7381 };
7382#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007383
7384 /* Build the matching 'supported_machs' bitmask */
7385 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7386 mach_mask = I2C_SURF;
7387 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
7388 mach_mask = I2C_FFA;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007389 else if (machine_is_msm8x60_fluid())
7390 mach_mask = I2C_FLUID;
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007391 else if (machine_is_msm8x60_dragon())
7392 mach_mask = I2C_DRAGON;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007393 else
7394 pr_err("unmatched machine ID in register_i2c_devices\n");
7395
7396 /* Run the array and install devices as appropriate */
7397 for (i = 0; i < ARRAY_SIZE(msm8x60_i2c_devices); ++i) {
7398 if (msm8x60_i2c_devices[i].machs & mach_mask)
7399 i2c_register_board_info(msm8x60_i2c_devices[i].bus,
7400 msm8x60_i2c_devices[i].info,
7401 msm8x60_i2c_devices[i].len);
7402 }
Kevin Chan3be11612012-03-22 20:05:40 -07007403#ifdef CONFIG_MSM_CAMERA_V4L2
7404 if (msm8x60_camera_i2c_devices.machs & mach_mask)
7405 i2c_register_board_info(msm8x60_camera_i2c_devices.bus,
7406 msm8x60_camera_i2c_devices.info,
7407 msm8x60_camera_i2c_devices.len);
7408#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007409#endif
7410}
7411
7412static void __init msm8x60_init_uart12dm(void)
7413{
7414#if !defined(CONFIG_USB_PEHCI_HCD) && !defined(CONFIG_USB_PEHCI_HCD_MODULE)
7415 /* 0x1D000000 now belongs to EBI2:CS3 i.e. USB ISP Controller */
7416 void *fpga_mem = ioremap_nocache(0x1D000000, SZ_4K);
7417
7418 if (!fpga_mem)
7419 pr_err("%s(): Error getting memory\n", __func__);
7420
7421 /* Advanced mode */
7422 writew(0xFFFF, fpga_mem + 0x15C);
7423 /* FPGA_UART_SEL */
7424 writew(0, fpga_mem + 0x172);
7425 /* FPGA_GPIO_CONFIG_117 */
7426 writew(1, fpga_mem + 0xEA);
7427 /* FPGA_GPIO_CONFIG_118 */
7428 writew(1, fpga_mem + 0xEC);
7429 mb();
7430 iounmap(fpga_mem);
7431#endif
7432}
7433
7434#define MSM_GSBI9_PHYS 0x19900000
7435#define GSBI_DUAL_MODE_CODE 0x60
7436
7437static void __init msm8x60_init_buses(void)
7438{
7439#ifdef CONFIG_I2C_QUP
7440 void *gsbi_mem = ioremap_nocache(0x19C00000, 4);
7441 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI12 */
7442 writel_relaxed(0x6 << 4, gsbi_mem);
7443 /* Ensure protocol code is written before proceeding further */
7444 mb();
7445 iounmap(gsbi_mem);
7446
7447 msm_gsbi3_qup_i2c_device.dev.platform_data = &msm_gsbi3_qup_i2c_pdata;
7448 msm_gsbi4_qup_i2c_device.dev.platform_data = &msm_gsbi4_qup_i2c_pdata;
7449 msm_gsbi7_qup_i2c_device.dev.platform_data = &msm_gsbi7_qup_i2c_pdata;
7450 msm_gsbi8_qup_i2c_device.dev.platform_data = &msm_gsbi8_qup_i2c_pdata;
7451
7452#ifdef CONFIG_MSM_GSBI9_UART
7453 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7454 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI9 */
7455 gsbi_mem = ioremap_nocache(MSM_GSBI9_PHYS, 4);
7456 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
7457 iounmap(gsbi_mem);
7458 msm_gsbi9_qup_i2c_pdata.use_gsbi_shared_mode = 1;
7459 }
7460#endif
7461 msm_gsbi9_qup_i2c_device.dev.platform_data = &msm_gsbi9_qup_i2c_pdata;
7462 msm_gsbi12_qup_i2c_device.dev.platform_data = &msm_gsbi12_qup_i2c_pdata;
7463#endif
7464#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7465 msm_gsbi1_qup_spi_device.dev.platform_data = &msm_gsbi1_qup_spi_pdata;
7466#endif
7467#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007468 msm_device_ssbi3.dev.platform_data = &msm_ssbi3_pdata;
7469#endif
7470
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307471#ifdef CONFIG_MSM_SSBI
7472 msm_device_ssbi_pmic1.dev.platform_data =
7473 &msm8x60_ssbi_pm8058_pdata;
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05307474 msm_device_ssbi_pmic2.dev.platform_data =
7475 &msm8x60_ssbi_pm8901_pdata;
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307476#endif
7477
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007478 if (machine_is_msm8x60_fluid()) {
7479#if (defined(CONFIG_USB_EHCI_MSM_72K) && \
7480 (defined(CONFIG_SMB137B_CHARGER) || \
7481 defined(CONFIG_SMB137B_CHARGER_MODULE)))
7482 msm_otg_pdata.vbus_power = msm_hsusb_smb137b_vbus_power;
7483#endif
7484#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7485 msm_gsbi10_qup_spi_device.dev.platform_data =
7486 &msm_gsbi10_qup_spi_pdata;
7487#endif
7488 }
7489
Lena Salman57d167e2012-03-21 19:46:38 +02007490#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007491 /*
7492 * We can not put USB regulators (8058_l6 and 8058_l7) in LPM
7493 * when we depend on USB PHY for VBUS/ID notifications. VBUS
7494 * and ID notifications are available only on V2 surf and FFA
7495 * with a hardware workaround.
7496 */
7497 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 &&
7498 (machine_is_msm8x60_surf() ||
7499 (machine_is_msm8x60_ffa() &&
7500 pmic_id_notif_supported)))
7501 msm_otg_pdata.phy_can_powercollapse = 1;
7502 msm_device_otg.dev.platform_data = &msm_otg_pdata;
7503#endif
7504
Lena Salman57d167e2012-03-21 19:46:38 +02007505#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007506 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
7507#endif
7508
7509#ifdef CONFIG_SERIAL_MSM_HS
7510 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(54); /* GSBI6(2) */
7511 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
7512#endif
7513#ifdef CONFIG_MSM_GSBI9_UART
7514 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7515 msm_device_uart_gsbi9 = msm_add_gsbi9_uart();
7516 if (IS_ERR(msm_device_uart_gsbi9))
7517 pr_err("%s(): Failed to create uart gsbi9 device\n",
7518 __func__);
7519 }
7520#endif
7521
7522#ifdef CONFIG_MSM_BUS_SCALING
7523
7524 /* RPM calls are only enabled on V2 */
7525 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2) {
7526 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
7527 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
7528 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
7529 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
7530 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
7531 }
7532
7533 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
7534 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
7535 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
7536 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
7537 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
7538#endif
Stephen Boyd9e775ad2011-08-12 00:14:28 +01007539}
Steve Mucklea55df6e2010-01-07 12:43:24 -08007540
7541static void __init msm8x60_map_io(void)
7542{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007543 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Steve Mucklea55df6e2010-01-07 12:43:24 -08007544 msm_map_msm8x60_io();
Abhimanyu Kapur91a0a502013-01-11 19:24:59 -08007545 if (socinfo_init() < 0)
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007546 pr_err("socinfo_init() failed!\n");
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -08007547
Steve Mucklea55df6e2010-01-07 12:43:24 -08007548}
7549
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007550/*
7551 * Most segments of the EBI2 bus are disabled by default.
7552 */
7553static void __init msm8x60_init_ebi2(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08007554{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007555 uint32_t ebi2_cfg;
7556 void *ebi2_cfg_ptr;
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007557 struct clk *mem_clk = clk_get_sys("msm_ebi2", "mem_clk");
Steve Mucklea55df6e2010-01-07 12:43:24 -08007558
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007559 if (IS_ERR(mem_clk)) {
7560 pr_err("%s: clk_get_sys(%s,%s), failed", __func__,
7561 "msm_ebi2", "mem_clk");
7562 return;
7563 }
Stephen Boyd818a3f62012-05-08 12:12:18 -07007564 clk_prepare_enable(mem_clk);
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007565 clk_put(mem_clk);
Steve Mucklea55df6e2010-01-07 12:43:24 -08007566
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007567 ebi2_cfg_ptr = ioremap_nocache(0x1a100000, sizeof(uint32_t));
7568 if (ebi2_cfg_ptr != 0) {
7569 ebi2_cfg = readl_relaxed(ebi2_cfg_ptr);
Steve Mucklea55df6e2010-01-07 12:43:24 -08007570
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007571 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007572 machine_is_msm8x60_fluid() ||
7573 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007574 ebi2_cfg |= (1 << 4) | (1 << 5); /* CS2, CS3 */
Steve Mucklea55df6e2010-01-07 12:43:24 -08007575
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007576 writel_relaxed(ebi2_cfg, ebi2_cfg_ptr);
7577 iounmap(ebi2_cfg_ptr);
David Brown56e2d8a2011-08-04 02:01:02 -07007578 }
7579
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007580 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007581 machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007582 ebi2_cfg_ptr = ioremap_nocache(0x1a110000, SZ_4K);
7583 if (ebi2_cfg_ptr != 0) {
7584 /* EBI2_XMEM_CFG:PWRSAVE_MODE off */
7585 writel_relaxed(0UL, ebi2_cfg_ptr);
7586
7587 /* CS2: Delay 9 cycles (140ns@64MHz) between SMSC
7588 * LAN9221 Ethernet controller reads and writes.
7589 * The lowest 4 bits are the read delay, the next
7590 * 4 are the write delay. */
7591 writel_relaxed(0x031F1C99, ebi2_cfg_ptr + 0x10);
7592#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
7593 /*
7594 * RECOVERY=5, HOLD_WR=1
7595 * INIT_LATENCY_WR=1, INIT_LATENCY_RD=1
7596 * WAIT_WR=1, WAIT_RD=2
7597 */
7598 writel_relaxed(0x51010112, ebi2_cfg_ptr + 0x14);
7599 /*
7600 * HOLD_RD=1
7601 * ADV_OE_RECOVERY=0, ADDR_HOLD_ENA=1
7602 */
7603 writel_relaxed(0x01000020, ebi2_cfg_ptr + 0x34);
7604#else
7605 /* EBI2 CS3 muxed address/data,
7606 * two cyc addr enable */
7607 writel_relaxed(0xA3030020, ebi2_cfg_ptr + 0x34);
7608
7609#endif
7610 iounmap(ebi2_cfg_ptr);
7611 }
7612 }
David Brown56e2d8a2011-08-04 02:01:02 -07007613}
7614
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007615#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
7616 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
7617 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
7618 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\
7619 || defined(CONFIG_MMC_MSM_SDC5_SUPPORT))
7620
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007621/* 8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007622#define MAX_SDCC_CONTROLLER 5
7623
7624struct msm_sdcc_gpio {
7625 /* maximum 10 GPIOs per SDCC controller */
7626 s16 no;
7627 /* name of this GPIO */
7628 const char *name;
7629 bool always_on;
7630 bool is_enabled;
David Brown56e2d8a2011-08-04 02:01:02 -07007631};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007632
7633#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7634static struct msm_sdcc_gpio sdc1_gpio_cfg[] = {
7635 {159, "sdc1_dat_0"},
7636 {160, "sdc1_dat_1"},
7637 {161, "sdc1_dat_2"},
7638 {162, "sdc1_dat_3"},
7639#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
7640 {163, "sdc1_dat_4"},
7641 {164, "sdc1_dat_5"},
7642 {165, "sdc1_dat_6"},
7643 {166, "sdc1_dat_7"},
7644#endif
7645 {167, "sdc1_clk"},
7646 {168, "sdc1_cmd"}
7647};
7648#endif
7649
7650#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7651static struct msm_sdcc_gpio sdc2_gpio_cfg[] = {
7652 {143, "sdc2_dat_0"},
7653 {144, "sdc2_dat_1", 1},
7654 {145, "sdc2_dat_2"},
7655 {146, "sdc2_dat_3"},
7656#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
7657 {147, "sdc2_dat_4"},
7658 {148, "sdc2_dat_5"},
7659 {149, "sdc2_dat_6"},
7660 {150, "sdc2_dat_7"},
7661#endif
7662 {151, "sdc2_cmd"},
7663 {152, "sdc2_clk", 1}
7664};
7665#endif
7666
7667#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7668static struct msm_sdcc_gpio sdc5_gpio_cfg[] = {
7669 {95, "sdc5_cmd"},
7670 {96, "sdc5_dat_3"},
7671 {97, "sdc5_clk", 1},
7672 {98, "sdc5_dat_2"},
7673 {99, "sdc5_dat_1", 1},
7674 {100, "sdc5_dat_0"}
7675};
7676#endif
7677
7678struct msm_sdcc_pad_pull_cfg {
7679 enum msm_tlmm_pull_tgt pull;
7680 u32 pull_val;
7681};
7682
7683struct msm_sdcc_pad_drv_cfg {
7684 enum msm_tlmm_hdrive_tgt drv;
7685 u32 drv_val;
7686};
7687
7688#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7689static struct msm_sdcc_pad_drv_cfg sdc3_pad_on_drv_cfg[] = {
7690 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
7691 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
7692 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
7693};
7694
7695static struct msm_sdcc_pad_pull_cfg sdc3_pad_on_pull_cfg[] = {
7696 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
7697 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
7698};
7699
7700static struct msm_sdcc_pad_drv_cfg sdc3_pad_off_drv_cfg[] = {
7701 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
7702 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
7703 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
7704};
7705
7706static struct msm_sdcc_pad_pull_cfg sdc3_pad_off_pull_cfg[] = {
7707 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
7708 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
7709};
7710#endif
7711
7712#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7713static struct msm_sdcc_pad_drv_cfg sdc4_pad_on_drv_cfg[] = {
7714 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_8MA},
7715 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_8MA},
7716 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_8MA}
7717};
7718
7719static struct msm_sdcc_pad_pull_cfg sdc4_pad_on_pull_cfg[] = {
7720 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_UP},
7721 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_UP}
7722};
7723
7724static struct msm_sdcc_pad_drv_cfg sdc4_pad_off_drv_cfg[] = {
7725 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_2MA},
7726 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_2MA},
7727 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_2MA}
7728};
7729
7730static struct msm_sdcc_pad_pull_cfg sdc4_pad_off_pull_cfg[] = {
7731 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_DOWN},
7732 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_DOWN}
7733};
7734#endif
7735
7736struct msm_sdcc_pin_cfg {
7737 /*
7738 * = 1 if controller pins are using gpios
7739 * = 0 if controller has dedicated MSM pins
7740 */
7741 u8 is_gpio;
7742 u8 cfg_sts;
7743 u8 gpio_data_size;
7744 struct msm_sdcc_gpio *gpio_data;
7745 struct msm_sdcc_pad_drv_cfg *pad_drv_on_data;
7746 struct msm_sdcc_pad_drv_cfg *pad_drv_off_data;
7747 struct msm_sdcc_pad_pull_cfg *pad_pull_on_data;
7748 struct msm_sdcc_pad_pull_cfg *pad_pull_off_data;
7749 u8 pad_drv_data_size;
7750 u8 pad_pull_data_size;
7751 u8 sdio_lpm_gpio_cfg;
7752};
7753
7754
7755static struct msm_sdcc_pin_cfg sdcc_pin_cfg_data[MAX_SDCC_CONTROLLER] = {
7756#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7757 [0] = {
7758 .is_gpio = 1,
7759 .gpio_data_size = ARRAY_SIZE(sdc1_gpio_cfg),
7760 .gpio_data = sdc1_gpio_cfg
7761 },
7762#endif
7763#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7764 [1] = {
7765 .is_gpio = 1,
7766 .gpio_data_size = ARRAY_SIZE(sdc2_gpio_cfg),
7767 .gpio_data = sdc2_gpio_cfg
7768 },
7769#endif
7770#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7771 [2] = {
7772 .is_gpio = 0,
7773 .pad_drv_on_data = sdc3_pad_on_drv_cfg,
7774 .pad_drv_off_data = sdc3_pad_off_drv_cfg,
7775 .pad_pull_on_data = sdc3_pad_on_pull_cfg,
7776 .pad_pull_off_data = sdc3_pad_off_pull_cfg,
7777 .pad_drv_data_size = ARRAY_SIZE(sdc3_pad_on_drv_cfg),
7778 .pad_pull_data_size = ARRAY_SIZE(sdc3_pad_on_pull_cfg)
7779 },
7780#endif
7781#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7782 [3] = {
7783 .is_gpio = 0,
7784 .pad_drv_on_data = sdc4_pad_on_drv_cfg,
7785 .pad_drv_off_data = sdc4_pad_off_drv_cfg,
7786 .pad_pull_on_data = sdc4_pad_on_pull_cfg,
7787 .pad_pull_off_data = sdc4_pad_off_pull_cfg,
7788 .pad_drv_data_size = ARRAY_SIZE(sdc4_pad_on_drv_cfg),
7789 .pad_pull_data_size = ARRAY_SIZE(sdc4_pad_on_pull_cfg)
7790 },
7791#endif
7792#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7793 [4] = {
7794 .is_gpio = 1,
7795 .gpio_data_size = ARRAY_SIZE(sdc5_gpio_cfg),
7796 .gpio_data = sdc5_gpio_cfg
7797 }
7798#endif
7799};
7800
7801static int msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
7802{
7803 int rc = 0;
7804 struct msm_sdcc_pin_cfg *curr;
7805 int n;
7806
7807 curr = &sdcc_pin_cfg_data[dev_id - 1];
7808 if (!curr->gpio_data)
7809 goto out;
7810
7811 for (n = 0; n < curr->gpio_data_size; n++) {
7812 if (enable) {
7813
7814 if (curr->gpio_data[n].always_on &&
7815 curr->gpio_data[n].is_enabled)
7816 continue;
7817 pr_debug("%s: enable: %s\n", __func__,
7818 curr->gpio_data[n].name);
7819 rc = gpio_request(curr->gpio_data[n].no,
7820 curr->gpio_data[n].name);
7821 if (rc) {
7822 pr_err("%s: gpio_request(%d, %s)"
7823 "failed", __func__,
7824 curr->gpio_data[n].no,
7825 curr->gpio_data[n].name);
7826 goto free_gpios;
7827 }
7828 /* set direction as output for all GPIOs */
7829 rc = gpio_direction_output(
7830 curr->gpio_data[n].no, 1);
7831 if (rc) {
7832 pr_err("%s: gpio_direction_output"
7833 "(%d, 1) failed\n", __func__,
7834 curr->gpio_data[n].no);
7835 goto free_gpios;
7836 }
7837 curr->gpio_data[n].is_enabled = 1;
7838 } else {
7839 /*
7840 * now free this GPIO which will put GPIO
7841 * in low power mode and will also put GPIO
7842 * in input mode
7843 */
7844 if (curr->gpio_data[n].always_on)
7845 continue;
7846 pr_debug("%s: disable: %s\n", __func__,
7847 curr->gpio_data[n].name);
7848 gpio_free(curr->gpio_data[n].no);
7849 curr->gpio_data[n].is_enabled = 0;
7850 }
7851 }
7852 curr->cfg_sts = enable;
7853 goto out;
7854
7855free_gpios:
7856 for (; n >= 0; n--)
7857 gpio_free(curr->gpio_data[n].no);
7858out:
7859 return rc;
7860}
7861
7862static int msm_sdcc_setup_pad(int dev_id, unsigned int enable)
7863{
7864 int rc = 0;
7865 struct msm_sdcc_pin_cfg *curr;
7866 int n;
7867
7868 curr = &sdcc_pin_cfg_data[dev_id - 1];
7869 if (!curr->pad_drv_on_data || !curr->pad_pull_on_data)
7870 goto out;
7871
7872 if (enable) {
7873 /*
7874 * set up the normal driver strength and
7875 * pull config for pads
7876 */
7877 for (n = 0; n < curr->pad_drv_data_size; n++) {
7878 if (curr->sdio_lpm_gpio_cfg) {
7879 if (curr->pad_drv_on_data[n].drv ==
7880 TLMM_HDRV_SDC4_DATA)
7881 continue;
7882 }
7883 msm_tlmm_set_hdrive(curr->pad_drv_on_data[n].drv,
7884 curr->pad_drv_on_data[n].drv_val);
7885 }
7886 for (n = 0; n < curr->pad_pull_data_size; n++) {
7887 if (curr->sdio_lpm_gpio_cfg) {
7888 if (curr->pad_pull_on_data[n].pull ==
7889 TLMM_PULL_SDC4_DATA)
7890 continue;
7891 }
7892 msm_tlmm_set_pull(curr->pad_pull_on_data[n].pull,
7893 curr->pad_pull_on_data[n].pull_val);
7894 }
7895 } else {
7896 /* set the low power config for pads */
7897 for (n = 0; n < curr->pad_drv_data_size; n++) {
7898 if (curr->sdio_lpm_gpio_cfg) {
7899 if (curr->pad_drv_off_data[n].drv ==
7900 TLMM_HDRV_SDC4_DATA)
7901 continue;
7902 }
7903 msm_tlmm_set_hdrive(
7904 curr->pad_drv_off_data[n].drv,
7905 curr->pad_drv_off_data[n].drv_val);
7906 }
7907 for (n = 0; n < curr->pad_pull_data_size; n++) {
7908 if (curr->sdio_lpm_gpio_cfg) {
7909 if (curr->pad_pull_off_data[n].pull ==
7910 TLMM_PULL_SDC4_DATA)
7911 continue;
7912 }
7913 msm_tlmm_set_pull(
7914 curr->pad_pull_off_data[n].pull,
7915 curr->pad_pull_off_data[n].pull_val);
7916 }
7917 }
7918 curr->cfg_sts = enable;
7919out:
7920 return rc;
7921}
7922
7923struct sdcc_reg {
7924 /* VDD/VCC/VCCQ regulator name on PMIC8058/PMIC8089*/
7925 const char *reg_name;
7926 /*
7927 * is set voltage supported for this regulator?
7928 * 0 = not supported, 1 = supported
7929 */
7930 unsigned char set_voltage_sup;
7931 /* voltage level to be set */
7932 unsigned int level;
7933 /* VDD/VCC/VCCQ voltage regulator handle */
7934 struct regulator *reg;
7935 /* is this regulator enabled? */
7936 bool enabled;
7937 /* is this regulator needs to be always on? */
7938 bool always_on;
7939 /* is operating power mode setting required for this regulator? */
7940 bool op_pwr_mode_sup;
7941 /* Load values for low power and high power mode */
7942 unsigned int lpm_uA;
7943 unsigned int hpm_uA;
7944};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007945/* all SDCC controllers require VDD/VCC voltage */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007946static struct sdcc_reg sdcc_vdd_reg_data[MAX_SDCC_CONTROLLER];
7947/* only SDCC1 requires VCCQ voltage */
7948static struct sdcc_reg sdcc_vccq_reg_data[1];
7949/* all SDCC controllers may require voting for VDD PAD voltage */
7950static struct sdcc_reg sdcc_vddp_reg_data[MAX_SDCC_CONTROLLER];
7951
7952struct sdcc_reg_data {
7953 struct sdcc_reg *vdd_data; /* keeps VDD/VCC regulator info */
7954 struct sdcc_reg *vccq_data; /* keeps VCCQ regulator info */
7955 struct sdcc_reg *vddp_data; /* keeps VDD Pad regulator info */
7956 unsigned char sts; /* regulator enable/disable status */
7957};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007958/* msm8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007959static struct sdcc_reg_data sdcc_vreg_data[MAX_SDCC_CONTROLLER];
7960
7961static int msm_sdcc_vreg_init_reg(struct sdcc_reg *vreg)
7962{
7963 int rc = 0;
7964
7965 /* Get the regulator handle */
7966 vreg->reg = regulator_get(NULL, vreg->reg_name);
7967 if (IS_ERR(vreg->reg)) {
7968 rc = PTR_ERR(vreg->reg);
7969 pr_err("%s: regulator_get(%s) failed. rc=%d\n",
7970 __func__, vreg->reg_name, rc);
7971 goto out;
7972 }
7973
7974 /* Set the voltage level if required */
7975 if (vreg->set_voltage_sup) {
7976 rc = regulator_set_voltage(vreg->reg, vreg->level,
7977 vreg->level);
7978 if (rc) {
7979 pr_err("%s: regulator_set_voltage(%s) failed rc=%d\n",
7980 __func__, vreg->reg_name, rc);
7981 goto vreg_put;
7982 }
7983 }
7984 goto out;
7985
7986vreg_put:
7987 regulator_put(vreg->reg);
7988out:
7989 return rc;
7990}
7991
7992static inline void msm_sdcc_vreg_deinit_reg(struct sdcc_reg *vreg)
7993{
7994 regulator_put(vreg->reg);
7995}
7996
7997/* this init function should be called only once for each SDCC */
7998static int msm_sdcc_vreg_init(int dev_id, unsigned char init)
7999{
8000 int rc = 0;
8001 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
8002 struct sdcc_reg_data *curr;
8003
8004 curr = &sdcc_vreg_data[dev_id - 1];
8005 curr_vdd_reg = curr->vdd_data;
8006 curr_vccq_reg = curr->vccq_data;
8007 curr_vddp_reg = curr->vddp_data;
8008
8009 if (init) {
8010 /*
8011 * get the regulator handle from voltage regulator framework
8012 * and then try to set the voltage level for the regulator
8013 */
8014 if (curr_vdd_reg) {
8015 rc = msm_sdcc_vreg_init_reg(curr_vdd_reg);
8016 if (rc)
8017 goto out;
8018 }
8019 if (curr_vccq_reg) {
8020 rc = msm_sdcc_vreg_init_reg(curr_vccq_reg);
8021 if (rc)
8022 goto vdd_reg_deinit;
8023 }
8024 if (curr_vddp_reg) {
8025 rc = msm_sdcc_vreg_init_reg(curr_vddp_reg);
8026 if (rc)
8027 goto vccq_reg_deinit;
8028 }
8029 goto out;
8030 } else
8031 /* deregister with all regulators from regulator framework */
8032 goto vddp_reg_deinit;
8033
8034vddp_reg_deinit:
8035 if (curr_vddp_reg)
8036 msm_sdcc_vreg_deinit_reg(curr_vddp_reg);
8037vccq_reg_deinit:
8038 if (curr_vccq_reg)
8039 msm_sdcc_vreg_deinit_reg(curr_vccq_reg);
8040vdd_reg_deinit:
8041 if (curr_vdd_reg)
8042 msm_sdcc_vreg_deinit_reg(curr_vdd_reg);
8043out:
8044 return rc;
8045}
8046
8047static int msm_sdcc_vreg_enable(struct sdcc_reg *vreg)
8048{
8049 int rc;
8050
8051 if (!vreg->enabled) {
8052 rc = regulator_enable(vreg->reg);
8053 if (rc) {
8054 pr_err("%s: regulator_enable(%s) failed. rc=%d\n",
8055 __func__, vreg->reg_name, rc);
8056 goto out;
8057 }
8058 vreg->enabled = 1;
8059 }
8060
8061 /* Put always_on regulator in HPM (high power mode) */
8062 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8063 rc = regulator_set_optimum_mode(vreg->reg, vreg->hpm_uA);
8064 if (rc < 0) {
8065 pr_err("%s: reg=%s: HPM setting failed"
8066 " hpm_uA=%d, rc=%d\n",
8067 __func__, vreg->reg_name,
8068 vreg->hpm_uA, rc);
8069 goto vreg_disable;
8070 }
8071 rc = 0;
8072 }
8073 goto out;
8074
8075vreg_disable:
8076 regulator_disable(vreg->reg);
8077 vreg->enabled = 0;
8078out:
8079 return rc;
8080}
8081
8082static int msm_sdcc_vreg_disable(struct sdcc_reg *vreg)
8083{
8084 int rc;
8085
8086 /* Never disable always_on regulator */
8087 if (!vreg->always_on) {
8088 rc = regulator_disable(vreg->reg);
8089 if (rc) {
8090 pr_err("%s: regulator_disable(%s) failed. rc=%d\n",
8091 __func__, vreg->reg_name, rc);
8092 goto out;
8093 }
8094 vreg->enabled = 0;
8095 }
8096
8097 /* Put always_on regulator in LPM (low power mode) */
8098 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8099 rc = regulator_set_optimum_mode(vreg->reg, vreg->lpm_uA);
8100 if (rc < 0) {
8101 pr_err("%s: reg=%s: LPM setting failed"
8102 " lpm_uA=%d, rc=%d\n",
8103 __func__,
8104 vreg->reg_name,
8105 vreg->lpm_uA, rc);
8106 goto out;
8107 }
8108 rc = 0;
8109 }
8110
8111out:
8112 return rc;
8113}
8114
8115static int msm_sdcc_setup_vreg(int dev_id, unsigned char enable)
8116{
8117 int rc = 0;
8118 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
8119 struct sdcc_reg_data *curr;
8120
8121 curr = &sdcc_vreg_data[dev_id - 1];
8122 curr_vdd_reg = curr->vdd_data;
8123 curr_vccq_reg = curr->vccq_data;
8124 curr_vddp_reg = curr->vddp_data;
8125
8126 /* check if regulators are initialized or not? */
8127 if ((curr_vdd_reg && !curr_vdd_reg->reg) ||
8128 (curr_vccq_reg && !curr_vccq_reg->reg) ||
8129 (curr_vddp_reg && !curr_vddp_reg->reg)) {
8130 /* initialize voltage regulators required for this SDCC */
8131 rc = msm_sdcc_vreg_init(dev_id, 1);
8132 if (rc) {
8133 pr_err("%s: regulator init failed = %d\n",
8134 __func__, rc);
8135 goto out;
8136 }
8137 }
8138
8139 if (curr->sts == enable)
8140 goto out;
8141
8142 if (curr_vdd_reg) {
8143 if (enable)
8144 rc = msm_sdcc_vreg_enable(curr_vdd_reg);
8145 else
8146 rc = msm_sdcc_vreg_disable(curr_vdd_reg);
8147 if (rc)
8148 goto out;
8149 }
8150
8151 if (curr_vccq_reg) {
8152 if (enable)
8153 rc = msm_sdcc_vreg_enable(curr_vccq_reg);
8154 else
8155 rc = msm_sdcc_vreg_disable(curr_vccq_reg);
8156 if (rc)
8157 goto out;
8158 }
8159
8160 if (curr_vddp_reg) {
8161 if (enable)
8162 rc = msm_sdcc_vreg_enable(curr_vddp_reg);
8163 else
8164 rc = msm_sdcc_vreg_disable(curr_vddp_reg);
8165 if (rc)
8166 goto out;
8167 }
8168 curr->sts = enable;
8169
8170out:
8171 return rc;
8172}
8173
8174static u32 msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
8175{
8176 u32 rc_pin_cfg = 0;
8177 u32 rc_vreg_cfg = 0;
8178 u32 rc = 0;
8179 struct platform_device *pdev;
8180 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8181
8182 pdev = container_of(dv, struct platform_device, dev);
8183
8184 /* setup gpio/pad */
8185 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8186 if (curr_pin_cfg->cfg_sts == !!vdd)
8187 goto setup_vreg;
8188
8189 if (curr_pin_cfg->is_gpio)
8190 rc_pin_cfg = msm_sdcc_setup_gpio(pdev->id, !!vdd);
8191 else
8192 rc_pin_cfg = msm_sdcc_setup_pad(pdev->id, !!vdd);
8193
8194setup_vreg:
8195 /* setup voltage regulators */
8196 rc_vreg_cfg = msm_sdcc_setup_vreg(pdev->id, !!vdd);
8197
8198 if (rc_pin_cfg || rc_vreg_cfg)
8199 rc = rc_pin_cfg ? rc_pin_cfg : rc_vreg_cfg;
8200
8201 return rc;
8202}
8203
8204static void msm_sdcc_sdio_lpm_gpio(struct device *dv, unsigned int active)
8205{
8206 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8207 struct platform_device *pdev;
8208
8209 pdev = container_of(dv, struct platform_device, dev);
8210 /* setup gpio/pad */
8211 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8212
8213 if (curr_pin_cfg->cfg_sts == active)
8214 return;
8215
8216 curr_pin_cfg->sdio_lpm_gpio_cfg = 1;
8217 if (curr_pin_cfg->is_gpio)
8218 msm_sdcc_setup_gpio(pdev->id, active);
8219 else
8220 msm_sdcc_setup_pad(pdev->id, active);
8221 curr_pin_cfg->sdio_lpm_gpio_cfg = 0;
8222}
8223
8224static int msm_sdc3_get_wpswitch(struct device *dev)
8225{
8226 struct platform_device *pdev;
8227 int status;
8228 pdev = container_of(dev, struct platform_device, dev);
8229
8230 status = gpio_request(GPIO_SDC_WP, "SD_WP_Switch");
8231 if (status) {
8232 pr_err("%s:Failed to request GPIO %d\n",
8233 __func__, GPIO_SDC_WP);
8234 } else {
8235 status = gpio_direction_input(GPIO_SDC_WP);
8236 if (!status) {
8237 status = gpio_get_value_cansleep(GPIO_SDC_WP);
8238 pr_info("%s: WP Status for Slot %d = %d\n",
8239 __func__, pdev->id, status);
8240 }
8241 gpio_free(GPIO_SDC_WP);
8242 }
8243 return status;
8244}
8245
8246#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8247int sdc5_register_status_notify(void (*callback)(int, void *),
8248 void *dev_id)
8249{
8250 sdc5_status_notify_cb = callback;
8251 sdc5_status_notify_cb_devid = dev_id;
8252 return 0;
8253}
8254#endif
8255
8256#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8257int sdc2_register_status_notify(void (*callback)(int, void *),
8258 void *dev_id)
8259{
8260 sdc2_status_notify_cb = callback;
8261 sdc2_status_notify_cb_devid = dev_id;
8262 return 0;
8263}
8264#endif
8265
8266/* Interrupt handler for SDC2 and SDC5 detection
8267 * This function uses dual-edge interrputs settings in order
8268 * to get SDIO detection when the GPIO is rising and SDIO removal
8269 * when the GPIO is falling */
8270static irqreturn_t msm8x60_multi_sdio_slot_status_irq(int irq, void *dev_id)
8271{
8272 int status;
8273
8274 if (!machine_is_msm8x60_fusion() &&
8275 !machine_is_msm8x60_fusn_ffa())
8276 return IRQ_NONE;
8277
8278 status = gpio_get_value(MDM2AP_SYNC);
8279 pr_info("%s: MDM2AP_SYNC Status = %d\n",
8280 __func__, status);
8281
8282#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8283 if (sdc2_status_notify_cb) {
8284 pr_info("%s: calling sdc2_status_notify_cb\n", __func__);
8285 sdc2_status_notify_cb(status,
8286 sdc2_status_notify_cb_devid);
8287 }
8288#endif
8289
8290#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8291 if (sdc5_status_notify_cb) {
8292 pr_info("%s: calling sdc5_status_notify_cb\n", __func__);
8293 sdc5_status_notify_cb(status,
8294 sdc5_status_notify_cb_devid);
8295 }
8296#endif
8297 return IRQ_HANDLED;
8298}
8299
8300static int msm8x60_multi_sdio_init(void)
8301{
8302 int ret, irq_num;
8303
8304 if (!machine_is_msm8x60_fusion() &&
8305 !machine_is_msm8x60_fusn_ffa())
8306 return 0;
8307
8308 ret = msm_gpiomux_get(MDM2AP_SYNC);
8309 if (ret) {
8310 pr_err("%s:Failed to request GPIO %d, ret=%d\n",
8311 __func__, MDM2AP_SYNC, ret);
8312 return ret;
8313 }
8314
8315 irq_num = gpio_to_irq(MDM2AP_SYNC);
8316
8317 ret = request_irq(irq_num,
8318 msm8x60_multi_sdio_slot_status_irq,
8319 IRQ_TYPE_EDGE_BOTH,
8320 "sdio_multidetection", NULL);
8321
8322 if (ret) {
8323 pr_err("%s:Failed to request irq, ret=%d\n",
8324 __func__, ret);
8325 return ret;
8326 }
8327
8328 return ret;
8329}
8330
8331#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008332static unsigned int msm8x60_sdcc_slot_status(struct device *dev)
8333{
8334 int status;
8335
8336 status = gpio_request(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)
8337 , "SD_HW_Detect");
8338 if (status) {
8339 pr_err("%s:Failed to request GPIO %d\n", __func__,
8340 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8341 } else {
8342 status = gpio_direction_input(
8343 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8344 if (!status)
8345 status = !(gpio_get_value_cansleep(
8346 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)));
8347 gpio_free(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8348 }
8349 return (unsigned int) status;
8350}
8351#endif
8352#endif
8353
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308354#define MSM_MPM_PIN_SDC3_DAT1 21
Subhash Jadavanife608a22012-04-13 10:45:53 +05308355#define MSM_MPM_PIN_SDC4_DAT1 23
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008356
8357#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8358static struct mmc_platform_data msm8x60_sdc1_data = {
8359 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8360 .translate_vdd = msm_sdcc_setup_power,
8361#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
8362 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8363#else
8364 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8365#endif
8366 .msmsdcc_fmin = 400000,
8367 .msmsdcc_fmid = 24000000,
8368 .msmsdcc_fmax = 48000000,
8369 .nonremovable = 1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308370 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008371};
8372#endif
8373
8374#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8375static struct mmc_platform_data msm8x60_sdc2_data = {
8376 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8377 .translate_vdd = msm_sdcc_setup_power,
8378 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8379 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8380 .msmsdcc_fmin = 400000,
8381 .msmsdcc_fmid = 24000000,
8382 .msmsdcc_fmax = 48000000,
8383 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008384 .register_status_notify = sdc2_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008385#ifdef CONFIG_MSM_SDIO_AL
8386 .is_sdio_al_client = 1,
8387#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308388 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008389};
8390#endif
8391
8392#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8393static struct mmc_platform_data msm8x60_sdc3_data = {
8394 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8395 .translate_vdd = msm_sdcc_setup_power,
8396 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8397 .wpswitch = msm_sdc3_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008398 .status = msm8x60_sdcc_slot_status,
8399 .status_irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
8400 PMIC_GPIO_SDC3_DET - 1),
8401 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008402 .msmsdcc_fmin = 400000,
8403 .msmsdcc_fmid = 24000000,
8404 .msmsdcc_fmax = 48000000,
8405 .nonremovable = 0,
Subhash Jadavani55e188e2012-04-13 11:31:08 +05308406 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC3_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308407 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008408};
8409#endif
8410
8411#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8412static struct mmc_platform_data msm8x60_sdc4_data = {
8413 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8414 .translate_vdd = msm_sdcc_setup_power,
8415 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8416 .msmsdcc_fmin = 400000,
8417 .msmsdcc_fmid = 24000000,
8418 .msmsdcc_fmax = 48000000,
8419 .nonremovable = 0,
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308420 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC4_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308421 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008422};
8423#endif
8424
8425#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8426static struct mmc_platform_data msm8x60_sdc5_data = {
8427 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8428 .translate_vdd = msm_sdcc_setup_power,
8429 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8430 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8431 .msmsdcc_fmin = 400000,
8432 .msmsdcc_fmid = 24000000,
8433 .msmsdcc_fmax = 48000000,
8434 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008435 .register_status_notify = sdc5_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008436#ifdef CONFIG_MSM_SDIO_AL
8437 .is_sdio_al_client = 1,
8438#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308439 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008440};
8441#endif
8442
8443static void __init msm8x60_init_mmc(void)
8444{
8445#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8446 /* SDCC1 : eMMC card connected */
8447 sdcc_vreg_data[0].vdd_data = &sdcc_vdd_reg_data[0];
8448 sdcc_vreg_data[0].vdd_data->reg_name = "8901_l5";
8449 sdcc_vreg_data[0].vdd_data->set_voltage_sup = 1;
8450 sdcc_vreg_data[0].vdd_data->level = 2850000;
Subhash Jadavania8482a32011-08-08 11:01:44 +05308451 sdcc_vreg_data[0].vdd_data->always_on = 1;
8452 sdcc_vreg_data[0].vdd_data->op_pwr_mode_sup = 1;
8453 sdcc_vreg_data[0].vdd_data->lpm_uA = 9000;
8454 sdcc_vreg_data[0].vdd_data->hpm_uA = 200000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008455
8456 sdcc_vreg_data[0].vccq_data = &sdcc_vccq_reg_data[0];
8457 sdcc_vreg_data[0].vccq_data->reg_name = "8901_lvs0";
8458 sdcc_vreg_data[0].vccq_data->set_voltage_sup = 0;
8459 sdcc_vreg_data[0].vccq_data->always_on = 1;
8460
8461 msm_add_sdcc(1, &msm8x60_sdc1_data);
8462#endif
8463#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8464 /*
8465 * MDM SDIO client is connected to SDC2 on charm SURF/FFA
8466 * and no card is connected on 8660 SURF/FFA/FLUID.
8467 */
8468 sdcc_vreg_data[1].vdd_data = &sdcc_vdd_reg_data[1];
8469 sdcc_vreg_data[1].vdd_data->reg_name = "8058_s3";
8470 sdcc_vreg_data[1].vdd_data->set_voltage_sup = 1;
8471 sdcc_vreg_data[1].vdd_data->level = 1800000;
8472
8473 sdcc_vreg_data[1].vccq_data = NULL;
8474
8475 if (machine_is_msm8x60_fusion())
8476 msm8x60_sdc2_data.msmsdcc_fmax = 24000000;
8477 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008478 msm8x60_sdc2_data.sdiowakeup_irq = gpio_to_irq(144);
8479 msm_sdcc_setup_gpio(2, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008480 msm_add_sdcc(2, &msm8x60_sdc2_data);
8481 }
8482#endif
8483#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8484 /* SDCC3 : External card slot connected */
8485 sdcc_vreg_data[2].vdd_data = &sdcc_vdd_reg_data[2];
8486 sdcc_vreg_data[2].vdd_data->reg_name = "8058_l14";
8487 sdcc_vreg_data[2].vdd_data->set_voltage_sup = 1;
8488 sdcc_vreg_data[2].vdd_data->level = 2850000;
8489 sdcc_vreg_data[2].vdd_data->always_on = 1;
8490 sdcc_vreg_data[2].vdd_data->op_pwr_mode_sup = 1;
8491 sdcc_vreg_data[2].vdd_data->lpm_uA = 9000;
8492 sdcc_vreg_data[2].vdd_data->hpm_uA = 200000;
8493
8494 sdcc_vreg_data[2].vccq_data = NULL;
8495
8496 sdcc_vreg_data[2].vddp_data = &sdcc_vddp_reg_data[2];
8497 sdcc_vreg_data[2].vddp_data->reg_name = "8058_l5";
8498 sdcc_vreg_data[2].vddp_data->set_voltage_sup = 1;
8499 sdcc_vreg_data[2].vddp_data->level = 2850000;
8500 sdcc_vreg_data[2].vddp_data->always_on = 1;
8501 sdcc_vreg_data[2].vddp_data->op_pwr_mode_sup = 1;
8502 /* Sleep current required is ~300 uA. But min. RPM
8503 * vote can be in terms of mA (min. 1 mA).
8504 * So let's vote for 2 mA during sleep.
8505 */
8506 sdcc_vreg_data[2].vddp_data->lpm_uA = 2000;
8507 /* Max. Active current required is 16 mA */
8508 sdcc_vreg_data[2].vddp_data->hpm_uA = 16000;
8509
8510 if (machine_is_msm8x60_fluid())
8511 msm8x60_sdc3_data.wpswitch = NULL;
8512 msm_add_sdcc(3, &msm8x60_sdc3_data);
8513#endif
8514#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8515 /* SDCC4 : WLAN WCN1314 chip is connected */
8516 sdcc_vreg_data[3].vdd_data = &sdcc_vdd_reg_data[3];
8517 sdcc_vreg_data[3].vdd_data->reg_name = "8058_s3";
8518 sdcc_vreg_data[3].vdd_data->set_voltage_sup = 1;
8519 sdcc_vreg_data[3].vdd_data->level = 1800000;
8520
8521 sdcc_vreg_data[3].vccq_data = NULL;
8522
8523 msm_add_sdcc(4, &msm8x60_sdc4_data);
8524#endif
8525#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8526 /*
8527 * MDM SDIO client is connected to SDC5 on charm SURF/FFA
8528 * and no card is connected on 8660 SURF/FFA/FLUID.
8529 */
8530 sdcc_vreg_data[4].vdd_data = &sdcc_vdd_reg_data[4];
8531 sdcc_vreg_data[4].vdd_data->reg_name = "8058_s3";
8532 sdcc_vreg_data[4].vdd_data->set_voltage_sup = 1;
8533 sdcc_vreg_data[4].vdd_data->level = 1800000;
8534
8535 sdcc_vreg_data[4].vccq_data = NULL;
8536
8537 if (machine_is_msm8x60_fusion())
8538 msm8x60_sdc5_data.msmsdcc_fmax = 24000000;
8539 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008540 msm8x60_sdc5_data.sdiowakeup_irq = gpio_to_irq(99);
8541 msm_sdcc_setup_gpio(5, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008542 msm_add_sdcc(5, &msm8x60_sdc5_data);
8543 }
8544#endif
8545}
8546
8547#if !defined(CONFIG_GPIO_SX150X) && !defined(CONFIG_GPIO_SX150X_MODULE)
8548static inline void display_common_power(int on) {}
8549#else
8550
8551#define _GET_REGULATOR(var, name) do { \
8552 if (var == NULL) { \
8553 var = regulator_get(NULL, name); \
8554 if (IS_ERR(var)) { \
8555 pr_err("'%s' regulator not found, rc=%ld\n", \
8556 name, PTR_ERR(var)); \
8557 var = NULL; \
8558 } \
8559 } \
8560} while (0)
8561
8562static int dsub_regulator(int on)
8563{
8564 static struct regulator *dsub_reg;
8565 static struct regulator *mpp0_reg;
8566 static int dsub_reg_enabled;
8567 int rc = 0;
8568
8569 _GET_REGULATOR(dsub_reg, "8901_l3");
8570 if (IS_ERR(dsub_reg)) {
8571 printk(KERN_ERR "%s: failed to get reg 8901_l3 err=%ld",
8572 __func__, PTR_ERR(dsub_reg));
8573 return PTR_ERR(dsub_reg);
8574 }
8575
8576 _GET_REGULATOR(mpp0_reg, "8901_mpp0");
8577 if (IS_ERR(mpp0_reg)) {
8578 printk(KERN_ERR "%s: failed to get reg 8901_mpp0 err=%ld",
8579 __func__, PTR_ERR(mpp0_reg));
8580 return PTR_ERR(mpp0_reg);
8581 }
8582
8583 if (on && !dsub_reg_enabled) {
8584 rc = regulator_set_voltage(dsub_reg, 3300000, 3300000);
8585 if (rc) {
8586 printk(KERN_ERR "%s: failed to set reg 8901_l3 voltage"
8587 " err=%d", __func__, rc);
8588 goto dsub_regulator_err;
8589 }
8590 rc = regulator_enable(dsub_reg);
8591 if (rc) {
8592 printk(KERN_ERR "%s: failed to enable reg 8901_l3"
8593 " err=%d", __func__, rc);
8594 goto dsub_regulator_err;
8595 }
8596 rc = regulator_enable(mpp0_reg);
8597 if (rc) {
8598 printk(KERN_ERR "%s: failed to enable reg 8901_mpp0"
8599 " err=%d", __func__, rc);
8600 goto dsub_regulator_err;
8601 }
8602 dsub_reg_enabled = 1;
8603 } else if (!on && dsub_reg_enabled) {
8604 rc = regulator_disable(dsub_reg);
8605 if (rc)
8606 printk(KERN_WARNING "%s: failed to disable reg 8901_l3"
8607 " err=%d", __func__, rc);
8608 rc = regulator_disable(mpp0_reg);
8609 if (rc)
8610 printk(KERN_WARNING "%s: failed to disable reg "
8611 "8901_mpp0 err=%d", __func__, rc);
8612 dsub_reg_enabled = 0;
8613 }
8614
8615 return rc;
8616
8617dsub_regulator_err:
8618 regulator_put(mpp0_reg);
8619 regulator_put(dsub_reg);
8620 return rc;
8621}
8622
8623static int display_power_on;
8624static void setup_display_power(void)
8625{
8626 if (display_power_on)
8627 if (lcdc_vga_enabled) {
8628 dsub_regulator(1);
8629 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8630 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8631 if (machine_is_msm8x60_ffa() ||
8632 machine_is_msm8x60_fusn_ffa())
8633 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 1);
8634 } else {
8635 dsub_regulator(0);
8636 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 1);
8637 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 1);
8638 if (machine_is_msm8x60_ffa() ||
8639 machine_is_msm8x60_fusn_ffa())
8640 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8641 }
8642 else {
8643 dsub_regulator(0);
8644 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
8645 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8646 /* BACKLIGHT */
8647 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8648 /* LVDS */
8649 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8650 }
8651}
8652
8653#define _GET_REGULATOR(var, name) do { \
8654 if (var == NULL) { \
8655 var = regulator_get(NULL, name); \
8656 if (IS_ERR(var)) { \
8657 pr_err("'%s' regulator not found, rc=%ld\n", \
8658 name, PTR_ERR(var)); \
8659 var = NULL; \
8660 } \
8661 } \
8662} while (0)
8663
8664#define GPIO_RESX_N (GPIO_EXPANDER_GPIO_BASE + 2)
8665
8666static void display_common_power(int on)
8667{
8668 int rc;
8669 static struct regulator *display_reg;
8670
8671 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
8672 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8673 if (on) {
8674 /* LVDS */
8675 _GET_REGULATOR(display_reg, "8901_l2");
8676 if (!display_reg)
8677 return;
8678 rc = regulator_set_voltage(display_reg,
8679 3300000, 3300000);
8680 if (rc)
8681 goto out;
8682 rc = regulator_enable(display_reg);
8683 if (rc)
8684 goto out;
8685 rc = gpio_request(GPIO_LVDS_SHUTDOWN_N,
8686 "LVDS_STDN_OUT_N");
8687 if (rc) {
8688 printk(KERN_ERR "%s: LVDS gpio %d request"
8689 "failed\n", __func__,
8690 GPIO_LVDS_SHUTDOWN_N);
8691 goto out2;
8692 }
8693
8694 /* BACKLIGHT */
8695 rc = gpio_request(GPIO_BACKLIGHT_EN, "BACKLIGHT_EN");
8696 if (rc) {
8697 printk(KERN_ERR "%s: BACKLIGHT gpio %d request"
8698 "failed\n", __func__,
8699 GPIO_BACKLIGHT_EN);
8700 goto out3;
8701 }
8702
8703 if (machine_is_msm8x60_ffa() ||
8704 machine_is_msm8x60_fusn_ffa()) {
8705 rc = gpio_request(GPIO_DONGLE_PWR_EN,
8706 "DONGLE_PWR_EN");
8707 if (rc) {
8708 printk(KERN_ERR "%s: DONGLE_PWR_EN gpio"
8709 " %d request failed\n", __func__,
8710 GPIO_DONGLE_PWR_EN);
8711 goto out4;
8712 }
8713 }
8714
8715 gpio_direction_output(GPIO_LVDS_SHUTDOWN_N, 0);
8716 gpio_direction_output(GPIO_BACKLIGHT_EN, 0);
8717 if (machine_is_msm8x60_ffa() ||
8718 machine_is_msm8x60_fusn_ffa())
8719 gpio_direction_output(GPIO_DONGLE_PWR_EN, 0);
8720 mdelay(20);
8721 display_power_on = 1;
8722 setup_display_power();
8723 } else {
8724 if (display_power_on) {
8725 display_power_on = 0;
8726 setup_display_power();
8727 mdelay(20);
8728 if (machine_is_msm8x60_ffa() ||
8729 machine_is_msm8x60_fusn_ffa())
8730 gpio_free(GPIO_DONGLE_PWR_EN);
8731 goto out4;
8732 }
8733 }
8734 }
8735#if defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
8736 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA)
8737 else if (machine_is_msm8x60_fluid()) {
8738 static struct regulator *fluid_reg;
8739 static struct regulator *fluid_reg2;
8740
8741 if (on) {
8742 _GET_REGULATOR(fluid_reg, "8901_l2");
8743 if (!fluid_reg)
8744 return;
8745 _GET_REGULATOR(fluid_reg2, "8058_s3");
8746 if (!fluid_reg2) {
8747 regulator_put(fluid_reg);
8748 return;
8749 }
8750 rc = gpio_request(GPIO_RESX_N, "RESX_N");
8751 if (rc) {
8752 regulator_put(fluid_reg2);
8753 regulator_put(fluid_reg);
8754 return;
8755 }
8756 regulator_set_voltage(fluid_reg, 2850000, 2850000);
8757 regulator_set_voltage(fluid_reg2, 1800000, 1800000);
8758 regulator_enable(fluid_reg);
8759 regulator_enable(fluid_reg2);
8760 msleep(20);
8761 gpio_direction_output(GPIO_RESX_N, 0);
8762 udelay(10);
8763 gpio_set_value_cansleep(GPIO_RESX_N, 1);
8764 display_power_on = 1;
8765 setup_display_power();
8766 } else {
8767 gpio_set_value_cansleep(GPIO_RESX_N, 0);
8768 gpio_free(GPIO_RESX_N);
8769 msleep(20);
8770 regulator_disable(fluid_reg2);
8771 regulator_disable(fluid_reg);
8772 regulator_put(fluid_reg2);
8773 regulator_put(fluid_reg);
8774 display_power_on = 0;
8775 setup_display_power();
8776 fluid_reg = NULL;
8777 fluid_reg2 = NULL;
8778 }
8779 }
8780#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04008781#if defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA)
8782 else if (machine_is_msm8x60_dragon()) {
8783 static struct regulator *dragon_reg;
8784 static struct regulator *dragon_reg2;
8785
8786 if (on) {
8787 _GET_REGULATOR(dragon_reg, "8901_l2");
8788 if (!dragon_reg)
8789 return;
8790 _GET_REGULATOR(dragon_reg2, "8058_l16");
8791 if (!dragon_reg2) {
8792 regulator_put(dragon_reg);
8793 dragon_reg = NULL;
8794 return;
8795 }
8796
8797 rc = gpio_request(GPIO_NT35582_BL_EN, "lcdc_bl_en");
8798 if (rc) {
8799 pr_err("%s: gpio %d request failed with rc=%d\n",
8800 __func__, GPIO_NT35582_BL_EN, rc);
8801 regulator_put(dragon_reg);
8802 regulator_put(dragon_reg2);
8803 dragon_reg = NULL;
8804 dragon_reg2 = NULL;
8805 return;
8806 }
8807
8808 if (gpio_tlmm_config(GPIO_CFG(GPIO_NT35582_RESET, 0,
8809 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
8810 GPIO_CFG_16MA), GPIO_CFG_ENABLE)) {
8811 pr_err("%s: config gpio '%d' failed!\n",
8812 __func__, GPIO_NT35582_RESET);
8813 gpio_free(GPIO_NT35582_BL_EN);
8814 regulator_put(dragon_reg);
8815 regulator_put(dragon_reg2);
8816 dragon_reg = NULL;
8817 dragon_reg2 = NULL;
8818 return;
8819 }
8820
8821 rc = gpio_request(GPIO_NT35582_RESET, "lcdc_reset");
8822 if (rc) {
8823 pr_err("%s: unable to request gpio %d (rc=%d)\n",
8824 __func__, GPIO_NT35582_RESET, rc);
8825 gpio_free(GPIO_NT35582_BL_EN);
8826 regulator_put(dragon_reg);
8827 regulator_put(dragon_reg2);
8828 dragon_reg = NULL;
8829 dragon_reg2 = NULL;
8830 return;
8831 }
8832
8833 regulator_set_voltage(dragon_reg, 3300000, 3300000);
8834 regulator_set_voltage(dragon_reg2, 1800000, 1800000);
8835 regulator_enable(dragon_reg);
8836 regulator_enable(dragon_reg2);
8837 msleep(20);
8838
8839 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8840 msleep(20);
8841 gpio_set_value_cansleep(GPIO_NT35582_RESET, 0);
8842 msleep(20);
8843 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8844 msleep(50);
8845
8846 gpio_set_value_cansleep(GPIO_NT35582_BL_EN, 1);
8847
8848 display_power_on = 1;
8849 } else if ((dragon_reg != NULL) && (dragon_reg2 != NULL)) {
8850 gpio_free(GPIO_NT35582_RESET);
8851 gpio_free(GPIO_NT35582_BL_EN);
8852 regulator_disable(dragon_reg2);
8853 regulator_disable(dragon_reg);
8854 regulator_put(dragon_reg2);
8855 regulator_put(dragon_reg);
8856 display_power_on = 0;
8857 dragon_reg = NULL;
8858 dragon_reg2 = NULL;
8859 }
8860 }
8861#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008862 return;
8863
8864out4:
8865 gpio_free(GPIO_BACKLIGHT_EN);
8866out3:
8867 gpio_free(GPIO_LVDS_SHUTDOWN_N);
8868out2:
8869 regulator_disable(display_reg);
8870out:
8871 regulator_put(display_reg);
8872 display_reg = NULL;
8873}
8874#undef _GET_REGULATOR
8875#endif
8876
8877static int mipi_dsi_panel_power(int on);
8878
8879#define LCDC_NUM_GPIO 28
8880#define LCDC_GPIO_START 0
8881
8882static void lcdc_samsung_panel_power(int on)
8883{
8884 int n, ret = 0;
8885
8886 display_common_power(on);
8887
8888 for (n = 0; n < LCDC_NUM_GPIO; n++) {
8889 if (on) {
8890 ret = gpio_request(LCDC_GPIO_START + n, "LCDC_GPIO");
8891 if (unlikely(ret)) {
8892 pr_err("%s not able to get gpio\n", __func__);
8893 break;
8894 }
8895 } else
8896 gpio_free(LCDC_GPIO_START + n);
8897 }
8898
8899 if (ret) {
8900 for (n--; n >= 0; n--)
8901 gpio_free(LCDC_GPIO_START + n);
8902 }
8903
8904 mipi_dsi_panel_power(0); /* set 8058_ldo0 to LPM */
8905}
8906
8907#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
8908#define _GET_REGULATOR(var, name) do { \
8909 var = regulator_get(NULL, name); \
8910 if (IS_ERR(var)) { \
8911 pr_err("'%s' regulator not found, rc=%ld\n", \
8912 name, IS_ERR(var)); \
8913 var = NULL; \
8914 return -ENODEV; \
8915 } \
8916} while (0)
8917
8918static int hdmi_enable_5v(int on)
8919{
8920 static struct regulator *reg_8901_hdmi_mvs; /* HDMI_5V */
8921 static struct regulator *reg_8901_mpp0; /* External 5V */
8922 static int prev_on;
8923 int rc;
8924
8925 if (on == prev_on)
8926 return 0;
8927
8928 if (!reg_8901_hdmi_mvs)
8929 _GET_REGULATOR(reg_8901_hdmi_mvs, "8901_hdmi_mvs");
8930 if (!reg_8901_mpp0)
8931 _GET_REGULATOR(reg_8901_mpp0, "8901_mpp0");
8932
8933 if (on) {
8934 rc = regulator_enable(reg_8901_mpp0);
8935 if (rc) {
8936 pr_err("'%s' regulator enable failed, rc=%d\n",
8937 "reg_8901_mpp0", rc);
8938 return rc;
8939 }
8940 rc = regulator_enable(reg_8901_hdmi_mvs);
8941 if (rc) {
8942 pr_err("'%s' regulator enable failed, rc=%d\n",
8943 "8901_hdmi_mvs", rc);
8944 return rc;
8945 }
8946 pr_info("%s(on): success\n", __func__);
8947 } else {
8948 rc = regulator_disable(reg_8901_hdmi_mvs);
8949 if (rc)
8950 pr_warning("'%s' regulator disable failed, rc=%d\n",
8951 "8901_hdmi_mvs", rc);
8952 rc = regulator_disable(reg_8901_mpp0);
8953 if (rc)
8954 pr_warning("'%s' regulator disable failed, rc=%d\n",
8955 "reg_8901_mpp0", rc);
8956 pr_info("%s(off): success\n", __func__);
8957 }
8958
8959 prev_on = on;
8960
8961 return 0;
8962}
8963
8964static int hdmi_core_power(int on, int show)
8965{
8966 static struct regulator *reg_8058_l16; /* VDD_HDMI */
8967 static int prev_on;
8968 int rc;
8969
8970 if (on == prev_on)
8971 return 0;
8972
8973 if (!reg_8058_l16)
8974 _GET_REGULATOR(reg_8058_l16, "8058_l16");
8975
8976 if (on) {
8977 rc = regulator_set_voltage(reg_8058_l16, 1800000, 1800000);
8978 if (!rc)
8979 rc = regulator_enable(reg_8058_l16);
8980 if (rc) {
8981 pr_err("'%s' regulator enable failed, rc=%d\n",
8982 "8058_l16", rc);
8983 return rc;
8984 }
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05308985 pr_debug("%s(on): success\n", __func__);
8986 } else {
8987 rc = regulator_disable(reg_8058_l16);
8988 if (rc)
8989 pr_warning("'%s' regulator disable failed, rc=%d\n",
8990 "8058_l16", rc);
8991 pr_debug("%s(off): success\n", __func__);
8992 }
8993
8994 prev_on = on;
8995
8996 return 0;
8997}
8998
8999static int hdmi_gpio_config(int on)
9000{
9001 int rc = 0;
9002 static int prev_on;
9003
9004 if (on == prev_on)
9005 return 0;
9006
9007 if (on) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009008 rc = gpio_request(170, "HDMI_DDC_CLK");
9009 if (rc) {
9010 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9011 "HDMI_DDC_CLK", 170, rc);
9012 goto error1;
9013 }
9014 rc = gpio_request(171, "HDMI_DDC_DATA");
9015 if (rc) {
9016 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9017 "HDMI_DDC_DATA", 171, rc);
9018 goto error2;
9019 }
9020 rc = gpio_request(172, "HDMI_HPD");
9021 if (rc) {
9022 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9023 "HDMI_HPD", 172, rc);
9024 goto error3;
9025 }
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309026 pr_debug("%s(on): success\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009027 } else {
9028 gpio_free(170);
9029 gpio_free(171);
9030 gpio_free(172);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309031 pr_debug("%s(off): success\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009032 }
9033
9034 prev_on = on;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009035 return 0;
9036
9037error3:
9038 gpio_free(171);
9039error2:
9040 gpio_free(170);
9041error1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009042 return rc;
9043}
9044
9045static int hdmi_cec_power(int on)
9046{
9047 static struct regulator *reg_8901_l3; /* HDMI_CEC */
9048 static int prev_on;
9049 int rc;
9050
9051 if (on == prev_on)
9052 return 0;
9053
9054 if (!reg_8901_l3)
9055 _GET_REGULATOR(reg_8901_l3, "8901_l3");
9056
9057 if (on) {
9058 rc = regulator_set_voltage(reg_8901_l3, 3300000, 3300000);
9059 if (!rc)
9060 rc = regulator_enable(reg_8901_l3);
9061 if (rc) {
9062 pr_err("'%s' regulator enable failed, rc=%d\n",
9063 "8901_l3", rc);
9064 return rc;
9065 }
9066 rc = gpio_request(169, "HDMI_CEC_VAR");
9067 if (rc) {
9068 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9069 "HDMI_CEC_VAR", 169, rc);
9070 goto error;
9071 }
9072 pr_info("%s(on): success\n", __func__);
9073 } else {
9074 gpio_free(169);
9075 rc = regulator_disable(reg_8901_l3);
9076 if (rc)
9077 pr_warning("'%s' regulator disable failed, rc=%d\n",
9078 "8901_l3", rc);
9079 pr_info("%s(off): success\n", __func__);
9080 }
9081
9082 prev_on = on;
9083
9084 return 0;
9085error:
9086 regulator_disable(reg_8901_l3);
9087 return rc;
9088}
9089
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309090static int hdmi_panel_power(int on)
9091{
9092 int rc;
9093
9094 pr_debug("%s: HDMI Core: %s\n", __func__, (on ? "ON" : "OFF"));
9095 rc = hdmi_core_power(on, 1);
9096 if (rc)
9097 rc = hdmi_cec_power(on);
9098
9099 pr_debug("%s: HDMI Core: %s Success\n", __func__, (on ? "ON" : "OFF"));
9100 return rc;
9101}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009102#undef _GET_REGULATOR
9103
9104#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
9105
9106static int lcdc_panel_power(int on)
9107{
9108 int flag_on = !!on;
9109 static int lcdc_power_save_on;
9110
9111 if (lcdc_power_save_on == flag_on)
9112 return 0;
9113
9114 lcdc_power_save_on = flag_on;
9115
9116 lcdc_samsung_panel_power(on);
9117
9118 return 0;
9119}
9120
9121#ifdef CONFIG_MSM_BUS_SCALING
Nagamalleswararao Ganji5fabbd62011-11-06 23:10:43 -08009122
9123static struct msm_bus_vectors rotator_init_vectors[] = {
9124 {
9125 .src = MSM_BUS_MASTER_ROTATOR,
9126 .dst = MSM_BUS_SLAVE_SMI,
9127 .ab = 0,
9128 .ib = 0,
9129 },
9130 {
9131 .src = MSM_BUS_MASTER_ROTATOR,
9132 .dst = MSM_BUS_SLAVE_EBI_CH0,
9133 .ab = 0,
9134 .ib = 0,
9135 },
9136};
9137
9138static struct msm_bus_vectors rotator_ui_vectors[] = {
9139 {
9140 .src = MSM_BUS_MASTER_ROTATOR,
9141 .dst = MSM_BUS_SLAVE_SMI,
9142 .ab = 0,
9143 .ib = 0,
9144 },
9145 {
9146 .src = MSM_BUS_MASTER_ROTATOR,
9147 .dst = MSM_BUS_SLAVE_EBI_CH0,
9148 .ab = (1024 * 600 * 4 * 2 * 60),
9149 .ib = (1024 * 600 * 4 * 2 * 60 * 1.5),
9150 },
9151};
9152
9153static struct msm_bus_vectors rotator_vga_vectors[] = {
9154 {
9155 .src = MSM_BUS_MASTER_ROTATOR,
9156 .dst = MSM_BUS_SLAVE_SMI,
9157 .ab = (640 * 480 * 2 * 2 * 30),
9158 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9159 },
9160 {
9161 .src = MSM_BUS_MASTER_ROTATOR,
9162 .dst = MSM_BUS_SLAVE_EBI_CH0,
9163 .ab = (640 * 480 * 2 * 2 * 30),
9164 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9165 },
9166};
9167
9168static struct msm_bus_vectors rotator_720p_vectors[] = {
9169 {
9170 .src = MSM_BUS_MASTER_ROTATOR,
9171 .dst = MSM_BUS_SLAVE_SMI,
9172 .ab = (1280 * 736 * 2 * 2 * 30),
9173 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9174 },
9175 {
9176 .src = MSM_BUS_MASTER_ROTATOR,
9177 .dst = MSM_BUS_SLAVE_EBI_CH0,
9178 .ab = (1280 * 736 * 2 * 2 * 30),
9179 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9180 },
9181};
9182
9183static struct msm_bus_vectors rotator_1080p_vectors[] = {
9184 {
9185 .src = MSM_BUS_MASTER_ROTATOR,
9186 .dst = MSM_BUS_SLAVE_SMI,
9187 .ab = (1920 * 1088 * 2 * 2 * 30),
9188 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9189 },
9190 {
9191 .src = MSM_BUS_MASTER_ROTATOR,
9192 .dst = MSM_BUS_SLAVE_EBI_CH0,
9193 .ab = (1920 * 1088 * 2 * 2 * 30),
9194 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9195 },
9196};
9197
9198static struct msm_bus_paths rotator_bus_scale_usecases[] = {
9199 {
9200 ARRAY_SIZE(rotator_init_vectors),
9201 rotator_init_vectors,
9202 },
9203 {
9204 ARRAY_SIZE(rotator_ui_vectors),
9205 rotator_ui_vectors,
9206 },
9207 {
9208 ARRAY_SIZE(rotator_vga_vectors),
9209 rotator_vga_vectors,
9210 },
9211 {
9212 ARRAY_SIZE(rotator_720p_vectors),
9213 rotator_720p_vectors,
9214 },
9215 {
9216 ARRAY_SIZE(rotator_1080p_vectors),
9217 rotator_1080p_vectors,
9218 },
9219};
9220
9221struct msm_bus_scale_pdata rotator_bus_scale_pdata = {
9222 rotator_bus_scale_usecases,
9223 ARRAY_SIZE(rotator_bus_scale_usecases),
9224 .name = "rotator",
9225};
9226
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009227static struct msm_bus_vectors mdp_init_vectors[] = {
9228 /* For now, 0th array entry is reserved.
9229 * Please leave 0 as is and don't use it
9230 */
9231 {
9232 .src = MSM_BUS_MASTER_MDP_PORT0,
9233 .dst = MSM_BUS_SLAVE_SMI,
9234 .ab = 0,
9235 .ib = 0,
9236 },
9237 /* Master and slaves can be from different fabrics */
9238 {
9239 .src = MSM_BUS_MASTER_MDP_PORT0,
9240 .dst = MSM_BUS_SLAVE_EBI_CH0,
9241 .ab = 0,
9242 .ib = 0,
9243 },
9244};
9245
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009246#ifdef CONFIG_FB_MSM_LCDC_DSUB
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009247static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9248 /* Default case static display/UI/2d/3d if FB SMI */
9249 {
9250 .src = MSM_BUS_MASTER_MDP_PORT0,
9251 .dst = MSM_BUS_SLAVE_SMI,
9252 .ab = 388800000,
9253 .ib = 486000000,
9254 },
9255 /* Master and slaves can be from different fabrics */
9256 {
9257 .src = MSM_BUS_MASTER_MDP_PORT0,
9258 .dst = MSM_BUS_SLAVE_EBI_CH0,
9259 .ab = 0,
9260 .ib = 0,
9261 },
9262};
9263
9264static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9265 /* Default case static display/UI/2d/3d if FB SMI */
9266 {
9267 .src = MSM_BUS_MASTER_MDP_PORT0,
9268 .dst = MSM_BUS_SLAVE_SMI,
9269 .ab = 0,
9270 .ib = 0,
9271 },
9272 /* Master and slaves can be from different fabrics */
9273 {
9274 .src = MSM_BUS_MASTER_MDP_PORT0,
9275 .dst = MSM_BUS_SLAVE_EBI_CH0,
9276 .ab = 388800000,
9277 .ib = 486000000 * 2,
9278 },
9279};
9280static struct msm_bus_vectors mdp_vga_vectors[] = {
9281 /* VGA and less video */
9282 {
9283 .src = MSM_BUS_MASTER_MDP_PORT0,
9284 .dst = MSM_BUS_SLAVE_SMI,
9285 .ab = 458092800,
9286 .ib = 572616000,
9287 },
9288 {
9289 .src = MSM_BUS_MASTER_MDP_PORT0,
9290 .dst = MSM_BUS_SLAVE_EBI_CH0,
9291 .ab = 458092800,
9292 .ib = 572616000 * 2,
9293 },
9294};
9295static struct msm_bus_vectors mdp_720p_vectors[] = {
9296 /* 720p and less video */
9297 {
9298 .src = MSM_BUS_MASTER_MDP_PORT0,
9299 .dst = MSM_BUS_SLAVE_SMI,
9300 .ab = 471744000,
9301 .ib = 589680000,
9302 },
9303 /* Master and slaves can be from different fabrics */
9304 {
9305 .src = MSM_BUS_MASTER_MDP_PORT0,
9306 .dst = MSM_BUS_SLAVE_EBI_CH0,
9307 .ab = 471744000,
9308 .ib = 589680000 * 2,
9309 },
9310};
9311
9312static struct msm_bus_vectors mdp_1080p_vectors[] = {
9313 /* 1080p and less video */
9314 {
9315 .src = MSM_BUS_MASTER_MDP_PORT0,
9316 .dst = MSM_BUS_SLAVE_SMI,
9317 .ab = 575424000,
9318 .ib = 719280000,
9319 },
9320 /* Master and slaves can be from different fabrics */
9321 {
9322 .src = MSM_BUS_MASTER_MDP_PORT0,
9323 .dst = MSM_BUS_SLAVE_EBI_CH0,
9324 .ab = 575424000,
9325 .ib = 719280000 * 2,
9326 },
9327};
9328
9329#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009330static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9331 /* Default case static display/UI/2d/3d if FB SMI */
9332 {
9333 .src = MSM_BUS_MASTER_MDP_PORT0,
9334 .dst = MSM_BUS_SLAVE_SMI,
9335 .ab = 175110000,
9336 .ib = 218887500,
9337 },
9338 /* Master and slaves can be from different fabrics */
9339 {
9340 .src = MSM_BUS_MASTER_MDP_PORT0,
9341 .dst = MSM_BUS_SLAVE_EBI_CH0,
9342 .ab = 0,
9343 .ib = 0,
9344 },
9345};
9346
9347static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9348 /* Default case static display/UI/2d/3d if FB SMI */
9349 {
9350 .src = MSM_BUS_MASTER_MDP_PORT0,
9351 .dst = MSM_BUS_SLAVE_SMI,
9352 .ab = 0,
9353 .ib = 0,
9354 },
9355 /* Master and slaves can be from different fabrics */
9356 {
9357 .src = MSM_BUS_MASTER_MDP_PORT0,
9358 .dst = MSM_BUS_SLAVE_EBI_CH0,
9359 .ab = 216000000,
9360 .ib = 270000000 * 2,
9361 },
9362};
9363static struct msm_bus_vectors mdp_vga_vectors[] = {
9364 /* VGA and less video */
9365 {
9366 .src = MSM_BUS_MASTER_MDP_PORT0,
9367 .dst = MSM_BUS_SLAVE_SMI,
9368 .ab = 216000000,
9369 .ib = 270000000,
9370 },
9371 {
9372 .src = MSM_BUS_MASTER_MDP_PORT0,
9373 .dst = MSM_BUS_SLAVE_EBI_CH0,
9374 .ab = 216000000,
9375 .ib = 270000000 * 2,
9376 },
9377};
9378
9379static struct msm_bus_vectors mdp_720p_vectors[] = {
9380 /* 720p and less video */
9381 {
9382 .src = MSM_BUS_MASTER_MDP_PORT0,
9383 .dst = MSM_BUS_SLAVE_SMI,
9384 .ab = 230400000,
9385 .ib = 288000000,
9386 },
9387 /* Master and slaves can be from different fabrics */
9388 {
9389 .src = MSM_BUS_MASTER_MDP_PORT0,
9390 .dst = MSM_BUS_SLAVE_EBI_CH0,
9391 .ab = 230400000,
9392 .ib = 288000000 * 2,
9393 },
9394};
9395
9396static struct msm_bus_vectors mdp_1080p_vectors[] = {
9397 /* 1080p and less video */
9398 {
9399 .src = MSM_BUS_MASTER_MDP_PORT0,
9400 .dst = MSM_BUS_SLAVE_SMI,
9401 .ab = 334080000,
9402 .ib = 417600000,
9403 },
9404 /* Master and slaves can be from different fabrics */
9405 {
9406 .src = MSM_BUS_MASTER_MDP_PORT0,
9407 .dst = MSM_BUS_SLAVE_EBI_CH0,
9408 .ab = 334080000,
Ravishangar Kalyanam731beb92011-07-07 18:27:32 -07009409 .ib = 550000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009410 },
9411};
9412
9413#endif
9414static struct msm_bus_paths mdp_bus_scale_usecases[] = {
9415 {
9416 ARRAY_SIZE(mdp_init_vectors),
9417 mdp_init_vectors,
9418 },
9419 {
9420 ARRAY_SIZE(mdp_sd_smi_vectors),
9421 mdp_sd_smi_vectors,
9422 },
9423 {
9424 ARRAY_SIZE(mdp_sd_ebi_vectors),
9425 mdp_sd_ebi_vectors,
9426 },
9427 {
9428 ARRAY_SIZE(mdp_vga_vectors),
9429 mdp_vga_vectors,
9430 },
9431 {
9432 ARRAY_SIZE(mdp_720p_vectors),
9433 mdp_720p_vectors,
9434 },
9435 {
9436 ARRAY_SIZE(mdp_1080p_vectors),
9437 mdp_1080p_vectors,
9438 },
9439};
9440static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
9441 mdp_bus_scale_usecases,
9442 ARRAY_SIZE(mdp_bus_scale_usecases),
9443 .name = "mdp",
9444};
9445
9446#endif
9447#ifdef CONFIG_MSM_BUS_SCALING
9448static struct msm_bus_vectors dtv_bus_init_vectors[] = {
9449 /* For now, 0th array entry is reserved.
9450 * Please leave 0 as is and don't use it
9451 */
9452 {
9453 .src = MSM_BUS_MASTER_MDP_PORT0,
9454 .dst = MSM_BUS_SLAVE_SMI,
9455 .ab = 0,
9456 .ib = 0,
9457 },
9458 /* Master and slaves can be from different fabrics */
9459 {
9460 .src = MSM_BUS_MASTER_MDP_PORT0,
9461 .dst = MSM_BUS_SLAVE_EBI_CH0,
9462 .ab = 0,
9463 .ib = 0,
9464 },
9465};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009466
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009467static struct msm_bus_vectors dtv_bus_def_vectors[] = {
9468 /* For now, 0th array entry is reserved.
9469 * Please leave 0 as is and don't use it
9470 */
9471 {
9472 .src = MSM_BUS_MASTER_MDP_PORT0,
9473 .dst = MSM_BUS_SLAVE_SMI,
9474 .ab = 566092800,
9475 .ib = 707616000,
9476 },
9477 /* Master and slaves can be from different fabrics */
9478 {
9479 .src = MSM_BUS_MASTER_MDP_PORT0,
9480 .dst = MSM_BUS_SLAVE_EBI_CH0,
9481 .ab = 566092800,
9482 .ib = 707616000,
9483 },
9484};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009485
9486static struct msm_bus_vectors dtv_bus_hdmi_prim_vectors[] = {
9487 /* For now, 0th array entry is reserved.
9488 * Please leave 0 as is and don't use it
9489 */
9490 {
9491 .src = MSM_BUS_MASTER_MDP_PORT0,
9492 .dst = MSM_BUS_SLAVE_SMI,
9493 .ab = 2000000000,
9494 .ib = 2000000000,
9495 },
9496 /* Master and slaves can be from different fabrics */
9497 {
9498 .src = MSM_BUS_MASTER_MDP_PORT0,
9499 .dst = MSM_BUS_SLAVE_EBI_CH0,
9500 .ab = 2000000000,
9501 .ib = 2000000000,
9502 },
9503};
9504
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009505static struct msm_bus_paths dtv_bus_scale_usecases[] = {
9506 {
9507 ARRAY_SIZE(dtv_bus_init_vectors),
9508 dtv_bus_init_vectors,
9509 },
9510 {
9511 ARRAY_SIZE(dtv_bus_def_vectors),
9512 dtv_bus_def_vectors,
9513 },
9514};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009515
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009516static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
9517 dtv_bus_scale_usecases,
9518 ARRAY_SIZE(dtv_bus_scale_usecases),
9519 .name = "dtv",
9520};
9521
9522static struct lcdc_platform_data dtv_pdata = {
9523 .bus_scale_table = &dtv_bus_scale_pdata,
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309524 .lcdc_power_save = hdmi_panel_power,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009525};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009526
9527static struct msm_bus_paths dtv_hdmi_prim_bus_scale_usecases[] = {
9528 {
9529 ARRAY_SIZE(dtv_bus_init_vectors),
9530 dtv_bus_init_vectors,
9531 },
9532 {
9533 ARRAY_SIZE(dtv_bus_hdmi_prim_vectors),
9534 dtv_bus_hdmi_prim_vectors,
9535 },
9536};
9537
9538static struct msm_bus_scale_pdata dtv_hdmi_prim_bus_scale_pdata = {
9539 dtv_hdmi_prim_bus_scale_usecases,
9540 ARRAY_SIZE(dtv_hdmi_prim_bus_scale_usecases),
9541 .name = "dtv",
9542};
9543
9544static struct lcdc_platform_data dtv_hdmi_prim_pdata = {
9545 .bus_scale_table = &dtv_hdmi_prim_bus_scale_pdata,
9546};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009547#endif
9548
9549
9550static struct lcdc_platform_data lcdc_pdata = {
9551 .lcdc_power_save = lcdc_panel_power,
9552};
9553
9554
9555#define MDP_VSYNC_GPIO 28
9556
9557/*
9558 * MIPI_DSI only use 8058_LDO0 which need always on
9559 * therefore it need to be put at low power mode if
9560 * it was not used instead of turn it off.
9561 */
9562static int mipi_dsi_panel_power(int on)
9563{
9564 int flag_on = !!on;
9565 static int mipi_dsi_power_save_on;
9566 static struct regulator *ldo0;
9567 int rc = 0;
9568
9569 if (mipi_dsi_power_save_on == flag_on)
9570 return 0;
9571
9572 mipi_dsi_power_save_on = flag_on;
9573
9574 if (ldo0 == NULL) { /* init */
9575 ldo0 = regulator_get(NULL, "8058_l0");
9576 if (IS_ERR(ldo0)) {
9577 pr_debug("%s: LDO0 failed\n", __func__);
9578 rc = PTR_ERR(ldo0);
9579 return rc;
9580 }
9581
9582 rc = regulator_set_voltage(ldo0, 1200000, 1200000);
9583 if (rc)
9584 goto out;
9585
9586 rc = regulator_enable(ldo0);
9587 if (rc)
9588 goto out;
9589 }
9590
9591 if (on) {
9592 /* set ldo0 to HPM */
9593 rc = regulator_set_optimum_mode(ldo0, 100000);
9594 if (rc < 0)
9595 goto out;
9596 } else {
9597 /* set ldo0 to LPM */
Padmanabhan Komanduru0b478ff2011-11-22 19:15:40 +05309598 rc = regulator_set_optimum_mode(ldo0, 1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009599 if (rc < 0)
9600 goto out;
9601 }
9602
9603 return 0;
9604out:
9605 regulator_disable(ldo0);
9606 regulator_put(ldo0);
9607 ldo0 = NULL;
9608 return rc;
9609}
9610
9611static struct mipi_dsi_platform_data mipi_dsi_pdata = {
9612 .vsync_gpio = MDP_VSYNC_GPIO,
9613 .dsi_power_save = mipi_dsi_panel_power,
9614};
9615
9616#ifdef CONFIG_FB_MSM_TVOUT
9617static struct regulator *reg_8058_l13;
9618
9619static int atv_dac_power(int on)
9620{
9621 int rc = 0;
9622 #define _GET_REGULATOR(var, name) do { \
9623 var = regulator_get(NULL, name); \
9624 if (IS_ERR(var)) { \
9625 pr_info("'%s' regulator not found, rc=%ld\n", \
9626 name, IS_ERR(var)); \
9627 var = NULL; \
9628 return -ENODEV; \
9629 } \
9630 } while (0)
9631
9632 if (!reg_8058_l13)
9633 _GET_REGULATOR(reg_8058_l13, "8058_l13");
9634 #undef _GET_REGULATOR
9635
9636 if (on) {
9637 rc = regulator_set_voltage(reg_8058_l13, 2050000, 2050000);
9638 if (rc) {
9639 pr_info("%s: '%s' regulator set voltage failed,\
9640 rc=%d\n", __func__, "8058_l13", rc);
9641 return rc;
9642 }
9643
9644 rc = regulator_enable(reg_8058_l13);
9645 if (rc) {
9646 pr_err("%s: '%s' regulator enable failed,\
9647 rc=%d\n", __func__, "8058_l13", rc);
9648 return rc;
9649 }
9650 } else {
9651 rc = regulator_force_disable(reg_8058_l13);
9652 if (rc)
9653 pr_warning("%s: '%s' regulator disable failed, rc=%d\n",
9654 __func__, "8058_l13", rc);
9655 }
9656 return rc;
9657
9658}
9659#endif
9660
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009661static struct msm_panel_common_pdata mdp_pdata = {
9662 .gpio = MDP_VSYNC_GPIO,
Siddhartha Agrawal496f9282012-08-15 17:41:34 -07009663 .mdp_max_clk = 200000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009664#ifdef CONFIG_MSM_BUS_SCALING
9665 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
9666#endif
9667 .mdp_rev = MDP_REV_41,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009668#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Ravishangar Kalyanama3b168b2012-03-26 11:13:11 -07009669 .mem_hid = BIT(ION_CP_WB_HEAP_ID),
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009670#else
9671 .mem_hid = MEMTYPE_EBI1,
9672#endif
Olav Hauganef95ae32012-05-15 09:50:30 -07009673 .mdp_iommu_split_domain = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009674};
9675
Huaibin Yanga5419422011-12-08 23:52:10 -08009676static void __init reserve_mdp_memory(void)
9677{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009678 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
9679 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
9680#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
9681 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9682 mdp_pdata.ov0_wb_size;
9683 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9684 mdp_pdata.ov1_wb_size;
9685#endif
Huaibin Yanga5419422011-12-08 23:52:10 -08009686}
9687
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009688#ifdef CONFIG_FB_MSM_TVOUT
9689
9690#ifdef CONFIG_MSM_BUS_SCALING
9691static struct msm_bus_vectors atv_bus_init_vectors[] = {
9692 /* For now, 0th array entry is reserved.
9693 * Please leave 0 as is and don't use it
9694 */
9695 {
9696 .src = MSM_BUS_MASTER_MDP_PORT0,
9697 .dst = MSM_BUS_SLAVE_SMI,
9698 .ab = 0,
9699 .ib = 0,
9700 },
9701 /* Master and slaves can be from different fabrics */
9702 {
9703 .src = MSM_BUS_MASTER_MDP_PORT0,
9704 .dst = MSM_BUS_SLAVE_EBI_CH0,
9705 .ab = 0,
9706 .ib = 0,
9707 },
9708};
9709static struct msm_bus_vectors atv_bus_def_vectors[] = {
9710 /* For now, 0th array entry is reserved.
9711 * Please leave 0 as is and don't use it
9712 */
9713 {
9714 .src = MSM_BUS_MASTER_MDP_PORT0,
9715 .dst = MSM_BUS_SLAVE_SMI,
9716 .ab = 236390400,
9717 .ib = 265939200,
9718 },
9719 /* Master and slaves can be from different fabrics */
9720 {
9721 .src = MSM_BUS_MASTER_MDP_PORT0,
9722 .dst = MSM_BUS_SLAVE_EBI_CH0,
9723 .ab = 236390400,
9724 .ib = 265939200,
9725 },
9726};
9727static struct msm_bus_paths atv_bus_scale_usecases[] = {
9728 {
9729 ARRAY_SIZE(atv_bus_init_vectors),
9730 atv_bus_init_vectors,
9731 },
9732 {
9733 ARRAY_SIZE(atv_bus_def_vectors),
9734 atv_bus_def_vectors,
9735 },
9736};
9737static struct msm_bus_scale_pdata atv_bus_scale_pdata = {
9738 atv_bus_scale_usecases,
9739 ARRAY_SIZE(atv_bus_scale_usecases),
9740 .name = "atv",
9741};
9742#endif
9743
9744static struct tvenc_platform_data atv_pdata = {
9745 .poll = 0,
9746 .pm_vid_en = atv_dac_power,
9747#ifdef CONFIG_MSM_BUS_SCALING
9748 .bus_scale_table = &atv_bus_scale_pdata,
9749#endif
9750};
9751#endif
9752
9753static void __init msm_fb_add_devices(void)
9754{
9755#ifdef CONFIG_FB_MSM_LCDC_DSUB
Siddhartha Agrawal496f9282012-08-15 17:41:34 -07009756 mdp_pdata.mdp_max_clk = 200000000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009757#endif
Syed Rameez Mustafae4a6f8e2012-07-09 15:25:13 -07009758 msm_fb_register_device("mdp", &mdp_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009759
9760 msm_fb_register_device("lcdc", &lcdc_pdata);
9761 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
9762#ifdef CONFIG_MSM_BUS_SCALING
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009763 if (hdmi_is_primary)
9764 msm_fb_register_device("dtv", &dtv_hdmi_prim_pdata);
9765 else
9766 msm_fb_register_device("dtv", &dtv_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009767#endif
9768#ifdef CONFIG_FB_MSM_TVOUT
9769 msm_fb_register_device("tvenc", &atv_pdata);
9770 msm_fb_register_device("tvout_device", NULL);
9771#endif
9772}
9773
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07009774/**
9775 * Set MDP clocks to high frequency to avoid underflow when
9776 * using high resolution 1200x1920 WUXGA/HDMI as primary panels
9777 */
9778static void set_mdp_clocks_for_wuxga(void)
9779{
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07009780 mdp_sd_smi_vectors[0].ab = 2000000000;
9781 mdp_sd_smi_vectors[0].ib = 2000000000;
9782 mdp_sd_smi_vectors[1].ab = 2000000000;
9783 mdp_sd_smi_vectors[1].ib = 2000000000;
9784
9785 mdp_sd_ebi_vectors[0].ab = 2000000000;
9786 mdp_sd_ebi_vectors[0].ib = 2000000000;
9787 mdp_sd_ebi_vectors[1].ab = 2000000000;
9788 mdp_sd_ebi_vectors[1].ib = 2000000000;
9789
9790 mdp_vga_vectors[0].ab = 2000000000;
9791 mdp_vga_vectors[0].ib = 2000000000;
9792 mdp_vga_vectors[1].ab = 2000000000;
9793 mdp_vga_vectors[1].ib = 2000000000;
9794
9795 mdp_720p_vectors[0].ab = 2000000000;
9796 mdp_720p_vectors[0].ib = 2000000000;
9797 mdp_720p_vectors[1].ab = 2000000000;
9798 mdp_720p_vectors[1].ib = 2000000000;
9799
9800 mdp_1080p_vectors[0].ab = 2000000000;
9801 mdp_1080p_vectors[0].ib = 2000000000;
9802 mdp_1080p_vectors[1].ab = 2000000000;
9803 mdp_1080p_vectors[1].ib = 2000000000;
9804
Siddhartha Agrawal496f9282012-08-15 17:41:34 -07009805 mdp_pdata.mdp_max_clk = 200000000;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07009806}
9807
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009808#if (defined(CONFIG_MARIMBA_CORE)) && \
9809 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
9810
9811static const struct {
9812 char *name;
9813 int vmin;
9814 int vmax;
9815} bt_regs_info[] = {
9816 { "8058_s3", 1800000, 1800000 },
9817 { "8058_s2", 1300000, 1300000 },
9818 { "8058_l8", 2900000, 3050000 },
9819};
9820
9821static struct {
9822 bool enabled;
9823} bt_regs_status[] = {
9824 { false },
9825 { false },
9826 { false },
9827};
9828static struct regulator *bt_regs[ARRAY_SIZE(bt_regs_info)];
9829
9830static int bahama_bt(int on)
9831{
9832 int rc;
9833 int i;
9834 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
9835
9836 struct bahama_variant_register {
9837 const size_t size;
9838 const struct bahama_config_register *set;
9839 };
9840
9841 const struct bahama_config_register *p;
9842
9843 u8 version;
9844
9845 const struct bahama_config_register v10_bt_on[] = {
9846 { 0xE9, 0x00, 0xFF },
9847 { 0xF4, 0x80, 0xFF },
9848 { 0xE4, 0x00, 0xFF },
9849 { 0xE5, 0x00, 0x0F },
9850#ifdef CONFIG_WLAN
9851 { 0xE6, 0x38, 0x7F },
9852 { 0xE7, 0x06, 0xFF },
9853#endif
9854 { 0xE9, 0x21, 0xFF },
9855 { 0x01, 0x0C, 0x1F },
9856 { 0x01, 0x08, 0x1F },
9857 };
9858
9859 const struct bahama_config_register v20_bt_on_fm_off[] = {
9860 { 0x11, 0x0C, 0xFF },
9861 { 0x13, 0x01, 0xFF },
9862 { 0xF4, 0x80, 0xFF },
9863 { 0xF0, 0x00, 0xFF },
9864 { 0xE9, 0x00, 0xFF },
9865#ifdef CONFIG_WLAN
9866 { 0x81, 0x00, 0x7F },
9867 { 0x82, 0x00, 0xFF },
9868 { 0xE6, 0x38, 0x7F },
9869 { 0xE7, 0x06, 0xFF },
9870#endif
9871 { 0xE9, 0x21, 0xFF },
9872 };
9873
9874 const struct bahama_config_register v20_bt_on_fm_on[] = {
9875 { 0x11, 0x0C, 0xFF },
9876 { 0x13, 0x01, 0xFF },
9877 { 0xF4, 0x86, 0xFF },
9878 { 0xF0, 0x06, 0xFF },
9879 { 0xE9, 0x00, 0xFF },
9880#ifdef CONFIG_WLAN
9881 { 0x81, 0x00, 0x7F },
9882 { 0x82, 0x00, 0xFF },
9883 { 0xE6, 0x38, 0x7F },
9884 { 0xE7, 0x06, 0xFF },
9885#endif
9886 { 0xE9, 0x21, 0xFF },
9887 };
9888
9889 const struct bahama_config_register v10_bt_off[] = {
9890 { 0xE9, 0x00, 0xFF },
9891 };
9892
9893 const struct bahama_config_register v20_bt_off_fm_off[] = {
9894 { 0xF4, 0x84, 0xFF },
9895 { 0xF0, 0x04, 0xFF },
9896 { 0xE9, 0x00, 0xFF }
9897 };
9898
9899 const struct bahama_config_register v20_bt_off_fm_on[] = {
9900 { 0xF4, 0x86, 0xFF },
9901 { 0xF0, 0x06, 0xFF },
9902 { 0xE9, 0x00, 0xFF }
9903 };
9904 const struct bahama_variant_register bt_bahama[2][3] = {
9905 {
9906 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
9907 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
9908 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
9909 },
9910 {
9911 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
9912 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
9913 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
9914 }
9915 };
9916
9917 u8 offset = 0; /* index into bahama configs */
9918
9919 on = on ? 1 : 0;
9920 version = read_bahama_ver();
9921
9922 if (version == VER_UNSUPPORTED) {
9923 dev_err(&msm_bt_power_device.dev,
9924 "%s: unsupported version\n",
9925 __func__);
9926 return -EIO;
9927 }
9928
9929 if (version == VER_2_0) {
9930 if (marimba_get_fm_status(&config))
9931 offset = 0x01;
9932 }
9933
9934 /* Voting off 1.3V S2 Regulator,BahamaV2 used in Normal mode */
9935 if (on && (version == VER_2_0)) {
9936 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9937 if ((!strcmp(bt_regs_info[i].name, "8058_s2"))
9938 && (bt_regs_status[i].enabled == true)) {
9939 if (regulator_disable(bt_regs[i])) {
9940 dev_err(&msm_bt_power_device.dev,
9941 "%s: regulator disable failed",
9942 __func__);
9943 }
9944 bt_regs_status[i].enabled = false;
9945 break;
9946 }
9947 }
9948 }
9949
9950 p = bt_bahama[on][version + offset].set;
9951
9952 dev_info(&msm_bt_power_device.dev,
9953 "%s: found version %d\n", __func__, version);
9954
9955 for (i = 0; i < bt_bahama[on][version + offset].size; i++) {
9956 u8 value = (p+i)->value;
9957 rc = marimba_write_bit_mask(&config,
9958 (p+i)->reg,
9959 &value,
9960 sizeof((p+i)->value),
9961 (p+i)->mask);
9962 if (rc < 0) {
9963 dev_err(&msm_bt_power_device.dev,
9964 "%s: reg %d write failed: %d\n",
9965 __func__, (p+i)->reg, rc);
9966 return rc;
9967 }
9968 dev_dbg(&msm_bt_power_device.dev,
9969 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
9970 __func__, (p+i)->reg,
9971 value, (p+i)->mask);
9972 }
9973 /* Update BT Status */
9974 if (on)
9975 marimba_set_bt_status(&config, true);
9976 else
9977 marimba_set_bt_status(&config, false);
9978
9979 return 0;
9980}
9981
9982static int bluetooth_use_regulators(int on)
9983{
9984 int i, recover = -1, rc = 0;
9985
9986 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9987 bt_regs[i] = on ? regulator_get(&msm_bt_power_device.dev,
9988 bt_regs_info[i].name) :
9989 (regulator_put(bt_regs[i]), NULL);
9990 if (IS_ERR(bt_regs[i])) {
9991 rc = PTR_ERR(bt_regs[i]);
9992 dev_err(&msm_bt_power_device.dev,
9993 "regulator %s get failed (%d)\n",
9994 bt_regs_info[i].name, rc);
9995 recover = i - 1;
9996 bt_regs[i] = NULL;
9997 break;
9998 }
9999
10000 if (!on)
10001 continue;
10002
10003 rc = regulator_set_voltage(bt_regs[i],
10004 bt_regs_info[i].vmin,
10005 bt_regs_info[i].vmax);
10006 if (rc < 0) {
10007 dev_err(&msm_bt_power_device.dev,
10008 "regulator %s voltage set (%d)\n",
10009 bt_regs_info[i].name, rc);
10010 recover = i;
10011 break;
10012 }
10013 }
10014
10015 if (on && (recover > -1))
10016 for (i = recover; i >= 0; i--) {
10017 regulator_put(bt_regs[i]);
10018 bt_regs[i] = NULL;
10019 }
10020
10021 return rc;
10022}
10023
10024static int bluetooth_switch_regulators(int on)
10025{
10026 int i, rc = 0;
10027
10028 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
10029 if (on && (bt_regs_status[i].enabled == false)) {
10030 rc = regulator_enable(bt_regs[i]);
10031 if (rc < 0) {
10032 dev_err(&msm_bt_power_device.dev,
10033 "regulator %s %s failed (%d)\n",
10034 bt_regs_info[i].name,
10035 "enable", rc);
10036 if (i > 0) {
10037 while (--i) {
10038 regulator_disable(bt_regs[i]);
10039 bt_regs_status[i].enabled
10040 = false;
10041 }
10042 break;
10043 }
10044 }
10045 bt_regs_status[i].enabled = true;
10046 } else if (!on && (bt_regs_status[i].enabled == true)) {
10047 rc = regulator_disable(bt_regs[i]);
10048 if (rc < 0) {
10049 dev_err(&msm_bt_power_device.dev,
10050 "regulator %s %s failed (%d)\n",
10051 bt_regs_info[i].name,
10052 "disable", rc);
10053 break;
10054 }
10055 bt_regs_status[i].enabled = false;
10056 }
10057 }
10058 return rc;
10059}
10060
10061static struct msm_xo_voter *bt_clock;
10062
10063static int bluetooth_power(int on)
10064{
10065 int rc = 0;
10066 int id;
10067
10068 /* In case probe function fails, cur_connv_type would be -1 */
10069 id = adie_get_detected_connectivity_type();
10070 if (id != BAHAMA_ID) {
10071 pr_err("%s: unexpected adie connectivity type: %d\n",
10072 __func__, id);
10073 return -ENODEV;
10074 }
10075
10076 if (on) {
10077
10078 rc = bluetooth_use_regulators(1);
10079 if (rc < 0)
10080 goto out;
10081
10082 rc = bluetooth_switch_regulators(1);
10083
10084 if (rc < 0)
10085 goto fail_put;
10086
10087 bt_clock = msm_xo_get(MSM_XO_TCXO_D0, "bt_power");
10088
10089 if (IS_ERR(bt_clock)) {
10090 pr_err("Couldn't get TCXO_D0 voter\n");
10091 goto fail_switch;
10092 }
10093
10094 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_ON);
10095
10096 if (rc < 0) {
10097 pr_err("Failed to vote for TCXO_DO ON\n");
10098 goto fail_vote;
10099 }
10100
10101 rc = bahama_bt(1);
10102
10103 if (rc < 0)
10104 goto fail_clock;
10105
10106 msleep(10);
10107
10108 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_PIN_CTRL);
10109
10110 if (rc < 0) {
10111 pr_err("Failed to vote for TCXO_DO pin control\n");
10112 goto fail_vote;
10113 }
10114 } else {
10115 /* check for initial RFKILL block (power off) */
10116 /* some RFKILL versions/configurations rfkill_register */
10117 /* calls here for an initial set_block */
10118 /* avoid calling i2c and regulator before unblock (on) */
10119 if (platform_get_drvdata(&msm_bt_power_device) == NULL) {
10120 dev_info(&msm_bt_power_device.dev,
10121 "%s: initialized OFF/blocked\n", __func__);
10122 goto out;
10123 }
10124
10125 bahama_bt(0);
10126
10127fail_clock:
10128 msm_xo_mode_vote(bt_clock, MSM_XO_MODE_OFF);
10129fail_vote:
10130 msm_xo_put(bt_clock);
10131fail_switch:
10132 bluetooth_switch_regulators(0);
10133fail_put:
10134 bluetooth_use_regulators(0);
10135 }
10136
10137out:
10138 if (rc < 0)
10139 on = 0;
10140 dev_info(&msm_bt_power_device.dev,
10141 "Bluetooth power switch: state %d result %d\n", on, rc);
10142
10143 return rc;
10144}
10145
10146#endif /*CONFIG_MARIMBA_CORE, CONFIG_MSM_BT_POWER, CONFIG_MSM_BT_POWER_MODULE*/
10147
10148static void __init msm8x60_cfg_smsc911x(void)
10149{
10150 smsc911x_resources[1].start =
10151 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10152 smsc911x_resources[1].end =
10153 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10154}
10155
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010156void msm_fusion_setup_pinctrl(void)
10157{
10158 struct msm_xo_voter *a1;
10159
10160 if (socinfo_get_platform_subtype() == 0x3) {
10161 /*
10162 * Vote for the A1 clock to be in pin control mode before
10163 * the external images are loaded.
10164 */
10165 a1 = msm_xo_get(MSM_XO_TCXO_A1, "mdm");
10166 BUG_ON(!a1);
10167 msm_xo_mode_vote(a1, MSM_XO_MODE_PIN_CTRL);
10168 }
10169}
10170
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010171struct msm_board_data {
10172 struct msm_gpiomux_configs *gpiomux_cfgs;
10173};
10174
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010175static struct msm_board_data msm8x60_surf_board_data __initdata = {
10176 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10177};
10178
10179static struct msm_board_data msm8x60_ffa_board_data __initdata = {
10180 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10181};
10182
10183static struct msm_board_data msm8x60_fluid_board_data __initdata = {
10184 .gpiomux_cfgs = msm8x60_fluid_gpiomux_cfgs,
10185};
10186
10187static struct msm_board_data msm8x60_charm_surf_board_data __initdata = {
10188 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10189};
10190
10191static struct msm_board_data msm8x60_charm_ffa_board_data __initdata = {
10192 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10193};
10194
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010195static struct msm_board_data msm8x60_dragon_board_data __initdata = {
10196 .gpiomux_cfgs = msm8x60_dragon_gpiomux_cfgs,
10197};
10198
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010199static void __init msm8x60_init(struct msm_board_data *board_data)
10200{
10201 uint32_t soc_platform_version;
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010202#ifdef CONFIG_USB_EHCI_MSM_72K
10203 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
10204 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
10205 .level = PM8901_MPP_DIG_LEVEL_L5,
10206 .control = PM8XXX_MPP_DOUT_CTRL_HIGH,
10207 };
10208#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010209 pmic_reset_irq = PM8058_IRQ_BASE + PM8058_RESOUT_IRQ;
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070010210
Rohit Vaswanib1cc4932012-07-23 21:30:11 -070010211 platform_device_register(&msm_gpio_device);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010212 /*
10213 * Initialize RPM first as other drivers and devices may need
10214 * it for their initialization.
10215 */
Praveen Chidambaram78499012011-11-01 17:15:17 -060010216 BUG_ON(msm_rpm_init(&msm8660_rpm_data));
10217 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010218 if (msm_xo_init())
10219 pr_err("Failed to initialize XO votes\n");
10220
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010221 msm8x60_check_2d_hardware();
10222
10223 /* Change SPM handling of core 1 if PMM 8160 is present. */
10224 soc_platform_version = socinfo_get_platform_version();
10225 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1 &&
10226 SOCINFO_VERSION_MINOR(soc_platform_version) >= 2) {
10227 struct msm_spm_platform_data *spm_data;
10228
10229 spm_data = &msm_spm_data_v1[1];
10230 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10231 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10232
10233 spm_data = &msm_spm_data[1];
10234 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10235 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10236 }
10237
10238 /*
10239 * Initialize SPM before acpuclock as the latter calls into SPM
10240 * driver to set ACPU voltages.
10241 */
10242 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10243 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
10244 else
10245 msm_spm_init(msm_spm_data_v1, ARRAY_SIZE(msm_spm_data_v1));
10246
10247 /*
10248 * Set regulators 8901_l4 and 8901_l6 to be always on in HPM for SURF
10249 * devices so that the RPM doesn't drop into a low power mode that an
10250 * un-reworked SURF cannot resume from.
10251 */
10252 if (machine_is_msm8x60_surf()) {
David Collins6f032ba2011-08-31 14:08:15 -070010253 int i;
10254
10255 for (i = 0; i < ARRAY_SIZE(rpm_regulator_init_data); i++)
10256 if (rpm_regulator_init_data[i].id
10257 == RPM_VREG_ID_PM8901_L4
10258 || rpm_regulator_init_data[i].id
10259 == RPM_VREG_ID_PM8901_L6)
10260 rpm_regulator_init_data[i]
10261 .init_data.constraints.always_on = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010262 }
10263
10264 /*
10265 * Disable regulator info printing so that regulator registration
10266 * messages do not enter the kmsg log.
10267 */
10268 regulator_suppress_info_printing();
10269
10270 /* Initialize regulators needed for clock_init. */
10271 platform_add_devices(early_regulators, ARRAY_SIZE(early_regulators));
10272
Stephen Boydbb600ae2011-08-02 20:11:40 -070010273 msm_clock_init(&msm8x60_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010274
10275 /* Buses need to be initialized before early-device registration
10276 * to get the platform data for fabrics.
10277 */
10278 msm8x60_init_buses();
10279 platform_add_devices(early_devices, ARRAY_SIZE(early_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010280
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010281 /*
10282 * Enable EBI2 only for boards which make use of it. Leave
10283 * it disabled for all others for additional power savings.
10284 */
10285 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010286 machine_is_msm8x60_fluid() ||
10287 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010288 msm8x60_init_ebi2();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010289 msm8x60_init_gpiomux(board_data->gpiomux_cfgs);
10290 msm8x60_init_uart12dm();
Kevin Chan3be11612012-03-22 20:05:40 -070010291#ifdef CONFIG_MSM_CAMERA_V4L2
10292 msm8x60_init_cam();
10293#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010294 msm8x60_init_mmc();
10295
Kevin Chan3be11612012-03-22 20:05:40 -070010296
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010297#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
10298 msm8x60_init_pm8058_othc();
10299#endif
10300
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010301 if (machine_is_msm8x60_fluid())
10302 pm8058_platform_data.keypad_pdata = &fluid_keypad_data;
10303 else if (machine_is_msm8x60_dragon())
10304 pm8058_platform_data.keypad_pdata = &dragon_keypad_data;
10305 else
10306 pm8058_platform_data.keypad_pdata = &ffa_keypad_data;
Steve Mucklef132c6c2012-06-06 18:30:57 -070010307#if !defined(CONFIG_MSM_CAMERA_V4L2) && defined(CONFIG_WEBCAM_OV9726)
Jilai Wang53d27a82011-07-13 14:32:58 -040010308 /* Specify reset pin for OV9726 */
10309 if (machine_is_msm8x60_dragon()) {
10310 msm_camera_sensor_ov9726_data.sensor_reset = 62;
10311 ov9726_sensor_8660_info.mount_angle = 270;
10312 }
Kevin Chan3be11612012-03-22 20:05:40 -070010313#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010314#ifdef CONFIG_BATTERY_MSM8X60
10315 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10316 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
10317 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_fluid())
10318 platform_device_register(&msm_charger_device);
10319#endif
10320
10321 if (machine_is_msm8x60_dragon())
10322 pm8058_platform_data.charger_pdata = &pmic8058_charger_dragon;
10323 if (!machine_is_msm8x60_fluid())
10324 pm8058_platform_data.charger_pdata = &pmic8058_charger_ffa_surf;
10325
10326 /* configure pmic leds */
10327 if (machine_is_msm8x60_fluid())
10328 pm8058_platform_data.leds_pdata = &pm8058_fluid_flash_leds_data;
10329 else if (machine_is_msm8x60_dragon())
10330 pm8058_platform_data.leds_pdata = &pm8058_dragon_leds_data;
10331 else
10332 pm8058_platform_data.leds_pdata = &pm8058_flash_leds_data;
10333
10334 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
10335 machine_is_msm8x60_dragon()) {
10336 pm8058_platform_data.vibrator_pdata = &pm8058_vib_pdata;
10337 }
10338
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010339 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10340 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010341 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010342 msm8x60_cfg_smsc911x();
10343 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
Matt Wagantall1f65d9d2012-04-25 14:24:20 -070010344 platform_add_devices(msm8660_footswitch,
10345 msm8660_num_footswitch);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010346 platform_add_devices(surf_devices,
10347 ARRAY_SIZE(surf_devices));
10348
10349#ifdef CONFIG_MSM_DSPS
10350 if (machine_is_msm8x60_fluid()) {
10351 platform_device_unregister(&msm_gsbi12_qup_i2c_device);
10352 msm8x60_init_dsps();
10353 }
10354#endif
10355
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010356 pm8901_vreg_mpp0_init();
10357
10358 platform_device_register(&msm8x60_8901_mpp_vreg);
10359
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010360#ifdef CONFIG_USB_EHCI_MSM_72K
10361 /*
10362 * Drive MPP2 pin HIGH for PHY to generate ID interrupts on 8660
10363 * fluid
10364 */
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010365 if (machine_is_msm8x60_fluid())
10366 pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1), &hsusb_phy_mpp);
10367 msm_add_host(0, &msm_usb_host_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010368#endif
Lei Zhou338cab82011-08-19 13:38:17 -040010369
10370#ifdef CONFIG_SND_SOC_MSM8660_APQ
10371 if (machine_is_msm8x60_dragon())
10372 platform_add_devices(dragon_alsa_devices,
10373 ARRAY_SIZE(dragon_alsa_devices));
10374 else
10375#endif
10376 platform_add_devices(asoc_devices,
10377 ARRAY_SIZE(asoc_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010378 }
10379#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010380 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10381 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010382 msm8x60_cfg_isp1763();
10383#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010384
10385 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10386 platform_add_devices(charm_devices, ARRAY_SIZE(charm_devices));
10387
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010388
10389#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
10390 if (machine_is_msm8x60_fluid())
10391 platform_device_register(&msm_gsbi10_qup_spi_device);
10392 else
10393 platform_device_register(&msm_gsbi1_qup_spi_device);
10394#endif
10395
Steve Mucklef132c6c2012-06-06 18:30:57 -070010396#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
10397 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010398 if (machine_is_msm8x60_fluid())
10399 cyttsp_set_params();
10400#endif
Syed Rameez Mustafae4a6f8e2012-07-09 15:25:13 -070010401 msm_fb_add_devices();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010402 fixup_i2c_configs();
10403 register_i2c_devices();
10404
Terence Hampson1c73fef2011-07-19 17:10:49 -040010405 if (machine_is_msm8x60_dragon())
10406 smsc911x_config.reset_gpio
10407 = GPIO_ETHERNET_RESET_N_DRAGON;
10408
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010409 platform_device_register(&smsc911x_device);
10410
10411#if (defined(CONFIG_SPI_QUP)) && \
10412 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010413 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA) || \
10414 defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010415
10416 if (machine_is_msm8x60_fluid()) {
10417#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
10418 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
10419 spi_register_board_info(lcdc_samsung_spi_board_info,
10420 ARRAY_SIZE(lcdc_samsung_spi_board_info));
10421 } else
10422#endif
10423 {
10424#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
10425 spi_register_board_info(lcdc_auo_spi_board_info,
10426 ARRAY_SIZE(lcdc_auo_spi_board_info));
10427#endif
10428 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010429#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
10430 } else if (machine_is_msm8x60_dragon()) {
10431 spi_register_board_info(lcdc_nt35582_spi_board_info,
10432 ARRAY_SIZE(lcdc_nt35582_spi_board_info));
10433#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010434 }
10435#endif
10436
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060010437 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010438
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010439 pm8058_gpios_init();
10440
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010441#ifdef CONFIG_SENSORS_MSM_ADC
10442 if (machine_is_msm8x60_fluid()) {
10443 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
10444 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
10445 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3)
10446 msm_adc_pdata.gpio_config = APROC_CONFIG;
10447 else
10448 msm_adc_pdata.gpio_config = MPROC_CONFIG;
10449 }
10450 msm_adc_pdata.target_hw = MSM_8x60;
10451#endif
10452#ifdef CONFIG_MSM8X60_AUDIO
10453 msm_snddev_init();
10454#endif
10455#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
10456 if (machine_is_msm8x60_fluid())
10457 platform_device_register(&fluid_leds_gpio);
10458 else
10459 platform_device_register(&gpio_leds);
10460#endif
10461
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010462 msm8x60_multi_sdio_init();
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010463
10464 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10465 msm_fusion_setup_pinctrl();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010466}
10467
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010468static void __init msm8x60_surf_init(void)
10469{
10470 msm8x60_init(&msm8x60_surf_board_data);
10471}
10472
10473static void __init msm8x60_ffa_init(void)
10474{
10475 msm8x60_init(&msm8x60_ffa_board_data);
10476}
10477
10478static void __init msm8x60_fluid_init(void)
10479{
10480 msm8x60_init(&msm8x60_fluid_board_data);
10481}
10482
10483static void __init msm8x60_charm_surf_init(void)
10484{
10485 msm8x60_init(&msm8x60_charm_surf_board_data);
10486}
10487
10488static void __init msm8x60_charm_ffa_init(void)
10489{
10490 msm8x60_init(&msm8x60_charm_ffa_board_data);
10491}
10492
10493static void __init msm8x60_charm_init_early(void)
10494{
10495 msm8x60_allocate_memory_regions();
Steve Mucklea55df6e2010-01-07 12:43:24 -080010496}
10497
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010498static void __init msm8x60_dragon_init(void)
10499{
10500 msm8x60_init(&msm8x60_dragon_board_data);
10501}
David Brown56e2d8a2011-08-04 02:01:02 -070010502
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010503MACHINE_START(MSM8X60_SURF, "QCT MSM8X60 SURF")
10504 .map_io = msm8x60_map_io,
10505 .reserve = msm8x60_reserve,
10506 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010507 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010508 .init_machine = msm8x60_surf_init,
10509 .timer = &msm_timer,
10510 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010511 .restart = msm_restart,
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -080010512 .smp = &scorpion_smp_ops,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010513MACHINE_END
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010514
10515MACHINE_START(MSM8X60_FFA, "QCT MSM8X60 FFA")
10516 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010517 .reserve = msm8x60_reserve,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010518 .init_irq = msm8x60_init_irq,
Marc Zyngier041f7772011-09-06 10:23:45 +010010519 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010520 .init_machine = msm8x60_ffa_init,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010521 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010522 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010523 .restart = msm_restart,
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -080010524 .smp = &scorpion_smp_ops,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010525MACHINE_END
David Brown56e2d8a2011-08-04 02:01:02 -070010526
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010527MACHINE_START(MSM8X60_FLUID, "QCT MSM8X60 FLUID")
David Brown56e2d8a2011-08-04 02:01:02 -070010528 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010529 .reserve = msm8x60_reserve,
David Brown56e2d8a2011-08-04 02:01:02 -070010530 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010531 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010532 .init_machine = msm8x60_fluid_init,
David Brown56e2d8a2011-08-04 02:01:02 -070010533 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010534 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010535 .restart = msm_restart,
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -080010536 .smp = &scorpion_smp_ops,
David Brown56e2d8a2011-08-04 02:01:02 -070010537MACHINE_END
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010538
10539MACHINE_START(MSM8X60_FUSION, "QCT MSM8X60 FUSION SURF")
10540 .map_io = msm8x60_map_io,
10541 .reserve = msm8x60_reserve,
10542 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010543 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010544 .init_machine = msm8x60_charm_surf_init,
10545 .timer = &msm_timer,
10546 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010547 .restart = msm_restart,
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -080010548 .smp = &scorpion_smp_ops,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010549MACHINE_END
10550
10551MACHINE_START(MSM8X60_FUSN_FFA, "QCT MSM8X60 FUSION FFA")
10552 .map_io = msm8x60_map_io,
10553 .reserve = msm8x60_reserve,
10554 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010555 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010556 .init_machine = msm8x60_charm_ffa_init,
10557 .timer = &msm_timer,
10558 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010559 .restart = msm_restart,
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -080010560 .smp = &scorpion_smp_ops,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010561MACHINE_END
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010562
10563MACHINE_START(MSM8X60_DRAGON, "QCT MSM8X60 DRAGON")
10564 .map_io = msm8x60_map_io,
10565 .reserve = msm8x60_reserve,
10566 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010567 .handle_irq = gic_handle_irq,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010568 .init_machine = msm8x60_dragon_init,
10569 .timer = &msm_timer,
10570 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010571 .restart = msm_restart,
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -080010572 .smp = &scorpion_smp_ops,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010573MACHINE_END