blob: 4333cfbdf291684aa193c7e801727dedb08c20e5 [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
2930static struct mipi_dsi_novatek_platform_data novatek_pdata = {
2931 .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 */
3227 usleep_range(10000, 10000);
3228
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
4702static struct platform_device *charm_devices[] __initdata = {
4703 &msm_charm_modem,
4704#ifdef CONFIG_MSM_SDIO_AL
4705 &msm_device_sdio_al,
4706#endif
4707};
4708
4709static struct platform_device *surf_devices[] __initdata = {
4710 &msm_device_smd,
4711 &msm_device_uart_dm12,
4712#ifdef CONFIG_I2C_QUP
4713 &msm_gsbi3_qup_i2c_device,
4714 &msm_gsbi4_qup_i2c_device,
4715 &msm_gsbi7_qup_i2c_device,
4716 &msm_gsbi8_qup_i2c_device,
4717 &msm_gsbi9_qup_i2c_device,
4718 &msm_gsbi12_qup_i2c_device,
4719#endif
4720#ifdef CONFIG_SERIAL_MSM_HS
4721 &msm_device_uart_dm1,
4722#endif
4723#ifdef CONFIG_I2C_SSBI
4724 &msm_device_ssbi1,
4725 &msm_device_ssbi2,
4726 &msm_device_ssbi3,
4727#endif
4728#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
4729 &isp1763_device,
4730#endif
4731
4732 &asoc_msm_pcm,
4733 &asoc_msm_dai0,
4734 &asoc_msm_dai1,
4735#if defined (CONFIG_MSM_8x60_VOIP)
4736 &asoc_msm_mvs,
4737 &asoc_mvs_dai0,
4738 &asoc_mvs_dai1,
4739#endif
4740#if defined(CONFIG_USB_GADGET_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
4741 &msm_device_otg,
4742#endif
4743#ifdef CONFIG_USB_GADGET_MSM_72K
4744 &msm_device_gadget_peripheral,
4745#endif
4746#ifdef CONFIG_USB_G_ANDROID
4747 &android_usb_device,
4748#endif
4749#ifdef CONFIG_BATTERY_MSM
4750 &msm_batt_device,
4751#endif
4752#ifdef CONFIG_ANDROID_PMEM
4753 &android_pmem_device,
4754 &android_pmem_adsp_device,
4755 &android_pmem_audio_device,
4756 &android_pmem_smipool_device,
4757#endif
4758#ifdef CONFIG_MSM_ROTATOR
4759 &msm_rotator_device,
4760#endif
4761 &msm_fb_device,
4762 &msm_kgsl_3d0,
4763 &msm_kgsl_2d0,
4764 &msm_kgsl_2d1,
4765 &lcdc_samsung_panel_device,
4766#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
4767 &lcdc_samsung_oled_panel_device,
4768#endif
4769#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
4770 &lcdc_auo_wvga_panel_device,
4771#endif
4772#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
4773 &hdmi_msm_device,
4774#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
4775#ifdef CONFIG_FB_MSM_MIPI_DSI
4776 &mipi_dsi_toshiba_panel_device,
4777 &mipi_dsi_novatek_panel_device,
4778#endif
4779#ifdef CONFIG_MSM_CAMERA
4780#ifdef CONFIG_MT9E013
4781 &msm_camera_sensor_mt9e013,
4782#endif
4783#ifdef CONFIG_IMX074
4784 &msm_camera_sensor_imx074,
4785#endif
4786#ifdef CONFIG_WEBCAM_OV7692
4787 &msm_camera_sensor_webcam_ov7692,
4788#endif
4789#ifdef CONFIG_WEBCAM_OV9726
4790 &msm_camera_sensor_webcam_ov9726,
4791#endif
4792#ifdef CONFIG_QS_S5K4E1
4793 &msm_camera_sensor_qs_s5k4e1,
4794#endif
4795#endif
4796#ifdef CONFIG_MSM_GEMINI
4797 &msm_gemini_device,
4798#endif
4799#ifdef CONFIG_MSM_VPE
4800 &msm_vpe_device,
4801#endif
4802
4803#if defined(CONFIG_MSM_RPM_LOG) || defined(CONFIG_MSM_RPM_LOG_MODULE)
4804 &msm_rpm_log_device,
4805#endif
4806#if defined(CONFIG_MSM_RPM_STATS_LOG)
4807 &msm_rpm_stat_device,
4808#endif
4809 &msm_device_vidc,
4810#if (defined(CONFIG_MARIMBA_CORE)) && \
4811 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4812 &msm_bt_power_device,
4813#endif
4814#ifdef CONFIG_SENSORS_MSM_ADC
4815 &msm_adc_device,
4816#endif
4817#ifdef CONFIG_PMIC8058
4818 &rpm_vreg_device[RPM_VREG_ID_PM8058_L0],
4819 &rpm_vreg_device[RPM_VREG_ID_PM8058_L1],
4820 &rpm_vreg_device[RPM_VREG_ID_PM8058_L2],
4821 &rpm_vreg_device[RPM_VREG_ID_PM8058_L3],
4822 &rpm_vreg_device[RPM_VREG_ID_PM8058_L4],
4823 &rpm_vreg_device[RPM_VREG_ID_PM8058_L5],
4824 &rpm_vreg_device[RPM_VREG_ID_PM8058_L6],
4825 &rpm_vreg_device[RPM_VREG_ID_PM8058_L7],
4826 &rpm_vreg_device[RPM_VREG_ID_PM8058_L8],
4827 &rpm_vreg_device[RPM_VREG_ID_PM8058_L9],
4828 &rpm_vreg_device[RPM_VREG_ID_PM8058_L10],
4829 &rpm_vreg_device[RPM_VREG_ID_PM8058_L11],
4830 &rpm_vreg_device[RPM_VREG_ID_PM8058_L12],
4831 &rpm_vreg_device[RPM_VREG_ID_PM8058_L13],
4832 &rpm_vreg_device[RPM_VREG_ID_PM8058_L14],
4833 &rpm_vreg_device[RPM_VREG_ID_PM8058_L15],
4834 &rpm_vreg_device[RPM_VREG_ID_PM8058_L16],
4835 &rpm_vreg_device[RPM_VREG_ID_PM8058_L17],
4836 &rpm_vreg_device[RPM_VREG_ID_PM8058_L18],
4837 &rpm_vreg_device[RPM_VREG_ID_PM8058_L19],
4838 &rpm_vreg_device[RPM_VREG_ID_PM8058_L20],
4839 &rpm_vreg_device[RPM_VREG_ID_PM8058_L21],
4840 &rpm_vreg_device[RPM_VREG_ID_PM8058_L22],
4841 &rpm_vreg_device[RPM_VREG_ID_PM8058_L23],
4842 &rpm_vreg_device[RPM_VREG_ID_PM8058_L24],
4843 &rpm_vreg_device[RPM_VREG_ID_PM8058_L25],
4844 &rpm_vreg_device[RPM_VREG_ID_PM8058_S2],
4845 &rpm_vreg_device[RPM_VREG_ID_PM8058_S3],
4846 &rpm_vreg_device[RPM_VREG_ID_PM8058_S4],
4847 &rpm_vreg_device[RPM_VREG_ID_PM8058_LVS0],
4848 &rpm_vreg_device[RPM_VREG_ID_PM8058_LVS1],
4849 &rpm_vreg_device[RPM_VREG_ID_PM8058_NCP],
4850#endif
4851#ifdef CONFIG_PMIC8901
4852 &rpm_vreg_device[RPM_VREG_ID_PM8901_L0],
4853 &rpm_vreg_device[RPM_VREG_ID_PM8901_L1],
4854 &rpm_vreg_device[RPM_VREG_ID_PM8901_L2],
4855 &rpm_vreg_device[RPM_VREG_ID_PM8901_L3],
4856 &rpm_vreg_device[RPM_VREG_ID_PM8901_L4],
4857 &rpm_vreg_device[RPM_VREG_ID_PM8901_L5],
4858 &rpm_vreg_device[RPM_VREG_ID_PM8901_L6],
4859 &rpm_vreg_device[RPM_VREG_ID_PM8901_S2],
4860 &rpm_vreg_device[RPM_VREG_ID_PM8901_S3],
4861 &rpm_vreg_device[RPM_VREG_ID_PM8901_S4],
4862 &rpm_vreg_device[RPM_VREG_ID_PM8901_LVS0],
4863 &rpm_vreg_device[RPM_VREG_ID_PM8901_LVS1],
4864 &rpm_vreg_device[RPM_VREG_ID_PM8901_LVS2],
4865 &rpm_vreg_device[RPM_VREG_ID_PM8901_LVS3],
4866 &rpm_vreg_device[RPM_VREG_ID_PM8901_MVS0],
4867#endif
4868
4869#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
4870 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
4871 &qcrypto_device,
4872#endif
4873
4874#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
4875 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
4876 &qcedev_device,
4877#endif
4878
4879#ifdef CONFIG_MSM_SDIO_AL
4880 &msm_device_sdio_al,
4881#endif
4882
4883#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
4884#ifdef CONFIG_MSM_USE_TSIF1
4885 &msm_device_tsif[1],
4886#else
4887 &msm_device_tsif[0],
4888#endif /* CONFIG_MSM_USE_TSIF1 */
4889#endif /* CONFIG_TSIF */
4890
4891#ifdef CONFIG_HW_RANDOM_MSM
4892 &msm_device_rng,
4893#endif
4894
4895 &msm_tsens_device,
4896
4897};
4898
4899static struct memtype_reserve msm8x60_reserve_table[] __initdata = {
4900 /* Kernel SMI memory pool for video core, used for firmware */
4901 /* and encoder, decoder scratch buffers */
4902 /* Kernel SMI memory pool should always precede the user space */
4903 /* SMI memory pool, as the video core will use offset address */
4904 /* from the Firmware base */
4905 [MEMTYPE_SMI_KERNEL] = {
4906 .start = KERNEL_SMI_BASE,
4907 .limit = KERNEL_SMI_SIZE,
4908 .size = KERNEL_SMI_SIZE,
4909 .flags = MEMTYPE_FLAGS_FIXED,
4910 },
4911 /* User space SMI memory pool for video core */
4912 /* used for encoder, decoder input & output buffers */
4913 [MEMTYPE_SMI] = {
4914 .start = USER_SMI_BASE,
4915 .limit = USER_SMI_SIZE,
4916 .flags = MEMTYPE_FLAGS_FIXED,
4917 },
4918 [MEMTYPE_EBI0] = {
4919 .flags = MEMTYPE_FLAGS_1M_ALIGN,
4920 },
4921 [MEMTYPE_EBI1] = {
4922 .flags = MEMTYPE_FLAGS_1M_ALIGN,
4923 },
4924};
4925
4926static void __init size_pmem_devices(void)
4927{
4928#ifdef CONFIG_ANDROID_PMEM
4929 android_pmem_adsp_pdata.size = pmem_adsp_size;
4930 android_pmem_smipool_pdata.size = MSM_PMEM_SMIPOOL_SIZE;
4931 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
4932 android_pmem_pdata.size = pmem_sf_size;
4933#endif
4934}
4935
4936static void __init reserve_memory_for(struct android_pmem_platform_data *p)
4937{
4938 msm8x60_reserve_table[p->memory_type].size += p->size;
4939}
4940
4941static void __init reserve_pmem_memory(void)
4942{
4943#ifdef CONFIG_ANDROID_PMEM
4944 reserve_memory_for(&android_pmem_adsp_pdata);
4945 reserve_memory_for(&android_pmem_smipool_pdata);
4946 reserve_memory_for(&android_pmem_audio_pdata);
4947 reserve_memory_for(&android_pmem_pdata);
4948 msm8x60_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
4949#endif
4950}
4951
4952static void __init msm8x60_calculate_reserve_sizes(void)
4953{
4954 size_pmem_devices();
4955 reserve_pmem_memory();
4956}
4957
4958static int msm8x60_paddr_to_memtype(unsigned int paddr)
4959{
4960 if (paddr >= 0x40000000 && paddr < 0x60000000)
4961 return MEMTYPE_EBI1;
4962 if (paddr >= 0x38000000 && paddr < 0x40000000)
4963 return MEMTYPE_SMI;
4964 return MEMTYPE_NONE;
4965}
4966
4967static struct reserve_info msm8x60_reserve_info __initdata = {
4968 .memtype_reserve_table = msm8x60_reserve_table,
4969 .calculate_reserve_sizes = msm8x60_calculate_reserve_sizes,
4970 .paddr_to_memtype = msm8x60_paddr_to_memtype,
4971};
4972
4973static void __init msm8x60_reserve(void)
4974{
4975 reserve_info = &msm8x60_reserve_info;
4976 msm_reserve();
4977}
4978
4979#define EXT_CHG_VALID_MPP 10
4980#define EXT_CHG_VALID_MPP_2 11
4981
4982#ifdef CONFIG_ISL9519_CHARGER
4983static int isl_detection_setup(void)
4984{
4985 int ret = 0;
4986
4987 ret = pm8058_mpp_config_digital_in(EXT_CHG_VALID_MPP,
4988 PM8058_MPP_DIG_LEVEL_S3,
4989 PM_MPP_DIN_TO_INT);
4990 ret |= pm8058_mpp_config_bi_dir(EXT_CHG_VALID_MPP_2,
4991 PM8058_MPP_DIG_LEVEL_S3,
4992 PM_MPP_BI_PULLUP_10KOHM
4993 );
4994 return ret;
4995}
4996
4997static struct isl_platform_data isl_data __initdata = {
4998 .chgcurrent = 700,
4999 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5000 .chg_detection_config = isl_detection_setup,
5001 .max_system_voltage = 4200,
5002 .min_system_voltage = 3200,
5003 .term_current = 120,
5004 .input_current = 2048,
5005};
5006
5007static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
5008 {
5009 I2C_BOARD_INFO("isl9519q", 0x9),
5010 .irq = PM8058_CBLPWR_IRQ(PM8058_IRQ_BASE),
5011 .platform_data = &isl_data,
5012 },
5013};
5014#endif
5015
5016#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
5017static int smb137b_detection_setup(void)
5018{
5019 int ret = 0;
5020
5021 ret = pm8058_mpp_config_digital_in(EXT_CHG_VALID_MPP,
5022 PM8058_MPP_DIG_LEVEL_S3,
5023 PM_MPP_DIN_TO_INT);
5024 ret |= pm8058_mpp_config_bi_dir(EXT_CHG_VALID_MPP_2,
5025 PM8058_MPP_DIG_LEVEL_S3,
5026 PM_MPP_BI_PULLUP_10KOHM);
5027 return ret;
5028}
5029
5030static struct smb137b_platform_data smb137b_data __initdata = {
5031 .chg_detection_config = smb137b_detection_setup,
5032 .valid_n_gpio = PM8058_MPP_PM_TO_SYS(10),
5033 .batt_mah_rating = 950,
5034};
5035
5036static struct i2c_board_info smb137b_charger_i2c_info[] __initdata = {
5037 {
5038 I2C_BOARD_INFO("smb137b", 0x08),
5039 .irq = PM8058_CBLPWR_IRQ(PM8058_IRQ_BASE),
5040 .platform_data = &smb137b_data,
5041 },
5042};
5043#endif
5044
5045#ifdef CONFIG_PMIC8058
5046#define PMIC_GPIO_SDC3_DET 22
5047
5048static int pm8058_gpios_init(void)
5049{
5050 int i;
5051 int rc;
5052 struct pm8058_gpio_cfg {
5053 int gpio;
5054 struct pm8058_gpio cfg;
5055 };
5056
5057 struct pm8058_gpio_cfg gpio_cfgs[] = {
5058 { /* FFA ethernet */
5059 6,
5060 {
5061 .direction = PM_GPIO_DIR_IN,
5062 .pull = PM_GPIO_PULL_DN,
5063 .vin_sel = 2,
5064 .function = PM_GPIO_FUNC_NORMAL,
5065 .inv_int_pol = 0,
5066 },
5067 },
5068#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
5069 {
5070 PMIC_GPIO_SDC3_DET - 1,
5071 {
5072 .direction = PM_GPIO_DIR_IN,
5073 .pull = PM_GPIO_PULL_UP_30,
5074 .vin_sel = 2,
5075 .function = PM_GPIO_FUNC_NORMAL,
5076 .inv_int_pol = 0,
5077 },
5078 },
5079#endif
5080 { /* core&surf gpio expander */
5081 UI_INT1_N,
5082 {
5083 .direction = PM_GPIO_DIR_IN,
5084 .pull = PM_GPIO_PULL_NO,
5085 .vin_sel = PM_GPIO_VIN_S3,
5086 .function = PM_GPIO_FUNC_NORMAL,
5087 .inv_int_pol = 0,
5088 },
5089 },
5090 { /* docking gpio expander */
5091 UI_INT2_N,
5092 {
5093 .direction = PM_GPIO_DIR_IN,
5094 .pull = PM_GPIO_PULL_NO,
5095 .vin_sel = PM_GPIO_VIN_S3,
5096 .function = PM_GPIO_FUNC_NORMAL,
5097 .inv_int_pol = 0,
5098 },
5099 },
5100 { /* FHA/keypad gpio expanders */
5101 UI_INT3_N,
5102 {
5103 .direction = PM_GPIO_DIR_IN,
5104 .pull = PM_GPIO_PULL_NO,
5105 .vin_sel = PM_GPIO_VIN_S3,
5106 .function = PM_GPIO_FUNC_NORMAL,
5107 .inv_int_pol = 0,
5108 },
5109 },
5110 { /* TouchDisc Interrupt */
5111 5,
5112 {
5113 .direction = PM_GPIO_DIR_IN,
5114 .pull = PM_GPIO_PULL_UP_1P5,
5115 .vin_sel = 2,
5116 .function = PM_GPIO_FUNC_NORMAL,
5117 .inv_int_pol = 0,
5118 }
5119 },
5120 { /* Timpani Reset */
5121 20,
5122 {
5123 .direction = PM_GPIO_DIR_OUT,
5124 .output_value = 1,
5125 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5126 .pull = PM_GPIO_PULL_DN,
5127 .out_strength = PM_GPIO_STRENGTH_HIGH,
5128 .function = PM_GPIO_FUNC_NORMAL,
5129 .vin_sel = 2,
5130 .inv_int_pol = 0,
5131 }
5132 },
5133 { /* PMIC ID interrupt */
5134 36,
5135 {
5136 .direction = PM_GPIO_DIR_IN,
5137 .pull = PM_GPIO_PULL_UP_1P5,
5138 .function = PM_GPIO_FUNC_NORMAL,
5139 .vin_sel = 2,
5140 .inv_int_pol = 0,
5141 }
5142 },
5143 };
5144
5145#if defined(CONFIG_HAPTIC_ISA1200) || \
5146 defined(CONFIG_HAPTIC_ISA1200_MODULE)
5147
5148 struct pm8058_gpio_cfg en_hap_gpio_cfg = {
5149 PMIC_GPIO_HAP_ENABLE,
5150 {
5151 .direction = PM_GPIO_DIR_OUT,
5152 .pull = PM_GPIO_PULL_NO,
5153 .out_strength = PM_GPIO_STRENGTH_HIGH,
5154 .function = PM_GPIO_FUNC_NORMAL,
5155 .inv_int_pol = 0,
5156 .vin_sel = 2,
5157 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5158 .output_value = 0,
5159 }
5160
5161 };
5162#endif
5163
5164#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5165 struct pm8058_gpio_cfg line_in_gpio_cfg = {
5166 18,
5167 {
5168 .direction = PM_GPIO_DIR_IN,
5169 .pull = PM_GPIO_PULL_UP_1P5,
5170 .vin_sel = 2,
5171 .function = PM_GPIO_FUNC_NORMAL,
5172 .inv_int_pol = 0,
5173 }
5174 };
5175#endif
5176
5177#if defined(CONFIG_QS_S5K4E1)
5178 {
5179 struct pm8058_gpio_cfg qs_hc37_cam_pd_gpio_cfg = {
5180 26,
5181 {
5182 .direction = PM_GPIO_DIR_OUT,
5183 .output_value = 0,
5184 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5185 .pull = PM_GPIO_PULL_DN,
5186 .out_strength = PM_GPIO_STRENGTH_HIGH,
5187 .function = PM_GPIO_FUNC_NORMAL,
5188 .vin_sel = 2,
5189 .inv_int_pol = 0,
5190 }
5191 };
5192#endif
5193
5194#if defined(CONFIG_HAPTIC_ISA1200) || \
5195 defined(CONFIG_HAPTIC_ISA1200_MODULE)
5196 if (machine_is_msm8x60_fluid()) {
5197 rc = pm8058_gpio_config(en_hap_gpio_cfg.gpio,
5198 &en_hap_gpio_cfg.cfg);
5199 if (rc < 0) {
5200 pr_err("%s pmic haptics gpio config failed\n",
5201 __func__);
5202 return rc;
5203 }
5204 }
5205#endif
5206
5207#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5208 /* Line_in only for 8660 ffa & surf */
5209 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_surf() ||
5210 machine_is_msm8x60_fusion() ||
5211 machine_is_msm8x60_fusn_ffa()) {
5212 rc = pm8058_gpio_config(line_in_gpio_cfg.gpio,
5213 &line_in_gpio_cfg.cfg);
5214 if (rc < 0) {
5215 pr_err("%s pmic line_in gpio config failed\n",
5216 __func__);
5217 return rc;
5218 }
5219 }
5220#endif
5221
5222#if defined(CONFIG_QS_S5K4E1)
5223 /* qs_cam_hc37_cam_pd only for 8660 fluid qs camera*/
5224 if (machine_is_msm8x60_fluid()) {
5225 rc = pm8058_gpio_config(qs_hc37_cam_pd_gpio_cfg.gpio,
5226 &qs_hc37_cam_pd_gpio_cfg.cfg);
5227 if (rc < 0) {
5228 pr_err("%s pmic qs_hc37_cam_pd gpio config failed\n",
5229 __func__);
5230 return rc;
5231 }
5232 }
5233 }
5234#endif
5235
5236 for (i = 0; i < ARRAY_SIZE(gpio_cfgs); ++i) {
5237 rc = pm8058_gpio_config(gpio_cfgs[i].gpio,
5238 &gpio_cfgs[i].cfg);
5239 if (rc < 0) {
5240 pr_err("%s pmic gpio config failed\n",
5241 __func__);
5242 return rc;
5243 }
5244 }
5245
5246 return 0;
5247}
5248
5249static const unsigned int ffa_keymap[] = {
5250 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5251 KEY(0, 1, KEY_UP), /* NAV - UP */
5252 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5253 KEY(0, 3, KEY_VOLUMEUP), /* Shuttle SW_UP */
5254
5255 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5256 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5257 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5258 KEY(1, 3, KEY_VOLUMEDOWN),
5259
5260 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5261
5262 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5263 KEY(4, 1, KEY_UP), /* USER_UP */
5264 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5265 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5266 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5267
5268 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
5269 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5270 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5271 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5272 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5273};
5274
5275static struct resource resources_keypad[] = {
5276 {
5277 .start = PM8058_KEYPAD_IRQ(PM8058_IRQ_BASE),
5278 .end = PM8058_KEYPAD_IRQ(PM8058_IRQ_BASE),
5279 .flags = IORESOURCE_IRQ,
5280 },
5281 {
5282 .start = PM8058_KEYSTUCK_IRQ(PM8058_IRQ_BASE),
5283 .end = PM8058_KEYSTUCK_IRQ(PM8058_IRQ_BASE),
5284 .flags = IORESOURCE_IRQ,
5285 },
5286};
5287
5288static struct matrix_keymap_data ffa_keymap_data = {
5289 .keymap_size = ARRAY_SIZE(ffa_keymap),
5290 .keymap = ffa_keymap,
5291};
5292
5293static struct pmic8058_keypad_data ffa_keypad_data = {
5294 .input_name = "ffa-keypad",
5295 .input_phys_device = "ffa-keypad/input0",
5296 .num_rows = 6,
5297 .num_cols = 5,
5298 .rows_gpio_start = 8,
5299 .cols_gpio_start = 0,
5300 .debounce_ms = {8, 10},
5301 .scan_delay_ms = 32,
5302 .row_hold_ns = 91500,
5303 .wakeup = 1,
5304 .keymap_data = &ffa_keymap_data,
5305};
5306
5307static const unsigned int fluid_keymap[] = {
5308 KEY(0, 0, KEY_FN_F1), /* LS - PUSH1 */
5309 KEY(0, 1, KEY_UP), /* NAV - UP */
5310 KEY(0, 2, KEY_LEFT), /* NAV - LEFT */
5311 KEY(0, 3, KEY_VOLUMEDOWN), /* Shuttle SW_UP */
5312
5313 KEY(1, 0, KEY_FN_F2), /* LS - PUSH2 */
5314 KEY(1, 1, KEY_RIGHT), /* NAV - RIGHT */
5315 KEY(1, 2, KEY_DOWN), /* NAV - DOWN */
5316 KEY(1, 3, KEY_VOLUMEUP),
5317
5318 KEY(2, 3, KEY_ENTER), /* SW_PUSH key */
5319
5320 KEY(4, 0, KEY_CAMERA_FOCUS), /* RS - PUSH1 */
5321 KEY(4, 1, KEY_UP), /* USER_UP */
5322 KEY(4, 2, KEY_LEFT), /* USER_LEFT */
5323 KEY(4, 3, KEY_HOME), /* Right switch: MIC Bd */
5324 KEY(4, 4, KEY_FN_F3), /* Reserved MIC */
5325
Jilai Wang9a895102011-07-12 14:00:35 -04005326 KEY(5, 0, KEY_CAMERA), /* RS - PUSH2 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005327 KEY(5, 1, KEY_RIGHT), /* USER_RIGHT */
5328 KEY(5, 2, KEY_DOWN), /* USER_DOWN */
5329 KEY(5, 3, KEY_BACK), /* Left switch: MIC */
5330 KEY(5, 4, KEY_MENU), /* Center switch: MIC */
5331};
5332
5333static struct matrix_keymap_data fluid_keymap_data = {
5334 .keymap_size = ARRAY_SIZE(fluid_keymap),
5335 .keymap = fluid_keymap,
5336};
5337
5338static struct pmic8058_keypad_data fluid_keypad_data = {
5339 .input_name = "fluid-keypad",
5340 .input_phys_device = "fluid-keypad/input0",
5341 .num_rows = 6,
5342 .num_cols = 5,
5343 .rows_gpio_start = 8,
5344 .cols_gpio_start = 0,
5345 .debounce_ms = {8, 10},
5346 .scan_delay_ms = 32,
5347 .row_hold_ns = 91500,
5348 .wakeup = 1,
5349 .keymap_data = &fluid_keymap_data,
5350};
5351
5352static struct resource resources_pwrkey[] = {
5353 {
5354 .start = PM8058_PWRKEY_REL_IRQ(PM8058_IRQ_BASE),
5355 .end = PM8058_PWRKEY_REL_IRQ(PM8058_IRQ_BASE),
5356 .flags = IORESOURCE_IRQ,
5357 },
5358 {
5359 .start = PM8058_PWRKEY_PRESS_IRQ(PM8058_IRQ_BASE),
5360 .end = PM8058_PWRKEY_PRESS_IRQ(PM8058_IRQ_BASE),
5361 .flags = IORESOURCE_IRQ,
5362 },
5363};
5364
5365static struct pmic8058_pwrkey_pdata pwrkey_pdata = {
5366 .pull_up = 1,
5367 .kpd_trigger_delay_us = 970,
5368 .wakeup = 1,
5369 .pwrkey_time_ms = 500,
5370};
5371
5372static struct pmic8058_vibrator_pdata pmic_vib_pdata = {
5373 .initial_vibrate_ms = 500,
5374 .level_mV = 3000,
5375 .max_timeout_ms = 15000,
5376};
5377
5378#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5379#define PM8058_OTHC_CNTR_BASE0 0xA0
5380#define PM8058_OTHC_CNTR_BASE1 0x134
5381#define PM8058_OTHC_CNTR_BASE2 0x137
5382#define PM8058_LINE_IN_DET_GPIO PM8058_GPIO_PM_TO_SYS(18)
5383
5384static struct othc_accessory_info othc_accessories[] = {
5385 {
5386 .accessory = OTHC_SVIDEO_OUT,
5387 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT
5388 | OTHC_ADC_DETECT,
5389 .key_code = SW_VIDEOOUT_INSERT,
5390 .enabled = false,
5391 .adc_thres = {
5392 .min_threshold = 20,
5393 .max_threshold = 40,
5394 },
5395 },
5396 {
5397 .accessory = OTHC_ANC_HEADPHONE,
5398 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT |
5399 OTHC_SWITCH_DETECT,
5400 .gpio = PM8058_LINE_IN_DET_GPIO,
5401 .active_low = 1,
5402 .key_code = SW_HEADPHONE_INSERT,
5403 .enabled = true,
5404 },
5405 {
5406 .accessory = OTHC_ANC_HEADSET,
5407 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT,
5408 .gpio = PM8058_LINE_IN_DET_GPIO,
5409 .active_low = 1,
5410 .key_code = SW_HEADPHONE_INSERT,
5411 .enabled = true,
5412 },
5413 {
5414 .accessory = OTHC_HEADPHONE,
5415 .detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT,
5416 .key_code = SW_HEADPHONE_INSERT,
5417 .enabled = true,
5418 },
5419 {
5420 .accessory = OTHC_MICROPHONE,
5421 .detect_flags = OTHC_GPIO_DETECT,
5422 .gpio = PM8058_LINE_IN_DET_GPIO,
5423 .active_low = 1,
5424 .key_code = SW_MICROPHONE_INSERT,
5425 .enabled = true,
5426 },
5427 {
5428 .accessory = OTHC_HEADSET,
5429 .detect_flags = OTHC_MICBIAS_DETECT,
5430 .key_code = SW_HEADPHONE_INSERT,
5431 .enabled = true,
5432 },
5433};
5434
5435static struct othc_switch_info switch_info[] = {
5436 {
5437 .min_adc_threshold = 0,
5438 .max_adc_threshold = 100,
5439 .key_code = KEY_PLAYPAUSE,
5440 },
5441 {
5442 .min_adc_threshold = 100,
5443 .max_adc_threshold = 200,
5444 .key_code = KEY_REWIND,
5445 },
5446 {
5447 .min_adc_threshold = 200,
5448 .max_adc_threshold = 500,
5449 .key_code = KEY_FASTFORWARD,
5450 },
5451};
5452
5453static struct othc_n_switch_config switch_config = {
5454 .voltage_settling_time_ms = 0,
5455 .num_adc_samples = 3,
5456 .adc_channel = CHANNEL_ADC_HDSET,
5457 .switch_info = switch_info,
5458 .num_keys = ARRAY_SIZE(switch_info),
5459 .default_sw_en = true,
5460 .default_sw_idx = 0,
5461};
5462
5463static struct hsed_bias_config hsed_bias_config = {
5464 /* HSED mic bias config info */
5465 .othc_headset = OTHC_HEADSET_NO,
5466 .othc_lowcurr_thresh_uA = 100,
5467 .othc_highcurr_thresh_uA = 600,
5468 .othc_hyst_prediv_us = 7800,
5469 .othc_period_clkdiv_us = 62500,
5470 .othc_hyst_clk_us = 121000,
5471 .othc_period_clk_us = 312500,
5472 .othc_wakeup = 1,
5473};
5474
5475static struct othc_hsed_config hsed_config_1 = {
5476 .hsed_bias_config = &hsed_bias_config,
5477 /*
5478 * The detection delay and switch reporting delay are
5479 * required to encounter a hardware bug (spurious switch
5480 * interrupts on slow insertion/removal of the headset).
5481 * This will introduce a delay in reporting the accessory
5482 * insertion and removal to the userspace.
5483 */
5484 .detection_delay_ms = 1500,
5485 /* Switch info */
5486 .switch_debounce_ms = 1500,
5487 .othc_support_n_switch = false,
5488 .switch_config = &switch_config,
5489 .ir_gpio = -1,
5490 /* Accessory info */
5491 .accessories_support = true,
5492 .accessories = othc_accessories,
5493 .othc_num_accessories = ARRAY_SIZE(othc_accessories),
5494};
5495
5496static struct othc_regulator_config othc_reg = {
5497 .regulator = "8058_l5",
5498 .max_uV = 2850000,
5499 .min_uV = 2850000,
5500};
5501
5502/* MIC_BIAS0 is configured as normal MIC BIAS */
5503static struct pmic8058_othc_config_pdata othc_config_pdata_0 = {
5504 .micbias_select = OTHC_MICBIAS_0,
5505 .micbias_capability = OTHC_MICBIAS,
5506 .micbias_enable = OTHC_SIGNAL_OFF,
5507 .micbias_regulator = &othc_reg,
5508};
5509
5510/* MIC_BIAS1 is configured as HSED_BIAS for OTHC */
5511static struct pmic8058_othc_config_pdata othc_config_pdata_1 = {
5512 .micbias_select = OTHC_MICBIAS_1,
5513 .micbias_capability = OTHC_MICBIAS_HSED,
5514 .micbias_enable = OTHC_SIGNAL_PWM_TCXO,
5515 .micbias_regulator = &othc_reg,
5516 .hsed_config = &hsed_config_1,
5517 .hsed_name = "8660_handset",
5518};
5519
5520/* MIC_BIAS2 is configured as normal MIC BIAS */
5521static struct pmic8058_othc_config_pdata othc_config_pdata_2 = {
5522 .micbias_select = OTHC_MICBIAS_2,
5523 .micbias_capability = OTHC_MICBIAS,
5524 .micbias_enable = OTHC_SIGNAL_OFF,
5525 .micbias_regulator = &othc_reg,
5526};
5527
5528static struct resource resources_othc_0[] = {
5529 {
5530 .name = "othc_base",
5531 .start = PM8058_OTHC_CNTR_BASE0,
5532 .end = PM8058_OTHC_CNTR_BASE0,
5533 .flags = IORESOURCE_IO,
5534 },
5535};
5536
5537static struct resource resources_othc_1[] = {
5538 {
5539 .start = PM8058_SW_1_IRQ(PM8058_IRQ_BASE),
5540 .end = PM8058_SW_1_IRQ(PM8058_IRQ_BASE),
5541 .flags = IORESOURCE_IRQ,
5542 },
5543 {
5544 .start = PM8058_IR_1_IRQ(PM8058_IRQ_BASE),
5545 .end = PM8058_IR_1_IRQ(PM8058_IRQ_BASE),
5546 .flags = IORESOURCE_IRQ,
5547 },
5548 {
5549 .name = "othc_base",
5550 .start = PM8058_OTHC_CNTR_BASE1,
5551 .end = PM8058_OTHC_CNTR_BASE1,
5552 .flags = IORESOURCE_IO,
5553 },
5554};
5555
5556static struct resource resources_othc_2[] = {
5557 {
5558 .name = "othc_base",
5559 .start = PM8058_OTHC_CNTR_BASE2,
5560 .end = PM8058_OTHC_CNTR_BASE2,
5561 .flags = IORESOURCE_IO,
5562 },
5563};
5564
5565static void __init msm8x60_init_pm8058_othc(void)
5566{
5567 int i;
5568
5569 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 ||
5570 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
5571 machine_is_msm8x60_fusn_ffa()) {
5572 /* 3-switch headset supported only by V2 FFA and FLUID */
5573 hsed_config_1.accessories_adc_support = true,
5574 /* ADC based accessory detection works only on V2 and FLUID */
5575 hsed_config_1.accessories_adc_channel = CHANNEL_ADC_HDSET,
5576 hsed_config_1.othc_support_n_switch = true;
5577 }
5578
5579 /* IR GPIO is absent on FLUID */
5580 if (machine_is_msm8x60_fluid())
5581 hsed_config_1.ir_gpio = -1;
5582
5583 for (i = 0; i < ARRAY_SIZE(othc_accessories); i++) {
5584 if (machine_is_msm8x60_fluid()) {
5585 switch (othc_accessories[i].accessory) {
5586 case OTHC_ANC_HEADPHONE:
5587 case OTHC_ANC_HEADSET:
5588 othc_accessories[i].gpio = GPIO_HEADSET_DET_N;
5589 break;
5590 case OTHC_MICROPHONE:
5591 othc_accessories[i].enabled = false;
5592 break;
5593 case OTHC_SVIDEO_OUT:
5594 othc_accessories[i].enabled = true;
5595 hsed_config_1.video_out_gpio = GPIO_HS_SW_DIR;
5596 break;
5597 }
5598 }
5599 }
5600}
5601#endif
5602
5603static struct resource resources_pm8058_charger[] = {
5604 { .name = "CHGVAL",
5605 .start = PM8058_CHGVAL_IRQ(PM8058_IRQ_BASE),
5606 .end = PM8058_CHGVAL_IRQ(PM8058_IRQ_BASE),
5607 .flags = IORESOURCE_IRQ,
5608 },
5609 { .name = "CHGINVAL",
5610 .start = PM8058_CHGINVAL_IRQ(PM8058_IRQ_BASE),
5611 .end = PM8058_CHGINVAL_IRQ(PM8058_IRQ_BASE),
5612 .flags = IORESOURCE_IRQ,
5613 },
5614 {
5615 .name = "CHGILIM",
5616 .start = PM8058_CHGILIM_IRQ(PM8058_IRQ_BASE),
5617 .end = PM8058_CHGILIM_IRQ(PM8058_IRQ_BASE),
5618 .flags = IORESOURCE_IRQ,
5619 },
5620 {
5621 .name = "VCP",
5622 .start = PM8058_VCP_IRQ(PM8058_IRQ_BASE),
5623 .end = PM8058_VCP_IRQ(PM8058_IRQ_BASE),
5624 .flags = IORESOURCE_IRQ,
5625 },
5626 {
5627 .name = "ATC_DONE",
5628 .start = PM8058_ATC_DONE_IRQ(PM8058_IRQ_BASE),
5629 .end = PM8058_ATC_DONE_IRQ(PM8058_IRQ_BASE),
5630 .flags = IORESOURCE_IRQ,
5631 },
5632 {
5633 .name = "ATCFAIL",
5634 .start = PM8058_ATCFAIL_IRQ(PM8058_IRQ_BASE),
5635 .end = PM8058_ATCFAIL_IRQ(PM8058_IRQ_BASE),
5636 .flags = IORESOURCE_IRQ,
5637 },
5638 {
5639 .name = "AUTO_CHGDONE",
5640 .start = PM8058_AUTO_CHGDONE_IRQ(PM8058_IRQ_BASE),
5641 .end = PM8058_AUTO_CHGDONE_IRQ(PM8058_IRQ_BASE),
5642 .flags = IORESOURCE_IRQ,
5643 },
5644 {
5645 .name = "AUTO_CHGFAIL",
5646 .start = PM8058_AUTO_CHGFAIL_IRQ(PM8058_IRQ_BASE),
5647 .end = PM8058_AUTO_CHGFAIL_IRQ(PM8058_IRQ_BASE),
5648 .flags = IORESOURCE_IRQ,
5649 },
5650 {
5651 .name = "CHGSTATE",
5652 .start = PM8058_CHGSTATE_IRQ(PM8058_IRQ_BASE),
5653 .end = PM8058_CHGSTATE_IRQ(PM8058_IRQ_BASE),
5654 .flags = IORESOURCE_IRQ,
5655 },
5656 {
5657 .name = "FASTCHG",
5658 .start = PM8058_FASTCHG_IRQ(PM8058_IRQ_BASE),
5659 .end = PM8058_FASTCHG_IRQ(PM8058_IRQ_BASE),
5660 .flags = IORESOURCE_IRQ,
5661 },
5662 {
5663 .name = "CHG_END",
5664 .start = PM8058_CHG_END_IRQ(PM8058_IRQ_BASE),
5665 .end = PM8058_CHG_END_IRQ(PM8058_IRQ_BASE),
5666 .flags = IORESOURCE_IRQ,
5667 },
5668 {
5669 .name = "BATTTEMP",
5670 .start = PM8058_BATTTEMP_IRQ(PM8058_IRQ_BASE),
5671 .end = PM8058_BATTTEMP_IRQ(PM8058_IRQ_BASE),
5672 .flags = IORESOURCE_IRQ,
5673 },
5674 {
5675 .name = "CHGHOT",
5676 .start = PM8058_CHGHOT_IRQ(PM8058_IRQ_BASE),
5677 .end = PM8058_CHGHOT_IRQ(PM8058_IRQ_BASE),
5678 .flags = IORESOURCE_IRQ,
5679 },
5680 {
5681 .name = "CHGTLIMIT",
5682 .start = PM8058_CHGTLIMIT_IRQ(PM8058_IRQ_BASE),
5683 .end = PM8058_CHGTLIMIT_IRQ(PM8058_IRQ_BASE),
5684 .flags = IORESOURCE_IRQ,
5685 },
5686 {
5687 .name = "CHG_GONE",
5688 .start = PM8058_CHG_GONE_IRQ(PM8058_IRQ_BASE),
5689 .end = PM8058_CHG_GONE_IRQ(PM8058_IRQ_BASE),
5690 .flags = IORESOURCE_IRQ,
5691 },
5692 {
5693 .name = "VCPMAJOR",
5694 .start = PM8058_VCPMAJOR_IRQ(PM8058_IRQ_BASE),
5695 .end = PM8058_VCPMAJOR_IRQ(PM8058_IRQ_BASE),
5696 .flags = IORESOURCE_IRQ,
5697 },
5698 {
5699 .name = "VBATDET",
5700 .start = PM8058_VBATDET_IRQ(PM8058_IRQ_BASE),
5701 .end = PM8058_VBATDET_IRQ(PM8058_IRQ_BASE),
5702 .flags = IORESOURCE_IRQ,
5703 },
5704 {
5705 .name = "BATFET",
5706 .start = PM8058_BATFET_IRQ(PM8058_IRQ_BASE),
5707 .end = PM8058_BATFET_IRQ(PM8058_IRQ_BASE),
5708 .flags = IORESOURCE_IRQ,
5709 },
5710 {
5711 .name = "BATT_REPLACE",
5712 .start = PM8058_BATT_REPLACE_IRQ(PM8058_IRQ_BASE),
5713 .end = PM8058_BATT_REPLACE_IRQ(PM8058_IRQ_BASE),
5714 .flags = IORESOURCE_IRQ,
5715 },
5716 {
5717 .name = "BATTCONNECT",
5718 .start = PM8058_BATTCONNECT_IRQ(PM8058_IRQ_BASE),
5719 .end = PM8058_BATTCONNECT_IRQ(PM8058_IRQ_BASE),
5720 .flags = IORESOURCE_IRQ,
5721 },
5722 {
5723 .name = "VBATDET_LOW",
5724 .start = PM8058_VBATDET_LOW_IRQ(PM8058_IRQ_BASE),
5725 .end = PM8058_VBATDET_LOW_IRQ(PM8058_IRQ_BASE),
5726 .flags = IORESOURCE_IRQ,
5727 },
5728};
5729
5730static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
5731{
5732 struct pm8058_gpio pwm_gpio_config = {
5733 .direction = PM_GPIO_DIR_OUT,
5734 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
5735 .output_value = 0,
5736 .pull = PM_GPIO_PULL_NO,
5737 .vin_sel = PM_GPIO_VIN_VPH,
5738 .out_strength = PM_GPIO_STRENGTH_HIGH,
5739 .function = PM_GPIO_FUNC_2,
5740 };
5741
5742 int rc = -EINVAL;
5743 int id, mode, max_mA;
5744
5745 id = mode = max_mA = 0;
5746 switch (ch) {
5747 case 0:
5748 case 1:
5749 case 2:
5750 if (on) {
5751 id = 24 + ch;
5752 rc = pm8058_gpio_config(id - 1, &pwm_gpio_config);
5753 if (rc)
5754 pr_err("%s: pm8058_gpio_config(%d): rc=%d\n",
5755 __func__, id, rc);
5756 }
5757 break;
5758
5759 case 6:
5760 id = PM_PWM_LED_FLASH;
5761 mode = PM_PWM_CONF_PWM1;
5762 max_mA = 300;
5763 break;
5764
5765 case 7:
5766 id = PM_PWM_LED_FLASH1;
5767 mode = PM_PWM_CONF_PWM1;
5768 max_mA = 300;
5769 break;
5770
5771 default:
5772 break;
5773 }
5774
5775 if (ch >= 6 && ch <= 7) {
5776 if (!on) {
5777 mode = PM_PWM_CONF_NONE;
5778 max_mA = 0;
5779 }
5780 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
5781 if (rc)
5782 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
5783 __func__, ch, rc);
5784 }
5785 return rc;
5786
5787}
5788
5789static struct pm8058_pwm_pdata pm8058_pwm_data = {
5790 .config = pm8058_pwm_config,
5791};
5792
5793#define PM8058_GPIO_INT 88
5794
5795static struct pm8058_gpio_platform_data pm8058_gpio_data = {
5796 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
5797 .irq_base = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 0),
5798 .init = pm8058_gpios_init,
5799};
5800
5801static struct pm8058_gpio_platform_data pm8058_mpp_data = {
5802 .gpio_base = PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS),
5803 .irq_base = PM8058_MPP_IRQ(PM8058_IRQ_BASE, 0),
5804};
5805
5806static struct resource resources_rtc[] = {
5807 {
5808 .start = PM8058_RTC_IRQ(PM8058_IRQ_BASE),
5809 .end = PM8058_RTC_IRQ(PM8058_IRQ_BASE),
5810 .flags = IORESOURCE_IRQ,
5811 },
5812 {
5813 .start = PM8058_RTC_ALARM_IRQ(PM8058_IRQ_BASE),
5814 .end = PM8058_RTC_ALARM_IRQ(PM8058_IRQ_BASE),
5815 .flags = IORESOURCE_IRQ,
5816 },
5817};
5818
Ashay Jaiswal4d1ab552011-07-15 11:30:49 +05305819static struct pm8058_rtc_platform_data pm8058_rtc_pdata = {
5820 .rtc_alarm_powerup = false,
5821};
5822
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005823static struct pmic8058_led pmic8058_flash_leds[] = {
5824 [0] = {
5825 .name = "camera:flash0",
5826 .max_brightness = 15,
5827 .id = PMIC8058_ID_FLASH_LED_0,
5828 },
5829 [1] = {
5830 .name = "camera:flash1",
5831 .max_brightness = 15,
5832 .id = PMIC8058_ID_FLASH_LED_1,
5833 },
5834};
5835
5836static struct pmic8058_leds_platform_data pm8058_flash_leds_data = {
5837 .num_leds = ARRAY_SIZE(pmic8058_flash_leds),
5838 .leds = pmic8058_flash_leds,
5839};
5840
5841static struct pmic8058_led pmic8058_fluid_flash_leds[] = {
5842 [0] = {
5843 .name = "led:drv0",
5844 .max_brightness = 15,
5845 .id = PMIC8058_ID_FLASH_LED_0,
5846 },/* 300 mA flash led0 drv sink */
5847 [1] = {
5848 .name = "led:drv1",
5849 .max_brightness = 15,
5850 .id = PMIC8058_ID_FLASH_LED_1,
5851 },/* 300 mA flash led1 sink */
5852 [2] = {
5853 .name = "led:drv2",
5854 .max_brightness = 20,
5855 .id = PMIC8058_ID_LED_0,
5856 },/* 40 mA led0 sink */
5857 [3] = {
5858 .name = "keypad:drv",
5859 .max_brightness = 15,
5860 .id = PMIC8058_ID_LED_KB_LIGHT,
5861 },/* 300 mA keypad drv sink */
5862};
5863
5864static struct pmic8058_leds_platform_data pm8058_fluid_flash_leds_data = {
5865 .num_leds = ARRAY_SIZE(pmic8058_fluid_flash_leds),
5866 .leds = pmic8058_fluid_flash_leds,
5867};
5868
5869static struct resource resources_temp_alarm[] = {
5870 {
5871 .start = PM8058_TEMP_ALARM_IRQ(PM8058_IRQ_BASE),
5872 .end = PM8058_TEMP_ALARM_IRQ(PM8058_IRQ_BASE),
5873 .flags = IORESOURCE_IRQ,
5874 },
5875};
5876
5877static struct resource resources_pm8058_misc[] = {
5878 {
5879 .start = PM8058_OSCHALT_IRQ(PM8058_IRQ_BASE),
5880 .end = PM8058_OSCHALT_IRQ(PM8058_IRQ_BASE),
5881 .flags = IORESOURCE_IRQ,
5882 },
5883};
5884
5885static struct resource resources_pm8058_batt_alarm[] = {
5886 {
5887 .start = PM8058_BATT_ALARM_IRQ(PM8058_IRQ_BASE),
5888 .end = PM8058_BATT_ALARM_IRQ(PM8058_IRQ_BASE),
5889 .flags = IORESOURCE_IRQ,
5890 },
5891};
5892
5893#define PM8058_SUBDEV_KPD 0
5894#define PM8058_SUBDEV_LED 1
5895#define PM8058_SUBDEV_VIB 2
5896
5897static struct mfd_cell pm8058_subdevs[] = {
5898 {
5899 .name = "pm8058-keypad",
5900 .id = -1,
5901 .num_resources = ARRAY_SIZE(resources_keypad),
5902 .resources = resources_keypad,
5903 },
5904 { .name = "pm8058-led",
5905 .id = -1,
5906 },
5907 {
5908 .name = "pm8058-vib",
5909 .id = -1,
5910 },
5911 { .name = "pm8058-gpio",
5912 .id = -1,
5913 .platform_data = &pm8058_gpio_data,
5914 .pdata_size = sizeof(pm8058_gpio_data),
5915 },
5916 { .name = "pm8058-mpp",
5917 .id = -1,
5918 .platform_data = &pm8058_mpp_data,
5919 .pdata_size = sizeof(pm8058_mpp_data),
5920 },
5921 { .name = "pm8058-pwrkey",
5922 .id = -1,
5923 .resources = resources_pwrkey,
5924 .num_resources = ARRAY_SIZE(resources_pwrkey),
5925 .platform_data = &pwrkey_pdata,
5926 .pdata_size = sizeof(pwrkey_pdata),
5927 },
5928 {
5929 .name = "pm8058-pwm",
5930 .id = -1,
5931 .platform_data = &pm8058_pwm_data,
5932 .pdata_size = sizeof(pm8058_pwm_data),
5933 },
5934#ifdef CONFIG_SENSORS_MSM_ADC
5935 {
5936 .name = "pm8058-xoadc",
5937 .id = -1,
5938 .num_resources = ARRAY_SIZE(resources_adc),
5939 .resources = resources_adc,
5940 .platform_data = &xoadc_pdata,
5941 .pdata_size = sizeof(xoadc_pdata),
5942 },
5943#endif
5944#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
5945 {
5946 .name = "pm8058-othc",
5947 .id = 0,
5948 .platform_data = &othc_config_pdata_0,
5949 .pdata_size = sizeof(othc_config_pdata_0),
5950 .num_resources = ARRAY_SIZE(resources_othc_0),
5951 .resources = resources_othc_0,
5952 },
5953 {
5954 /* OTHC1 module has headset/switch dection */
5955 .name = "pm8058-othc",
5956 .id = 1,
5957 .num_resources = ARRAY_SIZE(resources_othc_1),
5958 .resources = resources_othc_1,
5959 .platform_data = &othc_config_pdata_1,
5960 .pdata_size = sizeof(othc_config_pdata_1),
5961 },
5962 {
5963 .name = "pm8058-othc",
5964 .id = 2,
5965 .platform_data = &othc_config_pdata_2,
5966 .pdata_size = sizeof(othc_config_pdata_2),
5967 .num_resources = ARRAY_SIZE(resources_othc_2),
5968 .resources = resources_othc_2,
5969 },
5970#endif
5971 {
5972 .name = "pm8058-rtc",
5973 .id = -1,
5974 .num_resources = ARRAY_SIZE(resources_rtc),
5975 .resources = resources_rtc,
Ashay Jaiswal4d1ab552011-07-15 11:30:49 +05305976 .platform_data = &pm8058_rtc_pdata,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005977 },
5978 {
5979 .name = "pm8058-tm",
5980 .id = -1,
5981 .num_resources = ARRAY_SIZE(resources_temp_alarm),
5982 .resources = resources_temp_alarm,
5983 },
5984 { .name = "pm8058-upl",
5985 .id = -1,
5986 },
5987 {
5988 .name = "pm8058-misc",
5989 .id = -1,
5990 .num_resources = ARRAY_SIZE(resources_pm8058_misc),
5991 .resources = resources_pm8058_misc,
5992 },
5993 { .name = "pm8058-batt-alarm",
5994 .id = -1,
5995 .num_resources = ARRAY_SIZE(resources_pm8058_batt_alarm),
5996 .resources = resources_pm8058_batt_alarm,
5997 },
5998};
5999
6000static struct mfd_cell pm8058_charger_sub_dev = {
6001 .name = "pm8058-charger",
6002 .id = -1,
6003 .num_resources = ARRAY_SIZE(resources_pm8058_charger),
6004 .resources = resources_pm8058_charger,
6005};
6006
6007static struct pm8058_platform_data pm8058_platform_data = {
6008 .irq_base = PM8058_IRQ_BASE,
6009
6010 .num_subdevs = ARRAY_SIZE(pm8058_subdevs),
6011 .sub_devices = pm8058_subdevs,
6012 .irq_trigger_flags = IRQF_TRIGGER_LOW,
6013};
6014
6015static struct i2c_board_info pm8058_boardinfo[] __initdata = {
6016 {
6017 I2C_BOARD_INFO("pm8058-core", 0x55),
6018 .irq = MSM_GPIO_TO_INT(PM8058_GPIO_INT),
6019 .platform_data = &pm8058_platform_data,
6020 },
6021};
6022#endif /* CONFIG_PMIC8058 */
6023
6024#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
6025 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
6026#define TDISC_I2C_SLAVE_ADDR 0x67
6027#define PMIC_GPIO_TDISC PM8058_GPIO_PM_TO_SYS(5)
6028#define TDISC_INT PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 5)
6029
6030static const char *vregs_tdisc_name[] = {
6031 "8058_l5",
6032 "8058_s3",
6033};
6034
6035static const int vregs_tdisc_val[] = {
6036 2850000,/* uV */
6037 1800000,
6038};
6039static struct regulator *vregs_tdisc[ARRAY_SIZE(vregs_tdisc_name)];
6040
6041static int tdisc_shinetsu_setup(void)
6042{
6043 int rc, i;
6044
6045 rc = gpio_request(PMIC_GPIO_TDISC, "tdisc_interrupt");
6046 if (rc) {
6047 pr_err("%s: gpio_request failed for PMIC_GPIO_TDISC\n",
6048 __func__);
6049 return rc;
6050 }
6051
6052 rc = gpio_request(GPIO_JOYSTICK_EN, "tdisc_oe");
6053 if (rc) {
6054 pr_err("%s: gpio_request failed for GPIO_JOYSTICK_EN\n",
6055 __func__);
6056 goto fail_gpio_oe;
6057 }
6058
6059 rc = gpio_direction_output(GPIO_JOYSTICK_EN, 1);
6060 if (rc) {
6061 pr_err("%s: gpio_direction_output failed for GPIO_JOYSTICK_EN\n",
6062 __func__);
6063 gpio_free(GPIO_JOYSTICK_EN);
6064 goto fail_gpio_oe;
6065 }
6066
6067 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6068 vregs_tdisc[i] = regulator_get(NULL, vregs_tdisc_name[i]);
6069 if (IS_ERR(vregs_tdisc[i])) {
6070 printk(KERN_ERR "%s: regulator get %s failed (%ld)\n",
6071 __func__, vregs_tdisc_name[i],
6072 PTR_ERR(vregs_tdisc[i]));
6073 rc = PTR_ERR(vregs_tdisc[i]);
6074 goto vreg_get_fail;
6075 }
6076
6077 rc = regulator_set_voltage(vregs_tdisc[i],
6078 vregs_tdisc_val[i], vregs_tdisc_val[i]);
6079 if (rc) {
6080 printk(KERN_ERR "%s: regulator_set_voltage() = %d\n",
6081 __func__, rc);
6082 goto vreg_set_voltage_fail;
6083 }
6084 }
6085
6086 return rc;
6087vreg_set_voltage_fail:
6088 i++;
6089vreg_get_fail:
6090 while (i)
6091 regulator_put(vregs_tdisc[--i]);
6092fail_gpio_oe:
6093 gpio_free(PMIC_GPIO_TDISC);
6094 return rc;
6095}
6096
6097static void tdisc_shinetsu_release(void)
6098{
6099 int i;
6100
6101 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++)
6102 regulator_put(vregs_tdisc[i]);
6103
6104 gpio_free(PMIC_GPIO_TDISC);
6105 gpio_free(GPIO_JOYSTICK_EN);
6106}
6107
6108static int tdisc_shinetsu_enable(void)
6109{
6110 int i, rc = -EINVAL;
6111
6112 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6113 rc = regulator_enable(vregs_tdisc[i]);
6114 if (rc < 0) {
6115 printk(KERN_ERR "%s: vreg %s enable failed (%d)\n",
6116 __func__, vregs_tdisc_name[i], rc);
6117 goto vreg_fail;
6118 }
6119 }
6120
6121 /* Enable the OE (output enable) gpio */
6122 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 1);
6123 /* voltage and gpio stabilization delay */
6124 msleep(50);
6125
6126 return 0;
6127vreg_fail:
6128 while (i)
6129 regulator_disable(vregs_tdisc[--i]);
6130 return rc;
6131}
6132
6133static int tdisc_shinetsu_disable(void)
6134{
6135 int i, rc;
6136
6137 for (i = 0; i < ARRAY_SIZE(vregs_tdisc_name); i++) {
6138 rc = regulator_disable(vregs_tdisc[i]);
6139 if (rc < 0) {
6140 printk(KERN_ERR "%s: vreg %s disable failed (%d)\n",
6141 __func__, vregs_tdisc_name[i], rc);
6142 goto tdisc_reg_fail;
6143 }
6144 }
6145
6146 /* Disable the OE (output enable) gpio */
6147 gpio_set_value_cansleep(GPIO_JOYSTICK_EN, 0);
6148
6149 return 0;
6150
6151tdisc_reg_fail:
6152 while (i)
6153 regulator_enable(vregs_tdisc[--i]);
6154 return rc;
6155}
6156
6157static struct tdisc_abs_values tdisc_abs = {
6158 .x_max = 32,
6159 .y_max = 32,
6160 .x_min = -32,
6161 .y_min = -32,
6162 .pressure_max = 32,
6163 .pressure_min = 0,
6164};
6165
6166static struct tdisc_platform_data tdisc_data = {
6167 .tdisc_setup = tdisc_shinetsu_setup,
6168 .tdisc_release = tdisc_shinetsu_release,
6169 .tdisc_enable = tdisc_shinetsu_enable,
6170 .tdisc_disable = tdisc_shinetsu_disable,
6171 .tdisc_wakeup = 0,
6172 .tdisc_gpio = PMIC_GPIO_TDISC,
6173 .tdisc_report_keys = true,
6174 .tdisc_report_relative = true,
6175 .tdisc_report_absolute = false,
6176 .tdisc_report_wheel = false,
6177 .tdisc_reverse_x = false,
6178 .tdisc_reverse_y = true,
6179 .tdisc_abs = &tdisc_abs,
6180};
6181
6182static struct i2c_board_info msm_i2c_gsbi3_tdisc_info[] = {
6183 {
6184 I2C_BOARD_INFO("vtd518", TDISC_I2C_SLAVE_ADDR),
6185 .irq = TDISC_INT,
6186 .platform_data = &tdisc_data,
6187 },
6188};
6189#endif
6190
6191#define PM_GPIO_CDC_RST_N 20
6192#define GPIO_CDC_RST_N PM8058_GPIO_PM_TO_SYS(PM_GPIO_CDC_RST_N)
6193
6194static struct regulator *vreg_timpani_1;
6195static struct regulator *vreg_timpani_2;
6196
6197static unsigned int msm_timpani_setup_power(void)
6198{
6199 int rc;
6200
6201 vreg_timpani_1 = regulator_get(NULL, "8058_l0");
6202 if (IS_ERR(vreg_timpani_1)) {
6203 pr_err("%s: Unable to get 8058_l0\n", __func__);
6204 return -ENODEV;
6205 }
6206
6207 vreg_timpani_2 = regulator_get(NULL, "8058_s3");
6208 if (IS_ERR(vreg_timpani_2)) {
6209 pr_err("%s: Unable to get 8058_s3\n", __func__);
6210 regulator_put(vreg_timpani_1);
6211 return -ENODEV;
6212 }
6213
6214 rc = regulator_set_voltage(vreg_timpani_1, 1200000, 1200000);
6215 if (rc) {
6216 pr_err("%s: unable to set L0 voltage to 1.2V\n", __func__);
6217 goto fail;
6218 }
6219
6220 rc = regulator_set_voltage(vreg_timpani_2, 1800000, 1800000);
6221 if (rc) {
6222 pr_err("%s: unable to set S3 voltage to 1.8V\n", __func__);
6223 goto fail;
6224 }
6225
6226 rc = regulator_enable(vreg_timpani_1);
6227 if (rc) {
6228 pr_err("%s: Enable regulator 8058_l0 failed\n", __func__);
6229 goto fail;
6230 }
6231
6232 /* The settings for LDO0 should be set such that
6233 * it doesn't require to reset the timpani. */
6234 rc = regulator_set_optimum_mode(vreg_timpani_1, 5000);
6235 if (rc < 0) {
6236 pr_err("Timpani regulator optimum mode setting failed\n");
6237 goto fail;
6238 }
6239
6240 rc = regulator_enable(vreg_timpani_2);
6241 if (rc) {
6242 pr_err("%s: Enable regulator 8058_s3 failed\n", __func__);
6243 regulator_disable(vreg_timpani_1);
6244 goto fail;
6245 }
6246
6247 rc = gpio_request(GPIO_CDC_RST_N, "CDC_RST_N");
6248 if (rc) {
6249 pr_err("%s: GPIO Request %d failed\n", __func__,
6250 GPIO_CDC_RST_N);
6251 regulator_disable(vreg_timpani_1);
6252 regulator_disable(vreg_timpani_2);
6253 goto fail;
6254 } else {
6255 gpio_direction_output(GPIO_CDC_RST_N, 1);
6256 usleep_range(1000, 1050);
6257 gpio_direction_output(GPIO_CDC_RST_N, 0);
6258 usleep_range(1000, 1050);
6259 gpio_direction_output(GPIO_CDC_RST_N, 1);
6260 gpio_free(GPIO_CDC_RST_N);
6261 }
6262 return rc;
6263
6264fail:
6265 regulator_put(vreg_timpani_1);
6266 regulator_put(vreg_timpani_2);
6267 return rc;
6268}
6269
6270static void msm_timpani_shutdown_power(void)
6271{
6272 int rc;
6273
6274 rc = regulator_disable(vreg_timpani_1);
6275 if (rc)
6276 pr_err("%s: Disable regulator 8058_l0 failed\n", __func__);
6277
6278 regulator_put(vreg_timpani_1);
6279
6280 rc = regulator_disable(vreg_timpani_2);
6281 if (rc)
6282 pr_err("%s: Disable regulator 8058_s3 failed\n", __func__);
6283
6284 regulator_put(vreg_timpani_2);
6285}
6286
6287/* Power analog function of codec */
6288static struct regulator *vreg_timpani_cdc_apwr;
6289static int msm_timpani_codec_power(int vreg_on)
6290{
6291 int rc = 0;
6292
6293 if (!vreg_timpani_cdc_apwr) {
6294
6295 vreg_timpani_cdc_apwr = regulator_get(NULL, "8058_s4");
6296
6297 if (IS_ERR(vreg_timpani_cdc_apwr)) {
6298 pr_err("%s: vreg_get failed (%ld)\n",
6299 __func__, PTR_ERR(vreg_timpani_cdc_apwr));
6300 rc = PTR_ERR(vreg_timpani_cdc_apwr);
6301 return rc;
6302 }
6303 }
6304
6305 if (vreg_on) {
6306
6307 rc = regulator_set_voltage(vreg_timpani_cdc_apwr,
6308 2200000, 2200000);
6309 if (rc) {
6310 pr_err("%s: unable to set 8058_s4 voltage to 2.2 V\n",
6311 __func__);
6312 goto vreg_fail;
6313 }
6314
6315 rc = regulator_enable(vreg_timpani_cdc_apwr);
6316 if (rc) {
6317 pr_err("%s: vreg_enable failed %d\n", __func__, rc);
6318 goto vreg_fail;
6319 }
6320 } else {
6321 rc = regulator_disable(vreg_timpani_cdc_apwr);
6322 if (rc) {
6323 pr_err("%s: vreg_disable failed %d\n",
6324 __func__, rc);
6325 goto vreg_fail;
6326 }
6327 }
6328
6329 return 0;
6330
6331vreg_fail:
6332 regulator_put(vreg_timpani_cdc_apwr);
6333 vreg_timpani_cdc_apwr = NULL;
6334 return rc;
6335}
6336
6337static struct marimba_codec_platform_data timpani_codec_pdata = {
6338 .marimba_codec_power = msm_timpani_codec_power,
6339};
6340
6341#define TIMPANI_SLAVE_ID_CDC_ADDR 0X77
6342#define TIMPANI_SLAVE_ID_QMEMBIST_ADDR 0X66
6343
6344static struct marimba_platform_data timpani_pdata = {
6345 .slave_id[MARIMBA_SLAVE_ID_CDC] = TIMPANI_SLAVE_ID_CDC_ADDR,
6346 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = TIMPANI_SLAVE_ID_QMEMBIST_ADDR,
6347 .marimba_setup = msm_timpani_setup_power,
6348 .marimba_shutdown = msm_timpani_shutdown_power,
6349 .codec = &timpani_codec_pdata,
6350 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6351};
6352
6353#define TIMPANI_I2C_SLAVE_ADDR 0xD
6354
6355static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
6356 {
6357 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
6358 .platform_data = &timpani_pdata,
6359 },
6360};
6361
6362#ifdef CONFIG_PMIC8901
6363
6364#define PM8901_GPIO_INT 91
6365
6366static struct pm8901_gpio_platform_data pm8901_mpp_data = {
6367 .gpio_base = PM8901_GPIO_PM_TO_SYS(0),
6368 .irq_base = PM8901_MPP_IRQ(PM8901_IRQ_BASE, 0),
6369};
6370
6371static struct resource pm8901_temp_alarm[] = {
6372 {
6373 .start = PM8901_TEMP_ALARM_IRQ(PM8901_IRQ_BASE),
6374 .end = PM8901_TEMP_ALARM_IRQ(PM8901_IRQ_BASE),
6375 .flags = IORESOURCE_IRQ,
6376 },
6377 {
6378 .start = PM8901_TEMP_HI_ALARM_IRQ(PM8901_IRQ_BASE),
6379 .end = PM8901_TEMP_HI_ALARM_IRQ(PM8901_IRQ_BASE),
6380 .flags = IORESOURCE_IRQ,
6381 },
6382};
6383
6384/*
6385 * Consumer specific regulator names:
6386 * regulator name consumer dev_name
6387 */
6388static struct regulator_consumer_supply vreg_consumers_8901_MPP0[] = {
6389 REGULATOR_SUPPLY("8901_mpp0", NULL),
6390};
6391static struct regulator_consumer_supply vreg_consumers_8901_USB_OTG[] = {
6392 REGULATOR_SUPPLY("8901_usb_otg", NULL),
6393};
6394static struct regulator_consumer_supply vreg_consumers_8901_HDMI_MVS[] = {
6395 REGULATOR_SUPPLY("8901_hdmi_mvs", NULL),
6396};
6397
6398#define PM8901_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
6399 _always_on, _active_high) \
6400 [PM8901_VREG_ID_##_id] = { \
6401 .init_data = { \
6402 .constraints = { \
6403 .valid_modes_mask = _modes, \
6404 .valid_ops_mask = _ops, \
6405 .min_uV = _min_uV, \
6406 .max_uV = _max_uV, \
6407 .input_uV = _min_uV, \
6408 .apply_uV = _apply_uV, \
6409 .always_on = _always_on, \
6410 }, \
6411 .consumer_supplies = vreg_consumers_8901_##_id, \
6412 .num_consumer_supplies = \
6413 ARRAY_SIZE(vreg_consumers_8901_##_id), \
6414 }, \
6415 .active_high = _active_high, \
6416 }
6417
6418#define PM8901_VREG_INIT_MPP(_id, _active_high) \
6419 PM8901_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL, \
6420 REGULATOR_CHANGE_STATUS, 0, 0, _active_high)
6421
6422#define PM8901_VREG_INIT_VS(_id) \
6423 PM8901_VREG_INIT(_id, 0, 0, REGULATOR_MODE_NORMAL, \
6424 REGULATOR_CHANGE_STATUS, 0, 0, 0)
6425
6426static struct pm8901_vreg_pdata pm8901_vreg_init_pdata[PM8901_VREG_MAX] = {
6427 PM8901_VREG_INIT_MPP(MPP0, 1),
6428
6429 PM8901_VREG_INIT_VS(USB_OTG),
6430 PM8901_VREG_INIT_VS(HDMI_MVS),
6431};
6432
6433#define PM8901_VREG(_id) { \
6434 .name = "pm8901-regulator", \
6435 .id = _id, \
6436 .platform_data = &pm8901_vreg_init_pdata[_id], \
6437 .pdata_size = sizeof(pm8901_vreg_init_pdata[_id]), \
6438}
6439
6440static struct mfd_cell pm8901_subdevs[] = {
6441 { .name = "pm8901-mpp",
6442 .id = -1,
6443 .platform_data = &pm8901_mpp_data,
6444 .pdata_size = sizeof(pm8901_mpp_data),
6445 },
6446 { .name = "pm8901-tm",
6447 .id = -1,
6448 .num_resources = ARRAY_SIZE(pm8901_temp_alarm),
6449 .resources = pm8901_temp_alarm,
6450 },
6451 PM8901_VREG(PM8901_VREG_ID_MPP0),
6452 PM8901_VREG(PM8901_VREG_ID_USB_OTG),
6453 PM8901_VREG(PM8901_VREG_ID_HDMI_MVS),
6454};
6455
6456static struct pm8901_platform_data pm8901_platform_data = {
6457 .irq_base = PM8901_IRQ_BASE,
6458 .num_subdevs = ARRAY_SIZE(pm8901_subdevs),
6459 .sub_devices = pm8901_subdevs,
6460 .irq_trigger_flags = IRQF_TRIGGER_LOW,
6461};
6462
6463static struct i2c_board_info pm8901_boardinfo[] __initdata = {
6464 {
6465 I2C_BOARD_INFO("pm8901-core", 0x55),
6466 .irq = MSM_GPIO_TO_INT(PM8901_GPIO_INT),
6467 .platform_data = &pm8901_platform_data,
6468 },
6469};
6470
6471#endif /* CONFIG_PMIC8901 */
6472
6473#if defined(CONFIG_MARIMBA_CORE) && (defined(CONFIG_GPIO_SX150X) \
6474 || defined(CONFIG_GPIO_SX150X_MODULE))
6475
6476static struct regulator *vreg_bahama;
6477
6478struct bahama_config_register{
6479 u8 reg;
6480 u8 value;
6481 u8 mask;
6482};
6483
6484enum version{
6485 VER_1_0,
6486 VER_2_0,
6487 VER_UNSUPPORTED = 0xFF
6488};
6489
6490static u8 read_bahama_ver(void)
6491{
6492 int rc;
6493 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6494 u8 bahama_version;
6495
6496 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
6497 if (rc < 0) {
6498 printk(KERN_ERR
6499 "%s: version read failed: %d\n",
6500 __func__, rc);
6501 return VER_UNSUPPORTED;
6502 } else {
6503 printk(KERN_INFO
6504 "%s: version read got: 0x%x\n",
6505 __func__, bahama_version);
6506 }
6507
6508 switch (bahama_version) {
6509 case 0x08: /* varient of bahama v1 */
6510 case 0x10:
6511 case 0x00:
6512 return VER_1_0;
6513 case 0x09: /* variant of bahama v2 */
6514 return VER_2_0;
6515 default:
6516 return VER_UNSUPPORTED;
6517 }
6518}
6519
6520static unsigned int msm_bahama_setup_power(void)
6521{
6522 int rc = 0;
6523 const char *msm_bahama_regulator = "8058_s3";
6524 vreg_bahama = regulator_get(NULL, msm_bahama_regulator);
6525
6526 if (IS_ERR(vreg_bahama)) {
6527 rc = PTR_ERR(vreg_bahama);
6528 pr_err("%s: regulator_get %s = %d\n", __func__,
6529 msm_bahama_regulator, rc);
6530 }
6531
6532 if (!rc)
6533 rc = regulator_set_voltage(vreg_bahama, 1800000, 1800000);
6534 else {
6535 pr_err("%s: regulator_set_voltage %s = %d\n", __func__,
6536 msm_bahama_regulator, rc);
6537 goto unget;
6538 }
6539
6540 if (!rc)
6541 rc = regulator_enable(vreg_bahama);
6542 else {
6543 pr_err("%s: regulator_enable %s = %d\n", __func__,
6544 msm_bahama_regulator, rc);
6545 goto unget;
6546 }
6547
6548 if (!rc)
6549 rc = gpio_request(GPIO_MS_SYS_RESET_N, "bahama sys_rst_n");
6550 else {
6551 pr_err("%s: gpio_request %d = %d\n", __func__,
6552 GPIO_MS_SYS_RESET_N, rc);
6553 goto unenable;
6554 }
6555
Siddartha Mohanadoss72d796e2011-07-20 22:08:34 -07006556 if (!rc) {
6557 gpio_direction_output(GPIO_MS_SYS_RESET_N, 0);
6558 usleep_range(1000, 1050);
6559 gpio_direction_output(GPIO_MS_SYS_RESET_N, 1);
6560 usleep_range(1000, 1050);
6561 } else {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006562 pr_err("%s: gpio_direction_output %d = %d\n", __func__,
6563 GPIO_MS_SYS_RESET_N, rc);
6564 goto unrequest;
6565 }
6566
6567 return rc;
6568
6569unrequest:
6570 gpio_free(GPIO_MS_SYS_RESET_N);
6571unenable:
6572 regulator_disable(vreg_bahama);
6573unget:
6574 regulator_put(vreg_bahama);
6575 return rc;
6576};
6577static unsigned int msm_bahama_shutdown_power(int value)
6578
6579
6580{
6581 gpio_set_value_cansleep(GPIO_MS_SYS_RESET_N, 0);
6582
6583 gpio_free(GPIO_MS_SYS_RESET_N);
6584
6585 regulator_disable(vreg_bahama);
6586
6587 regulator_put(vreg_bahama);
6588
6589 return 0;
6590};
6591
6592static unsigned int msm_bahama_core_config(int type)
6593{
6594 int rc = 0;
6595
6596 if (type == BAHAMA_ID) {
6597
6598 int i;
6599 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
6600
6601 const struct bahama_config_register v20_init[] = {
6602 /* reg, value, mask */
6603 { 0xF4, 0x84, 0xFF }, /* AREG */
6604 { 0xF0, 0x04, 0xFF } /* DREG */
6605 };
6606
6607 if (read_bahama_ver() == VER_2_0) {
6608 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
6609 u8 value = v20_init[i].value;
6610 rc = marimba_write_bit_mask(&config,
6611 v20_init[i].reg,
6612 &value,
6613 sizeof(v20_init[i].value),
6614 v20_init[i].mask);
6615 if (rc < 0) {
6616 printk(KERN_ERR
6617 "%s: reg %d write failed: %d\n",
6618 __func__, v20_init[i].reg, rc);
6619 return rc;
6620 }
6621 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
6622 " mask 0x%02x\n",
6623 __func__, v20_init[i].reg,
6624 v20_init[i].value, v20_init[i].mask);
6625 }
6626 }
6627 }
6628 printk(KERN_INFO "core type: %d\n", type);
6629
6630 return rc;
6631}
6632
6633static struct regulator *fm_regulator_s3;
6634static struct msm_xo_voter *fm_clock;
6635
6636static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
6637{
6638 int rc = 0;
6639 struct pm8058_gpio cfg = {
6640 .direction = PM_GPIO_DIR_IN,
6641 .pull = PM_GPIO_PULL_NO,
6642 .vin_sel = PM_GPIO_VIN_S3,
6643 .function = PM_GPIO_FUNC_NORMAL,
6644 .inv_int_pol = 0,
6645 };
6646
6647 if (!fm_regulator_s3) {
6648 fm_regulator_s3 = regulator_get(NULL, "8058_s3");
6649 if (IS_ERR(fm_regulator_s3)) {
6650 rc = PTR_ERR(fm_regulator_s3);
6651 printk(KERN_ERR "%s: regulator get s3 (%d)\n",
6652 __func__, rc);
6653 goto out;
6654 }
6655 }
6656
6657
6658 rc = regulator_set_voltage(fm_regulator_s3, 1800000, 1800000);
6659 if (rc < 0) {
6660 printk(KERN_ERR "%s: regulator set voltage failed (%d)\n",
6661 __func__, rc);
6662 goto fm_fail_put;
6663 }
6664
6665 rc = regulator_enable(fm_regulator_s3);
6666 if (rc < 0) {
6667 printk(KERN_ERR "%s: regulator s3 enable failed (%d)\n",
6668 __func__, rc);
6669 goto fm_fail_put;
6670 }
6671
6672 /*Vote for XO clock*/
6673 fm_clock = msm_xo_get(MSM_XO_TCXO_D0, "fm_power");
6674
6675 if (IS_ERR(fm_clock)) {
6676 rc = PTR_ERR(fm_clock);
6677 printk(KERN_ERR "%s: Couldn't get TCXO_D0 vote for FM (%d)\n",
6678 __func__, rc);
6679 goto fm_fail_switch;
6680 }
6681
6682 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_ON);
6683 if (rc < 0) {
6684 printk(KERN_ERR "%s: Failed to vote for TCX0_D0 ON (%d)\n",
6685 __func__, rc);
6686 goto fm_fail_vote;
6687 }
6688
6689 /*GPIO 18 on PMIC is FM_IRQ*/
6690 rc = pm8058_gpio_config(FM_GPIO, &cfg);
6691 if (rc) {
6692 printk(KERN_ERR "%s: return val of pm8058_gpio_config: %d\n",
6693 __func__, rc);
6694 goto fm_fail_clock;
6695 }
6696 goto out;
6697
6698fm_fail_clock:
6699 msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
6700fm_fail_vote:
6701 msm_xo_put(fm_clock);
6702fm_fail_switch:
6703 regulator_disable(fm_regulator_s3);
6704fm_fail_put:
6705 regulator_put(fm_regulator_s3);
6706out:
6707 return rc;
6708};
6709
6710static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
6711{
6712 int rc = 0;
6713 if (fm_regulator_s3 != NULL) {
6714 rc = regulator_disable(fm_regulator_s3);
6715 if (rc < 0) {
6716 printk(KERN_ERR "%s: regulator s3 disable (%d)\n",
6717 __func__, rc);
6718 }
6719 regulator_put(fm_regulator_s3);
6720 fm_regulator_s3 = NULL;
6721 }
6722 printk(KERN_ERR "%s: Voting off for XO", __func__);
6723
6724 if (fm_clock != NULL) {
6725 rc = msm_xo_mode_vote(fm_clock, MSM_XO_MODE_OFF);
6726 if (rc < 0) {
6727 printk(KERN_ERR "%s: Voting off XO clock (%d)\n",
6728 __func__, rc);
6729 }
6730 msm_xo_put(fm_clock);
6731 }
6732 printk(KERN_ERR "%s: coming out of fm_radio_shutdown", __func__);
6733}
6734
6735/* Slave id address for FM/CDC/QMEMBIST
6736 * Values can be programmed using Marimba slave id 0
6737 * should there be a conflict with other I2C devices
6738 * */
6739#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
6740#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
6741
6742static struct marimba_fm_platform_data marimba_fm_pdata = {
6743 .fm_setup = fm_radio_setup,
6744 .fm_shutdown = fm_radio_shutdown,
6745 .irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE, FM_GPIO),
6746 .is_fm_soc_i2s_master = false,
6747 .config_i2s_gpio = NULL,
6748};
6749
6750/*
6751Just initializing the BAHAMA related slave
6752*/
6753static struct marimba_platform_data marimba_pdata = {
6754 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
6755 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
6756 .bahama_setup = msm_bahama_setup_power,
6757 .bahama_shutdown = msm_bahama_shutdown_power,
6758 .bahama_core_config = msm_bahama_core_config,
6759 .fm = &marimba_fm_pdata,
6760 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
6761};
6762
6763
6764static struct i2c_board_info msm_marimba_board_info[] = {
6765 {
6766 I2C_BOARD_INFO("marimba", 0xc),
6767 .platform_data = &marimba_pdata,
6768 }
6769};
6770#endif /* CONFIG_MAIMBA_CORE */
6771
6772#ifdef CONFIG_I2C
6773#define I2C_SURF 1
6774#define I2C_FFA (1 << 1)
6775#define I2C_RUMI (1 << 2)
6776#define I2C_SIM (1 << 3)
6777#define I2C_FLUID (1 << 4)
6778
6779struct i2c_registry {
6780 u8 machs;
6781 int bus;
6782 struct i2c_board_info *info;
6783 int len;
6784};
6785
6786static struct i2c_registry msm8x60_i2c_devices[] __initdata = {
6787#ifdef CONFIG_PMIC8058
6788 {
6789 I2C_SURF | I2C_FFA | I2C_FLUID,
6790 MSM_SSBI1_I2C_BUS_ID,
6791 pm8058_boardinfo,
6792 ARRAY_SIZE(pm8058_boardinfo),
6793 },
6794#endif
6795#ifdef CONFIG_PMIC8901
6796 {
6797 I2C_SURF | I2C_FFA | I2C_FLUID,
6798 MSM_SSBI2_I2C_BUS_ID,
6799 pm8901_boardinfo,
6800 ARRAY_SIZE(pm8901_boardinfo),
6801 },
6802#endif
6803#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
6804 {
6805 I2C_SURF | I2C_FFA,
6806 MSM_GSBI8_QUP_I2C_BUS_ID,
6807 core_expander_i2c_info,
6808 ARRAY_SIZE(core_expander_i2c_info),
6809 },
6810 {
6811 I2C_SURF | I2C_FFA,
6812 MSM_GSBI8_QUP_I2C_BUS_ID,
6813 docking_expander_i2c_info,
6814 ARRAY_SIZE(docking_expander_i2c_info),
6815 },
6816 {
6817 I2C_SURF,
6818 MSM_GSBI8_QUP_I2C_BUS_ID,
6819 surf_expanders_i2c_info,
6820 ARRAY_SIZE(surf_expanders_i2c_info),
6821 },
6822 {
6823 I2C_SURF | I2C_FFA,
6824 MSM_GSBI3_QUP_I2C_BUS_ID,
6825 fha_expanders_i2c_info,
6826 ARRAY_SIZE(fha_expanders_i2c_info),
6827 },
6828 {
6829 I2C_FLUID,
6830 MSM_GSBI3_QUP_I2C_BUS_ID,
6831 fluid_expanders_i2c_info,
6832 ARRAY_SIZE(fluid_expanders_i2c_info),
6833 },
6834 {
6835 I2C_FLUID,
6836 MSM_GSBI8_QUP_I2C_BUS_ID,
6837 fluid_core_expander_i2c_info,
6838 ARRAY_SIZE(fluid_core_expander_i2c_info),
6839 },
6840#endif
6841#if defined(CONFIG_TOUCHDISC_VTD518_SHINETSU) || \
6842 defined(CONFIG_TOUCHDISC_VTD518_SHINETSU_MODULE)
6843 {
6844 I2C_SURF | I2C_FFA | I2C_FLUID,
6845 MSM_GSBI3_QUP_I2C_BUS_ID,
6846 msm_i2c_gsbi3_tdisc_info,
6847 ARRAY_SIZE(msm_i2c_gsbi3_tdisc_info),
6848 },
6849#endif
6850 {
6851 I2C_SURF | I2C_FFA | I2C_FLUID,
6852 MSM_GSBI3_QUP_I2C_BUS_ID,
6853 cy8ctmg200_board_info,
6854 ARRAY_SIZE(cy8ctmg200_board_info),
6855 },
6856#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
6857 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
6858 {
6859 I2C_FLUID,
6860 MSM_GSBI3_QUP_I2C_BUS_ID,
6861 cyttsp_fluid_info,
6862 ARRAY_SIZE(cyttsp_fluid_info),
6863 },
6864 {
6865 I2C_FFA | I2C_SURF,
6866 MSM_GSBI3_QUP_I2C_BUS_ID,
6867 cyttsp_ffa_info,
6868 ARRAY_SIZE(cyttsp_ffa_info),
6869 },
6870#endif
6871#ifdef CONFIG_MSM_CAMERA
6872 {
6873 I2C_SURF | I2C_FFA | I2C_FLUID,
6874 MSM_GSBI4_QUP_I2C_BUS_ID,
6875 msm_camera_boardinfo,
6876 ARRAY_SIZE(msm_camera_boardinfo),
6877 },
6878#endif
6879 {
6880 I2C_SURF | I2C_FFA | I2C_FLUID,
6881 MSM_GSBI7_QUP_I2C_BUS_ID,
6882 msm_i2c_gsbi7_timpani_info,
6883 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info),
6884 },
6885#if defined(CONFIG_MARIMBA_CORE)
6886 {
6887 I2C_SURF | I2C_FFA | I2C_FLUID,
6888 MSM_GSBI7_QUP_I2C_BUS_ID,
6889 msm_marimba_board_info,
6890 ARRAY_SIZE(msm_marimba_board_info),
6891 },
6892#endif /* CONFIG_MARIMBA_CORE */
6893#ifdef CONFIG_ISL9519_CHARGER
6894 {
6895 I2C_SURF | I2C_FFA,
6896 MSM_GSBI8_QUP_I2C_BUS_ID,
6897 isl_charger_i2c_info,
6898 ARRAY_SIZE(isl_charger_i2c_info),
6899 },
6900#endif
6901#if defined(CONFIG_HAPTIC_ISA1200) || \
6902 defined(CONFIG_HAPTIC_ISA1200_MODULE)
6903 {
6904 I2C_FLUID,
6905 MSM_GSBI8_QUP_I2C_BUS_ID,
6906 msm_isa1200_board_info,
6907 ARRAY_SIZE(msm_isa1200_board_info),
6908 },
6909#endif
6910#if defined(CONFIG_SMB137B_CHARGER) || defined(CONFIG_SMB137B_CHARGER_MODULE)
6911 {
6912 I2C_FLUID,
6913 MSM_GSBI8_QUP_I2C_BUS_ID,
6914 smb137b_charger_i2c_info,
6915 ARRAY_SIZE(smb137b_charger_i2c_info),
6916 },
6917#endif
6918#if defined(CONFIG_BATTERY_BQ27520) || \
6919 defined(CONFIG_BATTERY_BQ27520_MODULE)
6920 {
6921 I2C_FLUID,
6922 MSM_GSBI8_QUP_I2C_BUS_ID,
6923 msm_bq27520_board_info,
6924 ARRAY_SIZE(msm_bq27520_board_info),
6925 },
6926#endif
6927};
6928#endif /* CONFIG_I2C */
6929
6930static void fixup_i2c_configs(void)
6931{
6932#ifdef CONFIG_I2C
6933#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
6934 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
6935 sx150x_data[SX150X_CORE].irq_summary =
6936 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT2_N);
6937 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
6938 sx150x_data[SX150X_CORE].irq_summary =
6939 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
6940 else if (machine_is_msm8x60_fluid())
6941 sx150x_data[SX150X_CORE_FLUID].irq_summary =
6942 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, UI_INT1_N);
6943#endif
6944 /*
6945 * Set PMIC 8901 MPP0 active_high to 0 for surf and charm_surf. This
6946 * implies that the regulator connected to MPP0 is enabled when
6947 * MPP0 is low.
6948 */
6949 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
6950 pm8901_vreg_init_pdata[PM8901_VREG_ID_MPP0].active_high = 0;
6951 else
6952 pm8901_vreg_init_pdata[PM8901_VREG_ID_MPP0].active_high = 1;
6953#endif
6954}
6955
6956static void register_i2c_devices(void)
6957{
6958#ifdef CONFIG_I2C
6959 u8 mach_mask = 0;
6960 int i;
6961
6962 /* Build the matching 'supported_machs' bitmask */
6963 if (machine_is_msm8x60_surf() || machine_is_msm8x60_fusion())
6964 mach_mask = I2C_SURF;
6965 else if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
6966 mach_mask = I2C_FFA;
6967 else if (machine_is_msm8x60_rumi3())
6968 mach_mask = I2C_RUMI;
6969 else if (machine_is_msm8x60_sim())
6970 mach_mask = I2C_SIM;
6971 else if (machine_is_msm8x60_fluid())
6972 mach_mask = I2C_FLUID;
6973 else
6974 pr_err("unmatched machine ID in register_i2c_devices\n");
6975
6976 /* Run the array and install devices as appropriate */
6977 for (i = 0; i < ARRAY_SIZE(msm8x60_i2c_devices); ++i) {
6978 if (msm8x60_i2c_devices[i].machs & mach_mask)
6979 i2c_register_board_info(msm8x60_i2c_devices[i].bus,
6980 msm8x60_i2c_devices[i].info,
6981 msm8x60_i2c_devices[i].len);
6982 }
6983#endif
6984}
6985
6986static void __init msm8x60_init_uart12dm(void)
6987{
6988#if !defined(CONFIG_USB_PEHCI_HCD) && !defined(CONFIG_USB_PEHCI_HCD_MODULE)
6989 /* 0x1D000000 now belongs to EBI2:CS3 i.e. USB ISP Controller */
6990 void *fpga_mem = ioremap_nocache(0x1D000000, SZ_4K);
6991
6992 if (!fpga_mem)
6993 pr_err("%s(): Error getting memory\n", __func__);
6994
6995 /* Advanced mode */
6996 writew(0xFFFF, fpga_mem + 0x15C);
6997 /* FPGA_UART_SEL */
6998 writew(0, fpga_mem + 0x172);
6999 /* FPGA_GPIO_CONFIG_117 */
7000 writew(1, fpga_mem + 0xEA);
7001 /* FPGA_GPIO_CONFIG_118 */
7002 writew(1, fpga_mem + 0xEC);
7003 mb();
7004 iounmap(fpga_mem);
7005#endif
7006}
7007
7008#define MSM_GSBI9_PHYS 0x19900000
7009#define GSBI_DUAL_MODE_CODE 0x60
7010
7011static void __init msm8x60_init_buses(void)
7012{
7013#ifdef CONFIG_I2C_QUP
7014 void *gsbi_mem = ioremap_nocache(0x19C00000, 4);
7015 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI12 */
7016 writel_relaxed(0x6 << 4, gsbi_mem);
7017 /* Ensure protocol code is written before proceeding further */
7018 mb();
7019 iounmap(gsbi_mem);
7020
7021 msm_gsbi3_qup_i2c_device.dev.platform_data = &msm_gsbi3_qup_i2c_pdata;
7022 msm_gsbi4_qup_i2c_device.dev.platform_data = &msm_gsbi4_qup_i2c_pdata;
7023 msm_gsbi7_qup_i2c_device.dev.platform_data = &msm_gsbi7_qup_i2c_pdata;
7024 msm_gsbi8_qup_i2c_device.dev.platform_data = &msm_gsbi8_qup_i2c_pdata;
7025
7026#ifdef CONFIG_MSM_GSBI9_UART
7027 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7028 /* Setting protocol code to 0x60 for dual UART/I2C in GSBI9 */
7029 gsbi_mem = ioremap_nocache(MSM_GSBI9_PHYS, 4);
7030 writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
7031 iounmap(gsbi_mem);
7032 msm_gsbi9_qup_i2c_pdata.use_gsbi_shared_mode = 1;
7033 }
7034#endif
7035 msm_gsbi9_qup_i2c_device.dev.platform_data = &msm_gsbi9_qup_i2c_pdata;
7036 msm_gsbi12_qup_i2c_device.dev.platform_data = &msm_gsbi12_qup_i2c_pdata;
7037#endif
7038#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7039 msm_gsbi1_qup_spi_device.dev.platform_data = &msm_gsbi1_qup_spi_pdata;
7040#endif
7041#ifdef CONFIG_I2C_SSBI
7042 msm_device_ssbi1.dev.platform_data = &msm_ssbi1_pdata;
7043 msm_device_ssbi2.dev.platform_data = &msm_ssbi2_pdata;
7044 msm_device_ssbi3.dev.platform_data = &msm_ssbi3_pdata;
7045#endif
7046
7047 if (machine_is_msm8x60_fluid()) {
7048#if (defined(CONFIG_USB_EHCI_MSM_72K) && \
7049 (defined(CONFIG_SMB137B_CHARGER) || \
7050 defined(CONFIG_SMB137B_CHARGER_MODULE)))
7051 msm_otg_pdata.vbus_power = msm_hsusb_smb137b_vbus_power;
7052#endif
7053#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
7054 msm_gsbi10_qup_spi_device.dev.platform_data =
7055 &msm_gsbi10_qup_spi_pdata;
7056#endif
7057 }
7058
7059#if defined(CONFIG_USB_GADGET_MSM_72K) || defined(CONFIG_USB_EHCI_HCD)
7060 /*
7061 * We can not put USB regulators (8058_l6 and 8058_l7) in LPM
7062 * when we depend on USB PHY for VBUS/ID notifications. VBUS
7063 * and ID notifications are available only on V2 surf and FFA
7064 * with a hardware workaround.
7065 */
7066 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2 &&
7067 (machine_is_msm8x60_surf() ||
7068 (machine_is_msm8x60_ffa() &&
7069 pmic_id_notif_supported)))
7070 msm_otg_pdata.phy_can_powercollapse = 1;
7071 msm_device_otg.dev.platform_data = &msm_otg_pdata;
7072#endif
7073
7074#ifdef CONFIG_USB_GADGET_MSM_72K
7075 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
7076#endif
7077
7078#ifdef CONFIG_SERIAL_MSM_HS
7079 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(54); /* GSBI6(2) */
7080 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
7081#endif
7082#ifdef CONFIG_MSM_GSBI9_UART
7083 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
7084 msm_device_uart_gsbi9 = msm_add_gsbi9_uart();
7085 if (IS_ERR(msm_device_uart_gsbi9))
7086 pr_err("%s(): Failed to create uart gsbi9 device\n",
7087 __func__);
7088 }
7089#endif
7090
7091#ifdef CONFIG_MSM_BUS_SCALING
7092
7093 /* RPM calls are only enabled on V2 */
7094 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 2) {
7095 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
7096 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
7097 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
7098 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
7099 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
7100 }
7101
7102 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
7103 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
7104 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
7105 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
7106 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
7107#endif
7108}
7109
7110static void __init msm8x60_map_io(void)
7111{
7112 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
7113 msm_map_msm8x60_io();
7114}
7115
7116/*
7117 * Most segments of the EBI2 bus are disabled by default.
7118 */
7119static void __init msm8x60_init_ebi2(void)
7120{
7121 uint32_t ebi2_cfg;
7122 void *ebi2_cfg_ptr;
7123
7124 ebi2_cfg_ptr = ioremap_nocache(0x1a100000, sizeof(uint32_t));
7125 if (ebi2_cfg_ptr != 0) {
7126 ebi2_cfg = readl_relaxed(ebi2_cfg_ptr);
7127
7128 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
7129 machine_is_msm8x60_fluid())
7130 ebi2_cfg |= (1 << 4) | (1 << 5); /* CS2, CS3 */
7131 else if (machine_is_msm8x60_sim())
7132 ebi2_cfg |= (1 << 4); /* CS2 */
7133 else if (machine_is_msm8x60_rumi3())
7134 ebi2_cfg |= (1 << 5); /* CS3 */
7135
7136 writel_relaxed(ebi2_cfg, ebi2_cfg_ptr);
7137 iounmap(ebi2_cfg_ptr);
7138 }
7139
7140 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
7141 machine_is_msm8x60_fluid()) {
7142 ebi2_cfg_ptr = ioremap_nocache(0x1a110000, SZ_4K);
7143 if (ebi2_cfg_ptr != 0) {
7144 /* EBI2_XMEM_CFG:PWRSAVE_MODE off */
7145 writel_relaxed(0UL, ebi2_cfg_ptr);
7146
7147 /* CS2: Delay 9 cycles (140ns@64MHz) between SMSC
7148 * LAN9221 Ethernet controller reads and writes.
7149 * The lowest 4 bits are the read delay, the next
7150 * 4 are the write delay. */
7151 writel_relaxed(0x031F1C99, ebi2_cfg_ptr + 0x10);
7152#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
7153 /*
7154 * RECOVERY=5, HOLD_WR=1
7155 * INIT_LATENCY_WR=1, INIT_LATENCY_RD=1
7156 * WAIT_WR=1, WAIT_RD=2
7157 */
7158 writel_relaxed(0x51010112, ebi2_cfg_ptr + 0x14);
7159 /*
7160 * HOLD_RD=1
7161 * ADV_OE_RECOVERY=0, ADDR_HOLD_ENA=1
7162 */
7163 writel_relaxed(0x01000020, ebi2_cfg_ptr + 0x34);
7164#else
7165 /* EBI2 CS3 muxed address/data,
7166 * two cyc addr enable */
7167 writel_relaxed(0xA3030020, ebi2_cfg_ptr + 0x34);
7168
7169#endif
7170 iounmap(ebi2_cfg_ptr);
7171 }
7172 }
7173}
7174
7175static void __init msm8x60_configure_smc91x(void)
7176{
7177 if (machine_is_msm8x60_sim()) {
7178
7179 smc91x_resources[0].start = 0x1b800300;
7180 smc91x_resources[0].end = 0x1b8003ff;
7181
7182 smc91x_resources[1].start = (NR_MSM_IRQS + 40);
7183 smc91x_resources[1].end = (NR_MSM_IRQS + 40);
7184
7185 } else if (machine_is_msm8x60_rumi3()) {
7186
7187 smc91x_resources[0].start = 0x1d000300;
7188 smc91x_resources[0].end = 0x1d0003ff;
7189
7190 smc91x_resources[1].start = TLMM_MSM_DIR_CONN_IRQ_0;
7191 smc91x_resources[1].end = TLMM_MSM_DIR_CONN_IRQ_0;
7192 }
7193}
7194
7195static void __init msm8x60_init_tlmm(void)
7196{
7197 if (machine_is_msm8x60_rumi3())
7198 msm_gpio_install_direct_irq(0, 0, 1);
7199}
7200
7201#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
7202 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
7203 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
7204 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\
7205 || defined(CONFIG_MMC_MSM_SDC5_SUPPORT))
7206
7207/* 8x60 is having 5 SDCC controllers */
7208#define MAX_SDCC_CONTROLLER 5
7209
7210struct msm_sdcc_gpio {
7211 /* maximum 10 GPIOs per SDCC controller */
7212 s16 no;
7213 /* name of this GPIO */
7214 const char *name;
7215 bool always_on;
7216 bool is_enabled;
7217};
7218
7219#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7220static struct msm_sdcc_gpio sdc1_gpio_cfg[] = {
7221 {159, "sdc1_dat_0"},
7222 {160, "sdc1_dat_1"},
7223 {161, "sdc1_dat_2"},
7224 {162, "sdc1_dat_3"},
7225#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
7226 {163, "sdc1_dat_4"},
7227 {164, "sdc1_dat_5"},
7228 {165, "sdc1_dat_6"},
7229 {166, "sdc1_dat_7"},
7230#endif
7231 {167, "sdc1_clk"},
7232 {168, "sdc1_cmd"}
7233};
7234#endif
7235
7236#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7237static struct msm_sdcc_gpio sdc2_gpio_cfg[] = {
7238 {143, "sdc2_dat_0"},
7239 {144, "sdc2_dat_1", 1},
7240 {145, "sdc2_dat_2"},
7241 {146, "sdc2_dat_3"},
7242#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
7243 {147, "sdc2_dat_4"},
7244 {148, "sdc2_dat_5"},
7245 {149, "sdc2_dat_6"},
7246 {150, "sdc2_dat_7"},
7247#endif
7248 {151, "sdc2_cmd"},
7249 {152, "sdc2_clk", 1}
7250};
7251#endif
7252
7253#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7254static struct msm_sdcc_gpio sdc5_gpio_cfg[] = {
7255 {95, "sdc5_cmd"},
7256 {96, "sdc5_dat_3"},
7257 {97, "sdc5_clk", 1},
7258 {98, "sdc5_dat_2"},
7259 {99, "sdc5_dat_1", 1},
7260 {100, "sdc5_dat_0"}
7261};
7262#endif
7263
7264struct msm_sdcc_pad_pull_cfg {
7265 enum msm_tlmm_pull_tgt pull;
7266 u32 pull_val;
7267};
7268
7269struct msm_sdcc_pad_drv_cfg {
7270 enum msm_tlmm_hdrive_tgt drv;
7271 u32 drv_val;
7272};
7273
7274#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7275static struct msm_sdcc_pad_drv_cfg sdc3_pad_on_drv_cfg[] = {
7276 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
7277 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
7278 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
7279};
7280
7281static struct msm_sdcc_pad_pull_cfg sdc3_pad_on_pull_cfg[] = {
7282 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
7283 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
7284};
7285
7286static struct msm_sdcc_pad_drv_cfg sdc3_pad_off_drv_cfg[] = {
7287 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
7288 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
7289 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
7290};
7291
7292static struct msm_sdcc_pad_pull_cfg sdc3_pad_off_pull_cfg[] = {
7293 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
7294 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
7295};
7296#endif
7297
7298#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7299static struct msm_sdcc_pad_drv_cfg sdc4_pad_on_drv_cfg[] = {
7300 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_8MA},
7301 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_8MA},
7302 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_8MA}
7303};
7304
7305static struct msm_sdcc_pad_pull_cfg sdc4_pad_on_pull_cfg[] = {
7306 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_UP},
7307 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_UP}
7308};
7309
7310static struct msm_sdcc_pad_drv_cfg sdc4_pad_off_drv_cfg[] = {
7311 {TLMM_HDRV_SDC4_CLK, GPIO_CFG_2MA},
7312 {TLMM_HDRV_SDC4_CMD, GPIO_CFG_2MA},
7313 {TLMM_HDRV_SDC4_DATA, GPIO_CFG_2MA}
7314};
7315
7316static struct msm_sdcc_pad_pull_cfg sdc4_pad_off_pull_cfg[] = {
7317 {TLMM_PULL_SDC4_CMD, GPIO_CFG_PULL_DOWN},
7318 {TLMM_PULL_SDC4_DATA, GPIO_CFG_PULL_DOWN}
7319};
7320#endif
7321
7322struct msm_sdcc_pin_cfg {
7323 /*
7324 * = 1 if controller pins are using gpios
7325 * = 0 if controller has dedicated MSM pins
7326 */
7327 u8 is_gpio;
7328 u8 cfg_sts;
7329 u8 gpio_data_size;
7330 struct msm_sdcc_gpio *gpio_data;
7331 struct msm_sdcc_pad_drv_cfg *pad_drv_on_data;
7332 struct msm_sdcc_pad_drv_cfg *pad_drv_off_data;
7333 struct msm_sdcc_pad_pull_cfg *pad_pull_on_data;
7334 struct msm_sdcc_pad_pull_cfg *pad_pull_off_data;
7335 u8 pad_drv_data_size;
7336 u8 pad_pull_data_size;
7337 u8 sdio_lpm_gpio_cfg;
7338};
7339
7340
7341static struct msm_sdcc_pin_cfg sdcc_pin_cfg_data[MAX_SDCC_CONTROLLER] = {
7342#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7343 [0] = {
7344 .is_gpio = 1,
7345 .gpio_data_size = ARRAY_SIZE(sdc1_gpio_cfg),
7346 .gpio_data = sdc1_gpio_cfg
7347 },
7348#endif
7349#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7350 [1] = {
7351 .is_gpio = 1,
7352 .gpio_data_size = ARRAY_SIZE(sdc2_gpio_cfg),
7353 .gpio_data = sdc2_gpio_cfg
7354 },
7355#endif
7356#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7357 [2] = {
7358 .is_gpio = 0,
7359 .pad_drv_on_data = sdc3_pad_on_drv_cfg,
7360 .pad_drv_off_data = sdc3_pad_off_drv_cfg,
7361 .pad_pull_on_data = sdc3_pad_on_pull_cfg,
7362 .pad_pull_off_data = sdc3_pad_off_pull_cfg,
7363 .pad_drv_data_size = ARRAY_SIZE(sdc3_pad_on_drv_cfg),
7364 .pad_pull_data_size = ARRAY_SIZE(sdc3_pad_on_pull_cfg)
7365 },
7366#endif
7367#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7368 [3] = {
7369 .is_gpio = 0,
7370 .pad_drv_on_data = sdc4_pad_on_drv_cfg,
7371 .pad_drv_off_data = sdc4_pad_off_drv_cfg,
7372 .pad_pull_on_data = sdc4_pad_on_pull_cfg,
7373 .pad_pull_off_data = sdc4_pad_off_pull_cfg,
7374 .pad_drv_data_size = ARRAY_SIZE(sdc4_pad_on_drv_cfg),
7375 .pad_pull_data_size = ARRAY_SIZE(sdc4_pad_on_pull_cfg)
7376 },
7377#endif
7378#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7379 [4] = {
7380 .is_gpio = 1,
7381 .gpio_data_size = ARRAY_SIZE(sdc5_gpio_cfg),
7382 .gpio_data = sdc5_gpio_cfg
7383 }
7384#endif
7385};
7386
7387static int msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
7388{
7389 int rc = 0;
7390 struct msm_sdcc_pin_cfg *curr;
7391 int n;
7392
7393 curr = &sdcc_pin_cfg_data[dev_id - 1];
7394 if (!curr->gpio_data)
7395 goto out;
7396
7397 for (n = 0; n < curr->gpio_data_size; n++) {
7398 if (enable) {
7399
7400 if (curr->gpio_data[n].always_on &&
7401 curr->gpio_data[n].is_enabled)
7402 continue;
7403 pr_debug("%s: enable: %s\n", __func__,
7404 curr->gpio_data[n].name);
7405 rc = gpio_request(curr->gpio_data[n].no,
7406 curr->gpio_data[n].name);
7407 if (rc) {
7408 pr_err("%s: gpio_request(%d, %s)"
7409 "failed", __func__,
7410 curr->gpio_data[n].no,
7411 curr->gpio_data[n].name);
7412 goto free_gpios;
7413 }
7414 /* set direction as output for all GPIOs */
7415 rc = gpio_direction_output(
7416 curr->gpio_data[n].no, 1);
7417 if (rc) {
7418 pr_err("%s: gpio_direction_output"
7419 "(%d, 1) failed\n", __func__,
7420 curr->gpio_data[n].no);
7421 goto free_gpios;
7422 }
7423 curr->gpio_data[n].is_enabled = 1;
7424 } else {
7425 /*
7426 * now free this GPIO which will put GPIO
7427 * in low power mode and will also put GPIO
7428 * in input mode
7429 */
7430 if (curr->gpio_data[n].always_on)
7431 continue;
7432 pr_debug("%s: disable: %s\n", __func__,
7433 curr->gpio_data[n].name);
7434 gpio_free(curr->gpio_data[n].no);
7435 curr->gpio_data[n].is_enabled = 0;
7436 }
7437 }
7438 curr->cfg_sts = enable;
7439 goto out;
7440
7441free_gpios:
7442 for (; n >= 0; n--)
7443 gpio_free(curr->gpio_data[n].no);
7444out:
7445 return rc;
7446}
7447
7448static int msm_sdcc_setup_pad(int dev_id, unsigned int enable)
7449{
7450 int rc = 0;
7451 struct msm_sdcc_pin_cfg *curr;
7452 int n;
7453
7454 curr = &sdcc_pin_cfg_data[dev_id - 1];
7455 if (!curr->pad_drv_on_data || !curr->pad_pull_on_data)
7456 goto out;
7457
7458 if (enable) {
7459 /*
7460 * set up the normal driver strength and
7461 * pull config for pads
7462 */
7463 for (n = 0; n < curr->pad_drv_data_size; n++) {
7464 if (curr->sdio_lpm_gpio_cfg) {
7465 if (curr->pad_drv_on_data[n].drv ==
7466 TLMM_HDRV_SDC4_DATA)
7467 continue;
7468 }
7469 msm_tlmm_set_hdrive(curr->pad_drv_on_data[n].drv,
7470 curr->pad_drv_on_data[n].drv_val);
7471 }
7472 for (n = 0; n < curr->pad_pull_data_size; n++) {
7473 if (curr->sdio_lpm_gpio_cfg) {
7474 if (curr->pad_pull_on_data[n].pull ==
7475 TLMM_PULL_SDC4_DATA)
7476 continue;
7477 }
7478 msm_tlmm_set_pull(curr->pad_pull_on_data[n].pull,
7479 curr->pad_pull_on_data[n].pull_val);
7480 }
7481 } else {
7482 /* set the low power config for pads */
7483 for (n = 0; n < curr->pad_drv_data_size; n++) {
7484 if (curr->sdio_lpm_gpio_cfg) {
7485 if (curr->pad_drv_off_data[n].drv ==
7486 TLMM_HDRV_SDC4_DATA)
7487 continue;
7488 }
7489 msm_tlmm_set_hdrive(
7490 curr->pad_drv_off_data[n].drv,
7491 curr->pad_drv_off_data[n].drv_val);
7492 }
7493 for (n = 0; n < curr->pad_pull_data_size; n++) {
7494 if (curr->sdio_lpm_gpio_cfg) {
7495 if (curr->pad_pull_off_data[n].pull ==
7496 TLMM_PULL_SDC4_DATA)
7497 continue;
7498 }
7499 msm_tlmm_set_pull(
7500 curr->pad_pull_off_data[n].pull,
7501 curr->pad_pull_off_data[n].pull_val);
7502 }
7503 }
7504 curr->cfg_sts = enable;
7505out:
7506 return rc;
7507}
7508
7509struct sdcc_reg {
7510 /* VDD/VCC/VCCQ regulator name on PMIC8058/PMIC8089*/
7511 const char *reg_name;
7512 /*
7513 * is set voltage supported for this regulator?
7514 * 0 = not supported, 1 = supported
7515 */
7516 unsigned char set_voltage_sup;
7517 /* voltage level to be set */
7518 unsigned int level;
7519 /* VDD/VCC/VCCQ voltage regulator handle */
7520 struct regulator *reg;
7521 /* is this regulator enabled? */
7522 bool enabled;
7523 /* is this regulator needs to be always on? */
7524 bool always_on;
7525 /* is operating power mode setting required for this regulator? */
7526 bool op_pwr_mode_sup;
7527 /* Load values for low power and high power mode */
7528 unsigned int lpm_uA;
7529 unsigned int hpm_uA;
7530};
7531/* all SDCC controllers requires VDD/VCC voltage */
7532static struct sdcc_reg sdcc_vdd_reg_data[MAX_SDCC_CONTROLLER];
7533/* only SDCC1 requires VCCQ voltage */
7534static struct sdcc_reg sdcc_vccq_reg_data[1];
7535/* all SDCC controllers may require voting for VDD PAD voltage */
7536static struct sdcc_reg sdcc_vddp_reg_data[MAX_SDCC_CONTROLLER];
7537
7538struct sdcc_reg_data {
7539 struct sdcc_reg *vdd_data; /* keeps VDD/VCC regulator info */
7540 struct sdcc_reg *vccq_data; /* keeps VCCQ regulator info */
7541 struct sdcc_reg *vddp_data; /* keeps VDD Pad regulator info */
7542 unsigned char sts; /* regulator enable/disable status */
7543};
7544/* msm8x60 have 5 SDCC controllers */
7545static struct sdcc_reg_data sdcc_vreg_data[MAX_SDCC_CONTROLLER];
7546
7547static int msm_sdcc_vreg_init_reg(struct sdcc_reg *vreg)
7548{
7549 int rc = 0;
7550
7551 /* Get the regulator handle */
7552 vreg->reg = regulator_get(NULL, vreg->reg_name);
7553 if (IS_ERR(vreg->reg)) {
7554 rc = PTR_ERR(vreg->reg);
7555 pr_err("%s: regulator_get(%s) failed. rc=%d\n",
7556 __func__, vreg->reg_name, rc);
7557 goto out;
7558 }
7559
7560 /* Set the voltage level if required */
7561 if (vreg->set_voltage_sup) {
7562 rc = regulator_set_voltage(vreg->reg, vreg->level,
7563 vreg->level);
7564 if (rc) {
7565 pr_err("%s: regulator_set_voltage(%s) failed rc=%d\n",
7566 __func__, vreg->reg_name, rc);
7567 goto vreg_put;
7568 }
7569 }
7570 goto out;
7571
7572vreg_put:
7573 regulator_put(vreg->reg);
7574out:
7575 return rc;
7576}
7577
7578static inline void msm_sdcc_vreg_deinit_reg(struct sdcc_reg *vreg)
7579{
7580 regulator_put(vreg->reg);
7581}
7582
7583/* this init function should be called only once for each SDCC */
7584static int msm_sdcc_vreg_init(int dev_id, unsigned char init)
7585{
7586 int rc = 0;
7587 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
7588 struct sdcc_reg_data *curr;
7589
7590 curr = &sdcc_vreg_data[dev_id - 1];
7591 curr_vdd_reg = curr->vdd_data;
7592 curr_vccq_reg = curr->vccq_data;
7593 curr_vddp_reg = curr->vddp_data;
7594
7595 if (init) {
7596 /*
7597 * get the regulator handle from voltage regulator framework
7598 * and then try to set the voltage level for the regulator
7599 */
7600 if (curr_vdd_reg) {
7601 rc = msm_sdcc_vreg_init_reg(curr_vdd_reg);
7602 if (rc)
7603 goto out;
7604 }
7605 if (curr_vccq_reg) {
7606 rc = msm_sdcc_vreg_init_reg(curr_vccq_reg);
7607 if (rc)
7608 goto vdd_reg_deinit;
7609 }
7610 if (curr_vddp_reg) {
7611 rc = msm_sdcc_vreg_init_reg(curr_vddp_reg);
7612 if (rc)
7613 goto vccq_reg_deinit;
7614 }
7615 goto out;
7616 } else
7617 /* deregister with all regulators from regulator framework */
7618 goto vddp_reg_deinit;
7619
7620vddp_reg_deinit:
7621 if (curr_vddp_reg)
7622 msm_sdcc_vreg_deinit_reg(curr_vddp_reg);
7623vccq_reg_deinit:
7624 if (curr_vccq_reg)
7625 msm_sdcc_vreg_deinit_reg(curr_vccq_reg);
7626vdd_reg_deinit:
7627 if (curr_vdd_reg)
7628 msm_sdcc_vreg_deinit_reg(curr_vdd_reg);
7629out:
7630 return rc;
7631}
7632
7633static int msm_sdcc_vreg_enable(struct sdcc_reg *vreg)
7634{
7635 int rc;
7636
7637 if (!vreg->enabled) {
7638 rc = regulator_enable(vreg->reg);
7639 if (rc) {
7640 pr_err("%s: regulator_enable(%s) failed. rc=%d\n",
7641 __func__, vreg->reg_name, rc);
7642 goto out;
7643 }
7644 vreg->enabled = 1;
7645 }
7646
7647 /* Put always_on regulator in HPM (high power mode) */
7648 if (vreg->always_on && vreg->op_pwr_mode_sup) {
7649 rc = regulator_set_optimum_mode(vreg->reg, vreg->hpm_uA);
7650 if (rc < 0) {
7651 pr_err("%s: reg=%s: HPM setting failed"
7652 " hpm_uA=%d, rc=%d\n",
7653 __func__, vreg->reg_name,
7654 vreg->hpm_uA, rc);
7655 goto vreg_disable;
7656 }
7657 rc = 0;
7658 }
7659 goto out;
7660
7661vreg_disable:
7662 regulator_disable(vreg->reg);
7663 vreg->enabled = 0;
7664out:
7665 return rc;
7666}
7667
7668static int msm_sdcc_vreg_disable(struct sdcc_reg *vreg)
7669{
7670 int rc;
7671
7672 /* Never disable always_on regulator */
7673 if (!vreg->always_on) {
7674 rc = regulator_disable(vreg->reg);
7675 if (rc) {
7676 pr_err("%s: regulator_disable(%s) failed. rc=%d\n",
7677 __func__, vreg->reg_name, rc);
7678 goto out;
7679 }
7680 vreg->enabled = 0;
7681 }
7682
7683 /* Put always_on regulator in LPM (low power mode) */
7684 if (vreg->always_on && vreg->op_pwr_mode_sup) {
7685 rc = regulator_set_optimum_mode(vreg->reg, vreg->lpm_uA);
7686 if (rc < 0) {
7687 pr_err("%s: reg=%s: LPM setting failed"
7688 " lpm_uA=%d, rc=%d\n",
7689 __func__,
7690 vreg->reg_name,
7691 vreg->lpm_uA, rc);
7692 goto out;
7693 }
7694 rc = 0;
7695 }
7696
7697out:
7698 return rc;
7699}
7700
7701static int msm_sdcc_setup_vreg(int dev_id, unsigned char enable)
7702{
7703 int rc = 0;
7704 struct sdcc_reg *curr_vdd_reg, *curr_vccq_reg, *curr_vddp_reg;
7705 struct sdcc_reg_data *curr;
7706
7707 curr = &sdcc_vreg_data[dev_id - 1];
7708 curr_vdd_reg = curr->vdd_data;
7709 curr_vccq_reg = curr->vccq_data;
7710 curr_vddp_reg = curr->vddp_data;
7711
7712 /* check if regulators are initialized or not? */
7713 if ((curr_vdd_reg && !curr_vdd_reg->reg) ||
7714 (curr_vccq_reg && !curr_vccq_reg->reg) ||
7715 (curr_vddp_reg && !curr_vddp_reg->reg)) {
7716 /* initialize voltage regulators required for this SDCC */
7717 rc = msm_sdcc_vreg_init(dev_id, 1);
7718 if (rc) {
7719 pr_err("%s: regulator init failed = %d\n",
7720 __func__, rc);
7721 goto out;
7722 }
7723 }
7724
7725 if (curr->sts == enable)
7726 goto out;
7727
7728 if (curr_vdd_reg) {
7729 if (enable)
7730 rc = msm_sdcc_vreg_enable(curr_vdd_reg);
7731 else
7732 rc = msm_sdcc_vreg_disable(curr_vdd_reg);
7733 if (rc)
7734 goto out;
7735 }
7736
7737 if (curr_vccq_reg) {
7738 if (enable)
7739 rc = msm_sdcc_vreg_enable(curr_vccq_reg);
7740 else
7741 rc = msm_sdcc_vreg_disable(curr_vccq_reg);
7742 if (rc)
7743 goto out;
7744 }
7745
7746 if (curr_vddp_reg) {
7747 if (enable)
7748 rc = msm_sdcc_vreg_enable(curr_vddp_reg);
7749 else
7750 rc = msm_sdcc_vreg_disable(curr_vddp_reg);
7751 if (rc)
7752 goto out;
7753 }
7754 curr->sts = enable;
7755
7756out:
7757 return rc;
7758}
7759
7760static u32 msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
7761{
7762 u32 rc_pin_cfg = 0;
7763 u32 rc_vreg_cfg = 0;
7764 u32 rc = 0;
7765 struct platform_device *pdev;
7766 struct msm_sdcc_pin_cfg *curr_pin_cfg;
7767
7768 pdev = container_of(dv, struct platform_device, dev);
7769
7770 /* setup gpio/pad */
7771 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
7772 if (curr_pin_cfg->cfg_sts == !!vdd)
7773 goto setup_vreg;
7774
7775 if (curr_pin_cfg->is_gpio)
7776 rc_pin_cfg = msm_sdcc_setup_gpio(pdev->id, !!vdd);
7777 else
7778 rc_pin_cfg = msm_sdcc_setup_pad(pdev->id, !!vdd);
7779
7780setup_vreg:
7781 /* setup voltage regulators */
7782 rc_vreg_cfg = msm_sdcc_setup_vreg(pdev->id, !!vdd);
7783
7784 if (rc_pin_cfg || rc_vreg_cfg)
7785 rc = rc_pin_cfg ? rc_pin_cfg : rc_vreg_cfg;
7786
7787 return rc;
7788}
7789
7790static void msm_sdcc_sdio_lpm_gpio(struct device *dv, unsigned int active)
7791{
7792 struct msm_sdcc_pin_cfg *curr_pin_cfg;
7793 struct platform_device *pdev;
7794
7795 pdev = container_of(dv, struct platform_device, dev);
7796 /* setup gpio/pad */
7797 curr_pin_cfg = &sdcc_pin_cfg_data[pdev->id - 1];
7798
7799 if (curr_pin_cfg->cfg_sts == active)
7800 return;
7801
7802 curr_pin_cfg->sdio_lpm_gpio_cfg = 1;
7803 if (curr_pin_cfg->is_gpio)
7804 msm_sdcc_setup_gpio(pdev->id, active);
7805 else
7806 msm_sdcc_setup_pad(pdev->id, active);
7807 curr_pin_cfg->sdio_lpm_gpio_cfg = 0;
7808}
7809
7810static int msm_sdc3_get_wpswitch(struct device *dev)
7811{
7812 struct platform_device *pdev;
7813 int status;
7814 pdev = container_of(dev, struct platform_device, dev);
7815
7816 status = gpio_request(GPIO_SDC_WP, "SD_WP_Switch");
7817 if (status) {
7818 pr_err("%s:Failed to request GPIO %d\n",
7819 __func__, GPIO_SDC_WP);
7820 } else {
7821 status = gpio_direction_input(GPIO_SDC_WP);
7822 if (!status) {
7823 status = gpio_get_value_cansleep(GPIO_SDC_WP);
7824 pr_info("%s: WP Status for Slot %d = %d\n",
7825 __func__, pdev->id, status);
7826 }
7827 gpio_free(GPIO_SDC_WP);
7828 }
7829 return status;
7830}
7831
7832#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7833int sdc5_register_status_notify(void (*callback)(int, void *),
7834 void *dev_id)
7835{
7836 sdc5_status_notify_cb = callback;
7837 sdc5_status_notify_cb_devid = dev_id;
7838 return 0;
7839}
7840#endif
7841
7842#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7843int sdc2_register_status_notify(void (*callback)(int, void *),
7844 void *dev_id)
7845{
7846 sdc2_status_notify_cb = callback;
7847 sdc2_status_notify_cb_devid = dev_id;
7848 return 0;
7849}
7850#endif
7851
7852/* Interrupt handler for SDC2 and SDC5 detection
7853 * This function uses dual-edge interrputs settings in order
7854 * to get SDIO detection when the GPIO is rising and SDIO removal
7855 * when the GPIO is falling */
7856static irqreturn_t msm8x60_multi_sdio_slot_status_irq(int irq, void *dev_id)
7857{
7858 int status;
7859
7860 if (!machine_is_msm8x60_fusion() &&
7861 !machine_is_msm8x60_fusn_ffa())
7862 return IRQ_NONE;
7863
7864 status = gpio_get_value(MDM2AP_SYNC);
7865 pr_info("%s: MDM2AP_SYNC Status = %d\n",
7866 __func__, status);
7867
7868#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
7869 if (sdc2_status_notify_cb) {
7870 pr_info("%s: calling sdc2_status_notify_cb\n", __func__);
7871 sdc2_status_notify_cb(status,
7872 sdc2_status_notify_cb_devid);
7873 }
7874#endif
7875
7876#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
7877 if (sdc5_status_notify_cb) {
7878 pr_info("%s: calling sdc5_status_notify_cb\n", __func__);
7879 sdc5_status_notify_cb(status,
7880 sdc5_status_notify_cb_devid);
7881 }
7882#endif
7883 return IRQ_HANDLED;
7884}
7885
7886static int msm8x60_multi_sdio_init(void)
7887{
7888 int ret, irq_num;
7889
7890 if (!machine_is_msm8x60_fusion() &&
7891 !machine_is_msm8x60_fusn_ffa())
7892 return 0;
7893
7894 ret = msm_gpiomux_get(MDM2AP_SYNC);
7895 if (ret) {
7896 pr_err("%s:Failed to request GPIO %d, ret=%d\n",
7897 __func__, MDM2AP_SYNC, ret);
7898 return ret;
7899 }
7900
7901 irq_num = gpio_to_irq(MDM2AP_SYNC);
7902
7903 ret = request_irq(irq_num,
7904 msm8x60_multi_sdio_slot_status_irq,
7905 IRQ_TYPE_EDGE_BOTH,
7906 "sdio_multidetection", NULL);
7907
7908 if (ret) {
7909 pr_err("%s:Failed to request irq, ret=%d\n",
7910 __func__, ret);
7911 return ret;
7912 }
7913
7914 return ret;
7915}
7916
7917#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
7918#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
7919static unsigned int msm8x60_sdcc_slot_status(struct device *dev)
7920{
7921 int status;
7922
7923 status = gpio_request(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)
7924 , "SD_HW_Detect");
7925 if (status) {
7926 pr_err("%s:Failed to request GPIO %d\n", __func__,
7927 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
7928 } else {
7929 status = gpio_direction_input(
7930 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
7931 if (!status)
7932 status = !(gpio_get_value_cansleep(
7933 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1)));
7934 gpio_free(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC3_DET - 1));
7935 }
7936 return (unsigned int) status;
7937}
7938#endif
7939#endif
7940
7941#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
7942static int msm_sdcc_cfg_mpm_sdiowakeup(struct device *dev, unsigned mode)
7943{
7944 struct platform_device *pdev;
7945 enum msm_mpm_pin pin;
7946 int ret = 0;
7947
7948 pdev = container_of(dev, struct platform_device, dev);
7949
7950 /* Only SDCC4 slot connected to WLAN chip has wakeup capability */
7951 if (pdev->id == 4)
7952 pin = MSM_MPM_PIN_SDC4_DAT1;
7953 else
7954 return -EINVAL;
7955
7956 switch (mode) {
7957 case SDC_DAT1_DISABLE:
7958 ret = msm_mpm_enable_pin(pin, 0);
7959 break;
7960 case SDC_DAT1_ENABLE:
7961 ret = msm_mpm_set_pin_type(pin, IRQ_TYPE_LEVEL_LOW);
7962 ret = msm_mpm_enable_pin(pin, 1);
7963 break;
7964 case SDC_DAT1_ENWAKE:
7965 ret = msm_mpm_set_pin_wake(pin, 1);
7966 break;
7967 case SDC_DAT1_DISWAKE:
7968 ret = msm_mpm_set_pin_wake(pin, 0);
7969 break;
7970 default:
7971 ret = -EINVAL;
7972 break;
7973 }
7974 return ret;
7975}
7976#endif
7977#endif
7978
7979#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
7980static struct mmc_platform_data msm8x60_sdc1_data = {
7981 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
7982 .translate_vdd = msm_sdcc_setup_power,
7983#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
7984 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
7985#else
7986 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
7987#endif
7988 .msmsdcc_fmin = 400000,
7989 .msmsdcc_fmid = 24000000,
7990 .msmsdcc_fmax = 48000000,
7991 .nonremovable = 1,
7992 .pclk_src_dfab = 1,
7993#ifdef CONFIG_MMC_MSM_SDC1_DUMMY52_REQUIRED
7994 .dummy52_required = 1,
7995#endif
7996};
7997#endif
7998
7999#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8000static struct mmc_platform_data msm8x60_sdc2_data = {
8001 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8002 .translate_vdd = msm_sdcc_setup_power,
8003 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8004 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
8005 .msmsdcc_fmin = 400000,
8006 .msmsdcc_fmid = 24000000,
8007 .msmsdcc_fmax = 48000000,
8008 .nonremovable = 0,
8009 .pclk_src_dfab = 1,
8010 .register_status_notify = sdc2_register_status_notify,
8011#ifdef CONFIG_MMC_MSM_SDC2_DUMMY52_REQUIRED
8012 .dummy52_required = 1,
8013#endif
8014#ifdef CONFIG_MSM_SDIO_AL
8015 .is_sdio_al_client = 1,
8016#endif
8017};
8018#endif
8019
8020#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8021static struct mmc_platform_data msm8x60_sdc3_data = {
8022 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8023 .translate_vdd = msm_sdcc_setup_power,
8024 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8025 .wpswitch = msm_sdc3_get_wpswitch,
8026#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
8027 .status = msm8x60_sdcc_slot_status,
8028 .status_irq = PM8058_GPIO_IRQ(PM8058_IRQ_BASE,
8029 PMIC_GPIO_SDC3_DET - 1),
8030 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
8031#endif
8032 .msmsdcc_fmin = 400000,
8033 .msmsdcc_fmid = 24000000,
8034 .msmsdcc_fmax = 48000000,
8035 .nonremovable = 0,
8036 .pclk_src_dfab = 1,
8037#ifdef CONFIG_MMC_MSM_SDC3_DUMMY52_REQUIRED
8038 .dummy52_required = 1,
8039#endif
8040};
8041#endif
8042
8043#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8044static struct mmc_platform_data msm8x60_sdc4_data = {
8045 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
8046 .translate_vdd = msm_sdcc_setup_power,
8047 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8048 .msmsdcc_fmin = 400000,
8049 .msmsdcc_fmid = 24000000,
8050 .msmsdcc_fmax = 48000000,
8051 .nonremovable = 0,
8052 .pclk_src_dfab = 1,
8053 .cfg_mpm_sdiowakeup = msm_sdcc_cfg_mpm_sdiowakeup,
8054#ifdef CONFIG_MMC_MSM_SDC4_DUMMY52_REQUIRED
8055 .dummy52_required = 1,
8056#endif
8057};
8058#endif
8059
8060#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8061static struct mmc_platform_data msm8x60_sdc5_data = {
8062 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_165_195,
8063 .translate_vdd = msm_sdcc_setup_power,
8064 .sdio_lpm_gpio_setup = msm_sdcc_sdio_lpm_gpio,
8065 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
8066 .msmsdcc_fmin = 400000,
8067 .msmsdcc_fmid = 24000000,
8068 .msmsdcc_fmax = 48000000,
8069 .nonremovable = 0,
8070 .pclk_src_dfab = 1,
8071 .register_status_notify = sdc5_register_status_notify,
8072#ifdef CONFIG_MMC_MSM_SDC5_DUMMY52_REQUIRED
8073 .dummy52_required = 1,
8074#endif
8075#ifdef CONFIG_MSM_SDIO_AL
8076 .is_sdio_al_client = 1,
8077#endif
8078};
8079#endif
8080
8081static void __init msm8x60_init_mmc(void)
8082{
8083#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
8084 /* SDCC1 : eMMC card connected */
8085 sdcc_vreg_data[0].vdd_data = &sdcc_vdd_reg_data[0];
8086 sdcc_vreg_data[0].vdd_data->reg_name = "8901_l5";
8087 sdcc_vreg_data[0].vdd_data->set_voltage_sup = 1;
8088 sdcc_vreg_data[0].vdd_data->level = 2850000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008089
8090 sdcc_vreg_data[0].vccq_data = &sdcc_vccq_reg_data[0];
8091 sdcc_vreg_data[0].vccq_data->reg_name = "8901_lvs0";
8092 sdcc_vreg_data[0].vccq_data->set_voltage_sup = 0;
8093 sdcc_vreg_data[0].vccq_data->always_on = 1;
8094
8095 msm_add_sdcc(1, &msm8x60_sdc1_data);
8096#endif
8097#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
8098 /*
8099 * MDM SDIO client is connected to SDC2 on charm SURF/FFA
8100 * and no card is connected on 8660 SURF/FFA/FLUID.
8101 */
8102 sdcc_vreg_data[1].vdd_data = &sdcc_vdd_reg_data[1];
8103 sdcc_vreg_data[1].vdd_data->reg_name = "8058_s3";
8104 sdcc_vreg_data[1].vdd_data->set_voltage_sup = 1;
8105 sdcc_vreg_data[1].vdd_data->level = 1800000;
8106
8107 sdcc_vreg_data[1].vccq_data = NULL;
8108
8109 if (machine_is_msm8x60_fusion())
8110 msm8x60_sdc2_data.msmsdcc_fmax = 24000000;
8111 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8112#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
8113 msm8x60_sdc2_data.sdiowakeup_irq = gpio_to_irq(144);
8114 msm_sdcc_setup_gpio(2, 1);
8115#endif
8116 msm_add_sdcc(2, &msm8x60_sdc2_data);
8117 }
8118#endif
8119#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
8120 /* SDCC3 : External card slot connected */
8121 sdcc_vreg_data[2].vdd_data = &sdcc_vdd_reg_data[2];
8122 sdcc_vreg_data[2].vdd_data->reg_name = "8058_l14";
8123 sdcc_vreg_data[2].vdd_data->set_voltage_sup = 1;
8124 sdcc_vreg_data[2].vdd_data->level = 2850000;
8125 sdcc_vreg_data[2].vdd_data->always_on = 1;
8126 sdcc_vreg_data[2].vdd_data->op_pwr_mode_sup = 1;
8127 sdcc_vreg_data[2].vdd_data->lpm_uA = 9000;
8128 sdcc_vreg_data[2].vdd_data->hpm_uA = 200000;
8129
8130 sdcc_vreg_data[2].vccq_data = NULL;
8131
8132 sdcc_vreg_data[2].vddp_data = &sdcc_vddp_reg_data[2];
8133 sdcc_vreg_data[2].vddp_data->reg_name = "8058_l5";
8134 sdcc_vreg_data[2].vddp_data->set_voltage_sup = 1;
8135 sdcc_vreg_data[2].vddp_data->level = 2850000;
8136 sdcc_vreg_data[2].vddp_data->always_on = 1;
8137 sdcc_vreg_data[2].vddp_data->op_pwr_mode_sup = 1;
8138 /* Sleep current required is ~300 uA. But min. RPM
8139 * vote can be in terms of mA (min. 1 mA).
8140 * So let's vote for 2 mA during sleep.
8141 */
8142 sdcc_vreg_data[2].vddp_data->lpm_uA = 2000;
8143 /* Max. Active current required is 16 mA */
8144 sdcc_vreg_data[2].vddp_data->hpm_uA = 16000;
8145
8146 if (machine_is_msm8x60_fluid())
8147 msm8x60_sdc3_data.wpswitch = NULL;
8148 msm_add_sdcc(3, &msm8x60_sdc3_data);
8149#endif
8150#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
8151 /* SDCC4 : WLAN WCN1314 chip is connected */
8152 sdcc_vreg_data[3].vdd_data = &sdcc_vdd_reg_data[3];
8153 sdcc_vreg_data[3].vdd_data->reg_name = "8058_s3";
8154 sdcc_vreg_data[3].vdd_data->set_voltage_sup = 1;
8155 sdcc_vreg_data[3].vdd_data->level = 1800000;
8156
8157 sdcc_vreg_data[3].vccq_data = NULL;
8158
8159 msm_add_sdcc(4, &msm8x60_sdc4_data);
8160#endif
8161#ifdef CONFIG_MMC_MSM_SDC5_SUPPORT
8162 /*
8163 * MDM SDIO client is connected to SDC5 on charm SURF/FFA
8164 * and no card is connected on 8660 SURF/FFA/FLUID.
8165 */
8166 sdcc_vreg_data[4].vdd_data = &sdcc_vdd_reg_data[4];
8167 sdcc_vreg_data[4].vdd_data->reg_name = "8058_s3";
8168 sdcc_vreg_data[4].vdd_data->set_voltage_sup = 1;
8169 sdcc_vreg_data[4].vdd_data->level = 1800000;
8170
8171 sdcc_vreg_data[4].vccq_data = NULL;
8172
8173 if (machine_is_msm8x60_fusion())
8174 msm8x60_sdc5_data.msmsdcc_fmax = 24000000;
8175 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8176#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
8177 msm8x60_sdc5_data.sdiowakeup_irq = gpio_to_irq(99);
8178 msm_sdcc_setup_gpio(5, 1);
8179#endif
8180 msm_add_sdcc(5, &msm8x60_sdc5_data);
8181 }
8182#endif
8183}
8184
8185#if !defined(CONFIG_GPIO_SX150X) && !defined(CONFIG_GPIO_SX150X_MODULE)
8186static inline void display_common_power(int on) {}
8187#else
8188
8189#define _GET_REGULATOR(var, name) do { \
8190 if (var == NULL) { \
8191 var = regulator_get(NULL, name); \
8192 if (IS_ERR(var)) { \
8193 pr_err("'%s' regulator not found, rc=%ld\n", \
8194 name, PTR_ERR(var)); \
8195 var = NULL; \
8196 } \
8197 } \
8198} while (0)
8199
8200static int dsub_regulator(int on)
8201{
8202 static struct regulator *dsub_reg;
8203 static struct regulator *mpp0_reg;
8204 static int dsub_reg_enabled;
8205 int rc = 0;
8206
8207 _GET_REGULATOR(dsub_reg, "8901_l3");
8208 if (IS_ERR(dsub_reg)) {
8209 printk(KERN_ERR "%s: failed to get reg 8901_l3 err=%ld",
8210 __func__, PTR_ERR(dsub_reg));
8211 return PTR_ERR(dsub_reg);
8212 }
8213
8214 _GET_REGULATOR(mpp0_reg, "8901_mpp0");
8215 if (IS_ERR(mpp0_reg)) {
8216 printk(KERN_ERR "%s: failed to get reg 8901_mpp0 err=%ld",
8217 __func__, PTR_ERR(mpp0_reg));
8218 return PTR_ERR(mpp0_reg);
8219 }
8220
8221 if (on && !dsub_reg_enabled) {
8222 rc = regulator_set_voltage(dsub_reg, 3300000, 3300000);
8223 if (rc) {
8224 printk(KERN_ERR "%s: failed to set reg 8901_l3 voltage"
8225 " err=%d", __func__, rc);
8226 goto dsub_regulator_err;
8227 }
8228 rc = regulator_enable(dsub_reg);
8229 if (rc) {
8230 printk(KERN_ERR "%s: failed to enable reg 8901_l3"
8231 " err=%d", __func__, rc);
8232 goto dsub_regulator_err;
8233 }
8234 rc = regulator_enable(mpp0_reg);
8235 if (rc) {
8236 printk(KERN_ERR "%s: failed to enable reg 8901_mpp0"
8237 " err=%d", __func__, rc);
8238 goto dsub_regulator_err;
8239 }
8240 dsub_reg_enabled = 1;
8241 } else if (!on && dsub_reg_enabled) {
8242 rc = regulator_disable(dsub_reg);
8243 if (rc)
8244 printk(KERN_WARNING "%s: failed to disable reg 8901_l3"
8245 " err=%d", __func__, rc);
8246 rc = regulator_disable(mpp0_reg);
8247 if (rc)
8248 printk(KERN_WARNING "%s: failed to disable reg "
8249 "8901_mpp0 err=%d", __func__, rc);
8250 dsub_reg_enabled = 0;
8251 }
8252
8253 return rc;
8254
8255dsub_regulator_err:
8256 regulator_put(mpp0_reg);
8257 regulator_put(dsub_reg);
8258 return rc;
8259}
8260
8261static int display_power_on;
8262static void setup_display_power(void)
8263{
8264 if (display_power_on)
8265 if (lcdc_vga_enabled) {
8266 dsub_regulator(1);
8267 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8268 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8269 if (machine_is_msm8x60_ffa() ||
8270 machine_is_msm8x60_fusn_ffa())
8271 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 1);
8272 } else {
8273 dsub_regulator(0);
8274 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 1);
8275 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 1);
8276 if (machine_is_msm8x60_ffa() ||
8277 machine_is_msm8x60_fusn_ffa())
8278 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8279 }
8280 else {
8281 dsub_regulator(0);
8282 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa())
8283 gpio_set_value_cansleep(GPIO_DONGLE_PWR_EN, 0);
8284 /* BACKLIGHT */
8285 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, 0);
8286 /* LVDS */
8287 gpio_set_value_cansleep(GPIO_LVDS_SHUTDOWN_N, 0);
8288 }
8289}
8290
8291#define _GET_REGULATOR(var, name) do { \
8292 if (var == NULL) { \
8293 var = regulator_get(NULL, name); \
8294 if (IS_ERR(var)) { \
8295 pr_err("'%s' regulator not found, rc=%ld\n", \
8296 name, PTR_ERR(var)); \
8297 var = NULL; \
8298 } \
8299 } \
8300} while (0)
8301
8302#define GPIO_RESX_N (GPIO_EXPANDER_GPIO_BASE + 2)
8303
8304static void display_common_power(int on)
8305{
8306 int rc;
8307 static struct regulator *display_reg;
8308
8309 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
8310 machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) {
8311 if (on) {
8312 /* LVDS */
8313 _GET_REGULATOR(display_reg, "8901_l2");
8314 if (!display_reg)
8315 return;
8316 rc = regulator_set_voltage(display_reg,
8317 3300000, 3300000);
8318 if (rc)
8319 goto out;
8320 rc = regulator_enable(display_reg);
8321 if (rc)
8322 goto out;
8323 rc = gpio_request(GPIO_LVDS_SHUTDOWN_N,
8324 "LVDS_STDN_OUT_N");
8325 if (rc) {
8326 printk(KERN_ERR "%s: LVDS gpio %d request"
8327 "failed\n", __func__,
8328 GPIO_LVDS_SHUTDOWN_N);
8329 goto out2;
8330 }
8331
8332 /* BACKLIGHT */
8333 rc = gpio_request(GPIO_BACKLIGHT_EN, "BACKLIGHT_EN");
8334 if (rc) {
8335 printk(KERN_ERR "%s: BACKLIGHT gpio %d request"
8336 "failed\n", __func__,
8337 GPIO_BACKLIGHT_EN);
8338 goto out3;
8339 }
8340
8341 if (machine_is_msm8x60_ffa() ||
8342 machine_is_msm8x60_fusn_ffa()) {
8343 rc = gpio_request(GPIO_DONGLE_PWR_EN,
8344 "DONGLE_PWR_EN");
8345 if (rc) {
8346 printk(KERN_ERR "%s: DONGLE_PWR_EN gpio"
8347 " %d request failed\n", __func__,
8348 GPIO_DONGLE_PWR_EN);
8349 goto out4;
8350 }
8351 }
8352
8353 gpio_direction_output(GPIO_LVDS_SHUTDOWN_N, 0);
8354 gpio_direction_output(GPIO_BACKLIGHT_EN, 0);
8355 if (machine_is_msm8x60_ffa() ||
8356 machine_is_msm8x60_fusn_ffa())
8357 gpio_direction_output(GPIO_DONGLE_PWR_EN, 0);
8358 mdelay(20);
8359 display_power_on = 1;
8360 setup_display_power();
8361 } else {
8362 if (display_power_on) {
8363 display_power_on = 0;
8364 setup_display_power();
8365 mdelay(20);
8366 if (machine_is_msm8x60_ffa() ||
8367 machine_is_msm8x60_fusn_ffa())
8368 gpio_free(GPIO_DONGLE_PWR_EN);
8369 goto out4;
8370 }
8371 }
8372 }
8373#if defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
8374 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA)
8375 else if (machine_is_msm8x60_fluid()) {
8376 static struct regulator *fluid_reg;
8377 static struct regulator *fluid_reg2;
8378
8379 if (on) {
8380 _GET_REGULATOR(fluid_reg, "8901_l2");
8381 if (!fluid_reg)
8382 return;
8383 _GET_REGULATOR(fluid_reg2, "8058_s3");
8384 if (!fluid_reg2) {
8385 regulator_put(fluid_reg);
8386 return;
8387 }
8388 rc = gpio_request(GPIO_RESX_N, "RESX_N");
8389 if (rc) {
8390 regulator_put(fluid_reg2);
8391 regulator_put(fluid_reg);
8392 return;
8393 }
8394 regulator_set_voltage(fluid_reg, 2850000, 2850000);
8395 regulator_set_voltage(fluid_reg2, 1800000, 1800000);
8396 regulator_enable(fluid_reg);
8397 regulator_enable(fluid_reg2);
8398 msleep(20);
8399 gpio_direction_output(GPIO_RESX_N, 0);
8400 udelay(10);
8401 gpio_set_value_cansleep(GPIO_RESX_N, 1);
8402 display_power_on = 1;
8403 setup_display_power();
8404 } else {
8405 gpio_set_value_cansleep(GPIO_RESX_N, 0);
8406 gpio_free(GPIO_RESX_N);
8407 msleep(20);
8408 regulator_disable(fluid_reg2);
8409 regulator_disable(fluid_reg);
8410 regulator_put(fluid_reg2);
8411 regulator_put(fluid_reg);
8412 display_power_on = 0;
8413 setup_display_power();
8414 fluid_reg = NULL;
8415 fluid_reg2 = NULL;
8416 }
8417 }
8418#endif
8419 return;
8420
8421out4:
8422 gpio_free(GPIO_BACKLIGHT_EN);
8423out3:
8424 gpio_free(GPIO_LVDS_SHUTDOWN_N);
8425out2:
8426 regulator_disable(display_reg);
8427out:
8428 regulator_put(display_reg);
8429 display_reg = NULL;
8430}
8431#undef _GET_REGULATOR
8432#endif
8433
8434static int mipi_dsi_panel_power(int on);
8435
8436#define LCDC_NUM_GPIO 28
8437#define LCDC_GPIO_START 0
8438
8439static void lcdc_samsung_panel_power(int on)
8440{
8441 int n, ret = 0;
8442
8443 display_common_power(on);
8444
8445 for (n = 0; n < LCDC_NUM_GPIO; n++) {
8446 if (on) {
8447 ret = gpio_request(LCDC_GPIO_START + n, "LCDC_GPIO");
8448 if (unlikely(ret)) {
8449 pr_err("%s not able to get gpio\n", __func__);
8450 break;
8451 }
8452 } else
8453 gpio_free(LCDC_GPIO_START + n);
8454 }
8455
8456 if (ret) {
8457 for (n--; n >= 0; n--)
8458 gpio_free(LCDC_GPIO_START + n);
8459 }
8460
8461 mipi_dsi_panel_power(0); /* set 8058_ldo0 to LPM */
8462}
8463
8464#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
8465#define _GET_REGULATOR(var, name) do { \
8466 var = regulator_get(NULL, name); \
8467 if (IS_ERR(var)) { \
8468 pr_err("'%s' regulator not found, rc=%ld\n", \
8469 name, IS_ERR(var)); \
8470 var = NULL; \
8471 return -ENODEV; \
8472 } \
8473} while (0)
8474
8475static int hdmi_enable_5v(int on)
8476{
8477 static struct regulator *reg_8901_hdmi_mvs; /* HDMI_5V */
8478 static struct regulator *reg_8901_mpp0; /* External 5V */
8479 static int prev_on;
8480 int rc;
8481
8482 if (on == prev_on)
8483 return 0;
8484
8485 if (!reg_8901_hdmi_mvs)
8486 _GET_REGULATOR(reg_8901_hdmi_mvs, "8901_hdmi_mvs");
8487 if (!reg_8901_mpp0)
8488 _GET_REGULATOR(reg_8901_mpp0, "8901_mpp0");
8489
8490 if (on) {
8491 rc = regulator_enable(reg_8901_mpp0);
8492 if (rc) {
8493 pr_err("'%s' regulator enable failed, rc=%d\n",
8494 "reg_8901_mpp0", rc);
8495 return rc;
8496 }
8497 rc = regulator_enable(reg_8901_hdmi_mvs);
8498 if (rc) {
8499 pr_err("'%s' regulator enable failed, rc=%d\n",
8500 "8901_hdmi_mvs", rc);
8501 return rc;
8502 }
8503 pr_info("%s(on): success\n", __func__);
8504 } else {
8505 rc = regulator_disable(reg_8901_hdmi_mvs);
8506 if (rc)
8507 pr_warning("'%s' regulator disable failed, rc=%d\n",
8508 "8901_hdmi_mvs", rc);
8509 rc = regulator_disable(reg_8901_mpp0);
8510 if (rc)
8511 pr_warning("'%s' regulator disable failed, rc=%d\n",
8512 "reg_8901_mpp0", rc);
8513 pr_info("%s(off): success\n", __func__);
8514 }
8515
8516 prev_on = on;
8517
8518 return 0;
8519}
8520
8521static int hdmi_core_power(int on, int show)
8522{
8523 static struct regulator *reg_8058_l16; /* VDD_HDMI */
8524 static int prev_on;
8525 int rc;
8526
8527 if (on == prev_on)
8528 return 0;
8529
8530 if (!reg_8058_l16)
8531 _GET_REGULATOR(reg_8058_l16, "8058_l16");
8532
8533 if (on) {
8534 rc = regulator_set_voltage(reg_8058_l16, 1800000, 1800000);
8535 if (!rc)
8536 rc = regulator_enable(reg_8058_l16);
8537 if (rc) {
8538 pr_err("'%s' regulator enable failed, rc=%d\n",
8539 "8058_l16", rc);
8540 return rc;
8541 }
8542 rc = gpio_request(170, "HDMI_DDC_CLK");
8543 if (rc) {
8544 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8545 "HDMI_DDC_CLK", 170, rc);
8546 goto error1;
8547 }
8548 rc = gpio_request(171, "HDMI_DDC_DATA");
8549 if (rc) {
8550 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8551 "HDMI_DDC_DATA", 171, rc);
8552 goto error2;
8553 }
8554 rc = gpio_request(172, "HDMI_HPD");
8555 if (rc) {
8556 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8557 "HDMI_HPD", 172, rc);
8558 goto error3;
8559 }
8560 pr_info("%s(on): success\n", __func__);
8561 } else {
8562 gpio_free(170);
8563 gpio_free(171);
8564 gpio_free(172);
8565 rc = regulator_disable(reg_8058_l16);
8566 if (rc)
8567 pr_warning("'%s' regulator disable failed, rc=%d\n",
8568 "8058_l16", rc);
8569 pr_info("%s(off): success\n", __func__);
8570 }
8571
8572 prev_on = on;
8573
8574 return 0;
8575
8576error3:
8577 gpio_free(171);
8578error2:
8579 gpio_free(170);
8580error1:
8581 regulator_disable(reg_8058_l16);
8582 return rc;
8583}
8584
8585static int hdmi_cec_power(int on)
8586{
8587 static struct regulator *reg_8901_l3; /* HDMI_CEC */
8588 static int prev_on;
8589 int rc;
8590
8591 if (on == prev_on)
8592 return 0;
8593
8594 if (!reg_8901_l3)
8595 _GET_REGULATOR(reg_8901_l3, "8901_l3");
8596
8597 if (on) {
8598 rc = regulator_set_voltage(reg_8901_l3, 3300000, 3300000);
8599 if (!rc)
8600 rc = regulator_enable(reg_8901_l3);
8601 if (rc) {
8602 pr_err("'%s' regulator enable failed, rc=%d\n",
8603 "8901_l3", rc);
8604 return rc;
8605 }
8606 rc = gpio_request(169, "HDMI_CEC_VAR");
8607 if (rc) {
8608 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
8609 "HDMI_CEC_VAR", 169, rc);
8610 goto error;
8611 }
8612 pr_info("%s(on): success\n", __func__);
8613 } else {
8614 gpio_free(169);
8615 rc = regulator_disable(reg_8901_l3);
8616 if (rc)
8617 pr_warning("'%s' regulator disable failed, rc=%d\n",
8618 "8901_l3", rc);
8619 pr_info("%s(off): success\n", __func__);
8620 }
8621
8622 prev_on = on;
8623
8624 return 0;
8625error:
8626 regulator_disable(reg_8901_l3);
8627 return rc;
8628}
8629
8630#undef _GET_REGULATOR
8631
8632#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
8633
8634static int lcdc_panel_power(int on)
8635{
8636 int flag_on = !!on;
8637 static int lcdc_power_save_on;
8638
8639 if (lcdc_power_save_on == flag_on)
8640 return 0;
8641
8642 lcdc_power_save_on = flag_on;
8643
8644 lcdc_samsung_panel_power(on);
8645
8646 return 0;
8647}
8648
8649#ifdef CONFIG_MSM_BUS_SCALING
8650#ifdef CONFIG_FB_MSM_LCDC_DSUB
8651static struct msm_bus_vectors mdp_init_vectors[] = {
8652 /* For now, 0th array entry is reserved.
8653 * Please leave 0 as is and don't use it
8654 */
8655 {
8656 .src = MSM_BUS_MASTER_MDP_PORT0,
8657 .dst = MSM_BUS_SLAVE_SMI,
8658 .ab = 0,
8659 .ib = 0,
8660 },
8661 /* Master and slaves can be from different fabrics */
8662 {
8663 .src = MSM_BUS_MASTER_MDP_PORT0,
8664 .dst = MSM_BUS_SLAVE_EBI_CH0,
8665 .ab = 0,
8666 .ib = 0,
8667 },
8668};
8669
8670static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
8671 /* Default case static display/UI/2d/3d if FB SMI */
8672 {
8673 .src = MSM_BUS_MASTER_MDP_PORT0,
8674 .dst = MSM_BUS_SLAVE_SMI,
8675 .ab = 388800000,
8676 .ib = 486000000,
8677 },
8678 /* Master and slaves can be from different fabrics */
8679 {
8680 .src = MSM_BUS_MASTER_MDP_PORT0,
8681 .dst = MSM_BUS_SLAVE_EBI_CH0,
8682 .ab = 0,
8683 .ib = 0,
8684 },
8685};
8686
8687static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
8688 /* Default case static display/UI/2d/3d if FB SMI */
8689 {
8690 .src = MSM_BUS_MASTER_MDP_PORT0,
8691 .dst = MSM_BUS_SLAVE_SMI,
8692 .ab = 0,
8693 .ib = 0,
8694 },
8695 /* Master and slaves can be from different fabrics */
8696 {
8697 .src = MSM_BUS_MASTER_MDP_PORT0,
8698 .dst = MSM_BUS_SLAVE_EBI_CH0,
8699 .ab = 388800000,
8700 .ib = 486000000 * 2,
8701 },
8702};
8703static struct msm_bus_vectors mdp_vga_vectors[] = {
8704 /* VGA and less video */
8705 {
8706 .src = MSM_BUS_MASTER_MDP_PORT0,
8707 .dst = MSM_BUS_SLAVE_SMI,
8708 .ab = 458092800,
8709 .ib = 572616000,
8710 },
8711 {
8712 .src = MSM_BUS_MASTER_MDP_PORT0,
8713 .dst = MSM_BUS_SLAVE_EBI_CH0,
8714 .ab = 458092800,
8715 .ib = 572616000 * 2,
8716 },
8717};
8718static struct msm_bus_vectors mdp_720p_vectors[] = {
8719 /* 720p and less video */
8720 {
8721 .src = MSM_BUS_MASTER_MDP_PORT0,
8722 .dst = MSM_BUS_SLAVE_SMI,
8723 .ab = 471744000,
8724 .ib = 589680000,
8725 },
8726 /* Master and slaves can be from different fabrics */
8727 {
8728 .src = MSM_BUS_MASTER_MDP_PORT0,
8729 .dst = MSM_BUS_SLAVE_EBI_CH0,
8730 .ab = 471744000,
8731 .ib = 589680000 * 2,
8732 },
8733};
8734
8735static struct msm_bus_vectors mdp_1080p_vectors[] = {
8736 /* 1080p and less video */
8737 {
8738 .src = MSM_BUS_MASTER_MDP_PORT0,
8739 .dst = MSM_BUS_SLAVE_SMI,
8740 .ab = 575424000,
8741 .ib = 719280000,
8742 },
8743 /* Master and slaves can be from different fabrics */
8744 {
8745 .src = MSM_BUS_MASTER_MDP_PORT0,
8746 .dst = MSM_BUS_SLAVE_EBI_CH0,
8747 .ab = 575424000,
8748 .ib = 719280000 * 2,
8749 },
8750};
8751
8752#else
8753static struct msm_bus_vectors mdp_init_vectors[] = {
8754 /* For now, 0th array entry is reserved.
8755 * Please leave 0 as is and don't use it
8756 */
8757 {
8758 .src = MSM_BUS_MASTER_MDP_PORT0,
8759 .dst = MSM_BUS_SLAVE_SMI,
8760 .ab = 0,
8761 .ib = 0,
8762 },
8763 /* Master and slaves can be from different fabrics */
8764 {
8765 .src = MSM_BUS_MASTER_MDP_PORT0,
8766 .dst = MSM_BUS_SLAVE_EBI_CH0,
8767 .ab = 0,
8768 .ib = 0,
8769 },
8770};
8771
8772static struct msm_bus_vectors mdp_sd_smi_vectors[] = {
8773 /* Default case static display/UI/2d/3d if FB SMI */
8774 {
8775 .src = MSM_BUS_MASTER_MDP_PORT0,
8776 .dst = MSM_BUS_SLAVE_SMI,
8777 .ab = 175110000,
8778 .ib = 218887500,
8779 },
8780 /* Master and slaves can be from different fabrics */
8781 {
8782 .src = MSM_BUS_MASTER_MDP_PORT0,
8783 .dst = MSM_BUS_SLAVE_EBI_CH0,
8784 .ab = 0,
8785 .ib = 0,
8786 },
8787};
8788
8789static struct msm_bus_vectors mdp_sd_ebi_vectors[] = {
8790 /* Default case static display/UI/2d/3d if FB SMI */
8791 {
8792 .src = MSM_BUS_MASTER_MDP_PORT0,
8793 .dst = MSM_BUS_SLAVE_SMI,
8794 .ab = 0,
8795 .ib = 0,
8796 },
8797 /* Master and slaves can be from different fabrics */
8798 {
8799 .src = MSM_BUS_MASTER_MDP_PORT0,
8800 .dst = MSM_BUS_SLAVE_EBI_CH0,
8801 .ab = 216000000,
8802 .ib = 270000000 * 2,
8803 },
8804};
8805static struct msm_bus_vectors mdp_vga_vectors[] = {
8806 /* VGA and less video */
8807 {
8808 .src = MSM_BUS_MASTER_MDP_PORT0,
8809 .dst = MSM_BUS_SLAVE_SMI,
8810 .ab = 216000000,
8811 .ib = 270000000,
8812 },
8813 {
8814 .src = MSM_BUS_MASTER_MDP_PORT0,
8815 .dst = MSM_BUS_SLAVE_EBI_CH0,
8816 .ab = 216000000,
8817 .ib = 270000000 * 2,
8818 },
8819};
8820
8821static struct msm_bus_vectors mdp_720p_vectors[] = {
8822 /* 720p and less video */
8823 {
8824 .src = MSM_BUS_MASTER_MDP_PORT0,
8825 .dst = MSM_BUS_SLAVE_SMI,
8826 .ab = 230400000,
8827 .ib = 288000000,
8828 },
8829 /* Master and slaves can be from different fabrics */
8830 {
8831 .src = MSM_BUS_MASTER_MDP_PORT0,
8832 .dst = MSM_BUS_SLAVE_EBI_CH0,
8833 .ab = 230400000,
8834 .ib = 288000000 * 2,
8835 },
8836};
8837
8838static struct msm_bus_vectors mdp_1080p_vectors[] = {
8839 /* 1080p and less video */
8840 {
8841 .src = MSM_BUS_MASTER_MDP_PORT0,
8842 .dst = MSM_BUS_SLAVE_SMI,
8843 .ab = 334080000,
8844 .ib = 417600000,
8845 },
8846 /* Master and slaves can be from different fabrics */
8847 {
8848 .src = MSM_BUS_MASTER_MDP_PORT0,
8849 .dst = MSM_BUS_SLAVE_EBI_CH0,
8850 .ab = 334080000,
Ravishangar Kalyanam731beb92011-07-07 18:27:32 -07008851 .ib = 550000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07008852 },
8853};
8854
8855#endif
8856static struct msm_bus_paths mdp_bus_scale_usecases[] = {
8857 {
8858 ARRAY_SIZE(mdp_init_vectors),
8859 mdp_init_vectors,
8860 },
8861 {
8862 ARRAY_SIZE(mdp_sd_smi_vectors),
8863 mdp_sd_smi_vectors,
8864 },
8865 {
8866 ARRAY_SIZE(mdp_sd_ebi_vectors),
8867 mdp_sd_ebi_vectors,
8868 },
8869 {
8870 ARRAY_SIZE(mdp_vga_vectors),
8871 mdp_vga_vectors,
8872 },
8873 {
8874 ARRAY_SIZE(mdp_720p_vectors),
8875 mdp_720p_vectors,
8876 },
8877 {
8878 ARRAY_SIZE(mdp_1080p_vectors),
8879 mdp_1080p_vectors,
8880 },
8881};
8882static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
8883 mdp_bus_scale_usecases,
8884 ARRAY_SIZE(mdp_bus_scale_usecases),
8885 .name = "mdp",
8886};
8887
8888#endif
8889#ifdef CONFIG_MSM_BUS_SCALING
8890static struct msm_bus_vectors dtv_bus_init_vectors[] = {
8891 /* For now, 0th array entry is reserved.
8892 * Please leave 0 as is and don't use it
8893 */
8894 {
8895 .src = MSM_BUS_MASTER_MDP_PORT0,
8896 .dst = MSM_BUS_SLAVE_SMI,
8897 .ab = 0,
8898 .ib = 0,
8899 },
8900 /* Master and slaves can be from different fabrics */
8901 {
8902 .src = MSM_BUS_MASTER_MDP_PORT0,
8903 .dst = MSM_BUS_SLAVE_EBI_CH0,
8904 .ab = 0,
8905 .ib = 0,
8906 },
8907};
8908static struct msm_bus_vectors dtv_bus_def_vectors[] = {
8909 /* For now, 0th array entry is reserved.
8910 * Please leave 0 as is and don't use it
8911 */
8912 {
8913 .src = MSM_BUS_MASTER_MDP_PORT0,
8914 .dst = MSM_BUS_SLAVE_SMI,
8915 .ab = 566092800,
8916 .ib = 707616000,
8917 },
8918 /* Master and slaves can be from different fabrics */
8919 {
8920 .src = MSM_BUS_MASTER_MDP_PORT0,
8921 .dst = MSM_BUS_SLAVE_EBI_CH0,
8922 .ab = 566092800,
8923 .ib = 707616000,
8924 },
8925};
8926static struct msm_bus_paths dtv_bus_scale_usecases[] = {
8927 {
8928 ARRAY_SIZE(dtv_bus_init_vectors),
8929 dtv_bus_init_vectors,
8930 },
8931 {
8932 ARRAY_SIZE(dtv_bus_def_vectors),
8933 dtv_bus_def_vectors,
8934 },
8935};
8936static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
8937 dtv_bus_scale_usecases,
8938 ARRAY_SIZE(dtv_bus_scale_usecases),
8939 .name = "dtv",
8940};
8941
8942static struct lcdc_platform_data dtv_pdata = {
8943 .bus_scale_table = &dtv_bus_scale_pdata,
8944};
8945#endif
8946
8947
8948static struct lcdc_platform_data lcdc_pdata = {
8949 .lcdc_power_save = lcdc_panel_power,
8950};
8951
8952
8953#define MDP_VSYNC_GPIO 28
8954
8955/*
8956 * MIPI_DSI only use 8058_LDO0 which need always on
8957 * therefore it need to be put at low power mode if
8958 * it was not used instead of turn it off.
8959 */
8960static int mipi_dsi_panel_power(int on)
8961{
8962 int flag_on = !!on;
8963 static int mipi_dsi_power_save_on;
8964 static struct regulator *ldo0;
8965 int rc = 0;
8966
8967 if (mipi_dsi_power_save_on == flag_on)
8968 return 0;
8969
8970 mipi_dsi_power_save_on = flag_on;
8971
8972 if (ldo0 == NULL) { /* init */
8973 ldo0 = regulator_get(NULL, "8058_l0");
8974 if (IS_ERR(ldo0)) {
8975 pr_debug("%s: LDO0 failed\n", __func__);
8976 rc = PTR_ERR(ldo0);
8977 return rc;
8978 }
8979
8980 rc = regulator_set_voltage(ldo0, 1200000, 1200000);
8981 if (rc)
8982 goto out;
8983
8984 rc = regulator_enable(ldo0);
8985 if (rc)
8986 goto out;
8987 }
8988
8989 if (on) {
8990 /* set ldo0 to HPM */
8991 rc = regulator_set_optimum_mode(ldo0, 100000);
8992 if (rc < 0)
8993 goto out;
8994 } else {
8995 /* set ldo0 to LPM */
8996 rc = regulator_set_optimum_mode(ldo0, 9000);
8997 if (rc < 0)
8998 goto out;
8999 }
9000
9001 return 0;
9002out:
9003 regulator_disable(ldo0);
9004 regulator_put(ldo0);
9005 ldo0 = NULL;
9006 return rc;
9007}
9008
9009static struct mipi_dsi_platform_data mipi_dsi_pdata = {
9010 .vsync_gpio = MDP_VSYNC_GPIO,
9011 .dsi_power_save = mipi_dsi_panel_power,
9012};
9013
9014#ifdef CONFIG_FB_MSM_TVOUT
9015static struct regulator *reg_8058_l13;
9016
9017static int atv_dac_power(int on)
9018{
9019 int rc = 0;
9020 #define _GET_REGULATOR(var, name) do { \
9021 var = regulator_get(NULL, name); \
9022 if (IS_ERR(var)) { \
9023 pr_info("'%s' regulator not found, rc=%ld\n", \
9024 name, IS_ERR(var)); \
9025 var = NULL; \
9026 return -ENODEV; \
9027 } \
9028 } while (0)
9029
9030 if (!reg_8058_l13)
9031 _GET_REGULATOR(reg_8058_l13, "8058_l13");
9032 #undef _GET_REGULATOR
9033
9034 if (on) {
9035 rc = regulator_set_voltage(reg_8058_l13, 2050000, 2050000);
9036 if (rc) {
9037 pr_info("%s: '%s' regulator set voltage failed,\
9038 rc=%d\n", __func__, "8058_l13", rc);
9039 return rc;
9040 }
9041
9042 rc = regulator_enable(reg_8058_l13);
9043 if (rc) {
9044 pr_err("%s: '%s' regulator enable failed,\
9045 rc=%d\n", __func__, "8058_l13", rc);
9046 return rc;
9047 }
9048 } else {
9049 rc = regulator_force_disable(reg_8058_l13);
9050 if (rc)
9051 pr_warning("%s: '%s' regulator disable failed, rc=%d\n",
9052 __func__, "8058_l13", rc);
9053 }
9054 return rc;
9055
9056}
9057#endif
9058
9059#ifdef CONFIG_FB_MSM_MIPI_DSI
9060int mdp_core_clk_rate_table[] = {
9061 85330000,
9062 85330000,
9063 160000000,
9064 200000000,
9065};
9066#else
9067int mdp_core_clk_rate_table[] = {
9068 59080000,
9069 59080000,
9070 85330000,
9071 200000000,
9072};
9073#endif
9074
9075static struct msm_panel_common_pdata mdp_pdata = {
9076 .gpio = MDP_VSYNC_GPIO,
9077 .mdp_core_clk_rate = 59080000,
9078 .mdp_core_clk_table = mdp_core_clk_rate_table,
9079 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
9080#ifdef CONFIG_MSM_BUS_SCALING
9081 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
9082#endif
9083 .mdp_rev = MDP_REV_41,
9084};
9085
9086#ifdef CONFIG_FB_MSM_TVOUT
9087
9088#ifdef CONFIG_MSM_BUS_SCALING
9089static struct msm_bus_vectors atv_bus_init_vectors[] = {
9090 /* For now, 0th array entry is reserved.
9091 * Please leave 0 as is and don't use it
9092 */
9093 {
9094 .src = MSM_BUS_MASTER_MDP_PORT0,
9095 .dst = MSM_BUS_SLAVE_SMI,
9096 .ab = 0,
9097 .ib = 0,
9098 },
9099 /* Master and slaves can be from different fabrics */
9100 {
9101 .src = MSM_BUS_MASTER_MDP_PORT0,
9102 .dst = MSM_BUS_SLAVE_EBI_CH0,
9103 .ab = 0,
9104 .ib = 0,
9105 },
9106};
9107static struct msm_bus_vectors atv_bus_def_vectors[] = {
9108 /* For now, 0th array entry is reserved.
9109 * Please leave 0 as is and don't use it
9110 */
9111 {
9112 .src = MSM_BUS_MASTER_MDP_PORT0,
9113 .dst = MSM_BUS_SLAVE_SMI,
9114 .ab = 236390400,
9115 .ib = 265939200,
9116 },
9117 /* Master and slaves can be from different fabrics */
9118 {
9119 .src = MSM_BUS_MASTER_MDP_PORT0,
9120 .dst = MSM_BUS_SLAVE_EBI_CH0,
9121 .ab = 236390400,
9122 .ib = 265939200,
9123 },
9124};
9125static struct msm_bus_paths atv_bus_scale_usecases[] = {
9126 {
9127 ARRAY_SIZE(atv_bus_init_vectors),
9128 atv_bus_init_vectors,
9129 },
9130 {
9131 ARRAY_SIZE(atv_bus_def_vectors),
9132 atv_bus_def_vectors,
9133 },
9134};
9135static struct msm_bus_scale_pdata atv_bus_scale_pdata = {
9136 atv_bus_scale_usecases,
9137 ARRAY_SIZE(atv_bus_scale_usecases),
9138 .name = "atv",
9139};
9140#endif
9141
9142static struct tvenc_platform_data atv_pdata = {
9143 .poll = 0,
9144 .pm_vid_en = atv_dac_power,
9145#ifdef CONFIG_MSM_BUS_SCALING
9146 .bus_scale_table = &atv_bus_scale_pdata,
9147#endif
9148};
9149#endif
9150
9151static void __init msm_fb_add_devices(void)
9152{
9153#ifdef CONFIG_FB_MSM_LCDC_DSUB
9154 mdp_pdata.mdp_core_clk_table = NULL;
9155 mdp_pdata.num_mdp_clk = 0;
9156 mdp_pdata.mdp_core_clk_rate = 200000000;
9157#endif
9158 if (machine_is_msm8x60_rumi3())
9159 msm_fb_register_device("mdp", NULL);
9160 else
9161 msm_fb_register_device("mdp", &mdp_pdata);
9162
9163 msm_fb_register_device("lcdc", &lcdc_pdata);
9164 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
9165#ifdef CONFIG_MSM_BUS_SCALING
9166 msm_fb_register_device("dtv", &dtv_pdata);
9167#endif
9168#ifdef CONFIG_FB_MSM_TVOUT
9169 msm_fb_register_device("tvenc", &atv_pdata);
9170 msm_fb_register_device("tvout_device", NULL);
9171#endif
9172}
9173
9174#if (defined(CONFIG_MARIMBA_CORE)) && \
9175 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
9176
9177static const struct {
9178 char *name;
9179 int vmin;
9180 int vmax;
9181} bt_regs_info[] = {
9182 { "8058_s3", 1800000, 1800000 },
9183 { "8058_s2", 1300000, 1300000 },
9184 { "8058_l8", 2900000, 3050000 },
9185};
9186
9187static struct {
9188 bool enabled;
9189} bt_regs_status[] = {
9190 { false },
9191 { false },
9192 { false },
9193};
9194static struct regulator *bt_regs[ARRAY_SIZE(bt_regs_info)];
9195
9196static int bahama_bt(int on)
9197{
9198 int rc;
9199 int i;
9200 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
9201
9202 struct bahama_variant_register {
9203 const size_t size;
9204 const struct bahama_config_register *set;
9205 };
9206
9207 const struct bahama_config_register *p;
9208
9209 u8 version;
9210
9211 const struct bahama_config_register v10_bt_on[] = {
9212 { 0xE9, 0x00, 0xFF },
9213 { 0xF4, 0x80, 0xFF },
9214 { 0xE4, 0x00, 0xFF },
9215 { 0xE5, 0x00, 0x0F },
9216#ifdef CONFIG_WLAN
9217 { 0xE6, 0x38, 0x7F },
9218 { 0xE7, 0x06, 0xFF },
9219#endif
9220 { 0xE9, 0x21, 0xFF },
9221 { 0x01, 0x0C, 0x1F },
9222 { 0x01, 0x08, 0x1F },
9223 };
9224
9225 const struct bahama_config_register v20_bt_on_fm_off[] = {
9226 { 0x11, 0x0C, 0xFF },
9227 { 0x13, 0x01, 0xFF },
9228 { 0xF4, 0x80, 0xFF },
9229 { 0xF0, 0x00, 0xFF },
9230 { 0xE9, 0x00, 0xFF },
9231#ifdef CONFIG_WLAN
9232 { 0x81, 0x00, 0x7F },
9233 { 0x82, 0x00, 0xFF },
9234 { 0xE6, 0x38, 0x7F },
9235 { 0xE7, 0x06, 0xFF },
9236#endif
9237 { 0xE9, 0x21, 0xFF },
9238 };
9239
9240 const struct bahama_config_register v20_bt_on_fm_on[] = {
9241 { 0x11, 0x0C, 0xFF },
9242 { 0x13, 0x01, 0xFF },
9243 { 0xF4, 0x86, 0xFF },
9244 { 0xF0, 0x06, 0xFF },
9245 { 0xE9, 0x00, 0xFF },
9246#ifdef CONFIG_WLAN
9247 { 0x81, 0x00, 0x7F },
9248 { 0x82, 0x00, 0xFF },
9249 { 0xE6, 0x38, 0x7F },
9250 { 0xE7, 0x06, 0xFF },
9251#endif
9252 { 0xE9, 0x21, 0xFF },
9253 };
9254
9255 const struct bahama_config_register v10_bt_off[] = {
9256 { 0xE9, 0x00, 0xFF },
9257 };
9258
9259 const struct bahama_config_register v20_bt_off_fm_off[] = {
9260 { 0xF4, 0x84, 0xFF },
9261 { 0xF0, 0x04, 0xFF },
9262 { 0xE9, 0x00, 0xFF }
9263 };
9264
9265 const struct bahama_config_register v20_bt_off_fm_on[] = {
9266 { 0xF4, 0x86, 0xFF },
9267 { 0xF0, 0x06, 0xFF },
9268 { 0xE9, 0x00, 0xFF }
9269 };
9270 const struct bahama_variant_register bt_bahama[2][3] = {
9271 {
9272 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
9273 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
9274 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
9275 },
9276 {
9277 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
9278 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
9279 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
9280 }
9281 };
9282
9283 u8 offset = 0; /* index into bahama configs */
9284
9285 on = on ? 1 : 0;
9286 version = read_bahama_ver();
9287
9288 if (version == VER_UNSUPPORTED) {
9289 dev_err(&msm_bt_power_device.dev,
9290 "%s: unsupported version\n",
9291 __func__);
9292 return -EIO;
9293 }
9294
9295 if (version == VER_2_0) {
9296 if (marimba_get_fm_status(&config))
9297 offset = 0x01;
9298 }
9299
9300 /* Voting off 1.3V S2 Regulator,BahamaV2 used in Normal mode */
9301 if (on && (version == VER_2_0)) {
9302 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9303 if ((!strcmp(bt_regs_info[i].name, "8058_s2"))
9304 && (bt_regs_status[i].enabled == true)) {
9305 if (regulator_disable(bt_regs[i])) {
9306 dev_err(&msm_bt_power_device.dev,
9307 "%s: regulator disable failed",
9308 __func__);
9309 }
9310 bt_regs_status[i].enabled = false;
9311 break;
9312 }
9313 }
9314 }
9315
9316 p = bt_bahama[on][version + offset].set;
9317
9318 dev_info(&msm_bt_power_device.dev,
9319 "%s: found version %d\n", __func__, version);
9320
9321 for (i = 0; i < bt_bahama[on][version + offset].size; i++) {
9322 u8 value = (p+i)->value;
9323 rc = marimba_write_bit_mask(&config,
9324 (p+i)->reg,
9325 &value,
9326 sizeof((p+i)->value),
9327 (p+i)->mask);
9328 if (rc < 0) {
9329 dev_err(&msm_bt_power_device.dev,
9330 "%s: reg %d write failed: %d\n",
9331 __func__, (p+i)->reg, rc);
9332 return rc;
9333 }
9334 dev_dbg(&msm_bt_power_device.dev,
9335 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
9336 __func__, (p+i)->reg,
9337 value, (p+i)->mask);
9338 }
9339 /* Update BT Status */
9340 if (on)
9341 marimba_set_bt_status(&config, true);
9342 else
9343 marimba_set_bt_status(&config, false);
9344
9345 return 0;
9346}
9347
9348static int bluetooth_use_regulators(int on)
9349{
9350 int i, recover = -1, rc = 0;
9351
9352 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9353 bt_regs[i] = on ? regulator_get(&msm_bt_power_device.dev,
9354 bt_regs_info[i].name) :
9355 (regulator_put(bt_regs[i]), NULL);
9356 if (IS_ERR(bt_regs[i])) {
9357 rc = PTR_ERR(bt_regs[i]);
9358 dev_err(&msm_bt_power_device.dev,
9359 "regulator %s get failed (%d)\n",
9360 bt_regs_info[i].name, rc);
9361 recover = i - 1;
9362 bt_regs[i] = NULL;
9363 break;
9364 }
9365
9366 if (!on)
9367 continue;
9368
9369 rc = regulator_set_voltage(bt_regs[i],
9370 bt_regs_info[i].vmin,
9371 bt_regs_info[i].vmax);
9372 if (rc < 0) {
9373 dev_err(&msm_bt_power_device.dev,
9374 "regulator %s voltage set (%d)\n",
9375 bt_regs_info[i].name, rc);
9376 recover = i;
9377 break;
9378 }
9379 }
9380
9381 if (on && (recover > -1))
9382 for (i = recover; i >= 0; i--) {
9383 regulator_put(bt_regs[i]);
9384 bt_regs[i] = NULL;
9385 }
9386
9387 return rc;
9388}
9389
9390static int bluetooth_switch_regulators(int on)
9391{
9392 int i, rc = 0;
9393
9394 for (i = 0; i < ARRAY_SIZE(bt_regs_info); i++) {
9395 if (on && (bt_regs_status[i].enabled == false)) {
9396 rc = regulator_enable(bt_regs[i]);
9397 if (rc < 0) {
9398 dev_err(&msm_bt_power_device.dev,
9399 "regulator %s %s failed (%d)\n",
9400 bt_regs_info[i].name,
9401 "enable", rc);
9402 if (i > 0) {
9403 while (--i) {
9404 regulator_disable(bt_regs[i]);
9405 bt_regs_status[i].enabled
9406 = false;
9407 }
9408 break;
9409 }
9410 }
9411 bt_regs_status[i].enabled = true;
9412 } else if (!on && (bt_regs_status[i].enabled == true)) {
9413 rc = regulator_disable(bt_regs[i]);
9414 if (rc < 0) {
9415 dev_err(&msm_bt_power_device.dev,
9416 "regulator %s %s failed (%d)\n",
9417 bt_regs_info[i].name,
9418 "disable", rc);
9419 break;
9420 }
9421 bt_regs_status[i].enabled = false;
9422 }
9423 }
9424 return rc;
9425}
9426
9427static struct msm_xo_voter *bt_clock;
9428
9429static int bluetooth_power(int on)
9430{
9431 int rc = 0;
9432 int id;
9433
9434 /* In case probe function fails, cur_connv_type would be -1 */
9435 id = adie_get_detected_connectivity_type();
9436 if (id != BAHAMA_ID) {
9437 pr_err("%s: unexpected adie connectivity type: %d\n",
9438 __func__, id);
9439 return -ENODEV;
9440 }
9441
9442 if (on) {
9443
9444 rc = bluetooth_use_regulators(1);
9445 if (rc < 0)
9446 goto out;
9447
9448 rc = bluetooth_switch_regulators(1);
9449
9450 if (rc < 0)
9451 goto fail_put;
9452
9453 bt_clock = msm_xo_get(MSM_XO_TCXO_D0, "bt_power");
9454
9455 if (IS_ERR(bt_clock)) {
9456 pr_err("Couldn't get TCXO_D0 voter\n");
9457 goto fail_switch;
9458 }
9459
9460 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_ON);
9461
9462 if (rc < 0) {
9463 pr_err("Failed to vote for TCXO_DO ON\n");
9464 goto fail_vote;
9465 }
9466
9467 rc = bahama_bt(1);
9468
9469 if (rc < 0)
9470 goto fail_clock;
9471
9472 msleep(10);
9473
9474 rc = msm_xo_mode_vote(bt_clock, MSM_XO_MODE_PIN_CTRL);
9475
9476 if (rc < 0) {
9477 pr_err("Failed to vote for TCXO_DO pin control\n");
9478 goto fail_vote;
9479 }
9480 } else {
9481 /* check for initial RFKILL block (power off) */
9482 /* some RFKILL versions/configurations rfkill_register */
9483 /* calls here for an initial set_block */
9484 /* avoid calling i2c and regulator before unblock (on) */
9485 if (platform_get_drvdata(&msm_bt_power_device) == NULL) {
9486 dev_info(&msm_bt_power_device.dev,
9487 "%s: initialized OFF/blocked\n", __func__);
9488 goto out;
9489 }
9490
9491 bahama_bt(0);
9492
9493fail_clock:
9494 msm_xo_mode_vote(bt_clock, MSM_XO_MODE_OFF);
9495fail_vote:
9496 msm_xo_put(bt_clock);
9497fail_switch:
9498 bluetooth_switch_regulators(0);
9499fail_put:
9500 bluetooth_use_regulators(0);
9501 }
9502
9503out:
9504 if (rc < 0)
9505 on = 0;
9506 dev_info(&msm_bt_power_device.dev,
9507 "Bluetooth power switch: state %d result %d\n", on, rc);
9508
9509 return rc;
9510}
9511
9512#endif /*CONFIG_MARIMBA_CORE, CONFIG_MSM_BT_POWER, CONFIG_MSM_BT_POWER_MODULE*/
9513
9514static void __init msm8x60_cfg_smsc911x(void)
9515{
9516 smsc911x_resources[1].start =
9517 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
9518 smsc911x_resources[1].end =
9519 PM8058_GPIO_IRQ(PM8058_IRQ_BASE, 6);
9520}
9521
9522#ifdef CONFIG_MSM_RPM
9523static struct msm_rpm_platform_data msm_rpm_data = {
9524 .reg_base_addrs = {
9525 [MSM_RPM_PAGE_STATUS] = MSM_RPM_BASE,
9526 [MSM_RPM_PAGE_CTRL] = MSM_RPM_BASE + 0x400,
9527 [MSM_RPM_PAGE_REQ] = MSM_RPM_BASE + 0x600,
9528 [MSM_RPM_PAGE_ACK] = MSM_RPM_BASE + 0xa00,
9529 },
9530
9531 .irq_ack = RPM_SCSS_CPU0_GP_HIGH_IRQ,
9532 .irq_err = RPM_SCSS_CPU0_GP_LOW_IRQ,
9533 .irq_vmpm = RPM_SCSS_CPU0_GP_MEDIUM_IRQ,
9534 .msm_apps_ipc_rpm_reg = MSM_GCC_BASE + 0x008,
9535 .msm_apps_ipc_rpm_val = 4,
9536};
9537#endif
9538
9539struct msm_board_data {
9540 struct msm_gpiomux_configs *gpiomux_cfgs;
9541};
9542
9543static struct msm_board_data msm8x60_rumi3_board_data __initdata = {
9544 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
9545};
9546
9547static struct msm_board_data msm8x60_sim_board_data __initdata = {
9548 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
9549};
9550
9551static struct msm_board_data msm8x60_surf_board_data __initdata = {
9552 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
9553};
9554
9555static struct msm_board_data msm8x60_ffa_board_data __initdata = {
9556 .gpiomux_cfgs = msm8x60_surf_ffa_gpiomux_cfgs,
9557};
9558
9559static struct msm_board_data msm8x60_fluid_board_data __initdata = {
9560 .gpiomux_cfgs = msm8x60_fluid_gpiomux_cfgs,
9561};
9562
9563static struct msm_board_data msm8x60_charm_surf_board_data __initdata = {
9564 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
9565};
9566
9567static struct msm_board_data msm8x60_charm_ffa_board_data __initdata = {
9568 .gpiomux_cfgs = msm8x60_charm_gpiomux_cfgs,
9569};
9570
9571static void __init msm8x60_init(struct msm_board_data *board_data)
9572{
9573 uint32_t soc_platform_version;
9574
9575 /*
9576 * Initialize RPM first as other drivers and devices may need
9577 * it for their initialization.
9578 */
9579#ifdef CONFIG_MSM_RPM
9580 BUG_ON(msm_rpm_init(&msm_rpm_data));
9581#endif
9582 BUG_ON(msm_rpmrs_levels_init(msm_rpmrs_levels,
9583 ARRAY_SIZE(msm_rpmrs_levels)));
9584 if (msm_xo_init())
9585 pr_err("Failed to initialize XO votes\n");
9586
9587 if (socinfo_init() < 0)
9588 printk(KERN_ERR "%s: socinfo_init() failed!\n",
9589 __func__);
9590 msm8x60_check_2d_hardware();
9591
9592 /* Change SPM handling of core 1 if PMM 8160 is present. */
9593 soc_platform_version = socinfo_get_platform_version();
9594 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1 &&
9595 SOCINFO_VERSION_MINOR(soc_platform_version) >= 2) {
9596 struct msm_spm_platform_data *spm_data;
9597
9598 spm_data = &msm_spm_data_v1[1];
9599 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
9600 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
9601
9602 spm_data = &msm_spm_data[1];
9603 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] &= ~0x0F00UL;
9604 spm_data->reg_init_values[MSM_SPM_REG_SAW_CFG] |= 0x0100UL;
9605 }
9606
9607 /*
9608 * Initialize SPM before acpuclock as the latter calls into SPM
9609 * driver to set ACPU voltages.
9610 */
9611 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
9612 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
9613 else
9614 msm_spm_init(msm_spm_data_v1, ARRAY_SIZE(msm_spm_data_v1));
9615
9616 /*
9617 * Set regulators 8901_l4 and 8901_l6 to be always on in HPM for SURF
9618 * devices so that the RPM doesn't drop into a low power mode that an
9619 * un-reworked SURF cannot resume from.
9620 */
9621 if (machine_is_msm8x60_surf()) {
9622 rpm_vreg_init_pdata[RPM_VREG_ID_PM8901_L4]
9623 .init_data.constraints.always_on = 1;
9624 rpm_vreg_init_pdata[RPM_VREG_ID_PM8901_L6]
9625 .init_data.constraints.always_on = 1;
9626 }
9627
9628 /*
9629 * Disable regulator info printing so that regulator registration
9630 * messages do not enter the kmsg log.
9631 */
9632 regulator_suppress_info_printing();
9633
9634 /* Initialize regulators needed for clock_init. */
9635 platform_add_devices(early_regulators, ARRAY_SIZE(early_regulators));
9636
9637 msm8660_clock_init();
9638
9639 /* Buses need to be initialized before early-device registration
9640 * to get the platform data for fabrics.
9641 */
9642 msm8x60_init_buses();
9643 platform_add_devices(early_devices, ARRAY_SIZE(early_devices));
9644 /* CPU frequency control is not supported on simulated targets. */
9645 if (!machine_is_msm8x60_rumi3() && !machine_is_msm8x60_sim())
9646 msm_acpu_clock_init(&msm8x60_acpu_clock_data);
9647
9648 /* No EBI2 on 8660 charm targets */
9649 if (!machine_is_msm8x60_fusion() && !machine_is_msm8x60_fusn_ffa())
9650 msm8x60_init_ebi2();
9651 msm8x60_init_tlmm();
9652 msm8x60_init_gpiomux(board_data->gpiomux_cfgs);
9653 msm8x60_init_uart12dm();
9654 msm8x60_init_mmc();
9655
9656#if defined(CONFIG_PMIC8058_OTHC) || defined(CONFIG_PMIC8058_OTHC_MODULE)
9657 msm8x60_init_pm8058_othc();
9658#endif
9659
9660 if (machine_is_msm8x60_fluid()) {
9661 pm8058_platform_data.sub_devices[PM8058_SUBDEV_KPD].
9662 platform_data = &fluid_keypad_data;
9663 pm8058_platform_data.sub_devices[PM8058_SUBDEV_KPD].pdata_size
9664 = sizeof(fluid_keypad_data);
9665 } else {
9666 pm8058_platform_data.sub_devices[PM8058_SUBDEV_KPD].
9667 platform_data = &ffa_keypad_data;
9668 pm8058_platform_data.sub_devices[PM8058_SUBDEV_KPD].pdata_size
9669 = sizeof(ffa_keypad_data);
9670
9671 }
9672
9673 /* Disable END_CALL simulation function of powerkey on fluid */
9674 if (machine_is_msm8x60_fluid()) {
9675 pwrkey_pdata.pwrkey_time_ms = 0;
9676 }
9677
9678 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
9679 machine_is_msm8x60_fluid() || machine_is_msm8x60_fusion() ||
9680 machine_is_msm8x60_fusn_ffa()) {
9681 msm8x60_cfg_smsc911x();
9682 if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 1)
9683 platform_add_devices(msm_footswitch_devices,
9684 msm_num_footswitch_devices);
9685 platform_add_devices(surf_devices,
9686 ARRAY_SIZE(surf_devices));
9687
9688#ifdef CONFIG_MSM_DSPS
9689 if (machine_is_msm8x60_fluid()) {
9690 platform_device_unregister(&msm_gsbi12_qup_i2c_device);
9691 msm8x60_init_dsps();
9692 }
9693#endif
9694
9695#ifdef CONFIG_USB_EHCI_MSM_72K
9696 /*
9697 * Drive MPP2 pin HIGH for PHY to generate ID interrupts on 8660
9698 * fluid
9699 */
9700 if (machine_is_msm8x60_fluid()) {
9701 pm8901_mpp_config_digital_out(1,
9702 PM8901_MPP_DIG_LEVEL_L5, 1);
9703 }
9704 msm_add_host(0, &msm_usb_host_pdata);
9705#endif
9706 } else {
9707 msm8x60_configure_smc91x();
9708 platform_add_devices(rumi_sim_devices,
9709 ARRAY_SIZE(rumi_sim_devices));
9710 }
9711#if defined(CONFIG_USB_PEHCI_HCD) || defined(CONFIG_USB_PEHCI_HCD_MODULE)
9712 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa())
9713 msm8x60_cfg_isp1763();
9714#endif
9715#ifdef CONFIG_BATTERY_MSM8X60
9716 if (machine_is_msm8x60_surf() || machine_is_msm8x60_ffa() ||
9717 machine_is_msm8x60_fusion() ||
9718 machine_is_msm8x60_fusn_ffa() || machine_is_msm8x60_fluid())
9719 platform_device_register(&msm_charger_device);
9720#endif
9721
9722 if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
9723 platform_add_devices(charm_devices, ARRAY_SIZE(charm_devices));
9724
9725 if (!machine_is_msm8x60_fluid())
9726 pm8058_platform_data.charger_sub_device
9727 = &pm8058_charger_sub_dev;
9728
9729#if defined(CONFIG_SPI_QUP) || defined(CONFIG_SPI_QUP_MODULE)
9730 if (machine_is_msm8x60_fluid())
9731 platform_device_register(&msm_gsbi10_qup_spi_device);
9732 else
9733 platform_device_register(&msm_gsbi1_qup_spi_device);
9734#endif
9735
9736#if defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C) || \
9737 defined(CONFIG_TOUCHSCREEN_CYTTSP_I2C_MODULE)
9738 if (machine_is_msm8x60_fluid())
9739 cyttsp_set_params();
9740#endif
9741 if (!machine_is_msm8x60_sim())
9742 msm_fb_add_devices();
9743 fixup_i2c_configs();
9744 register_i2c_devices();
9745
9746 platform_device_register(&smsc911x_device);
9747
9748#if (defined(CONFIG_SPI_QUP)) && \
9749 (defined(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) || \
9750 defined(CONFIG_FB_MSM_LCDC_AUO_WVGA))
9751
9752 if (machine_is_msm8x60_fluid()) {
9753#ifdef CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT
9754 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3) {
9755 spi_register_board_info(lcdc_samsung_spi_board_info,
9756 ARRAY_SIZE(lcdc_samsung_spi_board_info));
9757 } else
9758#endif
9759 {
9760#ifdef CONFIG_FB_MSM_LCDC_AUO_WVGA
9761 spi_register_board_info(lcdc_auo_spi_board_info,
9762 ARRAY_SIZE(lcdc_auo_spi_board_info));
9763#endif
9764 }
9765 }
9766#endif
9767
9768 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
9769 msm_pm_set_rpm_wakeup_irq(RPM_SCSS_CPU0_WAKE_UP_IRQ);
9770 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
9771 msm_pm_data);
9772
9773#ifdef CONFIG_SENSORS_MSM_ADC
9774 if (machine_is_msm8x60_fluid()) {
9775 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
9776 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
9777 if (SOCINFO_VERSION_MAJOR(soc_platform_version) < 3)
9778 msm_adc_pdata.gpio_config = APROC_CONFIG;
9779 else
9780 msm_adc_pdata.gpio_config = MPROC_CONFIG;
9781 }
9782 msm_adc_pdata.target_hw = MSM_8x60;
9783#endif
9784#ifdef CONFIG_MSM8X60_AUDIO
9785 msm_snddev_init();
9786#endif
9787#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
9788 if (machine_is_msm8x60_fluid())
9789 platform_device_register(&fluid_leds_gpio);
9790 else
9791 platform_device_register(&gpio_leds);
9792#endif
9793
9794 /* configure pmic leds */
9795 if (machine_is_msm8x60_fluid()) {
9796 pm8058_platform_data.sub_devices[PM8058_SUBDEV_LED].
9797 platform_data = &pm8058_fluid_flash_leds_data;
9798 pm8058_platform_data.sub_devices[PM8058_SUBDEV_LED].pdata_size
9799 = sizeof(pm8058_fluid_flash_leds_data);
9800 } else {
9801 pm8058_platform_data.sub_devices[PM8058_SUBDEV_LED].
9802 platform_data = &pm8058_flash_leds_data;
9803 pm8058_platform_data.sub_devices[PM8058_SUBDEV_LED].pdata_size
9804 = sizeof(pm8058_flash_leds_data);
9805 }
9806
9807 if (machine_is_msm8x60_ffa() || machine_is_msm8x60_fusn_ffa()) {
9808 pm8058_platform_data.sub_devices[PM8058_SUBDEV_VIB].
9809 platform_data = &pmic_vib_pdata;
9810 pm8058_platform_data.sub_devices[PM8058_SUBDEV_VIB].
9811 pdata_size = sizeof(pmic_vib_pdata);
9812 }
9813
9814 msm8x60_multi_sdio_init();
9815}
9816
9817static void __init msm8x60_rumi3_init(void)
9818{
9819 msm8x60_init(&msm8x60_rumi3_board_data);
9820}
9821
9822static void __init msm8x60_sim_init(void)
9823{
9824 msm8x60_init(&msm8x60_sim_board_data);
9825}
9826
9827static void __init msm8x60_surf_init(void)
9828{
9829 msm8x60_init(&msm8x60_surf_board_data);
9830}
9831
9832static void __init msm8x60_ffa_init(void)
9833{
9834 msm8x60_init(&msm8x60_ffa_board_data);
9835}
9836
9837static void __init msm8x60_fluid_init(void)
9838{
9839 msm8x60_init(&msm8x60_fluid_board_data);
9840}
9841
9842static void __init msm8x60_charm_surf_init(void)
9843{
9844 msm8x60_init(&msm8x60_charm_surf_board_data);
9845}
9846
9847static void __init msm8x60_charm_ffa_init(void)
9848{
9849 msm8x60_init(&msm8x60_charm_ffa_board_data);
9850}
9851
9852static void __init msm8x60_charm_init_early(void)
9853{
9854 msm8x60_allocate_memory_regions();
Steve Mucklea55df6e2010-01-07 12:43:24 -08009855}
9856
9857MACHINE_START(MSM8X60_RUMI3, "QCT MSM8X60 RUMI3")
9858 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009859 .reserve = msm8x60_reserve,
Steve Mucklea55df6e2010-01-07 12:43:24 -08009860 .init_irq = msm8x60_init_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009861 .init_machine = msm8x60_rumi3_init,
Steve Mucklea55df6e2010-01-07 12:43:24 -08009862 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009863 .init_early = msm8x60_charm_init_early,
Steve Muckle49b76f72010-03-19 17:00:08 -07009864MACHINE_END
Steve Muckle57bbf1c2010-01-07 12:51:10 -08009865
9866MACHINE_START(MSM8X60_SIM, "QCT MSM8X60 SIMULATOR")
9867 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009868 .reserve = msm8x60_reserve,
Steve Muckle57bbf1c2010-01-07 12:51:10 -08009869 .init_irq = msm8x60_init_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009870 .init_machine = msm8x60_sim_init,
Steve Muckle57bbf1c2010-01-07 12:51:10 -08009871 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009872 .init_early = msm8x60_charm_init_early,
9873MACHINE_END
9874
9875MACHINE_START(MSM8X60_SURF, "QCT MSM8X60 SURF")
9876 .map_io = msm8x60_map_io,
9877 .reserve = msm8x60_reserve,
9878 .init_irq = msm8x60_init_irq,
9879 .init_machine = msm8x60_surf_init,
9880 .timer = &msm_timer,
9881 .init_early = msm8x60_charm_init_early,
Steve Muckle57bbf1c2010-01-07 12:51:10 -08009882MACHINE_END
Gregory Bean69b7f6f2010-04-04 22:29:02 -07009883
9884MACHINE_START(MSM8X60_FFA, "QCT MSM8X60 FFA")
9885 .map_io = msm8x60_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009886 .reserve = msm8x60_reserve,
Gregory Bean69b7f6f2010-04-04 22:29:02 -07009887 .init_irq = msm8x60_init_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009888 .init_machine = msm8x60_ffa_init,
Gregory Bean69b7f6f2010-04-04 22:29:02 -07009889 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07009890 .init_early = msm8x60_charm_init_early,
9891MACHINE_END
9892
9893MACHINE_START(MSM8X60_FLUID, "QCT MSM8X60 FLUID")
9894 .map_io = msm8x60_map_io,
9895 .reserve = msm8x60_reserve,
9896 .init_irq = msm8x60_init_irq,
9897 .init_machine = msm8x60_fluid_init,
9898 .timer = &msm_timer,
9899 .init_early = msm8x60_charm_init_early,
9900MACHINE_END
9901
9902MACHINE_START(MSM8X60_FUSION, "QCT MSM8X60 FUSION SURF")
9903 .map_io = msm8x60_map_io,
9904 .reserve = msm8x60_reserve,
9905 .init_irq = msm8x60_init_irq,
9906 .init_machine = msm8x60_charm_surf_init,
9907 .timer = &msm_timer,
9908 .init_early = msm8x60_charm_init_early,
9909MACHINE_END
9910
9911MACHINE_START(MSM8X60_FUSN_FFA, "QCT MSM8X60 FUSION FFA")
9912 .map_io = msm8x60_map_io,
9913 .reserve = msm8x60_reserve,
9914 .init_irq = msm8x60_init_irq,
9915 .init_machine = msm8x60_charm_ffa_init,
9916 .timer = &msm_timer,
9917 .init_early = msm8x60_charm_init_early,
Gregory Bean69b7f6f2010-04-04 22:29:02 -07009918MACHINE_END