blob: d60b6cacc15f89d8128661a11ff37205a68795b9 [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,
Siddartha Mohanadoss5d49cec2011-09-21 10:26:15 -070035 &msm9615_device_tsens,
Rohit Vaswani09666872011-08-23 17:41:54 -070036};
37
David Collinsfb88c432011-08-25 15:12:47 -070038static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata __devinitdata = {
39 .irq_base = PM8018_IRQ_BASE,
40 .devirq = MSM_GPIO_TO_INT(87),
41 .irq_trigger_flag = IRQF_TRIGGER_LOW,
42};
43
44static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata __devinitdata = {
45 .gpio_base = PM8018_GPIO_PM_TO_SYS(1),
46};
47
48static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata __devinitdata = {
49 .mpp_base = PM8018_MPP_PM_TO_SYS(1),
50};
51
52static struct pm8xxx_rtc_platform_data pm8xxx_rtc_pdata __devinitdata = {
53 .rtc_write_enable = false,
54};
55
56static struct pm8xxx_pwrkey_platform_data pm8xxx_pwrkey_pdata = {
57 .pull_up = 1,
58 .kpd_trigger_delay_us = 970,
59 .wakeup = 1,
60};
61
62static struct pm8xxx_misc_platform_data pm8xxx_misc_pdata = {
63 .priority = 0,
64};
65
66static struct pm8018_platform_data pm8018_platform_data __devinitdata = {
67 .irq_pdata = &pm8xxx_irq_pdata,
68 .gpio_pdata = &pm8xxx_gpio_pdata,
69 .mpp_pdata = &pm8xxx_mpp_pdata,
70 .rtc_pdata = &pm8xxx_rtc_pdata,
71 .pwrkey_pdata = &pm8xxx_pwrkey_pdata,
72 .misc_pdata = &pm8xxx_misc_pdata,
David Collins00b31e62011-08-31 20:00:10 -070073 .regulator_pdatas = msm_pm8018_regulator_pdata,
David Collinsfb88c432011-08-25 15:12:47 -070074};
75
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -070076static struct msm_ssbi_platform_data msm9615_ssbi_pm8018_pdata __devinitdata = {
77 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
78 .slave = {
David Collinsfb88c432011-08-25 15:12:47 -070079 .name = PM8018_CORE_DEV_NAME,
80 .platform_data = &pm8018_platform_data,
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -070081 },
82};
83
Rohit Vaswani09666872011-08-23 17:41:54 -070084static struct gpiomux_setting gsbi4 = {
85 .func = GPIOMUX_FUNC_1,
86 .drv = GPIOMUX_DRV_8MA,
87 .pull = GPIOMUX_PULL_NONE,
88};
89
Harini Jayaramaneba52672011-09-08 15:13:00 -060090static struct gpiomux_setting gsbi5 = {
91 .func = GPIOMUX_FUNC_1,
92 .drv = GPIOMUX_DRV_8MA,
93 .pull = GPIOMUX_PULL_NONE,
94};
95
Harini Jayaraman738c9312011-09-08 15:22:38 -060096static struct gpiomux_setting gsbi3 = {
97 .func = GPIOMUX_FUNC_1,
98 .drv = GPIOMUX_DRV_8MA,
99 .pull = GPIOMUX_PULL_NONE,
100};
101
102static struct gpiomux_setting gsbi3_cs1_config = {
103 .func = GPIOMUX_FUNC_4,
104 .drv = GPIOMUX_DRV_8MA,
105 .pull = GPIOMUX_PULL_NONE,
106};
107
Rohit Vaswani09666872011-08-23 17:41:54 -0700108struct msm_gpiomux_config msm9615_gsbi_configs[] __initdata = {
109 {
Harini Jayaraman738c9312011-09-08 15:22:38 -0600110 .gpio = 8, /* GSBI3 QUP SPI_CLK */
111 .settings = {
112 [GPIOMUX_SUSPENDED] = &gsbi3,
113 },
114 },
115 {
116 .gpio = 9, /* GSBI3 QUP SPI_CS_N */
117 .settings = {
118 [GPIOMUX_SUSPENDED] = &gsbi3,
119 },
120 },
121 {
122 .gpio = 10, /* GSBI3 QUP SPI_DATA_MISO */
123 .settings = {
124 [GPIOMUX_SUSPENDED] = &gsbi3,
125 },
126 },
127 {
128 .gpio = 11, /* GSBI3 QUP SPI_DATA_MOSI */
129 .settings = {
130 [GPIOMUX_SUSPENDED] = &gsbi3,
131 },
132 },
133 {
Rohit Vaswani09666872011-08-23 17:41:54 -0700134 .gpio = 12, /* GSBI4 UART */
135 .settings = {
136 [GPIOMUX_SUSPENDED] = &gsbi4,
137 },
138 },
139 {
140 .gpio = 13, /* GSBI4 UART */
141 .settings = {
142 [GPIOMUX_SUSPENDED] = &gsbi4,
143 },
144 },
145 {
146 .gpio = 14, /* GSBI4 UART */
147 .settings = {
148 [GPIOMUX_SUSPENDED] = &gsbi4,
149 },
150 },
151 {
152 .gpio = 15, /* GSBI4 UART */
153 .settings = {
154 [GPIOMUX_SUSPENDED] = &gsbi4,
155 },
156 },
Harini Jayaramaneba52672011-09-08 15:13:00 -0600157 {
158 .gpio = 16, /* GSBI5 I2C QUP SCL */
159 .settings = {
160 [GPIOMUX_SUSPENDED] = &gsbi5,
161 },
162 },
163 {
164 .gpio = 17, /* GSBI5 I2C QUP SDA */
165 .settings = {
166 [GPIOMUX_SUSPENDED] = &gsbi5,
167 },
168 },
Harini Jayaraman738c9312011-09-08 15:22:38 -0600169 {
170 /* GPIO 19 can be used for I2C/UART on GSBI5 */
171 .gpio = 19, /* GSBI3 QUP SPI_CS_1 */
172 .settings = {
173 [GPIOMUX_SUSPENDED] = &gsbi3_cs1_config,
174 },
175 },
Rohit Vaswani09666872011-08-23 17:41:54 -0700176};
177
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700178static int __init gpiomux_init(void)
179{
180 int rc;
181
182 rc = msm_gpiomux_init(NR_GPIO_IRQS);
183 if (rc) {
184 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
185 return rc;
186 }
Rohit Vaswani09666872011-08-23 17:41:54 -0700187 msm_gpiomux_install(msm9615_gsbi_configs,
188 ARRAY_SIZE(msm9615_gsbi_configs));
189
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700190 return 0;
191}
192
Harini Jayaraman738c9312011-09-08 15:22:38 -0600193static struct msm_spi_platform_data msm9615_qup_spi_gsbi3_pdata = {
194 .max_clock_speed = 24000000,
195};
196
Harini Jayaramaneba52672011-09-08 15:13:00 -0600197static struct msm_i2c_platform_data msm9615_i2c_qup_gsbi5_pdata = {
198 .clk_freq = 100000,
199 .src_clk_rate = 24000000,
200};
201
202static void __init msm9615_i2c_init(void)
203{
204 msm9615_device_qup_i2c_gsbi5.dev.platform_data =
205 &msm9615_i2c_qup_gsbi5_pdata;
206}
207
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700208static void __init msm9615_common_init(void)
209{
210 msm9615_device_init();
211 gpiomux_init();
Harini Jayaramaneba52672011-09-08 15:13:00 -0600212 msm9615_i2c_init();
David Collins00b31e62011-08-31 20:00:10 -0700213 regulator_suppress_info_printing();
Harini Jayaraman738c9312011-09-08 15:22:38 -0600214 msm9615_device_qup_spi_gsbi3.dev.platform_data =
215 &msm9615_qup_spi_gsbi3_pdata;
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700216 msm9615_device_ssbi_pmic1.dev.platform_data =
217 &msm9615_ssbi_pm8018_pdata;
David Collins00b31e62011-08-31 20:00:10 -0700218 pm8018_platform_data.num_regulators = msm_pm8018_regulator_pdata_len;
Rohit Vaswani09666872011-08-23 17:41:54 -0700219 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700220}
221
222static void __init msm9615_cdp_init(void)
223{
224 msm9615_common_init();
225}
226
227static void __init msm9615_mtp_init(void)
228{
229 msm9615_common_init();
230}
231
232MACHINE_START(MSM9615_CDP, "QCT MSM9615 CDP")
233 .map_io = msm9615_map_io,
234 .init_irq = msm9615_init_irq,
235 .timer = &msm_timer,
236 .init_machine = msm9615_cdp_init,
237MACHINE_END
238
239MACHINE_START(MSM9615_MTP, "QCT MSM9615 MTP")
240 .map_io = msm9615_map_io,
241 .init_irq = msm9615_init_irq,
242 .timer = &msm_timer,
243 .init_machine = msm9615_mtp_init,
244MACHINE_END