blob: e678dfb33177ccd395f4e4177ffbb1f93cc1a095 [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,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005302};
5303
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005304#ifdef CONFIG_ION_MSM
Olav Haugan0703dbf2011-12-19 17:53:38 -08005305#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5306static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
5307 .permission_type = IPT_TYPE_MM_CARVEOUT,
Olav Haugan8726caf2012-05-10 15:11:35 -07005308 .align = SZ_64K,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005309 .request_region = request_smi_region,
5310 .release_region = release_smi_region,
5311 .setup_region = setup_smi_region,
Chintan Pandya490c9712012-08-07 17:19:59 +05305312 .secure_base = SECURE_BASE,
5313 .secure_size = SECURE_SIZE,
Olav Haugan8726caf2012-05-10 15:11:35 -07005314 .iommu_map_all = 1,
5315 .iommu_2x_map_domain = VIDEO_DOMAIN,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005316};
5317
5318static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
5319 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
Olav Haugan42ebe712012-01-10 16:30:58 -08005320 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005321 .request_region = request_smi_region,
5322 .release_region = release_smi_region,
5323 .setup_region = setup_smi_region,
5324};
5325
5326static struct ion_cp_heap_pdata cp_wb_ion_pdata = {
5327 .permission_type = IPT_TYPE_MDP_WRITEBACK,
Olav Haugan42ebe712012-01-10 16:30:58 -08005328 .align = PAGE_SIZE,
5329};
5330
Chintan Pandya7c2b9cb2012-06-25 14:35:02 +05305331static struct ion_co_heap_pdata mm_fw_co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005332 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005333};
5334
5335static struct ion_co_heap_pdata co_ion_pdata = {
Olav Haugan42ebe712012-01-10 16:30:58 -08005336 .adjacent_mem_id = INVALID_HEAP_ID,
5337 .align = PAGE_SIZE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005338};
5339#endif
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005340
5341/**
5342 * These heaps are listed in the order they will be allocated. Due to
5343 * video hardware restrictions and content protection the FW heap has to
5344 * be allocated adjacent (below) the MM heap and the MFC heap has to be
5345 * allocated after the MM heap to ensure MFC heap is not more than 256MB
5346 * away from the base address of the FW heap.
5347 * However, the order of FW heap and MM heap doesn't matter since these
5348 * two heaps are taken care of by separate code to ensure they are adjacent
5349 * to each other.
5350 * Don't swap the order unless you know what you are doing!
5351 */
Benjamin Gaignard63d81032012-06-25 15:27:30 -07005352struct ion_platform_heap msm8x60_heaps [] = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005353 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005354 .id = ION_SYSTEM_HEAP_ID,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005355 .type = ION_HEAP_TYPE_SYSTEM,
5356 .name = ION_VMALLOC_HEAP_NAME,
5357 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005358#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
5359 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005360 .id = ION_CP_MM_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005361 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005362 .name = ION_MM_HEAP_NAME,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305363 .base = MSM_ION_MM_BASE,
Olav Hauganb5be7992011-11-18 14:29:02 -08005364 .size = MSM_ION_MM_SIZE,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005365 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005366 .extra_data = (void *) &cp_mm_ion_pdata,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005367 },
Olav Hauganb5be7992011-11-18 14:29:02 -08005368 {
Olav Haugan42ebe712012-01-10 16:30:58 -08005369 .id = ION_MM_FIRMWARE_HEAP_ID,
5370 .type = ION_HEAP_TYPE_CARVEOUT,
5371 .name = ION_MM_FIRMWARE_HEAP_NAME,
Chintan Pandya7c2b9cb2012-06-25 14:35:02 +05305372 .base = MSM_MM_FW_BASE,
5373 .size = MSM_MM_FW_SIZE,
Olav Haugan42ebe712012-01-10 16:30:58 -08005374 .memory_type = ION_SMI_TYPE,
Chintan Pandya7c2b9cb2012-06-25 14:35:02 +05305375 .extra_data = (void *) &mm_fw_co_ion_pdata,
Olav Haugan42ebe712012-01-10 16:30:58 -08005376 },
5377 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005378 .id = ION_CP_MFC_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005379 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005380 .name = ION_MFC_HEAP_NAME,
Chintan Pandyafda5bc42012-05-08 14:15:33 +05305381 .base = MSM_ION_MFC_BASE,
Olav Hauganb5be7992011-11-18 14:29:02 -08005382 .size = MSM_ION_MFC_SIZE,
5383 .memory_type = ION_SMI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005384 .extra_data = (void *) &cp_mfc_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005385 },
5386 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -08005387 .id = ION_SF_HEAP_ID,
5388 .type = ION_HEAP_TYPE_CARVEOUT,
5389 .name = ION_SF_HEAP_NAME,
5390 .size = MSM_ION_SF_SIZE,
5391 .memory_type = ION_EBI_TYPE,
5392 .extra_data = (void *)&co_ion_pdata,
5393 },
5394 {
5395 .id = ION_CAMERA_HEAP_ID,
5396 .type = ION_HEAP_TYPE_CARVEOUT,
5397 .name = ION_CAMERA_HEAP_NAME,
5398 .size = MSM_ION_CAMERA_SIZE,
5399 .memory_type = ION_EBI_TYPE,
5400 .extra_data = &co_ion_pdata,
5401 },
5402 {
Olav Hauganb5be7992011-11-18 14:29:02 -08005403 .id = ION_CP_WB_HEAP_ID,
Olav Haugan0a852512012-01-09 10:20:55 -08005404 .type = ION_HEAP_TYPE_CP,
Olav Hauganb5be7992011-11-18 14:29:02 -08005405 .name = ION_WB_HEAP_NAME,
5406 .size = MSM_ION_WB_SIZE,
5407 .memory_type = ION_EBI_TYPE,
Olav Haugan0703dbf2011-12-19 17:53:38 -08005408 .extra_data = (void *) &cp_wb_ion_pdata,
Olav Hauganb5be7992011-11-18 14:29:02 -08005409 },
Olav Haugan3a55e322012-01-23 14:24:01 -08005410 {
Olav Haugan6ab47252012-02-15 14:46:49 -08005411 .id = ION_QSECOM_HEAP_ID,
5412 .type = ION_HEAP_TYPE_CARVEOUT,
5413 .name = ION_QSECOM_HEAP_NAME,
5414 .size = MSM_ION_QSECOM_SIZE,
5415 .memory_type = ION_EBI_TYPE,
5416 .extra_data = (void *) &co_ion_pdata,
5417 },
5418 {
Olav Haugan3a55e322012-01-23 14:24:01 -08005419 .id = ION_AUDIO_HEAP_ID,
5420 .type = ION_HEAP_TYPE_CARVEOUT,
5421 .name = ION_AUDIO_HEAP_NAME,
5422 .size = MSM_ION_AUDIO_SIZE,
5423 .memory_type = ION_EBI_TYPE,
5424 .extra_data = (void *)&co_ion_pdata,
5425 },
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005426#endif
Benjamin Gaignard63d81032012-06-25 15:27:30 -07005427};
5428
5429static struct ion_platform_data ion_pdata = {
5430 .nr = MSM_ION_HEAP_NUM,
5431 .heaps = msm8x60_heaps,
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005432};
5433
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -08005434static struct platform_device ion_dev = {
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005435 .name = "ion-msm",
5436 .id = 1,
5437 .dev = { .platform_data = &ion_pdata },
5438};
5439#endif
5440
5441
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005442static struct memtype_reserve msm8x60_reserve_table[] __initdata = {
5443 /* Kernel SMI memory pool for video core, used for firmware */
5444 /* and encoder, decoder scratch buffers */
5445 /* Kernel SMI memory pool should always precede the user space */
5446 /* SMI memory pool, as the video core will use offset address */
5447 /* from the Firmware base */
5448 [MEMTYPE_SMI_KERNEL] = {
5449 .start = KERNEL_SMI_BASE,
5450 .limit = KERNEL_SMI_SIZE,
5451 .size = KERNEL_SMI_SIZE,
5452 .flags = MEMTYPE_FLAGS_FIXED,
5453 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005454 [MEMTYPE_SMI] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005455 },
5456 [MEMTYPE_EBI0] = {
5457 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5458 },
5459 [MEMTYPE_EBI1] = {
5460 .flags = MEMTYPE_FLAGS_1M_ALIGN,
5461 },
5462};
5463
Stephen Boyd668d7652012-04-25 11:31:01 -07005464static void __init reserve_ion_memory(void)
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005465{
5466#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005467 unsigned int i;
5468
5469 if (hdmi_is_primary) {
5470 msm_ion_sf_size = MSM_HDMI_PRIM_ION_SF_SIZE;
5471 for (i = 0; i < ion_pdata.nr; i++) {
5472 if (ion_pdata.heaps[i].id == ION_SF_HEAP_ID) {
5473 ion_pdata.heaps[i].size = msm_ion_sf_size;
5474 pr_debug("msm_ion_sf_size 0x%x\n",
5475 msm_ion_sf_size);
5476 break;
5477 }
5478 }
5479 }
5480
Olav Haugan8726caf2012-05-10 15:11:35 -07005481 /* Verify size of heap is a multiple of 64K */
5482 for (i = 0; i < ion_pdata.nr; i++) {
5483 struct ion_platform_heap *heap = &(ion_pdata.heaps[i]);
5484
Mitchel Humpherys362b52b2012-09-13 10:53:22 -07005485 if (heap->extra_data &&
5486 heap->type == (enum ion_heap_type) ION_HEAP_TYPE_CP) {
Olav Haugan8726caf2012-05-10 15:11:35 -07005487 int map_all = ((struct ion_cp_heap_pdata *)
5488 heap->extra_data)->iommu_map_all;
5489
5490 if (map_all && (heap->size & (SZ_64K-1))) {
5491 heap->size = ALIGN(heap->size, SZ_64K);
5492 pr_err("Heap %s size is not a multiple of 64K. Adjusting size to %x\n",
5493 heap->name, heap->size);
5494
5495 }
5496 }
5497 }
5498
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005499 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_ion_sf_size;
Olav Hauganb5be7992011-11-18 14:29:02 -08005500 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_CAMERA_SIZE;
5501 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_WB_SIZE;
Olav Haugan3a55e322012-01-23 14:24:01 -08005502 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE;
Olav Haugan8d8c2d12012-04-02 12:01:44 -07005503 msm8x60_reserve_table[MEMTYPE_EBI1].size += MSM_ION_QSECOM_SIZE;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005504#endif
5505}
5506
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005507static void __init size_pmem_devices(void)
5508{
5509#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005510#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005511 android_pmem_adsp_pdata.size = pmem_adsp_size;
5512 android_pmem_smipool_pdata.size = MSM_PMEM_SMIPOOL_SIZE;
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005513
5514 if (hdmi_is_primary)
5515 pmem_sf_size = MSM_HDMI_PRIM_PMEM_SF_SIZE;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005516 android_pmem_pdata.size = pmem_sf_size;
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005517 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305518#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5519#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005520}
5521
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305522#ifdef CONFIG_ANDROID_PMEM
5523#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005524static void __init reserve_memory_for(struct android_pmem_platform_data *p)
5525{
5526 msm8x60_reserve_table[p->memory_type].size += p->size;
5527}
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305528#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
5529#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005530
5531static void __init reserve_pmem_memory(void)
5532{
5533#ifdef CONFIG_ANDROID_PMEM
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005534#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005535 reserve_memory_for(&android_pmem_adsp_pdata);
5536 reserve_memory_for(&android_pmem_smipool_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005537 reserve_memory_for(&android_pmem_pdata);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005538 reserve_memory_for(&android_pmem_audio_pdata);
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305539#endif /*CONFIG_MSM_MULTIMEDIA_USE_ION*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005540 msm8x60_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
Chaithanya Krishna Bacharaju23685fb2012-03-19 11:43:53 +05305541#endif /*CONFIG_ANDROID_PMEM*/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005542}
5543
Huaibin Yanga5419422011-12-08 23:52:10 -08005544static void __init reserve_mdp_memory(void);
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005545
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305546static void __init reserve_rtb_memory(void)
5547{
5548#if defined(CONFIG_MSM_RTB)
5549 msm8x60_reserve_table[MEMTYPE_EBI1].size += msm_rtb_pdata.size;
5550#endif
5551}
5552
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005553static void __init msm8x60_calculate_reserve_sizes(void)
5554{
5555 size_pmem_devices();
5556 reserve_pmem_memory();
Laura Abbott63cfd7e2011-10-10 18:21:01 -07005557 reserve_ion_memory();
Huaibin Yanga5419422011-12-08 23:52:10 -08005558 reserve_mdp_memory();
Adinarayana Gupta Grandhi4ed4ad82012-04-03 17:11:56 +05305559 reserve_rtb_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005560}
5561
5562static int msm8x60_paddr_to_memtype(unsigned int paddr)
5563{
5564 if (paddr >= 0x40000000 && paddr < 0x60000000)
5565 return MEMTYPE_EBI1;
5566 if (paddr >= 0x38000000 && paddr < 0x40000000)
5567 return MEMTYPE_SMI;
5568 return MEMTYPE_NONE;
5569}
5570
5571static struct reserve_info msm8x60_reserve_info __initdata = {
5572 .memtype_reserve_table = msm8x60_reserve_table,
5573 .calculate_reserve_sizes = msm8x60_calculate_reserve_sizes,
5574 .paddr_to_memtype = msm8x60_paddr_to_memtype,
5575};
5576
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005577static char prim_panel_name[PANEL_NAME_MAX_LEN];
5578static char ext_panel_name[PANEL_NAME_MAX_LEN];
5579static int __init prim_display_setup(char *param)
5580{
5581 if (strnlen(param, PANEL_NAME_MAX_LEN))
5582 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
5583 return 0;
5584}
5585early_param("prim_display", prim_display_setup);
5586
5587static int __init ext_display_setup(char *param)
5588{
5589 if (strnlen(param, PANEL_NAME_MAX_LEN))
5590 strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
5591 return 0;
5592}
5593early_param("ext_display", ext_display_setup);
5594
Stephen Boyd9e775ad2011-08-12 00:14:28 +01005595static void __init msm8x60_reserve(void)
5596{
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08005597 msm8x60_set_display_params(prim_panel_name, ext_panel_name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005598 reserve_info = &msm8x60_reserve_info;
5599 msm_reserve();
5600}
5601
5602#define EXT_CHG_VALID_MPP 10
5603#define EXT_CHG_VALID_MPP_2 11
5604
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305605static struct pm8xxx_mpp_init_info isl_mpp[] = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305606 PM8058_MPP_INIT(EXT_CHG_VALID_MPP, D_INPUT,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305607 PM8058_MPP_DIG_LEVEL_S3, DIN_TO_INT),
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05305608 PM8058_MPP_INIT(EXT_CHG_VALID_MPP_2, D_BI_DIR,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305609 PM8058_MPP_DIG_LEVEL_S3, BI_PULLUP_10KOHM),
5610};
5611
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005612#ifdef CONFIG_ISL9519_CHARGER
5613static int isl_detection_setup(void)
5614{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305615 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005616
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305617 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5618 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5619 &isl_mpp[i].config);
5620 if (ret) {
5621 pr_err("%s: Config MPP %d of PM8058 failed\n",
5622 __func__, isl_mpp[i].mpp);
5623 return ret;
5624 }
5625 }
5626
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005627 return ret;
5628}
5629
5630static struct isl_platform_data isl_data __initdata = {
5631 .chgcurrent = 700,
5632 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5633 .chg_detection_config = isl_detection_setup,
5634 .max_system_voltage = 4200,
5635 .min_system_voltage = 3200,
5636 .term_current = 120,
5637 .input_current = 2048,
5638};
5639
5640static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
5641 {
5642 I2C_BOARD_INFO("isl9519q", 0x9),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305643 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005644 .platform_data = &isl_data,
5645 },
5646};
5647#endif
5648
5649#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
5650static int smb137b_detection_setup(void)
5651{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305652 int ret = 0, i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005653
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305654 for (i = 0; i < ARRAY_SIZE(isl_mpp); i++) {
5655 ret = pm8xxx_mpp_config(isl_mpp[i].mpp,
5656 &isl_mpp[i].config);
5657 if (ret) {
5658 pr_err("%s: Config MPP %d of PM8058 failed\n",
5659 __func__, isl_mpp[i].mpp);
5660 return ret;
5661 }
5662 }
5663
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005664 return ret;
5665}
5666
5667static struct smb137b_platform_data smb137b_data __initdata = {
5668 .chg_detection_config = smb137b_detection_setup,
5669 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5670 .batt_mah_rating = 950,
5671};
5672
5673static struct i2c_board_info smb137b_charger_i2c_info[] __initdata = {
5674 {
5675 I2C_BOARD_INFO("smb137b", 0x08),
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305676 .irq = PM8058_IRQ_BASE + PM8058_CBLPWR_IRQ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005677 .platform_data = &smb137b_data,
5678 },
5679};
5680#endif
5681
5682#ifdef CONFIG_PMIC8058
5683#define PMIC_GPIO_SDC3_DET 22
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305684#define PMIC_GPIO_TOUCH_DISC_INTR 5
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005685
5686static int pm8058_gpios_init(void)
5687{
5688 int i;
5689 int rc;
5690 struct pm8058_gpio_cfg {
5691 int gpio;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305692 struct pm_gpio cfg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005693 };
5694
5695 struct pm8058_gpio_cfg gpio_cfgs[] = {
5696 { /* FFA ethernet */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305697 PM8058_GPIO_PM_TO_SYS(6),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005698 {
5699 .direction = PM_GPIO_DIR_IN,
5700 .pull = PM_GPIO_PULL_DN,
5701 .vin_sel = 2,
5702 .function = PM_GPIO_FUNC_NORMAL,
5703 .inv_int_pol = 0,
5704 },
5705 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005706 {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305707 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005708 {
5709 .direction = PM_GPIO_DIR_IN,
5710 .pull = PM_GPIO_PULL_UP_30,
5711 .vin_sel = 2,
5712 .function = PM_GPIO_FUNC_NORMAL,
5713 .inv_int_pol = 0,
5714 },
5715 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005716 { /* core&surf gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305717 PM8058_GPIO_PM_TO_SYS(UI_INT1_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005718 {
5719 .direction = PM_GPIO_DIR_IN,
5720 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305721 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005722 .function = PM_GPIO_FUNC_NORMAL,
5723 .inv_int_pol = 0,
5724 },
5725 },
5726 { /* docking gpio expander */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305727 PM8058_GPIO_PM_TO_SYS(UI_INT2_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005728 {
5729 .direction = PM_GPIO_DIR_IN,
5730 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305731 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005732 .function = PM_GPIO_FUNC_NORMAL,
5733 .inv_int_pol = 0,
5734 },
5735 },
5736 { /* FHA/keypad gpio expanders */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305737 PM8058_GPIO_PM_TO_SYS(UI_INT3_N),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005738 {
5739 .direction = PM_GPIO_DIR_IN,
5740 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305741 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005742 .function = PM_GPIO_FUNC_NORMAL,
5743 .inv_int_pol = 0,
5744 },
5745 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005746 { /* Timpani Reset */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305747 PM8058_GPIO_PM_TO_SYS(20),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005748 {
5749 .direction = PM_GPIO_DIR_OUT,
5750 .output_value = 1,
5751 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5752 .pull = PM_GPIO_PULL_DN,
5753 .out_strength = PM_GPIO_STRENGTH_HIGH,
5754 .function = PM_GPIO_FUNC_NORMAL,
5755 .vin_sel = 2,
5756 .inv_int_pol = 0,
5757 }
5758 },
5759 { /* PMIC ID interrupt */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305760 PM8058_GPIO_PM_TO_SYS(36),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005761 {
5762 .direction = PM_GPIO_DIR_IN,
Anji jonnalaae745e92011-11-14 18:34:31 +05305763 .pull = PM_GPIO_PULL_NO,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005764 .function = PM_GPIO_FUNC_NORMAL,
5765 .vin_sel = 2,
5766 .inv_int_pol = 0,
5767 }
5768 },
5769 };
5770
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305771#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5772 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305773 struct pm_gpio touchdisc_intr_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305774 .direction = PM_GPIO_DIR_IN,
5775 .pull = PM_GPIO_PULL_UP_1P5,
5776 .vin_sel = 2,
5777 .function = PM_GPIO_FUNC_NORMAL,
5778 };
5779#endif
5780
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005781#if defined(CONFIG_HAPTIC_ISA1200) || \
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305782 defined(CONFIG_HAPTIC_ISA1200_MODULE)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305783 struct pm_gpio en_hap_gpio_cfg = {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305784 .direction = PM_GPIO_DIR_OUT,
5785 .pull = PM_GPIO_PULL_NO,
5786 .out_strength = PM_GPIO_STRENGTH_HIGH,
5787 .function = PM_GPIO_FUNC_NORMAL,
5788 .inv_int_pol = 0,
5789 .vin_sel = 2,
5790 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5791 .output_value = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005792 };
5793#endif
5794
5795#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5796 struct pm8058_gpio_cfg line_in_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305797 PM8058_GPIO_PM_TO_SYS(18),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005798 {
5799 .direction = PM_GPIO_DIR_IN,
5800 .pull = PM_GPIO_PULL_UP_1P5,
5801 .vin_sel = 2,
5802 .function = PM_GPIO_FUNC_NORMAL,
5803 .inv_int_pol = 0,
5804 }
5805 };
5806#endif
5807
5808#if defined(CONFIG_QS_S5K4E1)
5809 {
5810 struct pm8058_gpio_cfg qs_hc37_cam_pd_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305811 PM8058_GPIO_PM_TO_SYS(26),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005812 {
5813 .direction = PM_GPIO_DIR_OUT,
5814 .output_value = 0,
5815 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5816 .pull = PM_GPIO_PULL_DN,
5817 .out_strength = PM_GPIO_STRENGTH_HIGH,
5818 .function = PM_GPIO_FUNC_NORMAL,
5819 .vin_sel = 2,
5820 .inv_int_pol = 0,
5821 }
5822 };
5823#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005824#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5825 struct pm8058_gpio_cfg pmic_lcdc_nt35582_gpio_cfg = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305826 PM8058_GPIO_PM_TO_SYS(GPIO_NT35582_BL_EN_HW_PIN - 1),
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005827 {
5828 .direction = PM_GPIO_DIR_OUT,
5829 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5830 .output_value = 1,
5831 .pull = PM_GPIO_PULL_UP_30,
5832 /* 2.9V PM_GPIO_VIN_L2, which gives 2.6V */
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305833 .vin_sel = PM8058_GPIO_VIN_L5,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005834 .out_strength = PM_GPIO_STRENGTH_HIGH,
5835 .function = PM_GPIO_FUNC_NORMAL,
5836 .inv_int_pol = 0,
5837 }
5838 };
5839#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005840#if defined(CONFIG_HAPTIC_ISA1200) || \
5841 defined(CONFIG_HAPTIC_ISA1200_MODULE)
5842 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305843 rc = pm8xxx_gpio_config(
5844 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
5845 &en_hap_gpio_cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005846 if (rc < 0) {
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305847 pr_err("%s: pmic haptics gpio config failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005848 __func__);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305849 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305850 rc = pm8xxx_gpio_config(
5851 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_LDO_ENABLE),
5852 &en_hap_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305853 if (rc < 0) {
5854 pr_err("%s: pmic haptics ldo gpio config failed\n",
5855 __func__);
5856 }
5857
5858 }
5859#endif
5860
5861#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
5862 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
5863 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
5864 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305865 rc = pm8xxx_gpio_config(
5866 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_TOUCH_DISC_INTR),
5867 &touchdisc_intr_gpio_cfg);
Mohan Pallaka4a1160d2011-09-09 15:17:45 +05305868 if (rc < 0) {
5869 pr_err("%s: Touchdisc interrupt gpio config failed\n",
5870 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005871 }
5872 }
5873#endif
5874
5875#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5876 /* Line_in only for 8660 ffa & surf */
5877 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04005878 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005879 machine_is_msm8x60_fusn_ffa()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305880 rc = pm8xxx_gpio_config(line_in_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005881 &line_in_gpio_cfg.cfg);
5882 if (rc < 0) {
5883 pr_err("%s pmic line_in gpio config failed\n",
5884 __func__);
5885 return rc;
5886 }
5887 }
5888#endif
5889
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005890#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
5891 if (machine_is_msm8x60_dragon()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305892 rc = pm8xxx_gpio_config(pmic_lcdc_nt35582_gpio_cfg.gpio,
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04005893 &pmic_lcdc_nt35582_gpio_cfg.cfg);
5894 if (rc < 0) {
5895 pr_err("%s pmic gpio config failed\n", __func__);
5896 return rc;
5897 }
5898 }
5899#endif
5900
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005901#if defined(CONFIG_QS_S5K4E1)
5902 /* qs_cam_hc37_cam_pd only for 8660 fluid qs camera*/
5903 if (machine_is_msm8x60_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305904 rc = pm8xxx_gpio_config(qs_hc37_cam_pd_gpio_cfg.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005905 &qs_hc37_cam_pd_gpio_cfg.cfg);
5906 if (rc < 0) {
5907 pr_err("%s pmic qs_hc37_cam_pd gpio config failed\n",
5908 __func__);
5909 return rc;
5910 }
5911 }
5912 }
5913#endif
5914
5915 for (i = 0; i < ARRAY_SIZE(gpio_cfgs); ++i) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305916 rc = pm8xxx_gpio_config(gpio_cfgs[i].gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005917 &gpio_cfgs[i].cfg);
5918 if (rc < 0) {
5919 pr_err("%s pmic gpio config failed\n",
5920 __func__);
5921 return rc;
5922 }
5923 }
5924
5925 return 0;
5926}
5927
5928static const unsigned int ffa_keymap[] = {
5929 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5930 KEY(0, 1, KEY_UP), /* NAV - UP */
5931 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5932 KEY(0, 3, KEY_VOLUMEUP), /* Shuttle SW_UP */
5933
5934 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5935 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5936 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5937 KEY(1, 3, KEY_VOLUMEDOWN),
5938
5939 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5940
5941 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5942 KEY(4, 1, KEY_UP), /* USER_UP */
5943 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5944 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5945 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5946
5947 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
5948 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5949 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5950 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5951 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5952};
5953
Zhang Chang Ken683be172011-08-10 17:45:34 -04005954static const unsigned int dragon_keymap[] = {
5955 KEY(0, 0, KEY_MENU),
5956 KEY(0, 2, KEY_1),
5957 KEY(0, 3, KEY_4),
5958 KEY(0, 4, KEY_7),
5959
5960 KEY(1, 0, KEY_UP),
5961 KEY(1, 1, KEY_LEFT),
5962 KEY(1, 2, KEY_DOWN),
5963 KEY(1, 3, KEY_5),
5964 KEY(1, 4, KEY_8),
5965
5966 KEY(2, 0, KEY_HOME),
5967 KEY(2, 1, KEY_REPLY),
5968 KEY(2, 2, KEY_2),
5969 KEY(2, 3, KEY_6),
5970 KEY(2, 4, KEY_0),
5971
5972 KEY(3, 0, KEY_VOLUMEUP),
5973 KEY(3, 1, KEY_RIGHT),
5974 KEY(3, 2, KEY_3),
5975 KEY(3, 3, KEY_9),
5976 KEY(3, 4, KEY_SWITCHVIDEOMODE),
5977
5978 KEY(4, 0, KEY_VOLUMEDOWN),
5979 KEY(4, 1, KEY_BACK),
5980 KEY(4, 2, KEY_CAMERA),
5981 KEY(4, 3, KEY_KBDILLUMTOGGLE),
5982};
5983
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005984static struct matrix_keymap_data ffa_keymap_data = {
5985 .keymap_size = ARRAY_SIZE(ffa_keymap),
5986 .keymap = ffa_keymap,
5987};
5988
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305989static struct pm8xxx_keypad_platform_data ffa_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005990 .input_name = "ffa-keypad",
5991 .input_phys_device = "ffa-keypad/input0",
5992 .num_rows = 6,
5993 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05305994 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
5995 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
5996 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005997 .scan_delay_ms = 32,
5998 .row_hold_ns = 91500,
5999 .wakeup = 1,
6000 .keymap_data = &ffa_keymap_data,
6001};
6002
Zhang Chang Ken683be172011-08-10 17:45:34 -04006003static struct matrix_keymap_data dragon_keymap_data = {
6004 .keymap_size = ARRAY_SIZE(dragon_keymap),
6005 .keymap = dragon_keymap,
6006};
6007
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306008static struct pm8xxx_keypad_platform_data dragon_keypad_data = {
Zhang Chang Ken683be172011-08-10 17:45:34 -04006009 .input_name = "dragon-keypad",
6010 .input_phys_device = "dragon-keypad/input0",
6011 .num_rows = 6,
6012 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306013 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
6014 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
6015 .debounce_ms = 15,
Zhang Chang Ken683be172011-08-10 17:45:34 -04006016 .scan_delay_ms = 32,
6017 .row_hold_ns = 91500,
6018 .wakeup = 1,
6019 .keymap_data = &dragon_keymap_data,
6020};
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306021
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006022static const unsigned int fluid_keymap[] = {
6023 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
6024 KEY(0, 1, KEY_UP), /* NAV - UP */
6025 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
6026 KEY(0, 3, KEY_VOLUMEDOWN), /* Shuttle SW_UP */
6027
6028 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
6029 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
6030 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
6031 KEY(1, 3, KEY_VOLUMEUP),
6032
6033 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
6034
6035 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
6036 KEY(4, 1, KEY_UP), /* USER_UP */
6037 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
6038 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
6039 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
6040
Jilai Wang9a895102011-07-12 14:00:35 -04006041 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006042 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
6043 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
6044 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
6045 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
6046};
6047
6048static struct matrix_keymap_data fluid_keymap_data = {
6049 .keymap_size = ARRAY_SIZE(fluid_keymap),
6050 .keymap = fluid_keymap,
6051};
6052
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306053static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006054 .input_name = "fluid-keypad",
6055 .input_phys_device = "fluid-keypad/input0",
6056 .num_rows = 6,
6057 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306058 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
6059 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
6060 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006061 .scan_delay_ms = 32,
6062 .row_hold_ns = 91500,
6063 .wakeup = 1,
6064 .keymap_data = &fluid_keymap_data,
6065};
6066
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306067static struct pm8xxx_vibrator_platform_data pm8058_vib_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006068 .initial_vibrate_ms = 500,
6069 .level_mV = 3000,
6070 .max_timeout_ms = 15000,
6071};
6072
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306073static struct pm8xxx_rtc_platform_data pm8058_rtc_pdata = {
6074 .rtc_write_enable = false,
6075 .rtc_alarm_powerup = false,
6076};
6077
6078static struct pm8xxx_pwrkey_platform_data pm8058_pwrkey_pdata = {
6079 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -08006080 .kpd_trigger_delay_us = 15625,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306081 .wakeup = 1,
6082};
6083
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006084#define PM8058_LINE_IN_DET_GPIO PM8058_GPIO_PM_TO_SYS(18)
6085
6086static struct othc_accessory_info othc_accessories[] = {
6087 {
6088 .accessory = OTHC_SVIDEO_OUT,
6089 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT
6090 | OTHC_ADC_DETECT,
6091 .key_code = SW_VIDEOOUT_INSERT,
6092 .enabled = false,
6093 .adc_thres = {
6094 .min_threshold = 20,
6095 .max_threshold = 40,
6096 },
6097 },
6098 {
6099 .accessory = OTHC_ANC_HEADPHONE,
6100 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT |
6101 OTHC_SWITCH_DETECT,
6102 .gpio = PM8058_LINE_IN_DET_GPIO,
6103 .active_low = 1,
6104 .key_code = SW_HEADPHONE_INSERT,
6105 .enabled = true,
6106 },
6107 {
6108 .accessory = OTHC_ANC_HEADSET,
6109 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT,
6110 .gpio = PM8058_LINE_IN_DET_GPIO,
6111 .active_low = 1,
6112 .key_code = SW_HEADPHONE_INSERT,
6113 .enabled = true,
6114 },
6115 {
6116 .accessory = OTHC_HEADPHONE,
6117 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT,
6118 .key_code = SW_HEADPHONE_INSERT,
6119 .enabled = true,
6120 },
6121 {
6122 .accessory = OTHC_MICROPHONE,
6123 .detect_flags = OTHC_GPIO_DETECT,
6124 .gpio = PM8058_LINE_IN_DET_GPIO,
6125 .active_low = 1,
6126 .key_code = SW_MICROPHONE_INSERT,
6127 .enabled = true,
6128 },
6129 {
6130 .accessory = OTHC_HEADSET,
6131 .detect_flags = OTHC_MICBIAS_DETECT,
6132 .key_code = SW_HEADPHONE_INSERT,
6133 .enabled = true,
6134 },
6135};
6136
6137static struct othc_switch_info switch_info[] = {
6138 {
6139 .min_adc_threshold = 0,
6140 .max_adc_threshold = 100,
6141 .key_code = KEY_PLAYPAUSE,
6142 },
6143 {
6144 .min_adc_threshold = 100,
6145 .max_adc_threshold = 200,
6146 .key_code = KEY_REWIND,
6147 },
6148 {
6149 .min_adc_threshold = 200,
6150 .max_adc_threshold = 500,
6151 .key_code = KEY_FASTFORWARD,
6152 },
6153};
6154
6155static struct othc_n_switch_config switch_config = {
6156 .voltage_settling_time_ms = 0,
6157 .num_adc_samples = 3,
6158 .adc_channel = CHANNEL_ADC_HDSET,
6159 .switch_info = switch_info,
6160 .num_keys = ARRAY_SIZE(switch_info),
6161 .default_sw_en = true,
6162 .default_sw_idx = 0,
6163};
6164
6165static struct hsed_bias_config hsed_bias_config = {
6166 /* HSED mic bias config info */
6167 .othc_headset = OTHC_HEADSET_NO,
6168 .othc_lowcurr_thresh_uA = 100,
6169 .othc_highcurr_thresh_uA = 600,
6170 .othc_hyst_prediv_us = 7800,
6171 .othc_period_clkdiv_us = 62500,
6172 .othc_hyst_clk_us = 121000,
6173 .othc_period_clk_us = 312500,
6174 .othc_wakeup = 1,
6175};
6176
6177static struct othc_hsed_config hsed_config_1 = {
6178 .hsed_bias_config = &hsed_bias_config,
6179 /*
6180 * The detection delay and switch reporting delay are
6181 * required to encounter a hardware bug (spurious switch
6182 * interrupts on slow insertion/removal of the headset).
6183 * This will introduce a delay in reporting the accessory
6184 * insertion and removal to the userspace.
6185 */
6186 .detection_delay_ms = 1500,
6187 /* Switch info */
6188 .switch_debounce_ms = 1500,
6189 .othc_support_n_switch = false,
6190 .switch_config = &switch_config,
6191 .ir_gpio = -1,
6192 /* Accessory info */
6193 .accessories_support = true,
6194 .accessories = othc_accessories,
6195 .othc_num_accessories = ARRAY_SIZE(othc_accessories),
6196};
6197
6198static struct othc_regulator_config othc_reg = {
6199 .regulator = "8058_l5",
6200 .max_uV = 2850000,
6201 .min_uV = 2850000,
6202};
6203
6204/* MIC_BIAS0 is configured as normal MIC BIAS */
6205static struct pmic8058_othc_config_pdata othc_config_pdata_0 = {
6206 .micbias_select = OTHC_MICBIAS_0,
6207 .micbias_capability = OTHC_MICBIAS,
6208 .micbias_enable = OTHC_SIGNAL_OFF,
6209 .micbias_regulator = &othc_reg,
6210};
6211
6212/* MIC_BIAS1 is configured as HSED_BIAS for OTHC */
6213static struct pmic8058_othc_config_pdata othc_config_pdata_1 = {
6214 .micbias_select = OTHC_MICBIAS_1,
6215 .micbias_capability = OTHC_MICBIAS_HSED,
6216 .micbias_enable = OTHC_SIGNAL_PWM_TCXO,
6217 .micbias_regulator = &othc_reg,
6218 .hsed_config = &hsed_config_1,
6219 .hsed_name = "8660_handset",
6220};
6221
6222/* MIC_BIAS2 is configured as normal MIC BIAS */
6223static struct pmic8058_othc_config_pdata othc_config_pdata_2 = {
6224 .micbias_select = OTHC_MICBIAS_2,
6225 .micbias_capability = OTHC_MICBIAS,
6226 .micbias_enable = OTHC_SIGNAL_OFF,
6227 .micbias_regulator = &othc_reg,
6228};
6229
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006230
6231static void __init msm8x60_init_pm8058_othc(void)
6232{
6233 int i;
6234
6235 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 ||
6236 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
6237 machine_is_msm8x60_fusn_ffa()) {
6238 /* 3-switch headset supported only by V2 FFA and FLUID */
6239 hsed_config_1.accessories_adc_support = true,
6240 /* ADC based accessory detection works only on V2 and FLUID */
6241 hsed_config_1.accessories_adc_channel = CHANNEL_ADC_HDSET,
6242 hsed_config_1.othc_support_n_switch = true;
6243 }
6244
6245 /* IR GPIO is absent on FLUID */
6246 if (machine_is_msm8x60_fluid())
6247 hsed_config_1.ir_gpio = -1;
6248
6249 for (i = 0; i < ARRAY_SIZE(othc_accessories); i++) {
6250 if (machine_is_msm8x60_fluid()) {
6251 switch (othc_accessories[i].accessory) {
6252 case OTHC_ANC_HEADPHONE:
6253 case OTHC_ANC_HEADSET:
6254 othc_accessories[i].gpio = GPIO_HEADSET_DET_N;
6255 break;
6256 case OTHC_MICROPHONE:
6257 othc_accessories[i].enabled = false;
6258 break;
6259 case OTHC_SVIDEO_OUT:
6260 othc_accessories[i].enabled = true;
6261 hsed_config_1.video_out_gpio = GPIO_HS_SW_DIR;
6262 break;
6263 }
6264 }
6265 }
6266}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006267
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006268
6269static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
6270{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306271 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006272 .direction = PM_GPIO_DIR_OUT,
6273 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
6274 .output_value = 0,
6275 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306276 .vin_sel = PM8058_GPIO_VIN_VPH,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006277 .out_strength = PM_GPIO_STRENGTH_HIGH,
6278 .function = PM_GPIO_FUNC_2,
6279 };
6280
6281 int rc = -EINVAL;
6282 int id, mode, max_mA;
6283
6284 id = mode = max_mA = 0;
6285 switch (ch) {
6286 case 0:
6287 case 1:
6288 case 2:
6289 if (on) {
6290 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306291 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
6292 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006293 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306294 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006295 __func__, id, rc);
6296 }
6297 break;
6298
6299 case 6:
6300 id = PM_PWM_LED_FLASH;
6301 mode = PM_PWM_CONF_PWM1;
6302 max_mA = 300;
6303 break;
6304
6305 case 7:
6306 id = PM_PWM_LED_FLASH1;
6307 mode = PM_PWM_CONF_PWM1;
6308 max_mA = 300;
6309 break;
6310
6311 default:
6312 break;
6313 }
6314
6315 if (ch >= 6 && ch <= 7) {
6316 if (!on) {
6317 mode = PM_PWM_CONF_NONE;
6318 max_mA = 0;
6319 }
6320 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
6321 if (rc)
6322 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
6323 __func__, ch, rc);
6324 }
6325 return rc;
6326
6327}
6328
6329static struct pm8058_pwm_pdata pm8058_pwm_data = {
6330 .config = pm8058_pwm_config,
6331};
6332
6333#define PM8058_GPIO_INT 88
6334
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006335static struct pmic8058_led pmic8058_flash_leds[] = {
6336 [0] = {
6337 .name = "camera:flash0",
6338 .max_brightness = 15,
6339 .id = PMIC8058_ID_FLASH_LED_0,
6340 },
6341 [1] = {
6342 .name = "camera:flash1",
6343 .max_brightness = 15,
6344 .id = PMIC8058_ID_FLASH_LED_1,
6345 },
6346};
6347
6348static struct pmic8058_leds_platform_data pm8058_flash_leds_data = {
6349 .num_leds = ARRAY_SIZE(pmic8058_flash_leds),
6350 .leds = pmic8058_flash_leds,
6351};
6352
Terence Hampsonc0b6dfb2011-07-15 11:07:17 -04006353static struct pmic8058_led pmic8058_dragon_leds[] = {
6354 [0] = {
6355 /* RED */
6356 .name = "led_drv0",
6357 .max_brightness = 15,
6358 .id = PMIC8058_ID_LED_0,
6359 },/* 300 mA flash led0 drv sink */
6360 [1] = {
6361 /* Yellow */
6362 .name = "led_drv1",
6363 .max_brightness = 15,
6364 .id = PMIC8058_ID_LED_1,
6365 },/* 300 mA flash led0 drv sink */
6366 [2] = {
6367 /* Green */
6368 .name = "led_drv2",
6369 .max_brightness = 15,
6370 .id = PMIC8058_ID_LED_2,
6371 },/* 300 mA flash led0 drv sink */
6372 [3] = {
6373 .name = "led_psensor",
6374 .max_brightness = 15,
6375 .id = PMIC8058_ID_LED_KB_LIGHT,
6376 },/* 300 mA flash led0 drv sink */
6377};
6378
6379static struct pmic8058_leds_platform_data pm8058_dragon_leds_data = {
6380 .num_leds = ARRAY_SIZE(pmic8058_dragon_leds),
6381 .leds = pmic8058_dragon_leds,
6382};
6383
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006384static struct pmic8058_led pmic8058_fluid_flash_leds[] = {
6385 [0] = {
6386 .name = "led:drv0",
6387 .max_brightness = 15,
6388 .id = PMIC8058_ID_FLASH_LED_0,
6389 },/* 300 mA flash led0 drv sink */
6390 [1] = {
6391 .name = "led:drv1",
6392 .max_brightness = 15,
6393 .id = PMIC8058_ID_FLASH_LED_1,
6394 },/* 300 mA flash led1 sink */
6395 [2] = {
6396 .name = "led:drv2",
6397 .max_brightness = 20,
6398 .id = PMIC8058_ID_LED_0,
6399 },/* 40 mA led0 sink */
6400 [3] = {
6401 .name = "keypad:drv",
6402 .max_brightness = 15,
6403 .id = PMIC8058_ID_LED_KB_LIGHT,
6404 },/* 300 mA keypad drv sink */
6405};
6406
6407static struct pmic8058_leds_platform_data pm8058_fluid_flash_leds_data = {
6408 .num_leds = ARRAY_SIZE(pmic8058_fluid_flash_leds),
6409 .leds = pmic8058_fluid_flash_leds,
6410};
6411
Terence Hampson90508a92011-08-09 10:40:08 -04006412static struct pmic8058_charger_data pmic8058_charger_dragon = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306413 .charger_data_valid = true,
Terence Hampson90508a92011-08-09 10:40:08 -04006414 .max_source_current = 1800,
6415 .charger_type = CHG_TYPE_AC,
6416};
6417
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306418static struct pmic8058_charger_data pmic8058_charger_ffa_surf = {
6419 .charger_data_valid = false,
6420};
6421
6422static struct pm8xxx_misc_platform_data pm8058_misc_pdata = {
6423 .priority = 0,
6424};
6425
6426static struct pm8xxx_irq_platform_data pm8058_irq_pdata = {
6427 .irq_base = PM8058_IRQ_BASE,
6428 .devirq = MSM_GPIO_TO_INT(PM8058_GPIO_INT),
6429 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6430};
6431
6432static struct pm8xxx_gpio_platform_data pm8058_gpio_pdata = {
6433 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
6434};
6435
6436static struct pm8xxx_mpp_platform_data pm8058_mpp_pdata = {
6437 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006438};
6439
6440static struct pm8058_platform_data pm8058_platform_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306441 .irq_pdata = &pm8058_irq_pdata,
6442 .gpio_pdata = &pm8058_gpio_pdata,
6443 .mpp_pdata = &pm8058_mpp_pdata,
6444 .rtc_pdata = &pm8058_rtc_pdata,
6445 .pwrkey_pdata = &pm8058_pwrkey_pdata,
6446 .othc0_pdata = &othc_config_pdata_0,
6447 .othc1_pdata = &othc_config_pdata_1,
6448 .othc2_pdata = &othc_config_pdata_2,
6449 .pwm_pdata = &pm8058_pwm_data,
6450 .misc_pdata = &pm8058_misc_pdata,
6451#ifdef CONFIG_SENSORS_MSM_ADC
6452 .xoadc_pdata = &pm8058_xoadc_pdata,
6453#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006454};
6455
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306456#ifdef CONFIG_MSM_SSBI
6457static struct msm_ssbi_platform_data msm8x60_ssbi_pm8058_pdata __devinitdata = {
6458 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6459 .slave = {
6460 .name = "pm8058-core",
6461 .platform_data = &pm8058_platform_data,
6462 },
6463};
6464#endif
6465#endif /* CONFIG_PMIC8058 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006466
6467#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
6468 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
6469#define TDISC_I2C_SLAVE_ADDR 0x67
6470#define PMIC_GPIO_TDISC PM8058_GPIO_PM_TO_SYS(5)
6471#define TDISC_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 5)
6472
6473static const char *vregs_tdisc_name[] = {
6474 "8058_l5",
6475 "8058_s3",
6476};
6477
6478static const int vregs_tdisc_val[] = {
6479 2850000,/* uV */
6480 1800000,
6481};
6482static struct regulator *vregs_tdisc[ARRAY_SIZE(vregs_tdisc_name)];
6483
6484static int tdisc_shinetsu_setup(void)
6485{
6486 int rc, i;
6487
6488 rc = gpio_request(PMIC_GPIO_TDISC, "tdisc_interrupt");
6489 if (rc) {
6490 pr_err("%s: gpio_request failed for PMIC_GPIO_TDISC\n",
6491 __func__);
6492 return rc;
6493 }
6494
6495 rc = gpio_request(GPIO_JOYSTICK_EN, "tdisc_oe");
6496 if (rc) {
6497 pr_err("%s: gpio_request failed for GPIO_JOYSTICK_EN\n",
6498 __func__);
6499 goto fail_gpio_oe;
6500 }
6501
6502 rc = gpio_direction_output(GPIO_JOYSTICK_EN, 1);
6503 if (rc) {
6504 pr_err("%s: gpio_direction_output failed for GPIO_JOYSTICK_EN\n",
6505 __func__);
6506 gpio_free(GPIO_JOYSTICK_EN);
6507 goto fail_gpio_oe;
6508 }
6509
6510 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6511 vregs_tdisc[i] = regulator_get(NULL, vregs_tdisc_name[i]);
6512 if (IS_ERR(vregs_tdisc[i])) {
6513 printk(KERN_ERR "%s: regulator get %s failed (%ld)\n",
6514 __func__, vregs_tdisc_name[i],
6515 PTR_ERR(vregs_tdisc[i]));
6516 rc = PTR_ERR(vregs_tdisc[i]);
6517 goto vreg_get_fail;
6518 }
6519
6520 rc = regulator_set_voltage(vregs_tdisc[i],
6521 vregs_tdisc_val[i], vregs_tdisc_val[i]);
6522 if (rc) {
6523 printk(KERN_ERR "%s: regulator_set_voltage() = %d\n",
6524 __func__, rc);
6525 goto vreg_set_voltage_fail;
6526 }
6527 }
6528
6529 return rc;
6530vreg_set_voltage_fail:
6531 i++;
6532vreg_get_fail:
6533 while (i)
6534 regulator_put(vregs_tdisc[--i]);
6535fail_gpio_oe:
6536 gpio_free(PMIC_GPIO_TDISC);
6537 return rc;
6538}
6539
6540static void tdisc_shinetsu_release(void)
6541{
6542 int i;
6543
6544 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++)
6545 regulator_put(vregs_tdisc[i]);
6546
6547 gpio_free(PMIC_GPIO_TDISC);
6548 gpio_free(GPIO_JOYSTICK_EN);
6549}
6550
6551static int tdisc_shinetsu_enable(void)
6552{
6553 int i, rc = -EINVAL;
6554
6555 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6556 rc = regulator_enable(vregs_tdisc[i]);
6557 if (rc < 0) {
6558 printk(KERN_ERR "%s: vreg %s enable failed (%d)\n",
6559 __func__, vregs_tdisc_name[i], rc);
6560 goto vreg_fail;
6561 }
6562 }
6563
6564 /* Enable the OE (output enable) gpio */
6565 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 1);
6566 /* voltage and gpio stabilization delay */
6567 msleep(50);
6568
6569 return 0;
6570vreg_fail:
6571 while (i)
6572 regulator_disable(vregs_tdisc[--i]);
6573 return rc;
6574}
6575
6576static int tdisc_shinetsu_disable(void)
6577{
6578 int i, rc;
6579
6580 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6581 rc = regulator_disable(vregs_tdisc[i]);
6582 if (rc < 0) {
6583 printk(KERN_ERR "%s: vreg %s disable failed (%d)\n",
6584 __func__, vregs_tdisc_name[i], rc);
6585 goto tdisc_reg_fail;
6586 }
6587 }
6588
6589 /* Disable the OE (output enable) gpio */
6590 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 0);
6591
6592 return 0;
6593
6594tdisc_reg_fail:
6595 while (i)
6596 regulator_enable(vregs_tdisc[--i]);
6597 return rc;
6598}
6599
6600static struct tdisc_abs_values tdisc_abs = {
6601 .x_max = 32,
6602 .y_max = 32,
6603 .x_min = -32,
6604 .y_min = -32,
6605 .pressure_max = 32,
6606 .pressure_min = 0,
6607};
6608
6609static struct tdisc_platform_data tdisc_data = {
6610 .tdisc_setup = tdisc_shinetsu_setup,
6611 .tdisc_release = tdisc_shinetsu_release,
6612 .tdisc_enable = tdisc_shinetsu_enable,
6613 .tdisc_disable = tdisc_shinetsu_disable,
6614 .tdisc_wakeup = 0,
6615 .tdisc_gpio = PMIC_GPIO_TDISC,
6616 .tdisc_report_keys = true,
6617 .tdisc_report_relative = true,
6618 .tdisc_report_absolute = false,
6619 .tdisc_report_wheel = false,
6620 .tdisc_reverse_x = false,
6621 .tdisc_reverse_y = true,
6622 .tdisc_abs = &tdisc_abs,
6623};
6624
6625static struct i2c_board_info msm_i2c_gsbi3_tdisc_info[] = {
6626 {
6627 I2C_BOARD_INFO("vtd518", TDISC_I2C_SLAVE_ADDR),
6628 .irq = TDISC_INT,
6629 .platform_data = &tdisc_data,
6630 },
6631};
6632#endif
6633
6634#define PM_GPIO_CDC_RST_N 20
6635#define GPIO_CDC_RST_N PM8058_GPIO_PM_TO_SYS(PM_GPIO_CDC_RST_N)
6636
6637static struct regulator *vreg_timpani_1;
6638static struct regulator *vreg_timpani_2;
6639
6640static unsigned int msm_timpani_setup_power(void)
6641{
6642 int rc;
6643
6644 vreg_timpani_1 = regulator_get(NULL, "8058_l0");
6645 if (IS_ERR(vreg_timpani_1)) {
6646 pr_err("%s: Unable to get 8058_l0\n", __func__);
6647 return -ENODEV;
6648 }
6649
6650 vreg_timpani_2 = regulator_get(NULL, "8058_s3");
6651 if (IS_ERR(vreg_timpani_2)) {
6652 pr_err("%s: Unable to get 8058_s3\n", __func__);
6653 regulator_put(vreg_timpani_1);
6654 return -ENODEV;
6655 }
6656
6657 rc = regulator_set_voltage(vreg_timpani_1, 1200000, 1200000);
6658 if (rc) {
6659 pr_err("%s: unable to set L0 voltage to 1.2V\n", __func__);
6660 goto fail;
6661 }
6662
6663 rc = regulator_set_voltage(vreg_timpani_2, 1800000, 1800000);
6664 if (rc) {
6665 pr_err("%s: unable to set S3 voltage to 1.8V\n", __func__);
6666 goto fail;
6667 }
6668
6669 rc = regulator_enable(vreg_timpani_1);
6670 if (rc) {
6671 pr_err("%s: Enable regulator 8058_l0 failed\n", __func__);
6672 goto fail;
6673 }
6674
6675 /* The settings for LDO0 should be set such that
6676 * it doesn't require to reset the timpani. */
6677 rc = regulator_set_optimum_mode(vreg_timpani_1, 5000);
6678 if (rc < 0) {
6679 pr_err("Timpani regulator optimum mode setting failed\n");
6680 goto fail;
6681 }
6682
6683 rc = regulator_enable(vreg_timpani_2);
6684 if (rc) {
6685 pr_err("%s: Enable regulator 8058_s3 failed\n", __func__);
6686 regulator_disable(vreg_timpani_1);
6687 goto fail;
6688 }
6689
6690 rc = gpio_request(GPIO_CDC_RST_N, "CDC_RST_N");
6691 if (rc) {
6692 pr_err("%s: GPIO Request %d failed\n", __func__,
6693 GPIO_CDC_RST_N);
6694 regulator_disable(vreg_timpani_1);
6695 regulator_disable(vreg_timpani_2);
6696 goto fail;
6697 } else {
6698 gpio_direction_output(GPIO_CDC_RST_N, 1);
6699 usleep_range(1000, 1050);
6700 gpio_direction_output(GPIO_CDC_RST_N, 0);
6701 usleep_range(1000, 1050);
6702 gpio_direction_output(GPIO_CDC_RST_N, 1);
6703 gpio_free(GPIO_CDC_RST_N);
6704 }
6705 return rc;
6706
6707fail:
6708 regulator_put(vreg_timpani_1);
6709 regulator_put(vreg_timpani_2);
6710 return rc;
6711}
6712
6713static void msm_timpani_shutdown_power(void)
6714{
6715 int rc;
6716
6717 rc = regulator_disable(vreg_timpani_1);
6718 if (rc)
6719 pr_err("%s: Disable regulator 8058_l0 failed\n", __func__);
6720
6721 regulator_put(vreg_timpani_1);
6722
6723 rc = regulator_disable(vreg_timpani_2);
6724 if (rc)
6725 pr_err("%s: Disable regulator 8058_s3 failed\n", __func__);
6726
6727 regulator_put(vreg_timpani_2);
6728}
6729
6730/* Power analog function of codec */
6731static struct regulator *vreg_timpani_cdc_apwr;
6732static int msm_timpani_codec_power(int vreg_on)
6733{
6734 int rc = 0;
6735
6736 if (!vreg_timpani_cdc_apwr) {
6737
6738 vreg_timpani_cdc_apwr = regulator_get(NULL, "8058_s4");
6739
6740 if (IS_ERR(vreg_timpani_cdc_apwr)) {
6741 pr_err("%s: vreg_get failed (%ld)\n",
6742 __func__, PTR_ERR(vreg_timpani_cdc_apwr));
6743 rc = PTR_ERR(vreg_timpani_cdc_apwr);
6744 return rc;
6745 }
6746 }
6747
6748 if (vreg_on) {
6749
6750 rc = regulator_set_voltage(vreg_timpani_cdc_apwr,
6751 2200000, 2200000);
6752 if (rc) {
6753 pr_err("%s: unable to set 8058_s4 voltage to 2.2 V\n",
6754 __func__);
6755 goto vreg_fail;
6756 }
6757
6758 rc = regulator_enable(vreg_timpani_cdc_apwr);
6759 if (rc) {
6760 pr_err("%s: vreg_enable failed %d\n", __func__, rc);
6761 goto vreg_fail;
6762 }
6763 } else {
6764 rc = regulator_disable(vreg_timpani_cdc_apwr);
6765 if (rc) {
6766 pr_err("%s: vreg_disable failed %d\n",
6767 __func__, rc);
6768 goto vreg_fail;
6769 }
6770 }
6771
6772 return 0;
6773
6774vreg_fail:
6775 regulator_put(vreg_timpani_cdc_apwr);
6776 vreg_timpani_cdc_apwr = NULL;
6777 return rc;
6778}
6779
6780static struct marimba_codec_platform_data timpani_codec_pdata = {
6781 .marimba_codec_power = msm_timpani_codec_power,
6782};
6783
6784#define TIMPANI_SLAVE_ID_CDC_ADDR 0X77
6785#define TIMPANI_SLAVE_ID_QMEMBIST_ADDR 0X66
6786
6787static struct marimba_platform_data timpani_pdata = {
6788 .slave_id[MARIMBA_SLAVE_ID_CDC] = TIMPANI_SLAVE_ID_CDC_ADDR,
6789 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = TIMPANI_SLAVE_ID_QMEMBIST_ADDR,
6790 .marimba_setup = msm_timpani_setup_power,
6791 .marimba_shutdown = msm_timpani_shutdown_power,
6792 .codec = &timpani_codec_pdata,
6793 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6794};
6795
6796#define TIMPANI_I2C_SLAVE_ADDR 0xD
6797
6798static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
6799 {
6800 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
6801 .platform_data = &timpani_pdata,
6802 },
6803};
6804
Lei Zhou338cab82011-08-19 13:38:17 -04006805#ifdef CONFIG_SND_SOC_WM8903
6806static struct wm8903_platform_data wm8903_pdata = {
6807 .gpio_cfg[2] = 0x3A8,
6808};
6809
6810#define WM8903_I2C_SLAVE_ADDR 0x34
6811static struct i2c_board_info wm8903_codec_i2c_info[] = {
6812 {
6813 I2C_BOARD_INFO("wm8903", WM8903_I2C_SLAVE_ADDR >> 1),
6814 .platform_data = &wm8903_pdata,
6815 },
6816};
6817#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006818#ifdef CONFIG_PMIC8901
6819
6820#define PM8901_GPIO_INT 91
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006821/*
6822 * Consumer specific regulator names:
6823 * regulator name consumer dev_name
6824 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006825static struct regulator_consumer_supply vreg_consumers_8901_USB_OTG[] = {
6826 REGULATOR_SUPPLY("8901_usb_otg", NULL),
6827};
6828static struct regulator_consumer_supply vreg_consumers_8901_HDMI_MVS[] = {
6829 REGULATOR_SUPPLY("8901_hdmi_mvs", NULL),
6830};
6831
6832#define PM8901_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306833 _always_on) \
6834 { \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006835 .init_data = { \
6836 .constraints = { \
6837 .valid_modes_mask = _modes, \
6838 .valid_ops_mask = _ops, \
6839 .min_uV = _min_uV, \
6840 .max_uV = _max_uV, \
6841 .input_uV = _min_uV, \
6842 .apply_uV = _apply_uV, \
6843 .always_on = _always_on, \
6844 }, \
6845 .consumer_supplies = vreg_consumers_8901_##_id, \
6846 .num_consumer_supplies = \
6847 ARRAY_SIZE(vreg_consumers_8901_##_id), \
6848 }, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306849 .id = PM8901_VREG_ID_##_id, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006850 }
6851
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006852#define PM8901_VREG_INIT_VS(_id) \
6853 PM8901_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL, \
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306854 REGULATOR_CHANGE_STATUS, 0, 0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006855
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306856static struct pm8901_vreg_pdata pm8901_vreg_init[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006857 PM8901_VREG_INIT_VS(USB_OTG),
6858 PM8901_VREG_INIT_VS(HDMI_MVS),
6859};
6860
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306861static struct pm8xxx_misc_platform_data pm8901_misc_pdata = {
6862 .priority = 1,
6863};
6864
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306865static struct pm8xxx_irq_platform_data pm8901_irq_pdata = {
6866 .irq_base = PM8901_IRQ_BASE,
6867 .devirq = MSM_GPIO_TO_INT(PM8901_GPIO_INT),
6868 .irq_trigger_flag = IRQF_TRIGGER_LOW,
6869};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006870
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306871static struct pm8xxx_mpp_platform_data pm8901_mpp_pdata = {
6872 .mpp_base = PM8901_MPP_PM_TO_SYS(0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006873};
6874
6875static struct pm8901_platform_data pm8901_platform_data = {
Anirudh Ghayal9f77e962011-12-06 12:38:21 +05306876 .irq_pdata = &pm8901_irq_pdata,
6877 .mpp_pdata = &pm8901_mpp_pdata,
6878 .regulator_pdatas = pm8901_vreg_init,
6879 .num_regulators = ARRAY_SIZE(pm8901_vreg_init),
Anirudh Ghayalb6c98092011-12-13 14:06:48 +05306880 .misc_pdata = &pm8901_misc_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006881};
6882
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05306883static struct msm_ssbi_platform_data msm8x60_ssbi_pm8901_pdata __devinitdata = {
6884 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
6885 .slave = {
6886 .name = "pm8901-core",
6887 .platform_data = &pm8901_platform_data,
6888 },
6889};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006890#endif /* CONFIG_PMIC8901 */
6891
6892#if defined(CONFIG_MARIMBA_CORE) && (defined(CONFIG_GPIO_SX150X) \
6893 || defined(CONFIG_GPIO_SX150X_MODULE))
6894
6895static struct regulator *vreg_bahama;
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006896static int msm_bahama_sys_rst = GPIO_MS_SYS_RESET_N;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006897
6898struct bahama_config_register{
6899 u8 reg;
6900 u8 value;
6901 u8 mask;
6902};
6903
6904enum version{
6905 VER_1_0,
6906 VER_2_0,
6907 VER_UNSUPPORTED = 0xFF
6908};
6909
6910static u8 read_bahama_ver(void)
6911{
6912 int rc;
6913 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6914 u8 bahama_version;
6915
6916 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
6917 if (rc < 0) {
6918 printk(KERN_ERR
6919 "%s: version read failed: %d\n",
6920 __func__, rc);
6921 return VER_UNSUPPORTED;
6922 } else {
6923 printk(KERN_INFO
6924 "%s: version read got: 0x%x\n",
6925 __func__, bahama_version);
6926 }
6927
6928 switch (bahama_version) {
6929 case 0x08: /* varient of bahama v1 */
6930 case 0x10:
6931 case 0x00:
6932 return VER_1_0;
6933 case 0x09: /* variant of bahama v2 */
6934 return VER_2_0;
6935 default:
6936 return VER_UNSUPPORTED;
6937 }
6938}
6939
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006940static int msm_bahama_setup_power_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006941static unsigned int msm_bahama_setup_power(void)
6942{
6943 int rc = 0;
6944 const char *msm_bahama_regulator = "8058_s3";
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006945
6946 if (machine_is_msm8x60_dragon())
6947 msm_bahama_sys_rst = GPIO_CDC_RST_N;
6948
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006949 vreg_bahama = regulator_get(NULL, msm_bahama_regulator);
6950
6951 if (IS_ERR(vreg_bahama)) {
6952 rc = PTR_ERR(vreg_bahama);
6953 pr_err("%s: regulator_get %s = %d\n", __func__,
6954 msm_bahama_regulator, rc);
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006955 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006956 }
6957
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006958 rc = regulator_set_voltage(vreg_bahama, 1800000, 1800000);
6959 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006960 pr_err("%s: regulator_set_voltage %s = %d\n", __func__,
6961 msm_bahama_regulator, rc);
6962 goto unget;
6963 }
6964
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006965 rc = regulator_enable(vreg_bahama);
6966 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006967 pr_err("%s: regulator_enable %s = %d\n", __func__,
6968 msm_bahama_regulator, rc);
6969 goto unget;
6970 }
6971
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006972 rc = gpio_request(msm_bahama_sys_rst, "bahama sys_rst_n");
6973 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006974 pr_err("%s: gpio_request %d = %d\n", __func__,
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006975 msm_bahama_sys_rst, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006976 goto unenable;
6977 }
6978
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006979 gpio_direction_output(msm_bahama_sys_rst, 0);
6980 usleep_range(1000, 1050);
6981 gpio_set_value_cansleep(msm_bahama_sys_rst, 1);
6982 usleep_range(1000, 1050);
6983 msm_bahama_setup_power_enable = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006984 return rc;
6985
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006986unenable:
6987 regulator_disable(vreg_bahama);
6988unget:
6989 regulator_put(vreg_bahama);
6990 return rc;
6991};
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006992
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006993static unsigned int msm_bahama_shutdown_power(int value)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006994{
Siddartha Mohanadoss7e8e9dd2011-09-27 19:04:58 -07006995 if (msm_bahama_setup_power_enable) {
6996 gpio_set_value_cansleep(msm_bahama_sys_rst, 0);
6997 gpio_free(msm_bahama_sys_rst);
6998 regulator_disable(vreg_bahama);
6999 regulator_put(vreg_bahama);
7000 msm_bahama_setup_power_enable = 0;
7001 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007002
7003 return 0;
7004};
7005
7006static unsigned int msm_bahama_core_config(int type)
7007{
7008 int rc = 0;
7009
7010 if (type == BAHAMA_ID) {
7011
7012 int i;
7013 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
7014
7015 const struct bahama_config_register v20_init[] = {
7016 /* reg, value, mask */
7017 { 0xF4, 0x84, 0xFF }, /* AREG */
7018 { 0xF0, 0x04, 0xFF } /* DREG */
7019 };
7020
7021 if (read_bahama_ver() == VER_2_0) {
7022 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
7023 u8 value = v20_init[i].value;
7024 rc = marimba_write_bit_mask(&config,
7025 v20_init[i].reg,
7026 &value,
7027 sizeof(v20_init[i].value),
7028 v20_init[i].mask);
7029 if (rc < 0) {
7030 printk(KERN_ERR
7031 "%s: reg %d write failed: %d\n",
7032 __func__, v20_init[i].reg, rc);
7033 return rc;
7034 }
7035 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
7036 " mask 0x%02x\n",
7037 __func__, v20_init[i].reg,
7038 v20_init[i].value, v20_init[i].mask);
7039 }
7040 }
7041 }
7042 printk(KERN_INFO "core type: %d\n", type);
7043
7044 return rc;
7045}
7046
7047static struct regulator *fm_regulator_s3;
7048static struct msm_xo_voter *fm_clock;
7049
7050static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
7051{
7052 int rc = 0;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307053 struct pm_gpio cfg = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007054 .direction = PM_GPIO_DIR_IN,
7055 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307056 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007057 .function = PM_GPIO_FUNC_NORMAL,
7058 .inv_int_pol = 0,
7059 };
7060
7061 if (!fm_regulator_s3) {
7062 fm_regulator_s3 = regulator_get(NULL, "8058_s3");
7063 if (IS_ERR(fm_regulator_s3)) {
7064 rc = PTR_ERR(fm_regulator_s3);
7065 printk(KERN_ERR "%s: regulator get s3 (%d)\n",
7066 __func__, rc);
7067 goto out;
7068 }
7069 }
7070
7071
7072 rc = regulator_set_voltage(fm_regulator_s3, 1800000, 1800000);
7073 if (rc < 0) {
7074 printk(KERN_ERR "%s: regulator set voltage failed (%d)\n",
7075 __func__, rc);
7076 goto fm_fail_put;
7077 }
7078
7079 rc = regulator_enable(fm_regulator_s3);
7080 if (rc < 0) {
7081 printk(KERN_ERR "%s: regulator s3 enable failed (%d)\n",
7082 __func__, rc);
7083 goto fm_fail_put;
7084 }
7085
7086 /*Vote for XO clock*/
7087 fm_clock = msm_xo_get(MSM_XO_TCXO_D0, "fm_power");
7088
7089 if (IS_ERR(fm_clock)) {
7090 rc = PTR_ERR(fm_clock);
7091 printk(KERN_ERR "%s: Couldn't get TCXO_D0 vote for FM (%d)\n",
7092 __func__, rc);
7093 goto fm_fail_switch;
7094 }
7095
7096 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_ON);
7097 if (rc < 0) {
7098 printk(KERN_ERR "%s: Failed to vote for TCX0_D0 ON (%d)\n",
7099 __func__, rc);
7100 goto fm_fail_vote;
7101 }
7102
7103 /*GPIO 18 on PMIC is FM_IRQ*/
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307104 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(FM_GPIO), &cfg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007105 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307106 printk(KERN_ERR "%s: return val of pm8xxx_gpio_config: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007107 __func__, rc);
7108 goto fm_fail_clock;
7109 }
7110 goto out;
7111
7112fm_fail_clock:
7113 msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7114fm_fail_vote:
7115 msm_xo_put(fm_clock);
7116fm_fail_switch:
7117 regulator_disable(fm_regulator_s3);
7118fm_fail_put:
7119 regulator_put(fm_regulator_s3);
7120out:
7121 return rc;
7122};
7123
7124static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
7125{
7126 int rc = 0;
7127 if (fm_regulator_s3 != NULL) {
7128 rc = regulator_disable(fm_regulator_s3);
7129 if (rc < 0) {
7130 printk(KERN_ERR "%s: regulator s3 disable (%d)\n",
7131 __func__, rc);
7132 }
7133 regulator_put(fm_regulator_s3);
7134 fm_regulator_s3 = NULL;
7135 }
7136 printk(KERN_ERR "%s: Voting off for XO", __func__);
7137
7138 if (fm_clock != NULL) {
7139 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
7140 if (rc < 0) {
7141 printk(KERN_ERR "%s: Voting off XO clock (%d)\n",
7142 __func__, rc);
7143 }
7144 msm_xo_put(fm_clock);
7145 }
7146 printk(KERN_ERR "%s: coming out of fm_radio_shutdown", __func__);
7147}
7148
7149/* Slave id address for FM/CDC/QMEMBIST
7150 * Values can be programmed using Marimba slave id 0
7151 * should there be a conflict with other I2C devices
7152 * */
7153#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
7154#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
7155
7156static struct marimba_fm_platform_data marimba_fm_pdata = {
7157 .fm_setup = fm_radio_setup,
7158 .fm_shutdown = fm_radio_shutdown,
7159 .irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, FM_GPIO),
7160 .is_fm_soc_i2s_master = false,
7161 .config_i2s_gpio = NULL,
7162};
7163
7164/*
7165Just initializing the BAHAMA related slave
7166*/
7167static struct marimba_platform_data marimba_pdata = {
7168 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
7169 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
7170 .bahama_setup = msm_bahama_setup_power,
7171 .bahama_shutdown = msm_bahama_shutdown_power,
7172 .bahama_core_config = msm_bahama_core_config,
7173 .fm = &marimba_fm_pdata,
7174 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
7175};
7176
7177
7178static struct i2c_board_info msm_marimba_board_info[] = {
7179 {
7180 I2C_BOARD_INFO("marimba", 0xc),
7181 .platform_data = &marimba_pdata,
7182 }
7183};
7184#endif /* CONFIG_MAIMBA_CORE */
7185
7186#ifdef CONFIG_I2C
7187#define I2C_SURF 1
7188#define I2C_FFA (1 << 1)
7189#define I2C_RUMI (1 << 2)
7190#define I2C_SIM (1 << 3)
7191#define I2C_FLUID (1 << 4)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007192#define I2C_DRAGON (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007193
7194struct i2c_registry {
7195 u8 machs;
7196 int bus;
7197 struct i2c_board_info *info;
7198 int len;
7199};
7200
7201static struct i2c_registry msm8x60_i2c_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007202#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7203 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007204 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007205 MSM_GSBI8_QUP_I2C_BUS_ID,
7206 core_expander_i2c_info,
7207 ARRAY_SIZE(core_expander_i2c_info),
7208 },
7209 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007210 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007211 MSM_GSBI8_QUP_I2C_BUS_ID,
7212 docking_expander_i2c_info,
7213 ARRAY_SIZE(docking_expander_i2c_info),
7214 },
7215 {
7216 I2C_SURF,
7217 MSM_GSBI8_QUP_I2C_BUS_ID,
7218 surf_expanders_i2c_info,
7219 ARRAY_SIZE(surf_expanders_i2c_info),
7220 },
7221 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007222 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007223 MSM_GSBI3_QUP_I2C_BUS_ID,
7224 fha_expanders_i2c_info,
7225 ARRAY_SIZE(fha_expanders_i2c_info),
7226 },
7227 {
7228 I2C_FLUID,
7229 MSM_GSBI3_QUP_I2C_BUS_ID,
7230 fluid_expanders_i2c_info,
7231 ARRAY_SIZE(fluid_expanders_i2c_info),
7232 },
7233 {
7234 I2C_FLUID,
7235 MSM_GSBI8_QUP_I2C_BUS_ID,
7236 fluid_core_expander_i2c_info,
7237 ARRAY_SIZE(fluid_core_expander_i2c_info),
7238 },
7239#endif
7240#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
7241 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
7242 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007243 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007244 MSM_GSBI3_QUP_I2C_BUS_ID,
7245 msm_i2c_gsbi3_tdisc_info,
7246 ARRAY_SIZE(msm_i2c_gsbi3_tdisc_info),
7247 },
7248#endif
7249 {
Zhang Chang Ken211df572011-07-05 19:16:39 -04007250 I2C_SURF | I2C_FFA | I2C_FLUID,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007251 MSM_GSBI3_QUP_I2C_BUS_ID,
7252 cy8ctmg200_board_info,
7253 ARRAY_SIZE(cy8ctmg200_board_info),
7254 },
Zhang Chang Ken211df572011-07-05 19:16:39 -04007255 {
7256 I2C_DRAGON,
7257 MSM_GSBI3_QUP_I2C_BUS_ID,
7258 cy8ctma340_dragon_board_info,
7259 ARRAY_SIZE(cy8ctma340_dragon_board_info),
7260 },
Steve Mucklef132c6c2012-06-06 18:30:57 -07007261#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
7262 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007263 {
7264 I2C_FLUID,
7265 MSM_GSBI3_QUP_I2C_BUS_ID,
7266 cyttsp_fluid_info,
7267 ARRAY_SIZE(cyttsp_fluid_info),
7268 },
7269 {
7270 I2C_FFA | I2C_SURF,
7271 MSM_GSBI3_QUP_I2C_BUS_ID,
7272 cyttsp_ffa_info,
7273 ARRAY_SIZE(cyttsp_ffa_info),
7274 },
7275#endif
7276#ifdef CONFIG_MSM_CAMERA
Kevin Chan3be11612012-03-22 20:05:40 -07007277#ifndef CONFIG_MSM_CAMERA_V4L2
Jilai Wang971f97f2011-07-13 14:25:25 -04007278 {
7279 I2C_SURF | I2C_FFA | I2C_FLUID ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007280 MSM_GSBI4_QUP_I2C_BUS_ID,
7281 msm_camera_boardinfo,
7282 ARRAY_SIZE(msm_camera_boardinfo),
7283 },
Jilai Wang971f97f2011-07-13 14:25:25 -04007284 {
7285 I2C_DRAGON,
7286 MSM_GSBI4_QUP_I2C_BUS_ID,
7287 msm_camera_dragon_boardinfo,
7288 ARRAY_SIZE(msm_camera_dragon_boardinfo),
7289 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007290#endif
Kevin Chan3be11612012-03-22 20:05:40 -07007291#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007292 {
7293 I2C_SURF | I2C_FFA | I2C_FLUID,
7294 MSM_GSBI7_QUP_I2C_BUS_ID,
7295 msm_i2c_gsbi7_timpani_info,
7296 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info),
7297 },
7298#if defined(CONFIG_MARIMBA_CORE)
7299 {
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04007300 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007301 MSM_GSBI7_QUP_I2C_BUS_ID,
7302 msm_marimba_board_info,
7303 ARRAY_SIZE(msm_marimba_board_info),
7304 },
7305#endif /* CONFIG_MARIMBA_CORE */
7306#ifdef CONFIG_ISL9519_CHARGER
7307 {
7308 I2C_SURF | I2C_FFA,
7309 MSM_GSBI8_QUP_I2C_BUS_ID,
7310 isl_charger_i2c_info,
7311 ARRAY_SIZE(isl_charger_i2c_info),
7312 },
7313#endif
7314#if defined(CONFIG_HAPTIC_ISA1200) || \
7315 defined(CONFIG_HAPTIC_ISA1200_MODULE)
7316 {
7317 I2C_FLUID,
7318 MSM_GSBI8_QUP_I2C_BUS_ID,
7319 msm_isa1200_board_info,
7320 ARRAY_SIZE(msm_isa1200_board_info),
7321 },
7322#endif
7323#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
7324 {
7325 I2C_FLUID,
7326 MSM_GSBI8_QUP_I2C_BUS_ID,
7327 smb137b_charger_i2c_info,
7328 ARRAY_SIZE(smb137b_charger_i2c_info),
7329 },
7330#endif
7331#if defined(CONFIG_BATTERY_BQ27520) || \
7332 defined(CONFIG_BATTERY_BQ27520_MODULE)
7333 {
7334 I2C_FLUID,
7335 MSM_GSBI8_QUP_I2C_BUS_ID,
7336 msm_bq27520_board_info,
7337 ARRAY_SIZE(msm_bq27520_board_info),
7338 },
7339#endif
Lei Zhou338cab82011-08-19 13:38:17 -04007340#if defined(CONFIG_SND_SOC_WM8903) || defined(CONFIG_SND_SOC_WM8903_MODULE)
7341 {
7342 I2C_DRAGON,
7343 MSM_GSBI8_QUP_I2C_BUS_ID,
7344 wm8903_codec_i2c_info,
7345 ARRAY_SIZE(wm8903_codec_i2c_info),
7346 },
7347#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007348};
7349#endif /* CONFIG_I2C */
7350
Stephen Boyd668d7652012-04-25 11:31:01 -07007351static void __init fixup_i2c_configs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007352{
7353#ifdef CONFIG_I2C
7354#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7355 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7356 sx150x_data[SX150X_CORE].irq_summary =
7357 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT2_N);
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007358 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
7359 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007360 sx150x_data[SX150X_CORE].irq_summary =
7361 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7362 else if (machine_is_msm8x60_fluid())
7363 sx150x_data[SX150X_CORE_FLUID].irq_summary =
7364 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7365#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007366#endif
7367}
7368
Stephen Boyd668d7652012-04-25 11:31:01 -07007369static void __init register_i2c_devices(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007370{
7371#ifdef CONFIG_I2C
7372 u8 mach_mask = 0;
7373 int i;
Kevin Chan3be11612012-03-22 20:05:40 -07007374#ifdef CONFIG_MSM_CAMERA_V4L2
7375 struct i2c_registry msm8x60_camera_i2c_devices = {
7376 I2C_SURF | I2C_FFA | I2C_FLUID,
7377 MSM_GSBI4_QUP_I2C_BUS_ID,
7378 msm8x60_camera_board_info.board_info,
7379 msm8x60_camera_board_info.num_i2c_board_info,
7380 };
7381#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007382
7383 /* Build the matching 'supported_machs' bitmask */
7384 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7385 mach_mask = I2C_SURF;
7386 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
7387 mach_mask = I2C_FFA;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007388 else if (machine_is_msm8x60_fluid())
7389 mach_mask = I2C_FLUID;
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007390 else if (machine_is_msm8x60_dragon())
7391 mach_mask = I2C_DRAGON;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007392 else
7393 pr_err("unmatched machine ID in register_i2c_devices\n");
7394
7395 /* Run the array and install devices as appropriate */
7396 for (i = 0; i < ARRAY_SIZE(msm8x60_i2c_devices); ++i) {
7397 if (msm8x60_i2c_devices[i].machs & mach_mask)
7398 i2c_register_board_info(msm8x60_i2c_devices[i].bus,
7399 msm8x60_i2c_devices[i].info,
7400 msm8x60_i2c_devices[i].len);
7401 }
Kevin Chan3be11612012-03-22 20:05:40 -07007402#ifdef CONFIG_MSM_CAMERA_V4L2
7403 if (msm8x60_camera_i2c_devices.machs & mach_mask)
7404 i2c_register_board_info(msm8x60_camera_i2c_devices.bus,
7405 msm8x60_camera_i2c_devices.info,
7406 msm8x60_camera_i2c_devices.len);
7407#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007408#endif
7409}
7410
7411static void __init msm8x60_init_uart12dm(void)
7412{
7413#if !defined(CONFIG_USB_PEHCI_HCD) && !defined(CONFIG_USB_PEHCI_HCD_MODULE)
7414 /* 0x1D000000 now belongs to EBI2:CS3 i.e. USB ISP Controller */
7415 void *fpga_mem = ioremap_nocache(0x1D000000, SZ_4K);
7416
7417 if (!fpga_mem)
7418 pr_err("%s(): Error getting memory\n", __func__);
7419
7420 /* Advanced mode */
7421 writew(0xFFFF, fpga_mem + 0x15C);
7422 /* FPGA_UART_SEL */
7423 writew(0, fpga_mem + 0x172);
7424 /* FPGA_GPIO_CONFIG_117 */
7425 writew(1, fpga_mem + 0xEA);
7426 /* FPGA_GPIO_CONFIG_118 */
7427 writew(1, fpga_mem + 0xEC);
7428 mb();
7429 iounmap(fpga_mem);
7430#endif
7431}
7432
7433#define MSM_GSBI9_PHYS 0x19900000
7434#define GSBI_DUAL_MODE_CODE 0x60
7435
7436static void __init msm8x60_init_buses(void)
7437{
7438#ifdef CONFIG_I2C_QUP
7439 void *gsbi_mem = ioremap_nocache(0x19C00000, 4);
7440 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI12 */
7441 writel_relaxed(0x6 << 4, gsbi_mem);
7442 /* Ensure protocol code is written before proceeding further */
7443 mb();
7444 iounmap(gsbi_mem);
7445
7446 msm_gsbi3_qup_i2c_device.dev.platform_data = &msm_gsbi3_qup_i2c_pdata;
7447 msm_gsbi4_qup_i2c_device.dev.platform_data = &msm_gsbi4_qup_i2c_pdata;
7448 msm_gsbi7_qup_i2c_device.dev.platform_data = &msm_gsbi7_qup_i2c_pdata;
7449 msm_gsbi8_qup_i2c_device.dev.platform_data = &msm_gsbi8_qup_i2c_pdata;
7450
7451#ifdef CONFIG_MSM_GSBI9_UART
7452 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7453 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI9 */
7454 gsbi_mem = ioremap_nocache(MSM_GSBI9_PHYS, 4);
7455 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
7456 iounmap(gsbi_mem);
7457 msm_gsbi9_qup_i2c_pdata.use_gsbi_shared_mode = 1;
7458 }
7459#endif
7460 msm_gsbi9_qup_i2c_device.dev.platform_data = &msm_gsbi9_qup_i2c_pdata;
7461 msm_gsbi12_qup_i2c_device.dev.platform_data = &msm_gsbi12_qup_i2c_pdata;
7462#endif
7463#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7464 msm_gsbi1_qup_spi_device.dev.platform_data = &msm_gsbi1_qup_spi_pdata;
7465#endif
7466#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007467 msm_device_ssbi3.dev.platform_data = &msm_ssbi3_pdata;
7468#endif
7469
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307470#ifdef CONFIG_MSM_SSBI
7471 msm_device_ssbi_pmic1.dev.platform_data =
7472 &msm8x60_ssbi_pm8058_pdata;
Anirudh Ghayalc49157f2011-11-09 14:49:59 +05307473 msm_device_ssbi_pmic2.dev.platform_data =
7474 &msm8x60_ssbi_pm8901_pdata;
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307475#endif
7476
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007477 if (machine_is_msm8x60_fluid()) {
7478#if (defined(CONFIG_USB_EHCI_MSM_72K) && \
7479 (defined(CONFIG_SMB137B_CHARGER) || \
7480 defined(CONFIG_SMB137B_CHARGER_MODULE)))
7481 msm_otg_pdata.vbus_power = msm_hsusb_smb137b_vbus_power;
7482#endif
7483#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7484 msm_gsbi10_qup_spi_device.dev.platform_data =
7485 &msm_gsbi10_qup_spi_pdata;
7486#endif
7487 }
7488
Lena Salman57d167e2012-03-21 19:46:38 +02007489#if defined(CONFIG_USB_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007490 /*
7491 * We can not put USB regulators (8058_l6 and 8058_l7) in LPM
7492 * when we depend on USB PHY for VBUS/ID notifications. VBUS
7493 * and ID notifications are available only on V2 surf and FFA
7494 * with a hardware workaround.
7495 */
7496 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 &&
7497 (machine_is_msm8x60_surf() ||
7498 (machine_is_msm8x60_ffa() &&
7499 pmic_id_notif_supported)))
7500 msm_otg_pdata.phy_can_powercollapse = 1;
7501 msm_device_otg.dev.platform_data = &msm_otg_pdata;
7502#endif
7503
Lena Salman57d167e2012-03-21 19:46:38 +02007504#ifdef CONFIG_USB_MSM_72K
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007505 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
7506#endif
7507
7508#ifdef CONFIG_SERIAL_MSM_HS
7509 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(54); /* GSBI6(2) */
7510 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
7511#endif
7512#ifdef CONFIG_MSM_GSBI9_UART
7513 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7514 msm_device_uart_gsbi9 = msm_add_gsbi9_uart();
7515 if (IS_ERR(msm_device_uart_gsbi9))
7516 pr_err("%s(): Failed to create uart gsbi9 device\n",
7517 __func__);
7518 }
7519#endif
7520
7521#ifdef CONFIG_MSM_BUS_SCALING
7522
7523 /* RPM calls are only enabled on V2 */
7524 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2) {
7525 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
7526 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
7527 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
7528 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
7529 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
7530 }
7531
7532 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
7533 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
7534 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
7535 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
7536 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
7537#endif
Stephen Boyd9e775ad2011-08-12 00:14:28 +01007538}
Steve Mucklea55df6e2010-01-07 12:43:24 -08007539
7540static void __init msm8x60_map_io(void)
7541{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007542 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Steve Mucklea55df6e2010-01-07 12:43:24 -08007543 msm_map_msm8x60_io();
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -08007544 if (IS_ERR_OR_NULL(socinfo_init()))
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007545 pr_err("socinfo_init() failed!\n");
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -08007546
Steve Mucklea55df6e2010-01-07 12:43:24 -08007547}
7548
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007549/*
7550 * Most segments of the EBI2 bus are disabled by default.
7551 */
7552static void __init msm8x60_init_ebi2(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08007553{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007554 uint32_t ebi2_cfg;
7555 void *ebi2_cfg_ptr;
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007556 struct clk *mem_clk = clk_get_sys("msm_ebi2", "mem_clk");
Steve Mucklea55df6e2010-01-07 12:43:24 -08007557
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007558 if (IS_ERR(mem_clk)) {
7559 pr_err("%s: clk_get_sys(%s,%s), failed", __func__,
7560 "msm_ebi2", "mem_clk");
7561 return;
7562 }
Stephen Boyd818a3f62012-05-08 12:12:18 -07007563 clk_prepare_enable(mem_clk);
Terence Hampsonb36a38c2011-09-19 19:10:40 -04007564 clk_put(mem_clk);
Steve Mucklea55df6e2010-01-07 12:43:24 -08007565
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007566 ebi2_cfg_ptr = ioremap_nocache(0x1a100000, sizeof(uint32_t));
7567 if (ebi2_cfg_ptr != 0) {
7568 ebi2_cfg = readl_relaxed(ebi2_cfg_ptr);
Steve Mucklea55df6e2010-01-07 12:43:24 -08007569
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007570 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007571 machine_is_msm8x60_fluid() ||
7572 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007573 ebi2_cfg |= (1 << 4) | (1 << 5); /* CS2, CS3 */
Steve Mucklea55df6e2010-01-07 12:43:24 -08007574
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007575 writel_relaxed(ebi2_cfg, ebi2_cfg_ptr);
7576 iounmap(ebi2_cfg_ptr);
David Brown56e2d8a2011-08-04 02:01:02 -07007577 }
7578
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007579 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007580 machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007581 ebi2_cfg_ptr = ioremap_nocache(0x1a110000, SZ_4K);
7582 if (ebi2_cfg_ptr != 0) {
7583 /* EBI2_XMEM_CFG:PWRSAVE_MODE off */
7584 writel_relaxed(0UL, ebi2_cfg_ptr);
7585
7586 /* CS2: Delay 9 cycles (140ns@64MHz) between SMSC
7587 * LAN9221 Ethernet controller reads and writes.
7588 * The lowest 4 bits are the read delay, the next
7589 * 4 are the write delay. */
7590 writel_relaxed(0x031F1C99, ebi2_cfg_ptr + 0x10);
7591#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
7592 /*
7593 * RECOVERY=5, HOLD_WR=1
7594 * INIT_LATENCY_WR=1, INIT_LATENCY_RD=1
7595 * WAIT_WR=1, WAIT_RD=2
7596 */
7597 writel_relaxed(0x51010112, ebi2_cfg_ptr + 0x14);
7598 /*
7599 * HOLD_RD=1
7600 * ADV_OE_RECOVERY=0, ADDR_HOLD_ENA=1
7601 */
7602 writel_relaxed(0x01000020, ebi2_cfg_ptr + 0x34);
7603#else
7604 /* EBI2 CS3 muxed address/data,
7605 * two cyc addr enable */
7606 writel_relaxed(0xA3030020, ebi2_cfg_ptr + 0x34);
7607
7608#endif
7609 iounmap(ebi2_cfg_ptr);
7610 }
7611 }
David Brown56e2d8a2011-08-04 02:01:02 -07007612}
7613
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007614#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
7615 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
7616 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
7617 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\
7618 || defined(CONFIG_MMC_MSM_SDC5_SUPPORT))
7619
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007620/* 8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007621#define MAX_SDCC_CONTROLLER 5
7622
7623struct msm_sdcc_gpio {
7624 /* maximum 10 GPIOs per SDCC controller */
7625 s16 no;
7626 /* name of this GPIO */
7627 const char *name;
7628 bool always_on;
7629 bool is_enabled;
David Brown56e2d8a2011-08-04 02:01:02 -07007630};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007631
7632#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7633static struct msm_sdcc_gpio sdc1_gpio_cfg[] = {
7634 {159, "sdc1_dat_0"},
7635 {160, "sdc1_dat_1"},
7636 {161, "sdc1_dat_2"},
7637 {162, "sdc1_dat_3"},
7638#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
7639 {163, "sdc1_dat_4"},
7640 {164, "sdc1_dat_5"},
7641 {165, "sdc1_dat_6"},
7642 {166, "sdc1_dat_7"},
7643#endif
7644 {167, "sdc1_clk"},
7645 {168, "sdc1_cmd"}
7646};
7647#endif
7648
7649#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7650static struct msm_sdcc_gpio sdc2_gpio_cfg[] = {
7651 {143, "sdc2_dat_0"},
7652 {144, "sdc2_dat_1", 1},
7653 {145, "sdc2_dat_2"},
7654 {146, "sdc2_dat_3"},
7655#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
7656 {147, "sdc2_dat_4"},
7657 {148, "sdc2_dat_5"},
7658 {149, "sdc2_dat_6"},
7659 {150, "sdc2_dat_7"},
7660#endif
7661 {151, "sdc2_cmd"},
7662 {152, "sdc2_clk", 1}
7663};
7664#endif
7665
7666#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7667static struct msm_sdcc_gpio sdc5_gpio_cfg[] = {
7668 {95, "sdc5_cmd"},
7669 {96, "sdc5_dat_3"},
7670 {97, "sdc5_clk", 1},
7671 {98, "sdc5_dat_2"},
7672 {99, "sdc5_dat_1", 1},
7673 {100, "sdc5_dat_0"}
7674};
7675#endif
7676
7677struct msm_sdcc_pad_pull_cfg {
7678 enum msm_tlmm_pull_tgt pull;
7679 u32 pull_val;
7680};
7681
7682struct msm_sdcc_pad_drv_cfg {
7683 enum msm_tlmm_hdrive_tgt drv;
7684 u32 drv_val;
7685};
7686
7687#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7688static struct msm_sdcc_pad_drv_cfg sdc3_pad_on_drv_cfg[] = {
7689 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
7690 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
7691 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
7692};
7693
7694static struct msm_sdcc_pad_pull_cfg sdc3_pad_on_pull_cfg[] = {
7695 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
7696 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
7697};
7698
7699static struct msm_sdcc_pad_drv_cfg sdc3_pad_off_drv_cfg[] = {
7700 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
7701 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
7702 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
7703};
7704
7705static struct msm_sdcc_pad_pull_cfg sdc3_pad_off_pull_cfg[] = {
7706 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
7707 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
7708};
7709#endif
7710
7711#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7712static struct msm_sdcc_pad_drv_cfg sdc4_pad_on_drv_cfg[] = {
7713 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_8MA},
7714 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_8MA},
7715 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_8MA}
7716};
7717
7718static struct msm_sdcc_pad_pull_cfg sdc4_pad_on_pull_cfg[] = {
7719 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_UP},
7720 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_UP}
7721};
7722
7723static struct msm_sdcc_pad_drv_cfg sdc4_pad_off_drv_cfg[] = {
7724 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_2MA},
7725 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_2MA},
7726 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_2MA}
7727};
7728
7729static struct msm_sdcc_pad_pull_cfg sdc4_pad_off_pull_cfg[] = {
7730 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_DOWN},
7731 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_DOWN}
7732};
7733#endif
7734
7735struct msm_sdcc_pin_cfg {
7736 /*
7737 * = 1 if controller pins are using gpios
7738 * = 0 if controller has dedicated MSM pins
7739 */
7740 u8 is_gpio;
7741 u8 cfg_sts;
7742 u8 gpio_data_size;
7743 struct msm_sdcc_gpio *gpio_data;
7744 struct msm_sdcc_pad_drv_cfg *pad_drv_on_data;
7745 struct msm_sdcc_pad_drv_cfg *pad_drv_off_data;
7746 struct msm_sdcc_pad_pull_cfg *pad_pull_on_data;
7747 struct msm_sdcc_pad_pull_cfg *pad_pull_off_data;
7748 u8 pad_drv_data_size;
7749 u8 pad_pull_data_size;
7750 u8 sdio_lpm_gpio_cfg;
7751};
7752
7753
7754static struct msm_sdcc_pin_cfg sdcc_pin_cfg_data[MAX_SDCC_CONTROLLER] = {
7755#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7756 [0] = {
7757 .is_gpio = 1,
7758 .gpio_data_size = ARRAY_SIZE(sdc1_gpio_cfg),
7759 .gpio_data = sdc1_gpio_cfg
7760 },
7761#endif
7762#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7763 [1] = {
7764 .is_gpio = 1,
7765 .gpio_data_size = ARRAY_SIZE(sdc2_gpio_cfg),
7766 .gpio_data = sdc2_gpio_cfg
7767 },
7768#endif
7769#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7770 [2] = {
7771 .is_gpio = 0,
7772 .pad_drv_on_data = sdc3_pad_on_drv_cfg,
7773 .pad_drv_off_data = sdc3_pad_off_drv_cfg,
7774 .pad_pull_on_data = sdc3_pad_on_pull_cfg,
7775 .pad_pull_off_data = sdc3_pad_off_pull_cfg,
7776 .pad_drv_data_size = ARRAY_SIZE(sdc3_pad_on_drv_cfg),
7777 .pad_pull_data_size = ARRAY_SIZE(sdc3_pad_on_pull_cfg)
7778 },
7779#endif
7780#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7781 [3] = {
7782 .is_gpio = 0,
7783 .pad_drv_on_data = sdc4_pad_on_drv_cfg,
7784 .pad_drv_off_data = sdc4_pad_off_drv_cfg,
7785 .pad_pull_on_data = sdc4_pad_on_pull_cfg,
7786 .pad_pull_off_data = sdc4_pad_off_pull_cfg,
7787 .pad_drv_data_size = ARRAY_SIZE(sdc4_pad_on_drv_cfg),
7788 .pad_pull_data_size = ARRAY_SIZE(sdc4_pad_on_pull_cfg)
7789 },
7790#endif
7791#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7792 [4] = {
7793 .is_gpio = 1,
7794 .gpio_data_size = ARRAY_SIZE(sdc5_gpio_cfg),
7795 .gpio_data = sdc5_gpio_cfg
7796 }
7797#endif
7798};
7799
7800static int msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
7801{
7802 int rc = 0;
7803 struct msm_sdcc_pin_cfg *curr;
7804 int n;
7805
7806 curr = &sdcc_pin_cfg_data[dev_id - 1];
7807 if (!curr->gpio_data)
7808 goto out;
7809
7810 for (n = 0; n < curr->gpio_data_size; n++) {
7811 if (enable) {
7812
7813 if (curr->gpio_data[n].always_on &&
7814 curr->gpio_data[n].is_enabled)
7815 continue;
7816 pr_debug("%s: enable: %s\n", __func__,
7817 curr->gpio_data[n].name);
7818 rc = gpio_request(curr->gpio_data[n].no,
7819 curr->gpio_data[n].name);
7820 if (rc) {
7821 pr_err("%s: gpio_request(%d, %s)"
7822 "failed", __func__,
7823 curr->gpio_data[n].no,
7824 curr->gpio_data[n].name);
7825 goto free_gpios;
7826 }
7827 /* set direction as output for all GPIOs */
7828 rc = gpio_direction_output(
7829 curr->gpio_data[n].no, 1);
7830 if (rc) {
7831 pr_err("%s: gpio_direction_output"
7832 "(%d, 1) failed\n", __func__,
7833 curr->gpio_data[n].no);
7834 goto free_gpios;
7835 }
7836 curr->gpio_data[n].is_enabled = 1;
7837 } else {
7838 /*
7839 * now free this GPIO which will put GPIO
7840 * in low power mode and will also put GPIO
7841 * in input mode
7842 */
7843 if (curr->gpio_data[n].always_on)
7844 continue;
7845 pr_debug("%s: disable: %s\n", __func__,
7846 curr->gpio_data[n].name);
7847 gpio_free(curr->gpio_data[n].no);
7848 curr->gpio_data[n].is_enabled = 0;
7849 }
7850 }
7851 curr->cfg_sts = enable;
7852 goto out;
7853
7854free_gpios:
7855 for (; n >= 0; n--)
7856 gpio_free(curr->gpio_data[n].no);
7857out:
7858 return rc;
7859}
7860
7861static int msm_sdcc_setup_pad(int dev_id, unsigned int enable)
7862{
7863 int rc = 0;
7864 struct msm_sdcc_pin_cfg *curr;
7865 int n;
7866
7867 curr = &sdcc_pin_cfg_data[dev_id - 1];
7868 if (!curr->pad_drv_on_data || !curr->pad_pull_on_data)
7869 goto out;
7870
7871 if (enable) {
7872 /*
7873 * set up the normal driver strength and
7874 * pull config for pads
7875 */
7876 for (n = 0; n < curr->pad_drv_data_size; n++) {
7877 if (curr->sdio_lpm_gpio_cfg) {
7878 if (curr->pad_drv_on_data[n].drv ==
7879 TLMM_HDRV_SDC4_DATA)
7880 continue;
7881 }
7882 msm_tlmm_set_hdrive(curr->pad_drv_on_data[n].drv,
7883 curr->pad_drv_on_data[n].drv_val);
7884 }
7885 for (n = 0; n < curr->pad_pull_data_size; n++) {
7886 if (curr->sdio_lpm_gpio_cfg) {
7887 if (curr->pad_pull_on_data[n].pull ==
7888 TLMM_PULL_SDC4_DATA)
7889 continue;
7890 }
7891 msm_tlmm_set_pull(curr->pad_pull_on_data[n].pull,
7892 curr->pad_pull_on_data[n].pull_val);
7893 }
7894 } else {
7895 /* set the low power config for pads */
7896 for (n = 0; n < curr->pad_drv_data_size; n++) {
7897 if (curr->sdio_lpm_gpio_cfg) {
7898 if (curr->pad_drv_off_data[n].drv ==
7899 TLMM_HDRV_SDC4_DATA)
7900 continue;
7901 }
7902 msm_tlmm_set_hdrive(
7903 curr->pad_drv_off_data[n].drv,
7904 curr->pad_drv_off_data[n].drv_val);
7905 }
7906 for (n = 0; n < curr->pad_pull_data_size; n++) {
7907 if (curr->sdio_lpm_gpio_cfg) {
7908 if (curr->pad_pull_off_data[n].pull ==
7909 TLMM_PULL_SDC4_DATA)
7910 continue;
7911 }
7912 msm_tlmm_set_pull(
7913 curr->pad_pull_off_data[n].pull,
7914 curr->pad_pull_off_data[n].pull_val);
7915 }
7916 }
7917 curr->cfg_sts = enable;
7918out:
7919 return rc;
7920}
7921
7922struct sdcc_reg {
7923 /* VDD/VCC/VCCQ regulator name on PMIC8058/PMIC8089*/
7924 const char *reg_name;
7925 /*
7926 * is set voltage supported for this regulator?
7927 * 0 = not supported, 1 = supported
7928 */
7929 unsigned char set_voltage_sup;
7930 /* voltage level to be set */
7931 unsigned int level;
7932 /* VDD/VCC/VCCQ voltage regulator handle */
7933 struct regulator *reg;
7934 /* is this regulator enabled? */
7935 bool enabled;
7936 /* is this regulator needs to be always on? */
7937 bool always_on;
7938 /* is operating power mode setting required for this regulator? */
7939 bool op_pwr_mode_sup;
7940 /* Load values for low power and high power mode */
7941 unsigned int lpm_uA;
7942 unsigned int hpm_uA;
7943};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007944/* all SDCC controllers require VDD/VCC voltage */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007945static struct sdcc_reg sdcc_vdd_reg_data[MAX_SDCC_CONTROLLER];
7946/* only SDCC1 requires VCCQ voltage */
7947static struct sdcc_reg sdcc_vccq_reg_data[1];
7948/* all SDCC controllers may require voting for VDD PAD voltage */
7949static struct sdcc_reg sdcc_vddp_reg_data[MAX_SDCC_CONTROLLER];
7950
7951struct sdcc_reg_data {
7952 struct sdcc_reg *vdd_data; /* keeps VDD/VCC regulator info */
7953 struct sdcc_reg *vccq_data; /* keeps VCCQ regulator info */
7954 struct sdcc_reg *vddp_data; /* keeps VDD Pad regulator info */
7955 unsigned char sts; /* regulator enable/disable status */
7956};
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -07007957/* msm8x60 has 5 SDCC controllers */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007958static struct sdcc_reg_data sdcc_vreg_data[MAX_SDCC_CONTROLLER];
7959
7960static int msm_sdcc_vreg_init_reg(struct sdcc_reg *vreg)
7961{
7962 int rc = 0;
7963
7964 /* Get the regulator handle */
7965 vreg->reg = regulator_get(NULL, vreg->reg_name);
7966 if (IS_ERR(vreg->reg)) {
7967 rc = PTR_ERR(vreg->reg);
7968 pr_err("%s: regulator_get(%s) failed. rc=%d\n",
7969 __func__, vreg->reg_name, rc);
7970 goto out;
7971 }
7972
7973 /* Set the voltage level if required */
7974 if (vreg->set_voltage_sup) {
7975 rc = regulator_set_voltage(vreg->reg, vreg->level,
7976 vreg->level);
7977 if (rc) {
7978 pr_err("%s: regulator_set_voltage(%s) failed rc=%d\n",
7979 __func__, vreg->reg_name, rc);
7980 goto vreg_put;
7981 }
7982 }
7983 goto out;
7984
7985vreg_put:
7986 regulator_put(vreg->reg);
7987out:
7988 return rc;
7989}
7990
7991static inline void msm_sdcc_vreg_deinit_reg(struct sdcc_reg *vreg)
7992{
7993 regulator_put(vreg->reg);
7994}
7995
7996/* this init function should be called only once for each SDCC */
7997static int msm_sdcc_vreg_init(int dev_id, unsigned char init)
7998{
7999 int rc = 0;
8000 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
8001 struct sdcc_reg_data *curr;
8002
8003 curr = &sdcc_vreg_data[dev_id - 1];
8004 curr_vdd_reg = curr->vdd_data;
8005 curr_vccq_reg = curr->vccq_data;
8006 curr_vddp_reg = curr->vddp_data;
8007
8008 if (init) {
8009 /*
8010 * get the regulator handle from voltage regulator framework
8011 * and then try to set the voltage level for the regulator
8012 */
8013 if (curr_vdd_reg) {
8014 rc = msm_sdcc_vreg_init_reg(curr_vdd_reg);
8015 if (rc)
8016 goto out;
8017 }
8018 if (curr_vccq_reg) {
8019 rc = msm_sdcc_vreg_init_reg(curr_vccq_reg);
8020 if (rc)
8021 goto vdd_reg_deinit;
8022 }
8023 if (curr_vddp_reg) {
8024 rc = msm_sdcc_vreg_init_reg(curr_vddp_reg);
8025 if (rc)
8026 goto vccq_reg_deinit;
8027 }
8028 goto out;
8029 } else
8030 /* deregister with all regulators from regulator framework */
8031 goto vddp_reg_deinit;
8032
8033vddp_reg_deinit:
8034 if (curr_vddp_reg)
8035 msm_sdcc_vreg_deinit_reg(curr_vddp_reg);
8036vccq_reg_deinit:
8037 if (curr_vccq_reg)
8038 msm_sdcc_vreg_deinit_reg(curr_vccq_reg);
8039vdd_reg_deinit:
8040 if (curr_vdd_reg)
8041 msm_sdcc_vreg_deinit_reg(curr_vdd_reg);
8042out:
8043 return rc;
8044}
8045
8046static int msm_sdcc_vreg_enable(struct sdcc_reg *vreg)
8047{
8048 int rc;
8049
8050 if (!vreg->enabled) {
8051 rc = regulator_enable(vreg->reg);
8052 if (rc) {
8053 pr_err("%s: regulator_enable(%s) failed. rc=%d\n",
8054 __func__, vreg->reg_name, rc);
8055 goto out;
8056 }
8057 vreg->enabled = 1;
8058 }
8059
8060 /* Put always_on regulator in HPM (high power mode) */
8061 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8062 rc = regulator_set_optimum_mode(vreg->reg, vreg->hpm_uA);
8063 if (rc < 0) {
8064 pr_err("%s: reg=%s: HPM setting failed"
8065 " hpm_uA=%d, rc=%d\n",
8066 __func__, vreg->reg_name,
8067 vreg->hpm_uA, rc);
8068 goto vreg_disable;
8069 }
8070 rc = 0;
8071 }
8072 goto out;
8073
8074vreg_disable:
8075 regulator_disable(vreg->reg);
8076 vreg->enabled = 0;
8077out:
8078 return rc;
8079}
8080
8081static int msm_sdcc_vreg_disable(struct sdcc_reg *vreg)
8082{
8083 int rc;
8084
8085 /* Never disable always_on regulator */
8086 if (!vreg->always_on) {
8087 rc = regulator_disable(vreg->reg);
8088 if (rc) {
8089 pr_err("%s: regulator_disable(%s) failed. rc=%d\n",
8090 __func__, vreg->reg_name, rc);
8091 goto out;
8092 }
8093 vreg->enabled = 0;
8094 }
8095
8096 /* Put always_on regulator in LPM (low power mode) */
8097 if (vreg->always_on && vreg->op_pwr_mode_sup) {
8098 rc = regulator_set_optimum_mode(vreg->reg, vreg->lpm_uA);
8099 if (rc < 0) {
8100 pr_err("%s: reg=%s: LPM setting failed"
8101 " lpm_uA=%d, rc=%d\n",
8102 __func__,
8103 vreg->reg_name,
8104 vreg->lpm_uA, rc);
8105 goto out;
8106 }
8107 rc = 0;
8108 }
8109
8110out:
8111 return rc;
8112}
8113
8114static int msm_sdcc_setup_vreg(int dev_id, unsigned char enable)
8115{
8116 int rc = 0;
8117 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
8118 struct sdcc_reg_data *curr;
8119
8120 curr = &sdcc_vreg_data[dev_id - 1];
8121 curr_vdd_reg = curr->vdd_data;
8122 curr_vccq_reg = curr->vccq_data;
8123 curr_vddp_reg = curr->vddp_data;
8124
8125 /* check if regulators are initialized or not? */
8126 if ((curr_vdd_reg && !curr_vdd_reg->reg) ||
8127 (curr_vccq_reg && !curr_vccq_reg->reg) ||
8128 (curr_vddp_reg && !curr_vddp_reg->reg)) {
8129 /* initialize voltage regulators required for this SDCC */
8130 rc = msm_sdcc_vreg_init(dev_id, 1);
8131 if (rc) {
8132 pr_err("%s: regulator init failed = %d\n",
8133 __func__, rc);
8134 goto out;
8135 }
8136 }
8137
8138 if (curr->sts == enable)
8139 goto out;
8140
8141 if (curr_vdd_reg) {
8142 if (enable)
8143 rc = msm_sdcc_vreg_enable(curr_vdd_reg);
8144 else
8145 rc = msm_sdcc_vreg_disable(curr_vdd_reg);
8146 if (rc)
8147 goto out;
8148 }
8149
8150 if (curr_vccq_reg) {
8151 if (enable)
8152 rc = msm_sdcc_vreg_enable(curr_vccq_reg);
8153 else
8154 rc = msm_sdcc_vreg_disable(curr_vccq_reg);
8155 if (rc)
8156 goto out;
8157 }
8158
8159 if (curr_vddp_reg) {
8160 if (enable)
8161 rc = msm_sdcc_vreg_enable(curr_vddp_reg);
8162 else
8163 rc = msm_sdcc_vreg_disable(curr_vddp_reg);
8164 if (rc)
8165 goto out;
8166 }
8167 curr->sts = enable;
8168
8169out:
8170 return rc;
8171}
8172
8173static u32 msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
8174{
8175 u32 rc_pin_cfg = 0;
8176 u32 rc_vreg_cfg = 0;
8177 u32 rc = 0;
8178 struct platform_device *pdev;
8179 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8180
8181 pdev = container_of(dv, struct platform_device, dev);
8182
8183 /* setup gpio/pad */
8184 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8185 if (curr_pin_cfg->cfg_sts == !!vdd)
8186 goto setup_vreg;
8187
8188 if (curr_pin_cfg->is_gpio)
8189 rc_pin_cfg = msm_sdcc_setup_gpio(pdev->id, !!vdd);
8190 else
8191 rc_pin_cfg = msm_sdcc_setup_pad(pdev->id, !!vdd);
8192
8193setup_vreg:
8194 /* setup voltage regulators */
8195 rc_vreg_cfg = msm_sdcc_setup_vreg(pdev->id, !!vdd);
8196
8197 if (rc_pin_cfg || rc_vreg_cfg)
8198 rc = rc_pin_cfg ? rc_pin_cfg : rc_vreg_cfg;
8199
8200 return rc;
8201}
8202
8203static void msm_sdcc_sdio_lpm_gpio(struct device *dv, unsigned int active)
8204{
8205 struct msm_sdcc_pin_cfg *curr_pin_cfg;
8206 struct platform_device *pdev;
8207
8208 pdev = container_of(dv, struct platform_device, dev);
8209 /* setup gpio/pad */
8210 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
8211
8212 if (curr_pin_cfg->cfg_sts == active)
8213 return;
8214
8215 curr_pin_cfg->sdio_lpm_gpio_cfg = 1;
8216 if (curr_pin_cfg->is_gpio)
8217 msm_sdcc_setup_gpio(pdev->id, active);
8218 else
8219 msm_sdcc_setup_pad(pdev->id, active);
8220 curr_pin_cfg->sdio_lpm_gpio_cfg = 0;
8221}
8222
8223static int msm_sdc3_get_wpswitch(struct device *dev)
8224{
8225 struct platform_device *pdev;
8226 int status;
8227 pdev = container_of(dev, struct platform_device, dev);
8228
8229 status = gpio_request(GPIO_SDC_WP, "SD_WP_Switch");
8230 if (status) {
8231 pr_err("%s:Failed to request GPIO %d\n",
8232 __func__, GPIO_SDC_WP);
8233 } else {
8234 status = gpio_direction_input(GPIO_SDC_WP);
8235 if (!status) {
8236 status = gpio_get_value_cansleep(GPIO_SDC_WP);
8237 pr_info("%s: WP Status for Slot %d = %d\n",
8238 __func__, pdev->id, status);
8239 }
8240 gpio_free(GPIO_SDC_WP);
8241 }
8242 return status;
8243}
8244
8245#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8246int sdc5_register_status_notify(void (*callback)(int, void *),
8247 void *dev_id)
8248{
8249 sdc5_status_notify_cb = callback;
8250 sdc5_status_notify_cb_devid = dev_id;
8251 return 0;
8252}
8253#endif
8254
8255#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8256int sdc2_register_status_notify(void (*callback)(int, void *),
8257 void *dev_id)
8258{
8259 sdc2_status_notify_cb = callback;
8260 sdc2_status_notify_cb_devid = dev_id;
8261 return 0;
8262}
8263#endif
8264
8265/* Interrupt handler for SDC2 and SDC5 detection
8266 * This function uses dual-edge interrputs settings in order
8267 * to get SDIO detection when the GPIO is rising and SDIO removal
8268 * when the GPIO is falling */
8269static irqreturn_t msm8x60_multi_sdio_slot_status_irq(int irq, void *dev_id)
8270{
8271 int status;
8272
8273 if (!machine_is_msm8x60_fusion() &&
8274 !machine_is_msm8x60_fusn_ffa())
8275 return IRQ_NONE;
8276
8277 status = gpio_get_value(MDM2AP_SYNC);
8278 pr_info("%s: MDM2AP_SYNC Status = %d\n",
8279 __func__, status);
8280
8281#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8282 if (sdc2_status_notify_cb) {
8283 pr_info("%s: calling sdc2_status_notify_cb\n", __func__);
8284 sdc2_status_notify_cb(status,
8285 sdc2_status_notify_cb_devid);
8286 }
8287#endif
8288
8289#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8290 if (sdc5_status_notify_cb) {
8291 pr_info("%s: calling sdc5_status_notify_cb\n", __func__);
8292 sdc5_status_notify_cb(status,
8293 sdc5_status_notify_cb_devid);
8294 }
8295#endif
8296 return IRQ_HANDLED;
8297}
8298
8299static int msm8x60_multi_sdio_init(void)
8300{
8301 int ret, irq_num;
8302
8303 if (!machine_is_msm8x60_fusion() &&
8304 !machine_is_msm8x60_fusn_ffa())
8305 return 0;
8306
8307 ret = msm_gpiomux_get(MDM2AP_SYNC);
8308 if (ret) {
8309 pr_err("%s:Failed to request GPIO %d, ret=%d\n",
8310 __func__, MDM2AP_SYNC, ret);
8311 return ret;
8312 }
8313
8314 irq_num = gpio_to_irq(MDM2AP_SYNC);
8315
8316 ret = request_irq(irq_num,
8317 msm8x60_multi_sdio_slot_status_irq,
8318 IRQ_TYPE_EDGE_BOTH,
8319 "sdio_multidetection", NULL);
8320
8321 if (ret) {
8322 pr_err("%s:Failed to request irq, ret=%d\n",
8323 __func__, ret);
8324 return ret;
8325 }
8326
8327 return ret;
8328}
8329
8330#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008331static unsigned int msm8x60_sdcc_slot_status(struct device *dev)
8332{
8333 int status;
8334
8335 status = gpio_request(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)
8336 , "SD_HW_Detect");
8337 if (status) {
8338 pr_err("%s:Failed to request GPIO %d\n", __func__,
8339 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8340 } else {
8341 status = gpio_direction_input(
8342 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8343 if (!status)
8344 status = !(gpio_get_value_cansleep(
8345 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)));
8346 gpio_free(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8347 }
8348 return (unsigned int) status;
8349}
8350#endif
8351#endif
8352
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308353#define MSM_MPM_PIN_SDC3_DAT1 21
Subhash Jadavanife608a22012-04-13 10:45:53 +05308354#define MSM_MPM_PIN_SDC4_DAT1 23
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008355
8356#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8357static struct mmc_platform_data msm8x60_sdc1_data = {
8358 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8359 .translate_vdd = msm_sdcc_setup_power,
8360#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
8361 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8362#else
8363 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8364#endif
8365 .msmsdcc_fmin = 400000,
8366 .msmsdcc_fmid = 24000000,
8367 .msmsdcc_fmax = 48000000,
8368 .nonremovable = 1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308369 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008370};
8371#endif
8372
8373#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8374static struct mmc_platform_data msm8x60_sdc2_data = {
8375 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8376 .translate_vdd = msm_sdcc_setup_power,
8377 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8378 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8379 .msmsdcc_fmin = 400000,
8380 .msmsdcc_fmid = 24000000,
8381 .msmsdcc_fmax = 48000000,
8382 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008383 .register_status_notify = sdc2_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008384#ifdef CONFIG_MSM_SDIO_AL
8385 .is_sdio_al_client = 1,
8386#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308387 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008388};
8389#endif
8390
8391#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8392static struct mmc_platform_data msm8x60_sdc3_data = {
8393 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8394 .translate_vdd = msm_sdcc_setup_power,
8395 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8396 .wpswitch = msm_sdc3_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008397 .status = msm8x60_sdcc_slot_status,
8398 .status_irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
8399 PMIC_GPIO_SDC3_DET - 1),
8400 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008401 .msmsdcc_fmin = 400000,
8402 .msmsdcc_fmid = 24000000,
8403 .msmsdcc_fmax = 48000000,
8404 .nonremovable = 0,
Subhash Jadavani55e188e2012-04-13 11:31:08 +05308405 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC3_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308406 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008407};
8408#endif
8409
8410#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8411static struct mmc_platform_data msm8x60_sdc4_data = {
8412 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8413 .translate_vdd = msm_sdcc_setup_power,
8414 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8415 .msmsdcc_fmin = 400000,
8416 .msmsdcc_fmid = 24000000,
8417 .msmsdcc_fmax = 48000000,
8418 .nonremovable = 0,
Subhash Jadavanic9b85752012-04-13 11:16:49 +05308419 .mpm_sdiowakeup_int = MSM_MPM_PIN_SDC4_DAT1,
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308420 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008421};
8422#endif
8423
8424#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8425static struct mmc_platform_data msm8x60_sdc5_data = {
8426 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8427 .translate_vdd = msm_sdcc_setup_power,
8428 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8429 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8430 .msmsdcc_fmin = 400000,
8431 .msmsdcc_fmid = 24000000,
8432 .msmsdcc_fmax = 48000000,
8433 .nonremovable = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008434 .register_status_notify = sdc5_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008435#ifdef CONFIG_MSM_SDIO_AL
8436 .is_sdio_al_client = 1,
8437#endif
Subhash Jadavanibcd435f2012-04-24 18:26:49 +05308438 .msm_bus_voting_data = &sps_to_ddr_bus_voting_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008439};
8440#endif
8441
8442static void __init msm8x60_init_mmc(void)
8443{
8444#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8445 /* SDCC1 : eMMC card connected */
8446 sdcc_vreg_data[0].vdd_data = &sdcc_vdd_reg_data[0];
8447 sdcc_vreg_data[0].vdd_data->reg_name = "8901_l5";
8448 sdcc_vreg_data[0].vdd_data->set_voltage_sup = 1;
8449 sdcc_vreg_data[0].vdd_data->level = 2850000;
Subhash Jadavania8482a32011-08-08 11:01:44 +05308450 sdcc_vreg_data[0].vdd_data->always_on = 1;
8451 sdcc_vreg_data[0].vdd_data->op_pwr_mode_sup = 1;
8452 sdcc_vreg_data[0].vdd_data->lpm_uA = 9000;
8453 sdcc_vreg_data[0].vdd_data->hpm_uA = 200000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008454
8455 sdcc_vreg_data[0].vccq_data = &sdcc_vccq_reg_data[0];
8456 sdcc_vreg_data[0].vccq_data->reg_name = "8901_lvs0";
8457 sdcc_vreg_data[0].vccq_data->set_voltage_sup = 0;
8458 sdcc_vreg_data[0].vccq_data->always_on = 1;
8459
8460 msm_add_sdcc(1, &msm8x60_sdc1_data);
8461#endif
8462#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8463 /*
8464 * MDM SDIO client is connected to SDC2 on charm SURF/FFA
8465 * and no card is connected on 8660 SURF/FFA/FLUID.
8466 */
8467 sdcc_vreg_data[1].vdd_data = &sdcc_vdd_reg_data[1];
8468 sdcc_vreg_data[1].vdd_data->reg_name = "8058_s3";
8469 sdcc_vreg_data[1].vdd_data->set_voltage_sup = 1;
8470 sdcc_vreg_data[1].vdd_data->level = 1800000;
8471
8472 sdcc_vreg_data[1].vccq_data = NULL;
8473
8474 if (machine_is_msm8x60_fusion())
8475 msm8x60_sdc2_data.msmsdcc_fmax = 24000000;
8476 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008477 msm8x60_sdc2_data.sdiowakeup_irq = gpio_to_irq(144);
8478 msm_sdcc_setup_gpio(2, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008479 msm_add_sdcc(2, &msm8x60_sdc2_data);
8480 }
8481#endif
8482#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8483 /* SDCC3 : External card slot connected */
8484 sdcc_vreg_data[2].vdd_data = &sdcc_vdd_reg_data[2];
8485 sdcc_vreg_data[2].vdd_data->reg_name = "8058_l14";
8486 sdcc_vreg_data[2].vdd_data->set_voltage_sup = 1;
8487 sdcc_vreg_data[2].vdd_data->level = 2850000;
8488 sdcc_vreg_data[2].vdd_data->always_on = 1;
8489 sdcc_vreg_data[2].vdd_data->op_pwr_mode_sup = 1;
8490 sdcc_vreg_data[2].vdd_data->lpm_uA = 9000;
8491 sdcc_vreg_data[2].vdd_data->hpm_uA = 200000;
8492
8493 sdcc_vreg_data[2].vccq_data = NULL;
8494
8495 sdcc_vreg_data[2].vddp_data = &sdcc_vddp_reg_data[2];
8496 sdcc_vreg_data[2].vddp_data->reg_name = "8058_l5";
8497 sdcc_vreg_data[2].vddp_data->set_voltage_sup = 1;
8498 sdcc_vreg_data[2].vddp_data->level = 2850000;
8499 sdcc_vreg_data[2].vddp_data->always_on = 1;
8500 sdcc_vreg_data[2].vddp_data->op_pwr_mode_sup = 1;
8501 /* Sleep current required is ~300 uA. But min. RPM
8502 * vote can be in terms of mA (min. 1 mA).
8503 * So let's vote for 2 mA during sleep.
8504 */
8505 sdcc_vreg_data[2].vddp_data->lpm_uA = 2000;
8506 /* Max. Active current required is 16 mA */
8507 sdcc_vreg_data[2].vddp_data->hpm_uA = 16000;
8508
8509 if (machine_is_msm8x60_fluid())
8510 msm8x60_sdc3_data.wpswitch = NULL;
8511 msm_add_sdcc(3, &msm8x60_sdc3_data);
8512#endif
8513#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8514 /* SDCC4 : WLAN WCN1314 chip is connected */
8515 sdcc_vreg_data[3].vdd_data = &sdcc_vdd_reg_data[3];
8516 sdcc_vreg_data[3].vdd_data->reg_name = "8058_s3";
8517 sdcc_vreg_data[3].vdd_data->set_voltage_sup = 1;
8518 sdcc_vreg_data[3].vdd_data->level = 1800000;
8519
8520 sdcc_vreg_data[3].vccq_data = NULL;
8521
8522 msm_add_sdcc(4, &msm8x60_sdc4_data);
8523#endif
8524#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8525 /*
8526 * MDM SDIO client is connected to SDC5 on charm SURF/FFA
8527 * and no card is connected on 8660 SURF/FFA/FLUID.
8528 */
8529 sdcc_vreg_data[4].vdd_data = &sdcc_vdd_reg_data[4];
8530 sdcc_vreg_data[4].vdd_data->reg_name = "8058_s3";
8531 sdcc_vreg_data[4].vdd_data->set_voltage_sup = 1;
8532 sdcc_vreg_data[4].vdd_data->level = 1800000;
8533
8534 sdcc_vreg_data[4].vccq_data = NULL;
8535
8536 if (machine_is_msm8x60_fusion())
8537 msm8x60_sdc5_data.msmsdcc_fmax = 24000000;
8538 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008539 msm8x60_sdc5_data.sdiowakeup_irq = gpio_to_irq(99);
8540 msm_sdcc_setup_gpio(5, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008541 msm_add_sdcc(5, &msm8x60_sdc5_data);
8542 }
8543#endif
8544}
8545
8546#if !defined(CONFIG_GPIO_SX150X) && !defined(CONFIG_GPIO_SX150X_MODULE)
8547static inline void display_common_power(int on) {}
8548#else
8549
8550#define _GET_REGULATOR(var, name) do { \
8551 if (var == NULL) { \
8552 var = regulator_get(NULL, name); \
8553 if (IS_ERR(var)) { \
8554 pr_err("'%s' regulator not found, rc=%ld\n", \
8555 name, PTR_ERR(var)); \
8556 var = NULL; \
8557 } \
8558 } \
8559} while (0)
8560
8561static int dsub_regulator(int on)
8562{
8563 static struct regulator *dsub_reg;
8564 static struct regulator *mpp0_reg;
8565 static int dsub_reg_enabled;
8566 int rc = 0;
8567
8568 _GET_REGULATOR(dsub_reg, "8901_l3");
8569 if (IS_ERR(dsub_reg)) {
8570 printk(KERN_ERR "%s: failed to get reg 8901_l3 err=%ld",
8571 __func__, PTR_ERR(dsub_reg));
8572 return PTR_ERR(dsub_reg);
8573 }
8574
8575 _GET_REGULATOR(mpp0_reg, "8901_mpp0");
8576 if (IS_ERR(mpp0_reg)) {
8577 printk(KERN_ERR "%s: failed to get reg 8901_mpp0 err=%ld",
8578 __func__, PTR_ERR(mpp0_reg));
8579 return PTR_ERR(mpp0_reg);
8580 }
8581
8582 if (on && !dsub_reg_enabled) {
8583 rc = regulator_set_voltage(dsub_reg, 3300000, 3300000);
8584 if (rc) {
8585 printk(KERN_ERR "%s: failed to set reg 8901_l3 voltage"
8586 " err=%d", __func__, rc);
8587 goto dsub_regulator_err;
8588 }
8589 rc = regulator_enable(dsub_reg);
8590 if (rc) {
8591 printk(KERN_ERR "%s: failed to enable reg 8901_l3"
8592 " err=%d", __func__, rc);
8593 goto dsub_regulator_err;
8594 }
8595 rc = regulator_enable(mpp0_reg);
8596 if (rc) {
8597 printk(KERN_ERR "%s: failed to enable reg 8901_mpp0"
8598 " err=%d", __func__, rc);
8599 goto dsub_regulator_err;
8600 }
8601 dsub_reg_enabled = 1;
8602 } else if (!on && dsub_reg_enabled) {
8603 rc = regulator_disable(dsub_reg);
8604 if (rc)
8605 printk(KERN_WARNING "%s: failed to disable reg 8901_l3"
8606 " err=%d", __func__, rc);
8607 rc = regulator_disable(mpp0_reg);
8608 if (rc)
8609 printk(KERN_WARNING "%s: failed to disable reg "
8610 "8901_mpp0 err=%d", __func__, rc);
8611 dsub_reg_enabled = 0;
8612 }
8613
8614 return rc;
8615
8616dsub_regulator_err:
8617 regulator_put(mpp0_reg);
8618 regulator_put(dsub_reg);
8619 return rc;
8620}
8621
8622static int display_power_on;
8623static void setup_display_power(void)
8624{
8625 if (display_power_on)
8626 if (lcdc_vga_enabled) {
8627 dsub_regulator(1);
8628 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8629 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8630 if (machine_is_msm8x60_ffa() ||
8631 machine_is_msm8x60_fusn_ffa())
8632 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 1);
8633 } else {
8634 dsub_regulator(0);
8635 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 1);
8636 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 1);
8637 if (machine_is_msm8x60_ffa() ||
8638 machine_is_msm8x60_fusn_ffa())
8639 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8640 }
8641 else {
8642 dsub_regulator(0);
8643 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
8644 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8645 /* BACKLIGHT */
8646 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8647 /* LVDS */
8648 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8649 }
8650}
8651
8652#define _GET_REGULATOR(var, name) do { \
8653 if (var == NULL) { \
8654 var = regulator_get(NULL, name); \
8655 if (IS_ERR(var)) { \
8656 pr_err("'%s' regulator not found, rc=%ld\n", \
8657 name, PTR_ERR(var)); \
8658 var = NULL; \
8659 } \
8660 } \
8661} while (0)
8662
8663#define GPIO_RESX_N (GPIO_EXPANDER_GPIO_BASE + 2)
8664
8665static void display_common_power(int on)
8666{
8667 int rc;
8668 static struct regulator *display_reg;
8669
8670 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
8671 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8672 if (on) {
8673 /* LVDS */
8674 _GET_REGULATOR(display_reg, "8901_l2");
8675 if (!display_reg)
8676 return;
8677 rc = regulator_set_voltage(display_reg,
8678 3300000, 3300000);
8679 if (rc)
8680 goto out;
8681 rc = regulator_enable(display_reg);
8682 if (rc)
8683 goto out;
8684 rc = gpio_request(GPIO_LVDS_SHUTDOWN_N,
8685 "LVDS_STDN_OUT_N");
8686 if (rc) {
8687 printk(KERN_ERR "%s: LVDS gpio %d request"
8688 "failed\n", __func__,
8689 GPIO_LVDS_SHUTDOWN_N);
8690 goto out2;
8691 }
8692
8693 /* BACKLIGHT */
8694 rc = gpio_request(GPIO_BACKLIGHT_EN, "BACKLIGHT_EN");
8695 if (rc) {
8696 printk(KERN_ERR "%s: BACKLIGHT gpio %d request"
8697 "failed\n", __func__,
8698 GPIO_BACKLIGHT_EN);
8699 goto out3;
8700 }
8701
8702 if (machine_is_msm8x60_ffa() ||
8703 machine_is_msm8x60_fusn_ffa()) {
8704 rc = gpio_request(GPIO_DONGLE_PWR_EN,
8705 "DONGLE_PWR_EN");
8706 if (rc) {
8707 printk(KERN_ERR "%s: DONGLE_PWR_EN gpio"
8708 " %d request failed\n", __func__,
8709 GPIO_DONGLE_PWR_EN);
8710 goto out4;
8711 }
8712 }
8713
8714 gpio_direction_output(GPIO_LVDS_SHUTDOWN_N, 0);
8715 gpio_direction_output(GPIO_BACKLIGHT_EN, 0);
8716 if (machine_is_msm8x60_ffa() ||
8717 machine_is_msm8x60_fusn_ffa())
8718 gpio_direction_output(GPIO_DONGLE_PWR_EN, 0);
8719 mdelay(20);
8720 display_power_on = 1;
8721 setup_display_power();
8722 } else {
8723 if (display_power_on) {
8724 display_power_on = 0;
8725 setup_display_power();
8726 mdelay(20);
8727 if (machine_is_msm8x60_ffa() ||
8728 machine_is_msm8x60_fusn_ffa())
8729 gpio_free(GPIO_DONGLE_PWR_EN);
8730 goto out4;
8731 }
8732 }
8733 }
8734#if defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
8735 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA)
8736 else if (machine_is_msm8x60_fluid()) {
8737 static struct regulator *fluid_reg;
8738 static struct regulator *fluid_reg2;
8739
8740 if (on) {
8741 _GET_REGULATOR(fluid_reg, "8901_l2");
8742 if (!fluid_reg)
8743 return;
8744 _GET_REGULATOR(fluid_reg2, "8058_s3");
8745 if (!fluid_reg2) {
8746 regulator_put(fluid_reg);
8747 return;
8748 }
8749 rc = gpio_request(GPIO_RESX_N, "RESX_N");
8750 if (rc) {
8751 regulator_put(fluid_reg2);
8752 regulator_put(fluid_reg);
8753 return;
8754 }
8755 regulator_set_voltage(fluid_reg, 2850000, 2850000);
8756 regulator_set_voltage(fluid_reg2, 1800000, 1800000);
8757 regulator_enable(fluid_reg);
8758 regulator_enable(fluid_reg2);
8759 msleep(20);
8760 gpio_direction_output(GPIO_RESX_N, 0);
8761 udelay(10);
8762 gpio_set_value_cansleep(GPIO_RESX_N, 1);
8763 display_power_on = 1;
8764 setup_display_power();
8765 } else {
8766 gpio_set_value_cansleep(GPIO_RESX_N, 0);
8767 gpio_free(GPIO_RESX_N);
8768 msleep(20);
8769 regulator_disable(fluid_reg2);
8770 regulator_disable(fluid_reg);
8771 regulator_put(fluid_reg2);
8772 regulator_put(fluid_reg);
8773 display_power_on = 0;
8774 setup_display_power();
8775 fluid_reg = NULL;
8776 fluid_reg2 = NULL;
8777 }
8778 }
8779#endif
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -04008780#if defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA)
8781 else if (machine_is_msm8x60_dragon()) {
8782 static struct regulator *dragon_reg;
8783 static struct regulator *dragon_reg2;
8784
8785 if (on) {
8786 _GET_REGULATOR(dragon_reg, "8901_l2");
8787 if (!dragon_reg)
8788 return;
8789 _GET_REGULATOR(dragon_reg2, "8058_l16");
8790 if (!dragon_reg2) {
8791 regulator_put(dragon_reg);
8792 dragon_reg = NULL;
8793 return;
8794 }
8795
8796 rc = gpio_request(GPIO_NT35582_BL_EN, "lcdc_bl_en");
8797 if (rc) {
8798 pr_err("%s: gpio %d request failed with rc=%d\n",
8799 __func__, GPIO_NT35582_BL_EN, rc);
8800 regulator_put(dragon_reg);
8801 regulator_put(dragon_reg2);
8802 dragon_reg = NULL;
8803 dragon_reg2 = NULL;
8804 return;
8805 }
8806
8807 if (gpio_tlmm_config(GPIO_CFG(GPIO_NT35582_RESET, 0,
8808 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
8809 GPIO_CFG_16MA), GPIO_CFG_ENABLE)) {
8810 pr_err("%s: config gpio '%d' failed!\n",
8811 __func__, GPIO_NT35582_RESET);
8812 gpio_free(GPIO_NT35582_BL_EN);
8813 regulator_put(dragon_reg);
8814 regulator_put(dragon_reg2);
8815 dragon_reg = NULL;
8816 dragon_reg2 = NULL;
8817 return;
8818 }
8819
8820 rc = gpio_request(GPIO_NT35582_RESET, "lcdc_reset");
8821 if (rc) {
8822 pr_err("%s: unable to request gpio %d (rc=%d)\n",
8823 __func__, GPIO_NT35582_RESET, rc);
8824 gpio_free(GPIO_NT35582_BL_EN);
8825 regulator_put(dragon_reg);
8826 regulator_put(dragon_reg2);
8827 dragon_reg = NULL;
8828 dragon_reg2 = NULL;
8829 return;
8830 }
8831
8832 regulator_set_voltage(dragon_reg, 3300000, 3300000);
8833 regulator_set_voltage(dragon_reg2, 1800000, 1800000);
8834 regulator_enable(dragon_reg);
8835 regulator_enable(dragon_reg2);
8836 msleep(20);
8837
8838 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8839 msleep(20);
8840 gpio_set_value_cansleep(GPIO_NT35582_RESET, 0);
8841 msleep(20);
8842 gpio_set_value_cansleep(GPIO_NT35582_RESET, 1);
8843 msleep(50);
8844
8845 gpio_set_value_cansleep(GPIO_NT35582_BL_EN, 1);
8846
8847 display_power_on = 1;
8848 } else if ((dragon_reg != NULL) && (dragon_reg2 != NULL)) {
8849 gpio_free(GPIO_NT35582_RESET);
8850 gpio_free(GPIO_NT35582_BL_EN);
8851 regulator_disable(dragon_reg2);
8852 regulator_disable(dragon_reg);
8853 regulator_put(dragon_reg2);
8854 regulator_put(dragon_reg);
8855 display_power_on = 0;
8856 dragon_reg = NULL;
8857 dragon_reg2 = NULL;
8858 }
8859 }
8860#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008861 return;
8862
8863out4:
8864 gpio_free(GPIO_BACKLIGHT_EN);
8865out3:
8866 gpio_free(GPIO_LVDS_SHUTDOWN_N);
8867out2:
8868 regulator_disable(display_reg);
8869out:
8870 regulator_put(display_reg);
8871 display_reg = NULL;
8872}
8873#undef _GET_REGULATOR
8874#endif
8875
8876static int mipi_dsi_panel_power(int on);
8877
8878#define LCDC_NUM_GPIO 28
8879#define LCDC_GPIO_START 0
8880
8881static void lcdc_samsung_panel_power(int on)
8882{
8883 int n, ret = 0;
8884
8885 display_common_power(on);
8886
8887 for (n = 0; n < LCDC_NUM_GPIO; n++) {
8888 if (on) {
8889 ret = gpio_request(LCDC_GPIO_START + n, "LCDC_GPIO");
8890 if (unlikely(ret)) {
8891 pr_err("%s not able to get gpio\n", __func__);
8892 break;
8893 }
8894 } else
8895 gpio_free(LCDC_GPIO_START + n);
8896 }
8897
8898 if (ret) {
8899 for (n--; n >= 0; n--)
8900 gpio_free(LCDC_GPIO_START + n);
8901 }
8902
8903 mipi_dsi_panel_power(0); /* set 8058_ldo0 to LPM */
8904}
8905
8906#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
8907#define _GET_REGULATOR(var, name) do { \
8908 var = regulator_get(NULL, name); \
8909 if (IS_ERR(var)) { \
8910 pr_err("'%s' regulator not found, rc=%ld\n", \
8911 name, IS_ERR(var)); \
8912 var = NULL; \
8913 return -ENODEV; \
8914 } \
8915} while (0)
8916
8917static int hdmi_enable_5v(int on)
8918{
8919 static struct regulator *reg_8901_hdmi_mvs; /* HDMI_5V */
8920 static struct regulator *reg_8901_mpp0; /* External 5V */
8921 static int prev_on;
8922 int rc;
8923
8924 if (on == prev_on)
8925 return 0;
8926
8927 if (!reg_8901_hdmi_mvs)
8928 _GET_REGULATOR(reg_8901_hdmi_mvs, "8901_hdmi_mvs");
8929 if (!reg_8901_mpp0)
8930 _GET_REGULATOR(reg_8901_mpp0, "8901_mpp0");
8931
8932 if (on) {
8933 rc = regulator_enable(reg_8901_mpp0);
8934 if (rc) {
8935 pr_err("'%s' regulator enable failed, rc=%d\n",
8936 "reg_8901_mpp0", rc);
8937 return rc;
8938 }
8939 rc = regulator_enable(reg_8901_hdmi_mvs);
8940 if (rc) {
8941 pr_err("'%s' regulator enable failed, rc=%d\n",
8942 "8901_hdmi_mvs", rc);
8943 return rc;
8944 }
8945 pr_info("%s(on): success\n", __func__);
8946 } else {
8947 rc = regulator_disable(reg_8901_hdmi_mvs);
8948 if (rc)
8949 pr_warning("'%s' regulator disable failed, rc=%d\n",
8950 "8901_hdmi_mvs", rc);
8951 rc = regulator_disable(reg_8901_mpp0);
8952 if (rc)
8953 pr_warning("'%s' regulator disable failed, rc=%d\n",
8954 "reg_8901_mpp0", rc);
8955 pr_info("%s(off): success\n", __func__);
8956 }
8957
8958 prev_on = on;
8959
8960 return 0;
8961}
8962
8963static int hdmi_core_power(int on, int show)
8964{
8965 static struct regulator *reg_8058_l16; /* VDD_HDMI */
8966 static int prev_on;
8967 int rc;
8968
8969 if (on == prev_on)
8970 return 0;
8971
8972 if (!reg_8058_l16)
8973 _GET_REGULATOR(reg_8058_l16, "8058_l16");
8974
8975 if (on) {
8976 rc = regulator_set_voltage(reg_8058_l16, 1800000, 1800000);
8977 if (!rc)
8978 rc = regulator_enable(reg_8058_l16);
8979 if (rc) {
8980 pr_err("'%s' regulator enable failed, rc=%d\n",
8981 "8058_l16", rc);
8982 return rc;
8983 }
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05308984 pr_debug("%s(on): success\n", __func__);
8985 } else {
8986 rc = regulator_disable(reg_8058_l16);
8987 if (rc)
8988 pr_warning("'%s' regulator disable failed, rc=%d\n",
8989 "8058_l16", rc);
8990 pr_debug("%s(off): success\n", __func__);
8991 }
8992
8993 prev_on = on;
8994
8995 return 0;
8996}
8997
8998static int hdmi_gpio_config(int on)
8999{
9000 int rc = 0;
9001 static int prev_on;
9002
9003 if (on == prev_on)
9004 return 0;
9005
9006 if (on) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009007 rc = gpio_request(170, "HDMI_DDC_CLK");
9008 if (rc) {
9009 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9010 "HDMI_DDC_CLK", 170, rc);
9011 goto error1;
9012 }
9013 rc = gpio_request(171, "HDMI_DDC_DATA");
9014 if (rc) {
9015 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9016 "HDMI_DDC_DATA", 171, rc);
9017 goto error2;
9018 }
9019 rc = gpio_request(172, "HDMI_HPD");
9020 if (rc) {
9021 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9022 "HDMI_HPD", 172, rc);
9023 goto error3;
9024 }
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309025 pr_debug("%s(on): success\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009026 } else {
9027 gpio_free(170);
9028 gpio_free(171);
9029 gpio_free(172);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309030 pr_debug("%s(off): success\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009031 }
9032
9033 prev_on = on;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009034 return 0;
9035
9036error3:
9037 gpio_free(171);
9038error2:
9039 gpio_free(170);
9040error1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009041 return rc;
9042}
9043
9044static int hdmi_cec_power(int on)
9045{
9046 static struct regulator *reg_8901_l3; /* HDMI_CEC */
9047 static int prev_on;
9048 int rc;
9049
9050 if (on == prev_on)
9051 return 0;
9052
9053 if (!reg_8901_l3)
9054 _GET_REGULATOR(reg_8901_l3, "8901_l3");
9055
9056 if (on) {
9057 rc = regulator_set_voltage(reg_8901_l3, 3300000, 3300000);
9058 if (!rc)
9059 rc = regulator_enable(reg_8901_l3);
9060 if (rc) {
9061 pr_err("'%s' regulator enable failed, rc=%d\n",
9062 "8901_l3", rc);
9063 return rc;
9064 }
9065 rc = gpio_request(169, "HDMI_CEC_VAR");
9066 if (rc) {
9067 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
9068 "HDMI_CEC_VAR", 169, rc);
9069 goto error;
9070 }
9071 pr_info("%s(on): success\n", __func__);
9072 } else {
9073 gpio_free(169);
9074 rc = regulator_disable(reg_8901_l3);
9075 if (rc)
9076 pr_warning("'%s' regulator disable failed, rc=%d\n",
9077 "8901_l3", rc);
9078 pr_info("%s(off): success\n", __func__);
9079 }
9080
9081 prev_on = on;
9082
9083 return 0;
9084error:
9085 regulator_disable(reg_8901_l3);
9086 return rc;
9087}
9088
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309089static int hdmi_panel_power(int on)
9090{
9091 int rc;
9092
9093 pr_debug("%s: HDMI Core: %s\n", __func__, (on ? "ON" : "OFF"));
9094 rc = hdmi_core_power(on, 1);
9095 if (rc)
9096 rc = hdmi_cec_power(on);
9097
9098 pr_debug("%s: HDMI Core: %s Success\n", __func__, (on ? "ON" : "OFF"));
9099 return rc;
9100}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009101#undef _GET_REGULATOR
9102
9103#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
9104
9105static int lcdc_panel_power(int on)
9106{
9107 int flag_on = !!on;
9108 static int lcdc_power_save_on;
9109
9110 if (lcdc_power_save_on == flag_on)
9111 return 0;
9112
9113 lcdc_power_save_on = flag_on;
9114
9115 lcdc_samsung_panel_power(on);
9116
9117 return 0;
9118}
9119
9120#ifdef CONFIG_MSM_BUS_SCALING
Nagamalleswararao Ganji5fabbd62011-11-06 23:10:43 -08009121
9122static struct msm_bus_vectors rotator_init_vectors[] = {
9123 {
9124 .src = MSM_BUS_MASTER_ROTATOR,
9125 .dst = MSM_BUS_SLAVE_SMI,
9126 .ab = 0,
9127 .ib = 0,
9128 },
9129 {
9130 .src = MSM_BUS_MASTER_ROTATOR,
9131 .dst = MSM_BUS_SLAVE_EBI_CH0,
9132 .ab = 0,
9133 .ib = 0,
9134 },
9135};
9136
9137static struct msm_bus_vectors rotator_ui_vectors[] = {
9138 {
9139 .src = MSM_BUS_MASTER_ROTATOR,
9140 .dst = MSM_BUS_SLAVE_SMI,
9141 .ab = 0,
9142 .ib = 0,
9143 },
9144 {
9145 .src = MSM_BUS_MASTER_ROTATOR,
9146 .dst = MSM_BUS_SLAVE_EBI_CH0,
9147 .ab = (1024 * 600 * 4 * 2 * 60),
9148 .ib = (1024 * 600 * 4 * 2 * 60 * 1.5),
9149 },
9150};
9151
9152static struct msm_bus_vectors rotator_vga_vectors[] = {
9153 {
9154 .src = MSM_BUS_MASTER_ROTATOR,
9155 .dst = MSM_BUS_SLAVE_SMI,
9156 .ab = (640 * 480 * 2 * 2 * 30),
9157 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9158 },
9159 {
9160 .src = MSM_BUS_MASTER_ROTATOR,
9161 .dst = MSM_BUS_SLAVE_EBI_CH0,
9162 .ab = (640 * 480 * 2 * 2 * 30),
9163 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
9164 },
9165};
9166
9167static struct msm_bus_vectors rotator_720p_vectors[] = {
9168 {
9169 .src = MSM_BUS_MASTER_ROTATOR,
9170 .dst = MSM_BUS_SLAVE_SMI,
9171 .ab = (1280 * 736 * 2 * 2 * 30),
9172 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9173 },
9174 {
9175 .src = MSM_BUS_MASTER_ROTATOR,
9176 .dst = MSM_BUS_SLAVE_EBI_CH0,
9177 .ab = (1280 * 736 * 2 * 2 * 30),
9178 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
9179 },
9180};
9181
9182static struct msm_bus_vectors rotator_1080p_vectors[] = {
9183 {
9184 .src = MSM_BUS_MASTER_ROTATOR,
9185 .dst = MSM_BUS_SLAVE_SMI,
9186 .ab = (1920 * 1088 * 2 * 2 * 30),
9187 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9188 },
9189 {
9190 .src = MSM_BUS_MASTER_ROTATOR,
9191 .dst = MSM_BUS_SLAVE_EBI_CH0,
9192 .ab = (1920 * 1088 * 2 * 2 * 30),
9193 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
9194 },
9195};
9196
9197static struct msm_bus_paths rotator_bus_scale_usecases[] = {
9198 {
9199 ARRAY_SIZE(rotator_init_vectors),
9200 rotator_init_vectors,
9201 },
9202 {
9203 ARRAY_SIZE(rotator_ui_vectors),
9204 rotator_ui_vectors,
9205 },
9206 {
9207 ARRAY_SIZE(rotator_vga_vectors),
9208 rotator_vga_vectors,
9209 },
9210 {
9211 ARRAY_SIZE(rotator_720p_vectors),
9212 rotator_720p_vectors,
9213 },
9214 {
9215 ARRAY_SIZE(rotator_1080p_vectors),
9216 rotator_1080p_vectors,
9217 },
9218};
9219
9220struct msm_bus_scale_pdata rotator_bus_scale_pdata = {
9221 rotator_bus_scale_usecases,
9222 ARRAY_SIZE(rotator_bus_scale_usecases),
9223 .name = "rotator",
9224};
9225
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009226static struct msm_bus_vectors mdp_init_vectors[] = {
9227 /* For now, 0th array entry is reserved.
9228 * Please leave 0 as is and don't use it
9229 */
9230 {
9231 .src = MSM_BUS_MASTER_MDP_PORT0,
9232 .dst = MSM_BUS_SLAVE_SMI,
9233 .ab = 0,
9234 .ib = 0,
9235 },
9236 /* Master and slaves can be from different fabrics */
9237 {
9238 .src = MSM_BUS_MASTER_MDP_PORT0,
9239 .dst = MSM_BUS_SLAVE_EBI_CH0,
9240 .ab = 0,
9241 .ib = 0,
9242 },
9243};
9244
Ravishangar Kalyanam75f37322011-10-14 12:15:40 -07009245#ifdef CONFIG_FB_MSM_LCDC_DSUB
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009246static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9247 /* Default case static display/UI/2d/3d if FB SMI */
9248 {
9249 .src = MSM_BUS_MASTER_MDP_PORT0,
9250 .dst = MSM_BUS_SLAVE_SMI,
9251 .ab = 388800000,
9252 .ib = 486000000,
9253 },
9254 /* Master and slaves can be from different fabrics */
9255 {
9256 .src = MSM_BUS_MASTER_MDP_PORT0,
9257 .dst = MSM_BUS_SLAVE_EBI_CH0,
9258 .ab = 0,
9259 .ib = 0,
9260 },
9261};
9262
9263static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9264 /* Default case static display/UI/2d/3d if FB SMI */
9265 {
9266 .src = MSM_BUS_MASTER_MDP_PORT0,
9267 .dst = MSM_BUS_SLAVE_SMI,
9268 .ab = 0,
9269 .ib = 0,
9270 },
9271 /* Master and slaves can be from different fabrics */
9272 {
9273 .src = MSM_BUS_MASTER_MDP_PORT0,
9274 .dst = MSM_BUS_SLAVE_EBI_CH0,
9275 .ab = 388800000,
9276 .ib = 486000000 * 2,
9277 },
9278};
9279static struct msm_bus_vectors mdp_vga_vectors[] = {
9280 /* VGA and less video */
9281 {
9282 .src = MSM_BUS_MASTER_MDP_PORT0,
9283 .dst = MSM_BUS_SLAVE_SMI,
9284 .ab = 458092800,
9285 .ib = 572616000,
9286 },
9287 {
9288 .src = MSM_BUS_MASTER_MDP_PORT0,
9289 .dst = MSM_BUS_SLAVE_EBI_CH0,
9290 .ab = 458092800,
9291 .ib = 572616000 * 2,
9292 },
9293};
9294static struct msm_bus_vectors mdp_720p_vectors[] = {
9295 /* 720p and less video */
9296 {
9297 .src = MSM_BUS_MASTER_MDP_PORT0,
9298 .dst = MSM_BUS_SLAVE_SMI,
9299 .ab = 471744000,
9300 .ib = 589680000,
9301 },
9302 /* Master and slaves can be from different fabrics */
9303 {
9304 .src = MSM_BUS_MASTER_MDP_PORT0,
9305 .dst = MSM_BUS_SLAVE_EBI_CH0,
9306 .ab = 471744000,
9307 .ib = 589680000 * 2,
9308 },
9309};
9310
9311static struct msm_bus_vectors mdp_1080p_vectors[] = {
9312 /* 1080p and less video */
9313 {
9314 .src = MSM_BUS_MASTER_MDP_PORT0,
9315 .dst = MSM_BUS_SLAVE_SMI,
9316 .ab = 575424000,
9317 .ib = 719280000,
9318 },
9319 /* Master and slaves can be from different fabrics */
9320 {
9321 .src = MSM_BUS_MASTER_MDP_PORT0,
9322 .dst = MSM_BUS_SLAVE_EBI_CH0,
9323 .ab = 575424000,
9324 .ib = 719280000 * 2,
9325 },
9326};
9327
9328#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009329static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
9330 /* Default case static display/UI/2d/3d if FB SMI */
9331 {
9332 .src = MSM_BUS_MASTER_MDP_PORT0,
9333 .dst = MSM_BUS_SLAVE_SMI,
9334 .ab = 175110000,
9335 .ib = 218887500,
9336 },
9337 /* Master and slaves can be from different fabrics */
9338 {
9339 .src = MSM_BUS_MASTER_MDP_PORT0,
9340 .dst = MSM_BUS_SLAVE_EBI_CH0,
9341 .ab = 0,
9342 .ib = 0,
9343 },
9344};
9345
9346static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
9347 /* Default case static display/UI/2d/3d if FB SMI */
9348 {
9349 .src = MSM_BUS_MASTER_MDP_PORT0,
9350 .dst = MSM_BUS_SLAVE_SMI,
9351 .ab = 0,
9352 .ib = 0,
9353 },
9354 /* Master and slaves can be from different fabrics */
9355 {
9356 .src = MSM_BUS_MASTER_MDP_PORT0,
9357 .dst = MSM_BUS_SLAVE_EBI_CH0,
9358 .ab = 216000000,
9359 .ib = 270000000 * 2,
9360 },
9361};
9362static struct msm_bus_vectors mdp_vga_vectors[] = {
9363 /* VGA and less video */
9364 {
9365 .src = MSM_BUS_MASTER_MDP_PORT0,
9366 .dst = MSM_BUS_SLAVE_SMI,
9367 .ab = 216000000,
9368 .ib = 270000000,
9369 },
9370 {
9371 .src = MSM_BUS_MASTER_MDP_PORT0,
9372 .dst = MSM_BUS_SLAVE_EBI_CH0,
9373 .ab = 216000000,
9374 .ib = 270000000 * 2,
9375 },
9376};
9377
9378static struct msm_bus_vectors mdp_720p_vectors[] = {
9379 /* 720p and less video */
9380 {
9381 .src = MSM_BUS_MASTER_MDP_PORT0,
9382 .dst = MSM_BUS_SLAVE_SMI,
9383 .ab = 230400000,
9384 .ib = 288000000,
9385 },
9386 /* Master and slaves can be from different fabrics */
9387 {
9388 .src = MSM_BUS_MASTER_MDP_PORT0,
9389 .dst = MSM_BUS_SLAVE_EBI_CH0,
9390 .ab = 230400000,
9391 .ib = 288000000 * 2,
9392 },
9393};
9394
9395static struct msm_bus_vectors mdp_1080p_vectors[] = {
9396 /* 1080p and less video */
9397 {
9398 .src = MSM_BUS_MASTER_MDP_PORT0,
9399 .dst = MSM_BUS_SLAVE_SMI,
9400 .ab = 334080000,
9401 .ib = 417600000,
9402 },
9403 /* Master and slaves can be from different fabrics */
9404 {
9405 .src = MSM_BUS_MASTER_MDP_PORT0,
9406 .dst = MSM_BUS_SLAVE_EBI_CH0,
9407 .ab = 334080000,
Ravishangar Kalyanam731beb92011-07-07 18:27:32 -07009408 .ib = 550000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009409 },
9410};
9411
9412#endif
9413static struct msm_bus_paths mdp_bus_scale_usecases[] = {
9414 {
9415 ARRAY_SIZE(mdp_init_vectors),
9416 mdp_init_vectors,
9417 },
9418 {
9419 ARRAY_SIZE(mdp_sd_smi_vectors),
9420 mdp_sd_smi_vectors,
9421 },
9422 {
9423 ARRAY_SIZE(mdp_sd_ebi_vectors),
9424 mdp_sd_ebi_vectors,
9425 },
9426 {
9427 ARRAY_SIZE(mdp_vga_vectors),
9428 mdp_vga_vectors,
9429 },
9430 {
9431 ARRAY_SIZE(mdp_720p_vectors),
9432 mdp_720p_vectors,
9433 },
9434 {
9435 ARRAY_SIZE(mdp_1080p_vectors),
9436 mdp_1080p_vectors,
9437 },
9438};
9439static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
9440 mdp_bus_scale_usecases,
9441 ARRAY_SIZE(mdp_bus_scale_usecases),
9442 .name = "mdp",
9443};
9444
9445#endif
9446#ifdef CONFIG_MSM_BUS_SCALING
9447static struct msm_bus_vectors dtv_bus_init_vectors[] = {
9448 /* For now, 0th array entry is reserved.
9449 * Please leave 0 as is and don't use it
9450 */
9451 {
9452 .src = MSM_BUS_MASTER_MDP_PORT0,
9453 .dst = MSM_BUS_SLAVE_SMI,
9454 .ab = 0,
9455 .ib = 0,
9456 },
9457 /* Master and slaves can be from different fabrics */
9458 {
9459 .src = MSM_BUS_MASTER_MDP_PORT0,
9460 .dst = MSM_BUS_SLAVE_EBI_CH0,
9461 .ab = 0,
9462 .ib = 0,
9463 },
9464};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009465
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009466static struct msm_bus_vectors dtv_bus_def_vectors[] = {
9467 /* For now, 0th array entry is reserved.
9468 * Please leave 0 as is and don't use it
9469 */
9470 {
9471 .src = MSM_BUS_MASTER_MDP_PORT0,
9472 .dst = MSM_BUS_SLAVE_SMI,
9473 .ab = 566092800,
9474 .ib = 707616000,
9475 },
9476 /* Master and slaves can be from different fabrics */
9477 {
9478 .src = MSM_BUS_MASTER_MDP_PORT0,
9479 .dst = MSM_BUS_SLAVE_EBI_CH0,
9480 .ab = 566092800,
9481 .ib = 707616000,
9482 },
9483};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009484
9485static struct msm_bus_vectors dtv_bus_hdmi_prim_vectors[] = {
9486 /* For now, 0th array entry is reserved.
9487 * Please leave 0 as is and don't use it
9488 */
9489 {
9490 .src = MSM_BUS_MASTER_MDP_PORT0,
9491 .dst = MSM_BUS_SLAVE_SMI,
9492 .ab = 2000000000,
9493 .ib = 2000000000,
9494 },
9495 /* Master and slaves can be from different fabrics */
9496 {
9497 .src = MSM_BUS_MASTER_MDP_PORT0,
9498 .dst = MSM_BUS_SLAVE_EBI_CH0,
9499 .ab = 2000000000,
9500 .ib = 2000000000,
9501 },
9502};
9503
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009504static struct msm_bus_paths dtv_bus_scale_usecases[] = {
9505 {
9506 ARRAY_SIZE(dtv_bus_init_vectors),
9507 dtv_bus_init_vectors,
9508 },
9509 {
9510 ARRAY_SIZE(dtv_bus_def_vectors),
9511 dtv_bus_def_vectors,
9512 },
9513};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009514
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009515static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
9516 dtv_bus_scale_usecases,
9517 ARRAY_SIZE(dtv_bus_scale_usecases),
9518 .name = "dtv",
9519};
9520
9521static struct lcdc_platform_data dtv_pdata = {
9522 .bus_scale_table = &dtv_bus_scale_pdata,
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +05309523 .lcdc_power_save = hdmi_panel_power,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009524};
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009525
9526static struct msm_bus_paths dtv_hdmi_prim_bus_scale_usecases[] = {
9527 {
9528 ARRAY_SIZE(dtv_bus_init_vectors),
9529 dtv_bus_init_vectors,
9530 },
9531 {
9532 ARRAY_SIZE(dtv_bus_hdmi_prim_vectors),
9533 dtv_bus_hdmi_prim_vectors,
9534 },
9535};
9536
9537static struct msm_bus_scale_pdata dtv_hdmi_prim_bus_scale_pdata = {
9538 dtv_hdmi_prim_bus_scale_usecases,
9539 ARRAY_SIZE(dtv_hdmi_prim_bus_scale_usecases),
9540 .name = "dtv",
9541};
9542
9543static struct lcdc_platform_data dtv_hdmi_prim_pdata = {
9544 .bus_scale_table = &dtv_hdmi_prim_bus_scale_pdata,
9545};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009546#endif
9547
9548
9549static struct lcdc_platform_data lcdc_pdata = {
9550 .lcdc_power_save = lcdc_panel_power,
9551};
9552
9553
9554#define MDP_VSYNC_GPIO 28
9555
9556/*
9557 * MIPI_DSI only use 8058_LDO0 which need always on
9558 * therefore it need to be put at low power mode if
9559 * it was not used instead of turn it off.
9560 */
9561static int mipi_dsi_panel_power(int on)
9562{
9563 int flag_on = !!on;
9564 static int mipi_dsi_power_save_on;
9565 static struct regulator *ldo0;
9566 int rc = 0;
9567
9568 if (mipi_dsi_power_save_on == flag_on)
9569 return 0;
9570
9571 mipi_dsi_power_save_on = flag_on;
9572
9573 if (ldo0 == NULL) { /* init */
9574 ldo0 = regulator_get(NULL, "8058_l0");
9575 if (IS_ERR(ldo0)) {
9576 pr_debug("%s: LDO0 failed\n", __func__);
9577 rc = PTR_ERR(ldo0);
9578 return rc;
9579 }
9580
9581 rc = regulator_set_voltage(ldo0, 1200000, 1200000);
9582 if (rc)
9583 goto out;
9584
9585 rc = regulator_enable(ldo0);
9586 if (rc)
9587 goto out;
9588 }
9589
9590 if (on) {
9591 /* set ldo0 to HPM */
9592 rc = regulator_set_optimum_mode(ldo0, 100000);
9593 if (rc < 0)
9594 goto out;
9595 } else {
9596 /* set ldo0 to LPM */
Padmanabhan Komanduru0b478ff2011-11-22 19:15:40 +05309597 rc = regulator_set_optimum_mode(ldo0, 1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009598 if (rc < 0)
9599 goto out;
9600 }
9601
9602 return 0;
9603out:
9604 regulator_disable(ldo0);
9605 regulator_put(ldo0);
9606 ldo0 = NULL;
9607 return rc;
9608}
9609
9610static struct mipi_dsi_platform_data mipi_dsi_pdata = {
9611 .vsync_gpio = MDP_VSYNC_GPIO,
9612 .dsi_power_save = mipi_dsi_panel_power,
9613};
9614
9615#ifdef CONFIG_FB_MSM_TVOUT
9616static struct regulator *reg_8058_l13;
9617
9618static int atv_dac_power(int on)
9619{
9620 int rc = 0;
9621 #define _GET_REGULATOR(var, name) do { \
9622 var = regulator_get(NULL, name); \
9623 if (IS_ERR(var)) { \
9624 pr_info("'%s' regulator not found, rc=%ld\n", \
9625 name, IS_ERR(var)); \
9626 var = NULL; \
9627 return -ENODEV; \
9628 } \
9629 } while (0)
9630
9631 if (!reg_8058_l13)
9632 _GET_REGULATOR(reg_8058_l13, "8058_l13");
9633 #undef _GET_REGULATOR
9634
9635 if (on) {
9636 rc = regulator_set_voltage(reg_8058_l13, 2050000, 2050000);
9637 if (rc) {
9638 pr_info("%s: '%s' regulator set voltage failed,\
9639 rc=%d\n", __func__, "8058_l13", rc);
9640 return rc;
9641 }
9642
9643 rc = regulator_enable(reg_8058_l13);
9644 if (rc) {
9645 pr_err("%s: '%s' regulator enable failed,\
9646 rc=%d\n", __func__, "8058_l13", rc);
9647 return rc;
9648 }
9649 } else {
9650 rc = regulator_force_disable(reg_8058_l13);
9651 if (rc)
9652 pr_warning("%s: '%s' regulator disable failed, rc=%d\n",
9653 __func__, "8058_l13", rc);
9654 }
9655 return rc;
9656
9657}
9658#endif
9659
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009660static struct msm_panel_common_pdata mdp_pdata = {
9661 .gpio = MDP_VSYNC_GPIO,
Siddhartha Agrawal496f9282012-08-15 17:41:34 -07009662 .mdp_max_clk = 200000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009663#ifdef CONFIG_MSM_BUS_SCALING
9664 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
9665#endif
9666 .mdp_rev = MDP_REV_41,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009667#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Ravishangar Kalyanama3b168b2012-03-26 11:13:11 -07009668 .mem_hid = BIT(ION_CP_WB_HEAP_ID),
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009669#else
9670 .mem_hid = MEMTYPE_EBI1,
9671#endif
Olav Hauganef95ae32012-05-15 09:50:30 -07009672 .mdp_iommu_split_domain = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009673};
9674
Huaibin Yanga5419422011-12-08 23:52:10 -08009675static void __init reserve_mdp_memory(void)
9676{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -08009677 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
9678 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
9679#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
9680 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9681 mdp_pdata.ov0_wb_size;
9682 msm8x60_reserve_table[mdp_pdata.mem_hid].size +=
9683 mdp_pdata.ov1_wb_size;
9684#endif
Huaibin Yanga5419422011-12-08 23:52:10 -08009685}
9686
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009687#ifdef CONFIG_FB_MSM_TVOUT
9688
9689#ifdef CONFIG_MSM_BUS_SCALING
9690static struct msm_bus_vectors atv_bus_init_vectors[] = {
9691 /* For now, 0th array entry is reserved.
9692 * Please leave 0 as is and don't use it
9693 */
9694 {
9695 .src = MSM_BUS_MASTER_MDP_PORT0,
9696 .dst = MSM_BUS_SLAVE_SMI,
9697 .ab = 0,
9698 .ib = 0,
9699 },
9700 /* Master and slaves can be from different fabrics */
9701 {
9702 .src = MSM_BUS_MASTER_MDP_PORT0,
9703 .dst = MSM_BUS_SLAVE_EBI_CH0,
9704 .ab = 0,
9705 .ib = 0,
9706 },
9707};
9708static struct msm_bus_vectors atv_bus_def_vectors[] = {
9709 /* For now, 0th array entry is reserved.
9710 * Please leave 0 as is and don't use it
9711 */
9712 {
9713 .src = MSM_BUS_MASTER_MDP_PORT0,
9714 .dst = MSM_BUS_SLAVE_SMI,
9715 .ab = 236390400,
9716 .ib = 265939200,
9717 },
9718 /* Master and slaves can be from different fabrics */
9719 {
9720 .src = MSM_BUS_MASTER_MDP_PORT0,
9721 .dst = MSM_BUS_SLAVE_EBI_CH0,
9722 .ab = 236390400,
9723 .ib = 265939200,
9724 },
9725};
9726static struct msm_bus_paths atv_bus_scale_usecases[] = {
9727 {
9728 ARRAY_SIZE(atv_bus_init_vectors),
9729 atv_bus_init_vectors,
9730 },
9731 {
9732 ARRAY_SIZE(atv_bus_def_vectors),
9733 atv_bus_def_vectors,
9734 },
9735};
9736static struct msm_bus_scale_pdata atv_bus_scale_pdata = {
9737 atv_bus_scale_usecases,
9738 ARRAY_SIZE(atv_bus_scale_usecases),
9739 .name = "atv",
9740};
9741#endif
9742
9743static struct tvenc_platform_data atv_pdata = {
9744 .poll = 0,
9745 .pm_vid_en = atv_dac_power,
9746#ifdef CONFIG_MSM_BUS_SCALING
9747 .bus_scale_table = &atv_bus_scale_pdata,
9748#endif
9749};
9750#endif
9751
9752static void __init msm_fb_add_devices(void)
9753{
9754#ifdef CONFIG_FB_MSM_LCDC_DSUB
Siddhartha Agrawal496f9282012-08-15 17:41:34 -07009755 mdp_pdata.mdp_max_clk = 200000000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009756#endif
Syed Rameez Mustafae4a6f8e2012-07-09 15:25:13 -07009757 msm_fb_register_device("mdp", &mdp_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009758
9759 msm_fb_register_device("lcdc", &lcdc_pdata);
9760 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
9761#ifdef CONFIG_MSM_BUS_SCALING
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08009762 if (hdmi_is_primary)
9763 msm_fb_register_device("dtv", &dtv_hdmi_prim_pdata);
9764 else
9765 msm_fb_register_device("dtv", &dtv_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009766#endif
9767#ifdef CONFIG_FB_MSM_TVOUT
9768 msm_fb_register_device("tvenc", &atv_pdata);
9769 msm_fb_register_device("tvout_device", NULL);
9770#endif
9771}
9772
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07009773/**
9774 * Set MDP clocks to high frequency to avoid underflow when
9775 * using high resolution 1200x1920 WUXGA/HDMI as primary panels
9776 */
9777static void set_mdp_clocks_for_wuxga(void)
9778{
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07009779 mdp_sd_smi_vectors[0].ab = 2000000000;
9780 mdp_sd_smi_vectors[0].ib = 2000000000;
9781 mdp_sd_smi_vectors[1].ab = 2000000000;
9782 mdp_sd_smi_vectors[1].ib = 2000000000;
9783
9784 mdp_sd_ebi_vectors[0].ab = 2000000000;
9785 mdp_sd_ebi_vectors[0].ib = 2000000000;
9786 mdp_sd_ebi_vectors[1].ab = 2000000000;
9787 mdp_sd_ebi_vectors[1].ib = 2000000000;
9788
9789 mdp_vga_vectors[0].ab = 2000000000;
9790 mdp_vga_vectors[0].ib = 2000000000;
9791 mdp_vga_vectors[1].ab = 2000000000;
9792 mdp_vga_vectors[1].ib = 2000000000;
9793
9794 mdp_720p_vectors[0].ab = 2000000000;
9795 mdp_720p_vectors[0].ib = 2000000000;
9796 mdp_720p_vectors[1].ab = 2000000000;
9797 mdp_720p_vectors[1].ib = 2000000000;
9798
9799 mdp_1080p_vectors[0].ab = 2000000000;
9800 mdp_1080p_vectors[0].ib = 2000000000;
9801 mdp_1080p_vectors[1].ab = 2000000000;
9802 mdp_1080p_vectors[1].ib = 2000000000;
9803
Siddhartha Agrawal496f9282012-08-15 17:41:34 -07009804 mdp_pdata.mdp_max_clk = 200000000;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07009805}
9806
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009807#if (defined(CONFIG_MARIMBA_CORE)) && \
9808 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
9809
9810static const struct {
9811 char *name;
9812 int vmin;
9813 int vmax;
9814} bt_regs_info[] = {
9815 { "8058_s3", 1800000, 1800000 },
9816 { "8058_s2", 1300000, 1300000 },
9817 { "8058_l8", 2900000, 3050000 },
9818};
9819
9820static struct {
9821 bool enabled;
9822} bt_regs_status[] = {
9823 { false },
9824 { false },
9825 { false },
9826};
9827static struct regulator *bt_regs[ARRAY_SIZE(bt_regs_info)];
9828
9829static int bahama_bt(int on)
9830{
9831 int rc;
9832 int i;
9833 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
9834
9835 struct bahama_variant_register {
9836 const size_t size;
9837 const struct bahama_config_register *set;
9838 };
9839
9840 const struct bahama_config_register *p;
9841
9842 u8 version;
9843
9844 const struct bahama_config_register v10_bt_on[] = {
9845 { 0xE9, 0x00, 0xFF },
9846 { 0xF4, 0x80, 0xFF },
9847 { 0xE4, 0x00, 0xFF },
9848 { 0xE5, 0x00, 0x0F },
9849#ifdef CONFIG_WLAN
9850 { 0xE6, 0x38, 0x7F },
9851 { 0xE7, 0x06, 0xFF },
9852#endif
9853 { 0xE9, 0x21, 0xFF },
9854 { 0x01, 0x0C, 0x1F },
9855 { 0x01, 0x08, 0x1F },
9856 };
9857
9858 const struct bahama_config_register v20_bt_on_fm_off[] = {
9859 { 0x11, 0x0C, 0xFF },
9860 { 0x13, 0x01, 0xFF },
9861 { 0xF4, 0x80, 0xFF },
9862 { 0xF0, 0x00, 0xFF },
9863 { 0xE9, 0x00, 0xFF },
9864#ifdef CONFIG_WLAN
9865 { 0x81, 0x00, 0x7F },
9866 { 0x82, 0x00, 0xFF },
9867 { 0xE6, 0x38, 0x7F },
9868 { 0xE7, 0x06, 0xFF },
9869#endif
9870 { 0xE9, 0x21, 0xFF },
9871 };
9872
9873 const struct bahama_config_register v20_bt_on_fm_on[] = {
9874 { 0x11, 0x0C, 0xFF },
9875 { 0x13, 0x01, 0xFF },
9876 { 0xF4, 0x86, 0xFF },
9877 { 0xF0, 0x06, 0xFF },
9878 { 0xE9, 0x00, 0xFF },
9879#ifdef CONFIG_WLAN
9880 { 0x81, 0x00, 0x7F },
9881 { 0x82, 0x00, 0xFF },
9882 { 0xE6, 0x38, 0x7F },
9883 { 0xE7, 0x06, 0xFF },
9884#endif
9885 { 0xE9, 0x21, 0xFF },
9886 };
9887
9888 const struct bahama_config_register v10_bt_off[] = {
9889 { 0xE9, 0x00, 0xFF },
9890 };
9891
9892 const struct bahama_config_register v20_bt_off_fm_off[] = {
9893 { 0xF4, 0x84, 0xFF },
9894 { 0xF0, 0x04, 0xFF },
9895 { 0xE9, 0x00, 0xFF }
9896 };
9897
9898 const struct bahama_config_register v20_bt_off_fm_on[] = {
9899 { 0xF4, 0x86, 0xFF },
9900 { 0xF0, 0x06, 0xFF },
9901 { 0xE9, 0x00, 0xFF }
9902 };
9903 const struct bahama_variant_register bt_bahama[2][3] = {
9904 {
9905 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
9906 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
9907 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
9908 },
9909 {
9910 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
9911 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
9912 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
9913 }
9914 };
9915
9916 u8 offset = 0; /* index into bahama configs */
9917
9918 on = on ? 1 : 0;
9919 version = read_bahama_ver();
9920
9921 if (version == VER_UNSUPPORTED) {
9922 dev_err(&msm_bt_power_device.dev,
9923 "%s: unsupported version\n",
9924 __func__);
9925 return -EIO;
9926 }
9927
9928 if (version == VER_2_0) {
9929 if (marimba_get_fm_status(&config))
9930 offset = 0x01;
9931 }
9932
9933 /* Voting off 1.3V S2 Regulator,BahamaV2 used in Normal mode */
9934 if (on && (version == VER_2_0)) {
9935 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9936 if ((!strcmp(bt_regs_info[i].name, "8058_s2"))
9937 && (bt_regs_status[i].enabled == true)) {
9938 if (regulator_disable(bt_regs[i])) {
9939 dev_err(&msm_bt_power_device.dev,
9940 "%s: regulator disable failed",
9941 __func__);
9942 }
9943 bt_regs_status[i].enabled = false;
9944 break;
9945 }
9946 }
9947 }
9948
9949 p = bt_bahama[on][version + offset].set;
9950
9951 dev_info(&msm_bt_power_device.dev,
9952 "%s: found version %d\n", __func__, version);
9953
9954 for (i = 0; i < bt_bahama[on][version + offset].size; i++) {
9955 u8 value = (p+i)->value;
9956 rc = marimba_write_bit_mask(&config,
9957 (p+i)->reg,
9958 &value,
9959 sizeof((p+i)->value),
9960 (p+i)->mask);
9961 if (rc < 0) {
9962 dev_err(&msm_bt_power_device.dev,
9963 "%s: reg %d write failed: %d\n",
9964 __func__, (p+i)->reg, rc);
9965 return rc;
9966 }
9967 dev_dbg(&msm_bt_power_device.dev,
9968 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
9969 __func__, (p+i)->reg,
9970 value, (p+i)->mask);
9971 }
9972 /* Update BT Status */
9973 if (on)
9974 marimba_set_bt_status(&config, true);
9975 else
9976 marimba_set_bt_status(&config, false);
9977
9978 return 0;
9979}
9980
9981static int bluetooth_use_regulators(int on)
9982{
9983 int i, recover = -1, rc = 0;
9984
9985 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9986 bt_regs[i] = on ? regulator_get(&msm_bt_power_device.dev,
9987 bt_regs_info[i].name) :
9988 (regulator_put(bt_regs[i]), NULL);
9989 if (IS_ERR(bt_regs[i])) {
9990 rc = PTR_ERR(bt_regs[i]);
9991 dev_err(&msm_bt_power_device.dev,
9992 "regulator %s get failed (%d)\n",
9993 bt_regs_info[i].name, rc);
9994 recover = i - 1;
9995 bt_regs[i] = NULL;
9996 break;
9997 }
9998
9999 if (!on)
10000 continue;
10001
10002 rc = regulator_set_voltage(bt_regs[i],
10003 bt_regs_info[i].vmin,
10004 bt_regs_info[i].vmax);
10005 if (rc < 0) {
10006 dev_err(&msm_bt_power_device.dev,
10007 "regulator %s voltage set (%d)\n",
10008 bt_regs_info[i].name, rc);
10009 recover = i;
10010 break;
10011 }
10012 }
10013
10014 if (on && (recover > -1))
10015 for (i = recover; i >= 0; i--) {
10016 regulator_put(bt_regs[i]);
10017 bt_regs[i] = NULL;
10018 }
10019
10020 return rc;
10021}
10022
10023static int bluetooth_switch_regulators(int on)
10024{
10025 int i, rc = 0;
10026
10027 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
10028 if (on && (bt_regs_status[i].enabled == false)) {
10029 rc = regulator_enable(bt_regs[i]);
10030 if (rc < 0) {
10031 dev_err(&msm_bt_power_device.dev,
10032 "regulator %s %s failed (%d)\n",
10033 bt_regs_info[i].name,
10034 "enable", rc);
10035 if (i > 0) {
10036 while (--i) {
10037 regulator_disable(bt_regs[i]);
10038 bt_regs_status[i].enabled
10039 = false;
10040 }
10041 break;
10042 }
10043 }
10044 bt_regs_status[i].enabled = true;
10045 } else if (!on && (bt_regs_status[i].enabled == true)) {
10046 rc = regulator_disable(bt_regs[i]);
10047 if (rc < 0) {
10048 dev_err(&msm_bt_power_device.dev,
10049 "regulator %s %s failed (%d)\n",
10050 bt_regs_info[i].name,
10051 "disable", rc);
10052 break;
10053 }
10054 bt_regs_status[i].enabled = false;
10055 }
10056 }
10057 return rc;
10058}
10059
10060static struct msm_xo_voter *bt_clock;
10061
10062static int bluetooth_power(int on)
10063{
10064 int rc = 0;
10065 int id;
10066
10067 /* In case probe function fails, cur_connv_type would be -1 */
10068 id = adie_get_detected_connectivity_type();
10069 if (id != BAHAMA_ID) {
10070 pr_err("%s: unexpected adie connectivity type: %d\n",
10071 __func__, id);
10072 return -ENODEV;
10073 }
10074
10075 if (on) {
10076
10077 rc = bluetooth_use_regulators(1);
10078 if (rc < 0)
10079 goto out;
10080
10081 rc = bluetooth_switch_regulators(1);
10082
10083 if (rc < 0)
10084 goto fail_put;
10085
10086 bt_clock = msm_xo_get(MSM_XO_TCXO_D0, "bt_power");
10087
10088 if (IS_ERR(bt_clock)) {
10089 pr_err("Couldn't get TCXO_D0 voter\n");
10090 goto fail_switch;
10091 }
10092
10093 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_ON);
10094
10095 if (rc < 0) {
10096 pr_err("Failed to vote for TCXO_DO ON\n");
10097 goto fail_vote;
10098 }
10099
10100 rc = bahama_bt(1);
10101
10102 if (rc < 0)
10103 goto fail_clock;
10104
10105 msleep(10);
10106
10107 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_PIN_CTRL);
10108
10109 if (rc < 0) {
10110 pr_err("Failed to vote for TCXO_DO pin control\n");
10111 goto fail_vote;
10112 }
10113 } else {
10114 /* check for initial RFKILL block (power off) */
10115 /* some RFKILL versions/configurations rfkill_register */
10116 /* calls here for an initial set_block */
10117 /* avoid calling i2c and regulator before unblock (on) */
10118 if (platform_get_drvdata(&msm_bt_power_device) == NULL) {
10119 dev_info(&msm_bt_power_device.dev,
10120 "%s: initialized OFF/blocked\n", __func__);
10121 goto out;
10122 }
10123
10124 bahama_bt(0);
10125
10126fail_clock:
10127 msm_xo_mode_vote(bt_clock, MSM_XO_MODE_OFF);
10128fail_vote:
10129 msm_xo_put(bt_clock);
10130fail_switch:
10131 bluetooth_switch_regulators(0);
10132fail_put:
10133 bluetooth_use_regulators(0);
10134 }
10135
10136out:
10137 if (rc < 0)
10138 on = 0;
10139 dev_info(&msm_bt_power_device.dev,
10140 "Bluetooth power switch: state %d result %d\n", on, rc);
10141
10142 return rc;
10143}
10144
10145#endif /*CONFIG_MARIMBA_CORE, CONFIG_MSM_BT_POWER, CONFIG_MSM_BT_POWER_MODULE*/
10146
10147static void __init msm8x60_cfg_smsc911x(void)
10148{
10149 smsc911x_resources[1].start =
10150 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10151 smsc911x_resources[1].end =
10152 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
10153}
10154
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010155void msm_fusion_setup_pinctrl(void)
10156{
10157 struct msm_xo_voter *a1;
10158
10159 if (socinfo_get_platform_subtype() == 0x3) {
10160 /*
10161 * Vote for the A1 clock to be in pin control mode before
10162 * the external images are loaded.
10163 */
10164 a1 = msm_xo_get(MSM_XO_TCXO_A1, "mdm");
10165 BUG_ON(!a1);
10166 msm_xo_mode_vote(a1, MSM_XO_MODE_PIN_CTRL);
10167 }
10168}
10169
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010170struct msm_board_data {
10171 struct msm_gpiomux_configs *gpiomux_cfgs;
10172};
10173
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010174static struct msm_board_data msm8x60_surf_board_data __initdata = {
10175 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10176};
10177
10178static struct msm_board_data msm8x60_ffa_board_data __initdata = {
10179 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
10180};
10181
10182static struct msm_board_data msm8x60_fluid_board_data __initdata = {
10183 .gpiomux_cfgs = msm8x60_fluid_gpiomux_cfgs,
10184};
10185
10186static struct msm_board_data msm8x60_charm_surf_board_data __initdata = {
10187 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10188};
10189
10190static struct msm_board_data msm8x60_charm_ffa_board_data __initdata = {
10191 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
10192};
10193
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010194static struct msm_board_data msm8x60_dragon_board_data __initdata = {
10195 .gpiomux_cfgs = msm8x60_dragon_gpiomux_cfgs,
10196};
10197
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010198static void __init msm8x60_init(struct msm_board_data *board_data)
10199{
10200 uint32_t soc_platform_version;
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010201#ifdef CONFIG_USB_EHCI_MSM_72K
10202 struct pm8xxx_mpp_config_data hsusb_phy_mpp = {
10203 .type = PM8XXX_MPP_TYPE_D_OUTPUT,
10204 .level = PM8901_MPP_DIG_LEVEL_L5,
10205 .control = PM8XXX_MPP_DOUT_CTRL_HIGH,
10206 };
10207#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010208 pmic_reset_irq = PM8058_IRQ_BASE + PM8058_RESOUT_IRQ;
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070010209
Rohit Vaswanib1cc4932012-07-23 21:30:11 -070010210 platform_device_register(&msm_gpio_device);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010211 /*
10212 * Initialize RPM first as other drivers and devices may need
10213 * it for their initialization.
10214 */
Praveen Chidambaram78499012011-11-01 17:15:17 -060010215 BUG_ON(msm_rpm_init(&msm8660_rpm_data));
10216 BUG_ON(msm_rpmrs_levels_init(&msm_rpmrs_data));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010217 if (msm_xo_init())
10218 pr_err("Failed to initialize XO votes\n");
10219
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010220 msm8x60_check_2d_hardware();
10221
10222 /* Change SPM handling of core 1 if PMM 8160 is present. */
10223 soc_platform_version = socinfo_get_platform_version();
10224 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1 &&
10225 SOCINFO_VERSION_MINOR(soc_platform_version) >= 2) {
10226 struct msm_spm_platform_data *spm_data;
10227
10228 spm_data = &msm_spm_data_v1[1];
10229 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10230 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10231
10232 spm_data = &msm_spm_data[1];
10233 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
10234 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
10235 }
10236
10237 /*
10238 * Initialize SPM before acpuclock as the latter calls into SPM
10239 * driver to set ACPU voltages.
10240 */
10241 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
10242 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
10243 else
10244 msm_spm_init(msm_spm_data_v1, ARRAY_SIZE(msm_spm_data_v1));
10245
10246 /*
10247 * Set regulators 8901_l4 and 8901_l6 to be always on in HPM for SURF
10248 * devices so that the RPM doesn't drop into a low power mode that an
10249 * un-reworked SURF cannot resume from.
10250 */
10251 if (machine_is_msm8x60_surf()) {
David Collins6f032ba2011-08-31 14:08:15 -070010252 int i;
10253
10254 for (i = 0; i < ARRAY_SIZE(rpm_regulator_init_data); i++)
10255 if (rpm_regulator_init_data[i].id
10256 == RPM_VREG_ID_PM8901_L4
10257 || rpm_regulator_init_data[i].id
10258 == RPM_VREG_ID_PM8901_L6)
10259 rpm_regulator_init_data[i]
10260 .init_data.constraints.always_on = 1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010261 }
10262
10263 /*
10264 * Disable regulator info printing so that regulator registration
10265 * messages do not enter the kmsg log.
10266 */
10267 regulator_suppress_info_printing();
10268
10269 /* Initialize regulators needed for clock_init. */
10270 platform_add_devices(early_regulators, ARRAY_SIZE(early_regulators));
10271
Stephen Boydbb600ae2011-08-02 20:11:40 -070010272 msm_clock_init(&msm8x60_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010273
10274 /* Buses need to be initialized before early-device registration
10275 * to get the platform data for fabrics.
10276 */
10277 msm8x60_init_buses();
10278 platform_add_devices(early_devices, ARRAY_SIZE(early_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010279
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010280 /*
10281 * Enable EBI2 only for boards which make use of it. Leave
10282 * it disabled for all others for additional power savings.
10283 */
10284 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Terence Hampsonb36a38c2011-09-19 19:10:40 -040010285 machine_is_msm8x60_fluid() ||
10286 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010287 msm8x60_init_ebi2();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010288 msm8x60_init_gpiomux(board_data->gpiomux_cfgs);
10289 msm8x60_init_uart12dm();
Kevin Chan3be11612012-03-22 20:05:40 -070010290#ifdef CONFIG_MSM_CAMERA_V4L2
10291 msm8x60_init_cam();
10292#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010293 msm8x60_init_mmc();
10294
Kevin Chan3be11612012-03-22 20:05:40 -070010295
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010296#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
10297 msm8x60_init_pm8058_othc();
10298#endif
10299
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010300 if (machine_is_msm8x60_fluid())
10301 pm8058_platform_data.keypad_pdata = &fluid_keypad_data;
10302 else if (machine_is_msm8x60_dragon())
10303 pm8058_platform_data.keypad_pdata = &dragon_keypad_data;
10304 else
10305 pm8058_platform_data.keypad_pdata = &ffa_keypad_data;
Steve Mucklef132c6c2012-06-06 18:30:57 -070010306#if !defined(CONFIG_MSM_CAMERA_V4L2) && defined(CONFIG_WEBCAM_OV9726)
Jilai Wang53d27a82011-07-13 14:32:58 -040010307 /* Specify reset pin for OV9726 */
10308 if (machine_is_msm8x60_dragon()) {
10309 msm_camera_sensor_ov9726_data.sensor_reset = 62;
10310 ov9726_sensor_8660_info.mount_angle = 270;
10311 }
Kevin Chan3be11612012-03-22 20:05:40 -070010312#endif
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010313#ifdef CONFIG_BATTERY_MSM8X60
10314 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10315 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
10316 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_fluid())
10317 platform_device_register(&msm_charger_device);
10318#endif
10319
10320 if (machine_is_msm8x60_dragon())
10321 pm8058_platform_data.charger_pdata = &pmic8058_charger_dragon;
10322 if (!machine_is_msm8x60_fluid())
10323 pm8058_platform_data.charger_pdata = &pmic8058_charger_ffa_surf;
10324
10325 /* configure pmic leds */
10326 if (machine_is_msm8x60_fluid())
10327 pm8058_platform_data.leds_pdata = &pm8058_fluid_flash_leds_data;
10328 else if (machine_is_msm8x60_dragon())
10329 pm8058_platform_data.leds_pdata = &pm8058_dragon_leds_data;
10330 else
10331 pm8058_platform_data.leds_pdata = &pm8058_flash_leds_data;
10332
10333 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
10334 machine_is_msm8x60_dragon()) {
10335 pm8058_platform_data.vibrator_pdata = &pm8058_vib_pdata;
10336 }
10337
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010338 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10339 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010340 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010341 msm8x60_cfg_smsc911x();
10342 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
Matt Wagantall1f65d9d2012-04-25 14:24:20 -070010343 platform_add_devices(msm8660_footswitch,
10344 msm8660_num_footswitch);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010345 platform_add_devices(surf_devices,
10346 ARRAY_SIZE(surf_devices));
10347
10348#ifdef CONFIG_MSM_DSPS
10349 if (machine_is_msm8x60_fluid()) {
10350 platform_device_unregister(&msm_gsbi12_qup_i2c_device);
10351 msm8x60_init_dsps();
10352 }
10353#endif
10354
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010355 pm8901_vreg_mpp0_init();
10356
10357 platform_device_register(&msm8x60_8901_mpp_vreg);
10358
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010359#ifdef CONFIG_USB_EHCI_MSM_72K
10360 /*
10361 * Drive MPP2 pin HIGH for PHY to generate ID interrupts on 8660
10362 * fluid
10363 */
Anirudh Ghayal9f77e962011-12-06 12:38:21 +053010364 if (machine_is_msm8x60_fluid())
10365 pm8xxx_mpp_config(PM8901_MPP_PM_TO_SYS(1), &hsusb_phy_mpp);
10366 msm_add_host(0, &msm_usb_host_pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010367#endif
Lei Zhou338cab82011-08-19 13:38:17 -040010368
10369#ifdef CONFIG_SND_SOC_MSM8660_APQ
10370 if (machine_is_msm8x60_dragon())
10371 platform_add_devices(dragon_alsa_devices,
10372 ARRAY_SIZE(dragon_alsa_devices));
10373 else
10374#endif
10375 platform_add_devices(asoc_devices,
10376 ARRAY_SIZE(asoc_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010377 }
10378#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -040010379 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
10380 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010381 msm8x60_cfg_isp1763();
10382#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010383
10384 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10385 platform_add_devices(charm_devices, ARRAY_SIZE(charm_devices));
10386
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010387
10388#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
10389 if (machine_is_msm8x60_fluid())
10390 platform_device_register(&msm_gsbi10_qup_spi_device);
10391 else
10392 platform_device_register(&msm_gsbi1_qup_spi_device);
10393#endif
10394
Steve Mucklef132c6c2012-06-06 18:30:57 -070010395#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) || \
10396 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010397 if (machine_is_msm8x60_fluid())
10398 cyttsp_set_params();
10399#endif
Syed Rameez Mustafae4a6f8e2012-07-09 15:25:13 -070010400 msm_fb_add_devices();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010401 fixup_i2c_configs();
10402 register_i2c_devices();
10403
Terence Hampson1c73fef2011-07-19 17:10:49 -040010404 if (machine_is_msm8x60_dragon())
10405 smsc911x_config.reset_gpio
10406 = GPIO_ETHERNET_RESET_N_DRAGON;
10407
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010408 platform_device_register(&smsc911x_device);
10409
10410#if (defined(CONFIG_SPI_QUP)) && \
10411 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010412 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA) || \
10413 defined(CONFIG_FB_MSM_LCDC_NT35582_WVGA))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010414
10415 if (machine_is_msm8x60_fluid()) {
10416#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
10417 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
10418 spi_register_board_info(lcdc_samsung_spi_board_info,
10419 ARRAY_SIZE(lcdc_samsung_spi_board_info));
10420 } else
10421#endif
10422 {
10423#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
10424 spi_register_board_info(lcdc_auo_spi_board_info,
10425 ARRAY_SIZE(lcdc_auo_spi_board_info));
10426#endif
10427 }
Zhang Chang Ken3a8b8512011-08-04 18:41:39 -040010428#ifdef CONFIG_FB_MSM_LCDC_NT35582_WVGA
10429 } else if (machine_is_msm8x60_dragon()) {
10430 spi_register_board_info(lcdc_nt35582_spi_board_info,
10431 ARRAY_SIZE(lcdc_nt35582_spi_board_info));
10432#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010433 }
10434#endif
10435
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060010436 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010437
Anirudh Ghayalc2019332011-11-12 06:29:10 +053010438 pm8058_gpios_init();
10439
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010440#ifdef CONFIG_SENSORS_MSM_ADC
10441 if (machine_is_msm8x60_fluid()) {
10442 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
10443 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
10444 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3)
10445 msm_adc_pdata.gpio_config = APROC_CONFIG;
10446 else
10447 msm_adc_pdata.gpio_config = MPROC_CONFIG;
10448 }
10449 msm_adc_pdata.target_hw = MSM_8x60;
10450#endif
10451#ifdef CONFIG_MSM8X60_AUDIO
10452 msm_snddev_init();
10453#endif
10454#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
10455 if (machine_is_msm8x60_fluid())
10456 platform_device_register(&fluid_leds_gpio);
10457 else
10458 platform_device_register(&gpio_leds);
10459#endif
10460
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010461 msm8x60_multi_sdio_init();
Laura Abbott5d2d1e62011-08-10 16:27:35 -070010462
10463 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
10464 msm_fusion_setup_pinctrl();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010465}
10466
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010467static void __init msm8x60_surf_init(void)
10468{
10469 msm8x60_init(&msm8x60_surf_board_data);
10470}
10471
10472static void __init msm8x60_ffa_init(void)
10473{
10474 msm8x60_init(&msm8x60_ffa_board_data);
10475}
10476
10477static void __init msm8x60_fluid_init(void)
10478{
10479 msm8x60_init(&msm8x60_fluid_board_data);
10480}
10481
10482static void __init msm8x60_charm_surf_init(void)
10483{
10484 msm8x60_init(&msm8x60_charm_surf_board_data);
10485}
10486
10487static void __init msm8x60_charm_ffa_init(void)
10488{
10489 msm8x60_init(&msm8x60_charm_ffa_board_data);
10490}
10491
10492static void __init msm8x60_charm_init_early(void)
10493{
10494 msm8x60_allocate_memory_regions();
Steve Mucklea55df6e2010-01-07 12:43:24 -080010495}
10496
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010497static void __init msm8x60_dragon_init(void)
10498{
10499 msm8x60_init(&msm8x60_dragon_board_data);
10500}
David Brown56e2d8a2011-08-04 02:01:02 -070010501
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010502MACHINE_START(MSM8X60_SURF, "QCT MSM8X60 SURF")
10503 .map_io = msm8x60_map_io,
10504 .reserve = msm8x60_reserve,
10505 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010506 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010507 .init_machine = msm8x60_surf_init,
10508 .timer = &msm_timer,
10509 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010510 .restart = msm_restart,
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -080010511 .smp = &scorpion_smp_ops,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010512MACHINE_END
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010513
10514MACHINE_START(MSM8X60_FFA, "QCT MSM8X60 FFA")
10515 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010516 .reserve = msm8x60_reserve,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010517 .init_irq = msm8x60_init_irq,
Marc Zyngier041f7772011-09-06 10:23:45 +010010518 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010519 .init_machine = msm8x60_ffa_init,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010520 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010521 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010522 .restart = msm_restart,
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -080010523 .smp = &scorpion_smp_ops,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010524MACHINE_END
David Brown56e2d8a2011-08-04 02:01:02 -070010525
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010526MACHINE_START(MSM8X60_FLUID, "QCT MSM8X60 FLUID")
David Brown56e2d8a2011-08-04 02:01:02 -070010527 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010528 .reserve = msm8x60_reserve,
David Brown56e2d8a2011-08-04 02:01:02 -070010529 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010530 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010531 .init_machine = msm8x60_fluid_init,
David Brown56e2d8a2011-08-04 02:01:02 -070010532 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010533 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010534 .restart = msm_restart,
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -080010535 .smp = &scorpion_smp_ops,
David Brown56e2d8a2011-08-04 02:01:02 -070010536MACHINE_END
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010537
10538MACHINE_START(MSM8X60_FUSION, "QCT MSM8X60 FUSION SURF")
10539 .map_io = msm8x60_map_io,
10540 .reserve = msm8x60_reserve,
10541 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010542 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010543 .init_machine = msm8x60_charm_surf_init,
10544 .timer = &msm_timer,
10545 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010546 .restart = msm_restart,
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -080010547 .smp = &scorpion_smp_ops,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010548MACHINE_END
10549
10550MACHINE_START(MSM8X60_FUSN_FFA, "QCT MSM8X60 FUSION FFA")
10551 .map_io = msm8x60_map_io,
10552 .reserve = msm8x60_reserve,
10553 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010554 .handle_irq = gic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010555 .init_machine = msm8x60_charm_ffa_init,
10556 .timer = &msm_timer,
10557 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010558 .restart = msm_restart,
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -080010559 .smp = &scorpion_smp_ops,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010560MACHINE_END
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010561
10562MACHINE_START(MSM8X60_DRAGON, "QCT MSM8X60 DRAGON")
10563 .map_io = msm8x60_map_io,
10564 .reserve = msm8x60_reserve,
10565 .init_irq = msm8x60_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +053010566 .handle_irq = gic_handle_irq,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010567 .init_machine = msm8x60_dragon_init,
10568 .timer = &msm_timer,
10569 .init_early = msm8x60_charm_init_early,
Jeff Ohlsteindd0dd9b2012-05-29 17:47:21 -070010570 .restart = msm_restart,
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -080010571 .smp = &scorpion_smp_ops,
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010572MACHINE_END