blob: bfd65fbaab399ec9f290051b1f73bb704097ffb6 [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 Vaswania6815892011-12-15 20:20:39 -080018#include <linux/usb/android.h>
19#include <linux/usb/msm_hsusb.h>
20#include <linux/mfd/pm8xxx/pm8xxx-adc.h>
21#include <linux/leds.h>
22#include <linux/leds-pm8xxx.h>
23#include <linux/power/ltc4088-charger.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070024#include <asm/mach-types.h>
25#include <asm/mach/arch.h>
Krishna Kondadd794462011-10-01 00:19:29 -070026#include <asm/mach/mmc.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070027#include <mach/board.h>
28#include <mach/msm_iomap.h>
29#include <mach/gpio.h>
Harini Jayaraman738c9312011-09-08 15:22:38 -060030#include <mach/msm_spi.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"
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060038#include "pm-boot.h"
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070039
Siddartha Mohanadoss5f60b452011-10-05 11:49:00 -070040static struct pm8xxx_adc_amux pm8018_adc_channels_data[] = {
41 {"vcoin", CHANNEL_VCOIN, CHAN_PATH_SCALING2, AMUX_RSV1,
42 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
43 {"vbat", CHANNEL_VBAT, CHAN_PATH_SCALING2, AMUX_RSV1,
44 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
45 {"vph_pwr", CHANNEL_VPH_PWR, CHAN_PATH_SCALING2, AMUX_RSV1,
46 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
47 {"batt_therm", CHANNEL_BATT_THERM, CHAN_PATH_SCALING1, AMUX_RSV2,
48 ADC_DECIMATION_TYPE2, ADC_SCALE_BATT_THERM},
49 {"batt_id", CHANNEL_BATT_ID, CHAN_PATH_SCALING1, AMUX_RSV2,
50 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
51 {"pmic_therm", CHANNEL_DIE_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
52 ADC_DECIMATION_TYPE2, ADC_SCALE_PMIC_THERM},
53 {"625mv", CHANNEL_625MV, CHAN_PATH_SCALING1, AMUX_RSV1,
54 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
55 {"125v", CHANNEL_125V, CHAN_PATH_SCALING1, AMUX_RSV1,
56 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
57 {"pa_therm0", ADC_MPP_1_AMUX3, CHAN_PATH_SCALING1, AMUX_RSV1,
58 ADC_DECIMATION_TYPE2, ADC_SCALE_PA_THERM},
59};
60
61static struct pm8xxx_adc_properties pm8018_adc_data = {
62 .adc_vdd_reference = 1800, /* milli-voltage for this adc */
63 .bitresolution = 15,
64 .bipolar = 0,
65};
66
67static struct pm8xxx_adc_platform_data pm8018_adc_pdata = {
68 .adc_channel = pm8018_adc_channels_data,
69 .adc_num_board_channel = ARRAY_SIZE(pm8018_adc_channels_data),
70 .adc_prop = &pm8018_adc_data,
71};
72
David Collinsfb88c432011-08-25 15:12:47 -070073static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata __devinitdata = {
74 .irq_base = PM8018_IRQ_BASE,
75 .devirq = MSM_GPIO_TO_INT(87),
76 .irq_trigger_flag = IRQF_TRIGGER_LOW,
77};
78
79static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata __devinitdata = {
80 .gpio_base = PM8018_GPIO_PM_TO_SYS(1),
81};
82
83static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata __devinitdata = {
84 .mpp_base = PM8018_MPP_PM_TO_SYS(1),
85};
86
87static struct pm8xxx_rtc_platform_data pm8xxx_rtc_pdata __devinitdata = {
88 .rtc_write_enable = false,
Ashay Jaiswaldb5e6dc2011-10-12 11:02:47 +053089 .rtc_alarm_powerup = false,
David Collinsfb88c432011-08-25 15:12:47 -070090};
91
92static struct pm8xxx_pwrkey_platform_data pm8xxx_pwrkey_pdata = {
93 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -080094 .kpd_trigger_delay_us = 15625,
David Collinsfb88c432011-08-25 15:12:47 -070095 .wakeup = 1,
96};
97
98static struct pm8xxx_misc_platform_data pm8xxx_misc_pdata = {
99 .priority = 0,
100};
101
Jay Chokshieb5d0d52011-09-28 17:16:20 -0700102#define PM8018_LED_KB_MAX_CURRENT 20 /* I = 20mA */
103#define PM8XXX_LED_PWM_PERIOD_US 1000
104
105/**
106 * PM8XXX_PWM_CHANNEL_NONE shall be used when LED shall not be
107 * driven using PWM feature.
108 */
109#define PM8XXX_PWM_CHANNEL_NONE -1
110
111static struct led_info pm8018_led_info[] = {
112 [0] = {
113 .name = "led:kb",
114 },
115};
116
117static struct led_platform_data pm8018_led_core_pdata = {
118 .num_leds = ARRAY_SIZE(pm8018_led_info),
119 .leds = pm8018_led_info,
120};
121
122static struct pm8xxx_led_config pm8018_led_configs[] = {
123 [0] = {
124 .id = PM8XXX_ID_LED_KB_LIGHT,
125 .mode = PM8XXX_LED_MODE_PWM3,
126 .max_current = PM8018_LED_KB_MAX_CURRENT,
127 .pwm_channel = 2,
128 .pwm_period_us = PM8XXX_LED_PWM_PERIOD_US,
129 },
130};
131
132static struct pm8xxx_led_platform_data pm8xxx_leds_pdata = {
133 .led_core = &pm8018_led_core_pdata,
134 .configs = pm8018_led_configs,
135 .num_configs = ARRAY_SIZE(pm8018_led_configs),
136};
137
Jay Chokshidc8028b2011-12-01 16:17:34 -0800138#ifdef CONFIG_LTC4088_CHARGER
139static struct ltc4088_charger_platform_data ltc4088_chg_pdata = {
140 .gpio_mode_select_d0 = 7,
141 .gpio_mode_select_d1 = 6,
142 .gpio_mode_select_d2 = 4,
143};
144#endif
145
David Collinsfb88c432011-08-25 15:12:47 -0700146static struct pm8018_platform_data pm8018_platform_data __devinitdata = {
147 .irq_pdata = &pm8xxx_irq_pdata,
148 .gpio_pdata = &pm8xxx_gpio_pdata,
149 .mpp_pdata = &pm8xxx_mpp_pdata,
150 .rtc_pdata = &pm8xxx_rtc_pdata,
151 .pwrkey_pdata = &pm8xxx_pwrkey_pdata,
152 .misc_pdata = &pm8xxx_misc_pdata,
David Collins00b31e62011-08-31 20:00:10 -0700153 .regulator_pdatas = msm_pm8018_regulator_pdata,
Siddartha Mohanadoss5f60b452011-10-05 11:49:00 -0700154 .adc_pdata = &pm8018_adc_pdata,
Jay Chokshieb5d0d52011-09-28 17:16:20 -0700155 .leds_pdata = &pm8xxx_leds_pdata,
David Collinsfb88c432011-08-25 15:12:47 -0700156};
157
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700158static struct msm_ssbi_platform_data msm9615_ssbi_pm8018_pdata __devinitdata = {
159 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
160 .slave = {
David Collinsfb88c432011-08-25 15:12:47 -0700161 .name = PM8018_CORE_DEV_NAME,
162 .platform_data = &pm8018_platform_data,
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700163 },
164};
165
David Collinsbea297a2011-09-28 13:11:14 -0700166static struct platform_device msm9615_device_rpm_regulator __devinitdata = {
167 .name = "rpm-regulator",
168 .id = -1,
169 .dev = {
170 .platform_data = &msm_rpm_regulator_9615_pdata,
171 },
172};
173
David Collins0f9942a2011-10-31 09:47:34 -0700174static struct platform_device msm9615_device_ext_2p95v_vreg = {
175 .name = GPIO_REGULATOR_DEV_NAME,
176 .id = 18,
177 .dev = {
178 .platform_data =
179 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_2P95V],
180 },
181};
182
Krishna Kondadd794462011-10-01 00:19:29 -0700183#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
184 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT))
185
Krishna Konda7186bfe2011-10-17 15:36:54 -0700186#define GPIO_SDC1_HW_DET 80
Krishna Konda3b78ea72011-10-18 16:09:19 -0700187#define GPIO_SDC2_DAT1_WAKEUP 26
Krishna Kondadd794462011-10-01 00:19:29 -0700188
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -0700189/* MDM9x15 has 2 SDCC controllers */
Krishna Kondadd794462011-10-01 00:19:29 -0700190enum sdcc_controllers {
191 SDCC1,
192 SDCC2,
193 MAX_SDCC_CONTROLLER
194};
195
196#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Krishna Kondafea60182011-11-01 16:01:34 -0700197/* All SDCC controllers requires VDD/VCC voltage */
198static struct msm_mmc_reg_data mmc_vdd_reg_data[MAX_SDCC_CONTROLLER] = {
199 /* SDCC1 : External card slot connected */
200 [SDCC1] = {
201 .name = "sdc_vdd",
202 /*
203 * This is a gpio-regulator and does not support
204 * regulator_set_voltage and regulator_set_optimum_mode
205 */
Krishna Kondafea60182011-11-01 16:01:34 -0700206 .high_vol_level = 2950000,
207 .low_vol_level = 2950000,
208 .hpm_uA = 600000, /* 600mA */
209 }
210};
211
212/* All SDCC controllers may require voting for VDD PAD voltage */
213static struct msm_mmc_reg_data mmc_vddp_reg_data[MAX_SDCC_CONTROLLER] = {
214 /* SDCC1 : External card slot connected */
215 [SDCC1] = {
216 .name = "sdc_vddp",
Krishna Kondafea60182011-11-01 16:01:34 -0700217 .high_vol_level = 2950000,
218 .low_vol_level = 1850000,
219 .always_on = true,
220 .lpm_sup = true,
221 /* Max. Active current required is 16 mA */
222 .hpm_uA = 16000,
223 /*
224 * Sleep current required is ~300 uA. But min. vote can be
225 * in terms of mA (min. 1 mA). So let's vote for 2 mA
226 * during sleep.
227 */
228 .lpm_uA = 2000,
229 }
230};
231
232static struct msm_mmc_slot_reg_data mmc_slot_vreg_data[MAX_SDCC_CONTROLLER] = {
233 /* SDCC1 : External card slot connected */
234 [SDCC1] = {
235 .vdd_data = &mmc_vdd_reg_data[SDCC1],
236 .vddp_data = &mmc_vddp_reg_data[SDCC1],
237 }
238};
239
Krishna Kondadd794462011-10-01 00:19:29 -0700240/* SDC1 pad data */
241static struct msm_mmc_pad_drv sdc1_pad_drv_on_cfg[] = {
242 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_16MA},
243 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_10MA},
244 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_10MA}
245};
246
247static struct msm_mmc_pad_drv sdc1_pad_drv_off_cfg[] = {
248 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_2MA},
249 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_2MA},
250 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_2MA}
251};
252
253static struct msm_mmc_pad_pull sdc1_pad_pull_on_cfg[] = {
254 {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL},
255 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_UP},
256 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_UP}
257};
258
259static struct msm_mmc_pad_pull sdc1_pad_pull_off_cfg[] = {
260 {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL},
261 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_DOWN},
262 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_DOWN}
263};
264
265static struct msm_mmc_pad_pull_data mmc_pad_pull_data[MAX_SDCC_CONTROLLER] = {
266 [SDCC1] = {
267 .on = sdc1_pad_pull_on_cfg,
268 .off = sdc1_pad_pull_off_cfg,
269 .size = ARRAY_SIZE(sdc1_pad_pull_on_cfg)
270 },
271};
272
273static struct msm_mmc_pad_drv_data mmc_pad_drv_data[MAX_SDCC_CONTROLLER] = {
274 [SDCC1] = {
275 .on = sdc1_pad_drv_on_cfg,
276 .off = sdc1_pad_drv_off_cfg,
277 .size = ARRAY_SIZE(sdc1_pad_drv_on_cfg)
278 },
279};
280
281static struct msm_mmc_pad_data mmc_pad_data[MAX_SDCC_CONTROLLER] = {
282 [SDCC1] = {
283 .pull = &mmc_pad_pull_data[SDCC1],
284 .drv = &mmc_pad_drv_data[SDCC1]
285 },
286};
287#endif
288
Krishna Konda71aef182011-10-01 02:27:51 -0700289#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
Krishna Konda71aef182011-10-01 02:27:51 -0700290static struct msm_mmc_gpio sdc2_gpio_cfg[] = {
291 {25, "sdc2_dat_0"},
292 {26, "sdc2_dat_1"},
293 {27, "sdc2_dat_2"},
294 {28, "sdc2_dat_3"},
295 {29, "sdc2_cmd"},
296 {30, "sdc2_clk"},
297};
298
299static struct msm_mmc_gpio_data mmc_gpio_data[MAX_SDCC_CONTROLLER] = {
300 [SDCC2] = {
301 .gpio = sdc2_gpio_cfg,
302 .size = ARRAY_SIZE(sdc2_gpio_cfg),
303 },
304};
Krishna Konda71aef182011-10-01 02:27:51 -0700305#endif
306
307static struct msm_mmc_pin_data mmc_slot_pin_data[MAX_SDCC_CONTROLLER] = {
Krishna Kondadd794462011-10-01 00:19:29 -0700308#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
309 [SDCC1] = {
310 .is_gpio = 0,
311 .pad_data = &mmc_pad_data[SDCC1],
312 },
313#endif
Krishna Konda71aef182011-10-01 02:27:51 -0700314#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
315 [SDCC2] = {
316 .is_gpio = 1,
317 .gpio_data = &mmc_gpio_data[SDCC2],
318 },
319#endif
Krishna Kondadd794462011-10-01 00:19:29 -0700320};
321
322#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
323static unsigned int sdc1_sup_clk_rates[] = {
Krishna Konda360aa422011-12-06 18:27:41 -0800324 400000, 24000000, 48000000,
Krishna Kondadd794462011-10-01 00:19:29 -0700325};
326
327static struct mmc_platform_data sdc1_data = {
Krishna Konda360aa422011-12-06 18:27:41 -0800328 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
329 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Krishna Kondadd794462011-10-01 00:19:29 -0700330 .sup_clk_table = sdc1_sup_clk_rates,
331 .sup_clk_cnt = ARRAY_SIZE(sdc1_sup_clk_rates),
Krishna Kondafea60182011-11-01 16:01:34 -0700332 .pclk_src_dfab = true,
Krishna Kondafea60182011-11-01 16:01:34 -0700333 .vreg_data = &mmc_slot_vreg_data[SDCC1],
Krishna Kondadd794462011-10-01 00:19:29 -0700334 .pin_data = &mmc_slot_pin_data[SDCC1],
Krishna Konda7186bfe2011-10-17 15:36:54 -0700335#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
336 .status_gpio = GPIO_SDC1_HW_DET,
337 .status_irq = MSM_GPIO_TO_INT(GPIO_SDC1_HW_DET),
338 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
339#endif
Krishna Kondadbcf9702011-11-07 18:45:48 -0800340 .xpc_cap = 1,
341 .uhs_caps = (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 |
Krishna Konda360aa422011-12-06 18:27:41 -0800342 MMC_CAP_MAX_CURRENT_400),
Krishna Kondadd794462011-10-01 00:19:29 -0700343};
344static struct mmc_platform_data *msm9615_sdc1_pdata = &sdc1_data;
345#else
346static struct mmc_platform_data *msm9615_sdc1_pdata;
347#endif
348
Krishna Konda71aef182011-10-01 02:27:51 -0700349#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
350static unsigned int sdc2_sup_clk_rates[] = {
Krishna Konda360aa422011-12-06 18:27:41 -0800351 400000, 24000000, 48000000,
Krishna Konda71aef182011-10-01 02:27:51 -0700352};
353
354static struct mmc_platform_data sdc2_data = {
355 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
356 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
357 .sup_clk_table = sdc2_sup_clk_rates,
358 .sup_clk_cnt = ARRAY_SIZE(sdc2_sup_clk_rates),
Krishna Konda890b1d12011-10-18 16:05:37 -0700359 .pclk_src_dfab = 1,
Krishna Konda71aef182011-10-01 02:27:51 -0700360 .pin_data = &mmc_slot_pin_data[SDCC2],
Krishna Konda3b78ea72011-10-18 16:09:19 -0700361#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
362 .sdiowakeup_irq = MSM_GPIO_TO_INT(GPIO_SDC2_DAT1_WAKEUP),
363#endif
Krishna Konda71aef182011-10-01 02:27:51 -0700364};
365static struct mmc_platform_data *msm9615_sdc2_pdata = &sdc2_data;
366#else
367static struct mmc_platform_data *msm9615_sdc2_pdata;
368#endif
369
Krishna Kondadd794462011-10-01 00:19:29 -0700370static void __init msm9615_init_mmc(void)
371{
Krishna Kondadd794462011-10-01 00:19:29 -0700372 if (msm9615_sdc1_pdata) {
Krishna Kondafea60182011-11-01 16:01:34 -0700373 /* SDC1: External card slot for SD/MMC cards */
374 msm_add_sdcc(1, msm9615_sdc1_pdata);
Krishna Kondadd794462011-10-01 00:19:29 -0700375 }
Krishna Konda71aef182011-10-01 02:27:51 -0700376
377 if (msm9615_sdc2_pdata) {
Krishna Kondafea60182011-11-01 16:01:34 -0700378 /* SDC2: External card slot used for WLAN */
Krishna Konda71aef182011-10-01 02:27:51 -0700379 msm_add_sdcc(2, msm9615_sdc2_pdata);
380 }
Krishna Kondadd794462011-10-01 00:19:29 -0700381}
382#else
383static void __init msm9615_init_mmc(void) { }
384#endif
Maheshkumar Sivasubramanian4923db22011-09-15 09:28:15 -0600385static struct msm_cpuidle_state msm_cstates[] __initdata = {
386 {0, 0, "C0", "WFI",
387 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
388
389 {0, 1, "C1", "STANDALONE_POWER_COLLAPSE",
390 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
391
392 {0, 2, "C2", "POWER_COLLAPSE",
393 MSM_PM_SLEEP_MODE_POWER_COLLAPSE},
394};
395static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
396 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
397 .idle_supported = 1,
398 .suspend_supported = 1,
399 .idle_enabled = 0,
400 .suspend_enabled = 0,
401 },
402 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
403 .idle_supported = 1,
404 .suspend_supported = 1,
405 .idle_enabled = 0,
406 .suspend_enabled = 0,
407 },
408 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
409 .idle_supported = 1,
410 .suspend_supported = 1,
411 .idle_enabled = 1,
412 .suspend_enabled = 1,
413 },
414};
Krishna Kondadd794462011-10-01 00:19:29 -0700415
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600416static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
417 .mode = MSM_PM_BOOT_CONFIG_REMAP_BOOT_ADDR,
418 .v_addr = MSM_APCS_GLB_BASE + 0x24,
419};
420
Gagan Mac7a827642011-09-22 19:42:21 -0600421static void __init msm9615_init_buses(void)
422{
423#ifdef CONFIG_MSM_BUS_SCALING
424 msm_bus_rpm_set_mt_mask();
425 msm_bus_9615_sys_fabric_pdata.rpm_enabled = 1;
426 msm_bus_9615_sys_fabric.dev.platform_data =
427 &msm_bus_9615_sys_fabric_pdata;
428 msm_bus_def_fab.dev.platform_data = &msm_bus_9615_def_fab_pdata;
429#endif
430}
431
Harini Jayaraman738c9312011-09-08 15:22:38 -0600432static struct msm_spi_platform_data msm9615_qup_spi_gsbi3_pdata = {
433 .max_clock_speed = 24000000,
434};
435
Harini Jayaramaneba52672011-09-08 15:13:00 -0600436static struct msm_i2c_platform_data msm9615_i2c_qup_gsbi5_pdata = {
437 .clk_freq = 100000,
438 .src_clk_rate = 24000000,
439};
440
Amit Blay6a8d4f32011-11-21 10:36:25 +0200441#define USB_5V_EN 3
442#define PM_USB_5V_EN PM8018_GPIO_PM_TO_SYS(USB_5V_EN)
443
444static void msm_hsusb_vbus_power(bool on)
445{
446 int rc;
447 static bool vbus_is_on;
448 struct pm_gpio usb_vbus = {
449 .direction = PM_GPIO_DIR_OUT,
450 .pull = PM_GPIO_PULL_NO,
451 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
452 .output_value = 0,
453 .vin_sel = 2,
454 .out_strength = PM_GPIO_STRENGTH_HIGH,
455 .function = PM_GPIO_FUNC_NORMAL,
456 .inv_int_pol = 0,
457 };
458
459 if (vbus_is_on == on)
460 return;
461
462 if (on) {
463 rc = pm8xxx_gpio_config(PM_USB_5V_EN, &usb_vbus);
464 if (rc) {
465 pr_err("failed to config usb_5v_en gpio\n");
466 return;
467 }
468
469 rc = gpio_request(PM_USB_5V_EN,
470 "usb_5v_en");
471 if (rc < 0) {
472 pr_err("failed to request usb_5v_en gpio\n");
473 return;
474 }
475
476 rc = gpio_direction_output(PM_USB_5V_EN, 1);
477 if (rc) {
478 pr_err("%s: unable to set_direction for gpio [%d]\n",
479 __func__, PM_USB_5V_EN);
480 goto free_usb_5v_en;
481 }
482
483 vbus_is_on = true;
484 return;
485 }
486 gpio_set_value(PM_USB_5V_EN, 0);
487free_usb_5v_en:
488 gpio_free(PM_USB_5V_EN);
489 vbus_is_on = false;
490}
491
Anji jonnalaa8b8d732011-12-06 10:03:24 +0530492static int shelby_phy_init_seq[] = {
493 0x44, 0x80,/* set VBUS valid threshold and
494 disconnect valid threshold */
495 0x38, 0x81, /* update DC voltage level */
496 0x14, 0x82,/* set preemphasis and rise/fall time */
497 0x13, 0x83,/* set source impedance adjustment */
498 -1};
499
Ofir Cohen40a4e862011-12-08 15:17:52 +0200500#define USB_BAM_PHY_BASE 0x12502000
501#define USB_BAM_PHY_SIZE 0x10000
502#define A2_BAM_PHY_BASE 0x124C2000
503static struct usb_bam_pipe_connect msm_usb_bam_connections[4][2] = {
504 [0][USB_TO_PEER_PERIPHERAL] = {
505 .src_phy_addr = USB_BAM_PHY_BASE,
506 .src_pipe_index = 11,
507 .dst_phy_addr = A2_BAM_PHY_BASE,
508 .dst_pipe_index = 0,
Ofir Cohen29cd5752011-12-14 17:20:30 +0200509 .data_fifo_base_offset = 0x1100,
510 .data_fifo_size = 0x600,
511 .desc_fifo_base_offset = 0x1700,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200512 .desc_fifo_size = 0x300,
513 },
514 [0][PEER_PERIPHERAL_TO_USB] = {
515 .src_phy_addr = A2_BAM_PHY_BASE,
516 .src_pipe_index = 1,
517 .dst_phy_addr = USB_BAM_PHY_BASE,
518 .dst_pipe_index = 10,
519 .data_fifo_base_offset = 0xa00,
Ofir Cohen29cd5752011-12-14 17:20:30 +0200520 .data_fifo_size = 0x600,
521 .desc_fifo_base_offset = 0x1000,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200522 .desc_fifo_size = 0x100,
523 },
524};
525
526static struct msm_usb_bam_platform_data msm_usb_bam_pdata = {
527 .connections = &msm_usb_bam_connections[0][0],
528 .usb_bam_phy_base = USB_BAM_PHY_BASE,
529 .usb_bam_phy_size = USB_BAM_PHY_SIZE,
530 .usb_bam_num_pipes = 32,
531};
532
Amit Blay5e4ec192011-10-20 09:16:54 +0200533static struct msm_otg_platform_data msm_otg_pdata = {
Amit Blay6a8d4f32011-11-21 10:36:25 +0200534 .mode = USB_OTG,
535 .otg_control = OTG_PHY_CONTROL,
Amit Blay5e4ec192011-10-20 09:16:54 +0200536 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200537 .pclk_src_name = "dfab_usb_hs_clk",
538 .vbus_power = msm_hsusb_vbus_power,
Amit Blay5e4ec192011-10-20 09:16:54 +0200539};
540
541static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
542{
543 return 0;
544}
545
546static struct android_usb_platform_data android_usb_pdata = {
547 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
548};
549
550static struct platform_device android_usb_device = {
551 .name = "android_usb",
552 .id = -1,
553 .dev = {
554 .platform_data = &android_usb_pdata,
555 },
556};
557
Rohit Vaswani149f0a72011-11-09 15:21:28 -0800558static struct platform_device msm_wlan_ar6000_pm_device = {
559 .name = "wlan_ar6000_pm_dev",
560 .id = -1,
561};
562
563static int __init msm9615_init_ar6000pm(void)
564{
565 return platform_device_register(&msm_wlan_ar6000_pm_device);
566}
567
Jay Chokshidc8028b2011-12-01 16:17:34 -0800568#ifdef CONFIG_LTC4088_CHARGER
569static struct platform_device msm_device_charger = {
570 .name = LTC4088_CHARGER_DEV_NAME,
571 .id = -1,
572 .dev = {
573 .platform_data = &ltc4088_chg_pdata,
574 },
575};
576#endif
577
Amit Blay5e4ec192011-10-20 09:16:54 +0200578static struct platform_device *common_devices[] = {
579 &msm9615_device_dmov,
580 &msm_device_smd,
Jay Chokshidc8028b2011-12-01 16:17:34 -0800581#ifdef CONFIG_LTC4088_CHARGER
582 &msm_device_charger,
583#endif
Amit Blay5e4ec192011-10-20 09:16:54 +0200584 &msm_device_otg,
585 &msm_device_gadget_peripheral,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200586 &msm_device_hsusb_host,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200587 &msm_device_usb_bam,
Amit Blay5e4ec192011-10-20 09:16:54 +0200588 &android_usb_device,
589 &msm9615_device_uart_gsbi4,
David Collins0f9942a2011-10-31 09:47:34 -0700590 &msm9615_device_ext_2p95v_vreg,
Amit Blay5e4ec192011-10-20 09:16:54 +0200591 &msm9615_device_ssbi_pmic1,
592 &msm9615_device_qup_i2c_gsbi5,
593 &msm9615_device_qup_spi_gsbi3,
594 &msm_device_sps,
595 &msm9615_device_tsens,
596 &msm_device_nand,
Eric Holmberg0c96e702011-11-08 18:04:31 -0700597 &msm_device_bam_dmux,
Amit Blay5e4ec192011-10-20 09:16:54 +0200598 &msm_rpm_device,
599#ifdef CONFIG_HW_RANDOM_MSM
600 &msm_device_rng,
601#endif
602
603#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
604 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
Ramesh Masavarapuaa28b5b2011-10-21 10:26:03 -0700605 &msm9615_qcrypto_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200606#endif
607
608#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
609 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
Ramesh Masavarapuaa28b5b2011-10-21 10:26:03 -0700610 &msm9615_qcedev_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200611#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700612 &msm9615_device_watchdog,
Gagan Mac7a827642011-09-22 19:42:21 -0600613 &msm_bus_9615_sys_fabric,
614 &msm_bus_def_fab,
Amit Blay5e4ec192011-10-20 09:16:54 +0200615};
616
Harini Jayaramaneba52672011-09-08 15:13:00 -0600617static void __init msm9615_i2c_init(void)
618{
619 msm9615_device_qup_i2c_gsbi5.dev.platform_data =
620 &msm9615_i2c_qup_gsbi5_pdata;
621}
622
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600623static void __init msm9615_reserve(void)
624{
625 msm_pm_boot_pdata.p_addr = memblock_alloc(SZ_8, SZ_64K);
626}
627
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700628static void __init msm9615_common_init(void)
629{
630 msm9615_device_init();
Rohit Vaswania6815892011-12-15 20:20:39 -0800631 msm9615_init_gpiomux();
Harini Jayaramaneba52672011-09-08 15:13:00 -0600632 msm9615_i2c_init();
David Collins00b31e62011-08-31 20:00:10 -0700633 regulator_suppress_info_printing();
David Collinsbea297a2011-09-28 13:11:14 -0700634 platform_device_register(&msm9615_device_rpm_regulator);
Gagan Mac7a827642011-09-22 19:42:21 -0600635 msm_clock_init(&msm9615_clock_init_data);
636 msm9615_init_buses();
Harini Jayaraman738c9312011-09-08 15:22:38 -0600637 msm9615_device_qup_spi_gsbi3.dev.platform_data =
638 &msm9615_qup_spi_gsbi3_pdata;
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700639 msm9615_device_ssbi_pmic1.dev.platform_data =
640 &msm9615_ssbi_pm8018_pdata;
David Collins00b31e62011-08-31 20:00:10 -0700641 pm8018_platform_data.num_regulators = msm_pm8018_regulator_pdata_len;
Amit Blay5e4ec192011-10-20 09:16:54 +0200642
643 msm_device_otg.dev.platform_data = &msm_otg_pdata;
Anji jonnalaa8b8d732011-12-06 10:03:24 +0530644 msm_otg_pdata.phy_init_seq = shelby_phy_init_seq;
Ofir Cohen40a4e862011-12-08 15:17:52 +0200645 msm_device_usb_bam.dev.platform_data = &msm_usb_bam_pdata;
Rohit Vaswani09666872011-08-23 17:41:54 -0700646 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Krishna Kondadd794462011-10-01 00:19:29 -0700647
Vikram Mulukutlab5e1cda2011-10-04 16:17:22 -0700648 acpuclk_init(&acpuclk_9615_soc_data);
649
Rohit Vaswani149f0a72011-11-09 15:21:28 -0800650 /* Ensure ar6000pm device is registered before MMC/SDC */
651 msm9615_init_ar6000pm();
652
Krishna Kondadd794462011-10-01 00:19:29 -0700653 msm9615_init_mmc();
Maheshkumar Sivasubramanian4923db22011-09-15 09:28:15 -0600654 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
655 msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ);
656 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
657 msm_pm_data);
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600658 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700659}
660
661static void __init msm9615_cdp_init(void)
662{
663 msm9615_common_init();
664}
665
666static void __init msm9615_mtp_init(void)
667{
668 msm9615_common_init();
669}
670
671MACHINE_START(MSM9615_CDP, "QCT MSM9615 CDP")
672 .map_io = msm9615_map_io,
673 .init_irq = msm9615_init_irq,
674 .timer = &msm_timer,
675 .init_machine = msm9615_cdp_init,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600676 .reserve = msm9615_reserve,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700677MACHINE_END
678
679MACHINE_START(MSM9615_MTP, "QCT MSM9615 MTP")
680 .map_io = msm9615_map_io,
681 .init_irq = msm9615_init_irq,
682 .timer = &msm_timer,
683 .init_machine = msm9615_mtp_init,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600684 .reserve = msm9615_reserve,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700685MACHINE_END