blob: 2c5e9a451be14685ce6d9cfd86f553b6271d0d40 [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
2583/* 960 x 540 x 3 x 2 */
2584#define MSM_FB_WRITEBACK_SIZE 0x300000
2585#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
3336#ifdef CONFIG_SERIAL_MSM_HS
3337static int configure_uart_gpios(int on)
3338{
3339 int ret = 0, i;
3340 int uart_gpios[] = {53, 54, 55, 56};
3341 for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
3342 if (on) {
3343 ret = msm_gpiomux_get(uart_gpios[i]);
3344 if (unlikely(ret))
3345 break;
3346 } else {
3347 ret = msm_gpiomux_put(uart_gpios[i]);
3348 if (unlikely(ret))
3349 return ret;
3350 }
3351 }
3352 if (ret)
3353 for (; i >= 0; i--)
3354 msm_gpiomux_put(uart_gpios[i]);
3355 return ret;
3356}
3357static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3358 .inject_rx_on_wakeup = 1,
3359 .rx_to_inject = 0xFD,
3360 .gpio_config = configure_uart_gpios,
3361};
3362#endif
3363
3364
3365#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
3366
3367static struct gpio_led gpio_exp_leds_config[] = {
3368 {
3369 .name = "left_led1:green",
3370 .gpio = GPIO_LEFT_LED_1,
3371 .active_low = 1,
3372 .retain_state_suspended = 0,
3373 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3374 },
3375 {
3376 .name = "left_led2:red",
3377 .gpio = GPIO_LEFT_LED_2,
3378 .active_low = 1,
3379 .retain_state_suspended = 0,
3380 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3381 },
3382 {
3383 .name = "left_led3:green",
3384 .gpio = GPIO_LEFT_LED_3,
3385 .active_low = 1,
3386 .retain_state_suspended = 0,
3387 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3388 },
3389 {
3390 .name = "wlan_led:orange",
3391 .gpio = GPIO_LEFT_LED_WLAN,
3392 .active_low = 1,
3393 .retain_state_suspended = 0,
3394 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3395 },
3396 {
3397 .name = "left_led5:green",
3398 .gpio = GPIO_LEFT_LED_5,
3399 .active_low = 1,
3400 .retain_state_suspended = 0,
3401 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3402 },
3403 {
3404 .name = "right_led1:green",
3405 .gpio = GPIO_RIGHT_LED_1,
3406 .active_low = 1,
3407 .retain_state_suspended = 0,
3408 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3409 },
3410 {
3411 .name = "right_led2:red",
3412 .gpio = GPIO_RIGHT_LED_2,
3413 .active_low = 1,
3414 .retain_state_suspended = 0,
3415 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3416 },
3417 {
3418 .name = "right_led3:green",
3419 .gpio = GPIO_RIGHT_LED_3,
3420 .active_low = 1,
3421 .retain_state_suspended = 0,
3422 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3423 },
3424 {
3425 .name = "bt_led:blue",
3426 .gpio = GPIO_RIGHT_LED_BT,
3427 .active_low = 1,
3428 .retain_state_suspended = 0,
3429 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3430 },
3431 {
3432 .name = "right_led5:green",
3433 .gpio = GPIO_RIGHT_LED_5,
3434 .active_low = 1,
3435 .retain_state_suspended = 0,
3436 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3437 },
3438};
3439
3440static struct gpio_led_platform_data gpio_leds_pdata = {
3441 .num_leds = ARRAY_SIZE(gpio_exp_leds_config),
3442 .leds = gpio_exp_leds_config,
3443};
3444
3445static struct platform_device gpio_leds = {
3446 .name = "leds-gpio",
3447 .id = -1,
3448 .dev = {
3449 .platform_data = &gpio_leds_pdata,
3450 },
3451};
3452
3453static struct gpio_led fluid_gpio_leds[] = {
3454 {
3455 .name = "dual_led:green",
3456 .gpio = GPIO_LED1_GREEN_N,
3457 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3458 .active_low = 1,
3459 .retain_state_suspended = 0,
3460 },
3461 {
3462 .name = "dual_led:red",
3463 .gpio = GPIO_LED2_RED_N,
3464 .default_state = LEDS_GPIO_DEFSTATE_OFF,
3465 .active_low = 1,
3466 .retain_state_suspended = 0,
3467 },
3468};
3469
3470static struct gpio_led_platform_data gpio_led_pdata = {
3471 .leds = fluid_gpio_leds,
3472 .num_leds = ARRAY_SIZE(fluid_gpio_leds),
3473};
3474
3475static struct platform_device fluid_leds_gpio = {
3476 .name = "leds-gpio",
3477 .id = -1,
3478 .dev = {
3479 .platform_data = &gpio_led_pdata,
3480 },
3481};
3482
3483#endif
3484
3485#if defined(CONFIG_MSM_RPM_LOG) || defined(CONFIG_MSM_RPM_LOG_MODULE)
3486
3487static struct msm_rpm_log_platform_data msm_rpm_log_pdata = {
3488 .phys_addr_base = 0x00106000,
3489 .reg_offsets = {
3490 [MSM_RPM_LOG_PAGE_INDICES] = 0x00000C80,
3491 [MSM_RPM_LOG_PAGE_BUFFER] = 0x00000CA0,
3492 },
3493 .phys_size = SZ_8K,
3494 .log_len = 4096, /* log's buffer length in bytes */
3495 .log_len_mask = (4096 >> 2) - 1, /* length mask in units of u32 */
3496};
3497
3498static struct platform_device msm_rpm_log_device = {
3499 .name = "msm_rpm_log",
3500 .id = -1,
3501 .dev = {
3502 .platform_data = &msm_rpm_log_pdata,
3503 },
3504};
3505#endif
3506
3507#ifdef CONFIG_BATTERY_MSM8X60
3508static struct msm_charger_platform_data msm_charger_data = {
3509 .safety_time = 180,
3510 .update_time = 1,
3511 .max_voltage = 4200,
3512 .min_voltage = 3200,
3513};
3514
3515static struct platform_device msm_charger_device = {
3516 .name = "msm-charger",
3517 .id = -1,
3518 .dev = {
3519 .platform_data = &msm_charger_data,
3520 }
3521};
3522#endif
3523
3524/*
3525 * Consumer specific regulator names:
3526 * regulator name consumer dev_name
3527 */
3528static struct regulator_consumer_supply vreg_consumers_PM8058_L0[] = {
3529 REGULATOR_SUPPLY("8058_l0", NULL),
3530};
3531static struct regulator_consumer_supply vreg_consumers_PM8058_L1[] = {
3532 REGULATOR_SUPPLY("8058_l1", NULL),
3533};
3534static struct regulator_consumer_supply vreg_consumers_PM8058_L2[] = {
3535 REGULATOR_SUPPLY("8058_l2", NULL),
3536};
3537static struct regulator_consumer_supply vreg_consumers_PM8058_L3[] = {
3538 REGULATOR_SUPPLY("8058_l3", NULL),
3539};
3540static struct regulator_consumer_supply vreg_consumers_PM8058_L4[] = {
3541 REGULATOR_SUPPLY("8058_l4", NULL),
3542};
3543static struct regulator_consumer_supply vreg_consumers_PM8058_L5[] = {
3544 REGULATOR_SUPPLY("8058_l5", NULL),
3545};
3546static struct regulator_consumer_supply vreg_consumers_PM8058_L6[] = {
3547 REGULATOR_SUPPLY("8058_l6", NULL),
3548};
3549static struct regulator_consumer_supply vreg_consumers_PM8058_L7[] = {
3550 REGULATOR_SUPPLY("8058_l7", NULL),
3551};
3552static struct regulator_consumer_supply vreg_consumers_PM8058_L8[] = {
3553 REGULATOR_SUPPLY("8058_l8", NULL),
3554};
3555static struct regulator_consumer_supply vreg_consumers_PM8058_L9[] = {
3556 REGULATOR_SUPPLY("8058_l9", NULL),
3557};
3558static struct regulator_consumer_supply vreg_consumers_PM8058_L10[] = {
3559 REGULATOR_SUPPLY("8058_l10", NULL),
3560};
3561static struct regulator_consumer_supply vreg_consumers_PM8058_L11[] = {
3562 REGULATOR_SUPPLY("8058_l11", NULL),
3563};
3564static struct regulator_consumer_supply vreg_consumers_PM8058_L12[] = {
3565 REGULATOR_SUPPLY("8058_l12", NULL),
3566};
3567static struct regulator_consumer_supply vreg_consumers_PM8058_L13[] = {
3568 REGULATOR_SUPPLY("8058_l13", NULL),
3569};
3570static struct regulator_consumer_supply vreg_consumers_PM8058_L14[] = {
3571 REGULATOR_SUPPLY("8058_l14", NULL),
3572};
3573static struct regulator_consumer_supply vreg_consumers_PM8058_L15[] = {
3574 REGULATOR_SUPPLY("8058_l15", NULL),
3575};
3576static struct regulator_consumer_supply vreg_consumers_PM8058_L16[] = {
3577 REGULATOR_SUPPLY("8058_l16", NULL),
3578};
3579static struct regulator_consumer_supply vreg_consumers_PM8058_L17[] = {
3580 REGULATOR_SUPPLY("8058_l17", NULL),
3581};
3582static struct regulator_consumer_supply vreg_consumers_PM8058_L18[] = {
3583 REGULATOR_SUPPLY("8058_l18", NULL),
3584};
3585static struct regulator_consumer_supply vreg_consumers_PM8058_L19[] = {
3586 REGULATOR_SUPPLY("8058_l19", NULL),
3587};
3588static struct regulator_consumer_supply vreg_consumers_PM8058_L20[] = {
3589 REGULATOR_SUPPLY("8058_l20", NULL),
3590};
3591static struct regulator_consumer_supply vreg_consumers_PM8058_L21[] = {
3592 REGULATOR_SUPPLY("8058_l21", NULL),
3593};
3594static struct regulator_consumer_supply vreg_consumers_PM8058_L22[] = {
3595 REGULATOR_SUPPLY("8058_l22", NULL),
3596};
3597static struct regulator_consumer_supply vreg_consumers_PM8058_L23[] = {
3598 REGULATOR_SUPPLY("8058_l23", NULL),
3599};
3600static struct regulator_consumer_supply vreg_consumers_PM8058_L24[] = {
3601 REGULATOR_SUPPLY("8058_l24", NULL),
3602};
3603static struct regulator_consumer_supply vreg_consumers_PM8058_L25[] = {
3604 REGULATOR_SUPPLY("8058_l25", NULL),
3605};
3606static struct regulator_consumer_supply vreg_consumers_PM8058_S0[] = {
3607 REGULATOR_SUPPLY("8058_s0", NULL),
3608};
3609static struct regulator_consumer_supply vreg_consumers_PM8058_S1[] = {
3610 REGULATOR_SUPPLY("8058_s1", NULL),
3611};
3612static struct regulator_consumer_supply vreg_consumers_PM8058_S2[] = {
3613 REGULATOR_SUPPLY("8058_s2", NULL),
3614};
3615static struct regulator_consumer_supply vreg_consumers_PM8058_S3[] = {
3616 REGULATOR_SUPPLY("8058_s3", NULL),
3617};
3618static struct regulator_consumer_supply vreg_consumers_PM8058_S4[] = {
3619 REGULATOR_SUPPLY("8058_s4", NULL),
3620};
3621static struct regulator_consumer_supply vreg_consumers_PM8058_LVS0[] = {
3622 REGULATOR_SUPPLY("8058_lvs0", NULL),
3623};
3624static struct regulator_consumer_supply vreg_consumers_PM8058_LVS1[] = {
3625 REGULATOR_SUPPLY("8058_lvs1", NULL),
3626};
3627static struct regulator_consumer_supply vreg_consumers_PM8058_NCP[] = {
3628 REGULATOR_SUPPLY("8058_ncp", NULL),
3629};
3630
3631static struct regulator_consumer_supply vreg_consumers_PM8901_L0[] = {
3632 REGULATOR_SUPPLY("8901_l0", NULL),
3633};
3634static struct regulator_consumer_supply vreg_consumers_PM8901_L1[] = {
3635 REGULATOR_SUPPLY("8901_l1", NULL),
3636};
3637static struct regulator_consumer_supply vreg_consumers_PM8901_L2[] = {
3638 REGULATOR_SUPPLY("8901_l2", NULL),
3639};
3640static struct regulator_consumer_supply vreg_consumers_PM8901_L3[] = {
3641 REGULATOR_SUPPLY("8901_l3", NULL),
3642};
3643static struct regulator_consumer_supply vreg_consumers_PM8901_L4[] = {
3644 REGULATOR_SUPPLY("8901_l4", NULL),
3645};
3646static struct regulator_consumer_supply vreg_consumers_PM8901_L5[] = {
3647 REGULATOR_SUPPLY("8901_l5", NULL),
3648};
3649static struct regulator_consumer_supply vreg_consumers_PM8901_L6[] = {
3650 REGULATOR_SUPPLY("8901_l6", NULL),
3651};
3652static struct regulator_consumer_supply vreg_consumers_PM8901_S2[] = {
3653 REGULATOR_SUPPLY("8901_s2", NULL),
3654};
3655static struct regulator_consumer_supply vreg_consumers_PM8901_S3[] = {
3656 REGULATOR_SUPPLY("8901_s3", NULL),
3657};
3658static struct regulator_consumer_supply vreg_consumers_PM8901_S4[] = {
3659 REGULATOR_SUPPLY("8901_s4", NULL),
3660};
3661static struct regulator_consumer_supply vreg_consumers_PM8901_LVS0[] = {
3662 REGULATOR_SUPPLY("8901_lvs0", NULL),
3663};
3664static struct regulator_consumer_supply vreg_consumers_PM8901_LVS1[] = {
3665 REGULATOR_SUPPLY("8901_lvs1", NULL),
3666};
3667static struct regulator_consumer_supply vreg_consumers_PM8901_LVS2[] = {
3668 REGULATOR_SUPPLY("8901_lvs2", NULL),
3669};
3670static struct regulator_consumer_supply vreg_consumers_PM8901_LVS3[] = {
3671 REGULATOR_SUPPLY("8901_lvs3", NULL),
3672};
3673static struct regulator_consumer_supply vreg_consumers_PM8901_MVS0[] = {
3674 REGULATOR_SUPPLY("8901_mvs0", NULL),
3675};
3676
3677#define RPM_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
3678 _default_uV, _peak_uA, _avg_uA, _pull_down, _pin_ctrl, \
3679 _freq, _pin_fn, _rpm_mode, _state, _sleep_selectable, \
3680 _always_on) \
3681 [RPM_VREG_ID_##_id] = { \
3682 .init_data = { \
3683 .constraints = { \
3684 .valid_modes_mask = _modes, \
3685 .valid_ops_mask = _ops, \
3686 .min_uV = _min_uV, \
3687 .max_uV = _max_uV, \
3688 .input_uV = _min_uV, \
3689 .apply_uV = _apply_uV, \
3690 .always_on = _always_on, \
3691 }, \
3692 .consumer_supplies = vreg_consumers_##_id, \
3693 .num_consumer_supplies = \
3694 ARRAY_SIZE(vreg_consumers_##_id), \
3695 }, \
3696 .default_uV = _default_uV, \
3697 .peak_uA = _peak_uA, \
3698 .avg_uA = _avg_uA, \
3699 .pull_down_enable = _pull_down, \
3700 .pin_ctrl = _pin_ctrl, \
3701 .freq = _freq, \
3702 .pin_fn = _pin_fn, \
3703 .mode = _rpm_mode, \
3704 .state = _state, \
3705 .sleep_selectable = _sleep_selectable, \
3706 }
3707
3708/*
3709 * The default LPM/HPM state of an RPM controlled regulator can be controlled
3710 * via the peak_uA value specified in the table below. If the value is less
3711 * than the high power min threshold for the regulator, then the regulator will
3712 * be set to LPM. Otherwise, it will be set to HPM.
3713 *
3714 * This value can be further overridden by specifying an initial mode via
3715 * .init_data.constraints.initial_mode.
3716 */
3717
3718#define RPM_VREG_INIT_LDO(_id, _always_on, _pd, _sleep_selectable, _min_uV, \
3719 _max_uV, _init_peak_uA, _pin_ctrl) \
3720 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
3721 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
3722 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
3723 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
3724 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
3725 _init_peak_uA, _pd, _pin_ctrl, RPM_VREG_FREQ_NONE, \
3726 RPM_VREG_PIN_FN_ENABLE, RPM_VREG_MODE_NONE, \
3727 RPM_VREG_STATE_OFF, _sleep_selectable, _always_on)
3728
3729#define RPM_VREG_INIT_LDO_PF(_id, _always_on, _pd, _sleep_selectable, _min_uV, \
3730 _max_uV, _init_peak_uA, _pin_ctrl, _pin_fn) \
3731 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
3732 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
3733 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
3734 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
3735 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
3736 _init_peak_uA, _pd, _pin_ctrl, RPM_VREG_FREQ_NONE, \
3737 _pin_fn, RPM_VREG_MODE_NONE, RPM_VREG_STATE_OFF, \
3738 _sleep_selectable, _always_on)
3739
3740#define RPM_VREG_INIT_SMPS(_id, _always_on, _pd, _sleep_selectable, _min_uV, \
3741 _max_uV, _init_peak_uA, _pin_ctrl, _freq) \
3742 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_FAST | \
3743 REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE | \
3744 REGULATOR_MODE_STANDBY, REGULATOR_CHANGE_VOLTAGE | \
3745 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
3746 REGULATOR_CHANGE_DRMS, 0, _min_uV, _init_peak_uA, \
3747 _init_peak_uA, _pd, _pin_ctrl, _freq, \
3748 RPM_VREG_PIN_FN_ENABLE, RPM_VREG_MODE_NONE, \
3749 RPM_VREG_STATE_OFF, _sleep_selectable, _always_on)
3750
3751#define RPM_VREG_INIT_VS(_id, _always_on, _pd, _sleep_selectable, _pin_ctrl) \
3752 RPM_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE, \
3753 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE, 0, 0, \
3754 1000, 1000, _pd, _pin_ctrl, RPM_VREG_FREQ_NONE, \
3755 RPM_VREG_PIN_FN_ENABLE, RPM_VREG_MODE_NONE, \
3756 RPM_VREG_STATE_OFF, _sleep_selectable, _always_on)
3757
3758#define RPM_VREG_INIT_NCP(_id, _always_on, _pd, _sleep_selectable, _min_uV, \
3759 _max_uV, _pin_ctrl) \
3760 RPM_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL, \
3761 REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS, 0, \
3762 _min_uV, 1000, 1000, _pd, _pin_ctrl, RPM_VREG_FREQ_NONE, \
3763 RPM_VREG_PIN_FN_ENABLE, RPM_VREG_MODE_NONE, \
3764 RPM_VREG_STATE_OFF, _sleep_selectable, _always_on)
3765
3766#define LDO50HMIN RPM_VREG_LDO_50_HPM_MIN_LOAD
3767#define LDO150HMIN RPM_VREG_LDO_150_HPM_MIN_LOAD
3768#define LDO300HMIN RPM_VREG_LDO_300_HPM_MIN_LOAD
3769#define SMPS_HMIN RPM_VREG_SMPS_HPM_MIN_LOAD
3770#define FTS_HMIN RPM_VREG_FTSMPS_HPM_MIN_LOAD
3771
3772static struct rpm_vreg_pdata rpm_vreg_init_pdata[RPM_VREG_ID_MAX] = {
3773 RPM_VREG_INIT_LDO(PM8058_L0, 0, 1, 0, 1200000, 1200000, LDO150HMIN, 0),
3774 RPM_VREG_INIT_LDO(PM8058_L1, 0, 1, 0, 1200000, 1200000, LDO300HMIN, 0),
3775 RPM_VREG_INIT_LDO(PM8058_L2, 0, 1, 0, 1800000, 2600000, LDO300HMIN, 0),
3776 RPM_VREG_INIT_LDO(PM8058_L3, 0, 1, 0, 1800000, 1800000, LDO150HMIN, 0),
3777 RPM_VREG_INIT_LDO(PM8058_L4, 0, 1, 0, 2850000, 2850000, LDO50HMIN, 0),
3778 RPM_VREG_INIT_LDO(PM8058_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN, 0),
3779 RPM_VREG_INIT_LDO(PM8058_L6, 0, 1, 0, 3000000, 3600000, LDO50HMIN, 0),
3780 RPM_VREG_INIT_LDO(PM8058_L7, 0, 1, 0, 1800000, 1800000, LDO50HMIN, 0),
3781 RPM_VREG_INIT_LDO_PF(PM8058_L8, 0, 1, 0, 2900000, 3050000, LDO300HMIN,
3782 RPM_VREG_PIN_CTRL_NONE, RPM_VREG_PIN_FN_SLEEP_B),
3783 RPM_VREG_INIT_LDO(PM8058_L9, 0, 1, 0, 1800000, 1800000, LDO300HMIN, 0),
3784 RPM_VREG_INIT_LDO(PM8058_L10, 0, 1, 0, 2600000, 2600000, LDO300HMIN, 0),
3785 RPM_VREG_INIT_LDO(PM8058_L11, 0, 1, 0, 1500000, 1500000, LDO150HMIN, 0),
3786 RPM_VREG_INIT_LDO(PM8058_L12, 0, 1, 0, 2900000, 2900000, LDO150HMIN, 0),
3787 RPM_VREG_INIT_LDO(PM8058_L13, 0, 1, 0, 2050000, 2050000, LDO300HMIN, 0),
3788 RPM_VREG_INIT_LDO(PM8058_L14, 0, 0, 0, 2850000, 2850000, LDO300HMIN, 0),
3789 RPM_VREG_INIT_LDO(PM8058_L15, 0, 1, 0, 2850000, 2850000, LDO300HMIN, 0),
3790 RPM_VREG_INIT_LDO(PM8058_L16, 1, 1, 0, 1800000, 1800000, LDO300HMIN, 0),
3791 RPM_VREG_INIT_LDO(PM8058_L17, 0, 1, 0, 2600000, 2600000, LDO150HMIN, 0),
3792 RPM_VREG_INIT_LDO(PM8058_L18, 0, 1, 0, 2200000, 2200000, LDO150HMIN, 0),
3793 RPM_VREG_INIT_LDO(PM8058_L19, 0, 1, 0, 2500000, 2500000, LDO150HMIN, 0),
3794 RPM_VREG_INIT_LDO_PF(PM8058_L20, 0, 1, 0, 1800000, 1800000, LDO150HMIN,
3795 RPM_VREG_PIN_CTRL_NONE, RPM_VREG_PIN_FN_SLEEP_B),
3796 RPM_VREG_INIT_LDO_PF(PM8058_L21, 1, 1, 0, 1200000, 1200000, LDO150HMIN,
3797 RPM_VREG_PIN_CTRL_NONE, RPM_VREG_PIN_FN_SLEEP_B),
David Collins3cfb9652011-07-27 14:24:36 -07003798 RPM_VREG_INIT_LDO(PM8058_L22, 0, 1, 0, 1150000, 1150000, LDO300HMIN, 0),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003799 RPM_VREG_INIT_LDO(PM8058_L23, 0, 1, 0, 1200000, 1200000, LDO300HMIN, 0),
3800 RPM_VREG_INIT_LDO(PM8058_L24, 0, 1, 0, 1200000, 1200000, LDO150HMIN, 0),
3801 RPM_VREG_INIT_LDO(PM8058_L25, 0, 1, 0, 1200000, 1200000, LDO150HMIN, 0),
3802
3803 RPM_VREG_INIT_SMPS(PM8058_S0, 0, 1, 1, 500000, 1250000, SMPS_HMIN, 0,
3804 RPM_VREG_FREQ_1p60),
3805 RPM_VREG_INIT_SMPS(PM8058_S1, 0, 1, 1, 500000, 1250000, SMPS_HMIN, 0,
3806 RPM_VREG_FREQ_1p60),
3807 RPM_VREG_INIT_SMPS(PM8058_S2, 0, 1, 1, 1200000, 1400000, SMPS_HMIN,
3808 RPM_VREG_PIN_CTRL_A0, RPM_VREG_FREQ_1p60),
3809 RPM_VREG_INIT_SMPS(PM8058_S3, 1, 1, 0, 1800000, 1800000, SMPS_HMIN, 0,
3810 RPM_VREG_FREQ_1p60),
3811 RPM_VREG_INIT_SMPS(PM8058_S4, 1, 1, 0, 2200000, 2200000, SMPS_HMIN, 0,
3812 RPM_VREG_FREQ_1p60),
3813
3814 RPM_VREG_INIT_VS(PM8058_LVS0, 0, 1, 0, 0),
3815 RPM_VREG_INIT_VS(PM8058_LVS1, 0, 1, 0, 0),
3816
3817 RPM_VREG_INIT_NCP(PM8058_NCP, 0, 1, 0, 1800000, 1800000, 0),
3818
3819 RPM_VREG_INIT_LDO(PM8901_L0, 0, 1, 0, 1200000, 1200000, LDO300HMIN,
3820 RPM_VREG_PIN_CTRL_A0),
3821 RPM_VREG_INIT_LDO(PM8901_L1, 0, 1, 0, 3300000, 3300000, LDO300HMIN, 0),
3822 RPM_VREG_INIT_LDO(PM8901_L2, 0, 1, 0, 2850000, 3300000, LDO300HMIN, 0),
3823 RPM_VREG_INIT_LDO(PM8901_L3, 0, 1, 0, 3300000, 3300000, LDO300HMIN, 0),
3824 RPM_VREG_INIT_LDO(PM8901_L4, 0, 1, 0, 2600000, 2600000, LDO300HMIN, 0),
3825 RPM_VREG_INIT_LDO(PM8901_L5, 0, 1, 0, 2850000, 2850000, LDO300HMIN, 0),
3826 RPM_VREG_INIT_LDO(PM8901_L6, 0, 1, 0, 2200000, 2200000, LDO300HMIN, 0),
3827
3828 RPM_VREG_INIT_SMPS(PM8901_S2, 0, 1, 0, 1300000, 1300000, FTS_HMIN, 0,
3829 RPM_VREG_FREQ_1p60),
3830 RPM_VREG_INIT_SMPS(PM8901_S3, 0, 1, 0, 1100000, 1100000, FTS_HMIN, 0,
3831 RPM_VREG_FREQ_1p60),
3832 RPM_VREG_INIT_SMPS(PM8901_S4, 0, 1, 0, 1225000, 1225000, FTS_HMIN,
3833 RPM_VREG_PIN_CTRL_A0, RPM_VREG_FREQ_1p60),
3834
3835 RPM_VREG_INIT_VS(PM8901_LVS0, 1, 1, 0, 0),
3836 RPM_VREG_INIT_VS(PM8901_LVS1, 0, 1, 0, 0),
3837 RPM_VREG_INIT_VS(PM8901_LVS2, 0, 1, 0, 0),
3838 RPM_VREG_INIT_VS(PM8901_LVS3, 0, 1, 0, 0),
3839 RPM_VREG_INIT_VS(PM8901_MVS0, 0, 1, 0, 0),
3840};
3841
3842#define RPM_VREG(_id) \
3843 [_id] = { \
3844 .name = "rpm-regulator", \
3845 .id = _id, \
3846 .dev = { \
3847 .platform_data = &rpm_vreg_init_pdata[_id], \
3848 }, \
3849 }
3850
3851static struct platform_device rpm_vreg_device[RPM_VREG_ID_MAX] = {
3852 RPM_VREG(RPM_VREG_ID_PM8058_L0),
3853 RPM_VREG(RPM_VREG_ID_PM8058_L1),
3854 RPM_VREG(RPM_VREG_ID_PM8058_L2),
3855 RPM_VREG(RPM_VREG_ID_PM8058_L3),
3856 RPM_VREG(RPM_VREG_ID_PM8058_L4),
3857 RPM_VREG(RPM_VREG_ID_PM8058_L5),
3858 RPM_VREG(RPM_VREG_ID_PM8058_L6),
3859 RPM_VREG(RPM_VREG_ID_PM8058_L7),
3860 RPM_VREG(RPM_VREG_ID_PM8058_L8),
3861 RPM_VREG(RPM_VREG_ID_PM8058_L9),
3862 RPM_VREG(RPM_VREG_ID_PM8058_L10),
3863 RPM_VREG(RPM_VREG_ID_PM8058_L11),
3864 RPM_VREG(RPM_VREG_ID_PM8058_L12),
3865 RPM_VREG(RPM_VREG_ID_PM8058_L13),
3866 RPM_VREG(RPM_VREG_ID_PM8058_L14),
3867 RPM_VREG(RPM_VREG_ID_PM8058_L15),
3868 RPM_VREG(RPM_VREG_ID_PM8058_L16),
3869 RPM_VREG(RPM_VREG_ID_PM8058_L17),
3870 RPM_VREG(RPM_VREG_ID_PM8058_L18),
3871 RPM_VREG(RPM_VREG_ID_PM8058_L19),
3872 RPM_VREG(RPM_VREG_ID_PM8058_L20),
3873 RPM_VREG(RPM_VREG_ID_PM8058_L21),
3874 RPM_VREG(RPM_VREG_ID_PM8058_L22),
3875 RPM_VREG(RPM_VREG_ID_PM8058_L23),
3876 RPM_VREG(RPM_VREG_ID_PM8058_L24),
3877 RPM_VREG(RPM_VREG_ID_PM8058_L25),
3878 RPM_VREG(RPM_VREG_ID_PM8058_S0),
3879 RPM_VREG(RPM_VREG_ID_PM8058_S1),
3880 RPM_VREG(RPM_VREG_ID_PM8058_S2),
3881 RPM_VREG(RPM_VREG_ID_PM8058_S3),
3882 RPM_VREG(RPM_VREG_ID_PM8058_S4),
3883 RPM_VREG(RPM_VREG_ID_PM8058_LVS0),
3884 RPM_VREG(RPM_VREG_ID_PM8058_LVS1),
3885 RPM_VREG(RPM_VREG_ID_PM8058_NCP),
3886 RPM_VREG(RPM_VREG_ID_PM8901_L0),
3887 RPM_VREG(RPM_VREG_ID_PM8901_L1),
3888 RPM_VREG(RPM_VREG_ID_PM8901_L2),
3889 RPM_VREG(RPM_VREG_ID_PM8901_L3),
3890 RPM_VREG(RPM_VREG_ID_PM8901_L4),
3891 RPM_VREG(RPM_VREG_ID_PM8901_L5),
3892 RPM_VREG(RPM_VREG_ID_PM8901_L6),
3893 RPM_VREG(RPM_VREG_ID_PM8901_S2),
3894 RPM_VREG(RPM_VREG_ID_PM8901_S3),
3895 RPM_VREG(RPM_VREG_ID_PM8901_S4),
3896 RPM_VREG(RPM_VREG_ID_PM8901_LVS0),
3897 RPM_VREG(RPM_VREG_ID_PM8901_LVS1),
3898 RPM_VREG(RPM_VREG_ID_PM8901_LVS2),
3899 RPM_VREG(RPM_VREG_ID_PM8901_LVS3),
3900 RPM_VREG(RPM_VREG_ID_PM8901_MVS0),
3901};
3902
3903static struct platform_device *early_regulators[] __initdata = {
3904 &msm_device_saw_s0,
3905 &msm_device_saw_s1,
3906#ifdef CONFIG_PMIC8058
3907 &rpm_vreg_device[RPM_VREG_ID_PM8058_S0],
3908 &rpm_vreg_device[RPM_VREG_ID_PM8058_S1],
3909#endif
3910};
3911
3912static struct platform_device *early_devices[] __initdata = {
3913#ifdef CONFIG_MSM_BUS_SCALING
3914 &msm_bus_apps_fabric,
3915 &msm_bus_sys_fabric,
3916 &msm_bus_mm_fabric,
3917 &msm_bus_sys_fpb,
3918 &msm_bus_cpss_fpb,
3919#endif
3920 &msm_device_dmov_adm0,
3921 &msm_device_dmov_adm1,
3922};
3923
3924#if (defined(CONFIG_MARIMBA_CORE)) && \
3925 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
3926
3927static int bluetooth_power(int);
3928static struct platform_device msm_bt_power_device = {
3929 .name = "bt_power",
3930 .id = -1,
3931 .dev = {
3932 .platform_data = &bluetooth_power,
3933 },
3934};
3935#endif
3936
3937static struct platform_device msm_tsens_device = {
3938 .name = "tsens-tm",
3939 .id = -1,
3940};
3941
3942static struct platform_device *rumi_sim_devices[] __initdata = {
3943 &smc91x_device,
3944 &msm_device_uart_dm12,
3945#ifdef CONFIG_I2C_QUP
3946 &msm_gsbi3_qup_i2c_device,
3947 &msm_gsbi4_qup_i2c_device,
3948 &msm_gsbi7_qup_i2c_device,
3949 &msm_gsbi8_qup_i2c_device,
3950 &msm_gsbi9_qup_i2c_device,
3951 &msm_gsbi12_qup_i2c_device,
3952#endif
3953#ifdef CONFIG_I2C_SSBI
3954 &msm_device_ssbi1,
3955 &msm_device_ssbi2,
3956 &msm_device_ssbi3,
3957#endif
3958#ifdef CONFIG_ANDROID_PMEM
3959 &android_pmem_device,
3960 &android_pmem_adsp_device,
3961 &android_pmem_audio_device,
3962 &android_pmem_smipool_device,
3963#endif
3964#ifdef CONFIG_MSM_ROTATOR
3965 &msm_rotator_device,
3966#endif
3967 &msm_fb_device,
3968 &msm_kgsl_3d0,
3969 &msm_kgsl_2d0,
3970 &msm_kgsl_2d1,
3971 &lcdc_samsung_panel_device,
3972#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
3973 &hdmi_msm_device,
3974#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
3975#ifdef CONFIG_MSM_CAMERA
3976#ifdef CONFIG_MT9E013
3977 &msm_camera_sensor_mt9e013,
3978#endif
3979#ifdef CONFIG_IMX074
3980 &msm_camera_sensor_imx074,
3981#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04003982#ifdef CONFIG_VX6953
3983 &msm_camera_sensor_vx6953,
3984#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003985#ifdef CONFIG_WEBCAM_OV7692
3986 &msm_camera_sensor_webcam_ov7692,
3987#endif
3988#ifdef CONFIG_WEBCAM_OV9726
3989 &msm_camera_sensor_webcam_ov9726,
3990#endif
3991#ifdef CONFIG_QS_S5K4E1
3992 &msm_camera_sensor_qs_s5k4e1,
3993#endif
3994#endif
3995#ifdef CONFIG_MSM_GEMINI
3996 &msm_gemini_device,
3997#endif
3998#ifdef CONFIG_MSM_VPE
3999 &msm_vpe_device,
4000#endif
4001 &msm_device_vidc,
4002};
4003
4004#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
4005enum {
4006 SX150X_CORE,
4007 SX150X_DOCKING,
4008 SX150X_SURF,
4009 SX150X_LEFT_FHA,
4010 SX150X_RIGHT_FHA,
4011 SX150X_SOUTH,
4012 SX150X_NORTH,
4013 SX150X_CORE_FLUID,
4014};
4015
4016static struct sx150x_platform_data sx150x_data[] __initdata = {
4017 [SX150X_CORE] = {
4018 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4019 .oscio_is_gpo = false,
4020 .io_pullup_ena = 0x0c08,
4021 .io_pulldn_ena = 0x4060,
4022 .io_open_drain_ena = 0x000c,
4023 .io_polarity = 0,
4024 .irq_summary = -1, /* see fixup_i2c_configs() */
4025 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4026 },
4027 [SX150X_DOCKING] = {
4028 .gpio_base = GPIO_DOCKING_EXPANDER_BASE,
4029 .oscio_is_gpo = false,
4030 .io_pullup_ena = 0x5e06,
4031 .io_pulldn_ena = 0x81b8,
4032 .io_open_drain_ena = 0,
4033 .io_polarity = 0,
4034 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4035 UI_INT2_N),
4036 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4037 GPIO_DOCKING_EXPANDER_BASE -
4038 GPIO_EXPANDER_GPIO_BASE,
4039 },
4040 [SX150X_SURF] = {
4041 .gpio_base = GPIO_SURF_EXPANDER_BASE,
4042 .oscio_is_gpo = false,
4043 .io_pullup_ena = 0,
4044 .io_pulldn_ena = 0,
4045 .io_open_drain_ena = 0,
4046 .io_polarity = 0,
4047 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4048 UI_INT1_N),
4049 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4050 GPIO_SURF_EXPANDER_BASE -
4051 GPIO_EXPANDER_GPIO_BASE,
4052 },
4053 [SX150X_LEFT_FHA] = {
4054 .gpio_base = GPIO_LEFT_KB_EXPANDER_BASE,
4055 .oscio_is_gpo = false,
4056 .io_pullup_ena = 0,
4057 .io_pulldn_ena = 0x40,
4058 .io_open_drain_ena = 0,
4059 .io_polarity = 0,
4060 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4061 UI_INT3_N),
4062 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4063 GPIO_LEFT_KB_EXPANDER_BASE -
4064 GPIO_EXPANDER_GPIO_BASE,
4065 },
4066 [SX150X_RIGHT_FHA] = {
4067 .gpio_base = GPIO_RIGHT_KB_EXPANDER_BASE,
4068 .oscio_is_gpo = true,
4069 .io_pullup_ena = 0,
4070 .io_pulldn_ena = 0,
4071 .io_open_drain_ena = 0,
4072 .io_polarity = 0,
4073 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
4074 UI_INT3_N),
4075 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4076 GPIO_RIGHT_KB_EXPANDER_BASE -
4077 GPIO_EXPANDER_GPIO_BASE,
4078 },
4079 [SX150X_SOUTH] = {
4080 .gpio_base = GPIO_SOUTH_EXPANDER_BASE,
4081 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4082 GPIO_SOUTH_EXPANDER_BASE -
4083 GPIO_EXPANDER_GPIO_BASE,
4084 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4085 },
4086 [SX150X_NORTH] = {
4087 .gpio_base = GPIO_NORTH_EXPANDER_BASE,
4088 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4089 GPIO_NORTH_EXPANDER_BASE -
4090 GPIO_EXPANDER_GPIO_BASE,
4091 .irq_summary = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT3_N),
4092 .oscio_is_gpo = true,
4093 .io_open_drain_ena = 0x30,
4094 },
4095 [SX150X_CORE_FLUID] = {
4096 .gpio_base = GPIO_CORE_EXPANDER_BASE,
4097 .oscio_is_gpo = false,
4098 .io_pullup_ena = 0x0408,
4099 .io_pulldn_ena = 0x4060,
4100 .io_open_drain_ena = 0x0008,
4101 .io_polarity = 0,
4102 .irq_summary = -1, /* see fixup_i2c_configs() */
4103 .irq_base = GPIO_EXPANDER_IRQ_BASE,
4104 },
4105};
4106
4107#ifdef CONFIG_SENSORS_MSM_ADC
4108/* Configuration of EPM expander is done when client
4109 * request an adc read
4110 */
4111static struct sx150x_platform_data sx150x_epmdata = {
4112 .gpio_base = GPIO_EPM_EXPANDER_BASE,
4113 .irq_base = GPIO_EXPANDER_IRQ_BASE +
4114 GPIO_EPM_EXPANDER_BASE -
4115 GPIO_EXPANDER_GPIO_BASE,
4116 .irq_summary = -1,
4117};
4118#endif
4119
4120/* sx150x_low_power_cfg
4121 *
4122 * This data and init function are used to put unused gpio-expander output
4123 * lines into their low-power states at boot. The init
4124 * function must be deferred until a later init stage because the i2c
4125 * gpio expander drivers do not probe until after they are registered
4126 * (see register_i2c_devices) and the work-queues for those registrations
4127 * are processed. Because these lines are unused, there is no risk of
4128 * competing with a device driver for the gpio.
4129 *
4130 * gpio lines whose low-power states are input are naturally in their low-
4131 * power configurations once probed, see the platform data structures above.
4132 */
4133struct sx150x_low_power_cfg {
4134 unsigned gpio;
4135 unsigned val;
4136};
4137
4138static struct sx150x_low_power_cfg
4139common_sx150x_lp_cfgs[] __initdata = {
4140 {GPIO_WLAN_DEEP_SLEEP_N, 0},
4141 {GPIO_EXT_GPS_LNA_EN, 0},
4142 {GPIO_MSM_WAKES_BT, 0},
4143 {GPIO_USB_UICC_EN, 0},
4144 {GPIO_BATT_GAUGE_EN, 0},
4145};
4146
4147static struct sx150x_low_power_cfg
4148surf_ffa_sx150x_lp_cfgs[] __initdata = {
4149 {GPIO_MIPI_DSI_RST_N, 0},
4150 {GPIO_DONGLE_PWR_EN, 0},
4151 {GPIO_CAP_TS_SLEEP, 1},
4152 {GPIO_WEB_CAMIF_RESET_N, 0},
4153};
4154
4155static void __init
4156cfg_gpio_low_power(struct sx150x_low_power_cfg *cfgs, unsigned nelems)
4157{
4158 unsigned n;
4159 int rc;
4160
4161 for (n = 0; n < nelems; ++n) {
4162 rc = gpio_request(cfgs[n].gpio, NULL);
4163 if (!rc) {
4164 rc = gpio_direction_output(cfgs[n].gpio, cfgs[n].val);
4165 gpio_free(cfgs[n].gpio);
4166 }
4167
4168 if (rc) {
4169 printk(KERN_NOTICE "%s: failed to sleep gpio %d: %d\n",
4170 __func__, cfgs[n].gpio, rc);
4171 }
Steve Muckle9161d302010-02-11 11:50:40 -08004172 }
Steve Mucklea55df6e2010-01-07 12:43:24 -08004173}
4174
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004175static int __init cfg_sx150xs_low_power(void)
Steve Mucklea55df6e2010-01-07 12:43:24 -08004176{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004177 cfg_gpio_low_power(common_sx150x_lp_cfgs,
4178 ARRAY_SIZE(common_sx150x_lp_cfgs));
4179 if (!machine_is_msm8x60_fluid())
4180 cfg_gpio_low_power(surf_ffa_sx150x_lp_cfgs,
4181 ARRAY_SIZE(surf_ffa_sx150x_lp_cfgs));
4182 return 0;
4183}
4184module_init(cfg_sx150xs_low_power);
4185
4186#ifdef CONFIG_I2C
4187static struct i2c_board_info core_expander_i2c_info[] __initdata = {
4188 {
4189 I2C_BOARD_INFO("sx1509q", 0x3e),
4190 .platform_data = &sx150x_data[SX150X_CORE]
4191 },
4192};
4193
4194static struct i2c_board_info docking_expander_i2c_info[] __initdata = {
4195 {
4196 I2C_BOARD_INFO("sx1509q", 0x3f),
4197 .platform_data = &sx150x_data[SX150X_DOCKING]
4198 },
4199};
4200
4201static struct i2c_board_info surf_expanders_i2c_info[] __initdata = {
4202 {
4203 I2C_BOARD_INFO("sx1509q", 0x70),
4204 .platform_data = &sx150x_data[SX150X_SURF]
4205 }
4206};
4207
4208static struct i2c_board_info fha_expanders_i2c_info[] __initdata = {
4209 {
4210 I2C_BOARD_INFO("sx1508q", 0x21),
4211 .platform_data = &sx150x_data[SX150X_LEFT_FHA]
4212 },
4213 {
4214 I2C_BOARD_INFO("sx1508q", 0x22),
4215 .platform_data = &sx150x_data[SX150X_RIGHT_FHA]
4216 }
4217};
4218
4219static struct i2c_board_info fluid_expanders_i2c_info[] __initdata = {
4220 {
4221 I2C_BOARD_INFO("sx1508q", 0x23),
4222 .platform_data = &sx150x_data[SX150X_SOUTH]
4223 },
4224 {
4225 I2C_BOARD_INFO("sx1508q", 0x20),
4226 .platform_data = &sx150x_data[SX150X_NORTH]
4227 }
4228};
4229
4230static struct i2c_board_info fluid_core_expander_i2c_info[] __initdata = {
4231 {
4232 I2C_BOARD_INFO("sx1509q", 0x3e),
4233 .platform_data = &sx150x_data[SX150X_CORE_FLUID]
4234 },
4235};
4236
4237#ifdef CONFIG_SENSORS_MSM_ADC
4238static struct i2c_board_info fluid_expanders_i2c_epm_info[] = {
4239 {
4240 I2C_BOARD_INFO("sx1509q", 0x3e),
4241 .platform_data = &sx150x_epmdata
4242 },
4243};
4244#endif
4245#endif
4246#endif
4247
4248#ifdef CONFIG_SENSORS_MSM_ADC
4249static struct resource resources_adc[] = {
4250 {
4251 .start = PM8058_ADC_IRQ(PM8058_IRQ_BASE),
4252 .end = PM8058_ADC_IRQ(PM8058_IRQ_BASE),
4253 .flags = IORESOURCE_IRQ,
4254 },
4255};
4256
4257static struct adc_access_fn xoadc_fn = {
4258 pm8058_xoadc_select_chan_and_start_conv,
4259 pm8058_xoadc_read_adc_code,
4260 pm8058_xoadc_get_properties,
4261 pm8058_xoadc_slot_request,
4262 pm8058_xoadc_restore_slot,
4263 pm8058_xoadc_calibrate,
4264};
4265
4266#if defined(CONFIG_I2C) && \
4267 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4268static struct regulator *vreg_adc_epm1;
4269
4270static struct i2c_client *epm_expander_i2c_register_board(void)
4271
4272{
4273 struct i2c_adapter *i2c_adap;
4274 struct i2c_client *client = NULL;
4275 i2c_adap = i2c_get_adapter(0x0);
4276
4277 if (i2c_adap == NULL)
4278 printk(KERN_ERR "\nepm_expander_i2c_adapter is NULL\n");
4279
4280 if (i2c_adap != NULL)
4281 client = i2c_new_device(i2c_adap,
4282 &fluid_expanders_i2c_epm_info[0]);
4283 return client;
4284
4285}
4286
4287static unsigned int msm_adc_gpio_configure_expander_enable(void)
4288{
4289 int rc = 0;
4290 static struct i2c_client *epm_i2c_client;
4291
4292 printk(KERN_DEBUG "Enter msm_adc_gpio_configure_expander_enable\n");
4293
4294 vreg_adc_epm1 = regulator_get(NULL, "8058_s3");
4295
4296 if (IS_ERR(vreg_adc_epm1)) {
4297 printk(KERN_ERR "%s: Unable to get 8058_s3\n", __func__);
4298 return 0;
4299 }
4300
4301 rc = regulator_set_voltage(vreg_adc_epm1, 1800000, 1800000);
4302 if (rc)
4303 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4304 "regulator set voltage failed\n");
4305
4306 rc = regulator_enable(vreg_adc_epm1);
4307 if (rc) {
4308 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4309 "Error while enabling regulator for epm s3 %d\n", rc);
4310 return rc;
4311 }
4312
4313 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Start"
4314 " setting the value of the EPM 3.3, 5v and lvlsft\n");
4315
4316 msleep(1000);
4317
4318 rc = gpio_request(GPIO_EPM_5V_BOOST_EN, "boost_epm_5v");
4319 if (!rc) {
4320 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4321 "Configure 5v boost\n");
4322 gpio_direction_output(GPIO_EPM_5V_BOOST_EN, 1);
4323 } else {
4324 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4325 "Error for epm 5v boost en\n");
4326 goto exit_vreg_epm;
4327 }
4328
4329 msleep(500);
4330
4331 rc = gpio_request(GPIO_EPM_3_3V_EN, "epm_3_3v");
4332 if (!rc) {
4333 gpio_direction_output(GPIO_EPM_3_3V_EN, 1);
4334 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4335 "Configure epm 3.3v\n");
4336 } else {
4337 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4338 "Error for gpio 3.3ven\n");
4339 goto exit_vreg_epm;
4340 }
4341 msleep(500);
4342
4343 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4344 "Trying to request EPM LVLSFT_EN\n");
4345 rc = gpio_request(GPIO_EPM_LVLSFT_EN, "lvsft_en");
4346 if (!rc) {
4347 gpio_direction_output(GPIO_EPM_LVLSFT_EN, 1);
4348 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: "
4349 "Configure the lvlsft\n");
4350 } else {
4351 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: "
4352 "Error for epm lvlsft_en\n");
4353 goto exit_vreg_epm;
4354 }
4355
4356 msleep(500);
4357
4358 if (!epm_i2c_client)
4359 epm_i2c_client = epm_expander_i2c_register_board();
4360
4361 rc = gpio_request(GPIO_PWR_MON_ENABLE, "pwr_mon_enable");
4362 if (!rc)
4363 rc = gpio_direction_output(GPIO_PWR_MON_ENABLE, 1);
4364 if (rc) {
4365 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4366 ": GPIO PWR MON Enable issue\n");
4367 goto exit_vreg_epm;
4368 }
4369
4370 msleep(1000);
4371
4372 rc = gpio_request(GPIO_ADC1_PWDN_N, "adc1_pwdn");
4373 if (!rc) {
4374 rc = gpio_direction_output(GPIO_ADC1_PWDN_N, 1);
4375 if (rc) {
4376 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4377 ": ADC1_PWDN error direction out\n");
4378 goto exit_vreg_epm;
4379 }
4380 }
4381
4382 msleep(100);
4383
4384 rc = gpio_request(GPIO_ADC2_PWDN_N, "adc2_pwdn");
4385 if (!rc) {
4386 rc = gpio_direction_output(GPIO_ADC2_PWDN_N, 1);
4387 if (rc) {
4388 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4389 ": ADC2_PWD error direction out\n");
4390 goto exit_vreg_epm;
4391 }
4392 }
4393
4394 msleep(1000);
4395
4396 rc = gpio_request(GPIO_PWR_MON_START, "pwr_mon_start");
4397 if (!rc) {
4398 rc = gpio_direction_output(GPIO_PWR_MON_START, 0);
4399 if (rc) {
4400 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4401 "Gpio request problem %d\n", rc);
4402 goto exit_vreg_epm;
4403 }
4404 }
4405
4406 rc = gpio_request(GPIO_EPM_SPI_ADC1_CS_N, "spi_adc1_cs");
4407 if (!rc) {
4408 rc = gpio_direction_output(GPIO_EPM_SPI_ADC1_CS_N, 0);
4409 if (rc) {
4410 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4411 ": EPM_SPI_ADC1_CS_N error\n");
4412 goto exit_vreg_epm;
4413 }
4414 }
4415
4416 rc = gpio_request(GPIO_EPM_SPI_ADC2_CS_N, "spi_adc2_cs");
4417 if (!rc) {
4418 rc = gpio_direction_output(GPIO_EPM_SPI_ADC2_CS_N, 0);
4419 if (rc) {
4420 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4421 ": EPM_SPI_ADC2_Cs_N error\n");
4422 goto exit_vreg_epm;
4423 }
4424 }
4425
4426 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_enable: Set "
4427 "the power monitor reset for epm\n");
4428
4429 rc = gpio_request(GPIO_PWR_MON_RESET_N, "pwr_mon_reset_n");
4430 if (!rc) {
4431 gpio_direction_output(GPIO_PWR_MON_RESET_N, 0);
4432 if (rc) {
4433 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable"
4434 ": Error in the power mon reset\n");
4435 goto exit_vreg_epm;
4436 }
4437 }
4438
4439 msleep(1000);
4440
4441 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 1);
4442
4443 msleep(500);
4444
4445 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4446
4447 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4448
4449 return rc;
4450
4451exit_vreg_epm:
4452 regulator_disable(vreg_adc_epm1);
4453
4454 printk(KERN_ERR "msm_adc_gpio_configure_expander_enable: Exit."
4455 " rc = %d.\n", rc);
4456 return rc;
4457};
4458
4459static unsigned int msm_adc_gpio_configure_expander_disable(void)
4460{
4461 int rc = 0;
4462
4463 gpio_set_value_cansleep(GPIO_PWR_MON_RESET_N, 0);
4464 gpio_free(GPIO_PWR_MON_RESET_N);
4465
4466 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4467 gpio_free(GPIO_EPM_SPI_ADC1_CS_N);
4468
4469 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4470 gpio_free(GPIO_EPM_SPI_ADC2_CS_N);
4471
4472 gpio_set_value_cansleep(GPIO_PWR_MON_START, 0);
4473 gpio_free(GPIO_PWR_MON_START);
4474
4475 gpio_direction_output(GPIO_ADC1_PWDN_N, 0);
4476 gpio_free(GPIO_ADC1_PWDN_N);
4477
4478 gpio_direction_output(GPIO_ADC2_PWDN_N, 0);
4479 gpio_free(GPIO_ADC2_PWDN_N);
4480
4481 gpio_set_value_cansleep(GPIO_PWR_MON_ENABLE, 0);
4482 gpio_free(GPIO_PWR_MON_ENABLE);
4483
4484 gpio_set_value_cansleep(GPIO_EPM_LVLSFT_EN, 0);
4485 gpio_free(GPIO_EPM_LVLSFT_EN);
4486
4487 gpio_set_value_cansleep(GPIO_EPM_5V_BOOST_EN, 0);
4488 gpio_free(GPIO_EPM_5V_BOOST_EN);
4489
4490 gpio_set_value_cansleep(GPIO_EPM_3_3V_EN, 0);
4491 gpio_free(GPIO_EPM_3_3V_EN);
4492
4493 rc = regulator_disable(vreg_adc_epm1);
4494 if (rc)
4495 printk(KERN_DEBUG "msm_adc_gpio_configure_expander_disable: "
4496 "Error while enabling regulator for epm s3 %d\n", rc);
4497 regulator_put(vreg_adc_epm1);
4498
4499 printk(KERN_DEBUG "Exi msm_adc_gpio_configure_expander_disable\n");
4500 return rc;
4501};
4502
4503unsigned int msm_adc_gpio_expander_enable(int cs_enable)
4504{
4505 int rc = 0;
4506
4507 printk(KERN_DEBUG "msm_adc_gpio_expander_enable: cs_enable = %d",
4508 cs_enable);
4509
4510 if (cs_enable < 16) {
4511 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 0);
4512 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4513 } else {
4514 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 0);
4515 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4516 }
4517 return rc;
4518};
4519
4520unsigned int msm_adc_gpio_expander_disable(int cs_disable)
4521{
4522 int rc = 0;
4523
4524 printk(KERN_DEBUG "Enter msm_adc_gpio_expander_disable.\n");
4525
4526 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC1_CS_N, 1);
4527
4528 gpio_set_value_cansleep(GPIO_EPM_SPI_ADC2_CS_N, 1);
4529
4530 return rc;
4531};
4532#endif
4533
4534static struct msm_adc_channels msm_adc_channels_data[] = {
4535 {"vbatt", CHANNEL_ADC_VBATT, 0, &xoadc_fn, CHAN_PATH_TYPE2,
4536 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4537 {"vcoin", CHANNEL_ADC_VCOIN, 0, &xoadc_fn, CHAN_PATH_TYPE1,
4538 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4539 {"vcharger_channel", CHANNEL_ADC_VCHG, 0, &xoadc_fn, CHAN_PATH_TYPE3,
4540 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE4, scale_default},
4541 {"charger_current_monitor", CHANNEL_ADC_CHG_MONITOR, 0, &xoadc_fn,
4542 CHAN_PATH_TYPE4,
4543 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4544 {"vph_pwr", CHANNEL_ADC_VPH_PWR, 0, &xoadc_fn, CHAN_PATH_TYPE5,
4545 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4546 {"usb_vbus", CHANNEL_ADC_USB_VBUS, 0, &xoadc_fn, CHAN_PATH_TYPE11,
4547 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE3, scale_default},
4548 {"pmic_therm", CHANNEL_ADC_DIE_TEMP, 0, &xoadc_fn, CHAN_PATH_TYPE12,
4549 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_pmic_therm},
4550 {"pmic_therm_4K", CHANNEL_ADC_DIE_TEMP_4K, 0, &xoadc_fn,
4551 CHAN_PATH_TYPE12,
4552 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE7, scale_pmic_therm},
4553 {"xo_therm", CHANNEL_ADC_XOTHERM, 0, &xoadc_fn, CHAN_PATH_TYPE_NONE,
4554 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE5, tdkntcgtherm},
4555 {"xo_therm_4K", CHANNEL_ADC_XOTHERM_4K, 0, &xoadc_fn,
4556 CHAN_PATH_TYPE_NONE,
4557 ADC_CONFIG_TYPE1, ADC_CALIB_CONFIG_TYPE6, tdkntcgtherm},
4558 {"hdset_detect", CHANNEL_ADC_HDSET, 0, &xoadc_fn, CHAN_PATH_TYPE6,
4559 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1, scale_default},
4560 {"chg_batt_amon", CHANNEL_ADC_BATT_AMON, 0, &xoadc_fn, CHAN_PATH_TYPE10,
4561 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE1,
4562 scale_xtern_chgr_cur},
4563 {"msm_therm", CHANNEL_ADC_MSM_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE8,
4564 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_msm_therm},
4565 {"batt_therm", CHANNEL_ADC_BATT_THERM, 0, &xoadc_fn, CHAN_PATH_TYPE7,
4566 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_batt_therm},
4567 {"batt_id", CHANNEL_ADC_BATT_ID, 0, &xoadc_fn, CHAN_PATH_TYPE9,
4568 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4569 {"ref_625mv", CHANNEL_ADC_625_REF, 0, &xoadc_fn, CHAN_PATH_TYPE15,
4570 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4571 {"ref_1250mv", CHANNEL_ADC_1250_REF, 0, &xoadc_fn, CHAN_PATH_TYPE13,
4572 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4573 {"ref_325mv", CHANNEL_ADC_325_REF, 0, &xoadc_fn, CHAN_PATH_TYPE14,
4574 ADC_CONFIG_TYPE2, ADC_CALIB_CONFIG_TYPE2, scale_default},
4575};
4576
4577static char *msm_adc_fluid_device_names[] = {
4578 "ADS_ADC1",
4579 "ADS_ADC2",
4580};
4581
4582static struct msm_adc_platform_data msm_adc_pdata = {
4583 .channel = msm_adc_channels_data,
4584 .num_chan_supported = ARRAY_SIZE(msm_adc_channels_data),
4585#if defined(CONFIG_I2C) && \
4586 (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE))
4587 .adc_gpio_enable = msm_adc_gpio_expander_enable,
4588 .adc_gpio_disable = msm_adc_gpio_expander_disable,
4589 .adc_fluid_enable = msm_adc_gpio_configure_expander_enable,
4590 .adc_fluid_disable = msm_adc_gpio_configure_expander_disable,
4591#endif
4592};
4593
4594static struct platform_device msm_adc_device = {
4595 .name = "msm_adc",
4596 .id = -1,
4597 .dev = {
4598 .platform_data = &msm_adc_pdata,
4599 },
4600};
4601
4602static void pmic8058_xoadc_mpp_config(void)
4603{
4604 int rc;
4605
4606 rc = pm8901_mpp_config_digital_out(XOADC_MPP_4,
4607 PM8901_MPP_DIG_LEVEL_S4, PM_MPP_DOUT_CTL_LOW);
4608 if (rc)
4609 pr_err("%s: Config mpp4 on pmic 8901 failed\n", __func__);
4610
4611 rc = pm8058_mpp_config_analog_input(XOADC_MPP_3,
4612 PM_MPP_AIN_AMUX_CH5, PM_MPP_AOUT_CTL_DISABLE);
4613 if (rc)
4614 pr_err("%s: Config mpp3 on pmic 8058 failed\n", __func__);
4615
4616 rc = pm8058_mpp_config_analog_input(XOADC_MPP_5,
4617 PM_MPP_AIN_AMUX_CH9, PM_MPP_AOUT_CTL_DISABLE);
4618 if (rc)
4619 pr_err("%s: Config mpp5 on pmic 8058 failed\n", __func__);
4620
4621 rc = pm8058_mpp_config_analog_input(XOADC_MPP_7,
4622 PM_MPP_AIN_AMUX_CH6, PM_MPP_AOUT_CTL_DISABLE);
4623 if (rc)
4624 pr_err("%s: Config mpp7 on pmic 8058 failed\n", __func__);
4625
4626 rc = pm8058_mpp_config_analog_input(XOADC_MPP_8,
4627 PM_MPP_AIN_AMUX_CH8, PM_MPP_AOUT_CTL_DISABLE);
4628 if (rc)
4629 pr_err("%s: Config mpp8 on pmic 8058 failed\n", __func__);
4630
4631 rc = pm8058_mpp_config_analog_input(XOADC_MPP_10,
4632 PM_MPP_AIN_AMUX_CH7, PM_MPP_AOUT_CTL_DISABLE);
4633 if (rc)
4634 pr_err("%s: Config mpp10 on pmic 8058 failed\n", __func__);
4635}
4636
4637static struct regulator *vreg_ldo18_adc;
4638
4639static int pmic8058_xoadc_vreg_config(int on)
4640{
4641 int rc;
4642
4643 if (on) {
4644 rc = regulator_enable(vreg_ldo18_adc);
4645 if (rc)
4646 pr_err("%s: Enable of regulator ldo18_adc "
4647 "failed\n", __func__);
4648 } else {
4649 rc = regulator_disable(vreg_ldo18_adc);
4650 if (rc)
4651 pr_err("%s: Disable of regulator ldo18_adc "
4652 "failed\n", __func__);
4653 }
4654
4655 return rc;
4656}
4657
4658static int pmic8058_xoadc_vreg_setup(void)
4659{
4660 int rc;
4661
4662 vreg_ldo18_adc = regulator_get(NULL, "8058_l18");
4663 if (IS_ERR(vreg_ldo18_adc)) {
4664 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
4665 __func__, PTR_ERR(vreg_ldo18_adc));
4666 rc = PTR_ERR(vreg_ldo18_adc);
4667 goto fail;
4668 }
4669
4670 rc = regulator_set_voltage(vreg_ldo18_adc, 2200000, 2200000);
4671 if (rc) {
4672 pr_err("%s: unable to set ldo18 voltage to 2.2V\n", __func__);
4673 goto fail;
4674 }
4675
4676 return rc;
4677fail:
4678 regulator_put(vreg_ldo18_adc);
4679 return rc;
4680}
4681
4682static void pmic8058_xoadc_vreg_shutdown(void)
4683{
4684 regulator_put(vreg_ldo18_adc);
4685}
4686
4687/* usec. For this ADC,
4688 * this time represents clk rate @ txco w/ 1024 decimation ratio.
4689 * Each channel has different configuration, thus at the time of starting
4690 * the conversion, xoadc will return actual conversion time
4691 * */
4692static struct adc_properties pm8058_xoadc_data = {
4693 .adc_reference = 2200, /* milli-voltage for this adc */
4694 .bitresolution = 15,
4695 .bipolar = 0,
4696 .conversiontime = 54,
4697};
4698
4699static struct xoadc_platform_data xoadc_pdata = {
4700 .xoadc_prop = &pm8058_xoadc_data,
4701 .xoadc_mpp_config = pmic8058_xoadc_mpp_config,
4702 .xoadc_vreg_set = pmic8058_xoadc_vreg_config,
4703 .xoadc_num = XOADC_PMIC_0,
4704 .xoadc_vreg_setup = pmic8058_xoadc_vreg_setup,
4705 .xoadc_vreg_shutdown = pmic8058_xoadc_vreg_shutdown,
4706};
4707#endif
4708
4709#ifdef CONFIG_MSM_SDIO_AL
4710
4711static unsigned mdm2ap_status = 140;
4712
4713static int configure_mdm2ap_status(int on)
4714{
4715 int ret = 0;
4716 if (on)
4717 ret = msm_gpiomux_get(mdm2ap_status);
4718 else
4719 ret = msm_gpiomux_put(mdm2ap_status);
4720
4721 if (ret)
4722 pr_err("%s: mdm2ap_status config failed, on = %d\n", __func__,
4723 on);
4724
4725 return ret;
4726}
4727
4728
4729static int get_mdm2ap_status(void)
4730{
4731 return gpio_get_value(mdm2ap_status);
4732}
4733
4734static struct sdio_al_platform_data sdio_al_pdata = {
4735 .config_mdm2ap_status = configure_mdm2ap_status,
4736 .get_mdm2ap_status = get_mdm2ap_status,
4737 .allow_sdioc_version_major_2 = 0,
4738 .peer_sdioc_version_minor = 0x0101,
4739 .peer_sdioc_version_major = 0x0004,
4740 .peer_sdioc_boot_version_minor = 0x0001,
4741 .peer_sdioc_boot_version_major = 0x0003
4742};
4743
4744struct platform_device msm_device_sdio_al = {
4745 .name = "msm_sdio_al",
4746 .id = -1,
4747 .dev = {
4748 .platform_data = &sdio_al_pdata,
4749 },
4750};
4751
4752#endif /* CONFIG_MSM_SDIO_AL */
4753
Praveen Chidambaram043f4ce2011-08-02 09:37:59 -06004754static struct platform_device msm_rpm_device = {
4755 .name = "msm_rpm",
4756 .id = -1,
4757};
4758
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004759static struct platform_device *charm_devices[] __initdata = {
4760 &msm_charm_modem,
4761#ifdef CONFIG_MSM_SDIO_AL
4762 &msm_device_sdio_al,
4763#endif
4764};
4765
4766static struct platform_device *surf_devices[] __initdata = {
4767 &msm_device_smd,
4768 &msm_device_uart_dm12,
4769#ifdef CONFIG_I2C_QUP
4770 &msm_gsbi3_qup_i2c_device,
4771 &msm_gsbi4_qup_i2c_device,
4772 &msm_gsbi7_qup_i2c_device,
4773 &msm_gsbi8_qup_i2c_device,
4774 &msm_gsbi9_qup_i2c_device,
4775 &msm_gsbi12_qup_i2c_device,
4776#endif
4777#ifdef CONFIG_SERIAL_MSM_HS
4778 &msm_device_uart_dm1,
4779#endif
4780#ifdef CONFIG_I2C_SSBI
4781 &msm_device_ssbi1,
4782 &msm_device_ssbi2,
4783 &msm_device_ssbi3,
4784#endif
4785#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
4786 &isp1763_device,
4787#endif
4788
4789 &asoc_msm_pcm,
4790 &asoc_msm_dai0,
4791 &asoc_msm_dai1,
4792#if defined (CONFIG_MSM_8x60_VOIP)
4793 &asoc_msm_mvs,
4794 &asoc_mvs_dai0,
4795 &asoc_mvs_dai1,
4796#endif
4797#if defined(CONFIG_USB_GADGET_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
4798 &msm_device_otg,
4799#endif
4800#ifdef CONFIG_USB_GADGET_MSM_72K
4801 &msm_device_gadget_peripheral,
4802#endif
4803#ifdef CONFIG_USB_G_ANDROID
4804 &android_usb_device,
4805#endif
4806#ifdef CONFIG_BATTERY_MSM
4807 &msm_batt_device,
4808#endif
4809#ifdef CONFIG_ANDROID_PMEM
4810 &android_pmem_device,
4811 &android_pmem_adsp_device,
4812 &android_pmem_audio_device,
4813 &android_pmem_smipool_device,
4814#endif
4815#ifdef CONFIG_MSM_ROTATOR
4816 &msm_rotator_device,
4817#endif
4818 &msm_fb_device,
4819 &msm_kgsl_3d0,
4820 &msm_kgsl_2d0,
4821 &msm_kgsl_2d1,
4822 &lcdc_samsung_panel_device,
4823#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
4824 &lcdc_samsung_oled_panel_device,
4825#endif
4826#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
4827 &lcdc_auo_wvga_panel_device,
4828#endif
4829#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
4830 &hdmi_msm_device,
4831#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
4832#ifdef CONFIG_FB_MSM_MIPI_DSI
4833 &mipi_dsi_toshiba_panel_device,
4834 &mipi_dsi_novatek_panel_device,
4835#endif
4836#ifdef CONFIG_MSM_CAMERA
4837#ifdef CONFIG_MT9E013
4838 &msm_camera_sensor_mt9e013,
4839#endif
4840#ifdef CONFIG_IMX074
4841 &msm_camera_sensor_imx074,
4842#endif
4843#ifdef CONFIG_WEBCAM_OV7692
4844 &msm_camera_sensor_webcam_ov7692,
4845#endif
4846#ifdef CONFIG_WEBCAM_OV9726
4847 &msm_camera_sensor_webcam_ov9726,
4848#endif
4849#ifdef CONFIG_QS_S5K4E1
4850 &msm_camera_sensor_qs_s5k4e1,
4851#endif
Jilai Wang971f97f2011-07-13 14:25:25 -04004852#ifdef CONFIG_VX6953
4853 &msm_camera_sensor_vx6953,
4854#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004855#endif
4856#ifdef CONFIG_MSM_GEMINI
4857 &msm_gemini_device,
4858#endif
4859#ifdef CONFIG_MSM_VPE
4860 &msm_vpe_device,
4861#endif
4862
4863#if defined(CONFIG_MSM_RPM_LOG) || defined(CONFIG_MSM_RPM_LOG_MODULE)
4864 &msm_rpm_log_device,
4865#endif
4866#if defined(CONFIG_MSM_RPM_STATS_LOG)
4867 &msm_rpm_stat_device,
4868#endif
4869 &msm_device_vidc,
4870#if (defined(CONFIG_MARIMBA_CORE)) && \
4871 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4872 &msm_bt_power_device,
4873#endif
4874#ifdef CONFIG_SENSORS_MSM_ADC
4875 &msm_adc_device,
4876#endif
4877#ifdef CONFIG_PMIC8058
4878 &rpm_vreg_device[RPM_VREG_ID_PM8058_L0],
4879 &rpm_vreg_device[RPM_VREG_ID_PM8058_L1],
4880 &rpm_vreg_device[RPM_VREG_ID_PM8058_L2],
4881 &rpm_vreg_device[RPM_VREG_ID_PM8058_L3],
4882 &rpm_vreg_device[RPM_VREG_ID_PM8058_L4],
4883 &rpm_vreg_device[RPM_VREG_ID_PM8058_L5],
4884 &rpm_vreg_device[RPM_VREG_ID_PM8058_L6],
4885 &rpm_vreg_device[RPM_VREG_ID_PM8058_L7],
4886 &rpm_vreg_device[RPM_VREG_ID_PM8058_L8],
4887 &rpm_vreg_device[RPM_VREG_ID_PM8058_L9],
4888 &rpm_vreg_device[RPM_VREG_ID_PM8058_L10],
4889 &rpm_vreg_device[RPM_VREG_ID_PM8058_L11],
4890 &rpm_vreg_device[RPM_VREG_ID_PM8058_L12],
4891 &rpm_vreg_device[RPM_VREG_ID_PM8058_L13],
4892 &rpm_vreg_device[RPM_VREG_ID_PM8058_L14],
4893 &rpm_vreg_device[RPM_VREG_ID_PM8058_L15],
4894 &rpm_vreg_device[RPM_VREG_ID_PM8058_L16],
4895 &rpm_vreg_device[RPM_VREG_ID_PM8058_L17],
4896 &rpm_vreg_device[RPM_VREG_ID_PM8058_L18],
4897 &rpm_vreg_device[RPM_VREG_ID_PM8058_L19],
4898 &rpm_vreg_device[RPM_VREG_ID_PM8058_L20],
4899 &rpm_vreg_device[RPM_VREG_ID_PM8058_L21],
4900 &rpm_vreg_device[RPM_VREG_ID_PM8058_L22],
4901 &rpm_vreg_device[RPM_VREG_ID_PM8058_L23],
4902 &rpm_vreg_device[RPM_VREG_ID_PM8058_L24],
4903 &rpm_vreg_device[RPM_VREG_ID_PM8058_L25],
4904 &rpm_vreg_device[RPM_VREG_ID_PM8058_S2],
4905 &rpm_vreg_device[RPM_VREG_ID_PM8058_S3],
4906 &rpm_vreg_device[RPM_VREG_ID_PM8058_S4],
4907 &rpm_vreg_device[RPM_VREG_ID_PM8058_LVS0],
4908 &rpm_vreg_device[RPM_VREG_ID_PM8058_LVS1],
4909 &rpm_vreg_device[RPM_VREG_ID_PM8058_NCP],
4910#endif
4911#ifdef CONFIG_PMIC8901
4912 &rpm_vreg_device[RPM_VREG_ID_PM8901_L0],
4913 &rpm_vreg_device[RPM_VREG_ID_PM8901_L1],
4914 &rpm_vreg_device[RPM_VREG_ID_PM8901_L2],
4915 &rpm_vreg_device[RPM_VREG_ID_PM8901_L3],
4916 &rpm_vreg_device[RPM_VREG_ID_PM8901_L4],
4917 &rpm_vreg_device[RPM_VREG_ID_PM8901_L5],
4918 &rpm_vreg_device[RPM_VREG_ID_PM8901_L6],
4919 &rpm_vreg_device[RPM_VREG_ID_PM8901_S2],
4920 &rpm_vreg_device[RPM_VREG_ID_PM8901_S3],
4921 &rpm_vreg_device[RPM_VREG_ID_PM8901_S4],
4922 &rpm_vreg_device[RPM_VREG_ID_PM8901_LVS0],
4923 &rpm_vreg_device[RPM_VREG_ID_PM8901_LVS1],
4924 &rpm_vreg_device[RPM_VREG_ID_PM8901_LVS2],
4925 &rpm_vreg_device[RPM_VREG_ID_PM8901_LVS3],
4926 &rpm_vreg_device[RPM_VREG_ID_PM8901_MVS0],
4927#endif
4928
4929#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
4930 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
4931 &qcrypto_device,
4932#endif
4933
4934#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
4935 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
4936 &qcedev_device,
4937#endif
4938
4939#ifdef CONFIG_MSM_SDIO_AL
4940 &msm_device_sdio_al,
4941#endif
4942
4943#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
4944#ifdef CONFIG_MSM_USE_TSIF1
4945 &msm_device_tsif[1],
4946#else
4947 &msm_device_tsif[0],
4948#endif /* CONFIG_MSM_USE_TSIF1 */
4949#endif /* CONFIG_TSIF */
4950
4951#ifdef CONFIG_HW_RANDOM_MSM
4952 &msm_device_rng,
4953#endif
4954
4955 &msm_tsens_device,
Praveen Chidambaram043f4ce2011-08-02 09:37:59 -06004956 &msm_rpm_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004957
4958};
4959
4960static struct memtype_reserve msm8x60_reserve_table[] __initdata = {
4961 /* Kernel SMI memory pool for video core, used for firmware */
4962 /* and encoder, decoder scratch buffers */
4963 /* Kernel SMI memory pool should always precede the user space */
4964 /* SMI memory pool, as the video core will use offset address */
4965 /* from the Firmware base */
4966 [MEMTYPE_SMI_KERNEL] = {
4967 .start = KERNEL_SMI_BASE,
4968 .limit = KERNEL_SMI_SIZE,
4969 .size = KERNEL_SMI_SIZE,
4970 .flags = MEMTYPE_FLAGS_FIXED,
4971 },
4972 /* User space SMI memory pool for video core */
4973 /* used for encoder, decoder input & output buffers */
4974 [MEMTYPE_SMI] = {
4975 .start = USER_SMI_BASE,
4976 .limit = USER_SMI_SIZE,
4977 .flags = MEMTYPE_FLAGS_FIXED,
4978 },
4979 [MEMTYPE_EBI0] = {
4980 .flags = MEMTYPE_FLAGS_1M_ALIGN,
4981 },
4982 [MEMTYPE_EBI1] = {
4983 .flags = MEMTYPE_FLAGS_1M_ALIGN,
4984 },
4985};
4986
4987static void __init size_pmem_devices(void)
4988{
4989#ifdef CONFIG_ANDROID_PMEM
4990 android_pmem_adsp_pdata.size = pmem_adsp_size;
4991 android_pmem_smipool_pdata.size = MSM_PMEM_SMIPOOL_SIZE;
4992 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
4993 android_pmem_pdata.size = pmem_sf_size;
4994#endif
4995}
4996
4997static void __init reserve_memory_for(struct android_pmem_platform_data *p)
4998{
4999 msm8x60_reserve_table[p->memory_type].size += p->size;
5000}
5001
5002static void __init reserve_pmem_memory(void)
5003{
5004#ifdef CONFIG_ANDROID_PMEM
5005 reserve_memory_for(&android_pmem_adsp_pdata);
5006 reserve_memory_for(&android_pmem_smipool_pdata);
5007 reserve_memory_for(&android_pmem_audio_pdata);
5008 reserve_memory_for(&android_pmem_pdata);
5009 msm8x60_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
5010#endif
5011}
5012
5013static void __init msm8x60_calculate_reserve_sizes(void)
5014{
5015 size_pmem_devices();
5016 reserve_pmem_memory();
5017}
5018
5019static int msm8x60_paddr_to_memtype(unsigned int paddr)
5020{
5021 if (paddr >= 0x40000000 && paddr < 0x60000000)
5022 return MEMTYPE_EBI1;
5023 if (paddr >= 0x38000000 && paddr < 0x40000000)
5024 return MEMTYPE_SMI;
5025 return MEMTYPE_NONE;
5026}
5027
5028static struct reserve_info msm8x60_reserve_info __initdata = {
5029 .memtype_reserve_table = msm8x60_reserve_table,
5030 .calculate_reserve_sizes = msm8x60_calculate_reserve_sizes,
5031 .paddr_to_memtype = msm8x60_paddr_to_memtype,
5032};
5033
5034static void __init msm8x60_reserve(void)
5035{
5036 reserve_info = &msm8x60_reserve_info;
5037 msm_reserve();
5038}
5039
5040#define EXT_CHG_VALID_MPP 10
5041#define EXT_CHG_VALID_MPP_2 11
5042
5043#ifdef CONFIG_ISL9519_CHARGER
5044static int isl_detection_setup(void)
5045{
5046 int ret = 0;
5047
5048 ret = pm8058_mpp_config_digital_in(EXT_CHG_VALID_MPP,
5049 PM8058_MPP_DIG_LEVEL_S3,
5050 PM_MPP_DIN_TO_INT);
5051 ret |= pm8058_mpp_config_bi_dir(EXT_CHG_VALID_MPP_2,
5052 PM8058_MPP_DIG_LEVEL_S3,
5053 PM_MPP_BI_PULLUP_10KOHM
5054 );
5055 return ret;
5056}
5057
5058static struct isl_platform_data isl_data __initdata = {
5059 .chgcurrent = 700,
5060 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5061 .chg_detection_config = isl_detection_setup,
5062 .max_system_voltage = 4200,
5063 .min_system_voltage = 3200,
5064 .term_current = 120,
5065 .input_current = 2048,
5066};
5067
5068static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
5069 {
5070 I2C_BOARD_INFO("isl9519q", 0x9),
5071 .irq = PM8058_CBLPWR_IRQ(PM8058_IRQ_BASE),
5072 .platform_data = &isl_data,
5073 },
5074};
5075#endif
5076
5077#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
5078static int smb137b_detection_setup(void)
5079{
5080 int ret = 0;
5081
5082 ret = pm8058_mpp_config_digital_in(EXT_CHG_VALID_MPP,
5083 PM8058_MPP_DIG_LEVEL_S3,
5084 PM_MPP_DIN_TO_INT);
5085 ret |= pm8058_mpp_config_bi_dir(EXT_CHG_VALID_MPP_2,
5086 PM8058_MPP_DIG_LEVEL_S3,
5087 PM_MPP_BI_PULLUP_10KOHM);
5088 return ret;
5089}
5090
5091static struct smb137b_platform_data smb137b_data __initdata = {
5092 .chg_detection_config = smb137b_detection_setup,
5093 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5094 .batt_mah_rating = 950,
5095};
5096
5097static struct i2c_board_info smb137b_charger_i2c_info[] __initdata = {
5098 {
5099 I2C_BOARD_INFO("smb137b", 0x08),
5100 .irq = PM8058_CBLPWR_IRQ(PM8058_IRQ_BASE),
5101 .platform_data = &smb137b_data,
5102 },
5103};
5104#endif
5105
5106#ifdef CONFIG_PMIC8058
5107#define PMIC_GPIO_SDC3_DET 22
5108
5109static int pm8058_gpios_init(void)
5110{
5111 int i;
5112 int rc;
5113 struct pm8058_gpio_cfg {
5114 int gpio;
5115 struct pm8058_gpio cfg;
5116 };
5117
5118 struct pm8058_gpio_cfg gpio_cfgs[] = {
5119 { /* FFA ethernet */
5120 6,
5121 {
5122 .direction = PM_GPIO_DIR_IN,
5123 .pull = PM_GPIO_PULL_DN,
5124 .vin_sel = 2,
5125 .function = PM_GPIO_FUNC_NORMAL,
5126 .inv_int_pol = 0,
5127 },
5128 },
5129#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
5130 {
5131 PMIC_GPIO_SDC3_DET - 1,
5132 {
5133 .direction = PM_GPIO_DIR_IN,
5134 .pull = PM_GPIO_PULL_UP_30,
5135 .vin_sel = 2,
5136 .function = PM_GPIO_FUNC_NORMAL,
5137 .inv_int_pol = 0,
5138 },
5139 },
5140#endif
5141 { /* core&surf gpio expander */
5142 UI_INT1_N,
5143 {
5144 .direction = PM_GPIO_DIR_IN,
5145 .pull = PM_GPIO_PULL_NO,
5146 .vin_sel = PM_GPIO_VIN_S3,
5147 .function = PM_GPIO_FUNC_NORMAL,
5148 .inv_int_pol = 0,
5149 },
5150 },
5151 { /* docking gpio expander */
5152 UI_INT2_N,
5153 {
5154 .direction = PM_GPIO_DIR_IN,
5155 .pull = PM_GPIO_PULL_NO,
5156 .vin_sel = PM_GPIO_VIN_S3,
5157 .function = PM_GPIO_FUNC_NORMAL,
5158 .inv_int_pol = 0,
5159 },
5160 },
5161 { /* FHA/keypad gpio expanders */
5162 UI_INT3_N,
5163 {
5164 .direction = PM_GPIO_DIR_IN,
5165 .pull = PM_GPIO_PULL_NO,
5166 .vin_sel = PM_GPIO_VIN_S3,
5167 .function = PM_GPIO_FUNC_NORMAL,
5168 .inv_int_pol = 0,
5169 },
5170 },
5171 { /* TouchDisc Interrupt */
5172 5,
5173 {
5174 .direction = PM_GPIO_DIR_IN,
5175 .pull = PM_GPIO_PULL_UP_1P5,
5176 .vin_sel = 2,
5177 .function = PM_GPIO_FUNC_NORMAL,
5178 .inv_int_pol = 0,
5179 }
5180 },
5181 { /* Timpani Reset */
5182 20,
5183 {
5184 .direction = PM_GPIO_DIR_OUT,
5185 .output_value = 1,
5186 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5187 .pull = PM_GPIO_PULL_DN,
5188 .out_strength = PM_GPIO_STRENGTH_HIGH,
5189 .function = PM_GPIO_FUNC_NORMAL,
5190 .vin_sel = 2,
5191 .inv_int_pol = 0,
5192 }
5193 },
5194 { /* PMIC ID interrupt */
5195 36,
5196 {
5197 .direction = PM_GPIO_DIR_IN,
5198 .pull = PM_GPIO_PULL_UP_1P5,
5199 .function = PM_GPIO_FUNC_NORMAL,
5200 .vin_sel = 2,
5201 .inv_int_pol = 0,
5202 }
5203 },
5204 };
5205
5206#if defined(CONFIG_HAPTIC_ISA1200) || \
5207 defined(CONFIG_HAPTIC_ISA1200_MODULE)
5208
5209 struct pm8058_gpio_cfg en_hap_gpio_cfg = {
5210 PMIC_GPIO_HAP_ENABLE,
5211 {
5212 .direction = PM_GPIO_DIR_OUT,
5213 .pull = PM_GPIO_PULL_NO,
5214 .out_strength = PM_GPIO_STRENGTH_HIGH,
5215 .function = PM_GPIO_FUNC_NORMAL,
5216 .inv_int_pol = 0,
5217 .vin_sel = 2,
5218 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5219 .output_value = 0,
5220 }
5221
5222 };
5223#endif
5224
5225#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5226 struct pm8058_gpio_cfg line_in_gpio_cfg = {
5227 18,
5228 {
5229 .direction = PM_GPIO_DIR_IN,
5230 .pull = PM_GPIO_PULL_UP_1P5,
5231 .vin_sel = 2,
5232 .function = PM_GPIO_FUNC_NORMAL,
5233 .inv_int_pol = 0,
5234 }
5235 };
5236#endif
5237
5238#if defined(CONFIG_QS_S5K4E1)
5239 {
5240 struct pm8058_gpio_cfg qs_hc37_cam_pd_gpio_cfg = {
5241 26,
5242 {
5243 .direction = PM_GPIO_DIR_OUT,
5244 .output_value = 0,
5245 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5246 .pull = PM_GPIO_PULL_DN,
5247 .out_strength = PM_GPIO_STRENGTH_HIGH,
5248 .function = PM_GPIO_FUNC_NORMAL,
5249 .vin_sel = 2,
5250 .inv_int_pol = 0,
5251 }
5252 };
5253#endif
5254
5255#if defined(CONFIG_HAPTIC_ISA1200) || \
5256 defined(CONFIG_HAPTIC_ISA1200_MODULE)
5257 if (machine_is_msm8x60_fluid()) {
5258 rc = pm8058_gpio_config(en_hap_gpio_cfg.gpio,
5259 &en_hap_gpio_cfg.cfg);
5260 if (rc < 0) {
5261 pr_err("%s pmic haptics gpio config failed\n",
5262 __func__);
5263 return rc;
5264 }
5265 }
5266#endif
5267
5268#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5269 /* Line_in only for 8660 ffa & surf */
5270 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04005271 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005272 machine_is_msm8x60_fusn_ffa()) {
5273 rc = pm8058_gpio_config(line_in_gpio_cfg.gpio,
5274 &line_in_gpio_cfg.cfg);
5275 if (rc < 0) {
5276 pr_err("%s pmic line_in gpio config failed\n",
5277 __func__);
5278 return rc;
5279 }
5280 }
5281#endif
5282
5283#if defined(CONFIG_QS_S5K4E1)
5284 /* qs_cam_hc37_cam_pd only for 8660 fluid qs camera*/
5285 if (machine_is_msm8x60_fluid()) {
5286 rc = pm8058_gpio_config(qs_hc37_cam_pd_gpio_cfg.gpio,
5287 &qs_hc37_cam_pd_gpio_cfg.cfg);
5288 if (rc < 0) {
5289 pr_err("%s pmic qs_hc37_cam_pd gpio config failed\n",
5290 __func__);
5291 return rc;
5292 }
5293 }
5294 }
5295#endif
5296
5297 for (i = 0; i < ARRAY_SIZE(gpio_cfgs); ++i) {
5298 rc = pm8058_gpio_config(gpio_cfgs[i].gpio,
5299 &gpio_cfgs[i].cfg);
5300 if (rc < 0) {
5301 pr_err("%s pmic gpio config failed\n",
5302 __func__);
5303 return rc;
5304 }
5305 }
5306
5307 return 0;
5308}
5309
5310static const unsigned int ffa_keymap[] = {
5311 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5312 KEY(0, 1, KEY_UP), /* NAV - UP */
5313 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5314 KEY(0, 3, KEY_VOLUMEUP), /* Shuttle SW_UP */
5315
5316 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5317 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5318 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5319 KEY(1, 3, KEY_VOLUMEDOWN),
5320
5321 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5322
5323 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5324 KEY(4, 1, KEY_UP), /* USER_UP */
5325 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5326 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5327 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5328
5329 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
5330 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5331 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5332 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5333 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5334};
5335
Zhang Chang Ken683be172011-08-10 17:45:34 -04005336static const unsigned int dragon_keymap[] = {
5337 KEY(0, 0, KEY_MENU),
5338 KEY(0, 2, KEY_1),
5339 KEY(0, 3, KEY_4),
5340 KEY(0, 4, KEY_7),
5341
5342 KEY(1, 0, KEY_UP),
5343 KEY(1, 1, KEY_LEFT),
5344 KEY(1, 2, KEY_DOWN),
5345 KEY(1, 3, KEY_5),
5346 KEY(1, 4, KEY_8),
5347
5348 KEY(2, 0, KEY_HOME),
5349 KEY(2, 1, KEY_REPLY),
5350 KEY(2, 2, KEY_2),
5351 KEY(2, 3, KEY_6),
5352 KEY(2, 4, KEY_0),
5353
5354 KEY(3, 0, KEY_VOLUMEUP),
5355 KEY(3, 1, KEY_RIGHT),
5356 KEY(3, 2, KEY_3),
5357 KEY(3, 3, KEY_9),
5358 KEY(3, 4, KEY_SWITCHVIDEOMODE),
5359
5360 KEY(4, 0, KEY_VOLUMEDOWN),
5361 KEY(4, 1, KEY_BACK),
5362 KEY(4, 2, KEY_CAMERA),
5363 KEY(4, 3, KEY_KBDILLUMTOGGLE),
5364};
5365
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005366static struct resource resources_keypad[] = {
5367 {
5368 .start = PM8058_KEYPAD_IRQ(PM8058_IRQ_BASE),
5369 .end = PM8058_KEYPAD_IRQ(PM8058_IRQ_BASE),
5370 .flags = IORESOURCE_IRQ,
5371 },
5372 {
5373 .start = PM8058_KEYSTUCK_IRQ(PM8058_IRQ_BASE),
5374 .end = PM8058_KEYSTUCK_IRQ(PM8058_IRQ_BASE),
5375 .flags = IORESOURCE_IRQ,
5376 },
5377};
5378
5379static struct matrix_keymap_data ffa_keymap_data = {
5380 .keymap_size = ARRAY_SIZE(ffa_keymap),
5381 .keymap = ffa_keymap,
5382};
5383
5384static struct pmic8058_keypad_data ffa_keypad_data = {
5385 .input_name = "ffa-keypad",
5386 .input_phys_device = "ffa-keypad/input0",
5387 .num_rows = 6,
5388 .num_cols = 5,
5389 .rows_gpio_start = 8,
5390 .cols_gpio_start = 0,
5391 .debounce_ms = {8, 10},
5392 .scan_delay_ms = 32,
5393 .row_hold_ns = 91500,
5394 .wakeup = 1,
5395 .keymap_data = &ffa_keymap_data,
5396};
5397
Zhang Chang Ken683be172011-08-10 17:45:34 -04005398static struct matrix_keymap_data dragon_keymap_data = {
5399 .keymap_size = ARRAY_SIZE(dragon_keymap),
5400 .keymap = dragon_keymap,
5401};
5402
5403static struct pmic8058_keypad_data dragon_keypad_data = {
5404 .input_name = "dragon-keypad",
5405 .input_phys_device = "dragon-keypad/input0",
5406 .num_rows = 6,
5407 .num_cols = 5,
5408 .rows_gpio_start = 8,
5409 .cols_gpio_start = 0,
5410 .debounce_ms = {8, 10},
5411 .scan_delay_ms = 32,
5412 .row_hold_ns = 91500,
5413 .wakeup = 1,
5414 .keymap_data = &dragon_keymap_data,
5415};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005416static const unsigned int fluid_keymap[] = {
5417 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5418 KEY(0, 1, KEY_UP), /* NAV - UP */
5419 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5420 KEY(0, 3, KEY_VOLUMEDOWN), /* Shuttle SW_UP */
5421
5422 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5423 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5424 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5425 KEY(1, 3, KEY_VOLUMEUP),
5426
5427 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5428
5429 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5430 KEY(4, 1, KEY_UP), /* USER_UP */
5431 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5432 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5433 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5434
Jilai Wang9a895102011-07-12 14:00:35 -04005435 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005436 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5437 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5438 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5439 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5440};
5441
5442static struct matrix_keymap_data fluid_keymap_data = {
5443 .keymap_size = ARRAY_SIZE(fluid_keymap),
5444 .keymap = fluid_keymap,
5445};
5446
5447static struct pmic8058_keypad_data fluid_keypad_data = {
5448 .input_name = "fluid-keypad",
5449 .input_phys_device = "fluid-keypad/input0",
5450 .num_rows = 6,
5451 .num_cols = 5,
5452 .rows_gpio_start = 8,
5453 .cols_gpio_start = 0,
5454 .debounce_ms = {8, 10},
5455 .scan_delay_ms = 32,
5456 .row_hold_ns = 91500,
5457 .wakeup = 1,
5458 .keymap_data = &fluid_keymap_data,
5459};
5460
5461static struct resource resources_pwrkey[] = {
5462 {
5463 .start = PM8058_PWRKEY_REL_IRQ(PM8058_IRQ_BASE),
5464 .end = PM8058_PWRKEY_REL_IRQ(PM8058_IRQ_BASE),
5465 .flags = IORESOURCE_IRQ,
5466 },
5467 {
5468 .start = PM8058_PWRKEY_PRESS_IRQ(PM8058_IRQ_BASE),
5469 .end = PM8058_PWRKEY_PRESS_IRQ(PM8058_IRQ_BASE),
5470 .flags = IORESOURCE_IRQ,
5471 },
5472};
5473
5474static struct pmic8058_pwrkey_pdata pwrkey_pdata = {
5475 .pull_up = 1,
5476 .kpd_trigger_delay_us = 970,
5477 .wakeup = 1,
5478 .pwrkey_time_ms = 500,
5479};
5480
5481static struct pmic8058_vibrator_pdata pmic_vib_pdata = {
5482 .initial_vibrate_ms = 500,
5483 .level_mV = 3000,
5484 .max_timeout_ms = 15000,
5485};
5486
5487#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5488#define PM8058_OTHC_CNTR_BASE0 0xA0
5489#define PM8058_OTHC_CNTR_BASE1 0x134
5490#define PM8058_OTHC_CNTR_BASE2 0x137
5491#define PM8058_LINE_IN_DET_GPIO PM8058_GPIO_PM_TO_SYS(18)
5492
5493static struct othc_accessory_info othc_accessories[] = {
5494 {
5495 .accessory = OTHC_SVIDEO_OUT,
5496 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT
5497 | OTHC_ADC_DETECT,
5498 .key_code = SW_VIDEOOUT_INSERT,
5499 .enabled = false,
5500 .adc_thres = {
5501 .min_threshold = 20,
5502 .max_threshold = 40,
5503 },
5504 },
5505 {
5506 .accessory = OTHC_ANC_HEADPHONE,
5507 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT |
5508 OTHC_SWITCH_DETECT,
5509 .gpio = PM8058_LINE_IN_DET_GPIO,
5510 .active_low = 1,
5511 .key_code = SW_HEADPHONE_INSERT,
5512 .enabled = true,
5513 },
5514 {
5515 .accessory = OTHC_ANC_HEADSET,
5516 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT,
5517 .gpio = PM8058_LINE_IN_DET_GPIO,
5518 .active_low = 1,
5519 .key_code = SW_HEADPHONE_INSERT,
5520 .enabled = true,
5521 },
5522 {
5523 .accessory = OTHC_HEADPHONE,
5524 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT,
5525 .key_code = SW_HEADPHONE_INSERT,
5526 .enabled = true,
5527 },
5528 {
5529 .accessory = OTHC_MICROPHONE,
5530 .detect_flags = OTHC_GPIO_DETECT,
5531 .gpio = PM8058_LINE_IN_DET_GPIO,
5532 .active_low = 1,
5533 .key_code = SW_MICROPHONE_INSERT,
5534 .enabled = true,
5535 },
5536 {
5537 .accessory = OTHC_HEADSET,
5538 .detect_flags = OTHC_MICBIAS_DETECT,
5539 .key_code = SW_HEADPHONE_INSERT,
5540 .enabled = true,
5541 },
5542};
5543
5544static struct othc_switch_info switch_info[] = {
5545 {
5546 .min_adc_threshold = 0,
5547 .max_adc_threshold = 100,
5548 .key_code = KEY_PLAYPAUSE,
5549 },
5550 {
5551 .min_adc_threshold = 100,
5552 .max_adc_threshold = 200,
5553 .key_code = KEY_REWIND,
5554 },
5555 {
5556 .min_adc_threshold = 200,
5557 .max_adc_threshold = 500,
5558 .key_code = KEY_FASTFORWARD,
5559 },
5560};
5561
5562static struct othc_n_switch_config switch_config = {
5563 .voltage_settling_time_ms = 0,
5564 .num_adc_samples = 3,
5565 .adc_channel = CHANNEL_ADC_HDSET,
5566 .switch_info = switch_info,
5567 .num_keys = ARRAY_SIZE(switch_info),
5568 .default_sw_en = true,
5569 .default_sw_idx = 0,
5570};
5571
5572static struct hsed_bias_config hsed_bias_config = {
5573 /* HSED mic bias config info */
5574 .othc_headset = OTHC_HEADSET_NO,
5575 .othc_lowcurr_thresh_uA = 100,
5576 .othc_highcurr_thresh_uA = 600,
5577 .othc_hyst_prediv_us = 7800,
5578 .othc_period_clkdiv_us = 62500,
5579 .othc_hyst_clk_us = 121000,
5580 .othc_period_clk_us = 312500,
5581 .othc_wakeup = 1,
5582};
5583
5584static struct othc_hsed_config hsed_config_1 = {
5585 .hsed_bias_config = &hsed_bias_config,
5586 /*
5587 * The detection delay and switch reporting delay are
5588 * required to encounter a hardware bug (spurious switch
5589 * interrupts on slow insertion/removal of the headset).
5590 * This will introduce a delay in reporting the accessory
5591 * insertion and removal to the userspace.
5592 */
5593 .detection_delay_ms = 1500,
5594 /* Switch info */
5595 .switch_debounce_ms = 1500,
5596 .othc_support_n_switch = false,
5597 .switch_config = &switch_config,
5598 .ir_gpio = -1,
5599 /* Accessory info */
5600 .accessories_support = true,
5601 .accessories = othc_accessories,
5602 .othc_num_accessories = ARRAY_SIZE(othc_accessories),
5603};
5604
5605static struct othc_regulator_config othc_reg = {
5606 .regulator = "8058_l5",
5607 .max_uV = 2850000,
5608 .min_uV = 2850000,
5609};
5610
5611/* MIC_BIAS0 is configured as normal MIC BIAS */
5612static struct pmic8058_othc_config_pdata othc_config_pdata_0 = {
5613 .micbias_select = OTHC_MICBIAS_0,
5614 .micbias_capability = OTHC_MICBIAS,
5615 .micbias_enable = OTHC_SIGNAL_OFF,
5616 .micbias_regulator = &othc_reg,
5617};
5618
5619/* MIC_BIAS1 is configured as HSED_BIAS for OTHC */
5620static struct pmic8058_othc_config_pdata othc_config_pdata_1 = {
5621 .micbias_select = OTHC_MICBIAS_1,
5622 .micbias_capability = OTHC_MICBIAS_HSED,
5623 .micbias_enable = OTHC_SIGNAL_PWM_TCXO,
5624 .micbias_regulator = &othc_reg,
5625 .hsed_config = &hsed_config_1,
5626 .hsed_name = "8660_handset",
5627};
5628
5629/* MIC_BIAS2 is configured as normal MIC BIAS */
5630static struct pmic8058_othc_config_pdata othc_config_pdata_2 = {
5631 .micbias_select = OTHC_MICBIAS_2,
5632 .micbias_capability = OTHC_MICBIAS,
5633 .micbias_enable = OTHC_SIGNAL_OFF,
5634 .micbias_regulator = &othc_reg,
5635};
5636
5637static struct resource resources_othc_0[] = {
5638 {
5639 .name = "othc_base",
5640 .start = PM8058_OTHC_CNTR_BASE0,
5641 .end = PM8058_OTHC_CNTR_BASE0,
5642 .flags = IORESOURCE_IO,
5643 },
5644};
5645
5646static struct resource resources_othc_1[] = {
5647 {
5648 .start = PM8058_SW_1_IRQ(PM8058_IRQ_BASE),
5649 .end = PM8058_SW_1_IRQ(PM8058_IRQ_BASE),
5650 .flags = IORESOURCE_IRQ,
5651 },
5652 {
5653 .start = PM8058_IR_1_IRQ(PM8058_IRQ_BASE),
5654 .end = PM8058_IR_1_IRQ(PM8058_IRQ_BASE),
5655 .flags = IORESOURCE_IRQ,
5656 },
5657 {
5658 .name = "othc_base",
5659 .start = PM8058_OTHC_CNTR_BASE1,
5660 .end = PM8058_OTHC_CNTR_BASE1,
5661 .flags = IORESOURCE_IO,
5662 },
5663};
5664
5665static struct resource resources_othc_2[] = {
5666 {
5667 .name = "othc_base",
5668 .start = PM8058_OTHC_CNTR_BASE2,
5669 .end = PM8058_OTHC_CNTR_BASE2,
5670 .flags = IORESOURCE_IO,
5671 },
5672};
5673
5674static void __init msm8x60_init_pm8058_othc(void)
5675{
5676 int i;
5677
5678 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 ||
5679 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
5680 machine_is_msm8x60_fusn_ffa()) {
5681 /* 3-switch headset supported only by V2 FFA and FLUID */
5682 hsed_config_1.accessories_adc_support = true,
5683 /* ADC based accessory detection works only on V2 and FLUID */
5684 hsed_config_1.accessories_adc_channel = CHANNEL_ADC_HDSET,
5685 hsed_config_1.othc_support_n_switch = true;
5686 }
5687
5688 /* IR GPIO is absent on FLUID */
5689 if (machine_is_msm8x60_fluid())
5690 hsed_config_1.ir_gpio = -1;
5691
5692 for (i = 0; i < ARRAY_SIZE(othc_accessories); i++) {
5693 if (machine_is_msm8x60_fluid()) {
5694 switch (othc_accessories[i].accessory) {
5695 case OTHC_ANC_HEADPHONE:
5696 case OTHC_ANC_HEADSET:
5697 othc_accessories[i].gpio = GPIO_HEADSET_DET_N;
5698 break;
5699 case OTHC_MICROPHONE:
5700 othc_accessories[i].enabled = false;
5701 break;
5702 case OTHC_SVIDEO_OUT:
5703 othc_accessories[i].enabled = true;
5704 hsed_config_1.video_out_gpio = GPIO_HS_SW_DIR;
5705 break;
5706 }
5707 }
5708 }
5709}
5710#endif
5711
5712static struct resource resources_pm8058_charger[] = {
5713 { .name = "CHGVAL",
5714 .start = PM8058_CHGVAL_IRQ(PM8058_IRQ_BASE),
5715 .end = PM8058_CHGVAL_IRQ(PM8058_IRQ_BASE),
5716 .flags = IORESOURCE_IRQ,
5717 },
5718 { .name = "CHGINVAL",
5719 .start = PM8058_CHGINVAL_IRQ(PM8058_IRQ_BASE),
5720 .end = PM8058_CHGINVAL_IRQ(PM8058_IRQ_BASE),
5721 .flags = IORESOURCE_IRQ,
5722 },
5723 {
5724 .name = "CHGILIM",
5725 .start = PM8058_CHGILIM_IRQ(PM8058_IRQ_BASE),
5726 .end = PM8058_CHGILIM_IRQ(PM8058_IRQ_BASE),
5727 .flags = IORESOURCE_IRQ,
5728 },
5729 {
5730 .name = "VCP",
5731 .start = PM8058_VCP_IRQ(PM8058_IRQ_BASE),
5732 .end = PM8058_VCP_IRQ(PM8058_IRQ_BASE),
5733 .flags = IORESOURCE_IRQ,
5734 },
5735 {
5736 .name = "ATC_DONE",
5737 .start = PM8058_ATC_DONE_IRQ(PM8058_IRQ_BASE),
5738 .end = PM8058_ATC_DONE_IRQ(PM8058_IRQ_BASE),
5739 .flags = IORESOURCE_IRQ,
5740 },
5741 {
5742 .name = "ATCFAIL",
5743 .start = PM8058_ATCFAIL_IRQ(PM8058_IRQ_BASE),
5744 .end = PM8058_ATCFAIL_IRQ(PM8058_IRQ_BASE),
5745 .flags = IORESOURCE_IRQ,
5746 },
5747 {
5748 .name = "AUTO_CHGDONE",
5749 .start = PM8058_AUTO_CHGDONE_IRQ(PM8058_IRQ_BASE),
5750 .end = PM8058_AUTO_CHGDONE_IRQ(PM8058_IRQ_BASE),
5751 .flags = IORESOURCE_IRQ,
5752 },
5753 {
5754 .name = "AUTO_CHGFAIL",
5755 .start = PM8058_AUTO_CHGFAIL_IRQ(PM8058_IRQ_BASE),
5756 .end = PM8058_AUTO_CHGFAIL_IRQ(PM8058_IRQ_BASE),
5757 .flags = IORESOURCE_IRQ,
5758 },
5759 {
5760 .name = "CHGSTATE",
5761 .start = PM8058_CHGSTATE_IRQ(PM8058_IRQ_BASE),
5762 .end = PM8058_CHGSTATE_IRQ(PM8058_IRQ_BASE),
5763 .flags = IORESOURCE_IRQ,
5764 },
5765 {
5766 .name = "FASTCHG",
5767 .start = PM8058_FASTCHG_IRQ(PM8058_IRQ_BASE),
5768 .end = PM8058_FASTCHG_IRQ(PM8058_IRQ_BASE),
5769 .flags = IORESOURCE_IRQ,
5770 },
5771 {
5772 .name = "CHG_END",
5773 .start = PM8058_CHG_END_IRQ(PM8058_IRQ_BASE),
5774 .end = PM8058_CHG_END_IRQ(PM8058_IRQ_BASE),
5775 .flags = IORESOURCE_IRQ,
5776 },
5777 {
5778 .name = "BATTTEMP",
5779 .start = PM8058_BATTTEMP_IRQ(PM8058_IRQ_BASE),
5780 .end = PM8058_BATTTEMP_IRQ(PM8058_IRQ_BASE),
5781 .flags = IORESOURCE_IRQ,
5782 },
5783 {
5784 .name = "CHGHOT",
5785 .start = PM8058_CHGHOT_IRQ(PM8058_IRQ_BASE),
5786 .end = PM8058_CHGHOT_IRQ(PM8058_IRQ_BASE),
5787 .flags = IORESOURCE_IRQ,
5788 },
5789 {
5790 .name = "CHGTLIMIT",
5791 .start = PM8058_CHGTLIMIT_IRQ(PM8058_IRQ_BASE),
5792 .end = PM8058_CHGTLIMIT_IRQ(PM8058_IRQ_BASE),
5793 .flags = IORESOURCE_IRQ,
5794 },
5795 {
5796 .name = "CHG_GONE",
5797 .start = PM8058_CHG_GONE_IRQ(PM8058_IRQ_BASE),
5798 .end = PM8058_CHG_GONE_IRQ(PM8058_IRQ_BASE),
5799 .flags = IORESOURCE_IRQ,
5800 },
5801 {
5802 .name = "VCPMAJOR",
5803 .start = PM8058_VCPMAJOR_IRQ(PM8058_IRQ_BASE),
5804 .end = PM8058_VCPMAJOR_IRQ(PM8058_IRQ_BASE),
5805 .flags = IORESOURCE_IRQ,
5806 },
5807 {
5808 .name = "VBATDET",
5809 .start = PM8058_VBATDET_IRQ(PM8058_IRQ_BASE),
5810 .end = PM8058_VBATDET_IRQ(PM8058_IRQ_BASE),
5811 .flags = IORESOURCE_IRQ,
5812 },
5813 {
5814 .name = "BATFET",
5815 .start = PM8058_BATFET_IRQ(PM8058_IRQ_BASE),
5816 .end = PM8058_BATFET_IRQ(PM8058_IRQ_BASE),
5817 .flags = IORESOURCE_IRQ,
5818 },
5819 {
5820 .name = "BATT_REPLACE",
5821 .start = PM8058_BATT_REPLACE_IRQ(PM8058_IRQ_BASE),
5822 .end = PM8058_BATT_REPLACE_IRQ(PM8058_IRQ_BASE),
5823 .flags = IORESOURCE_IRQ,
5824 },
5825 {
5826 .name = "BATTCONNECT",
5827 .start = PM8058_BATTCONNECT_IRQ(PM8058_IRQ_BASE),
5828 .end = PM8058_BATTCONNECT_IRQ(PM8058_IRQ_BASE),
5829 .flags = IORESOURCE_IRQ,
5830 },
5831 {
5832 .name = "VBATDET_LOW",
5833 .start = PM8058_VBATDET_LOW_IRQ(PM8058_IRQ_BASE),
5834 .end = PM8058_VBATDET_LOW_IRQ(PM8058_IRQ_BASE),
5835 .flags = IORESOURCE_IRQ,
5836 },
5837};
5838
5839static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
5840{
5841 struct pm8058_gpio pwm_gpio_config = {
5842 .direction = PM_GPIO_DIR_OUT,
5843 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5844 .output_value = 0,
5845 .pull = PM_GPIO_PULL_NO,
5846 .vin_sel = PM_GPIO_VIN_VPH,
5847 .out_strength = PM_GPIO_STRENGTH_HIGH,
5848 .function = PM_GPIO_FUNC_2,
5849 };
5850
5851 int rc = -EINVAL;
5852 int id, mode, max_mA;
5853
5854 id = mode = max_mA = 0;
5855 switch (ch) {
5856 case 0:
5857 case 1:
5858 case 2:
5859 if (on) {
5860 id = 24 + ch;
5861 rc = pm8058_gpio_config(id - 1, &pwm_gpio_config);
5862 if (rc)
5863 pr_err("%s: pm8058_gpio_config(%d): rc=%d\n",
5864 __func__, id, rc);
5865 }
5866 break;
5867
5868 case 6:
5869 id = PM_PWM_LED_FLASH;
5870 mode = PM_PWM_CONF_PWM1;
5871 max_mA = 300;
5872 break;
5873
5874 case 7:
5875 id = PM_PWM_LED_FLASH1;
5876 mode = PM_PWM_CONF_PWM1;
5877 max_mA = 300;
5878 break;
5879
5880 default:
5881 break;
5882 }
5883
5884 if (ch >= 6 && ch <= 7) {
5885 if (!on) {
5886 mode = PM_PWM_CONF_NONE;
5887 max_mA = 0;
5888 }
5889 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
5890 if (rc)
5891 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
5892 __func__, ch, rc);
5893 }
5894 return rc;
5895
5896}
5897
5898static struct pm8058_pwm_pdata pm8058_pwm_data = {
5899 .config = pm8058_pwm_config,
5900};
5901
5902#define PM8058_GPIO_INT 88
5903
5904static struct pm8058_gpio_platform_data pm8058_gpio_data = {
5905 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
5906 .irq_base = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 0),
5907 .init = pm8058_gpios_init,
5908};
5909
5910static struct pm8058_gpio_platform_data pm8058_mpp_data = {
5911 .gpio_base = PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS),
5912 .irq_base = PM8058_MPP_IRQ(PM8058_IRQ_BASE, 0),
5913};
5914
5915static struct resource resources_rtc[] = {
5916 {
5917 .start = PM8058_RTC_IRQ(PM8058_IRQ_BASE),
5918 .end = PM8058_RTC_IRQ(PM8058_IRQ_BASE),
5919 .flags = IORESOURCE_IRQ,
5920 },
5921 {
5922 .start = PM8058_RTC_ALARM_IRQ(PM8058_IRQ_BASE),
5923 .end = PM8058_RTC_ALARM_IRQ(PM8058_IRQ_BASE),
5924 .flags = IORESOURCE_IRQ,
5925 },
5926};
5927
Ashay Jaiswal4d1ab552011-07-15 11:30:49 +05305928static struct pm8058_rtc_platform_data pm8058_rtc_pdata = {
5929 .rtc_alarm_powerup = false,
5930};
5931
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005932static struct pmic8058_led pmic8058_flash_leds[] = {
5933 [0] = {
5934 .name = "camera:flash0",
5935 .max_brightness = 15,
5936 .id = PMIC8058_ID_FLASH_LED_0,
5937 },
5938 [1] = {
5939 .name = "camera:flash1",
5940 .max_brightness = 15,
5941 .id = PMIC8058_ID_FLASH_LED_1,
5942 },
5943};
5944
5945static struct pmic8058_leds_platform_data pm8058_flash_leds_data = {
5946 .num_leds = ARRAY_SIZE(pmic8058_flash_leds),
5947 .leds = pmic8058_flash_leds,
5948};
5949
Terence Hampsonc0b6dfb2011-07-15 11:07:17 -04005950static struct pmic8058_led pmic8058_dragon_leds[] = {
5951 [0] = {
5952 /* RED */
5953 .name = "led_drv0",
5954 .max_brightness = 15,
5955 .id = PMIC8058_ID_LED_0,
5956 },/* 300 mA flash led0 drv sink */
5957 [1] = {
5958 /* Yellow */
5959 .name = "led_drv1",
5960 .max_brightness = 15,
5961 .id = PMIC8058_ID_LED_1,
5962 },/* 300 mA flash led0 drv sink */
5963 [2] = {
5964 /* Green */
5965 .name = "led_drv2",
5966 .max_brightness = 15,
5967 .id = PMIC8058_ID_LED_2,
5968 },/* 300 mA flash led0 drv sink */
5969 [3] = {
5970 .name = "led_psensor",
5971 .max_brightness = 15,
5972 .id = PMIC8058_ID_LED_KB_LIGHT,
5973 },/* 300 mA flash led0 drv sink */
5974};
5975
5976static struct pmic8058_leds_platform_data pm8058_dragon_leds_data = {
5977 .num_leds = ARRAY_SIZE(pmic8058_dragon_leds),
5978 .leds = pmic8058_dragon_leds,
5979};
5980
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005981static struct pmic8058_led pmic8058_fluid_flash_leds[] = {
5982 [0] = {
5983 .name = "led:drv0",
5984 .max_brightness = 15,
5985 .id = PMIC8058_ID_FLASH_LED_0,
5986 },/* 300 mA flash led0 drv sink */
5987 [1] = {
5988 .name = "led:drv1",
5989 .max_brightness = 15,
5990 .id = PMIC8058_ID_FLASH_LED_1,
5991 },/* 300 mA flash led1 sink */
5992 [2] = {
5993 .name = "led:drv2",
5994 .max_brightness = 20,
5995 .id = PMIC8058_ID_LED_0,
5996 },/* 40 mA led0 sink */
5997 [3] = {
5998 .name = "keypad:drv",
5999 .max_brightness = 15,
6000 .id = PMIC8058_ID_LED_KB_LIGHT,
6001 },/* 300 mA keypad drv sink */
6002};
6003
6004static struct pmic8058_leds_platform_data pm8058_fluid_flash_leds_data = {
6005 .num_leds = ARRAY_SIZE(pmic8058_fluid_flash_leds),
6006 .leds = pmic8058_fluid_flash_leds,
6007};
6008
6009static struct resource resources_temp_alarm[] = {
6010 {
6011 .start = PM8058_TEMP_ALARM_IRQ(PM8058_IRQ_BASE),
6012 .end = PM8058_TEMP_ALARM_IRQ(PM8058_IRQ_BASE),
6013 .flags = IORESOURCE_IRQ,
6014 },
6015};
6016
6017static struct resource resources_pm8058_misc[] = {
6018 {
6019 .start = PM8058_OSCHALT_IRQ(PM8058_IRQ_BASE),
6020 .end = PM8058_OSCHALT_IRQ(PM8058_IRQ_BASE),
6021 .flags = IORESOURCE_IRQ,
6022 },
6023};
6024
6025static struct resource resources_pm8058_batt_alarm[] = {
6026 {
6027 .start = PM8058_BATT_ALARM_IRQ(PM8058_IRQ_BASE),
6028 .end = PM8058_BATT_ALARM_IRQ(PM8058_IRQ_BASE),
6029 .flags = IORESOURCE_IRQ,
6030 },
6031};
6032
6033#define PM8058_SUBDEV_KPD 0
6034#define PM8058_SUBDEV_LED 1
6035#define PM8058_SUBDEV_VIB 2
6036
6037static struct mfd_cell pm8058_subdevs[] = {
6038 {
6039 .name = "pm8058-keypad",
6040 .id = -1,
6041 .num_resources = ARRAY_SIZE(resources_keypad),
6042 .resources = resources_keypad,
6043 },
6044 { .name = "pm8058-led",
6045 .id = -1,
6046 },
6047 {
6048 .name = "pm8058-vib",
6049 .id = -1,
6050 },
6051 { .name = "pm8058-gpio",
6052 .id = -1,
6053 .platform_data = &pm8058_gpio_data,
6054 .pdata_size = sizeof(pm8058_gpio_data),
6055 },
6056 { .name = "pm8058-mpp",
6057 .id = -1,
6058 .platform_data = &pm8058_mpp_data,
6059 .pdata_size = sizeof(pm8058_mpp_data),
6060 },
6061 { .name = "pm8058-pwrkey",
6062 .id = -1,
6063 .resources = resources_pwrkey,
6064 .num_resources = ARRAY_SIZE(resources_pwrkey),
6065 .platform_data = &pwrkey_pdata,
6066 .pdata_size = sizeof(pwrkey_pdata),
6067 },
6068 {
6069 .name = "pm8058-pwm",
6070 .id = -1,
6071 .platform_data = &pm8058_pwm_data,
6072 .pdata_size = sizeof(pm8058_pwm_data),
6073 },
6074#ifdef CONFIG_SENSORS_MSM_ADC
6075 {
6076 .name = "pm8058-xoadc",
6077 .id = -1,
6078 .num_resources = ARRAY_SIZE(resources_adc),
6079 .resources = resources_adc,
6080 .platform_data = &xoadc_pdata,
6081 .pdata_size = sizeof(xoadc_pdata),
6082 },
6083#endif
6084#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
6085 {
6086 .name = "pm8058-othc",
6087 .id = 0,
6088 .platform_data = &othc_config_pdata_0,
6089 .pdata_size = sizeof(othc_config_pdata_0),
6090 .num_resources = ARRAY_SIZE(resources_othc_0),
6091 .resources = resources_othc_0,
6092 },
6093 {
6094 /* OTHC1 module has headset/switch dection */
6095 .name = "pm8058-othc",
6096 .id = 1,
6097 .num_resources = ARRAY_SIZE(resources_othc_1),
6098 .resources = resources_othc_1,
6099 .platform_data = &othc_config_pdata_1,
6100 .pdata_size = sizeof(othc_config_pdata_1),
6101 },
6102 {
6103 .name = "pm8058-othc",
6104 .id = 2,
6105 .platform_data = &othc_config_pdata_2,
6106 .pdata_size = sizeof(othc_config_pdata_2),
6107 .num_resources = ARRAY_SIZE(resources_othc_2),
6108 .resources = resources_othc_2,
6109 },
6110#endif
6111 {
6112 .name = "pm8058-rtc",
6113 .id = -1,
6114 .num_resources = ARRAY_SIZE(resources_rtc),
6115 .resources = resources_rtc,
Ashay Jaiswal4d1ab552011-07-15 11:30:49 +05306116 .platform_data = &pm8058_rtc_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006117 },
6118 {
6119 .name = "pm8058-tm",
6120 .id = -1,
6121 .num_resources = ARRAY_SIZE(resources_temp_alarm),
6122 .resources = resources_temp_alarm,
6123 },
6124 { .name = "pm8058-upl",
6125 .id = -1,
6126 },
6127 {
6128 .name = "pm8058-misc",
6129 .id = -1,
6130 .num_resources = ARRAY_SIZE(resources_pm8058_misc),
6131 .resources = resources_pm8058_misc,
6132 },
6133 { .name = "pm8058-batt-alarm",
6134 .id = -1,
6135 .num_resources = ARRAY_SIZE(resources_pm8058_batt_alarm),
6136 .resources = resources_pm8058_batt_alarm,
6137 },
6138};
6139
6140static struct mfd_cell pm8058_charger_sub_dev = {
6141 .name = "pm8058-charger",
6142 .id = -1,
6143 .num_resources = ARRAY_SIZE(resources_pm8058_charger),
6144 .resources = resources_pm8058_charger,
6145};
6146
6147static struct pm8058_platform_data pm8058_platform_data = {
6148 .irq_base = PM8058_IRQ_BASE,
6149
6150 .num_subdevs = ARRAY_SIZE(pm8058_subdevs),
6151 .sub_devices = pm8058_subdevs,
6152 .irq_trigger_flags = IRQF_TRIGGER_LOW,
6153};
6154
6155static struct i2c_board_info pm8058_boardinfo[] __initdata = {
6156 {
6157 I2C_BOARD_INFO("pm8058-core", 0x55),
6158 .irq = MSM_GPIO_TO_INT(PM8058_GPIO_INT),
6159 .platform_data = &pm8058_platform_data,
6160 },
6161};
6162#endif /* CONFIG_PMIC8058 */
6163
6164#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
6165 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
6166#define TDISC_I2C_SLAVE_ADDR 0x67
6167#define PMIC_GPIO_TDISC PM8058_GPIO_PM_TO_SYS(5)
6168#define TDISC_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 5)
6169
6170static const char *vregs_tdisc_name[] = {
6171 "8058_l5",
6172 "8058_s3",
6173};
6174
6175static const int vregs_tdisc_val[] = {
6176 2850000,/* uV */
6177 1800000,
6178};
6179static struct regulator *vregs_tdisc[ARRAY_SIZE(vregs_tdisc_name)];
6180
6181static int tdisc_shinetsu_setup(void)
6182{
6183 int rc, i;
6184
6185 rc = gpio_request(PMIC_GPIO_TDISC, "tdisc_interrupt");
6186 if (rc) {
6187 pr_err("%s: gpio_request failed for PMIC_GPIO_TDISC\n",
6188 __func__);
6189 return rc;
6190 }
6191
6192 rc = gpio_request(GPIO_JOYSTICK_EN, "tdisc_oe");
6193 if (rc) {
6194 pr_err("%s: gpio_request failed for GPIO_JOYSTICK_EN\n",
6195 __func__);
6196 goto fail_gpio_oe;
6197 }
6198
6199 rc = gpio_direction_output(GPIO_JOYSTICK_EN, 1);
6200 if (rc) {
6201 pr_err("%s: gpio_direction_output failed for GPIO_JOYSTICK_EN\n",
6202 __func__);
6203 gpio_free(GPIO_JOYSTICK_EN);
6204 goto fail_gpio_oe;
6205 }
6206
6207 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6208 vregs_tdisc[i] = regulator_get(NULL, vregs_tdisc_name[i]);
6209 if (IS_ERR(vregs_tdisc[i])) {
6210 printk(KERN_ERR "%s: regulator get %s failed (%ld)\n",
6211 __func__, vregs_tdisc_name[i],
6212 PTR_ERR(vregs_tdisc[i]));
6213 rc = PTR_ERR(vregs_tdisc[i]);
6214 goto vreg_get_fail;
6215 }
6216
6217 rc = regulator_set_voltage(vregs_tdisc[i],
6218 vregs_tdisc_val[i], vregs_tdisc_val[i]);
6219 if (rc) {
6220 printk(KERN_ERR "%s: regulator_set_voltage() = %d\n",
6221 __func__, rc);
6222 goto vreg_set_voltage_fail;
6223 }
6224 }
6225
6226 return rc;
6227vreg_set_voltage_fail:
6228 i++;
6229vreg_get_fail:
6230 while (i)
6231 regulator_put(vregs_tdisc[--i]);
6232fail_gpio_oe:
6233 gpio_free(PMIC_GPIO_TDISC);
6234 return rc;
6235}
6236
6237static void tdisc_shinetsu_release(void)
6238{
6239 int i;
6240
6241 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++)
6242 regulator_put(vregs_tdisc[i]);
6243
6244 gpio_free(PMIC_GPIO_TDISC);
6245 gpio_free(GPIO_JOYSTICK_EN);
6246}
6247
6248static int tdisc_shinetsu_enable(void)
6249{
6250 int i, rc = -EINVAL;
6251
6252 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6253 rc = regulator_enable(vregs_tdisc[i]);
6254 if (rc < 0) {
6255 printk(KERN_ERR "%s: vreg %s enable failed (%d)\n",
6256 __func__, vregs_tdisc_name[i], rc);
6257 goto vreg_fail;
6258 }
6259 }
6260
6261 /* Enable the OE (output enable) gpio */
6262 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 1);
6263 /* voltage and gpio stabilization delay */
6264 msleep(50);
6265
6266 return 0;
6267vreg_fail:
6268 while (i)
6269 regulator_disable(vregs_tdisc[--i]);
6270 return rc;
6271}
6272
6273static int tdisc_shinetsu_disable(void)
6274{
6275 int i, rc;
6276
6277 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6278 rc = regulator_disable(vregs_tdisc[i]);
6279 if (rc < 0) {
6280 printk(KERN_ERR "%s: vreg %s disable failed (%d)\n",
6281 __func__, vregs_tdisc_name[i], rc);
6282 goto tdisc_reg_fail;
6283 }
6284 }
6285
6286 /* Disable the OE (output enable) gpio */
6287 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 0);
6288
6289 return 0;
6290
6291tdisc_reg_fail:
6292 while (i)
6293 regulator_enable(vregs_tdisc[--i]);
6294 return rc;
6295}
6296
6297static struct tdisc_abs_values tdisc_abs = {
6298 .x_max = 32,
6299 .y_max = 32,
6300 .x_min = -32,
6301 .y_min = -32,
6302 .pressure_max = 32,
6303 .pressure_min = 0,
6304};
6305
6306static struct tdisc_platform_data tdisc_data = {
6307 .tdisc_setup = tdisc_shinetsu_setup,
6308 .tdisc_release = tdisc_shinetsu_release,
6309 .tdisc_enable = tdisc_shinetsu_enable,
6310 .tdisc_disable = tdisc_shinetsu_disable,
6311 .tdisc_wakeup = 0,
6312 .tdisc_gpio = PMIC_GPIO_TDISC,
6313 .tdisc_report_keys = true,
6314 .tdisc_report_relative = true,
6315 .tdisc_report_absolute = false,
6316 .tdisc_report_wheel = false,
6317 .tdisc_reverse_x = false,
6318 .tdisc_reverse_y = true,
6319 .tdisc_abs = &tdisc_abs,
6320};
6321
6322static struct i2c_board_info msm_i2c_gsbi3_tdisc_info[] = {
6323 {
6324 I2C_BOARD_INFO("vtd518", TDISC_I2C_SLAVE_ADDR),
6325 .irq = TDISC_INT,
6326 .platform_data = &tdisc_data,
6327 },
6328};
6329#endif
6330
6331#define PM_GPIO_CDC_RST_N 20
6332#define GPIO_CDC_RST_N PM8058_GPIO_PM_TO_SYS(PM_GPIO_CDC_RST_N)
6333
6334static struct regulator *vreg_timpani_1;
6335static struct regulator *vreg_timpani_2;
6336
6337static unsigned int msm_timpani_setup_power(void)
6338{
6339 int rc;
6340
6341 vreg_timpani_1 = regulator_get(NULL, "8058_l0");
6342 if (IS_ERR(vreg_timpani_1)) {
6343 pr_err("%s: Unable to get 8058_l0\n", __func__);
6344 return -ENODEV;
6345 }
6346
6347 vreg_timpani_2 = regulator_get(NULL, "8058_s3");
6348 if (IS_ERR(vreg_timpani_2)) {
6349 pr_err("%s: Unable to get 8058_s3\n", __func__);
6350 regulator_put(vreg_timpani_1);
6351 return -ENODEV;
6352 }
6353
6354 rc = regulator_set_voltage(vreg_timpani_1, 1200000, 1200000);
6355 if (rc) {
6356 pr_err("%s: unable to set L0 voltage to 1.2V\n", __func__);
6357 goto fail;
6358 }
6359
6360 rc = regulator_set_voltage(vreg_timpani_2, 1800000, 1800000);
6361 if (rc) {
6362 pr_err("%s: unable to set S3 voltage to 1.8V\n", __func__);
6363 goto fail;
6364 }
6365
6366 rc = regulator_enable(vreg_timpani_1);
6367 if (rc) {
6368 pr_err("%s: Enable regulator 8058_l0 failed\n", __func__);
6369 goto fail;
6370 }
6371
6372 /* The settings for LDO0 should be set such that
6373 * it doesn't require to reset the timpani. */
6374 rc = regulator_set_optimum_mode(vreg_timpani_1, 5000);
6375 if (rc < 0) {
6376 pr_err("Timpani regulator optimum mode setting failed\n");
6377 goto fail;
6378 }
6379
6380 rc = regulator_enable(vreg_timpani_2);
6381 if (rc) {
6382 pr_err("%s: Enable regulator 8058_s3 failed\n", __func__);
6383 regulator_disable(vreg_timpani_1);
6384 goto fail;
6385 }
6386
6387 rc = gpio_request(GPIO_CDC_RST_N, "CDC_RST_N");
6388 if (rc) {
6389 pr_err("%s: GPIO Request %d failed\n", __func__,
6390 GPIO_CDC_RST_N);
6391 regulator_disable(vreg_timpani_1);
6392 regulator_disable(vreg_timpani_2);
6393 goto fail;
6394 } else {
6395 gpio_direction_output(GPIO_CDC_RST_N, 1);
6396 usleep_range(1000, 1050);
6397 gpio_direction_output(GPIO_CDC_RST_N, 0);
6398 usleep_range(1000, 1050);
6399 gpio_direction_output(GPIO_CDC_RST_N, 1);
6400 gpio_free(GPIO_CDC_RST_N);
6401 }
6402 return rc;
6403
6404fail:
6405 regulator_put(vreg_timpani_1);
6406 regulator_put(vreg_timpani_2);
6407 return rc;
6408}
6409
6410static void msm_timpani_shutdown_power(void)
6411{
6412 int rc;
6413
6414 rc = regulator_disable(vreg_timpani_1);
6415 if (rc)
6416 pr_err("%s: Disable regulator 8058_l0 failed\n", __func__);
6417
6418 regulator_put(vreg_timpani_1);
6419
6420 rc = regulator_disable(vreg_timpani_2);
6421 if (rc)
6422 pr_err("%s: Disable regulator 8058_s3 failed\n", __func__);
6423
6424 regulator_put(vreg_timpani_2);
6425}
6426
6427/* Power analog function of codec */
6428static struct regulator *vreg_timpani_cdc_apwr;
6429static int msm_timpani_codec_power(int vreg_on)
6430{
6431 int rc = 0;
6432
6433 if (!vreg_timpani_cdc_apwr) {
6434
6435 vreg_timpani_cdc_apwr = regulator_get(NULL, "8058_s4");
6436
6437 if (IS_ERR(vreg_timpani_cdc_apwr)) {
6438 pr_err("%s: vreg_get failed (%ld)\n",
6439 __func__, PTR_ERR(vreg_timpani_cdc_apwr));
6440 rc = PTR_ERR(vreg_timpani_cdc_apwr);
6441 return rc;
6442 }
6443 }
6444
6445 if (vreg_on) {
6446
6447 rc = regulator_set_voltage(vreg_timpani_cdc_apwr,
6448 2200000, 2200000);
6449 if (rc) {
6450 pr_err("%s: unable to set 8058_s4 voltage to 2.2 V\n",
6451 __func__);
6452 goto vreg_fail;
6453 }
6454
6455 rc = regulator_enable(vreg_timpani_cdc_apwr);
6456 if (rc) {
6457 pr_err("%s: vreg_enable failed %d\n", __func__, rc);
6458 goto vreg_fail;
6459 }
6460 } else {
6461 rc = regulator_disable(vreg_timpani_cdc_apwr);
6462 if (rc) {
6463 pr_err("%s: vreg_disable failed %d\n",
6464 __func__, rc);
6465 goto vreg_fail;
6466 }
6467 }
6468
6469 return 0;
6470
6471vreg_fail:
6472 regulator_put(vreg_timpani_cdc_apwr);
6473 vreg_timpani_cdc_apwr = NULL;
6474 return rc;
6475}
6476
6477static struct marimba_codec_platform_data timpani_codec_pdata = {
6478 .marimba_codec_power = msm_timpani_codec_power,
6479};
6480
6481#define TIMPANI_SLAVE_ID_CDC_ADDR 0X77
6482#define TIMPANI_SLAVE_ID_QMEMBIST_ADDR 0X66
6483
6484static struct marimba_platform_data timpani_pdata = {
6485 .slave_id[MARIMBA_SLAVE_ID_CDC] = TIMPANI_SLAVE_ID_CDC_ADDR,
6486 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = TIMPANI_SLAVE_ID_QMEMBIST_ADDR,
6487 .marimba_setup = msm_timpani_setup_power,
6488 .marimba_shutdown = msm_timpani_shutdown_power,
6489 .codec = &timpani_codec_pdata,
6490 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6491};
6492
6493#define TIMPANI_I2C_SLAVE_ADDR 0xD
6494
6495static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
6496 {
6497 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
6498 .platform_data = &timpani_pdata,
6499 },
6500};
6501
6502#ifdef CONFIG_PMIC8901
6503
6504#define PM8901_GPIO_INT 91
6505
6506static struct pm8901_gpio_platform_data pm8901_mpp_data = {
6507 .gpio_base = PM8901_GPIO_PM_TO_SYS(0),
6508 .irq_base = PM8901_MPP_IRQ(PM8901_IRQ_BASE, 0),
6509};
6510
6511static struct resource pm8901_temp_alarm[] = {
6512 {
6513 .start = PM8901_TEMP_ALARM_IRQ(PM8901_IRQ_BASE),
6514 .end = PM8901_TEMP_ALARM_IRQ(PM8901_IRQ_BASE),
6515 .flags = IORESOURCE_IRQ,
6516 },
6517 {
6518 .start = PM8901_TEMP_HI_ALARM_IRQ(PM8901_IRQ_BASE),
6519 .end = PM8901_TEMP_HI_ALARM_IRQ(PM8901_IRQ_BASE),
6520 .flags = IORESOURCE_IRQ,
6521 },
6522};
6523
6524/*
6525 * Consumer specific regulator names:
6526 * regulator name consumer dev_name
6527 */
6528static struct regulator_consumer_supply vreg_consumers_8901_MPP0[] = {
6529 REGULATOR_SUPPLY("8901_mpp0", NULL),
6530};
6531static struct regulator_consumer_supply vreg_consumers_8901_USB_OTG[] = {
6532 REGULATOR_SUPPLY("8901_usb_otg", NULL),
6533};
6534static struct regulator_consumer_supply vreg_consumers_8901_HDMI_MVS[] = {
6535 REGULATOR_SUPPLY("8901_hdmi_mvs", NULL),
6536};
6537
6538#define PM8901_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
6539 _always_on, _active_high) \
6540 [PM8901_VREG_ID_##_id] = { \
6541 .init_data = { \
6542 .constraints = { \
6543 .valid_modes_mask = _modes, \
6544 .valid_ops_mask = _ops, \
6545 .min_uV = _min_uV, \
6546 .max_uV = _max_uV, \
6547 .input_uV = _min_uV, \
6548 .apply_uV = _apply_uV, \
6549 .always_on = _always_on, \
6550 }, \
6551 .consumer_supplies = vreg_consumers_8901_##_id, \
6552 .num_consumer_supplies = \
6553 ARRAY_SIZE(vreg_consumers_8901_##_id), \
6554 }, \
6555 .active_high = _active_high, \
6556 }
6557
6558#define PM8901_VREG_INIT_MPP(_id, _active_high) \
6559 PM8901_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL, \
6560 REGULATOR_CHANGE_STATUS, 0, 0, _active_high)
6561
6562#define PM8901_VREG_INIT_VS(_id) \
6563 PM8901_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL, \
6564 REGULATOR_CHANGE_STATUS, 0, 0, 0)
6565
6566static struct pm8901_vreg_pdata pm8901_vreg_init_pdata[PM8901_VREG_MAX] = {
6567 PM8901_VREG_INIT_MPP(MPP0, 1),
6568
6569 PM8901_VREG_INIT_VS(USB_OTG),
6570 PM8901_VREG_INIT_VS(HDMI_MVS),
6571};
6572
6573#define PM8901_VREG(_id) { \
6574 .name = "pm8901-regulator", \
6575 .id = _id, \
6576 .platform_data = &pm8901_vreg_init_pdata[_id], \
6577 .pdata_size = sizeof(pm8901_vreg_init_pdata[_id]), \
6578}
6579
6580static struct mfd_cell pm8901_subdevs[] = {
6581 { .name = "pm8901-mpp",
6582 .id = -1,
6583 .platform_data = &pm8901_mpp_data,
6584 .pdata_size = sizeof(pm8901_mpp_data),
6585 },
6586 { .name = "pm8901-tm",
6587 .id = -1,
6588 .num_resources = ARRAY_SIZE(pm8901_temp_alarm),
6589 .resources = pm8901_temp_alarm,
6590 },
6591 PM8901_VREG(PM8901_VREG_ID_MPP0),
6592 PM8901_VREG(PM8901_VREG_ID_USB_OTG),
6593 PM8901_VREG(PM8901_VREG_ID_HDMI_MVS),
6594};
6595
6596static struct pm8901_platform_data pm8901_platform_data = {
6597 .irq_base = PM8901_IRQ_BASE,
6598 .num_subdevs = ARRAY_SIZE(pm8901_subdevs),
6599 .sub_devices = pm8901_subdevs,
6600 .irq_trigger_flags = IRQF_TRIGGER_LOW,
6601};
6602
6603static struct i2c_board_info pm8901_boardinfo[] __initdata = {
6604 {
6605 I2C_BOARD_INFO("pm8901-core", 0x55),
6606 .irq = MSM_GPIO_TO_INT(PM8901_GPIO_INT),
6607 .platform_data = &pm8901_platform_data,
6608 },
6609};
6610
6611#endif /* CONFIG_PMIC8901 */
6612
6613#if defined(CONFIG_MARIMBA_CORE) && (defined(CONFIG_GPIO_SX150X) \
6614 || defined(CONFIG_GPIO_SX150X_MODULE))
6615
6616static struct regulator *vreg_bahama;
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006617static int msm_bahama_sys_rst = GPIO_MS_SYS_RESET_N;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006618
6619struct bahama_config_register{
6620 u8 reg;
6621 u8 value;
6622 u8 mask;
6623};
6624
6625enum version{
6626 VER_1_0,
6627 VER_2_0,
6628 VER_UNSUPPORTED = 0xFF
6629};
6630
6631static u8 read_bahama_ver(void)
6632{
6633 int rc;
6634 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6635 u8 bahama_version;
6636
6637 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
6638 if (rc < 0) {
6639 printk(KERN_ERR
6640 "%s: version read failed: %d\n",
6641 __func__, rc);
6642 return VER_UNSUPPORTED;
6643 } else {
6644 printk(KERN_INFO
6645 "%s: version read got: 0x%x\n",
6646 __func__, bahama_version);
6647 }
6648
6649 switch (bahama_version) {
6650 case 0x08: /* varient of bahama v1 */
6651 case 0x10:
6652 case 0x00:
6653 return VER_1_0;
6654 case 0x09: /* variant of bahama v2 */
6655 return VER_2_0;
6656 default:
6657 return VER_UNSUPPORTED;
6658 }
6659}
6660
6661static unsigned int msm_bahama_setup_power(void)
6662{
6663 int rc = 0;
6664 const char *msm_bahama_regulator = "8058_s3";
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006665
6666 if (machine_is_msm8x60_dragon())
6667 msm_bahama_sys_rst = GPIO_CDC_RST_N;
6668
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006669 vreg_bahama = regulator_get(NULL, msm_bahama_regulator);
6670
6671 if (IS_ERR(vreg_bahama)) {
6672 rc = PTR_ERR(vreg_bahama);
6673 pr_err("%s: regulator_get %s = %d\n", __func__,
6674 msm_bahama_regulator, rc);
6675 }
6676
6677 if (!rc)
6678 rc = regulator_set_voltage(vreg_bahama, 1800000, 1800000);
6679 else {
6680 pr_err("%s: regulator_set_voltage %s = %d\n", __func__,
6681 msm_bahama_regulator, rc);
6682 goto unget;
6683 }
6684
6685 if (!rc)
6686 rc = regulator_enable(vreg_bahama);
6687 else {
6688 pr_err("%s: regulator_enable %s = %d\n", __func__,
6689 msm_bahama_regulator, rc);
6690 goto unget;
6691 }
6692
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006693 if (!rc) {
6694 rc = gpio_request(msm_bahama_sys_rst, "bahama sys_rst_n");
6695 } else {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006696 pr_err("%s: gpio_request %d = %d\n", __func__,
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006697 msm_bahama_sys_rst, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006698 goto unenable;
6699 }
6700
Siddartha Mohanadoss72d796e2011-07-20 22:08:34 -07006701 if (!rc) {
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006702 gpio_direction_output(msm_bahama_sys_rst, 0);
Siddartha Mohanadoss72d796e2011-07-20 22:08:34 -07006703 usleep_range(1000, 1050);
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006704 gpio_set_value_cansleep(msm_bahama_sys_rst, 1);
Siddartha Mohanadoss72d796e2011-07-20 22:08:34 -07006705 usleep_range(1000, 1050);
6706 } else {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006707 pr_err("%s: gpio_direction_output %d = %d\n", __func__,
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006708 msm_bahama_sys_rst, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006709 goto unrequest;
6710 }
6711
6712 return rc;
6713
6714unrequest:
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006715 gpio_free(msm_bahama_sys_rst);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006716unenable:
6717 regulator_disable(vreg_bahama);
6718unget:
6719 regulator_put(vreg_bahama);
6720 return rc;
6721};
6722static unsigned int msm_bahama_shutdown_power(int value)
6723
6724
6725{
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006726 gpio_set_value_cansleep(msm_bahama_sys_rst, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006727
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04006728 gpio_free(msm_bahama_sys_rst);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006729
6730 regulator_disable(vreg_bahama);
6731
6732 regulator_put(vreg_bahama);
6733
6734 return 0;
6735};
6736
6737static unsigned int msm_bahama_core_config(int type)
6738{
6739 int rc = 0;
6740
6741 if (type == BAHAMA_ID) {
6742
6743 int i;
6744 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6745
6746 const struct bahama_config_register v20_init[] = {
6747 /* reg, value, mask */
6748 { 0xF4, 0x84, 0xFF }, /* AREG */
6749 { 0xF0, 0x04, 0xFF } /* DREG */
6750 };
6751
6752 if (read_bahama_ver() == VER_2_0) {
6753 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
6754 u8 value = v20_init[i].value;
6755 rc = marimba_write_bit_mask(&config,
6756 v20_init[i].reg,
6757 &value,
6758 sizeof(v20_init[i].value),
6759 v20_init[i].mask);
6760 if (rc < 0) {
6761 printk(KERN_ERR
6762 "%s: reg %d write failed: %d\n",
6763 __func__, v20_init[i].reg, rc);
6764 return rc;
6765 }
6766 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
6767 " mask 0x%02x\n",
6768 __func__, v20_init[i].reg,
6769 v20_init[i].value, v20_init[i].mask);
6770 }
6771 }
6772 }
6773 printk(KERN_INFO "core type: %d\n", type);
6774
6775 return rc;
6776}
6777
6778static struct regulator *fm_regulator_s3;
6779static struct msm_xo_voter *fm_clock;
6780
6781static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
6782{
6783 int rc = 0;
6784 struct pm8058_gpio cfg = {
6785 .direction = PM_GPIO_DIR_IN,
6786 .pull = PM_GPIO_PULL_NO,
6787 .vin_sel = PM_GPIO_VIN_S3,
6788 .function = PM_GPIO_FUNC_NORMAL,
6789 .inv_int_pol = 0,
6790 };
6791
6792 if (!fm_regulator_s3) {
6793 fm_regulator_s3 = regulator_get(NULL, "8058_s3");
6794 if (IS_ERR(fm_regulator_s3)) {
6795 rc = PTR_ERR(fm_regulator_s3);
6796 printk(KERN_ERR "%s: regulator get s3 (%d)\n",
6797 __func__, rc);
6798 goto out;
6799 }
6800 }
6801
6802
6803 rc = regulator_set_voltage(fm_regulator_s3, 1800000, 1800000);
6804 if (rc < 0) {
6805 printk(KERN_ERR "%s: regulator set voltage failed (%d)\n",
6806 __func__, rc);
6807 goto fm_fail_put;
6808 }
6809
6810 rc = regulator_enable(fm_regulator_s3);
6811 if (rc < 0) {
6812 printk(KERN_ERR "%s: regulator s3 enable failed (%d)\n",
6813 __func__, rc);
6814 goto fm_fail_put;
6815 }
6816
6817 /*Vote for XO clock*/
6818 fm_clock = msm_xo_get(MSM_XO_TCXO_D0, "fm_power");
6819
6820 if (IS_ERR(fm_clock)) {
6821 rc = PTR_ERR(fm_clock);
6822 printk(KERN_ERR "%s: Couldn't get TCXO_D0 vote for FM (%d)\n",
6823 __func__, rc);
6824 goto fm_fail_switch;
6825 }
6826
6827 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_ON);
6828 if (rc < 0) {
6829 printk(KERN_ERR "%s: Failed to vote for TCX0_D0 ON (%d)\n",
6830 __func__, rc);
6831 goto fm_fail_vote;
6832 }
6833
6834 /*GPIO 18 on PMIC is FM_IRQ*/
6835 rc = pm8058_gpio_config(FM_GPIO, &cfg);
6836 if (rc) {
6837 printk(KERN_ERR "%s: return val of pm8058_gpio_config: %d\n",
6838 __func__, rc);
6839 goto fm_fail_clock;
6840 }
6841 goto out;
6842
6843fm_fail_clock:
6844 msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
6845fm_fail_vote:
6846 msm_xo_put(fm_clock);
6847fm_fail_switch:
6848 regulator_disable(fm_regulator_s3);
6849fm_fail_put:
6850 regulator_put(fm_regulator_s3);
6851out:
6852 return rc;
6853};
6854
6855static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
6856{
6857 int rc = 0;
6858 if (fm_regulator_s3 != NULL) {
6859 rc = regulator_disable(fm_regulator_s3);
6860 if (rc < 0) {
6861 printk(KERN_ERR "%s: regulator s3 disable (%d)\n",
6862 __func__, rc);
6863 }
6864 regulator_put(fm_regulator_s3);
6865 fm_regulator_s3 = NULL;
6866 }
6867 printk(KERN_ERR "%s: Voting off for XO", __func__);
6868
6869 if (fm_clock != NULL) {
6870 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
6871 if (rc < 0) {
6872 printk(KERN_ERR "%s: Voting off XO clock (%d)\n",
6873 __func__, rc);
6874 }
6875 msm_xo_put(fm_clock);
6876 }
6877 printk(KERN_ERR "%s: coming out of fm_radio_shutdown", __func__);
6878}
6879
6880/* Slave id address for FM/CDC/QMEMBIST
6881 * Values can be programmed using Marimba slave id 0
6882 * should there be a conflict with other I2C devices
6883 * */
6884#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
6885#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
6886
6887static struct marimba_fm_platform_data marimba_fm_pdata = {
6888 .fm_setup = fm_radio_setup,
6889 .fm_shutdown = fm_radio_shutdown,
6890 .irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, FM_GPIO),
6891 .is_fm_soc_i2s_master = false,
6892 .config_i2s_gpio = NULL,
6893};
6894
6895/*
6896Just initializing the BAHAMA related slave
6897*/
6898static struct marimba_platform_data marimba_pdata = {
6899 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
6900 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
6901 .bahama_setup = msm_bahama_setup_power,
6902 .bahama_shutdown = msm_bahama_shutdown_power,
6903 .bahama_core_config = msm_bahama_core_config,
6904 .fm = &marimba_fm_pdata,
6905 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6906};
6907
6908
6909static struct i2c_board_info msm_marimba_board_info[] = {
6910 {
6911 I2C_BOARD_INFO("marimba", 0xc),
6912 .platform_data = &marimba_pdata,
6913 }
6914};
6915#endif /* CONFIG_MAIMBA_CORE */
6916
6917#ifdef CONFIG_I2C
6918#define I2C_SURF 1
6919#define I2C_FFA (1 << 1)
6920#define I2C_RUMI (1 << 2)
6921#define I2C_SIM (1 << 3)
6922#define I2C_FLUID (1 << 4)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04006923#define I2C_DRAGON (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006924
6925struct i2c_registry {
6926 u8 machs;
6927 int bus;
6928 struct i2c_board_info *info;
6929 int len;
6930};
6931
6932static struct i2c_registry msm8x60_i2c_devices[] __initdata = {
6933#ifdef CONFIG_PMIC8058
6934 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04006935 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006936 MSM_SSBI1_I2C_BUS_ID,
6937 pm8058_boardinfo,
6938 ARRAY_SIZE(pm8058_boardinfo),
6939 },
6940#endif
6941#ifdef CONFIG_PMIC8901
6942 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04006943 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006944 MSM_SSBI2_I2C_BUS_ID,
6945 pm8901_boardinfo,
6946 ARRAY_SIZE(pm8901_boardinfo),
6947 },
6948#endif
6949#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
6950 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04006951 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006952 MSM_GSBI8_QUP_I2C_BUS_ID,
6953 core_expander_i2c_info,
6954 ARRAY_SIZE(core_expander_i2c_info),
6955 },
6956 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04006957 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006958 MSM_GSBI8_QUP_I2C_BUS_ID,
6959 docking_expander_i2c_info,
6960 ARRAY_SIZE(docking_expander_i2c_info),
6961 },
6962 {
6963 I2C_SURF,
6964 MSM_GSBI8_QUP_I2C_BUS_ID,
6965 surf_expanders_i2c_info,
6966 ARRAY_SIZE(surf_expanders_i2c_info),
6967 },
6968 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04006969 I2C_SURF | I2C_FFA | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006970 MSM_GSBI3_QUP_I2C_BUS_ID,
6971 fha_expanders_i2c_info,
6972 ARRAY_SIZE(fha_expanders_i2c_info),
6973 },
6974 {
6975 I2C_FLUID,
6976 MSM_GSBI3_QUP_I2C_BUS_ID,
6977 fluid_expanders_i2c_info,
6978 ARRAY_SIZE(fluid_expanders_i2c_info),
6979 },
6980 {
6981 I2C_FLUID,
6982 MSM_GSBI8_QUP_I2C_BUS_ID,
6983 fluid_core_expander_i2c_info,
6984 ARRAY_SIZE(fluid_core_expander_i2c_info),
6985 },
6986#endif
6987#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
6988 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
6989 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04006990 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006991 MSM_GSBI3_QUP_I2C_BUS_ID,
6992 msm_i2c_gsbi3_tdisc_info,
6993 ARRAY_SIZE(msm_i2c_gsbi3_tdisc_info),
6994 },
6995#endif
6996 {
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04006997 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006998 MSM_GSBI3_QUP_I2C_BUS_ID,
6999 cy8ctmg200_board_info,
7000 ARRAY_SIZE(cy8ctmg200_board_info),
7001 },
7002#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
7003 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
7004 {
7005 I2C_FLUID,
7006 MSM_GSBI3_QUP_I2C_BUS_ID,
7007 cyttsp_fluid_info,
7008 ARRAY_SIZE(cyttsp_fluid_info),
7009 },
7010 {
7011 I2C_FFA | I2C_SURF,
7012 MSM_GSBI3_QUP_I2C_BUS_ID,
7013 cyttsp_ffa_info,
7014 ARRAY_SIZE(cyttsp_ffa_info),
7015 },
7016#endif
7017#ifdef CONFIG_MSM_CAMERA
Jilai Wang971f97f2011-07-13 14:25:25 -04007018 {
7019 I2C_SURF | I2C_FFA | I2C_FLUID ,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007020 MSM_GSBI4_QUP_I2C_BUS_ID,
7021 msm_camera_boardinfo,
7022 ARRAY_SIZE(msm_camera_boardinfo),
7023 },
Jilai Wang971f97f2011-07-13 14:25:25 -04007024 {
7025 I2C_DRAGON,
7026 MSM_GSBI4_QUP_I2C_BUS_ID,
7027 msm_camera_dragon_boardinfo,
7028 ARRAY_SIZE(msm_camera_dragon_boardinfo),
7029 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007030#endif
7031 {
7032 I2C_SURF | I2C_FFA | I2C_FLUID,
7033 MSM_GSBI7_QUP_I2C_BUS_ID,
7034 msm_i2c_gsbi7_timpani_info,
7035 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info),
7036 },
7037#if defined(CONFIG_MARIMBA_CORE)
7038 {
Zhang Chang Kene1fd3da2011-08-10 08:25:57 -04007039 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_DRAGON,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007040 MSM_GSBI7_QUP_I2C_BUS_ID,
7041 msm_marimba_board_info,
7042 ARRAY_SIZE(msm_marimba_board_info),
7043 },
7044#endif /* CONFIG_MARIMBA_CORE */
7045#ifdef CONFIG_ISL9519_CHARGER
7046 {
7047 I2C_SURF | I2C_FFA,
7048 MSM_GSBI8_QUP_I2C_BUS_ID,
7049 isl_charger_i2c_info,
7050 ARRAY_SIZE(isl_charger_i2c_info),
7051 },
7052#endif
7053#if defined(CONFIG_HAPTIC_ISA1200) || \
7054 defined(CONFIG_HAPTIC_ISA1200_MODULE)
7055 {
7056 I2C_FLUID,
7057 MSM_GSBI8_QUP_I2C_BUS_ID,
7058 msm_isa1200_board_info,
7059 ARRAY_SIZE(msm_isa1200_board_info),
7060 },
7061#endif
7062#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
7063 {
7064 I2C_FLUID,
7065 MSM_GSBI8_QUP_I2C_BUS_ID,
7066 smb137b_charger_i2c_info,
7067 ARRAY_SIZE(smb137b_charger_i2c_info),
7068 },
7069#endif
7070#if defined(CONFIG_BATTERY_BQ27520) || \
7071 defined(CONFIG_BATTERY_BQ27520_MODULE)
7072 {
7073 I2C_FLUID,
7074 MSM_GSBI8_QUP_I2C_BUS_ID,
7075 msm_bq27520_board_info,
7076 ARRAY_SIZE(msm_bq27520_board_info),
7077 },
7078#endif
7079};
7080#endif /* CONFIG_I2C */
7081
7082static void fixup_i2c_configs(void)
7083{
7084#ifdef CONFIG_I2C
7085#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
7086 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7087 sx150x_data[SX150X_CORE].irq_summary =
7088 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT2_N);
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007089 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
7090 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007091 sx150x_data[SX150X_CORE].irq_summary =
7092 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7093 else if (machine_is_msm8x60_fluid())
7094 sx150x_data[SX150X_CORE_FLUID].irq_summary =
7095 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
7096#endif
7097 /*
7098 * Set PMIC 8901 MPP0 active_high to 0 for surf and charm_surf. This
7099 * implies that the regulator connected to MPP0 is enabled when
7100 * MPP0 is low.
7101 */
7102 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7103 pm8901_vreg_init_pdata[PM8901_VREG_ID_MPP0].active_high = 0;
7104 else
7105 pm8901_vreg_init_pdata[PM8901_VREG_ID_MPP0].active_high = 1;
7106#endif
7107}
7108
7109static void register_i2c_devices(void)
7110{
7111#ifdef CONFIG_I2C
7112 u8 mach_mask = 0;
7113 int i;
7114
7115 /* Build the matching 'supported_machs' bitmask */
7116 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
7117 mach_mask = I2C_SURF;
7118 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
7119 mach_mask = I2C_FFA;
7120 else if (machine_is_msm8x60_rumi3())
7121 mach_mask = I2C_RUMI;
7122 else if (machine_is_msm8x60_sim())
7123 mach_mask = I2C_SIM;
7124 else if (machine_is_msm8x60_fluid())
7125 mach_mask = I2C_FLUID;
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007126 else if (machine_is_msm8x60_dragon())
7127 mach_mask = I2C_DRAGON;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007128 else
7129 pr_err("unmatched machine ID in register_i2c_devices\n");
7130
7131 /* Run the array and install devices as appropriate */
7132 for (i = 0; i < ARRAY_SIZE(msm8x60_i2c_devices); ++i) {
7133 if (msm8x60_i2c_devices[i].machs & mach_mask)
7134 i2c_register_board_info(msm8x60_i2c_devices[i].bus,
7135 msm8x60_i2c_devices[i].info,
7136 msm8x60_i2c_devices[i].len);
7137 }
7138#endif
7139}
7140
7141static void __init msm8x60_init_uart12dm(void)
7142{
7143#if !defined(CONFIG_USB_PEHCI_HCD) && !defined(CONFIG_USB_PEHCI_HCD_MODULE)
7144 /* 0x1D000000 now belongs to EBI2:CS3 i.e. USB ISP Controller */
7145 void *fpga_mem = ioremap_nocache(0x1D000000, SZ_4K);
7146
7147 if (!fpga_mem)
7148 pr_err("%s(): Error getting memory\n", __func__);
7149
7150 /* Advanced mode */
7151 writew(0xFFFF, fpga_mem + 0x15C);
7152 /* FPGA_UART_SEL */
7153 writew(0, fpga_mem + 0x172);
7154 /* FPGA_GPIO_CONFIG_117 */
7155 writew(1, fpga_mem + 0xEA);
7156 /* FPGA_GPIO_CONFIG_118 */
7157 writew(1, fpga_mem + 0xEC);
7158 mb();
7159 iounmap(fpga_mem);
7160#endif
7161}
7162
7163#define MSM_GSBI9_PHYS 0x19900000
7164#define GSBI_DUAL_MODE_CODE 0x60
7165
7166static void __init msm8x60_init_buses(void)
7167{
7168#ifdef CONFIG_I2C_QUP
7169 void *gsbi_mem = ioremap_nocache(0x19C00000, 4);
7170 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI12 */
7171 writel_relaxed(0x6 << 4, gsbi_mem);
7172 /* Ensure protocol code is written before proceeding further */
7173 mb();
7174 iounmap(gsbi_mem);
7175
7176 msm_gsbi3_qup_i2c_device.dev.platform_data = &msm_gsbi3_qup_i2c_pdata;
7177 msm_gsbi4_qup_i2c_device.dev.platform_data = &msm_gsbi4_qup_i2c_pdata;
7178 msm_gsbi7_qup_i2c_device.dev.platform_data = &msm_gsbi7_qup_i2c_pdata;
7179 msm_gsbi8_qup_i2c_device.dev.platform_data = &msm_gsbi8_qup_i2c_pdata;
7180
7181#ifdef CONFIG_MSM_GSBI9_UART
7182 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7183 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI9 */
7184 gsbi_mem = ioremap_nocache(MSM_GSBI9_PHYS, 4);
7185 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
7186 iounmap(gsbi_mem);
7187 msm_gsbi9_qup_i2c_pdata.use_gsbi_shared_mode = 1;
7188 }
7189#endif
7190 msm_gsbi9_qup_i2c_device.dev.platform_data = &msm_gsbi9_qup_i2c_pdata;
7191 msm_gsbi12_qup_i2c_device.dev.platform_data = &msm_gsbi12_qup_i2c_pdata;
7192#endif
7193#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7194 msm_gsbi1_qup_spi_device.dev.platform_data = &msm_gsbi1_qup_spi_pdata;
7195#endif
7196#ifdef CONFIG_I2C_SSBI
7197 msm_device_ssbi1.dev.platform_data = &msm_ssbi1_pdata;
7198 msm_device_ssbi2.dev.platform_data = &msm_ssbi2_pdata;
7199 msm_device_ssbi3.dev.platform_data = &msm_ssbi3_pdata;
7200#endif
7201
7202 if (machine_is_msm8x60_fluid()) {
7203#if (defined(CONFIG_USB_EHCI_MSM_72K) && \
7204 (defined(CONFIG_SMB137B_CHARGER) || \
7205 defined(CONFIG_SMB137B_CHARGER_MODULE)))
7206 msm_otg_pdata.vbus_power = msm_hsusb_smb137b_vbus_power;
7207#endif
7208#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7209 msm_gsbi10_qup_spi_device.dev.platform_data =
7210 &msm_gsbi10_qup_spi_pdata;
7211#endif
7212 }
7213
7214#if defined(CONFIG_USB_GADGET_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
7215 /*
7216 * We can not put USB regulators (8058_l6 and 8058_l7) in LPM
7217 * when we depend on USB PHY for VBUS/ID notifications. VBUS
7218 * and ID notifications are available only on V2 surf and FFA
7219 * with a hardware workaround.
7220 */
7221 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 &&
7222 (machine_is_msm8x60_surf() ||
7223 (machine_is_msm8x60_ffa() &&
7224 pmic_id_notif_supported)))
7225 msm_otg_pdata.phy_can_powercollapse = 1;
7226 msm_device_otg.dev.platform_data = &msm_otg_pdata;
7227#endif
7228
7229#ifdef CONFIG_USB_GADGET_MSM_72K
7230 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
7231#endif
7232
7233#ifdef CONFIG_SERIAL_MSM_HS
7234 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(54); /* GSBI6(2) */
7235 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
7236#endif
7237#ifdef CONFIG_MSM_GSBI9_UART
7238 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7239 msm_device_uart_gsbi9 = msm_add_gsbi9_uart();
7240 if (IS_ERR(msm_device_uart_gsbi9))
7241 pr_err("%s(): Failed to create uart gsbi9 device\n",
7242 __func__);
7243 }
7244#endif
7245
7246#ifdef CONFIG_MSM_BUS_SCALING
7247
7248 /* RPM calls are only enabled on V2 */
7249 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2) {
7250 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
7251 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
7252 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
7253 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
7254 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
7255 }
7256
7257 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
7258 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
7259 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
7260 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
7261 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
7262#endif
7263}
7264
7265static void __init msm8x60_map_io(void)
7266{
7267 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
7268 msm_map_msm8x60_io();
7269}
7270
7271/*
7272 * Most segments of the EBI2 bus are disabled by default.
7273 */
7274static void __init msm8x60_init_ebi2(void)
7275{
7276 uint32_t ebi2_cfg;
7277 void *ebi2_cfg_ptr;
7278
7279 ebi2_cfg_ptr = ioremap_nocache(0x1a100000, sizeof(uint32_t));
7280 if (ebi2_cfg_ptr != 0) {
7281 ebi2_cfg = readl_relaxed(ebi2_cfg_ptr);
7282
7283 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007284 machine_is_msm8x60_fluid() ||
7285 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007286 ebi2_cfg |= (1 << 4) | (1 << 5); /* CS2, CS3 */
7287 else if (machine_is_msm8x60_sim())
7288 ebi2_cfg |= (1 << 4); /* CS2 */
7289 else if (machine_is_msm8x60_rumi3())
7290 ebi2_cfg |= (1 << 5); /* CS3 */
7291
7292 writel_relaxed(ebi2_cfg, ebi2_cfg_ptr);
7293 iounmap(ebi2_cfg_ptr);
7294 }
7295
7296 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04007297 machine_is_msm8x60_fluid() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007298 ebi2_cfg_ptr = ioremap_nocache(0x1a110000, SZ_4K);
7299 if (ebi2_cfg_ptr != 0) {
7300 /* EBI2_XMEM_CFG:PWRSAVE_MODE off */
7301 writel_relaxed(0UL, ebi2_cfg_ptr);
7302
7303 /* CS2: Delay 9 cycles (140ns@64MHz) between SMSC
7304 * LAN9221 Ethernet controller reads and writes.
7305 * The lowest 4 bits are the read delay, the next
7306 * 4 are the write delay. */
7307 writel_relaxed(0x031F1C99, ebi2_cfg_ptr + 0x10);
7308#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
7309 /*
7310 * RECOVERY=5, HOLD_WR=1
7311 * INIT_LATENCY_WR=1, INIT_LATENCY_RD=1
7312 * WAIT_WR=1, WAIT_RD=2
7313 */
7314 writel_relaxed(0x51010112, ebi2_cfg_ptr + 0x14);
7315 /*
7316 * HOLD_RD=1
7317 * ADV_OE_RECOVERY=0, ADDR_HOLD_ENA=1
7318 */
7319 writel_relaxed(0x01000020, ebi2_cfg_ptr + 0x34);
7320#else
7321 /* EBI2 CS3 muxed address/data,
7322 * two cyc addr enable */
7323 writel_relaxed(0xA3030020, ebi2_cfg_ptr + 0x34);
7324
7325#endif
7326 iounmap(ebi2_cfg_ptr);
7327 }
7328 }
7329}
7330
7331static void __init msm8x60_configure_smc91x(void)
7332{
7333 if (machine_is_msm8x60_sim()) {
7334
7335 smc91x_resources[0].start = 0x1b800300;
7336 smc91x_resources[0].end = 0x1b8003ff;
7337
7338 smc91x_resources[1].start = (NR_MSM_IRQS + 40);
7339 smc91x_resources[1].end = (NR_MSM_IRQS + 40);
7340
7341 } else if (machine_is_msm8x60_rumi3()) {
7342
7343 smc91x_resources[0].start = 0x1d000300;
7344 smc91x_resources[0].end = 0x1d0003ff;
7345
7346 smc91x_resources[1].start = TLMM_MSM_DIR_CONN_IRQ_0;
7347 smc91x_resources[1].end = TLMM_MSM_DIR_CONN_IRQ_0;
7348 }
7349}
7350
7351static void __init msm8x60_init_tlmm(void)
7352{
7353 if (machine_is_msm8x60_rumi3())
7354 msm_gpio_install_direct_irq(0, 0, 1);
7355}
7356
7357#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
7358 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
7359 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
7360 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\
7361 || defined(CONFIG_MMC_MSM_SDC5_SUPPORT))
7362
7363/* 8x60 is having 5 SDCC controllers */
7364#define MAX_SDCC_CONTROLLER 5
7365
7366struct msm_sdcc_gpio {
7367 /* maximum 10 GPIOs per SDCC controller */
7368 s16 no;
7369 /* name of this GPIO */
7370 const char *name;
7371 bool always_on;
7372 bool is_enabled;
7373};
7374
7375#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7376static struct msm_sdcc_gpio sdc1_gpio_cfg[] = {
7377 {159, "sdc1_dat_0"},
7378 {160, "sdc1_dat_1"},
7379 {161, "sdc1_dat_2"},
7380 {162, "sdc1_dat_3"},
7381#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
7382 {163, "sdc1_dat_4"},
7383 {164, "sdc1_dat_5"},
7384 {165, "sdc1_dat_6"},
7385 {166, "sdc1_dat_7"},
7386#endif
7387 {167, "sdc1_clk"},
7388 {168, "sdc1_cmd"}
7389};
7390#endif
7391
7392#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7393static struct msm_sdcc_gpio sdc2_gpio_cfg[] = {
7394 {143, "sdc2_dat_0"},
7395 {144, "sdc2_dat_1", 1},
7396 {145, "sdc2_dat_2"},
7397 {146, "sdc2_dat_3"},
7398#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
7399 {147, "sdc2_dat_4"},
7400 {148, "sdc2_dat_5"},
7401 {149, "sdc2_dat_6"},
7402 {150, "sdc2_dat_7"},
7403#endif
7404 {151, "sdc2_cmd"},
7405 {152, "sdc2_clk", 1}
7406};
7407#endif
7408
7409#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7410static struct msm_sdcc_gpio sdc5_gpio_cfg[] = {
7411 {95, "sdc5_cmd"},
7412 {96, "sdc5_dat_3"},
7413 {97, "sdc5_clk", 1},
7414 {98, "sdc5_dat_2"},
7415 {99, "sdc5_dat_1", 1},
7416 {100, "sdc5_dat_0"}
7417};
7418#endif
7419
7420struct msm_sdcc_pad_pull_cfg {
7421 enum msm_tlmm_pull_tgt pull;
7422 u32 pull_val;
7423};
7424
7425struct msm_sdcc_pad_drv_cfg {
7426 enum msm_tlmm_hdrive_tgt drv;
7427 u32 drv_val;
7428};
7429
7430#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7431static struct msm_sdcc_pad_drv_cfg sdc3_pad_on_drv_cfg[] = {
7432 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
7433 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
7434 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
7435};
7436
7437static struct msm_sdcc_pad_pull_cfg sdc3_pad_on_pull_cfg[] = {
7438 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
7439 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
7440};
7441
7442static struct msm_sdcc_pad_drv_cfg sdc3_pad_off_drv_cfg[] = {
7443 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
7444 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
7445 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
7446};
7447
7448static struct msm_sdcc_pad_pull_cfg sdc3_pad_off_pull_cfg[] = {
7449 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
7450 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
7451};
7452#endif
7453
7454#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7455static struct msm_sdcc_pad_drv_cfg sdc4_pad_on_drv_cfg[] = {
7456 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_8MA},
7457 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_8MA},
7458 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_8MA}
7459};
7460
7461static struct msm_sdcc_pad_pull_cfg sdc4_pad_on_pull_cfg[] = {
7462 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_UP},
7463 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_UP}
7464};
7465
7466static struct msm_sdcc_pad_drv_cfg sdc4_pad_off_drv_cfg[] = {
7467 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_2MA},
7468 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_2MA},
7469 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_2MA}
7470};
7471
7472static struct msm_sdcc_pad_pull_cfg sdc4_pad_off_pull_cfg[] = {
7473 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_DOWN},
7474 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_DOWN}
7475};
7476#endif
7477
7478struct msm_sdcc_pin_cfg {
7479 /*
7480 * = 1 if controller pins are using gpios
7481 * = 0 if controller has dedicated MSM pins
7482 */
7483 u8 is_gpio;
7484 u8 cfg_sts;
7485 u8 gpio_data_size;
7486 struct msm_sdcc_gpio *gpio_data;
7487 struct msm_sdcc_pad_drv_cfg *pad_drv_on_data;
7488 struct msm_sdcc_pad_drv_cfg *pad_drv_off_data;
7489 struct msm_sdcc_pad_pull_cfg *pad_pull_on_data;
7490 struct msm_sdcc_pad_pull_cfg *pad_pull_off_data;
7491 u8 pad_drv_data_size;
7492 u8 pad_pull_data_size;
7493 u8 sdio_lpm_gpio_cfg;
7494};
7495
7496
7497static struct msm_sdcc_pin_cfg sdcc_pin_cfg_data[MAX_SDCC_CONTROLLER] = {
7498#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7499 [0] = {
7500 .is_gpio = 1,
7501 .gpio_data_size = ARRAY_SIZE(sdc1_gpio_cfg),
7502 .gpio_data = sdc1_gpio_cfg
7503 },
7504#endif
7505#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7506 [1] = {
7507 .is_gpio = 1,
7508 .gpio_data_size = ARRAY_SIZE(sdc2_gpio_cfg),
7509 .gpio_data = sdc2_gpio_cfg
7510 },
7511#endif
7512#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7513 [2] = {
7514 .is_gpio = 0,
7515 .pad_drv_on_data = sdc3_pad_on_drv_cfg,
7516 .pad_drv_off_data = sdc3_pad_off_drv_cfg,
7517 .pad_pull_on_data = sdc3_pad_on_pull_cfg,
7518 .pad_pull_off_data = sdc3_pad_off_pull_cfg,
7519 .pad_drv_data_size = ARRAY_SIZE(sdc3_pad_on_drv_cfg),
7520 .pad_pull_data_size = ARRAY_SIZE(sdc3_pad_on_pull_cfg)
7521 },
7522#endif
7523#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7524 [3] = {
7525 .is_gpio = 0,
7526 .pad_drv_on_data = sdc4_pad_on_drv_cfg,
7527 .pad_drv_off_data = sdc4_pad_off_drv_cfg,
7528 .pad_pull_on_data = sdc4_pad_on_pull_cfg,
7529 .pad_pull_off_data = sdc4_pad_off_pull_cfg,
7530 .pad_drv_data_size = ARRAY_SIZE(sdc4_pad_on_drv_cfg),
7531 .pad_pull_data_size = ARRAY_SIZE(sdc4_pad_on_pull_cfg)
7532 },
7533#endif
7534#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7535 [4] = {
7536 .is_gpio = 1,
7537 .gpio_data_size = ARRAY_SIZE(sdc5_gpio_cfg),
7538 .gpio_data = sdc5_gpio_cfg
7539 }
7540#endif
7541};
7542
7543static int msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
7544{
7545 int rc = 0;
7546 struct msm_sdcc_pin_cfg *curr;
7547 int n;
7548
7549 curr = &sdcc_pin_cfg_data[dev_id - 1];
7550 if (!curr->gpio_data)
7551 goto out;
7552
7553 for (n = 0; n < curr->gpio_data_size; n++) {
7554 if (enable) {
7555
7556 if (curr->gpio_data[n].always_on &&
7557 curr->gpio_data[n].is_enabled)
7558 continue;
7559 pr_debug("%s: enable: %s\n", __func__,
7560 curr->gpio_data[n].name);
7561 rc = gpio_request(curr->gpio_data[n].no,
7562 curr->gpio_data[n].name);
7563 if (rc) {
7564 pr_err("%s: gpio_request(%d, %s)"
7565 "failed", __func__,
7566 curr->gpio_data[n].no,
7567 curr->gpio_data[n].name);
7568 goto free_gpios;
7569 }
7570 /* set direction as output for all GPIOs */
7571 rc = gpio_direction_output(
7572 curr->gpio_data[n].no, 1);
7573 if (rc) {
7574 pr_err("%s: gpio_direction_output"
7575 "(%d, 1) failed\n", __func__,
7576 curr->gpio_data[n].no);
7577 goto free_gpios;
7578 }
7579 curr->gpio_data[n].is_enabled = 1;
7580 } else {
7581 /*
7582 * now free this GPIO which will put GPIO
7583 * in low power mode and will also put GPIO
7584 * in input mode
7585 */
7586 if (curr->gpio_data[n].always_on)
7587 continue;
7588 pr_debug("%s: disable: %s\n", __func__,
7589 curr->gpio_data[n].name);
7590 gpio_free(curr->gpio_data[n].no);
7591 curr->gpio_data[n].is_enabled = 0;
7592 }
7593 }
7594 curr->cfg_sts = enable;
7595 goto out;
7596
7597free_gpios:
7598 for (; n >= 0; n--)
7599 gpio_free(curr->gpio_data[n].no);
7600out:
7601 return rc;
7602}
7603
7604static int msm_sdcc_setup_pad(int dev_id, unsigned int enable)
7605{
7606 int rc = 0;
7607 struct msm_sdcc_pin_cfg *curr;
7608 int n;
7609
7610 curr = &sdcc_pin_cfg_data[dev_id - 1];
7611 if (!curr->pad_drv_on_data || !curr->pad_pull_on_data)
7612 goto out;
7613
7614 if (enable) {
7615 /*
7616 * set up the normal driver strength and
7617 * pull config for pads
7618 */
7619 for (n = 0; n < curr->pad_drv_data_size; n++) {
7620 if (curr->sdio_lpm_gpio_cfg) {
7621 if (curr->pad_drv_on_data[n].drv ==
7622 TLMM_HDRV_SDC4_DATA)
7623 continue;
7624 }
7625 msm_tlmm_set_hdrive(curr->pad_drv_on_data[n].drv,
7626 curr->pad_drv_on_data[n].drv_val);
7627 }
7628 for (n = 0; n < curr->pad_pull_data_size; n++) {
7629 if (curr->sdio_lpm_gpio_cfg) {
7630 if (curr->pad_pull_on_data[n].pull ==
7631 TLMM_PULL_SDC4_DATA)
7632 continue;
7633 }
7634 msm_tlmm_set_pull(curr->pad_pull_on_data[n].pull,
7635 curr->pad_pull_on_data[n].pull_val);
7636 }
7637 } else {
7638 /* set the low power config for pads */
7639 for (n = 0; n < curr->pad_drv_data_size; n++) {
7640 if (curr->sdio_lpm_gpio_cfg) {
7641 if (curr->pad_drv_off_data[n].drv ==
7642 TLMM_HDRV_SDC4_DATA)
7643 continue;
7644 }
7645 msm_tlmm_set_hdrive(
7646 curr->pad_drv_off_data[n].drv,
7647 curr->pad_drv_off_data[n].drv_val);
7648 }
7649 for (n = 0; n < curr->pad_pull_data_size; n++) {
7650 if (curr->sdio_lpm_gpio_cfg) {
7651 if (curr->pad_pull_off_data[n].pull ==
7652 TLMM_PULL_SDC4_DATA)
7653 continue;
7654 }
7655 msm_tlmm_set_pull(
7656 curr->pad_pull_off_data[n].pull,
7657 curr->pad_pull_off_data[n].pull_val);
7658 }
7659 }
7660 curr->cfg_sts = enable;
7661out:
7662 return rc;
7663}
7664
7665struct sdcc_reg {
7666 /* VDD/VCC/VCCQ regulator name on PMIC8058/PMIC8089*/
7667 const char *reg_name;
7668 /*
7669 * is set voltage supported for this regulator?
7670 * 0 = not supported, 1 = supported
7671 */
7672 unsigned char set_voltage_sup;
7673 /* voltage level to be set */
7674 unsigned int level;
7675 /* VDD/VCC/VCCQ voltage regulator handle */
7676 struct regulator *reg;
7677 /* is this regulator enabled? */
7678 bool enabled;
7679 /* is this regulator needs to be always on? */
7680 bool always_on;
7681 /* is operating power mode setting required for this regulator? */
7682 bool op_pwr_mode_sup;
7683 /* Load values for low power and high power mode */
7684 unsigned int lpm_uA;
7685 unsigned int hpm_uA;
7686};
7687/* all SDCC controllers requires VDD/VCC voltage */
7688static struct sdcc_reg sdcc_vdd_reg_data[MAX_SDCC_CONTROLLER];
7689/* only SDCC1 requires VCCQ voltage */
7690static struct sdcc_reg sdcc_vccq_reg_data[1];
7691/* all SDCC controllers may require voting for VDD PAD voltage */
7692static struct sdcc_reg sdcc_vddp_reg_data[MAX_SDCC_CONTROLLER];
7693
7694struct sdcc_reg_data {
7695 struct sdcc_reg *vdd_data; /* keeps VDD/VCC regulator info */
7696 struct sdcc_reg *vccq_data; /* keeps VCCQ regulator info */
7697 struct sdcc_reg *vddp_data; /* keeps VDD Pad regulator info */
7698 unsigned char sts; /* regulator enable/disable status */
7699};
7700/* msm8x60 have 5 SDCC controllers */
7701static struct sdcc_reg_data sdcc_vreg_data[MAX_SDCC_CONTROLLER];
7702
7703static int msm_sdcc_vreg_init_reg(struct sdcc_reg *vreg)
7704{
7705 int rc = 0;
7706
7707 /* Get the regulator handle */
7708 vreg->reg = regulator_get(NULL, vreg->reg_name);
7709 if (IS_ERR(vreg->reg)) {
7710 rc = PTR_ERR(vreg->reg);
7711 pr_err("%s: regulator_get(%s) failed. rc=%d\n",
7712 __func__, vreg->reg_name, rc);
7713 goto out;
7714 }
7715
7716 /* Set the voltage level if required */
7717 if (vreg->set_voltage_sup) {
7718 rc = regulator_set_voltage(vreg->reg, vreg->level,
7719 vreg->level);
7720 if (rc) {
7721 pr_err("%s: regulator_set_voltage(%s) failed rc=%d\n",
7722 __func__, vreg->reg_name, rc);
7723 goto vreg_put;
7724 }
7725 }
7726 goto out;
7727
7728vreg_put:
7729 regulator_put(vreg->reg);
7730out:
7731 return rc;
7732}
7733
7734static inline void msm_sdcc_vreg_deinit_reg(struct sdcc_reg *vreg)
7735{
7736 regulator_put(vreg->reg);
7737}
7738
7739/* this init function should be called only once for each SDCC */
7740static int msm_sdcc_vreg_init(int dev_id, unsigned char init)
7741{
7742 int rc = 0;
7743 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
7744 struct sdcc_reg_data *curr;
7745
7746 curr = &sdcc_vreg_data[dev_id - 1];
7747 curr_vdd_reg = curr->vdd_data;
7748 curr_vccq_reg = curr->vccq_data;
7749 curr_vddp_reg = curr->vddp_data;
7750
7751 if (init) {
7752 /*
7753 * get the regulator handle from voltage regulator framework
7754 * and then try to set the voltage level for the regulator
7755 */
7756 if (curr_vdd_reg) {
7757 rc = msm_sdcc_vreg_init_reg(curr_vdd_reg);
7758 if (rc)
7759 goto out;
7760 }
7761 if (curr_vccq_reg) {
7762 rc = msm_sdcc_vreg_init_reg(curr_vccq_reg);
7763 if (rc)
7764 goto vdd_reg_deinit;
7765 }
7766 if (curr_vddp_reg) {
7767 rc = msm_sdcc_vreg_init_reg(curr_vddp_reg);
7768 if (rc)
7769 goto vccq_reg_deinit;
7770 }
7771 goto out;
7772 } else
7773 /* deregister with all regulators from regulator framework */
7774 goto vddp_reg_deinit;
7775
7776vddp_reg_deinit:
7777 if (curr_vddp_reg)
7778 msm_sdcc_vreg_deinit_reg(curr_vddp_reg);
7779vccq_reg_deinit:
7780 if (curr_vccq_reg)
7781 msm_sdcc_vreg_deinit_reg(curr_vccq_reg);
7782vdd_reg_deinit:
7783 if (curr_vdd_reg)
7784 msm_sdcc_vreg_deinit_reg(curr_vdd_reg);
7785out:
7786 return rc;
7787}
7788
7789static int msm_sdcc_vreg_enable(struct sdcc_reg *vreg)
7790{
7791 int rc;
7792
7793 if (!vreg->enabled) {
7794 rc = regulator_enable(vreg->reg);
7795 if (rc) {
7796 pr_err("%s: regulator_enable(%s) failed. rc=%d\n",
7797 __func__, vreg->reg_name, rc);
7798 goto out;
7799 }
7800 vreg->enabled = 1;
7801 }
7802
7803 /* Put always_on regulator in HPM (high power mode) */
7804 if (vreg->always_on && vreg->op_pwr_mode_sup) {
7805 rc = regulator_set_optimum_mode(vreg->reg, vreg->hpm_uA);
7806 if (rc < 0) {
7807 pr_err("%s: reg=%s: HPM setting failed"
7808 " hpm_uA=%d, rc=%d\n",
7809 __func__, vreg->reg_name,
7810 vreg->hpm_uA, rc);
7811 goto vreg_disable;
7812 }
7813 rc = 0;
7814 }
7815 goto out;
7816
7817vreg_disable:
7818 regulator_disable(vreg->reg);
7819 vreg->enabled = 0;
7820out:
7821 return rc;
7822}
7823
7824static int msm_sdcc_vreg_disable(struct sdcc_reg *vreg)
7825{
7826 int rc;
7827
7828 /* Never disable always_on regulator */
7829 if (!vreg->always_on) {
7830 rc = regulator_disable(vreg->reg);
7831 if (rc) {
7832 pr_err("%s: regulator_disable(%s) failed. rc=%d\n",
7833 __func__, vreg->reg_name, rc);
7834 goto out;
7835 }
7836 vreg->enabled = 0;
7837 }
7838
7839 /* Put always_on regulator in LPM (low power mode) */
7840 if (vreg->always_on && vreg->op_pwr_mode_sup) {
7841 rc = regulator_set_optimum_mode(vreg->reg, vreg->lpm_uA);
7842 if (rc < 0) {
7843 pr_err("%s: reg=%s: LPM setting failed"
7844 " lpm_uA=%d, rc=%d\n",
7845 __func__,
7846 vreg->reg_name,
7847 vreg->lpm_uA, rc);
7848 goto out;
7849 }
7850 rc = 0;
7851 }
7852
7853out:
7854 return rc;
7855}
7856
7857static int msm_sdcc_setup_vreg(int dev_id, unsigned char enable)
7858{
7859 int rc = 0;
7860 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
7861 struct sdcc_reg_data *curr;
7862
7863 curr = &sdcc_vreg_data[dev_id - 1];
7864 curr_vdd_reg = curr->vdd_data;
7865 curr_vccq_reg = curr->vccq_data;
7866 curr_vddp_reg = curr->vddp_data;
7867
7868 /* check if regulators are initialized or not? */
7869 if ((curr_vdd_reg && !curr_vdd_reg->reg) ||
7870 (curr_vccq_reg && !curr_vccq_reg->reg) ||
7871 (curr_vddp_reg && !curr_vddp_reg->reg)) {
7872 /* initialize voltage regulators required for this SDCC */
7873 rc = msm_sdcc_vreg_init(dev_id, 1);
7874 if (rc) {
7875 pr_err("%s: regulator init failed = %d\n",
7876 __func__, rc);
7877 goto out;
7878 }
7879 }
7880
7881 if (curr->sts == enable)
7882 goto out;
7883
7884 if (curr_vdd_reg) {
7885 if (enable)
7886 rc = msm_sdcc_vreg_enable(curr_vdd_reg);
7887 else
7888 rc = msm_sdcc_vreg_disable(curr_vdd_reg);
7889 if (rc)
7890 goto out;
7891 }
7892
7893 if (curr_vccq_reg) {
7894 if (enable)
7895 rc = msm_sdcc_vreg_enable(curr_vccq_reg);
7896 else
7897 rc = msm_sdcc_vreg_disable(curr_vccq_reg);
7898 if (rc)
7899 goto out;
7900 }
7901
7902 if (curr_vddp_reg) {
7903 if (enable)
7904 rc = msm_sdcc_vreg_enable(curr_vddp_reg);
7905 else
7906 rc = msm_sdcc_vreg_disable(curr_vddp_reg);
7907 if (rc)
7908 goto out;
7909 }
7910 curr->sts = enable;
7911
7912out:
7913 return rc;
7914}
7915
7916static u32 msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
7917{
7918 u32 rc_pin_cfg = 0;
7919 u32 rc_vreg_cfg = 0;
7920 u32 rc = 0;
7921 struct platform_device *pdev;
7922 struct msm_sdcc_pin_cfg *curr_pin_cfg;
7923
7924 pdev = container_of(dv, struct platform_device, dev);
7925
7926 /* setup gpio/pad */
7927 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
7928 if (curr_pin_cfg->cfg_sts == !!vdd)
7929 goto setup_vreg;
7930
7931 if (curr_pin_cfg->is_gpio)
7932 rc_pin_cfg = msm_sdcc_setup_gpio(pdev->id, !!vdd);
7933 else
7934 rc_pin_cfg = msm_sdcc_setup_pad(pdev->id, !!vdd);
7935
7936setup_vreg:
7937 /* setup voltage regulators */
7938 rc_vreg_cfg = msm_sdcc_setup_vreg(pdev->id, !!vdd);
7939
7940 if (rc_pin_cfg || rc_vreg_cfg)
7941 rc = rc_pin_cfg ? rc_pin_cfg : rc_vreg_cfg;
7942
7943 return rc;
7944}
7945
7946static void msm_sdcc_sdio_lpm_gpio(struct device *dv, unsigned int active)
7947{
7948 struct msm_sdcc_pin_cfg *curr_pin_cfg;
7949 struct platform_device *pdev;
7950
7951 pdev = container_of(dv, struct platform_device, dev);
7952 /* setup gpio/pad */
7953 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
7954
7955 if (curr_pin_cfg->cfg_sts == active)
7956 return;
7957
7958 curr_pin_cfg->sdio_lpm_gpio_cfg = 1;
7959 if (curr_pin_cfg->is_gpio)
7960 msm_sdcc_setup_gpio(pdev->id, active);
7961 else
7962 msm_sdcc_setup_pad(pdev->id, active);
7963 curr_pin_cfg->sdio_lpm_gpio_cfg = 0;
7964}
7965
7966static int msm_sdc3_get_wpswitch(struct device *dev)
7967{
7968 struct platform_device *pdev;
7969 int status;
7970 pdev = container_of(dev, struct platform_device, dev);
7971
7972 status = gpio_request(GPIO_SDC_WP, "SD_WP_Switch");
7973 if (status) {
7974 pr_err("%s:Failed to request GPIO %d\n",
7975 __func__, GPIO_SDC_WP);
7976 } else {
7977 status = gpio_direction_input(GPIO_SDC_WP);
7978 if (!status) {
7979 status = gpio_get_value_cansleep(GPIO_SDC_WP);
7980 pr_info("%s: WP Status for Slot %d = %d\n",
7981 __func__, pdev->id, status);
7982 }
7983 gpio_free(GPIO_SDC_WP);
7984 }
7985 return status;
7986}
7987
7988#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7989int sdc5_register_status_notify(void (*callback)(int, void *),
7990 void *dev_id)
7991{
7992 sdc5_status_notify_cb = callback;
7993 sdc5_status_notify_cb_devid = dev_id;
7994 return 0;
7995}
7996#endif
7997
7998#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7999int sdc2_register_status_notify(void (*callback)(int, void *),
8000 void *dev_id)
8001{
8002 sdc2_status_notify_cb = callback;
8003 sdc2_status_notify_cb_devid = dev_id;
8004 return 0;
8005}
8006#endif
8007
8008/* Interrupt handler for SDC2 and SDC5 detection
8009 * This function uses dual-edge interrputs settings in order
8010 * to get SDIO detection when the GPIO is rising and SDIO removal
8011 * when the GPIO is falling */
8012static irqreturn_t msm8x60_multi_sdio_slot_status_irq(int irq, void *dev_id)
8013{
8014 int status;
8015
8016 if (!machine_is_msm8x60_fusion() &&
8017 !machine_is_msm8x60_fusn_ffa())
8018 return IRQ_NONE;
8019
8020 status = gpio_get_value(MDM2AP_SYNC);
8021 pr_info("%s: MDM2AP_SYNC Status = %d\n",
8022 __func__, status);
8023
8024#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8025 if (sdc2_status_notify_cb) {
8026 pr_info("%s: calling sdc2_status_notify_cb\n", __func__);
8027 sdc2_status_notify_cb(status,
8028 sdc2_status_notify_cb_devid);
8029 }
8030#endif
8031
8032#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8033 if (sdc5_status_notify_cb) {
8034 pr_info("%s: calling sdc5_status_notify_cb\n", __func__);
8035 sdc5_status_notify_cb(status,
8036 sdc5_status_notify_cb_devid);
8037 }
8038#endif
8039 return IRQ_HANDLED;
8040}
8041
8042static int msm8x60_multi_sdio_init(void)
8043{
8044 int ret, irq_num;
8045
8046 if (!machine_is_msm8x60_fusion() &&
8047 !machine_is_msm8x60_fusn_ffa())
8048 return 0;
8049
8050 ret = msm_gpiomux_get(MDM2AP_SYNC);
8051 if (ret) {
8052 pr_err("%s:Failed to request GPIO %d, ret=%d\n",
8053 __func__, MDM2AP_SYNC, ret);
8054 return ret;
8055 }
8056
8057 irq_num = gpio_to_irq(MDM2AP_SYNC);
8058
8059 ret = request_irq(irq_num,
8060 msm8x60_multi_sdio_slot_status_irq,
8061 IRQ_TYPE_EDGE_BOTH,
8062 "sdio_multidetection", NULL);
8063
8064 if (ret) {
8065 pr_err("%s:Failed to request irq, ret=%d\n",
8066 __func__, ret);
8067 return ret;
8068 }
8069
8070 return ret;
8071}
8072
8073#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8074#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8075static unsigned int msm8x60_sdcc_slot_status(struct device *dev)
8076{
8077 int status;
8078
8079 status = gpio_request(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)
8080 , "SD_HW_Detect");
8081 if (status) {
8082 pr_err("%s:Failed to request GPIO %d\n", __func__,
8083 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8084 } else {
8085 status = gpio_direction_input(
8086 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8087 if (!status)
8088 status = !(gpio_get_value_cansleep(
8089 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)));
8090 gpio_free(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
8091 }
8092 return (unsigned int) status;
8093}
8094#endif
8095#endif
8096
8097#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8098static int msm_sdcc_cfg_mpm_sdiowakeup(struct device *dev, unsigned mode)
8099{
8100 struct platform_device *pdev;
8101 enum msm_mpm_pin pin;
8102 int ret = 0;
8103
8104 pdev = container_of(dev, struct platform_device, dev);
8105
8106 /* Only SDCC4 slot connected to WLAN chip has wakeup capability */
8107 if (pdev->id == 4)
8108 pin = MSM_MPM_PIN_SDC4_DAT1;
8109 else
8110 return -EINVAL;
8111
8112 switch (mode) {
8113 case SDC_DAT1_DISABLE:
8114 ret = msm_mpm_enable_pin(pin, 0);
8115 break;
8116 case SDC_DAT1_ENABLE:
8117 ret = msm_mpm_set_pin_type(pin, IRQ_TYPE_LEVEL_LOW);
8118 ret = msm_mpm_enable_pin(pin, 1);
8119 break;
8120 case SDC_DAT1_ENWAKE:
8121 ret = msm_mpm_set_pin_wake(pin, 1);
8122 break;
8123 case SDC_DAT1_DISWAKE:
8124 ret = msm_mpm_set_pin_wake(pin, 0);
8125 break;
8126 default:
8127 ret = -EINVAL;
8128 break;
8129 }
8130 return ret;
8131}
8132#endif
8133#endif
8134
8135#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8136static struct mmc_platform_data msm8x60_sdc1_data = {
8137 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8138 .translate_vdd = msm_sdcc_setup_power,
8139#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
8140 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8141#else
8142 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8143#endif
8144 .msmsdcc_fmin = 400000,
8145 .msmsdcc_fmid = 24000000,
8146 .msmsdcc_fmax = 48000000,
8147 .nonremovable = 1,
8148 .pclk_src_dfab = 1,
8149#ifdef CONFIG_MMC_MSM_SDC1_DUMMY52_REQUIRED
8150 .dummy52_required = 1,
8151#endif
8152};
8153#endif
8154
8155#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8156static struct mmc_platform_data msm8x60_sdc2_data = {
8157 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8158 .translate_vdd = msm_sdcc_setup_power,
8159 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8160 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8161 .msmsdcc_fmin = 400000,
8162 .msmsdcc_fmid = 24000000,
8163 .msmsdcc_fmax = 48000000,
8164 .nonremovable = 0,
8165 .pclk_src_dfab = 1,
8166 .register_status_notify = sdc2_register_status_notify,
8167#ifdef CONFIG_MMC_MSM_SDC2_DUMMY52_REQUIRED
8168 .dummy52_required = 1,
8169#endif
8170#ifdef CONFIG_MSM_SDIO_AL
8171 .is_sdio_al_client = 1,
8172#endif
8173};
8174#endif
8175
8176#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8177static struct mmc_platform_data msm8x60_sdc3_data = {
8178 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8179 .translate_vdd = msm_sdcc_setup_power,
8180 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8181 .wpswitch = msm_sdc3_get_wpswitch,
8182#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8183 .status = msm8x60_sdcc_slot_status,
8184 .status_irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
8185 PMIC_GPIO_SDC3_DET - 1),
8186 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
8187#endif
8188 .msmsdcc_fmin = 400000,
8189 .msmsdcc_fmid = 24000000,
8190 .msmsdcc_fmax = 48000000,
8191 .nonremovable = 0,
8192 .pclk_src_dfab = 1,
8193#ifdef CONFIG_MMC_MSM_SDC3_DUMMY52_REQUIRED
8194 .dummy52_required = 1,
8195#endif
8196};
8197#endif
8198
8199#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8200static struct mmc_platform_data msm8x60_sdc4_data = {
8201 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8202 .translate_vdd = msm_sdcc_setup_power,
8203 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8204 .msmsdcc_fmin = 400000,
8205 .msmsdcc_fmid = 24000000,
8206 .msmsdcc_fmax = 48000000,
8207 .nonremovable = 0,
8208 .pclk_src_dfab = 1,
8209 .cfg_mpm_sdiowakeup = msm_sdcc_cfg_mpm_sdiowakeup,
8210#ifdef CONFIG_MMC_MSM_SDC4_DUMMY52_REQUIRED
8211 .dummy52_required = 1,
8212#endif
8213};
8214#endif
8215
8216#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8217static struct mmc_platform_data msm8x60_sdc5_data = {
8218 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8219 .translate_vdd = msm_sdcc_setup_power,
8220 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8221 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8222 .msmsdcc_fmin = 400000,
8223 .msmsdcc_fmid = 24000000,
8224 .msmsdcc_fmax = 48000000,
8225 .nonremovable = 0,
8226 .pclk_src_dfab = 1,
8227 .register_status_notify = sdc5_register_status_notify,
8228#ifdef CONFIG_MMC_MSM_SDC5_DUMMY52_REQUIRED
8229 .dummy52_required = 1,
8230#endif
8231#ifdef CONFIG_MSM_SDIO_AL
8232 .is_sdio_al_client = 1,
8233#endif
8234};
8235#endif
8236
8237static void __init msm8x60_init_mmc(void)
8238{
8239#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8240 /* SDCC1 : eMMC card connected */
8241 sdcc_vreg_data[0].vdd_data = &sdcc_vdd_reg_data[0];
8242 sdcc_vreg_data[0].vdd_data->reg_name = "8901_l5";
8243 sdcc_vreg_data[0].vdd_data->set_voltage_sup = 1;
8244 sdcc_vreg_data[0].vdd_data->level = 2850000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008245
8246 sdcc_vreg_data[0].vccq_data = &sdcc_vccq_reg_data[0];
8247 sdcc_vreg_data[0].vccq_data->reg_name = "8901_lvs0";
8248 sdcc_vreg_data[0].vccq_data->set_voltage_sup = 0;
8249 sdcc_vreg_data[0].vccq_data->always_on = 1;
8250
8251 msm_add_sdcc(1, &msm8x60_sdc1_data);
8252#endif
8253#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8254 /*
8255 * MDM SDIO client is connected to SDC2 on charm SURF/FFA
8256 * and no card is connected on 8660 SURF/FFA/FLUID.
8257 */
8258 sdcc_vreg_data[1].vdd_data = &sdcc_vdd_reg_data[1];
8259 sdcc_vreg_data[1].vdd_data->reg_name = "8058_s3";
8260 sdcc_vreg_data[1].vdd_data->set_voltage_sup = 1;
8261 sdcc_vreg_data[1].vdd_data->level = 1800000;
8262
8263 sdcc_vreg_data[1].vccq_data = NULL;
8264
8265 if (machine_is_msm8x60_fusion())
8266 msm8x60_sdc2_data.msmsdcc_fmax = 24000000;
8267 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8268#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
8269 msm8x60_sdc2_data.sdiowakeup_irq = gpio_to_irq(144);
8270 msm_sdcc_setup_gpio(2, 1);
8271#endif
8272 msm_add_sdcc(2, &msm8x60_sdc2_data);
8273 }
8274#endif
8275#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8276 /* SDCC3 : External card slot connected */
8277 sdcc_vreg_data[2].vdd_data = &sdcc_vdd_reg_data[2];
8278 sdcc_vreg_data[2].vdd_data->reg_name = "8058_l14";
8279 sdcc_vreg_data[2].vdd_data->set_voltage_sup = 1;
8280 sdcc_vreg_data[2].vdd_data->level = 2850000;
8281 sdcc_vreg_data[2].vdd_data->always_on = 1;
8282 sdcc_vreg_data[2].vdd_data->op_pwr_mode_sup = 1;
8283 sdcc_vreg_data[2].vdd_data->lpm_uA = 9000;
8284 sdcc_vreg_data[2].vdd_data->hpm_uA = 200000;
8285
8286 sdcc_vreg_data[2].vccq_data = NULL;
8287
8288 sdcc_vreg_data[2].vddp_data = &sdcc_vddp_reg_data[2];
8289 sdcc_vreg_data[2].vddp_data->reg_name = "8058_l5";
8290 sdcc_vreg_data[2].vddp_data->set_voltage_sup = 1;
8291 sdcc_vreg_data[2].vddp_data->level = 2850000;
8292 sdcc_vreg_data[2].vddp_data->always_on = 1;
8293 sdcc_vreg_data[2].vddp_data->op_pwr_mode_sup = 1;
8294 /* Sleep current required is ~300 uA. But min. RPM
8295 * vote can be in terms of mA (min. 1 mA).
8296 * So let's vote for 2 mA during sleep.
8297 */
8298 sdcc_vreg_data[2].vddp_data->lpm_uA = 2000;
8299 /* Max. Active current required is 16 mA */
8300 sdcc_vreg_data[2].vddp_data->hpm_uA = 16000;
8301
8302 if (machine_is_msm8x60_fluid())
8303 msm8x60_sdc3_data.wpswitch = NULL;
8304 msm_add_sdcc(3, &msm8x60_sdc3_data);
8305#endif
8306#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8307 /* SDCC4 : WLAN WCN1314 chip is connected */
8308 sdcc_vreg_data[3].vdd_data = &sdcc_vdd_reg_data[3];
8309 sdcc_vreg_data[3].vdd_data->reg_name = "8058_s3";
8310 sdcc_vreg_data[3].vdd_data->set_voltage_sup = 1;
8311 sdcc_vreg_data[3].vdd_data->level = 1800000;
8312
8313 sdcc_vreg_data[3].vccq_data = NULL;
8314
8315 msm_add_sdcc(4, &msm8x60_sdc4_data);
8316#endif
8317#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8318 /*
8319 * MDM SDIO client is connected to SDC5 on charm SURF/FFA
8320 * and no card is connected on 8660 SURF/FFA/FLUID.
8321 */
8322 sdcc_vreg_data[4].vdd_data = &sdcc_vdd_reg_data[4];
8323 sdcc_vreg_data[4].vdd_data->reg_name = "8058_s3";
8324 sdcc_vreg_data[4].vdd_data->set_voltage_sup = 1;
8325 sdcc_vreg_data[4].vdd_data->level = 1800000;
8326
8327 sdcc_vreg_data[4].vccq_data = NULL;
8328
8329 if (machine_is_msm8x60_fusion())
8330 msm8x60_sdc5_data.msmsdcc_fmax = 24000000;
8331 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8332#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
8333 msm8x60_sdc5_data.sdiowakeup_irq = gpio_to_irq(99);
8334 msm_sdcc_setup_gpio(5, 1);
8335#endif
8336 msm_add_sdcc(5, &msm8x60_sdc5_data);
8337 }
8338#endif
8339}
8340
8341#if !defined(CONFIG_GPIO_SX150X) && !defined(CONFIG_GPIO_SX150X_MODULE)
8342static inline void display_common_power(int on) {}
8343#else
8344
8345#define _GET_REGULATOR(var, name) do { \
8346 if (var == NULL) { \
8347 var = regulator_get(NULL, name); \
8348 if (IS_ERR(var)) { \
8349 pr_err("'%s' regulator not found, rc=%ld\n", \
8350 name, PTR_ERR(var)); \
8351 var = NULL; \
8352 } \
8353 } \
8354} while (0)
8355
8356static int dsub_regulator(int on)
8357{
8358 static struct regulator *dsub_reg;
8359 static struct regulator *mpp0_reg;
8360 static int dsub_reg_enabled;
8361 int rc = 0;
8362
8363 _GET_REGULATOR(dsub_reg, "8901_l3");
8364 if (IS_ERR(dsub_reg)) {
8365 printk(KERN_ERR "%s: failed to get reg 8901_l3 err=%ld",
8366 __func__, PTR_ERR(dsub_reg));
8367 return PTR_ERR(dsub_reg);
8368 }
8369
8370 _GET_REGULATOR(mpp0_reg, "8901_mpp0");
8371 if (IS_ERR(mpp0_reg)) {
8372 printk(KERN_ERR "%s: failed to get reg 8901_mpp0 err=%ld",
8373 __func__, PTR_ERR(mpp0_reg));
8374 return PTR_ERR(mpp0_reg);
8375 }
8376
8377 if (on && !dsub_reg_enabled) {
8378 rc = regulator_set_voltage(dsub_reg, 3300000, 3300000);
8379 if (rc) {
8380 printk(KERN_ERR "%s: failed to set reg 8901_l3 voltage"
8381 " err=%d", __func__, rc);
8382 goto dsub_regulator_err;
8383 }
8384 rc = regulator_enable(dsub_reg);
8385 if (rc) {
8386 printk(KERN_ERR "%s: failed to enable reg 8901_l3"
8387 " err=%d", __func__, rc);
8388 goto dsub_regulator_err;
8389 }
8390 rc = regulator_enable(mpp0_reg);
8391 if (rc) {
8392 printk(KERN_ERR "%s: failed to enable reg 8901_mpp0"
8393 " err=%d", __func__, rc);
8394 goto dsub_regulator_err;
8395 }
8396 dsub_reg_enabled = 1;
8397 } else if (!on && dsub_reg_enabled) {
8398 rc = regulator_disable(dsub_reg);
8399 if (rc)
8400 printk(KERN_WARNING "%s: failed to disable reg 8901_l3"
8401 " err=%d", __func__, rc);
8402 rc = regulator_disable(mpp0_reg);
8403 if (rc)
8404 printk(KERN_WARNING "%s: failed to disable reg "
8405 "8901_mpp0 err=%d", __func__, rc);
8406 dsub_reg_enabled = 0;
8407 }
8408
8409 return rc;
8410
8411dsub_regulator_err:
8412 regulator_put(mpp0_reg);
8413 regulator_put(dsub_reg);
8414 return rc;
8415}
8416
8417static int display_power_on;
8418static void setup_display_power(void)
8419{
8420 if (display_power_on)
8421 if (lcdc_vga_enabled) {
8422 dsub_regulator(1);
8423 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8424 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8425 if (machine_is_msm8x60_ffa() ||
8426 machine_is_msm8x60_fusn_ffa())
8427 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 1);
8428 } else {
8429 dsub_regulator(0);
8430 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 1);
8431 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 1);
8432 if (machine_is_msm8x60_ffa() ||
8433 machine_is_msm8x60_fusn_ffa())
8434 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8435 }
8436 else {
8437 dsub_regulator(0);
8438 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
8439 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8440 /* BACKLIGHT */
8441 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8442 /* LVDS */
8443 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8444 }
8445}
8446
8447#define _GET_REGULATOR(var, name) do { \
8448 if (var == NULL) { \
8449 var = regulator_get(NULL, name); \
8450 if (IS_ERR(var)) { \
8451 pr_err("'%s' regulator not found, rc=%ld\n", \
8452 name, PTR_ERR(var)); \
8453 var = NULL; \
8454 } \
8455 } \
8456} while (0)
8457
8458#define GPIO_RESX_N (GPIO_EXPANDER_GPIO_BASE + 2)
8459
8460static void display_common_power(int on)
8461{
8462 int rc;
8463 static struct regulator *display_reg;
8464
8465 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
8466 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8467 if (on) {
8468 /* LVDS */
8469 _GET_REGULATOR(display_reg, "8901_l2");
8470 if (!display_reg)
8471 return;
8472 rc = regulator_set_voltage(display_reg,
8473 3300000, 3300000);
8474 if (rc)
8475 goto out;
8476 rc = regulator_enable(display_reg);
8477 if (rc)
8478 goto out;
8479 rc = gpio_request(GPIO_LVDS_SHUTDOWN_N,
8480 "LVDS_STDN_OUT_N");
8481 if (rc) {
8482 printk(KERN_ERR "%s: LVDS gpio %d request"
8483 "failed\n", __func__,
8484 GPIO_LVDS_SHUTDOWN_N);
8485 goto out2;
8486 }
8487
8488 /* BACKLIGHT */
8489 rc = gpio_request(GPIO_BACKLIGHT_EN, "BACKLIGHT_EN");
8490 if (rc) {
8491 printk(KERN_ERR "%s: BACKLIGHT gpio %d request"
8492 "failed\n", __func__,
8493 GPIO_BACKLIGHT_EN);
8494 goto out3;
8495 }
8496
8497 if (machine_is_msm8x60_ffa() ||
8498 machine_is_msm8x60_fusn_ffa()) {
8499 rc = gpio_request(GPIO_DONGLE_PWR_EN,
8500 "DONGLE_PWR_EN");
8501 if (rc) {
8502 printk(KERN_ERR "%s: DONGLE_PWR_EN gpio"
8503 " %d request failed\n", __func__,
8504 GPIO_DONGLE_PWR_EN);
8505 goto out4;
8506 }
8507 }
8508
8509 gpio_direction_output(GPIO_LVDS_SHUTDOWN_N, 0);
8510 gpio_direction_output(GPIO_BACKLIGHT_EN, 0);
8511 if (machine_is_msm8x60_ffa() ||
8512 machine_is_msm8x60_fusn_ffa())
8513 gpio_direction_output(GPIO_DONGLE_PWR_EN, 0);
8514 mdelay(20);
8515 display_power_on = 1;
8516 setup_display_power();
8517 } else {
8518 if (display_power_on) {
8519 display_power_on = 0;
8520 setup_display_power();
8521 mdelay(20);
8522 if (machine_is_msm8x60_ffa() ||
8523 machine_is_msm8x60_fusn_ffa())
8524 gpio_free(GPIO_DONGLE_PWR_EN);
8525 goto out4;
8526 }
8527 }
8528 }
8529#if defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
8530 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA)
8531 else if (machine_is_msm8x60_fluid()) {
8532 static struct regulator *fluid_reg;
8533 static struct regulator *fluid_reg2;
8534
8535 if (on) {
8536 _GET_REGULATOR(fluid_reg, "8901_l2");
8537 if (!fluid_reg)
8538 return;
8539 _GET_REGULATOR(fluid_reg2, "8058_s3");
8540 if (!fluid_reg2) {
8541 regulator_put(fluid_reg);
8542 return;
8543 }
8544 rc = gpio_request(GPIO_RESX_N, "RESX_N");
8545 if (rc) {
8546 regulator_put(fluid_reg2);
8547 regulator_put(fluid_reg);
8548 return;
8549 }
8550 regulator_set_voltage(fluid_reg, 2850000, 2850000);
8551 regulator_set_voltage(fluid_reg2, 1800000, 1800000);
8552 regulator_enable(fluid_reg);
8553 regulator_enable(fluid_reg2);
8554 msleep(20);
8555 gpio_direction_output(GPIO_RESX_N, 0);
8556 udelay(10);
8557 gpio_set_value_cansleep(GPIO_RESX_N, 1);
8558 display_power_on = 1;
8559 setup_display_power();
8560 } else {
8561 gpio_set_value_cansleep(GPIO_RESX_N, 0);
8562 gpio_free(GPIO_RESX_N);
8563 msleep(20);
8564 regulator_disable(fluid_reg2);
8565 regulator_disable(fluid_reg);
8566 regulator_put(fluid_reg2);
8567 regulator_put(fluid_reg);
8568 display_power_on = 0;
8569 setup_display_power();
8570 fluid_reg = NULL;
8571 fluid_reg2 = NULL;
8572 }
8573 }
8574#endif
8575 return;
8576
8577out4:
8578 gpio_free(GPIO_BACKLIGHT_EN);
8579out3:
8580 gpio_free(GPIO_LVDS_SHUTDOWN_N);
8581out2:
8582 regulator_disable(display_reg);
8583out:
8584 regulator_put(display_reg);
8585 display_reg = NULL;
8586}
8587#undef _GET_REGULATOR
8588#endif
8589
8590static int mipi_dsi_panel_power(int on);
8591
8592#define LCDC_NUM_GPIO 28
8593#define LCDC_GPIO_START 0
8594
8595static void lcdc_samsung_panel_power(int on)
8596{
8597 int n, ret = 0;
8598
8599 display_common_power(on);
8600
8601 for (n = 0; n < LCDC_NUM_GPIO; n++) {
8602 if (on) {
8603 ret = gpio_request(LCDC_GPIO_START + n, "LCDC_GPIO");
8604 if (unlikely(ret)) {
8605 pr_err("%s not able to get gpio\n", __func__);
8606 break;
8607 }
8608 } else
8609 gpio_free(LCDC_GPIO_START + n);
8610 }
8611
8612 if (ret) {
8613 for (n--; n >= 0; n--)
8614 gpio_free(LCDC_GPIO_START + n);
8615 }
8616
8617 mipi_dsi_panel_power(0); /* set 8058_ldo0 to LPM */
8618}
8619
8620#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
8621#define _GET_REGULATOR(var, name) do { \
8622 var = regulator_get(NULL, name); \
8623 if (IS_ERR(var)) { \
8624 pr_err("'%s' regulator not found, rc=%ld\n", \
8625 name, IS_ERR(var)); \
8626 var = NULL; \
8627 return -ENODEV; \
8628 } \
8629} while (0)
8630
8631static int hdmi_enable_5v(int on)
8632{
8633 static struct regulator *reg_8901_hdmi_mvs; /* HDMI_5V */
8634 static struct regulator *reg_8901_mpp0; /* External 5V */
8635 static int prev_on;
8636 int rc;
8637
8638 if (on == prev_on)
8639 return 0;
8640
8641 if (!reg_8901_hdmi_mvs)
8642 _GET_REGULATOR(reg_8901_hdmi_mvs, "8901_hdmi_mvs");
8643 if (!reg_8901_mpp0)
8644 _GET_REGULATOR(reg_8901_mpp0, "8901_mpp0");
8645
8646 if (on) {
8647 rc = regulator_enable(reg_8901_mpp0);
8648 if (rc) {
8649 pr_err("'%s' regulator enable failed, rc=%d\n",
8650 "reg_8901_mpp0", rc);
8651 return rc;
8652 }
8653 rc = regulator_enable(reg_8901_hdmi_mvs);
8654 if (rc) {
8655 pr_err("'%s' regulator enable failed, rc=%d\n",
8656 "8901_hdmi_mvs", rc);
8657 return rc;
8658 }
8659 pr_info("%s(on): success\n", __func__);
8660 } else {
8661 rc = regulator_disable(reg_8901_hdmi_mvs);
8662 if (rc)
8663 pr_warning("'%s' regulator disable failed, rc=%d\n",
8664 "8901_hdmi_mvs", rc);
8665 rc = regulator_disable(reg_8901_mpp0);
8666 if (rc)
8667 pr_warning("'%s' regulator disable failed, rc=%d\n",
8668 "reg_8901_mpp0", rc);
8669 pr_info("%s(off): success\n", __func__);
8670 }
8671
8672 prev_on = on;
8673
8674 return 0;
8675}
8676
8677static int hdmi_core_power(int on, int show)
8678{
8679 static struct regulator *reg_8058_l16; /* VDD_HDMI */
8680 static int prev_on;
8681 int rc;
8682
8683 if (on == prev_on)
8684 return 0;
8685
8686 if (!reg_8058_l16)
8687 _GET_REGULATOR(reg_8058_l16, "8058_l16");
8688
8689 if (on) {
8690 rc = regulator_set_voltage(reg_8058_l16, 1800000, 1800000);
8691 if (!rc)
8692 rc = regulator_enable(reg_8058_l16);
8693 if (rc) {
8694 pr_err("'%s' regulator enable failed, rc=%d\n",
8695 "8058_l16", rc);
8696 return rc;
8697 }
8698 rc = gpio_request(170, "HDMI_DDC_CLK");
8699 if (rc) {
8700 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8701 "HDMI_DDC_CLK", 170, rc);
8702 goto error1;
8703 }
8704 rc = gpio_request(171, "HDMI_DDC_DATA");
8705 if (rc) {
8706 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8707 "HDMI_DDC_DATA", 171, rc);
8708 goto error2;
8709 }
8710 rc = gpio_request(172, "HDMI_HPD");
8711 if (rc) {
8712 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8713 "HDMI_HPD", 172, rc);
8714 goto error3;
8715 }
8716 pr_info("%s(on): success\n", __func__);
8717 } else {
8718 gpio_free(170);
8719 gpio_free(171);
8720 gpio_free(172);
8721 rc = regulator_disable(reg_8058_l16);
8722 if (rc)
8723 pr_warning("'%s' regulator disable failed, rc=%d\n",
8724 "8058_l16", rc);
8725 pr_info("%s(off): success\n", __func__);
8726 }
8727
8728 prev_on = on;
8729
8730 return 0;
8731
8732error3:
8733 gpio_free(171);
8734error2:
8735 gpio_free(170);
8736error1:
8737 regulator_disable(reg_8058_l16);
8738 return rc;
8739}
8740
8741static int hdmi_cec_power(int on)
8742{
8743 static struct regulator *reg_8901_l3; /* HDMI_CEC */
8744 static int prev_on;
8745 int rc;
8746
8747 if (on == prev_on)
8748 return 0;
8749
8750 if (!reg_8901_l3)
8751 _GET_REGULATOR(reg_8901_l3, "8901_l3");
8752
8753 if (on) {
8754 rc = regulator_set_voltage(reg_8901_l3, 3300000, 3300000);
8755 if (!rc)
8756 rc = regulator_enable(reg_8901_l3);
8757 if (rc) {
8758 pr_err("'%s' regulator enable failed, rc=%d\n",
8759 "8901_l3", rc);
8760 return rc;
8761 }
8762 rc = gpio_request(169, "HDMI_CEC_VAR");
8763 if (rc) {
8764 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8765 "HDMI_CEC_VAR", 169, rc);
8766 goto error;
8767 }
8768 pr_info("%s(on): success\n", __func__);
8769 } else {
8770 gpio_free(169);
8771 rc = regulator_disable(reg_8901_l3);
8772 if (rc)
8773 pr_warning("'%s' regulator disable failed, rc=%d\n",
8774 "8901_l3", rc);
8775 pr_info("%s(off): success\n", __func__);
8776 }
8777
8778 prev_on = on;
8779
8780 return 0;
8781error:
8782 regulator_disable(reg_8901_l3);
8783 return rc;
8784}
8785
8786#undef _GET_REGULATOR
8787
8788#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
8789
8790static int lcdc_panel_power(int on)
8791{
8792 int flag_on = !!on;
8793 static int lcdc_power_save_on;
8794
8795 if (lcdc_power_save_on == flag_on)
8796 return 0;
8797
8798 lcdc_power_save_on = flag_on;
8799
8800 lcdc_samsung_panel_power(on);
8801
8802 return 0;
8803}
8804
8805#ifdef CONFIG_MSM_BUS_SCALING
8806#ifdef CONFIG_FB_MSM_LCDC_DSUB
8807static struct msm_bus_vectors mdp_init_vectors[] = {
8808 /* For now, 0th array entry is reserved.
8809 * Please leave 0 as is and don't use it
8810 */
8811 {
8812 .src = MSM_BUS_MASTER_MDP_PORT0,
8813 .dst = MSM_BUS_SLAVE_SMI,
8814 .ab = 0,
8815 .ib = 0,
8816 },
8817 /* Master and slaves can be from different fabrics */
8818 {
8819 .src = MSM_BUS_MASTER_MDP_PORT0,
8820 .dst = MSM_BUS_SLAVE_EBI_CH0,
8821 .ab = 0,
8822 .ib = 0,
8823 },
8824};
8825
8826static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
8827 /* Default case static display/UI/2d/3d if FB SMI */
8828 {
8829 .src = MSM_BUS_MASTER_MDP_PORT0,
8830 .dst = MSM_BUS_SLAVE_SMI,
8831 .ab = 388800000,
8832 .ib = 486000000,
8833 },
8834 /* Master and slaves can be from different fabrics */
8835 {
8836 .src = MSM_BUS_MASTER_MDP_PORT0,
8837 .dst = MSM_BUS_SLAVE_EBI_CH0,
8838 .ab = 0,
8839 .ib = 0,
8840 },
8841};
8842
8843static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
8844 /* Default case static display/UI/2d/3d if FB SMI */
8845 {
8846 .src = MSM_BUS_MASTER_MDP_PORT0,
8847 .dst = MSM_BUS_SLAVE_SMI,
8848 .ab = 0,
8849 .ib = 0,
8850 },
8851 /* Master and slaves can be from different fabrics */
8852 {
8853 .src = MSM_BUS_MASTER_MDP_PORT0,
8854 .dst = MSM_BUS_SLAVE_EBI_CH0,
8855 .ab = 388800000,
8856 .ib = 486000000 * 2,
8857 },
8858};
8859static struct msm_bus_vectors mdp_vga_vectors[] = {
8860 /* VGA and less video */
8861 {
8862 .src = MSM_BUS_MASTER_MDP_PORT0,
8863 .dst = MSM_BUS_SLAVE_SMI,
8864 .ab = 458092800,
8865 .ib = 572616000,
8866 },
8867 {
8868 .src = MSM_BUS_MASTER_MDP_PORT0,
8869 .dst = MSM_BUS_SLAVE_EBI_CH0,
8870 .ab = 458092800,
8871 .ib = 572616000 * 2,
8872 },
8873};
8874static struct msm_bus_vectors mdp_720p_vectors[] = {
8875 /* 720p and less video */
8876 {
8877 .src = MSM_BUS_MASTER_MDP_PORT0,
8878 .dst = MSM_BUS_SLAVE_SMI,
8879 .ab = 471744000,
8880 .ib = 589680000,
8881 },
8882 /* Master and slaves can be from different fabrics */
8883 {
8884 .src = MSM_BUS_MASTER_MDP_PORT0,
8885 .dst = MSM_BUS_SLAVE_EBI_CH0,
8886 .ab = 471744000,
8887 .ib = 589680000 * 2,
8888 },
8889};
8890
8891static struct msm_bus_vectors mdp_1080p_vectors[] = {
8892 /* 1080p and less video */
8893 {
8894 .src = MSM_BUS_MASTER_MDP_PORT0,
8895 .dst = MSM_BUS_SLAVE_SMI,
8896 .ab = 575424000,
8897 .ib = 719280000,
8898 },
8899 /* Master and slaves can be from different fabrics */
8900 {
8901 .src = MSM_BUS_MASTER_MDP_PORT0,
8902 .dst = MSM_BUS_SLAVE_EBI_CH0,
8903 .ab = 575424000,
8904 .ib = 719280000 * 2,
8905 },
8906};
8907
8908#else
8909static struct msm_bus_vectors mdp_init_vectors[] = {
8910 /* For now, 0th array entry is reserved.
8911 * Please leave 0 as is and don't use it
8912 */
8913 {
8914 .src = MSM_BUS_MASTER_MDP_PORT0,
8915 .dst = MSM_BUS_SLAVE_SMI,
8916 .ab = 0,
8917 .ib = 0,
8918 },
8919 /* Master and slaves can be from different fabrics */
8920 {
8921 .src = MSM_BUS_MASTER_MDP_PORT0,
8922 .dst = MSM_BUS_SLAVE_EBI_CH0,
8923 .ab = 0,
8924 .ib = 0,
8925 },
8926};
8927
8928static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
8929 /* Default case static display/UI/2d/3d if FB SMI */
8930 {
8931 .src = MSM_BUS_MASTER_MDP_PORT0,
8932 .dst = MSM_BUS_SLAVE_SMI,
8933 .ab = 175110000,
8934 .ib = 218887500,
8935 },
8936 /* Master and slaves can be from different fabrics */
8937 {
8938 .src = MSM_BUS_MASTER_MDP_PORT0,
8939 .dst = MSM_BUS_SLAVE_EBI_CH0,
8940 .ab = 0,
8941 .ib = 0,
8942 },
8943};
8944
8945static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
8946 /* Default case static display/UI/2d/3d if FB SMI */
8947 {
8948 .src = MSM_BUS_MASTER_MDP_PORT0,
8949 .dst = MSM_BUS_SLAVE_SMI,
8950 .ab = 0,
8951 .ib = 0,
8952 },
8953 /* Master and slaves can be from different fabrics */
8954 {
8955 .src = MSM_BUS_MASTER_MDP_PORT0,
8956 .dst = MSM_BUS_SLAVE_EBI_CH0,
8957 .ab = 216000000,
8958 .ib = 270000000 * 2,
8959 },
8960};
8961static struct msm_bus_vectors mdp_vga_vectors[] = {
8962 /* VGA and less video */
8963 {
8964 .src = MSM_BUS_MASTER_MDP_PORT0,
8965 .dst = MSM_BUS_SLAVE_SMI,
8966 .ab = 216000000,
8967 .ib = 270000000,
8968 },
8969 {
8970 .src = MSM_BUS_MASTER_MDP_PORT0,
8971 .dst = MSM_BUS_SLAVE_EBI_CH0,
8972 .ab = 216000000,
8973 .ib = 270000000 * 2,
8974 },
8975};
8976
8977static struct msm_bus_vectors mdp_720p_vectors[] = {
8978 /* 720p and less video */
8979 {
8980 .src = MSM_BUS_MASTER_MDP_PORT0,
8981 .dst = MSM_BUS_SLAVE_SMI,
8982 .ab = 230400000,
8983 .ib = 288000000,
8984 },
8985 /* Master and slaves can be from different fabrics */
8986 {
8987 .src = MSM_BUS_MASTER_MDP_PORT0,
8988 .dst = MSM_BUS_SLAVE_EBI_CH0,
8989 .ab = 230400000,
8990 .ib = 288000000 * 2,
8991 },
8992};
8993
8994static struct msm_bus_vectors mdp_1080p_vectors[] = {
8995 /* 1080p and less video */
8996 {
8997 .src = MSM_BUS_MASTER_MDP_PORT0,
8998 .dst = MSM_BUS_SLAVE_SMI,
8999 .ab = 334080000,
9000 .ib = 417600000,
9001 },
9002 /* Master and slaves can be from different fabrics */
9003 {
9004 .src = MSM_BUS_MASTER_MDP_PORT0,
9005 .dst = MSM_BUS_SLAVE_EBI_CH0,
9006 .ab = 334080000,
Ravishangar Kalyanam731beb92011-07-07 18:27:32 -07009007 .ib = 550000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009008 },
9009};
9010
9011#endif
9012static struct msm_bus_paths mdp_bus_scale_usecases[] = {
9013 {
9014 ARRAY_SIZE(mdp_init_vectors),
9015 mdp_init_vectors,
9016 },
9017 {
9018 ARRAY_SIZE(mdp_sd_smi_vectors),
9019 mdp_sd_smi_vectors,
9020 },
9021 {
9022 ARRAY_SIZE(mdp_sd_ebi_vectors),
9023 mdp_sd_ebi_vectors,
9024 },
9025 {
9026 ARRAY_SIZE(mdp_vga_vectors),
9027 mdp_vga_vectors,
9028 },
9029 {
9030 ARRAY_SIZE(mdp_720p_vectors),
9031 mdp_720p_vectors,
9032 },
9033 {
9034 ARRAY_SIZE(mdp_1080p_vectors),
9035 mdp_1080p_vectors,
9036 },
9037};
9038static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
9039 mdp_bus_scale_usecases,
9040 ARRAY_SIZE(mdp_bus_scale_usecases),
9041 .name = "mdp",
9042};
9043
9044#endif
9045#ifdef CONFIG_MSM_BUS_SCALING
9046static struct msm_bus_vectors dtv_bus_init_vectors[] = {
9047 /* For now, 0th array entry is reserved.
9048 * Please leave 0 as is and don't use it
9049 */
9050 {
9051 .src = MSM_BUS_MASTER_MDP_PORT0,
9052 .dst = MSM_BUS_SLAVE_SMI,
9053 .ab = 0,
9054 .ib = 0,
9055 },
9056 /* Master and slaves can be from different fabrics */
9057 {
9058 .src = MSM_BUS_MASTER_MDP_PORT0,
9059 .dst = MSM_BUS_SLAVE_EBI_CH0,
9060 .ab = 0,
9061 .ib = 0,
9062 },
9063};
9064static struct msm_bus_vectors dtv_bus_def_vectors[] = {
9065 /* For now, 0th array entry is reserved.
9066 * Please leave 0 as is and don't use it
9067 */
9068 {
9069 .src = MSM_BUS_MASTER_MDP_PORT0,
9070 .dst = MSM_BUS_SLAVE_SMI,
9071 .ab = 566092800,
9072 .ib = 707616000,
9073 },
9074 /* Master and slaves can be from different fabrics */
9075 {
9076 .src = MSM_BUS_MASTER_MDP_PORT0,
9077 .dst = MSM_BUS_SLAVE_EBI_CH0,
9078 .ab = 566092800,
9079 .ib = 707616000,
9080 },
9081};
9082static struct msm_bus_paths dtv_bus_scale_usecases[] = {
9083 {
9084 ARRAY_SIZE(dtv_bus_init_vectors),
9085 dtv_bus_init_vectors,
9086 },
9087 {
9088 ARRAY_SIZE(dtv_bus_def_vectors),
9089 dtv_bus_def_vectors,
9090 },
9091};
9092static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
9093 dtv_bus_scale_usecases,
9094 ARRAY_SIZE(dtv_bus_scale_usecases),
9095 .name = "dtv",
9096};
9097
9098static struct lcdc_platform_data dtv_pdata = {
9099 .bus_scale_table = &dtv_bus_scale_pdata,
9100};
9101#endif
9102
9103
9104static struct lcdc_platform_data lcdc_pdata = {
9105 .lcdc_power_save = lcdc_panel_power,
9106};
9107
9108
9109#define MDP_VSYNC_GPIO 28
9110
9111/*
9112 * MIPI_DSI only use 8058_LDO0 which need always on
9113 * therefore it need to be put at low power mode if
9114 * it was not used instead of turn it off.
9115 */
9116static int mipi_dsi_panel_power(int on)
9117{
9118 int flag_on = !!on;
9119 static int mipi_dsi_power_save_on;
9120 static struct regulator *ldo0;
9121 int rc = 0;
9122
9123 if (mipi_dsi_power_save_on == flag_on)
9124 return 0;
9125
9126 mipi_dsi_power_save_on = flag_on;
9127
9128 if (ldo0 == NULL) { /* init */
9129 ldo0 = regulator_get(NULL, "8058_l0");
9130 if (IS_ERR(ldo0)) {
9131 pr_debug("%s: LDO0 failed\n", __func__);
9132 rc = PTR_ERR(ldo0);
9133 return rc;
9134 }
9135
9136 rc = regulator_set_voltage(ldo0, 1200000, 1200000);
9137 if (rc)
9138 goto out;
9139
9140 rc = regulator_enable(ldo0);
9141 if (rc)
9142 goto out;
9143 }
9144
9145 if (on) {
9146 /* set ldo0 to HPM */
9147 rc = regulator_set_optimum_mode(ldo0, 100000);
9148 if (rc < 0)
9149 goto out;
9150 } else {
9151 /* set ldo0 to LPM */
9152 rc = regulator_set_optimum_mode(ldo0, 9000);
9153 if (rc < 0)
9154 goto out;
9155 }
9156
9157 return 0;
9158out:
9159 regulator_disable(ldo0);
9160 regulator_put(ldo0);
9161 ldo0 = NULL;
9162 return rc;
9163}
9164
9165static struct mipi_dsi_platform_data mipi_dsi_pdata = {
9166 .vsync_gpio = MDP_VSYNC_GPIO,
9167 .dsi_power_save = mipi_dsi_panel_power,
9168};
9169
9170#ifdef CONFIG_FB_MSM_TVOUT
9171static struct regulator *reg_8058_l13;
9172
9173static int atv_dac_power(int on)
9174{
9175 int rc = 0;
9176 #define _GET_REGULATOR(var, name) do { \
9177 var = regulator_get(NULL, name); \
9178 if (IS_ERR(var)) { \
9179 pr_info("'%s' regulator not found, rc=%ld\n", \
9180 name, IS_ERR(var)); \
9181 var = NULL; \
9182 return -ENODEV; \
9183 } \
9184 } while (0)
9185
9186 if (!reg_8058_l13)
9187 _GET_REGULATOR(reg_8058_l13, "8058_l13");
9188 #undef _GET_REGULATOR
9189
9190 if (on) {
9191 rc = regulator_set_voltage(reg_8058_l13, 2050000, 2050000);
9192 if (rc) {
9193 pr_info("%s: '%s' regulator set voltage failed,\
9194 rc=%d\n", __func__, "8058_l13", rc);
9195 return rc;
9196 }
9197
9198 rc = regulator_enable(reg_8058_l13);
9199 if (rc) {
9200 pr_err("%s: '%s' regulator enable failed,\
9201 rc=%d\n", __func__, "8058_l13", rc);
9202 return rc;
9203 }
9204 } else {
9205 rc = regulator_force_disable(reg_8058_l13);
9206 if (rc)
9207 pr_warning("%s: '%s' regulator disable failed, rc=%d\n",
9208 __func__, "8058_l13", rc);
9209 }
9210 return rc;
9211
9212}
9213#endif
9214
9215#ifdef CONFIG_FB_MSM_MIPI_DSI
9216int mdp_core_clk_rate_table[] = {
9217 85330000,
9218 85330000,
9219 160000000,
9220 200000000,
9221};
9222#else
9223int mdp_core_clk_rate_table[] = {
9224 59080000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009225 85330000,
kuogee hsieh26791a92011-08-01 18:35:58 -07009226 128000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009227 200000000,
9228};
9229#endif
9230
9231static struct msm_panel_common_pdata mdp_pdata = {
9232 .gpio = MDP_VSYNC_GPIO,
9233 .mdp_core_clk_rate = 59080000,
9234 .mdp_core_clk_table = mdp_core_clk_rate_table,
9235 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
9236#ifdef CONFIG_MSM_BUS_SCALING
9237 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
9238#endif
9239 .mdp_rev = MDP_REV_41,
9240};
9241
9242#ifdef CONFIG_FB_MSM_TVOUT
9243
9244#ifdef CONFIG_MSM_BUS_SCALING
9245static struct msm_bus_vectors atv_bus_init_vectors[] = {
9246 /* For now, 0th array entry is reserved.
9247 * Please leave 0 as is and don't use it
9248 */
9249 {
9250 .src = MSM_BUS_MASTER_MDP_PORT0,
9251 .dst = MSM_BUS_SLAVE_SMI,
9252 .ab = 0,
9253 .ib = 0,
9254 },
9255 /* Master and slaves can be from different fabrics */
9256 {
9257 .src = MSM_BUS_MASTER_MDP_PORT0,
9258 .dst = MSM_BUS_SLAVE_EBI_CH0,
9259 .ab = 0,
9260 .ib = 0,
9261 },
9262};
9263static struct msm_bus_vectors atv_bus_def_vectors[] = {
9264 /* For now, 0th array entry is reserved.
9265 * Please leave 0 as is and don't use it
9266 */
9267 {
9268 .src = MSM_BUS_MASTER_MDP_PORT0,
9269 .dst = MSM_BUS_SLAVE_SMI,
9270 .ab = 236390400,
9271 .ib = 265939200,
9272 },
9273 /* Master and slaves can be from different fabrics */
9274 {
9275 .src = MSM_BUS_MASTER_MDP_PORT0,
9276 .dst = MSM_BUS_SLAVE_EBI_CH0,
9277 .ab = 236390400,
9278 .ib = 265939200,
9279 },
9280};
9281static struct msm_bus_paths atv_bus_scale_usecases[] = {
9282 {
9283 ARRAY_SIZE(atv_bus_init_vectors),
9284 atv_bus_init_vectors,
9285 },
9286 {
9287 ARRAY_SIZE(atv_bus_def_vectors),
9288 atv_bus_def_vectors,
9289 },
9290};
9291static struct msm_bus_scale_pdata atv_bus_scale_pdata = {
9292 atv_bus_scale_usecases,
9293 ARRAY_SIZE(atv_bus_scale_usecases),
9294 .name = "atv",
9295};
9296#endif
9297
9298static struct tvenc_platform_data atv_pdata = {
9299 .poll = 0,
9300 .pm_vid_en = atv_dac_power,
9301#ifdef CONFIG_MSM_BUS_SCALING
9302 .bus_scale_table = &atv_bus_scale_pdata,
9303#endif
9304};
9305#endif
9306
9307static void __init msm_fb_add_devices(void)
9308{
9309#ifdef CONFIG_FB_MSM_LCDC_DSUB
9310 mdp_pdata.mdp_core_clk_table = NULL;
9311 mdp_pdata.num_mdp_clk = 0;
9312 mdp_pdata.mdp_core_clk_rate = 200000000;
9313#endif
9314 if (machine_is_msm8x60_rumi3())
9315 msm_fb_register_device("mdp", NULL);
9316 else
9317 msm_fb_register_device("mdp", &mdp_pdata);
9318
9319 msm_fb_register_device("lcdc", &lcdc_pdata);
9320 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
9321#ifdef CONFIG_MSM_BUS_SCALING
9322 msm_fb_register_device("dtv", &dtv_pdata);
9323#endif
9324#ifdef CONFIG_FB_MSM_TVOUT
9325 msm_fb_register_device("tvenc", &atv_pdata);
9326 msm_fb_register_device("tvout_device", NULL);
9327#endif
9328}
9329
9330#if (defined(CONFIG_MARIMBA_CORE)) && \
9331 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
9332
9333static const struct {
9334 char *name;
9335 int vmin;
9336 int vmax;
9337} bt_regs_info[] = {
9338 { "8058_s3", 1800000, 1800000 },
9339 { "8058_s2", 1300000, 1300000 },
9340 { "8058_l8", 2900000, 3050000 },
9341};
9342
9343static struct {
9344 bool enabled;
9345} bt_regs_status[] = {
9346 { false },
9347 { false },
9348 { false },
9349};
9350static struct regulator *bt_regs[ARRAY_SIZE(bt_regs_info)];
9351
9352static int bahama_bt(int on)
9353{
9354 int rc;
9355 int i;
9356 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
9357
9358 struct bahama_variant_register {
9359 const size_t size;
9360 const struct bahama_config_register *set;
9361 };
9362
9363 const struct bahama_config_register *p;
9364
9365 u8 version;
9366
9367 const struct bahama_config_register v10_bt_on[] = {
9368 { 0xE9, 0x00, 0xFF },
9369 { 0xF4, 0x80, 0xFF },
9370 { 0xE4, 0x00, 0xFF },
9371 { 0xE5, 0x00, 0x0F },
9372#ifdef CONFIG_WLAN
9373 { 0xE6, 0x38, 0x7F },
9374 { 0xE7, 0x06, 0xFF },
9375#endif
9376 { 0xE9, 0x21, 0xFF },
9377 { 0x01, 0x0C, 0x1F },
9378 { 0x01, 0x08, 0x1F },
9379 };
9380
9381 const struct bahama_config_register v20_bt_on_fm_off[] = {
9382 { 0x11, 0x0C, 0xFF },
9383 { 0x13, 0x01, 0xFF },
9384 { 0xF4, 0x80, 0xFF },
9385 { 0xF0, 0x00, 0xFF },
9386 { 0xE9, 0x00, 0xFF },
9387#ifdef CONFIG_WLAN
9388 { 0x81, 0x00, 0x7F },
9389 { 0x82, 0x00, 0xFF },
9390 { 0xE6, 0x38, 0x7F },
9391 { 0xE7, 0x06, 0xFF },
9392#endif
9393 { 0xE9, 0x21, 0xFF },
9394 };
9395
9396 const struct bahama_config_register v20_bt_on_fm_on[] = {
9397 { 0x11, 0x0C, 0xFF },
9398 { 0x13, 0x01, 0xFF },
9399 { 0xF4, 0x86, 0xFF },
9400 { 0xF0, 0x06, 0xFF },
9401 { 0xE9, 0x00, 0xFF },
9402#ifdef CONFIG_WLAN
9403 { 0x81, 0x00, 0x7F },
9404 { 0x82, 0x00, 0xFF },
9405 { 0xE6, 0x38, 0x7F },
9406 { 0xE7, 0x06, 0xFF },
9407#endif
9408 { 0xE9, 0x21, 0xFF },
9409 };
9410
9411 const struct bahama_config_register v10_bt_off[] = {
9412 { 0xE9, 0x00, 0xFF },
9413 };
9414
9415 const struct bahama_config_register v20_bt_off_fm_off[] = {
9416 { 0xF4, 0x84, 0xFF },
9417 { 0xF0, 0x04, 0xFF },
9418 { 0xE9, 0x00, 0xFF }
9419 };
9420
9421 const struct bahama_config_register v20_bt_off_fm_on[] = {
9422 { 0xF4, 0x86, 0xFF },
9423 { 0xF0, 0x06, 0xFF },
9424 { 0xE9, 0x00, 0xFF }
9425 };
9426 const struct bahama_variant_register bt_bahama[2][3] = {
9427 {
9428 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
9429 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
9430 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
9431 },
9432 {
9433 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
9434 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
9435 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
9436 }
9437 };
9438
9439 u8 offset = 0; /* index into bahama configs */
9440
9441 on = on ? 1 : 0;
9442 version = read_bahama_ver();
9443
9444 if (version == VER_UNSUPPORTED) {
9445 dev_err(&msm_bt_power_device.dev,
9446 "%s: unsupported version\n",
9447 __func__);
9448 return -EIO;
9449 }
9450
9451 if (version == VER_2_0) {
9452 if (marimba_get_fm_status(&config))
9453 offset = 0x01;
9454 }
9455
9456 /* Voting off 1.3V S2 Regulator,BahamaV2 used in Normal mode */
9457 if (on && (version == VER_2_0)) {
9458 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9459 if ((!strcmp(bt_regs_info[i].name, "8058_s2"))
9460 && (bt_regs_status[i].enabled == true)) {
9461 if (regulator_disable(bt_regs[i])) {
9462 dev_err(&msm_bt_power_device.dev,
9463 "%s: regulator disable failed",
9464 __func__);
9465 }
9466 bt_regs_status[i].enabled = false;
9467 break;
9468 }
9469 }
9470 }
9471
9472 p = bt_bahama[on][version + offset].set;
9473
9474 dev_info(&msm_bt_power_device.dev,
9475 "%s: found version %d\n", __func__, version);
9476
9477 for (i = 0; i < bt_bahama[on][version + offset].size; i++) {
9478 u8 value = (p+i)->value;
9479 rc = marimba_write_bit_mask(&config,
9480 (p+i)->reg,
9481 &value,
9482 sizeof((p+i)->value),
9483 (p+i)->mask);
9484 if (rc < 0) {
9485 dev_err(&msm_bt_power_device.dev,
9486 "%s: reg %d write failed: %d\n",
9487 __func__, (p+i)->reg, rc);
9488 return rc;
9489 }
9490 dev_dbg(&msm_bt_power_device.dev,
9491 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
9492 __func__, (p+i)->reg,
9493 value, (p+i)->mask);
9494 }
9495 /* Update BT Status */
9496 if (on)
9497 marimba_set_bt_status(&config, true);
9498 else
9499 marimba_set_bt_status(&config, false);
9500
9501 return 0;
9502}
9503
9504static int bluetooth_use_regulators(int on)
9505{
9506 int i, recover = -1, rc = 0;
9507
9508 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9509 bt_regs[i] = on ? regulator_get(&msm_bt_power_device.dev,
9510 bt_regs_info[i].name) :
9511 (regulator_put(bt_regs[i]), NULL);
9512 if (IS_ERR(bt_regs[i])) {
9513 rc = PTR_ERR(bt_regs[i]);
9514 dev_err(&msm_bt_power_device.dev,
9515 "regulator %s get failed (%d)\n",
9516 bt_regs_info[i].name, rc);
9517 recover = i - 1;
9518 bt_regs[i] = NULL;
9519 break;
9520 }
9521
9522 if (!on)
9523 continue;
9524
9525 rc = regulator_set_voltage(bt_regs[i],
9526 bt_regs_info[i].vmin,
9527 bt_regs_info[i].vmax);
9528 if (rc < 0) {
9529 dev_err(&msm_bt_power_device.dev,
9530 "regulator %s voltage set (%d)\n",
9531 bt_regs_info[i].name, rc);
9532 recover = i;
9533 break;
9534 }
9535 }
9536
9537 if (on && (recover > -1))
9538 for (i = recover; i >= 0; i--) {
9539 regulator_put(bt_regs[i]);
9540 bt_regs[i] = NULL;
9541 }
9542
9543 return rc;
9544}
9545
9546static int bluetooth_switch_regulators(int on)
9547{
9548 int i, rc = 0;
9549
9550 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9551 if (on && (bt_regs_status[i].enabled == false)) {
9552 rc = regulator_enable(bt_regs[i]);
9553 if (rc < 0) {
9554 dev_err(&msm_bt_power_device.dev,
9555 "regulator %s %s failed (%d)\n",
9556 bt_regs_info[i].name,
9557 "enable", rc);
9558 if (i > 0) {
9559 while (--i) {
9560 regulator_disable(bt_regs[i]);
9561 bt_regs_status[i].enabled
9562 = false;
9563 }
9564 break;
9565 }
9566 }
9567 bt_regs_status[i].enabled = true;
9568 } else if (!on && (bt_regs_status[i].enabled == true)) {
9569 rc = regulator_disable(bt_regs[i]);
9570 if (rc < 0) {
9571 dev_err(&msm_bt_power_device.dev,
9572 "regulator %s %s failed (%d)\n",
9573 bt_regs_info[i].name,
9574 "disable", rc);
9575 break;
9576 }
9577 bt_regs_status[i].enabled = false;
9578 }
9579 }
9580 return rc;
9581}
9582
9583static struct msm_xo_voter *bt_clock;
9584
9585static int bluetooth_power(int on)
9586{
9587 int rc = 0;
9588 int id;
9589
9590 /* In case probe function fails, cur_connv_type would be -1 */
9591 id = adie_get_detected_connectivity_type();
9592 if (id != BAHAMA_ID) {
9593 pr_err("%s: unexpected adie connectivity type: %d\n",
9594 __func__, id);
9595 return -ENODEV;
9596 }
9597
9598 if (on) {
9599
9600 rc = bluetooth_use_regulators(1);
9601 if (rc < 0)
9602 goto out;
9603
9604 rc = bluetooth_switch_regulators(1);
9605
9606 if (rc < 0)
9607 goto fail_put;
9608
9609 bt_clock = msm_xo_get(MSM_XO_TCXO_D0, "bt_power");
9610
9611 if (IS_ERR(bt_clock)) {
9612 pr_err("Couldn't get TCXO_D0 voter\n");
9613 goto fail_switch;
9614 }
9615
9616 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_ON);
9617
9618 if (rc < 0) {
9619 pr_err("Failed to vote for TCXO_DO ON\n");
9620 goto fail_vote;
9621 }
9622
9623 rc = bahama_bt(1);
9624
9625 if (rc < 0)
9626 goto fail_clock;
9627
9628 msleep(10);
9629
9630 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_PIN_CTRL);
9631
9632 if (rc < 0) {
9633 pr_err("Failed to vote for TCXO_DO pin control\n");
9634 goto fail_vote;
9635 }
9636 } else {
9637 /* check for initial RFKILL block (power off) */
9638 /* some RFKILL versions/configurations rfkill_register */
9639 /* calls here for an initial set_block */
9640 /* avoid calling i2c and regulator before unblock (on) */
9641 if (platform_get_drvdata(&msm_bt_power_device) == NULL) {
9642 dev_info(&msm_bt_power_device.dev,
9643 "%s: initialized OFF/blocked\n", __func__);
9644 goto out;
9645 }
9646
9647 bahama_bt(0);
9648
9649fail_clock:
9650 msm_xo_mode_vote(bt_clock, MSM_XO_MODE_OFF);
9651fail_vote:
9652 msm_xo_put(bt_clock);
9653fail_switch:
9654 bluetooth_switch_regulators(0);
9655fail_put:
9656 bluetooth_use_regulators(0);
9657 }
9658
9659out:
9660 if (rc < 0)
9661 on = 0;
9662 dev_info(&msm_bt_power_device.dev,
9663 "Bluetooth power switch: state %d result %d\n", on, rc);
9664
9665 return rc;
9666}
9667
9668#endif /*CONFIG_MARIMBA_CORE, CONFIG_MSM_BT_POWER, CONFIG_MSM_BT_POWER_MODULE*/
9669
9670static void __init msm8x60_cfg_smsc911x(void)
9671{
9672 smsc911x_resources[1].start =
9673 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
9674 smsc911x_resources[1].end =
9675 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
9676}
9677
9678#ifdef CONFIG_MSM_RPM
9679static struct msm_rpm_platform_data msm_rpm_data = {
9680 .reg_base_addrs = {
9681 [MSM_RPM_PAGE_STATUS] = MSM_RPM_BASE,
9682 [MSM_RPM_PAGE_CTRL] = MSM_RPM_BASE + 0x400,
9683 [MSM_RPM_PAGE_REQ] = MSM_RPM_BASE + 0x600,
9684 [MSM_RPM_PAGE_ACK] = MSM_RPM_BASE + 0xa00,
9685 },
9686
9687 .irq_ack = RPM_SCSS_CPU0_GP_HIGH_IRQ,
9688 .irq_err = RPM_SCSS_CPU0_GP_LOW_IRQ,
9689 .irq_vmpm = RPM_SCSS_CPU0_GP_MEDIUM_IRQ,
9690 .msm_apps_ipc_rpm_reg = MSM_GCC_BASE + 0x008,
9691 .msm_apps_ipc_rpm_val = 4,
9692};
9693#endif
9694
9695struct msm_board_data {
9696 struct msm_gpiomux_configs *gpiomux_cfgs;
9697};
9698
9699static struct msm_board_data msm8x60_rumi3_board_data __initdata = {
9700 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
9701};
9702
9703static struct msm_board_data msm8x60_sim_board_data __initdata = {
9704 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
9705};
9706
9707static struct msm_board_data msm8x60_surf_board_data __initdata = {
9708 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
9709};
9710
9711static struct msm_board_data msm8x60_ffa_board_data __initdata = {
9712 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
9713};
9714
9715static struct msm_board_data msm8x60_fluid_board_data __initdata = {
9716 .gpiomux_cfgs = msm8x60_fluid_gpiomux_cfgs,
9717};
9718
9719static struct msm_board_data msm8x60_charm_surf_board_data __initdata = {
9720 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
9721};
9722
9723static struct msm_board_data msm8x60_charm_ffa_board_data __initdata = {
9724 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
9725};
9726
Zhang Chang Kenef05b172011-07-27 15:28:13 -04009727static struct msm_board_data msm8x60_dragon_board_data __initdata = {
9728 .gpiomux_cfgs = msm8x60_dragon_gpiomux_cfgs,
9729};
9730
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009731static void __init msm8x60_init(struct msm_board_data *board_data)
9732{
9733 uint32_t soc_platform_version;
9734
9735 /*
9736 * Initialize RPM first as other drivers and devices may need
9737 * it for their initialization.
9738 */
9739#ifdef CONFIG_MSM_RPM
9740 BUG_ON(msm_rpm_init(&msm_rpm_data));
9741#endif
9742 BUG_ON(msm_rpmrs_levels_init(msm_rpmrs_levels,
9743 ARRAY_SIZE(msm_rpmrs_levels)));
9744 if (msm_xo_init())
9745 pr_err("Failed to initialize XO votes\n");
9746
9747 if (socinfo_init() < 0)
9748 printk(KERN_ERR "%s: socinfo_init() failed!\n",
9749 __func__);
9750 msm8x60_check_2d_hardware();
9751
9752 /* Change SPM handling of core 1 if PMM 8160 is present. */
9753 soc_platform_version = socinfo_get_platform_version();
9754 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1 &&
9755 SOCINFO_VERSION_MINOR(soc_platform_version) >= 2) {
9756 struct msm_spm_platform_data *spm_data;
9757
9758 spm_data = &msm_spm_data_v1[1];
9759 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
9760 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
9761
9762 spm_data = &msm_spm_data[1];
9763 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
9764 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
9765 }
9766
9767 /*
9768 * Initialize SPM before acpuclock as the latter calls into SPM
9769 * driver to set ACPU voltages.
9770 */
9771 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
9772 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
9773 else
9774 msm_spm_init(msm_spm_data_v1, ARRAY_SIZE(msm_spm_data_v1));
9775
9776 /*
9777 * Set regulators 8901_l4 and 8901_l6 to be always on in HPM for SURF
9778 * devices so that the RPM doesn't drop into a low power mode that an
9779 * un-reworked SURF cannot resume from.
9780 */
9781 if (machine_is_msm8x60_surf()) {
9782 rpm_vreg_init_pdata[RPM_VREG_ID_PM8901_L4]
9783 .init_data.constraints.always_on = 1;
9784 rpm_vreg_init_pdata[RPM_VREG_ID_PM8901_L6]
9785 .init_data.constraints.always_on = 1;
9786 }
9787
9788 /*
9789 * Disable regulator info printing so that regulator registration
9790 * messages do not enter the kmsg log.
9791 */
9792 regulator_suppress_info_printing();
9793
9794 /* Initialize regulators needed for clock_init. */
9795 platform_add_devices(early_regulators, ARRAY_SIZE(early_regulators));
9796
Stephen Boydbb600ae2011-08-02 20:11:40 -07009797 msm_clock_init(&msm8x60_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009798
9799 /* Buses need to be initialized before early-device registration
9800 * to get the platform data for fabrics.
9801 */
9802 msm8x60_init_buses();
9803 platform_add_devices(early_devices, ARRAY_SIZE(early_devices));
9804 /* CPU frequency control is not supported on simulated targets. */
9805 if (!machine_is_msm8x60_rumi3() && !machine_is_msm8x60_sim())
9806 msm_acpu_clock_init(&msm8x60_acpu_clock_data);
9807
9808 /* No EBI2 on 8660 charm targets */
9809 if (!machine_is_msm8x60_fusion() && !machine_is_msm8x60_fusn_ffa())
9810 msm8x60_init_ebi2();
9811 msm8x60_init_tlmm();
9812 msm8x60_init_gpiomux(board_data->gpiomux_cfgs);
9813 msm8x60_init_uart12dm();
9814 msm8x60_init_mmc();
9815
9816#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
9817 msm8x60_init_pm8058_othc();
9818#endif
9819
9820 if (machine_is_msm8x60_fluid()) {
9821 pm8058_platform_data.sub_devices[PM8058_SUBDEV_KPD].
9822 platform_data = &fluid_keypad_data;
9823 pm8058_platform_data.sub_devices[PM8058_SUBDEV_KPD].pdata_size
9824 = sizeof(fluid_keypad_data);
Zhang Chang Ken683be172011-08-10 17:45:34 -04009825 } else if (machine_is_msm8x60_dragon()) {
9826 pm8058_platform_data.sub_devices[PM8058_SUBDEV_KPD].
9827 platform_data = &dragon_keypad_data;
9828 pm8058_platform_data.sub_devices[PM8058_SUBDEV_KPD].pdata_size
9829 = sizeof(dragon_keypad_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009830 } else {
9831 pm8058_platform_data.sub_devices[PM8058_SUBDEV_KPD].
9832 platform_data = &ffa_keypad_data;
9833 pm8058_platform_data.sub_devices[PM8058_SUBDEV_KPD].pdata_size
9834 = sizeof(ffa_keypad_data);
9835
9836 }
9837
9838 /* Disable END_CALL simulation function of powerkey on fluid */
9839 if (machine_is_msm8x60_fluid()) {
9840 pwrkey_pdata.pwrkey_time_ms = 0;
9841 }
9842
Jilai Wang53d27a82011-07-13 14:32:58 -04009843 /* Specify reset pin for OV9726 */
9844 if (machine_is_msm8x60_dragon()) {
9845 msm_camera_sensor_ov9726_data.sensor_reset = 62;
9846 ov9726_sensor_8660_info.mount_angle = 270;
9847 }
9848
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009849 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
9850 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04009851 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009852 msm8x60_cfg_smsc911x();
9853 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
9854 platform_add_devices(msm_footswitch_devices,
9855 msm_num_footswitch_devices);
9856 platform_add_devices(surf_devices,
9857 ARRAY_SIZE(surf_devices));
9858
9859#ifdef CONFIG_MSM_DSPS
9860 if (machine_is_msm8x60_fluid()) {
9861 platform_device_unregister(&msm_gsbi12_qup_i2c_device);
9862 msm8x60_init_dsps();
9863 }
9864#endif
9865
9866#ifdef CONFIG_USB_EHCI_MSM_72K
9867 /*
9868 * Drive MPP2 pin HIGH for PHY to generate ID interrupts on 8660
9869 * fluid
9870 */
9871 if (machine_is_msm8x60_fluid()) {
9872 pm8901_mpp_config_digital_out(1,
9873 PM8901_MPP_DIG_LEVEL_L5, 1);
9874 }
9875 msm_add_host(0, &msm_usb_host_pdata);
9876#endif
9877 } else {
9878 msm8x60_configure_smc91x();
9879 platform_add_devices(rumi_sim_devices,
9880 ARRAY_SIZE(rumi_sim_devices));
9881 }
9882#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04009883 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
9884 machine_is_msm8x60_dragon())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009885 msm8x60_cfg_isp1763();
9886#endif
9887#ifdef CONFIG_BATTERY_MSM8X60
9888 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04009889 machine_is_msm8x60_fusion() || machine_is_msm8x60_dragon() ||
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009890 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_fluid())
9891 platform_device_register(&msm_charger_device);
9892#endif
9893
9894 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
9895 platform_add_devices(charm_devices, ARRAY_SIZE(charm_devices));
9896
9897 if (!machine_is_msm8x60_fluid())
9898 pm8058_platform_data.charger_sub_device
9899 = &pm8058_charger_sub_dev;
9900
9901#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
9902 if (machine_is_msm8x60_fluid())
9903 platform_device_register(&msm_gsbi10_qup_spi_device);
9904 else
9905 platform_device_register(&msm_gsbi1_qup_spi_device);
9906#endif
9907
9908#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
9909 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
9910 if (machine_is_msm8x60_fluid())
9911 cyttsp_set_params();
9912#endif
9913 if (!machine_is_msm8x60_sim())
9914 msm_fb_add_devices();
9915 fixup_i2c_configs();
9916 register_i2c_devices();
9917
Terence Hampson1c73fef2011-07-19 17:10:49 -04009918 if (machine_is_msm8x60_dragon())
9919 smsc911x_config.reset_gpio
9920 = GPIO_ETHERNET_RESET_N_DRAGON;
9921
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009922 platform_device_register(&smsc911x_device);
9923
9924#if (defined(CONFIG_SPI_QUP)) && \
9925 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
9926 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA))
9927
9928 if (machine_is_msm8x60_fluid()) {
9929#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
9930 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
9931 spi_register_board_info(lcdc_samsung_spi_board_info,
9932 ARRAY_SIZE(lcdc_samsung_spi_board_info));
9933 } else
9934#endif
9935 {
9936#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
9937 spi_register_board_info(lcdc_auo_spi_board_info,
9938 ARRAY_SIZE(lcdc_auo_spi_board_info));
9939#endif
9940 }
9941 }
9942#endif
9943
9944 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
9945 msm_pm_set_rpm_wakeup_irq(RPM_SCSS_CPU0_WAKE_UP_IRQ);
9946 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
9947 msm_pm_data);
9948
9949#ifdef CONFIG_SENSORS_MSM_ADC
9950 if (machine_is_msm8x60_fluid()) {
9951 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
9952 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
9953 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3)
9954 msm_adc_pdata.gpio_config = APROC_CONFIG;
9955 else
9956 msm_adc_pdata.gpio_config = MPROC_CONFIG;
9957 }
9958 msm_adc_pdata.target_hw = MSM_8x60;
9959#endif
9960#ifdef CONFIG_MSM8X60_AUDIO
9961 msm_snddev_init();
9962#endif
9963#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
9964 if (machine_is_msm8x60_fluid())
9965 platform_device_register(&fluid_leds_gpio);
9966 else
9967 platform_device_register(&gpio_leds);
9968#endif
9969
9970 /* configure pmic leds */
9971 if (machine_is_msm8x60_fluid()) {
9972 pm8058_platform_data.sub_devices[PM8058_SUBDEV_LED].
9973 platform_data = &pm8058_fluid_flash_leds_data;
9974 pm8058_platform_data.sub_devices[PM8058_SUBDEV_LED].pdata_size
9975 = sizeof(pm8058_fluid_flash_leds_data);
Terence Hampsonc0b6dfb2011-07-15 11:07:17 -04009976 } else if (machine_is_msm8x60_dragon()) {
9977 pm8058_platform_data.sub_devices[PM8058_SUBDEV_LED].
9978 platform_data = &pm8058_dragon_leds_data;
9979 pm8058_platform_data.sub_devices[PM8058_SUBDEV_LED].pdata_size
9980 = sizeof(pm8058_dragon_leds_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009981 } else {
9982 pm8058_platform_data.sub_devices[PM8058_SUBDEV_LED].
9983 platform_data = &pm8058_flash_leds_data;
9984 pm8058_platform_data.sub_devices[PM8058_SUBDEV_LED].pdata_size
9985 = sizeof(pm8058_flash_leds_data);
9986 }
9987
Zhang Chang Ken6baadf02011-08-05 09:48:15 -04009988 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa() ||
9989 machine_is_msm8x60_dragon()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009990 pm8058_platform_data.sub_devices[PM8058_SUBDEV_VIB].
9991 platform_data = &pmic_vib_pdata;
9992 pm8058_platform_data.sub_devices[PM8058_SUBDEV_VIB].
9993 pdata_size = sizeof(pmic_vib_pdata);
9994 }
9995
9996 msm8x60_multi_sdio_init();
9997}
9998
9999static void __init msm8x60_rumi3_init(void)
10000{
10001 msm8x60_init(&msm8x60_rumi3_board_data);
10002}
10003
10004static void __init msm8x60_sim_init(void)
10005{
10006 msm8x60_init(&msm8x60_sim_board_data);
10007}
10008
10009static void __init msm8x60_surf_init(void)
10010{
10011 msm8x60_init(&msm8x60_surf_board_data);
10012}
10013
10014static void __init msm8x60_ffa_init(void)
10015{
10016 msm8x60_init(&msm8x60_ffa_board_data);
10017}
10018
10019static void __init msm8x60_fluid_init(void)
10020{
10021 msm8x60_init(&msm8x60_fluid_board_data);
10022}
10023
10024static void __init msm8x60_charm_surf_init(void)
10025{
10026 msm8x60_init(&msm8x60_charm_surf_board_data);
10027}
10028
10029static void __init msm8x60_charm_ffa_init(void)
10030{
10031 msm8x60_init(&msm8x60_charm_ffa_board_data);
10032}
10033
10034static void __init msm8x60_charm_init_early(void)
10035{
10036 msm8x60_allocate_memory_regions();
Steve Mucklea55df6e2010-01-07 12:43:24 -080010037}
10038
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010039static void __init msm8x60_dragon_init(void)
10040{
10041 msm8x60_init(&msm8x60_dragon_board_data);
10042}
10043
Steve Mucklea55df6e2010-01-07 12:43:24 -080010044MACHINE_START(MSM8X60_RUMI3, "QCT MSM8X60 RUMI3")
10045 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010046 .reserve = msm8x60_reserve,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010047 .init_irq = msm8x60_init_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010048 .init_machine = msm8x60_rumi3_init,
Steve Mucklea55df6e2010-01-07 12:43:24 -080010049 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010050 .init_early = msm8x60_charm_init_early,
Steve Muckle49b76f72010-03-19 17:00:08 -070010051MACHINE_END
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010052
10053MACHINE_START(MSM8X60_SIM, "QCT MSM8X60 SIMULATOR")
10054 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010055 .reserve = msm8x60_reserve,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010056 .init_irq = msm8x60_init_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010057 .init_machine = msm8x60_sim_init,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010058 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010059 .init_early = msm8x60_charm_init_early,
10060MACHINE_END
10061
10062MACHINE_START(MSM8X60_SURF, "QCT MSM8X60 SURF")
10063 .map_io = msm8x60_map_io,
10064 .reserve = msm8x60_reserve,
10065 .init_irq = msm8x60_init_irq,
10066 .init_machine = msm8x60_surf_init,
10067 .timer = &msm_timer,
10068 .init_early = msm8x60_charm_init_early,
Steve Muckle57bbf1c2010-01-07 12:51:10 -080010069MACHINE_END
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010070
10071MACHINE_START(MSM8X60_FFA, "QCT MSM8X60 FFA")
10072 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010073 .reserve = msm8x60_reserve,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010074 .init_irq = msm8x60_init_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010075 .init_machine = msm8x60_ffa_init,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010076 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010077 .init_early = msm8x60_charm_init_early,
10078MACHINE_END
10079
10080MACHINE_START(MSM8X60_FLUID, "QCT MSM8X60 FLUID")
10081 .map_io = msm8x60_map_io,
10082 .reserve = msm8x60_reserve,
10083 .init_irq = msm8x60_init_irq,
10084 .init_machine = msm8x60_fluid_init,
10085 .timer = &msm_timer,
10086 .init_early = msm8x60_charm_init_early,
10087MACHINE_END
10088
10089MACHINE_START(MSM8X60_FUSION, "QCT MSM8X60 FUSION SURF")
10090 .map_io = msm8x60_map_io,
10091 .reserve = msm8x60_reserve,
10092 .init_irq = msm8x60_init_irq,
10093 .init_machine = msm8x60_charm_surf_init,
10094 .timer = &msm_timer,
10095 .init_early = msm8x60_charm_init_early,
10096MACHINE_END
10097
10098MACHINE_START(MSM8X60_FUSN_FFA, "QCT MSM8X60 FUSION FFA")
10099 .map_io = msm8x60_map_io,
10100 .reserve = msm8x60_reserve,
10101 .init_irq = msm8x60_init_irq,
10102 .init_machine = msm8x60_charm_ffa_init,
10103 .timer = &msm_timer,
10104 .init_early = msm8x60_charm_init_early,
Gregory Bean69b7f6f2010-04-04 22:29:02 -070010105MACHINE_END
Zhang Chang Kenef05b172011-07-27 15:28:13 -040010106
10107MACHINE_START(MSM8X60_DRAGON, "QCT MSM8X60 DRAGON")
10108 .map_io = msm8x60_map_io,
10109 .reserve = msm8x60_reserve,
10110 .init_irq = msm8x60_init_irq,
10111 .init_machine = msm8x60_dragon_init,
10112 .timer = &msm_timer,
10113 .init_early = msm8x60_charm_init_early,
10114MACHINE_END