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