blob: e53334cf02483d2f3ad22a4d258366d30a3170e8 [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>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070025#include "timer.h"
26#include "devices.h"
David Collinsfb88c432011-08-25 15:12:47 -070027#include "board-9615.h"
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070028
Rohit Vaswani09666872011-08-23 17:41:54 -070029static struct platform_device *common_devices[] = {
Jeff Ohlsteind19bf442011-09-09 12:48:18 -070030 &msm9615_device_dmov,
Jeff Hugo56b933a2011-09-28 14:42:05 -060031 &msm_device_smd,
Rohit Vaswani09666872011-08-23 17:41:54 -070032 &msm9615_device_uart_gsbi4,
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -070033 &msm9615_device_ssbi_pmic1,
Harini Jayaramaneba52672011-09-08 15:13:00 -060034 &msm9615_device_qup_i2c_gsbi5,
Harini Jayaraman738c9312011-09-08 15:22:38 -060035 &msm9615_device_qup_spi_gsbi3,
Yan He092b7272011-09-21 15:25:03 -070036 &msm_device_sps,
Siddartha Mohanadoss5d49cec2011-09-21 10:26:15 -070037 &msm9615_device_tsens,
Sahitya Tummala38295432011-09-29 10:08:45 +053038 &msm_device_nand,
Rohit Vaswani09666872011-08-23 17:41:54 -070039};
40
David Collinsfb88c432011-08-25 15:12:47 -070041static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata __devinitdata = {
42 .irq_base = PM8018_IRQ_BASE,
43 .devirq = MSM_GPIO_TO_INT(87),
44 .irq_trigger_flag = IRQF_TRIGGER_LOW,
45};
46
47static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata __devinitdata = {
48 .gpio_base = PM8018_GPIO_PM_TO_SYS(1),
49};
50
51static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata __devinitdata = {
52 .mpp_base = PM8018_MPP_PM_TO_SYS(1),
53};
54
55static struct pm8xxx_rtc_platform_data pm8xxx_rtc_pdata __devinitdata = {
56 .rtc_write_enable = false,
57};
58
59static struct pm8xxx_pwrkey_platform_data pm8xxx_pwrkey_pdata = {
60 .pull_up = 1,
61 .kpd_trigger_delay_us = 970,
62 .wakeup = 1,
63};
64
65static struct pm8xxx_misc_platform_data pm8xxx_misc_pdata = {
66 .priority = 0,
67};
68
69static struct pm8018_platform_data pm8018_platform_data __devinitdata = {
70 .irq_pdata = &pm8xxx_irq_pdata,
71 .gpio_pdata = &pm8xxx_gpio_pdata,
72 .mpp_pdata = &pm8xxx_mpp_pdata,
73 .rtc_pdata = &pm8xxx_rtc_pdata,
74 .pwrkey_pdata = &pm8xxx_pwrkey_pdata,
75 .misc_pdata = &pm8xxx_misc_pdata,
David Collins00b31e62011-08-31 20:00:10 -070076 .regulator_pdatas = msm_pm8018_regulator_pdata,
David Collinsfb88c432011-08-25 15:12:47 -070077};
78
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -070079static struct msm_ssbi_platform_data msm9615_ssbi_pm8018_pdata __devinitdata = {
80 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
81 .slave = {
David Collinsfb88c432011-08-25 15:12:47 -070082 .name = PM8018_CORE_DEV_NAME,
83 .platform_data = &pm8018_platform_data,
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -070084 },
85};
86
Rohit Vaswani09666872011-08-23 17:41:54 -070087static struct gpiomux_setting gsbi4 = {
88 .func = GPIOMUX_FUNC_1,
89 .drv = GPIOMUX_DRV_8MA,
90 .pull = GPIOMUX_PULL_NONE,
91};
92
Harini Jayaramaneba52672011-09-08 15:13:00 -060093static struct gpiomux_setting gsbi5 = {
94 .func = GPIOMUX_FUNC_1,
95 .drv = GPIOMUX_DRV_8MA,
96 .pull = GPIOMUX_PULL_NONE,
97};
98
Harini Jayaraman738c9312011-09-08 15:22:38 -060099static struct gpiomux_setting gsbi3 = {
100 .func = GPIOMUX_FUNC_1,
101 .drv = GPIOMUX_DRV_8MA,
102 .pull = GPIOMUX_PULL_NONE,
103};
104
105static struct gpiomux_setting gsbi3_cs1_config = {
106 .func = GPIOMUX_FUNC_4,
107 .drv = GPIOMUX_DRV_8MA,
108 .pull = GPIOMUX_PULL_NONE,
109};
110
Rohit Vaswani09666872011-08-23 17:41:54 -0700111struct msm_gpiomux_config msm9615_gsbi_configs[] __initdata = {
112 {
Harini Jayaraman738c9312011-09-08 15:22:38 -0600113 .gpio = 8, /* GSBI3 QUP SPI_CLK */
114 .settings = {
115 [GPIOMUX_SUSPENDED] = &gsbi3,
116 },
117 },
118 {
119 .gpio = 9, /* GSBI3 QUP SPI_CS_N */
120 .settings = {
121 [GPIOMUX_SUSPENDED] = &gsbi3,
122 },
123 },
124 {
125 .gpio = 10, /* GSBI3 QUP SPI_DATA_MISO */
126 .settings = {
127 [GPIOMUX_SUSPENDED] = &gsbi3,
128 },
129 },
130 {
131 .gpio = 11, /* GSBI3 QUP SPI_DATA_MOSI */
132 .settings = {
133 [GPIOMUX_SUSPENDED] = &gsbi3,
134 },
135 },
136 {
Rohit Vaswani09666872011-08-23 17:41:54 -0700137 .gpio = 12, /* GSBI4 UART */
138 .settings = {
139 [GPIOMUX_SUSPENDED] = &gsbi4,
140 },
141 },
142 {
143 .gpio = 13, /* GSBI4 UART */
144 .settings = {
145 [GPIOMUX_SUSPENDED] = &gsbi4,
146 },
147 },
148 {
149 .gpio = 14, /* GSBI4 UART */
150 .settings = {
151 [GPIOMUX_SUSPENDED] = &gsbi4,
152 },
153 },
154 {
155 .gpio = 15, /* GSBI4 UART */
156 .settings = {
157 [GPIOMUX_SUSPENDED] = &gsbi4,
158 },
159 },
Harini Jayaramaneba52672011-09-08 15:13:00 -0600160 {
161 .gpio = 16, /* GSBI5 I2C QUP SCL */
162 .settings = {
163 [GPIOMUX_SUSPENDED] = &gsbi5,
164 },
165 },
166 {
167 .gpio = 17, /* GSBI5 I2C QUP SDA */
168 .settings = {
169 [GPIOMUX_SUSPENDED] = &gsbi5,
170 },
171 },
Harini Jayaraman738c9312011-09-08 15:22:38 -0600172 {
173 /* GPIO 19 can be used for I2C/UART on GSBI5 */
174 .gpio = 19, /* GSBI3 QUP SPI_CS_1 */
175 .settings = {
176 [GPIOMUX_SUSPENDED] = &gsbi3_cs1_config,
177 },
178 },
Rohit Vaswani09666872011-08-23 17:41:54 -0700179};
180
Krishna Kondadd794462011-10-01 00:19:29 -0700181#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
182 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT))
183
184#define GPIO_SDCARD_PWR_EN 18
185
186/* MDM9x15 have 2 SDCC controllers */
187enum sdcc_controllers {
188 SDCC1,
189 SDCC2,
190 MAX_SDCC_CONTROLLER
191};
192
193#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
194/* SDC1 pad data */
195static struct msm_mmc_pad_drv sdc1_pad_drv_on_cfg[] = {
196 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_16MA},
197 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_10MA},
198 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_10MA}
199};
200
201static struct msm_mmc_pad_drv sdc1_pad_drv_off_cfg[] = {
202 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_2MA},
203 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_2MA},
204 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_2MA}
205};
206
207static struct msm_mmc_pad_pull sdc1_pad_pull_on_cfg[] = {
208 {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL},
209 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_UP},
210 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_UP}
211};
212
213static struct msm_mmc_pad_pull sdc1_pad_pull_off_cfg[] = {
214 {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL},
215 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_DOWN},
216 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_DOWN}
217};
218
219static struct msm_mmc_pad_pull_data mmc_pad_pull_data[MAX_SDCC_CONTROLLER] = {
220 [SDCC1] = {
221 .on = sdc1_pad_pull_on_cfg,
222 .off = sdc1_pad_pull_off_cfg,
223 .size = ARRAY_SIZE(sdc1_pad_pull_on_cfg)
224 },
225};
226
227static struct msm_mmc_pad_drv_data mmc_pad_drv_data[MAX_SDCC_CONTROLLER] = {
228 [SDCC1] = {
229 .on = sdc1_pad_drv_on_cfg,
230 .off = sdc1_pad_drv_off_cfg,
231 .size = ARRAY_SIZE(sdc1_pad_drv_on_cfg)
232 },
233};
234
235static struct msm_mmc_pad_data mmc_pad_data[MAX_SDCC_CONTROLLER] = {
236 [SDCC1] = {
237 .pull = &mmc_pad_pull_data[SDCC1],
238 .drv = &mmc_pad_drv_data[SDCC1]
239 },
240};
241#endif
242
Krishna Konda71aef182011-10-01 02:27:51 -0700243#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
244static struct gpiomux_setting sdcc2_clk_actv_cfg = {
245 .func = GPIOMUX_FUNC_1,
246 .drv = GPIOMUX_DRV_16MA,
247 .pull = GPIOMUX_PULL_NONE,
248};
249
250static struct gpiomux_setting sdcc2_cmd_data_0_3_actv_cfg = {
251 .func = GPIOMUX_FUNC_1,
252 .drv = GPIOMUX_DRV_8MA,
253 .pull = GPIOMUX_PULL_UP,
254};
255
256static struct gpiomux_setting sdcc2_suspend_cfg = {
257 .func = GPIOMUX_FUNC_1,
258 .drv = GPIOMUX_DRV_2MA,
259 .pull = GPIOMUX_PULL_DOWN,
260};
261
262static struct msm_gpiomux_config msm9615_sdcc2_configs[] __initdata = {
263 {
264 /* SDC2_DATA_0 */
265 .gpio = 25,
266 .settings = {
267 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
268 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
269 },
270 },
271 {
272 /* SDC2_DATA_1 */
273 .gpio = 26,
274 .settings = {
275 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
276 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
277 },
278 },
279 {
280 /* SDC2_DATA_2 */
281 .gpio = 27,
282 .settings = {
283 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
284 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
285 },
286 },
287 {
288 /* SDC2_DATA_3 */
289 .gpio = 28,
290 .settings = {
291 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
292 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
293 },
294 },
295 {
296 /* SDC2_CMD GSBI1 */
297 .gpio = 29,
298 .settings = {
299 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
300 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
301 },
302 },
303 {
304 /* SDC2_CLK GSBI1 */
305 .gpio = 30,
306 .settings = {
307 [GPIOMUX_ACTIVE] = &sdcc2_clk_actv_cfg,
308 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
309 },
310 },
311};
312
313static struct msm_mmc_gpio sdc2_gpio_cfg[] = {
314 {25, "sdc2_dat_0"},
315 {26, "sdc2_dat_1"},
316 {27, "sdc2_dat_2"},
317 {28, "sdc2_dat_3"},
318 {29, "sdc2_cmd"},
319 {30, "sdc2_clk"},
320};
321
322static struct msm_mmc_gpio_data mmc_gpio_data[MAX_SDCC_CONTROLLER] = {
323 [SDCC2] = {
324 .gpio = sdc2_gpio_cfg,
325 .size = ARRAY_SIZE(sdc2_gpio_cfg),
326 },
327};
328#else
329static struct msm_gpiomux_config msm9615_sdcc2_configs[0];
330#endif
331
332static struct msm_mmc_pin_data mmc_slot_pin_data[MAX_SDCC_CONTROLLER] = {
Krishna Kondadd794462011-10-01 00:19:29 -0700333#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
334 [SDCC1] = {
335 .is_gpio = 0,
336 .pad_data = &mmc_pad_data[SDCC1],
337 },
338#endif
Krishna Konda71aef182011-10-01 02:27:51 -0700339#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
340 [SDCC2] = {
341 .is_gpio = 1,
342 .gpio_data = &mmc_gpio_data[SDCC2],
343 },
344#endif
Krishna Kondadd794462011-10-01 00:19:29 -0700345};
346
347#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
348static unsigned int sdc1_sup_clk_rates[] = {
349 400000, 24000000, 48000000
350};
351
352static struct mmc_platform_data sdc1_data = {
353 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
354 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
355 .sup_clk_table = sdc1_sup_clk_rates,
356 .sup_clk_cnt = ARRAY_SIZE(sdc1_sup_clk_rates),
357 .sdcc_v4_sup = true,
358 .pin_data = &mmc_slot_pin_data[SDCC1],
359};
360static struct mmc_platform_data *msm9615_sdc1_pdata = &sdc1_data;
361#else
362static struct mmc_platform_data *msm9615_sdc1_pdata;
363#endif
364
Krishna Konda71aef182011-10-01 02:27:51 -0700365#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
366static unsigned int sdc2_sup_clk_rates[] = {
367 400000, 24000000, 48000000
368};
369
370static struct mmc_platform_data sdc2_data = {
371 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
372 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
373 .sup_clk_table = sdc2_sup_clk_rates,
374 .sup_clk_cnt = ARRAY_SIZE(sdc2_sup_clk_rates),
375 .sdcc_v4_sup = true,
376 .pin_data = &mmc_slot_pin_data[SDCC2],
377};
378static struct mmc_platform_data *msm9615_sdc2_pdata = &sdc2_data;
379#else
380static struct mmc_platform_data *msm9615_sdc2_pdata;
381#endif
382
Krishna Kondadd794462011-10-01 00:19:29 -0700383static void __init msm9615_init_mmc(void)
384{
385 int ret;
386
387 if (msm9615_sdc1_pdata) {
388 ret = gpio_request(GPIO_SDCARD_PWR_EN, "SDCARD_PWR_EN");
389
390 if (ret) {
391 pr_err("%s: sdcc1: Error requesting GPIO "
392 "SDCARD_PWR_EN:%d\n", __func__, ret);
393 } else {
394 ret = gpio_direction_output(GPIO_SDCARD_PWR_EN, 1);
395 if (ret) {
396 pr_err("%s: sdcc1: Error setting o/p direction"
397 " for GPIO SDCARD_PWR_EN:%d\n",
398 __func__, ret);
399 gpio_free(GPIO_SDCARD_PWR_EN);
400 } else {
401 msm_add_sdcc(1, msm9615_sdc1_pdata);
402 }
403 }
404 }
Krishna Konda71aef182011-10-01 02:27:51 -0700405
406 if (msm9615_sdc2_pdata) {
407 msm_gpiomux_install(msm9615_sdcc2_configs,
408 ARRAY_SIZE(msm9615_sdcc2_configs));
409
410 /* SDC2: External card slot */
411 msm_add_sdcc(2, msm9615_sdc2_pdata);
412 }
Krishna Kondadd794462011-10-01 00:19:29 -0700413}
414#else
415static void __init msm9615_init_mmc(void) { }
416#endif
417
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700418static int __init gpiomux_init(void)
419{
420 int rc;
421
422 rc = msm_gpiomux_init(NR_GPIO_IRQS);
423 if (rc) {
424 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
425 return rc;
426 }
Rohit Vaswani09666872011-08-23 17:41:54 -0700427 msm_gpiomux_install(msm9615_gsbi_configs,
428 ARRAY_SIZE(msm9615_gsbi_configs));
429
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700430 return 0;
431}
432
Harini Jayaraman738c9312011-09-08 15:22:38 -0600433static struct msm_spi_platform_data msm9615_qup_spi_gsbi3_pdata = {
434 .max_clock_speed = 24000000,
435};
436
Harini Jayaramaneba52672011-09-08 15:13:00 -0600437static struct msm_i2c_platform_data msm9615_i2c_qup_gsbi5_pdata = {
438 .clk_freq = 100000,
439 .src_clk_rate = 24000000,
440};
441
442static void __init msm9615_i2c_init(void)
443{
444 msm9615_device_qup_i2c_gsbi5.dev.platform_data =
445 &msm9615_i2c_qup_gsbi5_pdata;
446}
447
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700448static void __init msm9615_common_init(void)
449{
450 msm9615_device_init();
451 gpiomux_init();
Harini Jayaramaneba52672011-09-08 15:13:00 -0600452 msm9615_i2c_init();
David Collins00b31e62011-08-31 20:00:10 -0700453 regulator_suppress_info_printing();
Harini Jayaraman738c9312011-09-08 15:22:38 -0600454 msm9615_device_qup_spi_gsbi3.dev.platform_data =
455 &msm9615_qup_spi_gsbi3_pdata;
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700456 msm9615_device_ssbi_pmic1.dev.platform_data =
457 &msm9615_ssbi_pm8018_pdata;
David Collins00b31e62011-08-31 20:00:10 -0700458 pm8018_platform_data.num_regulators = msm_pm8018_regulator_pdata_len;
Rohit Vaswani09666872011-08-23 17:41:54 -0700459 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Krishna Kondadd794462011-10-01 00:19:29 -0700460
461 msm9615_init_mmc();
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700462}
463
464static void __init msm9615_cdp_init(void)
465{
466 msm9615_common_init();
467}
468
469static void __init msm9615_mtp_init(void)
470{
471 msm9615_common_init();
472}
473
474MACHINE_START(MSM9615_CDP, "QCT MSM9615 CDP")
475 .map_io = msm9615_map_io,
476 .init_irq = msm9615_init_irq,
477 .timer = &msm_timer,
478 .init_machine = msm9615_cdp_init,
479MACHINE_END
480
481MACHINE_START(MSM9615_MTP, "QCT MSM9615 MTP")
482 .map_io = msm9615_map_io,
483 .init_irq = msm9615_init_irq,
484 .timer = &msm_timer,
485 .init_machine = msm9615_mtp_init,
486MACHINE_END