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