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