blob: ed93c3a868dc6f3943fcb8338ad053c315016719 [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,
Praveen Chidambaramab3b1c42011-08-25 08:44:05 -060039 &msm_rpm_device,
Rohit Vaswani09666872011-08-23 17:41:54 -070040};
41
David Collinsfb88c432011-08-25 15:12:47 -070042static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata __devinitdata = {
43 .irq_base = PM8018_IRQ_BASE,
44 .devirq = MSM_GPIO_TO_INT(87),
45 .irq_trigger_flag = IRQF_TRIGGER_LOW,
46};
47
48static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata __devinitdata = {
49 .gpio_base = PM8018_GPIO_PM_TO_SYS(1),
50};
51
52static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata __devinitdata = {
53 .mpp_base = PM8018_MPP_PM_TO_SYS(1),
54};
55
56static struct pm8xxx_rtc_platform_data pm8xxx_rtc_pdata __devinitdata = {
57 .rtc_write_enable = false,
58};
59
60static struct pm8xxx_pwrkey_platform_data pm8xxx_pwrkey_pdata = {
61 .pull_up = 1,
62 .kpd_trigger_delay_us = 970,
63 .wakeup = 1,
64};
65
66static struct pm8xxx_misc_platform_data pm8xxx_misc_pdata = {
67 .priority = 0,
68};
69
70static struct pm8018_platform_data pm8018_platform_data __devinitdata = {
71 .irq_pdata = &pm8xxx_irq_pdata,
72 .gpio_pdata = &pm8xxx_gpio_pdata,
73 .mpp_pdata = &pm8xxx_mpp_pdata,
74 .rtc_pdata = &pm8xxx_rtc_pdata,
75 .pwrkey_pdata = &pm8xxx_pwrkey_pdata,
76 .misc_pdata = &pm8xxx_misc_pdata,
David Collins00b31e62011-08-31 20:00:10 -070077 .regulator_pdatas = msm_pm8018_regulator_pdata,
David Collinsfb88c432011-08-25 15:12:47 -070078};
79
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -070080static struct msm_ssbi_platform_data msm9615_ssbi_pm8018_pdata __devinitdata = {
81 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
82 .slave = {
David Collinsfb88c432011-08-25 15:12:47 -070083 .name = PM8018_CORE_DEV_NAME,
84 .platform_data = &pm8018_platform_data,
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -070085 },
86};
87
Rohit Vaswani09666872011-08-23 17:41:54 -070088static struct gpiomux_setting gsbi4 = {
89 .func = GPIOMUX_FUNC_1,
90 .drv = GPIOMUX_DRV_8MA,
91 .pull = GPIOMUX_PULL_NONE,
92};
93
Harini Jayaramaneba52672011-09-08 15:13:00 -060094static struct gpiomux_setting gsbi5 = {
95 .func = GPIOMUX_FUNC_1,
96 .drv = GPIOMUX_DRV_8MA,
97 .pull = GPIOMUX_PULL_NONE,
98};
99
Harini Jayaraman738c9312011-09-08 15:22:38 -0600100static struct gpiomux_setting gsbi3 = {
101 .func = GPIOMUX_FUNC_1,
102 .drv = GPIOMUX_DRV_8MA,
103 .pull = GPIOMUX_PULL_NONE,
104};
105
106static struct gpiomux_setting gsbi3_cs1_config = {
107 .func = GPIOMUX_FUNC_4,
108 .drv = GPIOMUX_DRV_8MA,
109 .pull = GPIOMUX_PULL_NONE,
110};
111
Rohit Vaswani09666872011-08-23 17:41:54 -0700112struct msm_gpiomux_config msm9615_gsbi_configs[] __initdata = {
113 {
Harini Jayaraman738c9312011-09-08 15:22:38 -0600114 .gpio = 8, /* GSBI3 QUP SPI_CLK */
115 .settings = {
116 [GPIOMUX_SUSPENDED] = &gsbi3,
117 },
118 },
119 {
120 .gpio = 9, /* GSBI3 QUP SPI_CS_N */
121 .settings = {
122 [GPIOMUX_SUSPENDED] = &gsbi3,
123 },
124 },
125 {
126 .gpio = 10, /* GSBI3 QUP SPI_DATA_MISO */
127 .settings = {
128 [GPIOMUX_SUSPENDED] = &gsbi3,
129 },
130 },
131 {
132 .gpio = 11, /* GSBI3 QUP SPI_DATA_MOSI */
133 .settings = {
134 [GPIOMUX_SUSPENDED] = &gsbi3,
135 },
136 },
137 {
Rohit Vaswani09666872011-08-23 17:41:54 -0700138 .gpio = 12, /* GSBI4 UART */
139 .settings = {
140 [GPIOMUX_SUSPENDED] = &gsbi4,
141 },
142 },
143 {
144 .gpio = 13, /* GSBI4 UART */
145 .settings = {
146 [GPIOMUX_SUSPENDED] = &gsbi4,
147 },
148 },
149 {
150 .gpio = 14, /* GSBI4 UART */
151 .settings = {
152 [GPIOMUX_SUSPENDED] = &gsbi4,
153 },
154 },
155 {
156 .gpio = 15, /* GSBI4 UART */
157 .settings = {
158 [GPIOMUX_SUSPENDED] = &gsbi4,
159 },
160 },
Harini Jayaramaneba52672011-09-08 15:13:00 -0600161 {
162 .gpio = 16, /* GSBI5 I2C QUP SCL */
163 .settings = {
164 [GPIOMUX_SUSPENDED] = &gsbi5,
165 },
166 },
167 {
168 .gpio = 17, /* GSBI5 I2C QUP SDA */
169 .settings = {
170 [GPIOMUX_SUSPENDED] = &gsbi5,
171 },
172 },
Harini Jayaraman738c9312011-09-08 15:22:38 -0600173 {
174 /* GPIO 19 can be used for I2C/UART on GSBI5 */
175 .gpio = 19, /* GSBI3 QUP SPI_CS_1 */
176 .settings = {
177 [GPIOMUX_SUSPENDED] = &gsbi3_cs1_config,
178 },
179 },
Rohit Vaswani09666872011-08-23 17:41:54 -0700180};
181
Krishna Kondadd794462011-10-01 00:19:29 -0700182#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
183 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT))
184
185#define GPIO_SDCARD_PWR_EN 18
186
187/* MDM9x15 have 2 SDCC controllers */
188enum sdcc_controllers {
189 SDCC1,
190 SDCC2,
191 MAX_SDCC_CONTROLLER
192};
193
194#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
195/* SDC1 pad data */
196static struct msm_mmc_pad_drv sdc1_pad_drv_on_cfg[] = {
197 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_16MA},
198 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_10MA},
199 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_10MA}
200};
201
202static struct msm_mmc_pad_drv sdc1_pad_drv_off_cfg[] = {
203 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_2MA},
204 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_2MA},
205 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_2MA}
206};
207
208static struct msm_mmc_pad_pull sdc1_pad_pull_on_cfg[] = {
209 {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL},
210 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_UP},
211 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_UP}
212};
213
214static struct msm_mmc_pad_pull sdc1_pad_pull_off_cfg[] = {
215 {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL},
216 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_DOWN},
217 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_DOWN}
218};
219
220static struct msm_mmc_pad_pull_data mmc_pad_pull_data[MAX_SDCC_CONTROLLER] = {
221 [SDCC1] = {
222 .on = sdc1_pad_pull_on_cfg,
223 .off = sdc1_pad_pull_off_cfg,
224 .size = ARRAY_SIZE(sdc1_pad_pull_on_cfg)
225 },
226};
227
228static struct msm_mmc_pad_drv_data mmc_pad_drv_data[MAX_SDCC_CONTROLLER] = {
229 [SDCC1] = {
230 .on = sdc1_pad_drv_on_cfg,
231 .off = sdc1_pad_drv_off_cfg,
232 .size = ARRAY_SIZE(sdc1_pad_drv_on_cfg)
233 },
234};
235
236static struct msm_mmc_pad_data mmc_pad_data[MAX_SDCC_CONTROLLER] = {
237 [SDCC1] = {
238 .pull = &mmc_pad_pull_data[SDCC1],
239 .drv = &mmc_pad_drv_data[SDCC1]
240 },
241};
242#endif
243
Krishna Konda71aef182011-10-01 02:27:51 -0700244#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
245static struct gpiomux_setting sdcc2_clk_actv_cfg = {
246 .func = GPIOMUX_FUNC_1,
247 .drv = GPIOMUX_DRV_16MA,
248 .pull = GPIOMUX_PULL_NONE,
249};
250
251static struct gpiomux_setting sdcc2_cmd_data_0_3_actv_cfg = {
252 .func = GPIOMUX_FUNC_1,
253 .drv = GPIOMUX_DRV_8MA,
254 .pull = GPIOMUX_PULL_UP,
255};
256
257static struct gpiomux_setting sdcc2_suspend_cfg = {
258 .func = GPIOMUX_FUNC_1,
259 .drv = GPIOMUX_DRV_2MA,
260 .pull = GPIOMUX_PULL_DOWN,
261};
262
263static struct msm_gpiomux_config msm9615_sdcc2_configs[] __initdata = {
264 {
265 /* SDC2_DATA_0 */
266 .gpio = 25,
267 .settings = {
268 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
269 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
270 },
271 },
272 {
273 /* SDC2_DATA_1 */
274 .gpio = 26,
275 .settings = {
276 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
277 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
278 },
279 },
280 {
281 /* SDC2_DATA_2 */
282 .gpio = 27,
283 .settings = {
284 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
285 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
286 },
287 },
288 {
289 /* SDC2_DATA_3 */
290 .gpio = 28,
291 .settings = {
292 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
293 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
294 },
295 },
296 {
297 /* SDC2_CMD GSBI1 */
298 .gpio = 29,
299 .settings = {
300 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
301 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
302 },
303 },
304 {
305 /* SDC2_CLK GSBI1 */
306 .gpio = 30,
307 .settings = {
308 [GPIOMUX_ACTIVE] = &sdcc2_clk_actv_cfg,
309 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
310 },
311 },
312};
313
314static struct msm_mmc_gpio sdc2_gpio_cfg[] = {
315 {25, "sdc2_dat_0"},
316 {26, "sdc2_dat_1"},
317 {27, "sdc2_dat_2"},
318 {28, "sdc2_dat_3"},
319 {29, "sdc2_cmd"},
320 {30, "sdc2_clk"},
321};
322
323static struct msm_mmc_gpio_data mmc_gpio_data[MAX_SDCC_CONTROLLER] = {
324 [SDCC2] = {
325 .gpio = sdc2_gpio_cfg,
326 .size = ARRAY_SIZE(sdc2_gpio_cfg),
327 },
328};
329#else
330static struct msm_gpiomux_config msm9615_sdcc2_configs[0];
331#endif
332
333static struct msm_mmc_pin_data mmc_slot_pin_data[MAX_SDCC_CONTROLLER] = {
Krishna Kondadd794462011-10-01 00:19:29 -0700334#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
335 [SDCC1] = {
336 .is_gpio = 0,
337 .pad_data = &mmc_pad_data[SDCC1],
338 },
339#endif
Krishna Konda71aef182011-10-01 02:27:51 -0700340#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
341 [SDCC2] = {
342 .is_gpio = 1,
343 .gpio_data = &mmc_gpio_data[SDCC2],
344 },
345#endif
Krishna Kondadd794462011-10-01 00:19:29 -0700346};
347
348#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
349static unsigned int sdc1_sup_clk_rates[] = {
350 400000, 24000000, 48000000
351};
352
353static struct mmc_platform_data sdc1_data = {
354 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
355 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
356 .sup_clk_table = sdc1_sup_clk_rates,
357 .sup_clk_cnt = ARRAY_SIZE(sdc1_sup_clk_rates),
358 .sdcc_v4_sup = true,
359 .pin_data = &mmc_slot_pin_data[SDCC1],
360};
361static struct mmc_platform_data *msm9615_sdc1_pdata = &sdc1_data;
362#else
363static struct mmc_platform_data *msm9615_sdc1_pdata;
364#endif
365
Krishna Konda71aef182011-10-01 02:27:51 -0700366#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
367static unsigned int sdc2_sup_clk_rates[] = {
368 400000, 24000000, 48000000
369};
370
371static struct mmc_platform_data sdc2_data = {
372 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
373 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
374 .sup_clk_table = sdc2_sup_clk_rates,
375 .sup_clk_cnt = ARRAY_SIZE(sdc2_sup_clk_rates),
376 .sdcc_v4_sup = true,
377 .pin_data = &mmc_slot_pin_data[SDCC2],
378};
379static struct mmc_platform_data *msm9615_sdc2_pdata = &sdc2_data;
380#else
381static struct mmc_platform_data *msm9615_sdc2_pdata;
382#endif
383
Krishna Kondadd794462011-10-01 00:19:29 -0700384static void __init msm9615_init_mmc(void)
385{
386 int ret;
387
388 if (msm9615_sdc1_pdata) {
389 ret = gpio_request(GPIO_SDCARD_PWR_EN, "SDCARD_PWR_EN");
390
391 if (ret) {
392 pr_err("%s: sdcc1: Error requesting GPIO "
393 "SDCARD_PWR_EN:%d\n", __func__, ret);
394 } else {
395 ret = gpio_direction_output(GPIO_SDCARD_PWR_EN, 1);
396 if (ret) {
397 pr_err("%s: sdcc1: Error setting o/p direction"
398 " for GPIO SDCARD_PWR_EN:%d\n",
399 __func__, ret);
400 gpio_free(GPIO_SDCARD_PWR_EN);
401 } else {
402 msm_add_sdcc(1, msm9615_sdc1_pdata);
403 }
404 }
405 }
Krishna Konda71aef182011-10-01 02:27:51 -0700406
407 if (msm9615_sdc2_pdata) {
408 msm_gpiomux_install(msm9615_sdcc2_configs,
409 ARRAY_SIZE(msm9615_sdcc2_configs));
410
411 /* SDC2: External card slot */
412 msm_add_sdcc(2, msm9615_sdc2_pdata);
413 }
Krishna Kondadd794462011-10-01 00:19:29 -0700414}
415#else
416static void __init msm9615_init_mmc(void) { }
417#endif
418
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700419static int __init gpiomux_init(void)
420{
421 int rc;
422
423 rc = msm_gpiomux_init(NR_GPIO_IRQS);
424 if (rc) {
425 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
426 return rc;
427 }
Rohit Vaswani09666872011-08-23 17:41:54 -0700428 msm_gpiomux_install(msm9615_gsbi_configs,
429 ARRAY_SIZE(msm9615_gsbi_configs));
430
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700431 return 0;
432}
433
Harini Jayaraman738c9312011-09-08 15:22:38 -0600434static struct msm_spi_platform_data msm9615_qup_spi_gsbi3_pdata = {
435 .max_clock_speed = 24000000,
436};
437
Harini Jayaramaneba52672011-09-08 15:13:00 -0600438static struct msm_i2c_platform_data msm9615_i2c_qup_gsbi5_pdata = {
439 .clk_freq = 100000,
440 .src_clk_rate = 24000000,
441};
442
443static void __init msm9615_i2c_init(void)
444{
445 msm9615_device_qup_i2c_gsbi5.dev.platform_data =
446 &msm9615_i2c_qup_gsbi5_pdata;
447}
448
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700449static void __init msm9615_common_init(void)
450{
451 msm9615_device_init();
452 gpiomux_init();
Harini Jayaramaneba52672011-09-08 15:13:00 -0600453 msm9615_i2c_init();
David Collins00b31e62011-08-31 20:00:10 -0700454 regulator_suppress_info_printing();
Harini Jayaraman738c9312011-09-08 15:22:38 -0600455 msm9615_device_qup_spi_gsbi3.dev.platform_data =
456 &msm9615_qup_spi_gsbi3_pdata;
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700457 msm9615_device_ssbi_pmic1.dev.platform_data =
458 &msm9615_ssbi_pm8018_pdata;
David Collins00b31e62011-08-31 20:00:10 -0700459 pm8018_platform_data.num_regulators = msm_pm8018_regulator_pdata_len;
Rohit Vaswani09666872011-08-23 17:41:54 -0700460 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Krishna Kondadd794462011-10-01 00:19:29 -0700461
462 msm9615_init_mmc();
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700463}
464
465static void __init msm9615_cdp_init(void)
466{
467 msm9615_common_init();
468}
469
470static void __init msm9615_mtp_init(void)
471{
472 msm9615_common_init();
473}
474
475MACHINE_START(MSM9615_CDP, "QCT MSM9615 CDP")
476 .map_io = msm9615_map_io,
477 .init_irq = msm9615_init_irq,
478 .timer = &msm_timer,
479 .init_machine = msm9615_cdp_init,
480MACHINE_END
481
482MACHINE_START(MSM9615_MTP, "QCT MSM9615 MTP")
483 .map_io = msm9615_map_io,
484 .init_irq = msm9615_init_irq,
485 .timer = &msm_timer,
486 .init_machine = msm9615_mtp_init,
487MACHINE_END