blob: f5bd44dc6c0dd72dd41136202af0c24ed01ec96d [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>
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060017#include <linux/memblock.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070018#include <asm/mach-types.h>
19#include <asm/mach/arch.h>
Krishna Kondadd794462011-10-01 00:19:29 -070020#include <asm/mach/mmc.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070021#include <mach/board.h>
22#include <mach/msm_iomap.h>
23#include <mach/gpio.h>
24#include <mach/gpiomux.h>
Harini Jayaraman738c9312011-09-08 15:22:38 -060025#include <mach/msm_spi.h>
Amit Blay5e4ec192011-10-20 09:16:54 +020026#include <linux/usb/android.h>
27#include <linux/usb/msm_hsusb.h>
Siddartha Mohanadoss5f60b452011-10-05 11:49:00 -070028#include <linux/mfd/pm8xxx/pm8xxx-adc.h>
Jay Chokshieb5d0d52011-09-28 17:16:20 -070029#include <linux/leds.h>
30#include <linux/leds-pm8xxx.h>
Gagan Mac7a827642011-09-22 19:42:21 -060031#include <mach/msm_bus_board.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070032#include "timer.h"
33#include "devices.h"
David Collinsfb88c432011-08-25 15:12:47 -070034#include "board-9615.h"
Maheshkumar Sivasubramanian4923db22011-09-15 09:28:15 -060035#include "cpuidle.h"
36#include "pm.h"
Vikram Mulukutlab5e1cda2011-10-04 16:17:22 -070037#include "acpuclock.h"
Jay Chokshidc8028b2011-12-01 16:17:34 -080038#include <linux/power/ltc4088-charger.h>
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060039#include "pm-boot.h"
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070040
Siddartha Mohanadoss5f60b452011-10-05 11:49:00 -070041static struct pm8xxx_adc_amux pm8018_adc_channels_data[] = {
42 {"vcoin", CHANNEL_VCOIN, CHAN_PATH_SCALING2, AMUX_RSV1,
43 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
44 {"vbat", CHANNEL_VBAT, CHAN_PATH_SCALING2, AMUX_RSV1,
45 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
46 {"vph_pwr", CHANNEL_VPH_PWR, CHAN_PATH_SCALING2, AMUX_RSV1,
47 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
48 {"batt_therm", CHANNEL_BATT_THERM, CHAN_PATH_SCALING1, AMUX_RSV2,
49 ADC_DECIMATION_TYPE2, ADC_SCALE_BATT_THERM},
50 {"batt_id", CHANNEL_BATT_ID, CHAN_PATH_SCALING1, AMUX_RSV2,
51 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
52 {"pmic_therm", CHANNEL_DIE_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
53 ADC_DECIMATION_TYPE2, ADC_SCALE_PMIC_THERM},
54 {"625mv", CHANNEL_625MV, CHAN_PATH_SCALING1, AMUX_RSV1,
55 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
56 {"125v", CHANNEL_125V, CHAN_PATH_SCALING1, AMUX_RSV1,
57 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
58 {"pa_therm0", ADC_MPP_1_AMUX3, CHAN_PATH_SCALING1, AMUX_RSV1,
59 ADC_DECIMATION_TYPE2, ADC_SCALE_PA_THERM},
60};
61
62static struct pm8xxx_adc_properties pm8018_adc_data = {
63 .adc_vdd_reference = 1800, /* milli-voltage for this adc */
64 .bitresolution = 15,
65 .bipolar = 0,
66};
67
68static struct pm8xxx_adc_platform_data pm8018_adc_pdata = {
69 .adc_channel = pm8018_adc_channels_data,
70 .adc_num_board_channel = ARRAY_SIZE(pm8018_adc_channels_data),
71 .adc_prop = &pm8018_adc_data,
72};
73
David Collinsfb88c432011-08-25 15:12:47 -070074static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata __devinitdata = {
75 .irq_base = PM8018_IRQ_BASE,
76 .devirq = MSM_GPIO_TO_INT(87),
77 .irq_trigger_flag = IRQF_TRIGGER_LOW,
78};
79
80static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata __devinitdata = {
81 .gpio_base = PM8018_GPIO_PM_TO_SYS(1),
82};
83
84static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata __devinitdata = {
85 .mpp_base = PM8018_MPP_PM_TO_SYS(1),
86};
87
88static struct pm8xxx_rtc_platform_data pm8xxx_rtc_pdata __devinitdata = {
89 .rtc_write_enable = false,
Ashay Jaiswaldb5e6dc2011-10-12 11:02:47 +053090 .rtc_alarm_powerup = false,
David Collinsfb88c432011-08-25 15:12:47 -070091};
92
93static struct pm8xxx_pwrkey_platform_data pm8xxx_pwrkey_pdata = {
94 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -080095 .kpd_trigger_delay_us = 15625,
David Collinsfb88c432011-08-25 15:12:47 -070096 .wakeup = 1,
97};
98
99static struct pm8xxx_misc_platform_data pm8xxx_misc_pdata = {
100 .priority = 0,
101};
102
Jay Chokshieb5d0d52011-09-28 17:16:20 -0700103#define PM8018_LED_KB_MAX_CURRENT 20 /* I = 20mA */
104#define PM8XXX_LED_PWM_PERIOD_US 1000
105
106/**
107 * PM8XXX_PWM_CHANNEL_NONE shall be used when LED shall not be
108 * driven using PWM feature.
109 */
110#define PM8XXX_PWM_CHANNEL_NONE -1
111
112static struct led_info pm8018_led_info[] = {
113 [0] = {
114 .name = "led:kb",
115 },
116};
117
118static struct led_platform_data pm8018_led_core_pdata = {
119 .num_leds = ARRAY_SIZE(pm8018_led_info),
120 .leds = pm8018_led_info,
121};
122
123static struct pm8xxx_led_config pm8018_led_configs[] = {
124 [0] = {
125 .id = PM8XXX_ID_LED_KB_LIGHT,
126 .mode = PM8XXX_LED_MODE_PWM3,
127 .max_current = PM8018_LED_KB_MAX_CURRENT,
128 .pwm_channel = 2,
129 .pwm_period_us = PM8XXX_LED_PWM_PERIOD_US,
130 },
131};
132
133static struct pm8xxx_led_platform_data pm8xxx_leds_pdata = {
134 .led_core = &pm8018_led_core_pdata,
135 .configs = pm8018_led_configs,
136 .num_configs = ARRAY_SIZE(pm8018_led_configs),
137};
138
Jay Chokshidc8028b2011-12-01 16:17:34 -0800139#ifdef CONFIG_LTC4088_CHARGER
140static struct ltc4088_charger_platform_data ltc4088_chg_pdata = {
141 .gpio_mode_select_d0 = 7,
142 .gpio_mode_select_d1 = 6,
143 .gpio_mode_select_d2 = 4,
144};
145#endif
146
David Collinsfb88c432011-08-25 15:12:47 -0700147static struct pm8018_platform_data pm8018_platform_data __devinitdata = {
148 .irq_pdata = &pm8xxx_irq_pdata,
149 .gpio_pdata = &pm8xxx_gpio_pdata,
150 .mpp_pdata = &pm8xxx_mpp_pdata,
151 .rtc_pdata = &pm8xxx_rtc_pdata,
152 .pwrkey_pdata = &pm8xxx_pwrkey_pdata,
153 .misc_pdata = &pm8xxx_misc_pdata,
David Collins00b31e62011-08-31 20:00:10 -0700154 .regulator_pdatas = msm_pm8018_regulator_pdata,
Siddartha Mohanadoss5f60b452011-10-05 11:49:00 -0700155 .adc_pdata = &pm8018_adc_pdata,
Jay Chokshieb5d0d52011-09-28 17:16:20 -0700156 .leds_pdata = &pm8xxx_leds_pdata,
David Collinsfb88c432011-08-25 15:12:47 -0700157};
158
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700159static struct msm_ssbi_platform_data msm9615_ssbi_pm8018_pdata __devinitdata = {
160 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
161 .slave = {
David Collinsfb88c432011-08-25 15:12:47 -0700162 .name = PM8018_CORE_DEV_NAME,
163 .platform_data = &pm8018_platform_data,
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700164 },
165};
166
David Collinsbea297a2011-09-28 13:11:14 -0700167static struct platform_device msm9615_device_rpm_regulator __devinitdata = {
168 .name = "rpm-regulator",
169 .id = -1,
170 .dev = {
171 .platform_data = &msm_rpm_regulator_9615_pdata,
172 },
173};
174
David Collins0f9942a2011-10-31 09:47:34 -0700175static struct platform_device msm9615_device_ext_2p95v_vreg = {
176 .name = GPIO_REGULATOR_DEV_NAME,
177 .id = 18,
178 .dev = {
179 .platform_data =
180 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_2P95V],
181 },
182};
183
Rohit Vaswanif688fa62011-10-13 18:13:10 -0700184static struct gpiomux_setting ps_hold = {
185 .func = GPIOMUX_FUNC_1,
186 .drv = GPIOMUX_DRV_8MA,
187 .pull = GPIOMUX_PULL_NONE,
188};
189
Rohit Vaswani09666872011-08-23 17:41:54 -0700190static struct gpiomux_setting gsbi4 = {
191 .func = GPIOMUX_FUNC_1,
192 .drv = GPIOMUX_DRV_8MA,
193 .pull = GPIOMUX_PULL_NONE,
194};
195
Harini Jayaramaneba52672011-09-08 15:13:00 -0600196static struct gpiomux_setting gsbi5 = {
197 .func = GPIOMUX_FUNC_1,
198 .drv = GPIOMUX_DRV_8MA,
199 .pull = GPIOMUX_PULL_NONE,
200};
201
Harini Jayaraman738c9312011-09-08 15:22:38 -0600202static struct gpiomux_setting gsbi3 = {
203 .func = GPIOMUX_FUNC_1,
204 .drv = GPIOMUX_DRV_8MA,
205 .pull = GPIOMUX_PULL_NONE,
206};
207
208static struct gpiomux_setting gsbi3_cs1_config = {
209 .func = GPIOMUX_FUNC_4,
210 .drv = GPIOMUX_DRV_8MA,
211 .pull = GPIOMUX_PULL_NONE,
212};
213
Jay Chokshidc8028b2011-12-01 16:17:34 -0800214#ifdef CONFIG_LTC4088_CHARGER
215static struct gpiomux_setting ltc4088_chg_cfg = {
216 .func = GPIOMUX_FUNC_GPIO,
217 .drv = GPIOMUX_DRV_8MA,
218 .pull = GPIOMUX_PULL_NONE,
219};
220#endif
221
Rohit Vaswanif688fa62011-10-13 18:13:10 -0700222struct msm_gpiomux_config msm9615_ps_hold_config[] __initdata = {
223 {
224 .gpio = 83,
225 .settings = {
226 [GPIOMUX_SUSPENDED] = &ps_hold,
227 },
228 },
229};
230
Jay Chokshidc8028b2011-12-01 16:17:34 -0800231#ifdef CONFIG_LTC4088_CHARGER
232static struct msm_gpiomux_config
233 msm9615_ltc4088_charger_config[] __initdata = {
234 {
235 .gpio = 4,
236 .settings = {
237 [GPIOMUX_SUSPENDED] = &ltc4088_chg_cfg,
238 },
239 },
240 {
241 .gpio = 6,
242 .settings = {
243 [GPIOMUX_SUSPENDED] = &ltc4088_chg_cfg,
244 },
245 },
246 {
247 .gpio = 7,
248 .settings = {
249 [GPIOMUX_SUSPENDED] = &ltc4088_chg_cfg,
250 },
251 },
252};
253#endif
254
Rohit Vaswani09666872011-08-23 17:41:54 -0700255struct msm_gpiomux_config msm9615_gsbi_configs[] __initdata = {
256 {
Harini Jayaraman738c9312011-09-08 15:22:38 -0600257 .gpio = 8, /* GSBI3 QUP SPI_CLK */
258 .settings = {
259 [GPIOMUX_SUSPENDED] = &gsbi3,
260 },
261 },
262 {
263 .gpio = 9, /* GSBI3 QUP SPI_CS_N */
264 .settings = {
265 [GPIOMUX_SUSPENDED] = &gsbi3,
266 },
267 },
268 {
269 .gpio = 10, /* GSBI3 QUP SPI_DATA_MISO */
270 .settings = {
271 [GPIOMUX_SUSPENDED] = &gsbi3,
272 },
273 },
274 {
275 .gpio = 11, /* GSBI3 QUP SPI_DATA_MOSI */
276 .settings = {
277 [GPIOMUX_SUSPENDED] = &gsbi3,
278 },
279 },
280 {
Rohit Vaswani09666872011-08-23 17:41:54 -0700281 .gpio = 12, /* GSBI4 UART */
282 .settings = {
283 [GPIOMUX_SUSPENDED] = &gsbi4,
284 },
285 },
286 {
287 .gpio = 13, /* GSBI4 UART */
288 .settings = {
289 [GPIOMUX_SUSPENDED] = &gsbi4,
290 },
291 },
292 {
293 .gpio = 14, /* GSBI4 UART */
294 .settings = {
295 [GPIOMUX_SUSPENDED] = &gsbi4,
296 },
297 },
298 {
299 .gpio = 15, /* GSBI4 UART */
300 .settings = {
301 [GPIOMUX_SUSPENDED] = &gsbi4,
302 },
303 },
Harini Jayaramaneba52672011-09-08 15:13:00 -0600304 {
305 .gpio = 16, /* GSBI5 I2C QUP SCL */
306 .settings = {
307 [GPIOMUX_SUSPENDED] = &gsbi5,
308 },
309 },
310 {
311 .gpio = 17, /* GSBI5 I2C QUP SDA */
312 .settings = {
313 [GPIOMUX_SUSPENDED] = &gsbi5,
314 },
315 },
Harini Jayaraman738c9312011-09-08 15:22:38 -0600316 {
317 /* GPIO 19 can be used for I2C/UART on GSBI5 */
318 .gpio = 19, /* GSBI3 QUP SPI_CS_1 */
319 .settings = {
320 [GPIOMUX_SUSPENDED] = &gsbi3_cs1_config,
321 },
322 },
Rohit Vaswani09666872011-08-23 17:41:54 -0700323};
324
Krishna Kondadd794462011-10-01 00:19:29 -0700325#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
326 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT))
327
Krishna Konda7186bfe2011-10-17 15:36:54 -0700328#define GPIO_SDC1_HW_DET 80
Krishna Konda3b78ea72011-10-18 16:09:19 -0700329#define GPIO_SDC2_DAT1_WAKEUP 26
Krishna Kondadd794462011-10-01 00:19:29 -0700330
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -0700331/* MDM9x15 has 2 SDCC controllers */
Krishna Kondadd794462011-10-01 00:19:29 -0700332enum sdcc_controllers {
333 SDCC1,
334 SDCC2,
335 MAX_SDCC_CONTROLLER
336};
337
338#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Krishna Kondafea60182011-11-01 16:01:34 -0700339/* All SDCC controllers requires VDD/VCC voltage */
340static struct msm_mmc_reg_data mmc_vdd_reg_data[MAX_SDCC_CONTROLLER] = {
341 /* SDCC1 : External card slot connected */
342 [SDCC1] = {
343 .name = "sdc_vdd",
344 /*
345 * This is a gpio-regulator and does not support
346 * regulator_set_voltage and regulator_set_optimum_mode
347 */
Krishna Kondafea60182011-11-01 16:01:34 -0700348 .high_vol_level = 2950000,
349 .low_vol_level = 2950000,
350 .hpm_uA = 600000, /* 600mA */
351 }
352};
353
354/* All SDCC controllers may require voting for VDD PAD voltage */
355static struct msm_mmc_reg_data mmc_vddp_reg_data[MAX_SDCC_CONTROLLER] = {
356 /* SDCC1 : External card slot connected */
357 [SDCC1] = {
358 .name = "sdc_vddp",
Krishna Kondafea60182011-11-01 16:01:34 -0700359 .high_vol_level = 2950000,
360 .low_vol_level = 1850000,
361 .always_on = true,
362 .lpm_sup = true,
363 /* Max. Active current required is 16 mA */
364 .hpm_uA = 16000,
365 /*
366 * Sleep current required is ~300 uA. But min. vote can be
367 * in terms of mA (min. 1 mA). So let's vote for 2 mA
368 * during sleep.
369 */
370 .lpm_uA = 2000,
371 }
372};
373
374static struct msm_mmc_slot_reg_data mmc_slot_vreg_data[MAX_SDCC_CONTROLLER] = {
375 /* SDCC1 : External card slot connected */
376 [SDCC1] = {
377 .vdd_data = &mmc_vdd_reg_data[SDCC1],
378 .vddp_data = &mmc_vddp_reg_data[SDCC1],
379 }
380};
381
Krishna Kondadd794462011-10-01 00:19:29 -0700382/* SDC1 pad data */
383static struct msm_mmc_pad_drv sdc1_pad_drv_on_cfg[] = {
384 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_16MA},
385 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_10MA},
386 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_10MA}
387};
388
389static struct msm_mmc_pad_drv sdc1_pad_drv_off_cfg[] = {
390 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_2MA},
391 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_2MA},
392 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_2MA}
393};
394
395static struct msm_mmc_pad_pull sdc1_pad_pull_on_cfg[] = {
396 {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL},
397 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_UP},
398 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_UP}
399};
400
401static struct msm_mmc_pad_pull sdc1_pad_pull_off_cfg[] = {
402 {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL},
403 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_DOWN},
404 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_DOWN}
405};
406
407static struct msm_mmc_pad_pull_data mmc_pad_pull_data[MAX_SDCC_CONTROLLER] = {
408 [SDCC1] = {
409 .on = sdc1_pad_pull_on_cfg,
410 .off = sdc1_pad_pull_off_cfg,
411 .size = ARRAY_SIZE(sdc1_pad_pull_on_cfg)
412 },
413};
414
415static struct msm_mmc_pad_drv_data mmc_pad_drv_data[MAX_SDCC_CONTROLLER] = {
416 [SDCC1] = {
417 .on = sdc1_pad_drv_on_cfg,
418 .off = sdc1_pad_drv_off_cfg,
419 .size = ARRAY_SIZE(sdc1_pad_drv_on_cfg)
420 },
421};
422
423static struct msm_mmc_pad_data mmc_pad_data[MAX_SDCC_CONTROLLER] = {
424 [SDCC1] = {
425 .pull = &mmc_pad_pull_data[SDCC1],
426 .drv = &mmc_pad_drv_data[SDCC1]
427 },
428};
429#endif
430
Krishna Konda71aef182011-10-01 02:27:51 -0700431#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
432static struct gpiomux_setting sdcc2_clk_actv_cfg = {
433 .func = GPIOMUX_FUNC_1,
434 .drv = GPIOMUX_DRV_16MA,
435 .pull = GPIOMUX_PULL_NONE,
436};
437
438static struct gpiomux_setting sdcc2_cmd_data_0_3_actv_cfg = {
439 .func = GPIOMUX_FUNC_1,
440 .drv = GPIOMUX_DRV_8MA,
441 .pull = GPIOMUX_PULL_UP,
442};
443
444static struct gpiomux_setting sdcc2_suspend_cfg = {
445 .func = GPIOMUX_FUNC_1,
446 .drv = GPIOMUX_DRV_2MA,
447 .pull = GPIOMUX_PULL_DOWN,
448};
449
450static struct msm_gpiomux_config msm9615_sdcc2_configs[] __initdata = {
451 {
452 /* SDC2_DATA_0 */
453 .gpio = 25,
454 .settings = {
455 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
456 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
457 },
458 },
459 {
460 /* SDC2_DATA_1 */
461 .gpio = 26,
462 .settings = {
463 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
Krishna Konda0b10fa12011-11-07 22:47:41 -0800464 [GPIOMUX_SUSPENDED] = &sdcc2_cmd_data_0_3_actv_cfg,
Krishna Konda71aef182011-10-01 02:27:51 -0700465 },
466 },
467 {
468 /* SDC2_DATA_2 */
469 .gpio = 27,
470 .settings = {
471 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
472 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
473 },
474 },
475 {
476 /* SDC2_DATA_3 */
477 .gpio = 28,
478 .settings = {
479 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
480 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
481 },
482 },
483 {
Krishna Konda0b10fa12011-11-07 22:47:41 -0800484 /* SDC2_CMD */
Krishna Konda71aef182011-10-01 02:27:51 -0700485 .gpio = 29,
486 .settings = {
487 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
488 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
489 },
490 },
491 {
Krishna Konda0b10fa12011-11-07 22:47:41 -0800492 /* SDC2_CLK */
Krishna Konda71aef182011-10-01 02:27:51 -0700493 .gpio = 30,
494 .settings = {
495 [GPIOMUX_ACTIVE] = &sdcc2_clk_actv_cfg,
496 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
497 },
498 },
499};
500
501static struct msm_mmc_gpio sdc2_gpio_cfg[] = {
502 {25, "sdc2_dat_0"},
503 {26, "sdc2_dat_1"},
504 {27, "sdc2_dat_2"},
505 {28, "sdc2_dat_3"},
506 {29, "sdc2_cmd"},
507 {30, "sdc2_clk"},
508};
509
510static struct msm_mmc_gpio_data mmc_gpio_data[MAX_SDCC_CONTROLLER] = {
511 [SDCC2] = {
512 .gpio = sdc2_gpio_cfg,
513 .size = ARRAY_SIZE(sdc2_gpio_cfg),
514 },
515};
516#else
517static struct msm_gpiomux_config msm9615_sdcc2_configs[0];
518#endif
519
520static struct msm_mmc_pin_data mmc_slot_pin_data[MAX_SDCC_CONTROLLER] = {
Krishna Kondadd794462011-10-01 00:19:29 -0700521#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
522 [SDCC1] = {
523 .is_gpio = 0,
524 .pad_data = &mmc_pad_data[SDCC1],
525 },
526#endif
Krishna Konda71aef182011-10-01 02:27:51 -0700527#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
528 [SDCC2] = {
529 .is_gpio = 1,
530 .gpio_data = &mmc_gpio_data[SDCC2],
531 },
532#endif
Krishna Kondadd794462011-10-01 00:19:29 -0700533};
534
535#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
536static unsigned int sdc1_sup_clk_rates[] = {
537 400000, 24000000, 48000000
538};
539
540static struct mmc_platform_data sdc1_data = {
541 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
542 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
543 .sup_clk_table = sdc1_sup_clk_rates,
544 .sup_clk_cnt = ARRAY_SIZE(sdc1_sup_clk_rates),
Krishna Kondafea60182011-11-01 16:01:34 -0700545 .pclk_src_dfab = true,
Krishna Kondafea60182011-11-01 16:01:34 -0700546 .vreg_data = &mmc_slot_vreg_data[SDCC1],
Krishna Kondadd794462011-10-01 00:19:29 -0700547 .pin_data = &mmc_slot_pin_data[SDCC1],
Krishna Konda7186bfe2011-10-17 15:36:54 -0700548#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
549 .status_gpio = GPIO_SDC1_HW_DET,
550 .status_irq = MSM_GPIO_TO_INT(GPIO_SDC1_HW_DET),
551 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
552#endif
Krishna Kondadbcf9702011-11-07 18:45:48 -0800553 .xpc_cap = 1,
554 .uhs_caps = (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 |
555 MMC_CAP_MAX_CURRENT_400)
Krishna Kondadd794462011-10-01 00:19:29 -0700556};
557static struct mmc_platform_data *msm9615_sdc1_pdata = &sdc1_data;
558#else
559static struct mmc_platform_data *msm9615_sdc1_pdata;
560#endif
561
Krishna Konda71aef182011-10-01 02:27:51 -0700562#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
563static unsigned int sdc2_sup_clk_rates[] = {
564 400000, 24000000, 48000000
565};
566
567static struct mmc_platform_data sdc2_data = {
568 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
569 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
570 .sup_clk_table = sdc2_sup_clk_rates,
571 .sup_clk_cnt = ARRAY_SIZE(sdc2_sup_clk_rates),
Krishna Konda890b1d12011-10-18 16:05:37 -0700572 .pclk_src_dfab = 1,
Krishna Konda71aef182011-10-01 02:27:51 -0700573 .pin_data = &mmc_slot_pin_data[SDCC2],
Krishna Konda3b78ea72011-10-18 16:09:19 -0700574#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
575 .sdiowakeup_irq = MSM_GPIO_TO_INT(GPIO_SDC2_DAT1_WAKEUP),
576#endif
Krishna Konda71aef182011-10-01 02:27:51 -0700577};
578static struct mmc_platform_data *msm9615_sdc2_pdata = &sdc2_data;
579#else
580static struct mmc_platform_data *msm9615_sdc2_pdata;
581#endif
582
Krishna Kondadd794462011-10-01 00:19:29 -0700583static void __init msm9615_init_mmc(void)
584{
Krishna Kondadd794462011-10-01 00:19:29 -0700585 if (msm9615_sdc1_pdata) {
Krishna Kondafea60182011-11-01 16:01:34 -0700586 /* SDC1: External card slot for SD/MMC cards */
587 msm_add_sdcc(1, msm9615_sdc1_pdata);
Krishna Kondadd794462011-10-01 00:19:29 -0700588 }
Krishna Konda71aef182011-10-01 02:27:51 -0700589
590 if (msm9615_sdc2_pdata) {
591 msm_gpiomux_install(msm9615_sdcc2_configs,
592 ARRAY_SIZE(msm9615_sdcc2_configs));
593
Krishna Kondafea60182011-11-01 16:01:34 -0700594 /* SDC2: External card slot used for WLAN */
Krishna Konda71aef182011-10-01 02:27:51 -0700595 msm_add_sdcc(2, msm9615_sdc2_pdata);
596 }
Krishna Kondadd794462011-10-01 00:19:29 -0700597}
598#else
599static void __init msm9615_init_mmc(void) { }
600#endif
Maheshkumar Sivasubramanian4923db22011-09-15 09:28:15 -0600601static struct msm_cpuidle_state msm_cstates[] __initdata = {
602 {0, 0, "C0", "WFI",
603 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
604
605 {0, 1, "C1", "STANDALONE_POWER_COLLAPSE",
606 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
607
608 {0, 2, "C2", "POWER_COLLAPSE",
609 MSM_PM_SLEEP_MODE_POWER_COLLAPSE},
610};
611static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
612 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
613 .idle_supported = 1,
614 .suspend_supported = 1,
615 .idle_enabled = 0,
616 .suspend_enabled = 0,
617 },
618 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
619 .idle_supported = 1,
620 .suspend_supported = 1,
621 .idle_enabled = 0,
622 .suspend_enabled = 0,
623 },
624 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
625 .idle_supported = 1,
626 .suspend_supported = 1,
627 .idle_enabled = 1,
628 .suspend_enabled = 1,
629 },
630};
Krishna Kondadd794462011-10-01 00:19:29 -0700631
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600632static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
633 .mode = MSM_PM_BOOT_CONFIG_REMAP_BOOT_ADDR,
634 .v_addr = MSM_APCS_GLB_BASE + 0x24,
635};
636
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700637static int __init gpiomux_init(void)
638{
639 int rc;
640
641 rc = msm_gpiomux_init(NR_GPIO_IRQS);
642 if (rc) {
643 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
644 return rc;
645 }
Rohit Vaswani09666872011-08-23 17:41:54 -0700646 msm_gpiomux_install(msm9615_gsbi_configs,
647 ARRAY_SIZE(msm9615_gsbi_configs));
648
Rohit Vaswanif688fa62011-10-13 18:13:10 -0700649 msm_gpiomux_install(msm9615_ps_hold_config,
650 ARRAY_SIZE(msm9615_ps_hold_config));
Jay Chokshidc8028b2011-12-01 16:17:34 -0800651#ifdef CONFIG_LTC4088_CHARGER
652 msm_gpiomux_install(msm9615_ltc4088_charger_config,
653 ARRAY_SIZE(msm9615_ltc4088_charger_config));
654#endif
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700655 return 0;
656}
657
Gagan Mac7a827642011-09-22 19:42:21 -0600658static void __init msm9615_init_buses(void)
659{
660#ifdef CONFIG_MSM_BUS_SCALING
661 msm_bus_rpm_set_mt_mask();
662 msm_bus_9615_sys_fabric_pdata.rpm_enabled = 1;
663 msm_bus_9615_sys_fabric.dev.platform_data =
664 &msm_bus_9615_sys_fabric_pdata;
665 msm_bus_def_fab.dev.platform_data = &msm_bus_9615_def_fab_pdata;
666#endif
667}
668
Harini Jayaraman738c9312011-09-08 15:22:38 -0600669static struct msm_spi_platform_data msm9615_qup_spi_gsbi3_pdata = {
670 .max_clock_speed = 24000000,
671};
672
Harini Jayaramaneba52672011-09-08 15:13:00 -0600673static struct msm_i2c_platform_data msm9615_i2c_qup_gsbi5_pdata = {
674 .clk_freq = 100000,
675 .src_clk_rate = 24000000,
676};
677
Amit Blay6a8d4f32011-11-21 10:36:25 +0200678#define USB_5V_EN 3
679#define PM_USB_5V_EN PM8018_GPIO_PM_TO_SYS(USB_5V_EN)
680
681static void msm_hsusb_vbus_power(bool on)
682{
683 int rc;
684 static bool vbus_is_on;
685 struct pm_gpio usb_vbus = {
686 .direction = PM_GPIO_DIR_OUT,
687 .pull = PM_GPIO_PULL_NO,
688 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
689 .output_value = 0,
690 .vin_sel = 2,
691 .out_strength = PM_GPIO_STRENGTH_HIGH,
692 .function = PM_GPIO_FUNC_NORMAL,
693 .inv_int_pol = 0,
694 };
695
696 if (vbus_is_on == on)
697 return;
698
699 if (on) {
700 rc = pm8xxx_gpio_config(PM_USB_5V_EN, &usb_vbus);
701 if (rc) {
702 pr_err("failed to config usb_5v_en gpio\n");
703 return;
704 }
705
706 rc = gpio_request(PM_USB_5V_EN,
707 "usb_5v_en");
708 if (rc < 0) {
709 pr_err("failed to request usb_5v_en gpio\n");
710 return;
711 }
712
713 rc = gpio_direction_output(PM_USB_5V_EN, 1);
714 if (rc) {
715 pr_err("%s: unable to set_direction for gpio [%d]\n",
716 __func__, PM_USB_5V_EN);
717 goto free_usb_5v_en;
718 }
719
720 vbus_is_on = true;
721 return;
722 }
723 gpio_set_value(PM_USB_5V_EN, 0);
724free_usb_5v_en:
725 gpio_free(PM_USB_5V_EN);
726 vbus_is_on = false;
727}
728
Anji jonnalaa8b8d732011-12-06 10:03:24 +0530729static int shelby_phy_init_seq[] = {
730 0x44, 0x80,/* set VBUS valid threshold and
731 disconnect valid threshold */
732 0x38, 0x81, /* update DC voltage level */
733 0x14, 0x82,/* set preemphasis and rise/fall time */
734 0x13, 0x83,/* set source impedance adjustment */
735 -1};
736
Ofir Cohen40a4e862011-12-08 15:17:52 +0200737#define USB_BAM_PHY_BASE 0x12502000
738#define USB_BAM_PHY_SIZE 0x10000
739#define A2_BAM_PHY_BASE 0x124C2000
740static struct usb_bam_pipe_connect msm_usb_bam_connections[4][2] = {
741 [0][USB_TO_PEER_PERIPHERAL] = {
742 .src_phy_addr = USB_BAM_PHY_BASE,
743 .src_pipe_index = 11,
744 .dst_phy_addr = A2_BAM_PHY_BASE,
745 .dst_pipe_index = 0,
Ofir Cohen29cd5752011-12-14 17:20:30 +0200746 .data_fifo_base_offset = 0x1100,
747 .data_fifo_size = 0x600,
748 .desc_fifo_base_offset = 0x1700,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200749 .desc_fifo_size = 0x300,
750 },
751 [0][PEER_PERIPHERAL_TO_USB] = {
752 .src_phy_addr = A2_BAM_PHY_BASE,
753 .src_pipe_index = 1,
754 .dst_phy_addr = USB_BAM_PHY_BASE,
755 .dst_pipe_index = 10,
756 .data_fifo_base_offset = 0xa00,
Ofir Cohen29cd5752011-12-14 17:20:30 +0200757 .data_fifo_size = 0x600,
758 .desc_fifo_base_offset = 0x1000,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200759 .desc_fifo_size = 0x100,
760 },
761};
762
763static struct msm_usb_bam_platform_data msm_usb_bam_pdata = {
764 .connections = &msm_usb_bam_connections[0][0],
765 .usb_bam_phy_base = USB_BAM_PHY_BASE,
766 .usb_bam_phy_size = USB_BAM_PHY_SIZE,
767 .usb_bam_num_pipes = 32,
768};
769
Amit Blay5e4ec192011-10-20 09:16:54 +0200770static struct msm_otg_platform_data msm_otg_pdata = {
Amit Blay6a8d4f32011-11-21 10:36:25 +0200771 .mode = USB_OTG,
772 .otg_control = OTG_PHY_CONTROL,
Amit Blay5e4ec192011-10-20 09:16:54 +0200773 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200774 .pclk_src_name = "dfab_usb_hs_clk",
775 .vbus_power = msm_hsusb_vbus_power,
Amit Blay5e4ec192011-10-20 09:16:54 +0200776};
777
778static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
779{
780 return 0;
781}
782
783static struct android_usb_platform_data android_usb_pdata = {
784 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
785};
786
787static struct platform_device android_usb_device = {
788 .name = "android_usb",
789 .id = -1,
790 .dev = {
791 .platform_data = &android_usb_pdata,
792 },
793};
794
Rohit Vaswani149f0a72011-11-09 15:21:28 -0800795static struct platform_device msm_wlan_ar6000_pm_device = {
796 .name = "wlan_ar6000_pm_dev",
797 .id = -1,
798};
799
800static int __init msm9615_init_ar6000pm(void)
801{
802 return platform_device_register(&msm_wlan_ar6000_pm_device);
803}
804
Jay Chokshidc8028b2011-12-01 16:17:34 -0800805#ifdef CONFIG_LTC4088_CHARGER
806static struct platform_device msm_device_charger = {
807 .name = LTC4088_CHARGER_DEV_NAME,
808 .id = -1,
809 .dev = {
810 .platform_data = &ltc4088_chg_pdata,
811 },
812};
813#endif
814
Amit Blay5e4ec192011-10-20 09:16:54 +0200815static struct platform_device *common_devices[] = {
816 &msm9615_device_dmov,
817 &msm_device_smd,
Jay Chokshidc8028b2011-12-01 16:17:34 -0800818#ifdef CONFIG_LTC4088_CHARGER
819 &msm_device_charger,
820#endif
Amit Blay5e4ec192011-10-20 09:16:54 +0200821 &msm_device_otg,
822 &msm_device_gadget_peripheral,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200823 &msm_device_hsusb_host,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200824 &msm_device_usb_bam,
Amit Blay5e4ec192011-10-20 09:16:54 +0200825 &android_usb_device,
826 &msm9615_device_uart_gsbi4,
David Collins0f9942a2011-10-31 09:47:34 -0700827 &msm9615_device_ext_2p95v_vreg,
Amit Blay5e4ec192011-10-20 09:16:54 +0200828 &msm9615_device_ssbi_pmic1,
829 &msm9615_device_qup_i2c_gsbi5,
830 &msm9615_device_qup_spi_gsbi3,
831 &msm_device_sps,
832 &msm9615_device_tsens,
833 &msm_device_nand,
Eric Holmberg0c96e702011-11-08 18:04:31 -0700834 &msm_device_bam_dmux,
Amit Blay5e4ec192011-10-20 09:16:54 +0200835 &msm_rpm_device,
836#ifdef CONFIG_HW_RANDOM_MSM
837 &msm_device_rng,
838#endif
839
840#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
841 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
Ramesh Masavarapuaa28b5b2011-10-21 10:26:03 -0700842 &msm9615_qcrypto_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200843#endif
844
845#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
846 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
Ramesh Masavarapuaa28b5b2011-10-21 10:26:03 -0700847 &msm9615_qcedev_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200848#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700849 &msm9615_device_watchdog,
Gagan Mac7a827642011-09-22 19:42:21 -0600850 &msm_bus_9615_sys_fabric,
851 &msm_bus_def_fab,
Amit Blay5e4ec192011-10-20 09:16:54 +0200852};
853
Harini Jayaramaneba52672011-09-08 15:13:00 -0600854static void __init msm9615_i2c_init(void)
855{
856 msm9615_device_qup_i2c_gsbi5.dev.platform_data =
857 &msm9615_i2c_qup_gsbi5_pdata;
858}
859
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600860static void __init msm9615_reserve(void)
861{
862 msm_pm_boot_pdata.p_addr = memblock_alloc(SZ_8, SZ_64K);
863}
864
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700865static void __init msm9615_common_init(void)
866{
867 msm9615_device_init();
868 gpiomux_init();
Harini Jayaramaneba52672011-09-08 15:13:00 -0600869 msm9615_i2c_init();
David Collins00b31e62011-08-31 20:00:10 -0700870 regulator_suppress_info_printing();
David Collinsbea297a2011-09-28 13:11:14 -0700871 platform_device_register(&msm9615_device_rpm_regulator);
Gagan Mac7a827642011-09-22 19:42:21 -0600872 msm_clock_init(&msm9615_clock_init_data);
873 msm9615_init_buses();
Harini Jayaraman738c9312011-09-08 15:22:38 -0600874 msm9615_device_qup_spi_gsbi3.dev.platform_data =
875 &msm9615_qup_spi_gsbi3_pdata;
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700876 msm9615_device_ssbi_pmic1.dev.platform_data =
877 &msm9615_ssbi_pm8018_pdata;
David Collins00b31e62011-08-31 20:00:10 -0700878 pm8018_platform_data.num_regulators = msm_pm8018_regulator_pdata_len;
Amit Blay5e4ec192011-10-20 09:16:54 +0200879
880 msm_device_otg.dev.platform_data = &msm_otg_pdata;
Anji jonnalaa8b8d732011-12-06 10:03:24 +0530881 msm_otg_pdata.phy_init_seq = shelby_phy_init_seq;
Ofir Cohen40a4e862011-12-08 15:17:52 +0200882 msm_device_usb_bam.dev.platform_data = &msm_usb_bam_pdata;
Rohit Vaswani09666872011-08-23 17:41:54 -0700883 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Krishna Kondadd794462011-10-01 00:19:29 -0700884
Vikram Mulukutlab5e1cda2011-10-04 16:17:22 -0700885 acpuclk_init(&acpuclk_9615_soc_data);
886
Rohit Vaswani149f0a72011-11-09 15:21:28 -0800887 /* Ensure ar6000pm device is registered before MMC/SDC */
888 msm9615_init_ar6000pm();
889
Krishna Kondadd794462011-10-01 00:19:29 -0700890 msm9615_init_mmc();
Maheshkumar Sivasubramanian4923db22011-09-15 09:28:15 -0600891 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
892 msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ);
893 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
894 msm_pm_data);
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600895 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700896}
897
898static void __init msm9615_cdp_init(void)
899{
900 msm9615_common_init();
901}
902
903static void __init msm9615_mtp_init(void)
904{
905 msm9615_common_init();
906}
907
908MACHINE_START(MSM9615_CDP, "QCT MSM9615 CDP")
909 .map_io = msm9615_map_io,
910 .init_irq = msm9615_init_irq,
911 .timer = &msm_timer,
912 .init_machine = msm9615_cdp_init,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600913 .reserve = msm9615_reserve,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700914MACHINE_END
915
916MACHINE_START(MSM9615_MTP, "QCT MSM9615 MTP")
917 .map_io = msm9615_map_io,
918 .init_irq = msm9615_init_irq,
919 .timer = &msm_timer,
920 .init_machine = msm9615_mtp_init,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600921 .reserve = msm9615_reserve,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700922MACHINE_END