blob: 297b686d511a573646184ef9e9b58b1d8aeb62a0 [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[] = {
Jeff Ohlsteind19bf442011-09-09 12:48:18 -070029 &msm9615_device_dmov,
Rohit Vaswani09666872011-08-23 17:41:54 -070030 &msm9615_device_uart_gsbi4,
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -070031 &msm9615_device_ssbi_pmic1,
Harini Jayaramaneba52672011-09-08 15:13:00 -060032 &msm9615_device_qup_i2c_gsbi5,
Harini Jayaraman738c9312011-09-08 15:22:38 -060033 &msm9615_device_qup_spi_gsbi3,
Yan He092b7272011-09-21 15:25:03 -070034 &msm_device_sps,
Rohit Vaswani09666872011-08-23 17:41:54 -070035};
36
David Collinsfb88c432011-08-25 15:12:47 -070037static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata __devinitdata = {
38 .irq_base = PM8018_IRQ_BASE,
39 .devirq = MSM_GPIO_TO_INT(87),
40 .irq_trigger_flag = IRQF_TRIGGER_LOW,
41};
42
43static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata __devinitdata = {
44 .gpio_base = PM8018_GPIO_PM_TO_SYS(1),
45};
46
47static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata __devinitdata = {
48 .mpp_base = PM8018_MPP_PM_TO_SYS(1),
49};
50
51static struct pm8xxx_rtc_platform_data pm8xxx_rtc_pdata __devinitdata = {
52 .rtc_write_enable = false,
53};
54
55static struct pm8xxx_pwrkey_platform_data pm8xxx_pwrkey_pdata = {
56 .pull_up = 1,
57 .kpd_trigger_delay_us = 970,
58 .wakeup = 1,
59};
60
61static struct pm8xxx_misc_platform_data pm8xxx_misc_pdata = {
62 .priority = 0,
63};
64
65static struct pm8018_platform_data pm8018_platform_data __devinitdata = {
66 .irq_pdata = &pm8xxx_irq_pdata,
67 .gpio_pdata = &pm8xxx_gpio_pdata,
68 .mpp_pdata = &pm8xxx_mpp_pdata,
69 .rtc_pdata = &pm8xxx_rtc_pdata,
70 .pwrkey_pdata = &pm8xxx_pwrkey_pdata,
71 .misc_pdata = &pm8xxx_misc_pdata,
David Collins00b31e62011-08-31 20:00:10 -070072 .regulator_pdatas = msm_pm8018_regulator_pdata,
David Collinsfb88c432011-08-25 15:12:47 -070073};
74
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -070075static struct msm_ssbi_platform_data msm9615_ssbi_pm8018_pdata __devinitdata = {
76 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
77 .slave = {
David Collinsfb88c432011-08-25 15:12:47 -070078 .name = PM8018_CORE_DEV_NAME,
79 .platform_data = &pm8018_platform_data,
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -070080 },
81};
82
Rohit Vaswani09666872011-08-23 17:41:54 -070083static struct gpiomux_setting gsbi4 = {
84 .func = GPIOMUX_FUNC_1,
85 .drv = GPIOMUX_DRV_8MA,
86 .pull = GPIOMUX_PULL_NONE,
87};
88
Harini Jayaramaneba52672011-09-08 15:13:00 -060089static struct gpiomux_setting gsbi5 = {
90 .func = GPIOMUX_FUNC_1,
91 .drv = GPIOMUX_DRV_8MA,
92 .pull = GPIOMUX_PULL_NONE,
93};
94
Harini Jayaraman738c9312011-09-08 15:22:38 -060095static struct gpiomux_setting gsbi3 = {
96 .func = GPIOMUX_FUNC_1,
97 .drv = GPIOMUX_DRV_8MA,
98 .pull = GPIOMUX_PULL_NONE,
99};
100
101static struct gpiomux_setting gsbi3_cs1_config = {
102 .func = GPIOMUX_FUNC_4,
103 .drv = GPIOMUX_DRV_8MA,
104 .pull = GPIOMUX_PULL_NONE,
105};
106
Rohit Vaswani09666872011-08-23 17:41:54 -0700107struct msm_gpiomux_config msm9615_gsbi_configs[] __initdata = {
108 {
Harini Jayaraman738c9312011-09-08 15:22:38 -0600109 .gpio = 8, /* GSBI3 QUP SPI_CLK */
110 .settings = {
111 [GPIOMUX_SUSPENDED] = &gsbi3,
112 },
113 },
114 {
115 .gpio = 9, /* GSBI3 QUP SPI_CS_N */
116 .settings = {
117 [GPIOMUX_SUSPENDED] = &gsbi3,
118 },
119 },
120 {
121 .gpio = 10, /* GSBI3 QUP SPI_DATA_MISO */
122 .settings = {
123 [GPIOMUX_SUSPENDED] = &gsbi3,
124 },
125 },
126 {
127 .gpio = 11, /* GSBI3 QUP SPI_DATA_MOSI */
128 .settings = {
129 [GPIOMUX_SUSPENDED] = &gsbi3,
130 },
131 },
132 {
Rohit Vaswani09666872011-08-23 17:41:54 -0700133 .gpio = 12, /* GSBI4 UART */
134 .settings = {
135 [GPIOMUX_SUSPENDED] = &gsbi4,
136 },
137 },
138 {
139 .gpio = 13, /* GSBI4 UART */
140 .settings = {
141 [GPIOMUX_SUSPENDED] = &gsbi4,
142 },
143 },
144 {
145 .gpio = 14, /* GSBI4 UART */
146 .settings = {
147 [GPIOMUX_SUSPENDED] = &gsbi4,
148 },
149 },
150 {
151 .gpio = 15, /* GSBI4 UART */
152 .settings = {
153 [GPIOMUX_SUSPENDED] = &gsbi4,
154 },
155 },
Harini Jayaramaneba52672011-09-08 15:13:00 -0600156 {
157 .gpio = 16, /* GSBI5 I2C QUP SCL */
158 .settings = {
159 [GPIOMUX_SUSPENDED] = &gsbi5,
160 },
161 },
162 {
163 .gpio = 17, /* GSBI5 I2C QUP SDA */
164 .settings = {
165 [GPIOMUX_SUSPENDED] = &gsbi5,
166 },
167 },
Harini Jayaraman738c9312011-09-08 15:22:38 -0600168 {
169 /* GPIO 19 can be used for I2C/UART on GSBI5 */
170 .gpio = 19, /* GSBI3 QUP SPI_CS_1 */
171 .settings = {
172 [GPIOMUX_SUSPENDED] = &gsbi3_cs1_config,
173 },
174 },
Rohit Vaswani09666872011-08-23 17:41:54 -0700175};
176
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700177static int __init gpiomux_init(void)
178{
179 int rc;
180
181 rc = msm_gpiomux_init(NR_GPIO_IRQS);
182 if (rc) {
183 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
184 return rc;
185 }
Rohit Vaswani09666872011-08-23 17:41:54 -0700186 msm_gpiomux_install(msm9615_gsbi_configs,
187 ARRAY_SIZE(msm9615_gsbi_configs));
188
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700189 return 0;
190}
191
Harini Jayaraman738c9312011-09-08 15:22:38 -0600192static struct msm_spi_platform_data msm9615_qup_spi_gsbi3_pdata = {
193 .max_clock_speed = 24000000,
194};
195
Harini Jayaramaneba52672011-09-08 15:13:00 -0600196static struct msm_i2c_platform_data msm9615_i2c_qup_gsbi5_pdata = {
197 .clk_freq = 100000,
198 .src_clk_rate = 24000000,
199};
200
201static void __init msm9615_i2c_init(void)
202{
203 msm9615_device_qup_i2c_gsbi5.dev.platform_data =
204 &msm9615_i2c_qup_gsbi5_pdata;
205}
206
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700207static void __init msm9615_common_init(void)
208{
209 msm9615_device_init();
210 gpiomux_init();
Harini Jayaramaneba52672011-09-08 15:13:00 -0600211 msm9615_i2c_init();
David Collins00b31e62011-08-31 20:00:10 -0700212 regulator_suppress_info_printing();
Harini Jayaraman738c9312011-09-08 15:22:38 -0600213 msm9615_device_qup_spi_gsbi3.dev.platform_data =
214 &msm9615_qup_spi_gsbi3_pdata;
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700215 msm9615_device_ssbi_pmic1.dev.platform_data =
216 &msm9615_ssbi_pm8018_pdata;
David Collins00b31e62011-08-31 20:00:10 -0700217 pm8018_platform_data.num_regulators = msm_pm8018_regulator_pdata_len;
Rohit Vaswani09666872011-08-23 17:41:54 -0700218 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700219}
220
221static void __init msm9615_cdp_init(void)
222{
223 msm9615_common_init();
224}
225
226static void __init msm9615_mtp_init(void)
227{
228 msm9615_common_init();
229}
230
231MACHINE_START(MSM9615_CDP, "QCT MSM9615 CDP")
232 .map_io = msm9615_map_io,
233 .init_irq = msm9615_init_irq,
234 .timer = &msm_timer,
235 .init_machine = msm9615_cdp_init,
236MACHINE_END
237
238MACHINE_START(MSM9615_MTP, "QCT MSM9615 MTP")
239 .map_io = msm9615_map_io,
240 .init_irq = msm9615_init_irq,
241 .timer = &msm_timer,
242 .init_machine = msm9615_mtp_init,
243MACHINE_END