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