blob: 9238ab29adfd3c86c68e7b218b0abc942d693910 [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>
19#include <mach/board.h>
20#include <mach/msm_iomap.h>
21#include <mach/gpio.h>
22#include <mach/gpiomux.h>
Harini Jayaraman738c9312011-09-08 15:22:38 -060023#include <mach/msm_spi.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070024#include "timer.h"
25#include "devices.h"
David Collinsfb88c432011-08-25 15:12:47 -070026#include "board-9615.h"
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070027
Rohit Vaswani09666872011-08-23 17:41:54 -070028static struct platform_device *common_devices[] = {
29 &msm9615_device_uart_gsbi4,
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -070030 &msm9615_device_ssbi_pmic1,
Harini Jayaramaneba52672011-09-08 15:13:00 -060031 &msm9615_device_qup_i2c_gsbi5,
Harini Jayaraman738c9312011-09-08 15:22:38 -060032 &msm9615_device_qup_spi_gsbi3,
Rohit Vaswani09666872011-08-23 17:41:54 -070033};
34
David Collinsfb88c432011-08-25 15:12:47 -070035static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata __devinitdata = {
36 .irq_base = PM8018_IRQ_BASE,
37 .devirq = MSM_GPIO_TO_INT(87),
38 .irq_trigger_flag = IRQF_TRIGGER_LOW,
39};
40
41static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata __devinitdata = {
42 .gpio_base = PM8018_GPIO_PM_TO_SYS(1),
43};
44
45static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata __devinitdata = {
46 .mpp_base = PM8018_MPP_PM_TO_SYS(1),
47};
48
49static struct pm8xxx_rtc_platform_data pm8xxx_rtc_pdata __devinitdata = {
50 .rtc_write_enable = false,
51};
52
53static struct pm8xxx_pwrkey_platform_data pm8xxx_pwrkey_pdata = {
54 .pull_up = 1,
55 .kpd_trigger_delay_us = 970,
56 .wakeup = 1,
57};
58
59static struct pm8xxx_misc_platform_data pm8xxx_misc_pdata = {
60 .priority = 0,
61};
62
63static struct pm8018_platform_data pm8018_platform_data __devinitdata = {
64 .irq_pdata = &pm8xxx_irq_pdata,
65 .gpio_pdata = &pm8xxx_gpio_pdata,
66 .mpp_pdata = &pm8xxx_mpp_pdata,
67 .rtc_pdata = &pm8xxx_rtc_pdata,
68 .pwrkey_pdata = &pm8xxx_pwrkey_pdata,
69 .misc_pdata = &pm8xxx_misc_pdata,
70};
71
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -070072static struct msm_ssbi_platform_data msm9615_ssbi_pm8018_pdata __devinitdata = {
73 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
74 .slave = {
David Collinsfb88c432011-08-25 15:12:47 -070075 .name = PM8018_CORE_DEV_NAME,
76 .platform_data = &pm8018_platform_data,
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -070077 },
78};
79
Rohit Vaswani09666872011-08-23 17:41:54 -070080static struct gpiomux_setting gsbi4 = {
81 .func = GPIOMUX_FUNC_1,
82 .drv = GPIOMUX_DRV_8MA,
83 .pull = GPIOMUX_PULL_NONE,
84};
85
Harini Jayaramaneba52672011-09-08 15:13:00 -060086static struct gpiomux_setting gsbi5 = {
87 .func = GPIOMUX_FUNC_1,
88 .drv = GPIOMUX_DRV_8MA,
89 .pull = GPIOMUX_PULL_NONE,
90};
91
Harini Jayaraman738c9312011-09-08 15:22:38 -060092static struct gpiomux_setting gsbi3 = {
93 .func = GPIOMUX_FUNC_1,
94 .drv = GPIOMUX_DRV_8MA,
95 .pull = GPIOMUX_PULL_NONE,
96};
97
98static struct gpiomux_setting gsbi3_cs1_config = {
99 .func = GPIOMUX_FUNC_4,
100 .drv = GPIOMUX_DRV_8MA,
101 .pull = GPIOMUX_PULL_NONE,
102};
103
Rohit Vaswani09666872011-08-23 17:41:54 -0700104struct msm_gpiomux_config msm9615_gsbi_configs[] __initdata = {
105 {
Harini Jayaraman738c9312011-09-08 15:22:38 -0600106 .gpio = 8, /* GSBI3 QUP SPI_CLK */
107 .settings = {
108 [GPIOMUX_SUSPENDED] = &gsbi3,
109 },
110 },
111 {
112 .gpio = 9, /* GSBI3 QUP SPI_CS_N */
113 .settings = {
114 [GPIOMUX_SUSPENDED] = &gsbi3,
115 },
116 },
117 {
118 .gpio = 10, /* GSBI3 QUP SPI_DATA_MISO */
119 .settings = {
120 [GPIOMUX_SUSPENDED] = &gsbi3,
121 },
122 },
123 {
124 .gpio = 11, /* GSBI3 QUP SPI_DATA_MOSI */
125 .settings = {
126 [GPIOMUX_SUSPENDED] = &gsbi3,
127 },
128 },
129 {
Rohit Vaswani09666872011-08-23 17:41:54 -0700130 .gpio = 12, /* GSBI4 UART */
131 .settings = {
132 [GPIOMUX_SUSPENDED] = &gsbi4,
133 },
134 },
135 {
136 .gpio = 13, /* GSBI4 UART */
137 .settings = {
138 [GPIOMUX_SUSPENDED] = &gsbi4,
139 },
140 },
141 {
142 .gpio = 14, /* GSBI4 UART */
143 .settings = {
144 [GPIOMUX_SUSPENDED] = &gsbi4,
145 },
146 },
147 {
148 .gpio = 15, /* GSBI4 UART */
149 .settings = {
150 [GPIOMUX_SUSPENDED] = &gsbi4,
151 },
152 },
Harini Jayaramaneba52672011-09-08 15:13:00 -0600153 {
154 .gpio = 16, /* GSBI5 I2C QUP SCL */
155 .settings = {
156 [GPIOMUX_SUSPENDED] = &gsbi5,
157 },
158 },
159 {
160 .gpio = 17, /* GSBI5 I2C QUP SDA */
161 .settings = {
162 [GPIOMUX_SUSPENDED] = &gsbi5,
163 },
164 },
Harini Jayaraman738c9312011-09-08 15:22:38 -0600165 {
166 /* GPIO 19 can be used for I2C/UART on GSBI5 */
167 .gpio = 19, /* GSBI3 QUP SPI_CS_1 */
168 .settings = {
169 [GPIOMUX_SUSPENDED] = &gsbi3_cs1_config,
170 },
171 },
Rohit Vaswani09666872011-08-23 17:41:54 -0700172};
173
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700174static int __init gpiomux_init(void)
175{
176 int rc;
177
178 rc = msm_gpiomux_init(NR_GPIO_IRQS);
179 if (rc) {
180 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
181 return rc;
182 }
Rohit Vaswani09666872011-08-23 17:41:54 -0700183 msm_gpiomux_install(msm9615_gsbi_configs,
184 ARRAY_SIZE(msm9615_gsbi_configs));
185
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700186 return 0;
187}
188
Harini Jayaraman738c9312011-09-08 15:22:38 -0600189static struct msm_spi_platform_data msm9615_qup_spi_gsbi3_pdata = {
190 .max_clock_speed = 24000000,
191};
192
Harini Jayaramaneba52672011-09-08 15:13:00 -0600193static struct msm_i2c_platform_data msm9615_i2c_qup_gsbi5_pdata = {
194 .clk_freq = 100000,
195 .src_clk_rate = 24000000,
196};
197
198static void __init msm9615_i2c_init(void)
199{
200 msm9615_device_qup_i2c_gsbi5.dev.platform_data =
201 &msm9615_i2c_qup_gsbi5_pdata;
202}
203
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700204static void __init msm9615_common_init(void)
205{
206 msm9615_device_init();
207 gpiomux_init();
Harini Jayaramaneba52672011-09-08 15:13:00 -0600208 msm9615_i2c_init();
Harini Jayaraman738c9312011-09-08 15:22:38 -0600209 msm9615_device_qup_spi_gsbi3.dev.platform_data =
210 &msm9615_qup_spi_gsbi3_pdata;
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700211 msm9615_device_ssbi_pmic1.dev.platform_data =
212 &msm9615_ssbi_pm8018_pdata;
Rohit Vaswani09666872011-08-23 17:41:54 -0700213 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700214}
215
216static void __init msm9615_cdp_init(void)
217{
218 msm9615_common_init();
219}
220
221static void __init msm9615_mtp_init(void)
222{
223 msm9615_common_init();
224}
225
226MACHINE_START(MSM9615_CDP, "QCT MSM9615 CDP")
227 .map_io = msm9615_map_io,
228 .init_irq = msm9615_init_irq,
229 .timer = &msm_timer,
230 .init_machine = msm9615_cdp_init,
231MACHINE_END
232
233MACHINE_START(MSM9615_MTP, "QCT MSM9615 MTP")
234 .map_io = msm9615_map_io,
235 .init_irq = msm9615_init_irq,
236 .timer = &msm_timer,
237 .init_machine = msm9615_mtp_init,
238MACHINE_END