blob: 701464a8c06c9a70e60eae496cc8b72dec8f4430 [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>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070030#include "timer.h"
31#include "devices.h"
David Collinsfb88c432011-08-25 15:12:47 -070032#include "board-9615.h"
Maheshkumar Sivasubramanian4923db22011-09-15 09:28:15 -060033#include "cpuidle.h"
34#include "pm.h"
Vikram Mulukutlab5e1cda2011-10-04 16:17:22 -070035#include "acpuclock.h"
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070036
Siddartha Mohanadoss5f60b452011-10-05 11:49:00 -070037static struct pm8xxx_adc_amux pm8018_adc_channels_data[] = {
38 {"vcoin", CHANNEL_VCOIN, CHAN_PATH_SCALING2, AMUX_RSV1,
39 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
40 {"vbat", CHANNEL_VBAT, CHAN_PATH_SCALING2, AMUX_RSV1,
41 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
42 {"vph_pwr", CHANNEL_VPH_PWR, CHAN_PATH_SCALING2, AMUX_RSV1,
43 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
44 {"batt_therm", CHANNEL_BATT_THERM, CHAN_PATH_SCALING1, AMUX_RSV2,
45 ADC_DECIMATION_TYPE2, ADC_SCALE_BATT_THERM},
46 {"batt_id", CHANNEL_BATT_ID, CHAN_PATH_SCALING1, AMUX_RSV2,
47 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
48 {"pmic_therm", CHANNEL_DIE_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
49 ADC_DECIMATION_TYPE2, ADC_SCALE_PMIC_THERM},
50 {"625mv", CHANNEL_625MV, CHAN_PATH_SCALING1, AMUX_RSV1,
51 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
52 {"125v", CHANNEL_125V, CHAN_PATH_SCALING1, AMUX_RSV1,
53 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
54 {"pa_therm0", ADC_MPP_1_AMUX3, CHAN_PATH_SCALING1, AMUX_RSV1,
55 ADC_DECIMATION_TYPE2, ADC_SCALE_PA_THERM},
56};
57
58static struct pm8xxx_adc_properties pm8018_adc_data = {
59 .adc_vdd_reference = 1800, /* milli-voltage for this adc */
60 .bitresolution = 15,
61 .bipolar = 0,
62};
63
64static struct pm8xxx_adc_platform_data pm8018_adc_pdata = {
65 .adc_channel = pm8018_adc_channels_data,
66 .adc_num_board_channel = ARRAY_SIZE(pm8018_adc_channels_data),
67 .adc_prop = &pm8018_adc_data,
68};
69
David Collinsfb88c432011-08-25 15:12:47 -070070static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata __devinitdata = {
71 .irq_base = PM8018_IRQ_BASE,
72 .devirq = MSM_GPIO_TO_INT(87),
73 .irq_trigger_flag = IRQF_TRIGGER_LOW,
74};
75
76static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata __devinitdata = {
77 .gpio_base = PM8018_GPIO_PM_TO_SYS(1),
78};
79
80static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata __devinitdata = {
81 .mpp_base = PM8018_MPP_PM_TO_SYS(1),
82};
83
84static struct pm8xxx_rtc_platform_data pm8xxx_rtc_pdata __devinitdata = {
85 .rtc_write_enable = false,
Ashay Jaiswaldb5e6dc2011-10-12 11:02:47 +053086 .rtc_alarm_powerup = false,
David Collinsfb88c432011-08-25 15:12:47 -070087};
88
89static struct pm8xxx_pwrkey_platform_data pm8xxx_pwrkey_pdata = {
90 .pull_up = 1,
91 .kpd_trigger_delay_us = 970,
92 .wakeup = 1,
93};
94
95static struct pm8xxx_misc_platform_data pm8xxx_misc_pdata = {
96 .priority = 0,
97};
98
Jay Chokshieb5d0d52011-09-28 17:16:20 -070099#define PM8018_LED_KB_MAX_CURRENT 20 /* I = 20mA */
100#define PM8XXX_LED_PWM_PERIOD_US 1000
101
102/**
103 * PM8XXX_PWM_CHANNEL_NONE shall be used when LED shall not be
104 * driven using PWM feature.
105 */
106#define PM8XXX_PWM_CHANNEL_NONE -1
107
108static struct led_info pm8018_led_info[] = {
109 [0] = {
110 .name = "led:kb",
111 },
112};
113
114static struct led_platform_data pm8018_led_core_pdata = {
115 .num_leds = ARRAY_SIZE(pm8018_led_info),
116 .leds = pm8018_led_info,
117};
118
119static struct pm8xxx_led_config pm8018_led_configs[] = {
120 [0] = {
121 .id = PM8XXX_ID_LED_KB_LIGHT,
122 .mode = PM8XXX_LED_MODE_PWM3,
123 .max_current = PM8018_LED_KB_MAX_CURRENT,
124 .pwm_channel = 2,
125 .pwm_period_us = PM8XXX_LED_PWM_PERIOD_US,
126 },
127};
128
129static struct pm8xxx_led_platform_data pm8xxx_leds_pdata = {
130 .led_core = &pm8018_led_core_pdata,
131 .configs = pm8018_led_configs,
132 .num_configs = ARRAY_SIZE(pm8018_led_configs),
133};
134
David Collinsfb88c432011-08-25 15:12:47 -0700135static struct pm8018_platform_data pm8018_platform_data __devinitdata = {
136 .irq_pdata = &pm8xxx_irq_pdata,
137 .gpio_pdata = &pm8xxx_gpio_pdata,
138 .mpp_pdata = &pm8xxx_mpp_pdata,
139 .rtc_pdata = &pm8xxx_rtc_pdata,
140 .pwrkey_pdata = &pm8xxx_pwrkey_pdata,
141 .misc_pdata = &pm8xxx_misc_pdata,
David Collins00b31e62011-08-31 20:00:10 -0700142 .regulator_pdatas = msm_pm8018_regulator_pdata,
Siddartha Mohanadoss5f60b452011-10-05 11:49:00 -0700143 .adc_pdata = &pm8018_adc_pdata,
Jay Chokshieb5d0d52011-09-28 17:16:20 -0700144 .leds_pdata = &pm8xxx_leds_pdata,
David Collinsfb88c432011-08-25 15:12:47 -0700145};
146
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700147static struct msm_ssbi_platform_data msm9615_ssbi_pm8018_pdata __devinitdata = {
148 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
149 .slave = {
David Collinsfb88c432011-08-25 15:12:47 -0700150 .name = PM8018_CORE_DEV_NAME,
151 .platform_data = &pm8018_platform_data,
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700152 },
153};
154
David Collinsbea297a2011-09-28 13:11:14 -0700155static struct platform_device msm9615_device_rpm_regulator __devinitdata = {
156 .name = "rpm-regulator",
157 .id = -1,
158 .dev = {
159 .platform_data = &msm_rpm_regulator_9615_pdata,
160 },
161};
162
David Collins0f9942a2011-10-31 09:47:34 -0700163static struct platform_device msm9615_device_ext_2p95v_vreg = {
164 .name = GPIO_REGULATOR_DEV_NAME,
165 .id = 18,
166 .dev = {
167 .platform_data =
168 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_2P95V],
169 },
170};
171
Rohit Vaswanif688fa62011-10-13 18:13:10 -0700172static struct gpiomux_setting ps_hold = {
173 .func = GPIOMUX_FUNC_1,
174 .drv = GPIOMUX_DRV_8MA,
175 .pull = GPIOMUX_PULL_NONE,
176};
177
Rohit Vaswani09666872011-08-23 17:41:54 -0700178static struct gpiomux_setting gsbi4 = {
179 .func = GPIOMUX_FUNC_1,
180 .drv = GPIOMUX_DRV_8MA,
181 .pull = GPIOMUX_PULL_NONE,
182};
183
Harini Jayaramaneba52672011-09-08 15:13:00 -0600184static struct gpiomux_setting gsbi5 = {
185 .func = GPIOMUX_FUNC_1,
186 .drv = GPIOMUX_DRV_8MA,
187 .pull = GPIOMUX_PULL_NONE,
188};
189
Harini Jayaraman738c9312011-09-08 15:22:38 -0600190static struct gpiomux_setting gsbi3 = {
191 .func = GPIOMUX_FUNC_1,
192 .drv = GPIOMUX_DRV_8MA,
193 .pull = GPIOMUX_PULL_NONE,
194};
195
196static struct gpiomux_setting gsbi3_cs1_config = {
197 .func = GPIOMUX_FUNC_4,
198 .drv = GPIOMUX_DRV_8MA,
199 .pull = GPIOMUX_PULL_NONE,
200};
201
Rohit Vaswanif688fa62011-10-13 18:13:10 -0700202struct msm_gpiomux_config msm9615_ps_hold_config[] __initdata = {
203 {
204 .gpio = 83,
205 .settings = {
206 [GPIOMUX_SUSPENDED] = &ps_hold,
207 },
208 },
209};
210
Rohit Vaswani09666872011-08-23 17:41:54 -0700211struct msm_gpiomux_config msm9615_gsbi_configs[] __initdata = {
212 {
Harini Jayaraman738c9312011-09-08 15:22:38 -0600213 .gpio = 8, /* GSBI3 QUP SPI_CLK */
214 .settings = {
215 [GPIOMUX_SUSPENDED] = &gsbi3,
216 },
217 },
218 {
219 .gpio = 9, /* GSBI3 QUP SPI_CS_N */
220 .settings = {
221 [GPIOMUX_SUSPENDED] = &gsbi3,
222 },
223 },
224 {
225 .gpio = 10, /* GSBI3 QUP SPI_DATA_MISO */
226 .settings = {
227 [GPIOMUX_SUSPENDED] = &gsbi3,
228 },
229 },
230 {
231 .gpio = 11, /* GSBI3 QUP SPI_DATA_MOSI */
232 .settings = {
233 [GPIOMUX_SUSPENDED] = &gsbi3,
234 },
235 },
236 {
Rohit Vaswani09666872011-08-23 17:41:54 -0700237 .gpio = 12, /* GSBI4 UART */
238 .settings = {
239 [GPIOMUX_SUSPENDED] = &gsbi4,
240 },
241 },
242 {
243 .gpio = 13, /* GSBI4 UART */
244 .settings = {
245 [GPIOMUX_SUSPENDED] = &gsbi4,
246 },
247 },
248 {
249 .gpio = 14, /* GSBI4 UART */
250 .settings = {
251 [GPIOMUX_SUSPENDED] = &gsbi4,
252 },
253 },
254 {
255 .gpio = 15, /* GSBI4 UART */
256 .settings = {
257 [GPIOMUX_SUSPENDED] = &gsbi4,
258 },
259 },
Harini Jayaramaneba52672011-09-08 15:13:00 -0600260 {
261 .gpio = 16, /* GSBI5 I2C QUP SCL */
262 .settings = {
263 [GPIOMUX_SUSPENDED] = &gsbi5,
264 },
265 },
266 {
267 .gpio = 17, /* GSBI5 I2C QUP SDA */
268 .settings = {
269 [GPIOMUX_SUSPENDED] = &gsbi5,
270 },
271 },
Harini Jayaraman738c9312011-09-08 15:22:38 -0600272 {
273 /* GPIO 19 can be used for I2C/UART on GSBI5 */
274 .gpio = 19, /* GSBI3 QUP SPI_CS_1 */
275 .settings = {
276 [GPIOMUX_SUSPENDED] = &gsbi3_cs1_config,
277 },
278 },
Rohit Vaswani09666872011-08-23 17:41:54 -0700279};
280
Krishna Kondadd794462011-10-01 00:19:29 -0700281#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
282 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT))
283
Krishna Konda7186bfe2011-10-17 15:36:54 -0700284#define GPIO_SDCARD_PWR_EN 18
285#define GPIO_SDC1_HW_DET 80
Krishna Konda3b78ea72011-10-18 16:09:19 -0700286#define GPIO_SDC2_DAT1_WAKEUP 26
Krishna Kondadd794462011-10-01 00:19:29 -0700287
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -0700288/* MDM9x15 has 2 SDCC controllers */
Krishna Kondadd794462011-10-01 00:19:29 -0700289enum sdcc_controllers {
290 SDCC1,
291 SDCC2,
292 MAX_SDCC_CONTROLLER
293};
294
295#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
296/* SDC1 pad data */
297static struct msm_mmc_pad_drv sdc1_pad_drv_on_cfg[] = {
298 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_16MA},
299 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_10MA},
300 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_10MA}
301};
302
303static struct msm_mmc_pad_drv sdc1_pad_drv_off_cfg[] = {
304 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_2MA},
305 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_2MA},
306 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_2MA}
307};
308
309static struct msm_mmc_pad_pull sdc1_pad_pull_on_cfg[] = {
310 {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL},
311 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_UP},
312 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_UP}
313};
314
315static struct msm_mmc_pad_pull sdc1_pad_pull_off_cfg[] = {
316 {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL},
317 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_DOWN},
318 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_DOWN}
319};
320
321static struct msm_mmc_pad_pull_data mmc_pad_pull_data[MAX_SDCC_CONTROLLER] = {
322 [SDCC1] = {
323 .on = sdc1_pad_pull_on_cfg,
324 .off = sdc1_pad_pull_off_cfg,
325 .size = ARRAY_SIZE(sdc1_pad_pull_on_cfg)
326 },
327};
328
329static struct msm_mmc_pad_drv_data mmc_pad_drv_data[MAX_SDCC_CONTROLLER] = {
330 [SDCC1] = {
331 .on = sdc1_pad_drv_on_cfg,
332 .off = sdc1_pad_drv_off_cfg,
333 .size = ARRAY_SIZE(sdc1_pad_drv_on_cfg)
334 },
335};
336
337static struct msm_mmc_pad_data mmc_pad_data[MAX_SDCC_CONTROLLER] = {
338 [SDCC1] = {
339 .pull = &mmc_pad_pull_data[SDCC1],
340 .drv = &mmc_pad_drv_data[SDCC1]
341 },
342};
343#endif
344
Krishna Konda71aef182011-10-01 02:27:51 -0700345#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
346static struct gpiomux_setting sdcc2_clk_actv_cfg = {
347 .func = GPIOMUX_FUNC_1,
348 .drv = GPIOMUX_DRV_16MA,
349 .pull = GPIOMUX_PULL_NONE,
350};
351
352static struct gpiomux_setting sdcc2_cmd_data_0_3_actv_cfg = {
353 .func = GPIOMUX_FUNC_1,
354 .drv = GPIOMUX_DRV_8MA,
355 .pull = GPIOMUX_PULL_UP,
356};
357
358static struct gpiomux_setting sdcc2_suspend_cfg = {
359 .func = GPIOMUX_FUNC_1,
360 .drv = GPIOMUX_DRV_2MA,
361 .pull = GPIOMUX_PULL_DOWN,
362};
363
364static struct msm_gpiomux_config msm9615_sdcc2_configs[] __initdata = {
365 {
366 /* SDC2_DATA_0 */
367 .gpio = 25,
368 .settings = {
369 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
370 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
371 },
372 },
373 {
374 /* SDC2_DATA_1 */
375 .gpio = 26,
376 .settings = {
377 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
378 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
379 },
380 },
381 {
382 /* SDC2_DATA_2 */
383 .gpio = 27,
384 .settings = {
385 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
386 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
387 },
388 },
389 {
390 /* SDC2_DATA_3 */
391 .gpio = 28,
392 .settings = {
393 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
394 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
395 },
396 },
397 {
398 /* SDC2_CMD GSBI1 */
399 .gpio = 29,
400 .settings = {
401 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
402 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
403 },
404 },
405 {
406 /* SDC2_CLK GSBI1 */
407 .gpio = 30,
408 .settings = {
409 [GPIOMUX_ACTIVE] = &sdcc2_clk_actv_cfg,
410 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
411 },
412 },
413};
414
415static struct msm_mmc_gpio sdc2_gpio_cfg[] = {
416 {25, "sdc2_dat_0"},
417 {26, "sdc2_dat_1"},
418 {27, "sdc2_dat_2"},
419 {28, "sdc2_dat_3"},
420 {29, "sdc2_cmd"},
421 {30, "sdc2_clk"},
422};
423
424static struct msm_mmc_gpio_data mmc_gpio_data[MAX_SDCC_CONTROLLER] = {
425 [SDCC2] = {
426 .gpio = sdc2_gpio_cfg,
427 .size = ARRAY_SIZE(sdc2_gpio_cfg),
428 },
429};
430#else
431static struct msm_gpiomux_config msm9615_sdcc2_configs[0];
432#endif
433
434static struct msm_mmc_pin_data mmc_slot_pin_data[MAX_SDCC_CONTROLLER] = {
Krishna Kondadd794462011-10-01 00:19:29 -0700435#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
436 [SDCC1] = {
437 .is_gpio = 0,
438 .pad_data = &mmc_pad_data[SDCC1],
439 },
440#endif
Krishna Konda71aef182011-10-01 02:27:51 -0700441#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
442 [SDCC2] = {
443 .is_gpio = 1,
444 .gpio_data = &mmc_gpio_data[SDCC2],
445 },
446#endif
Krishna Kondadd794462011-10-01 00:19:29 -0700447};
448
449#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
450static unsigned int sdc1_sup_clk_rates[] = {
451 400000, 24000000, 48000000
452};
453
454static struct mmc_platform_data sdc1_data = {
455 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
456 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
457 .sup_clk_table = sdc1_sup_clk_rates,
458 .sup_clk_cnt = ARRAY_SIZE(sdc1_sup_clk_rates),
Krishna Konda890b1d12011-10-18 16:05:37 -0700459 .pclk_src_dfab = 1,
Krishna Kondadd794462011-10-01 00:19:29 -0700460 .sdcc_v4_sup = true,
461 .pin_data = &mmc_slot_pin_data[SDCC1],
Krishna Konda7186bfe2011-10-17 15:36:54 -0700462#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
463 .status_gpio = GPIO_SDC1_HW_DET,
464 .status_irq = MSM_GPIO_TO_INT(GPIO_SDC1_HW_DET),
465 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
466#endif
Krishna Kondadd794462011-10-01 00:19:29 -0700467};
468static struct mmc_platform_data *msm9615_sdc1_pdata = &sdc1_data;
469#else
470static struct mmc_platform_data *msm9615_sdc1_pdata;
471#endif
472
Krishna Konda71aef182011-10-01 02:27:51 -0700473#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
474static unsigned int sdc2_sup_clk_rates[] = {
475 400000, 24000000, 48000000
476};
477
478static struct mmc_platform_data sdc2_data = {
479 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
480 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
481 .sup_clk_table = sdc2_sup_clk_rates,
482 .sup_clk_cnt = ARRAY_SIZE(sdc2_sup_clk_rates),
Krishna Konda890b1d12011-10-18 16:05:37 -0700483 .pclk_src_dfab = 1,
Krishna Konda71aef182011-10-01 02:27:51 -0700484 .sdcc_v4_sup = true,
485 .pin_data = &mmc_slot_pin_data[SDCC2],
Krishna Konda3b78ea72011-10-18 16:09:19 -0700486#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
487 .sdiowakeup_irq = MSM_GPIO_TO_INT(GPIO_SDC2_DAT1_WAKEUP),
488#endif
Krishna Konda71aef182011-10-01 02:27:51 -0700489};
490static struct mmc_platform_data *msm9615_sdc2_pdata = &sdc2_data;
491#else
492static struct mmc_platform_data *msm9615_sdc2_pdata;
493#endif
494
Krishna Kondadd794462011-10-01 00:19:29 -0700495static void __init msm9615_init_mmc(void)
496{
497 int ret;
498
499 if (msm9615_sdc1_pdata) {
500 ret = gpio_request(GPIO_SDCARD_PWR_EN, "SDCARD_PWR_EN");
501
502 if (ret) {
503 pr_err("%s: sdcc1: Error requesting GPIO "
504 "SDCARD_PWR_EN:%d\n", __func__, ret);
505 } else {
506 ret = gpio_direction_output(GPIO_SDCARD_PWR_EN, 1);
507 if (ret) {
508 pr_err("%s: sdcc1: Error setting o/p direction"
509 " for GPIO SDCARD_PWR_EN:%d\n",
510 __func__, ret);
511 gpio_free(GPIO_SDCARD_PWR_EN);
512 } else {
513 msm_add_sdcc(1, msm9615_sdc1_pdata);
514 }
515 }
516 }
Krishna Konda71aef182011-10-01 02:27:51 -0700517
518 if (msm9615_sdc2_pdata) {
519 msm_gpiomux_install(msm9615_sdcc2_configs,
520 ARRAY_SIZE(msm9615_sdcc2_configs));
521
522 /* SDC2: External card slot */
523 msm_add_sdcc(2, msm9615_sdc2_pdata);
524 }
Krishna Kondadd794462011-10-01 00:19:29 -0700525}
526#else
527static void __init msm9615_init_mmc(void) { }
528#endif
Maheshkumar Sivasubramanian4923db22011-09-15 09:28:15 -0600529static struct msm_cpuidle_state msm_cstates[] __initdata = {
530 {0, 0, "C0", "WFI",
531 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
532
533 {0, 1, "C1", "STANDALONE_POWER_COLLAPSE",
534 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
535
536 {0, 2, "C2", "POWER_COLLAPSE",
537 MSM_PM_SLEEP_MODE_POWER_COLLAPSE},
538};
539static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
540 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
541 .idle_supported = 1,
542 .suspend_supported = 1,
543 .idle_enabled = 0,
544 .suspend_enabled = 0,
545 },
546 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
547 .idle_supported = 1,
548 .suspend_supported = 1,
549 .idle_enabled = 0,
550 .suspend_enabled = 0,
551 },
552 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
553 .idle_supported = 1,
554 .suspend_supported = 1,
555 .idle_enabled = 1,
556 .suspend_enabled = 1,
557 },
558};
Krishna Kondadd794462011-10-01 00:19:29 -0700559
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700560static int __init gpiomux_init(void)
561{
562 int rc;
563
564 rc = msm_gpiomux_init(NR_GPIO_IRQS);
565 if (rc) {
566 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
567 return rc;
568 }
Rohit Vaswani09666872011-08-23 17:41:54 -0700569 msm_gpiomux_install(msm9615_gsbi_configs,
570 ARRAY_SIZE(msm9615_gsbi_configs));
571
Rohit Vaswanif688fa62011-10-13 18:13:10 -0700572 msm_gpiomux_install(msm9615_ps_hold_config,
573 ARRAY_SIZE(msm9615_ps_hold_config));
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700574 return 0;
575}
576
Harini Jayaraman738c9312011-09-08 15:22:38 -0600577static struct msm_spi_platform_data msm9615_qup_spi_gsbi3_pdata = {
578 .max_clock_speed = 24000000,
579};
580
Harini Jayaramaneba52672011-09-08 15:13:00 -0600581static struct msm_i2c_platform_data msm9615_i2c_qup_gsbi5_pdata = {
582 .clk_freq = 100000,
583 .src_clk_rate = 24000000,
584};
585
Amit Blay5e4ec192011-10-20 09:16:54 +0200586static struct msm_otg_platform_data msm_otg_pdata = {
587 .mode = USB_PERIPHERAL,
588 .otg_control = OTG_NO_CONTROL,
589 .phy_type = SNPS_28NM_INTEGRATED_PHY,
590 .pclk_src_name = "dfab_usb_hs_clk",
591};
592
593static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
594{
595 return 0;
596}
597
598static struct android_usb_platform_data android_usb_pdata = {
599 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
600};
601
602static struct platform_device android_usb_device = {
603 .name = "android_usb",
604 .id = -1,
605 .dev = {
606 .platform_data = &android_usb_pdata,
607 },
608};
609
610static struct platform_device *common_devices[] = {
611 &msm9615_device_dmov,
612 &msm_device_smd,
613 &msm_device_otg,
614 &msm_device_gadget_peripheral,
615 &android_usb_device,
616 &msm9615_device_uart_gsbi4,
David Collins0f9942a2011-10-31 09:47:34 -0700617 &msm9615_device_ext_2p95v_vreg,
Amit Blay5e4ec192011-10-20 09:16:54 +0200618 &msm9615_device_ssbi_pmic1,
619 &msm9615_device_qup_i2c_gsbi5,
620 &msm9615_device_qup_spi_gsbi3,
621 &msm_device_sps,
622 &msm9615_device_tsens,
623 &msm_device_nand,
624 &msm_rpm_device,
625#ifdef CONFIG_HW_RANDOM_MSM
626 &msm_device_rng,
627#endif
628
629#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
630 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
Ramesh Masavarapuaa28b5b2011-10-21 10:26:03 -0700631 &msm9615_qcrypto_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200632#endif
633
634#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
635 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
Ramesh Masavarapuaa28b5b2011-10-21 10:26:03 -0700636 &msm9615_qcedev_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200637#endif
638};
639
Harini Jayaramaneba52672011-09-08 15:13:00 -0600640static void __init msm9615_i2c_init(void)
641{
642 msm9615_device_qup_i2c_gsbi5.dev.platform_data =
643 &msm9615_i2c_qup_gsbi5_pdata;
644}
645
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700646static void __init msm9615_common_init(void)
647{
648 msm9615_device_init();
649 gpiomux_init();
Harini Jayaramaneba52672011-09-08 15:13:00 -0600650 msm9615_i2c_init();
David Collins00b31e62011-08-31 20:00:10 -0700651 regulator_suppress_info_printing();
David Collinsbea297a2011-09-28 13:11:14 -0700652 platform_device_register(&msm9615_device_rpm_regulator);
Harini Jayaraman738c9312011-09-08 15:22:38 -0600653 msm9615_device_qup_spi_gsbi3.dev.platform_data =
654 &msm9615_qup_spi_gsbi3_pdata;
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700655 msm9615_device_ssbi_pmic1.dev.platform_data =
656 &msm9615_ssbi_pm8018_pdata;
David Collins00b31e62011-08-31 20:00:10 -0700657 pm8018_platform_data.num_regulators = msm_pm8018_regulator_pdata_len;
Amit Blay5e4ec192011-10-20 09:16:54 +0200658
659 msm_device_otg.dev.platform_data = &msm_otg_pdata;
660 msm_device_gadget_peripheral.dev.parent = &msm_device_otg.dev;
Rohit Vaswani09666872011-08-23 17:41:54 -0700661 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Krishna Kondadd794462011-10-01 00:19:29 -0700662
Vikram Mulukutlab5e1cda2011-10-04 16:17:22 -0700663 msm_clock_init(&msm9615_clock_init_data);
664 acpuclk_init(&acpuclk_9615_soc_data);
665
Krishna Kondadd794462011-10-01 00:19:29 -0700666 msm9615_init_mmc();
Maheshkumar Sivasubramanian4923db22011-09-15 09:28:15 -0600667 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
668 msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ);
669 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
670 msm_pm_data);
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700671}
672
673static void __init msm9615_cdp_init(void)
674{
675 msm9615_common_init();
676}
677
678static void __init msm9615_mtp_init(void)
679{
680 msm9615_common_init();
681}
682
683MACHINE_START(MSM9615_CDP, "QCT MSM9615 CDP")
684 .map_io = msm9615_map_io,
685 .init_irq = msm9615_init_irq,
686 .timer = &msm_timer,
687 .init_machine = msm9615_cdp_init,
688MACHINE_END
689
690MACHINE_START(MSM9615_MTP, "QCT MSM9615 MTP")
691 .map_io = msm9615_map_io,
692 .init_irq = msm9615_init_irq,
693 .timer = &msm_timer,
694 .init_machine = msm9615_mtp_init,
695MACHINE_END