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