blob: be0e4e64a321121e8a841c1d7255886d6b45989f [file] [log] [blame]
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -07001/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
2 *
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 *
12 */
13#include <linux/kernel.h>
14#include <linux/platform_device.h>
Harini Jayaramaneba52672011-09-08 15:13:00 -060015#include <linux/i2c.h>
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -070016#include <linux/msm_ssbi.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070017#include <asm/mach-types.h>
18#include <asm/mach/arch.h>
Krishna Kondadd794462011-10-01 00:19:29 -070019#include <asm/mach/mmc.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070020#include <mach/board.h>
21#include <mach/msm_iomap.h>
22#include <mach/gpio.h>
23#include <mach/gpiomux.h>
Harini Jayaraman738c9312011-09-08 15:22:38 -060024#include <mach/msm_spi.h>
Amit Blay5e4ec192011-10-20 09:16:54 +020025#include <linux/usb/android.h>
26#include <linux/usb/msm_hsusb.h>
Siddartha Mohanadoss5f60b452011-10-05 11:49:00 -070027#include <linux/mfd/pm8xxx/pm8xxx-adc.h>
Jay Chokshieb5d0d52011-09-28 17:16:20 -070028#include <linux/leds.h>
29#include <linux/leds-pm8xxx.h>
Gagan Mac7a827642011-09-22 19:42:21 -060030#include <mach/msm_bus_board.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070031#include "timer.h"
32#include "devices.h"
David Collinsfb88c432011-08-25 15:12:47 -070033#include "board-9615.h"
Maheshkumar Sivasubramanian4923db22011-09-15 09:28:15 -060034#include "cpuidle.h"
35#include "pm.h"
Vikram Mulukutlab5e1cda2011-10-04 16:17:22 -070036#include "acpuclock.h"
Jay Chokshidc8028b2011-12-01 16:17:34 -080037#include <linux/power/ltc4088-charger.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070038
Siddartha Mohanadoss5f60b452011-10-05 11:49:00 -070039static struct pm8xxx_adc_amux pm8018_adc_channels_data[] = {
40 {"vcoin", CHANNEL_VCOIN, CHAN_PATH_SCALING2, AMUX_RSV1,
41 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
42 {"vbat", CHANNEL_VBAT, CHAN_PATH_SCALING2, AMUX_RSV1,
43 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
44 {"vph_pwr", CHANNEL_VPH_PWR, CHAN_PATH_SCALING2, AMUX_RSV1,
45 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
46 {"batt_therm", CHANNEL_BATT_THERM, CHAN_PATH_SCALING1, AMUX_RSV2,
47 ADC_DECIMATION_TYPE2, ADC_SCALE_BATT_THERM},
48 {"batt_id", CHANNEL_BATT_ID, CHAN_PATH_SCALING1, AMUX_RSV2,
49 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
50 {"pmic_therm", CHANNEL_DIE_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
51 ADC_DECIMATION_TYPE2, ADC_SCALE_PMIC_THERM},
52 {"625mv", CHANNEL_625MV, CHAN_PATH_SCALING1, AMUX_RSV1,
53 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
54 {"125v", CHANNEL_125V, CHAN_PATH_SCALING1, AMUX_RSV1,
55 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
56 {"pa_therm0", ADC_MPP_1_AMUX3, CHAN_PATH_SCALING1, AMUX_RSV1,
57 ADC_DECIMATION_TYPE2, ADC_SCALE_PA_THERM},
58};
59
60static struct pm8xxx_adc_properties pm8018_adc_data = {
61 .adc_vdd_reference = 1800, /* milli-voltage for this adc */
62 .bitresolution = 15,
63 .bipolar = 0,
64};
65
66static struct pm8xxx_adc_platform_data pm8018_adc_pdata = {
67 .adc_channel = pm8018_adc_channels_data,
68 .adc_num_board_channel = ARRAY_SIZE(pm8018_adc_channels_data),
69 .adc_prop = &pm8018_adc_data,
70};
71
David Collinsfb88c432011-08-25 15:12:47 -070072static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata __devinitdata = {
73 .irq_base = PM8018_IRQ_BASE,
74 .devirq = MSM_GPIO_TO_INT(87),
75 .irq_trigger_flag = IRQF_TRIGGER_LOW,
76};
77
78static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata __devinitdata = {
79 .gpio_base = PM8018_GPIO_PM_TO_SYS(1),
80};
81
82static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata __devinitdata = {
83 .mpp_base = PM8018_MPP_PM_TO_SYS(1),
84};
85
86static struct pm8xxx_rtc_platform_data pm8xxx_rtc_pdata __devinitdata = {
87 .rtc_write_enable = false,
Ashay Jaiswaldb5e6dc2011-10-12 11:02:47 +053088 .rtc_alarm_powerup = false,
David Collinsfb88c432011-08-25 15:12:47 -070089};
90
91static struct pm8xxx_pwrkey_platform_data pm8xxx_pwrkey_pdata = {
92 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -080093 .kpd_trigger_delay_us = 15625,
David Collinsfb88c432011-08-25 15:12:47 -070094 .wakeup = 1,
95};
96
97static struct pm8xxx_misc_platform_data pm8xxx_misc_pdata = {
98 .priority = 0,
99};
100
Jay Chokshieb5d0d52011-09-28 17:16:20 -0700101#define PM8018_LED_KB_MAX_CURRENT 20 /* I = 20mA */
102#define PM8XXX_LED_PWM_PERIOD_US 1000
103
104/**
105 * PM8XXX_PWM_CHANNEL_NONE shall be used when LED shall not be
106 * driven using PWM feature.
107 */
108#define PM8XXX_PWM_CHANNEL_NONE -1
109
110static struct led_info pm8018_led_info[] = {
111 [0] = {
112 .name = "led:kb",
113 },
114};
115
116static struct led_platform_data pm8018_led_core_pdata = {
117 .num_leds = ARRAY_SIZE(pm8018_led_info),
118 .leds = pm8018_led_info,
119};
120
121static struct pm8xxx_led_config pm8018_led_configs[] = {
122 [0] = {
123 .id = PM8XXX_ID_LED_KB_LIGHT,
124 .mode = PM8XXX_LED_MODE_PWM3,
125 .max_current = PM8018_LED_KB_MAX_CURRENT,
126 .pwm_channel = 2,
127 .pwm_period_us = PM8XXX_LED_PWM_PERIOD_US,
128 },
129};
130
131static struct pm8xxx_led_platform_data pm8xxx_leds_pdata = {
132 .led_core = &pm8018_led_core_pdata,
133 .configs = pm8018_led_configs,
134 .num_configs = ARRAY_SIZE(pm8018_led_configs),
135};
136
Jay Chokshidc8028b2011-12-01 16:17:34 -0800137#ifdef CONFIG_LTC4088_CHARGER
138static struct ltc4088_charger_platform_data ltc4088_chg_pdata = {
139 .gpio_mode_select_d0 = 7,
140 .gpio_mode_select_d1 = 6,
141 .gpio_mode_select_d2 = 4,
142};
143#endif
144
David Collinsfb88c432011-08-25 15:12:47 -0700145static struct pm8018_platform_data pm8018_platform_data __devinitdata = {
146 .irq_pdata = &pm8xxx_irq_pdata,
147 .gpio_pdata = &pm8xxx_gpio_pdata,
148 .mpp_pdata = &pm8xxx_mpp_pdata,
149 .rtc_pdata = &pm8xxx_rtc_pdata,
150 .pwrkey_pdata = &pm8xxx_pwrkey_pdata,
151 .misc_pdata = &pm8xxx_misc_pdata,
David Collins00b31e62011-08-31 20:00:10 -0700152 .regulator_pdatas = msm_pm8018_regulator_pdata,
Siddartha Mohanadoss5f60b452011-10-05 11:49:00 -0700153 .adc_pdata = &pm8018_adc_pdata,
Jay Chokshieb5d0d52011-09-28 17:16:20 -0700154 .leds_pdata = &pm8xxx_leds_pdata,
David Collinsfb88c432011-08-25 15:12:47 -0700155};
156
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700157static struct msm_ssbi_platform_data msm9615_ssbi_pm8018_pdata __devinitdata = {
158 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
159 .slave = {
David Collinsfb88c432011-08-25 15:12:47 -0700160 .name = PM8018_CORE_DEV_NAME,
161 .platform_data = &pm8018_platform_data,
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700162 },
163};
164
David Collinsbea297a2011-09-28 13:11:14 -0700165static struct platform_device msm9615_device_rpm_regulator __devinitdata = {
166 .name = "rpm-regulator",
167 .id = -1,
168 .dev = {
169 .platform_data = &msm_rpm_regulator_9615_pdata,
170 },
171};
172
David Collins0f9942a2011-10-31 09:47:34 -0700173static struct platform_device msm9615_device_ext_2p95v_vreg = {
174 .name = GPIO_REGULATOR_DEV_NAME,
175 .id = 18,
176 .dev = {
177 .platform_data =
178 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_2P95V],
179 },
180};
181
Rohit Vaswanif688fa62011-10-13 18:13:10 -0700182static struct gpiomux_setting ps_hold = {
183 .func = GPIOMUX_FUNC_1,
184 .drv = GPIOMUX_DRV_8MA,
185 .pull = GPIOMUX_PULL_NONE,
186};
187
Rohit Vaswani09666872011-08-23 17:41:54 -0700188static struct gpiomux_setting gsbi4 = {
189 .func = GPIOMUX_FUNC_1,
190 .drv = GPIOMUX_DRV_8MA,
191 .pull = GPIOMUX_PULL_NONE,
192};
193
Harini Jayaramaneba52672011-09-08 15:13:00 -0600194static struct gpiomux_setting gsbi5 = {
195 .func = GPIOMUX_FUNC_1,
196 .drv = GPIOMUX_DRV_8MA,
197 .pull = GPIOMUX_PULL_NONE,
198};
199
Harini Jayaraman738c9312011-09-08 15:22:38 -0600200static struct gpiomux_setting gsbi3 = {
201 .func = GPIOMUX_FUNC_1,
202 .drv = GPIOMUX_DRV_8MA,
203 .pull = GPIOMUX_PULL_NONE,
204};
205
206static struct gpiomux_setting gsbi3_cs1_config = {
207 .func = GPIOMUX_FUNC_4,
208 .drv = GPIOMUX_DRV_8MA,
209 .pull = GPIOMUX_PULL_NONE,
210};
211
Jay Chokshidc8028b2011-12-01 16:17:34 -0800212#ifdef CONFIG_LTC4088_CHARGER
213static struct gpiomux_setting ltc4088_chg_cfg = {
214 .func = GPIOMUX_FUNC_GPIO,
215 .drv = GPIOMUX_DRV_8MA,
216 .pull = GPIOMUX_PULL_NONE,
217};
218#endif
219
Rohit Vaswanif688fa62011-10-13 18:13:10 -0700220struct msm_gpiomux_config msm9615_ps_hold_config[] __initdata = {
221 {
222 .gpio = 83,
223 .settings = {
224 [GPIOMUX_SUSPENDED] = &ps_hold,
225 },
226 },
227};
228
Jay Chokshidc8028b2011-12-01 16:17:34 -0800229#ifdef CONFIG_LTC4088_CHARGER
230static struct msm_gpiomux_config
231 msm9615_ltc4088_charger_config[] __initdata = {
232 {
233 .gpio = 4,
234 .settings = {
235 [GPIOMUX_SUSPENDED] = &ltc4088_chg_cfg,
236 },
237 },
238 {
239 .gpio = 6,
240 .settings = {
241 [GPIOMUX_SUSPENDED] = &ltc4088_chg_cfg,
242 },
243 },
244 {
245 .gpio = 7,
246 .settings = {
247 [GPIOMUX_SUSPENDED] = &ltc4088_chg_cfg,
248 },
249 },
250};
251#endif
252
Rohit Vaswani09666872011-08-23 17:41:54 -0700253struct msm_gpiomux_config msm9615_gsbi_configs[] __initdata = {
254 {
Harini Jayaraman738c9312011-09-08 15:22:38 -0600255 .gpio = 8, /* GSBI3 QUP SPI_CLK */
256 .settings = {
257 [GPIOMUX_SUSPENDED] = &gsbi3,
258 },
259 },
260 {
261 .gpio = 9, /* GSBI3 QUP SPI_CS_N */
262 .settings = {
263 [GPIOMUX_SUSPENDED] = &gsbi3,
264 },
265 },
266 {
267 .gpio = 10, /* GSBI3 QUP SPI_DATA_MISO */
268 .settings = {
269 [GPIOMUX_SUSPENDED] = &gsbi3,
270 },
271 },
272 {
273 .gpio = 11, /* GSBI3 QUP SPI_DATA_MOSI */
274 .settings = {
275 [GPIOMUX_SUSPENDED] = &gsbi3,
276 },
277 },
278 {
Rohit Vaswani09666872011-08-23 17:41:54 -0700279 .gpio = 12, /* GSBI4 UART */
280 .settings = {
281 [GPIOMUX_SUSPENDED] = &gsbi4,
282 },
283 },
284 {
285 .gpio = 13, /* GSBI4 UART */
286 .settings = {
287 [GPIOMUX_SUSPENDED] = &gsbi4,
288 },
289 },
290 {
291 .gpio = 14, /* GSBI4 UART */
292 .settings = {
293 [GPIOMUX_SUSPENDED] = &gsbi4,
294 },
295 },
296 {
297 .gpio = 15, /* GSBI4 UART */
298 .settings = {
299 [GPIOMUX_SUSPENDED] = &gsbi4,
300 },
301 },
Harini Jayaramaneba52672011-09-08 15:13:00 -0600302 {
303 .gpio = 16, /* GSBI5 I2C QUP SCL */
304 .settings = {
305 [GPIOMUX_SUSPENDED] = &gsbi5,
306 },
307 },
308 {
309 .gpio = 17, /* GSBI5 I2C QUP SDA */
310 .settings = {
311 [GPIOMUX_SUSPENDED] = &gsbi5,
312 },
313 },
Harini Jayaraman738c9312011-09-08 15:22:38 -0600314 {
315 /* GPIO 19 can be used for I2C/UART on GSBI5 */
316 .gpio = 19, /* GSBI3 QUP SPI_CS_1 */
317 .settings = {
318 [GPIOMUX_SUSPENDED] = &gsbi3_cs1_config,
319 },
320 },
Rohit Vaswani09666872011-08-23 17:41:54 -0700321};
322
Krishna Kondadd794462011-10-01 00:19:29 -0700323#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
324 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT))
325
Krishna Konda7186bfe2011-10-17 15:36:54 -0700326#define GPIO_SDC1_HW_DET 80
Krishna Konda3b78ea72011-10-18 16:09:19 -0700327#define GPIO_SDC2_DAT1_WAKEUP 26
Krishna Kondadd794462011-10-01 00:19:29 -0700328
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -0700329/* MDM9x15 has 2 SDCC controllers */
Krishna Kondadd794462011-10-01 00:19:29 -0700330enum sdcc_controllers {
331 SDCC1,
332 SDCC2,
333 MAX_SDCC_CONTROLLER
334};
335
336#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Krishna Kondafea60182011-11-01 16:01:34 -0700337/* All SDCC controllers requires VDD/VCC voltage */
338static struct msm_mmc_reg_data mmc_vdd_reg_data[MAX_SDCC_CONTROLLER] = {
339 /* SDCC1 : External card slot connected */
340 [SDCC1] = {
341 .name = "sdc_vdd",
342 /*
343 * This is a gpio-regulator and does not support
344 * regulator_set_voltage and regulator_set_optimum_mode
345 */
Krishna Kondafea60182011-11-01 16:01:34 -0700346 .high_vol_level = 2950000,
347 .low_vol_level = 2950000,
348 .hpm_uA = 600000, /* 600mA */
349 }
350};
351
352/* All SDCC controllers may require voting for VDD PAD voltage */
353static struct msm_mmc_reg_data mmc_vddp_reg_data[MAX_SDCC_CONTROLLER] = {
354 /* SDCC1 : External card slot connected */
355 [SDCC1] = {
356 .name = "sdc_vddp",
Krishna Kondafea60182011-11-01 16:01:34 -0700357 .high_vol_level = 2950000,
358 .low_vol_level = 1850000,
359 .always_on = true,
360 .lpm_sup = true,
361 /* Max. Active current required is 16 mA */
362 .hpm_uA = 16000,
363 /*
364 * Sleep current required is ~300 uA. But min. vote can be
365 * in terms of mA (min. 1 mA). So let's vote for 2 mA
366 * during sleep.
367 */
368 .lpm_uA = 2000,
369 }
370};
371
372static struct msm_mmc_slot_reg_data mmc_slot_vreg_data[MAX_SDCC_CONTROLLER] = {
373 /* SDCC1 : External card slot connected */
374 [SDCC1] = {
375 .vdd_data = &mmc_vdd_reg_data[SDCC1],
376 .vddp_data = &mmc_vddp_reg_data[SDCC1],
377 }
378};
379
Krishna Kondadd794462011-10-01 00:19:29 -0700380/* SDC1 pad data */
381static struct msm_mmc_pad_drv sdc1_pad_drv_on_cfg[] = {
382 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_16MA},
383 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_10MA},
384 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_10MA}
385};
386
387static struct msm_mmc_pad_drv sdc1_pad_drv_off_cfg[] = {
388 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_2MA},
389 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_2MA},
390 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_2MA}
391};
392
393static struct msm_mmc_pad_pull sdc1_pad_pull_on_cfg[] = {
394 {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL},
395 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_UP},
396 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_UP}
397};
398
399static struct msm_mmc_pad_pull sdc1_pad_pull_off_cfg[] = {
400 {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL},
401 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_DOWN},
402 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_DOWN}
403};
404
405static struct msm_mmc_pad_pull_data mmc_pad_pull_data[MAX_SDCC_CONTROLLER] = {
406 [SDCC1] = {
407 .on = sdc1_pad_pull_on_cfg,
408 .off = sdc1_pad_pull_off_cfg,
409 .size = ARRAY_SIZE(sdc1_pad_pull_on_cfg)
410 },
411};
412
413static struct msm_mmc_pad_drv_data mmc_pad_drv_data[MAX_SDCC_CONTROLLER] = {
414 [SDCC1] = {
415 .on = sdc1_pad_drv_on_cfg,
416 .off = sdc1_pad_drv_off_cfg,
417 .size = ARRAY_SIZE(sdc1_pad_drv_on_cfg)
418 },
419};
420
421static struct msm_mmc_pad_data mmc_pad_data[MAX_SDCC_CONTROLLER] = {
422 [SDCC1] = {
423 .pull = &mmc_pad_pull_data[SDCC1],
424 .drv = &mmc_pad_drv_data[SDCC1]
425 },
426};
427#endif
428
Krishna Konda71aef182011-10-01 02:27:51 -0700429#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
430static struct gpiomux_setting sdcc2_clk_actv_cfg = {
431 .func = GPIOMUX_FUNC_1,
432 .drv = GPIOMUX_DRV_16MA,
433 .pull = GPIOMUX_PULL_NONE,
434};
435
436static struct gpiomux_setting sdcc2_cmd_data_0_3_actv_cfg = {
437 .func = GPIOMUX_FUNC_1,
438 .drv = GPIOMUX_DRV_8MA,
439 .pull = GPIOMUX_PULL_UP,
440};
441
442static struct gpiomux_setting sdcc2_suspend_cfg = {
443 .func = GPIOMUX_FUNC_1,
444 .drv = GPIOMUX_DRV_2MA,
445 .pull = GPIOMUX_PULL_DOWN,
446};
447
448static struct msm_gpiomux_config msm9615_sdcc2_configs[] __initdata = {
449 {
450 /* SDC2_DATA_0 */
451 .gpio = 25,
452 .settings = {
453 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
454 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
455 },
456 },
457 {
458 /* SDC2_DATA_1 */
459 .gpio = 26,
460 .settings = {
461 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
Krishna Konda0b10fa12011-11-07 22:47:41 -0800462 [GPIOMUX_SUSPENDED] = &sdcc2_cmd_data_0_3_actv_cfg,
Krishna Konda71aef182011-10-01 02:27:51 -0700463 },
464 },
465 {
466 /* SDC2_DATA_2 */
467 .gpio = 27,
468 .settings = {
469 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
470 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
471 },
472 },
473 {
474 /* SDC2_DATA_3 */
475 .gpio = 28,
476 .settings = {
477 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
478 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
479 },
480 },
481 {
Krishna Konda0b10fa12011-11-07 22:47:41 -0800482 /* SDC2_CMD */
Krishna Konda71aef182011-10-01 02:27:51 -0700483 .gpio = 29,
484 .settings = {
485 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
486 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
487 },
488 },
489 {
Krishna Konda0b10fa12011-11-07 22:47:41 -0800490 /* SDC2_CLK */
Krishna Konda71aef182011-10-01 02:27:51 -0700491 .gpio = 30,
492 .settings = {
493 [GPIOMUX_ACTIVE] = &sdcc2_clk_actv_cfg,
494 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
495 },
496 },
497};
498
499static struct msm_mmc_gpio sdc2_gpio_cfg[] = {
500 {25, "sdc2_dat_0"},
501 {26, "sdc2_dat_1"},
502 {27, "sdc2_dat_2"},
503 {28, "sdc2_dat_3"},
504 {29, "sdc2_cmd"},
505 {30, "sdc2_clk"},
506};
507
508static struct msm_mmc_gpio_data mmc_gpio_data[MAX_SDCC_CONTROLLER] = {
509 [SDCC2] = {
510 .gpio = sdc2_gpio_cfg,
511 .size = ARRAY_SIZE(sdc2_gpio_cfg),
512 },
513};
514#else
515static struct msm_gpiomux_config msm9615_sdcc2_configs[0];
516#endif
517
518static struct msm_mmc_pin_data mmc_slot_pin_data[MAX_SDCC_CONTROLLER] = {
Krishna Kondadd794462011-10-01 00:19:29 -0700519#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
520 [SDCC1] = {
521 .is_gpio = 0,
522 .pad_data = &mmc_pad_data[SDCC1],
523 },
524#endif
Krishna Konda71aef182011-10-01 02:27:51 -0700525#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
526 [SDCC2] = {
527 .is_gpio = 1,
528 .gpio_data = &mmc_gpio_data[SDCC2],
529 },
530#endif
Krishna Kondadd794462011-10-01 00:19:29 -0700531};
532
533#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
534static unsigned int sdc1_sup_clk_rates[] = {
535 400000, 24000000, 48000000
536};
537
538static struct mmc_platform_data sdc1_data = {
539 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
540 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
541 .sup_clk_table = sdc1_sup_clk_rates,
542 .sup_clk_cnt = ARRAY_SIZE(sdc1_sup_clk_rates),
Krishna Kondafea60182011-11-01 16:01:34 -0700543 .pclk_src_dfab = true,
Krishna Kondafea60182011-11-01 16:01:34 -0700544 .vreg_data = &mmc_slot_vreg_data[SDCC1],
Krishna Kondadd794462011-10-01 00:19:29 -0700545 .pin_data = &mmc_slot_pin_data[SDCC1],
Krishna Konda7186bfe2011-10-17 15:36:54 -0700546#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
547 .status_gpio = GPIO_SDC1_HW_DET,
548 .status_irq = MSM_GPIO_TO_INT(GPIO_SDC1_HW_DET),
549 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
550#endif
Krishna Kondadbcf9702011-11-07 18:45:48 -0800551 .xpc_cap = 1,
552 .uhs_caps = (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 |
553 MMC_CAP_MAX_CURRENT_400)
Krishna Kondadd794462011-10-01 00:19:29 -0700554};
555static struct mmc_platform_data *msm9615_sdc1_pdata = &sdc1_data;
556#else
557static struct mmc_platform_data *msm9615_sdc1_pdata;
558#endif
559
Krishna Konda71aef182011-10-01 02:27:51 -0700560#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
561static unsigned int sdc2_sup_clk_rates[] = {
562 400000, 24000000, 48000000
563};
564
565static struct mmc_platform_data sdc2_data = {
566 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
567 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
568 .sup_clk_table = sdc2_sup_clk_rates,
569 .sup_clk_cnt = ARRAY_SIZE(sdc2_sup_clk_rates),
Krishna Konda890b1d12011-10-18 16:05:37 -0700570 .pclk_src_dfab = 1,
Krishna Konda71aef182011-10-01 02:27:51 -0700571 .pin_data = &mmc_slot_pin_data[SDCC2],
Krishna Konda3b78ea72011-10-18 16:09:19 -0700572#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
573 .sdiowakeup_irq = MSM_GPIO_TO_INT(GPIO_SDC2_DAT1_WAKEUP),
574#endif
Krishna Konda71aef182011-10-01 02:27:51 -0700575};
576static struct mmc_platform_data *msm9615_sdc2_pdata = &sdc2_data;
577#else
578static struct mmc_platform_data *msm9615_sdc2_pdata;
579#endif
580
Krishna Kondadd794462011-10-01 00:19:29 -0700581static void __init msm9615_init_mmc(void)
582{
Krishna Kondadd794462011-10-01 00:19:29 -0700583 if (msm9615_sdc1_pdata) {
Krishna Kondafea60182011-11-01 16:01:34 -0700584 /* SDC1: External card slot for SD/MMC cards */
585 msm_add_sdcc(1, msm9615_sdc1_pdata);
Krishna Kondadd794462011-10-01 00:19:29 -0700586 }
Krishna Konda71aef182011-10-01 02:27:51 -0700587
588 if (msm9615_sdc2_pdata) {
589 msm_gpiomux_install(msm9615_sdcc2_configs,
590 ARRAY_SIZE(msm9615_sdcc2_configs));
591
Krishna Kondafea60182011-11-01 16:01:34 -0700592 /* SDC2: External card slot used for WLAN */
Krishna Konda71aef182011-10-01 02:27:51 -0700593 msm_add_sdcc(2, msm9615_sdc2_pdata);
594 }
Krishna Kondadd794462011-10-01 00:19:29 -0700595}
596#else
597static void __init msm9615_init_mmc(void) { }
598#endif
Maheshkumar Sivasubramanian4923db22011-09-15 09:28:15 -0600599static struct msm_cpuidle_state msm_cstates[] __initdata = {
600 {0, 0, "C0", "WFI",
601 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
602
603 {0, 1, "C1", "STANDALONE_POWER_COLLAPSE",
604 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
605
606 {0, 2, "C2", "POWER_COLLAPSE",
607 MSM_PM_SLEEP_MODE_POWER_COLLAPSE},
608};
609static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
610 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
611 .idle_supported = 1,
612 .suspend_supported = 1,
613 .idle_enabled = 0,
614 .suspend_enabled = 0,
615 },
616 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
617 .idle_supported = 1,
618 .suspend_supported = 1,
619 .idle_enabled = 0,
620 .suspend_enabled = 0,
621 },
622 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
623 .idle_supported = 1,
624 .suspend_supported = 1,
625 .idle_enabled = 1,
626 .suspend_enabled = 1,
627 },
628};
Krishna Kondadd794462011-10-01 00:19:29 -0700629
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700630static int __init gpiomux_init(void)
631{
632 int rc;
633
634 rc = msm_gpiomux_init(NR_GPIO_IRQS);
635 if (rc) {
636 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
637 return rc;
638 }
Rohit Vaswani09666872011-08-23 17:41:54 -0700639 msm_gpiomux_install(msm9615_gsbi_configs,
640 ARRAY_SIZE(msm9615_gsbi_configs));
641
Rohit Vaswanif688fa62011-10-13 18:13:10 -0700642 msm_gpiomux_install(msm9615_ps_hold_config,
643 ARRAY_SIZE(msm9615_ps_hold_config));
Jay Chokshidc8028b2011-12-01 16:17:34 -0800644#ifdef CONFIG_LTC4088_CHARGER
645 msm_gpiomux_install(msm9615_ltc4088_charger_config,
646 ARRAY_SIZE(msm9615_ltc4088_charger_config));
647#endif
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700648 return 0;
649}
650
Gagan Mac7a827642011-09-22 19:42:21 -0600651static void __init msm9615_init_buses(void)
652{
653#ifdef CONFIG_MSM_BUS_SCALING
654 msm_bus_rpm_set_mt_mask();
655 msm_bus_9615_sys_fabric_pdata.rpm_enabled = 1;
656 msm_bus_9615_sys_fabric.dev.platform_data =
657 &msm_bus_9615_sys_fabric_pdata;
658 msm_bus_def_fab.dev.platform_data = &msm_bus_9615_def_fab_pdata;
659#endif
660}
661
Harini Jayaraman738c9312011-09-08 15:22:38 -0600662static struct msm_spi_platform_data msm9615_qup_spi_gsbi3_pdata = {
663 .max_clock_speed = 24000000,
664};
665
Harini Jayaramaneba52672011-09-08 15:13:00 -0600666static struct msm_i2c_platform_data msm9615_i2c_qup_gsbi5_pdata = {
667 .clk_freq = 100000,
668 .src_clk_rate = 24000000,
669};
670
Amit Blay6a8d4f32011-11-21 10:36:25 +0200671#define USB_5V_EN 3
672#define PM_USB_5V_EN PM8018_GPIO_PM_TO_SYS(USB_5V_EN)
673
674static void msm_hsusb_vbus_power(bool on)
675{
676 int rc;
677 static bool vbus_is_on;
678 struct pm_gpio usb_vbus = {
679 .direction = PM_GPIO_DIR_OUT,
680 .pull = PM_GPIO_PULL_NO,
681 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
682 .output_value = 0,
683 .vin_sel = 2,
684 .out_strength = PM_GPIO_STRENGTH_HIGH,
685 .function = PM_GPIO_FUNC_NORMAL,
686 .inv_int_pol = 0,
687 };
688
689 if (vbus_is_on == on)
690 return;
691
692 if (on) {
693 rc = pm8xxx_gpio_config(PM_USB_5V_EN, &usb_vbus);
694 if (rc) {
695 pr_err("failed to config usb_5v_en gpio\n");
696 return;
697 }
698
699 rc = gpio_request(PM_USB_5V_EN,
700 "usb_5v_en");
701 if (rc < 0) {
702 pr_err("failed to request usb_5v_en gpio\n");
703 return;
704 }
705
706 rc = gpio_direction_output(PM_USB_5V_EN, 1);
707 if (rc) {
708 pr_err("%s: unable to set_direction for gpio [%d]\n",
709 __func__, PM_USB_5V_EN);
710 goto free_usb_5v_en;
711 }
712
713 vbus_is_on = true;
714 return;
715 }
716 gpio_set_value(PM_USB_5V_EN, 0);
717free_usb_5v_en:
718 gpio_free(PM_USB_5V_EN);
719 vbus_is_on = false;
720}
721
Anji jonnalaa8b8d732011-12-06 10:03:24 +0530722static int shelby_phy_init_seq[] = {
723 0x44, 0x80,/* set VBUS valid threshold and
724 disconnect valid threshold */
725 0x38, 0x81, /* update DC voltage level */
726 0x14, 0x82,/* set preemphasis and rise/fall time */
727 0x13, 0x83,/* set source impedance adjustment */
728 -1};
729
Ofir Cohen40a4e862011-12-08 15:17:52 +0200730#define USB_BAM_PHY_BASE 0x12502000
731#define USB_BAM_PHY_SIZE 0x10000
732#define A2_BAM_PHY_BASE 0x124C2000
733static struct usb_bam_pipe_connect msm_usb_bam_connections[4][2] = {
734 [0][USB_TO_PEER_PERIPHERAL] = {
735 .src_phy_addr = USB_BAM_PHY_BASE,
736 .src_pipe_index = 11,
737 .dst_phy_addr = A2_BAM_PHY_BASE,
738 .dst_pipe_index = 0,
739 .data_fifo_base_offset = 0xf00,
740 .data_fifo_size = 0x400,
741 .desc_fifo_base_offset = 0x1300,
742 .desc_fifo_size = 0x300,
743 },
744 [0][PEER_PERIPHERAL_TO_USB] = {
745 .src_phy_addr = A2_BAM_PHY_BASE,
746 .src_pipe_index = 1,
747 .dst_phy_addr = USB_BAM_PHY_BASE,
748 .dst_pipe_index = 10,
749 .data_fifo_base_offset = 0xa00,
750 .data_fifo_size = 0x400,
751 .desc_fifo_base_offset = 0xe00,
752 .desc_fifo_size = 0x100,
753 },
754};
755
756static struct msm_usb_bam_platform_data msm_usb_bam_pdata = {
757 .connections = &msm_usb_bam_connections[0][0],
758 .usb_bam_phy_base = USB_BAM_PHY_BASE,
759 .usb_bam_phy_size = USB_BAM_PHY_SIZE,
760 .usb_bam_num_pipes = 32,
761};
762
Amit Blay5e4ec192011-10-20 09:16:54 +0200763static struct msm_otg_platform_data msm_otg_pdata = {
Amit Blay6a8d4f32011-11-21 10:36:25 +0200764 .mode = USB_OTG,
765 .otg_control = OTG_PHY_CONTROL,
Amit Blay5e4ec192011-10-20 09:16:54 +0200766 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200767 .pclk_src_name = "dfab_usb_hs_clk",
768 .vbus_power = msm_hsusb_vbus_power,
Amit Blay5e4ec192011-10-20 09:16:54 +0200769};
770
771static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
772{
773 return 0;
774}
775
776static struct android_usb_platform_data android_usb_pdata = {
777 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
778};
779
780static struct platform_device android_usb_device = {
781 .name = "android_usb",
782 .id = -1,
783 .dev = {
784 .platform_data = &android_usb_pdata,
785 },
786};
787
Rohit Vaswani149f0a72011-11-09 15:21:28 -0800788static struct platform_device msm_wlan_ar6000_pm_device = {
789 .name = "wlan_ar6000_pm_dev",
790 .id = -1,
791};
792
793static int __init msm9615_init_ar6000pm(void)
794{
795 return platform_device_register(&msm_wlan_ar6000_pm_device);
796}
797
Jay Chokshidc8028b2011-12-01 16:17:34 -0800798#ifdef CONFIG_LTC4088_CHARGER
799static struct platform_device msm_device_charger = {
800 .name = LTC4088_CHARGER_DEV_NAME,
801 .id = -1,
802 .dev = {
803 .platform_data = &ltc4088_chg_pdata,
804 },
805};
806#endif
807
Amit Blay5e4ec192011-10-20 09:16:54 +0200808static struct platform_device *common_devices[] = {
809 &msm9615_device_dmov,
810 &msm_device_smd,
Jay Chokshidc8028b2011-12-01 16:17:34 -0800811#ifdef CONFIG_LTC4088_CHARGER
812 &msm_device_charger,
813#endif
Amit Blay5e4ec192011-10-20 09:16:54 +0200814 &msm_device_otg,
815 &msm_device_gadget_peripheral,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200816 &msm_device_hsusb_host,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200817 &msm_device_usb_bam,
Amit Blay5e4ec192011-10-20 09:16:54 +0200818 &android_usb_device,
819 &msm9615_device_uart_gsbi4,
David Collins0f9942a2011-10-31 09:47:34 -0700820 &msm9615_device_ext_2p95v_vreg,
Amit Blay5e4ec192011-10-20 09:16:54 +0200821 &msm9615_device_ssbi_pmic1,
822 &msm9615_device_qup_i2c_gsbi5,
823 &msm9615_device_qup_spi_gsbi3,
824 &msm_device_sps,
825 &msm9615_device_tsens,
826 &msm_device_nand,
Eric Holmberg0c96e702011-11-08 18:04:31 -0700827 &msm_device_bam_dmux,
Amit Blay5e4ec192011-10-20 09:16:54 +0200828 &msm_rpm_device,
829#ifdef CONFIG_HW_RANDOM_MSM
830 &msm_device_rng,
831#endif
832
833#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
834 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
Ramesh Masavarapuaa28b5b2011-10-21 10:26:03 -0700835 &msm9615_qcrypto_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200836#endif
837
838#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
839 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
Ramesh Masavarapuaa28b5b2011-10-21 10:26:03 -0700840 &msm9615_qcedev_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200841#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700842 &msm9615_device_watchdog,
Gagan Mac7a827642011-09-22 19:42:21 -0600843 &msm_bus_9615_sys_fabric,
844 &msm_bus_def_fab,
Amit Blay5e4ec192011-10-20 09:16:54 +0200845};
846
Harini Jayaramaneba52672011-09-08 15:13:00 -0600847static void __init msm9615_i2c_init(void)
848{
849 msm9615_device_qup_i2c_gsbi5.dev.platform_data =
850 &msm9615_i2c_qup_gsbi5_pdata;
851}
852
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700853static void __init msm9615_common_init(void)
854{
855 msm9615_device_init();
856 gpiomux_init();
Harini Jayaramaneba52672011-09-08 15:13:00 -0600857 msm9615_i2c_init();
David Collins00b31e62011-08-31 20:00:10 -0700858 regulator_suppress_info_printing();
David Collinsbea297a2011-09-28 13:11:14 -0700859 platform_device_register(&msm9615_device_rpm_regulator);
Gagan Mac7a827642011-09-22 19:42:21 -0600860 msm_clock_init(&msm9615_clock_init_data);
861 msm9615_init_buses();
Harini Jayaraman738c9312011-09-08 15:22:38 -0600862 msm9615_device_qup_spi_gsbi3.dev.platform_data =
863 &msm9615_qup_spi_gsbi3_pdata;
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700864 msm9615_device_ssbi_pmic1.dev.platform_data =
865 &msm9615_ssbi_pm8018_pdata;
David Collins00b31e62011-08-31 20:00:10 -0700866 pm8018_platform_data.num_regulators = msm_pm8018_regulator_pdata_len;
Amit Blay5e4ec192011-10-20 09:16:54 +0200867
868 msm_device_otg.dev.platform_data = &msm_otg_pdata;
Anji jonnalaa8b8d732011-12-06 10:03:24 +0530869 msm_otg_pdata.phy_init_seq = shelby_phy_init_seq;
Ofir Cohen40a4e862011-12-08 15:17:52 +0200870 msm_device_usb_bam.dev.platform_data = &msm_usb_bam_pdata;
Rohit Vaswani09666872011-08-23 17:41:54 -0700871 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Krishna Kondadd794462011-10-01 00:19:29 -0700872
Vikram Mulukutlab5e1cda2011-10-04 16:17:22 -0700873 acpuclk_init(&acpuclk_9615_soc_data);
874
Rohit Vaswani149f0a72011-11-09 15:21:28 -0800875 /* Ensure ar6000pm device is registered before MMC/SDC */
876 msm9615_init_ar6000pm();
877
Krishna Kondadd794462011-10-01 00:19:29 -0700878 msm9615_init_mmc();
Maheshkumar Sivasubramanian4923db22011-09-15 09:28:15 -0600879 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
880 msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ);
881 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
882 msm_pm_data);
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700883}
884
885static void __init msm9615_cdp_init(void)
886{
887 msm9615_common_init();
888}
889
890static void __init msm9615_mtp_init(void)
891{
892 msm9615_common_init();
893}
894
895MACHINE_START(MSM9615_CDP, "QCT MSM9615 CDP")
896 .map_io = msm9615_map_io,
897 .init_irq = msm9615_init_irq,
898 .timer = &msm_timer,
899 .init_machine = msm9615_cdp_init,
900MACHINE_END
901
902MACHINE_START(MSM9615_MTP, "QCT MSM9615 MTP")
903 .map_io = msm9615_map_io,
904 .init_irq = msm9615_init_irq,
905 .timer = &msm_timer,
906 .init_machine = msm9615_mtp_init,
907MACHINE_END