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