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