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