blob: d35de582a21c2cbf45d3b4d31257b06f6961a543 [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"
26
Rohit Vaswani09666872011-08-23 17:41:54 -070027static struct platform_device *common_devices[] = {
28 &msm9615_device_uart_gsbi4,
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -070029 &msm9615_device_ssbi_pmic1,
Harini Jayaramaneba52672011-09-08 15:13:00 -060030 &msm9615_device_qup_i2c_gsbi5,
Harini Jayaraman738c9312011-09-08 15:22:38 -060031 &msm9615_device_qup_spi_gsbi3,
Rohit Vaswani09666872011-08-23 17:41:54 -070032};
33
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -070034static struct msm_ssbi_platform_data msm9615_ssbi_pm8018_pdata __devinitdata = {
35 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
36 .slave = {
37 .name = "pm8018-core",
38 },
39};
40
Rohit Vaswani09666872011-08-23 17:41:54 -070041static struct gpiomux_setting gsbi4 = {
42 .func = GPIOMUX_FUNC_1,
43 .drv = GPIOMUX_DRV_8MA,
44 .pull = GPIOMUX_PULL_NONE,
45};
46
Harini Jayaramaneba52672011-09-08 15:13:00 -060047static struct gpiomux_setting gsbi5 = {
48 .func = GPIOMUX_FUNC_1,
49 .drv = GPIOMUX_DRV_8MA,
50 .pull = GPIOMUX_PULL_NONE,
51};
52
Harini Jayaraman738c9312011-09-08 15:22:38 -060053static struct gpiomux_setting gsbi3 = {
54 .func = GPIOMUX_FUNC_1,
55 .drv = GPIOMUX_DRV_8MA,
56 .pull = GPIOMUX_PULL_NONE,
57};
58
59static struct gpiomux_setting gsbi3_cs1_config = {
60 .func = GPIOMUX_FUNC_4,
61 .drv = GPIOMUX_DRV_8MA,
62 .pull = GPIOMUX_PULL_NONE,
63};
64
Rohit Vaswani09666872011-08-23 17:41:54 -070065struct msm_gpiomux_config msm9615_gsbi_configs[] __initdata = {
66 {
Harini Jayaraman738c9312011-09-08 15:22:38 -060067 .gpio = 8, /* GSBI3 QUP SPI_CLK */
68 .settings = {
69 [GPIOMUX_SUSPENDED] = &gsbi3,
70 },
71 },
72 {
73 .gpio = 9, /* GSBI3 QUP SPI_CS_N */
74 .settings = {
75 [GPIOMUX_SUSPENDED] = &gsbi3,
76 },
77 },
78 {
79 .gpio = 10, /* GSBI3 QUP SPI_DATA_MISO */
80 .settings = {
81 [GPIOMUX_SUSPENDED] = &gsbi3,
82 },
83 },
84 {
85 .gpio = 11, /* GSBI3 QUP SPI_DATA_MOSI */
86 .settings = {
87 [GPIOMUX_SUSPENDED] = &gsbi3,
88 },
89 },
90 {
Rohit Vaswani09666872011-08-23 17:41:54 -070091 .gpio = 12, /* GSBI4 UART */
92 .settings = {
93 [GPIOMUX_SUSPENDED] = &gsbi4,
94 },
95 },
96 {
97 .gpio = 13, /* GSBI4 UART */
98 .settings = {
99 [GPIOMUX_SUSPENDED] = &gsbi4,
100 },
101 },
102 {
103 .gpio = 14, /* GSBI4 UART */
104 .settings = {
105 [GPIOMUX_SUSPENDED] = &gsbi4,
106 },
107 },
108 {
109 .gpio = 15, /* GSBI4 UART */
110 .settings = {
111 [GPIOMUX_SUSPENDED] = &gsbi4,
112 },
113 },
Harini Jayaramaneba52672011-09-08 15:13:00 -0600114 {
115 .gpio = 16, /* GSBI5 I2C QUP SCL */
116 .settings = {
117 [GPIOMUX_SUSPENDED] = &gsbi5,
118 },
119 },
120 {
121 .gpio = 17, /* GSBI5 I2C QUP SDA */
122 .settings = {
123 [GPIOMUX_SUSPENDED] = &gsbi5,
124 },
125 },
Harini Jayaraman738c9312011-09-08 15:22:38 -0600126 {
127 /* GPIO 19 can be used for I2C/UART on GSBI5 */
128 .gpio = 19, /* GSBI3 QUP SPI_CS_1 */
129 .settings = {
130 [GPIOMUX_SUSPENDED] = &gsbi3_cs1_config,
131 },
132 },
Rohit Vaswani09666872011-08-23 17:41:54 -0700133};
134
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700135static int __init gpiomux_init(void)
136{
137 int rc;
138
139 rc = msm_gpiomux_init(NR_GPIO_IRQS);
140 if (rc) {
141 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
142 return rc;
143 }
Rohit Vaswani09666872011-08-23 17:41:54 -0700144 msm_gpiomux_install(msm9615_gsbi_configs,
145 ARRAY_SIZE(msm9615_gsbi_configs));
146
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700147 return 0;
148}
149
Harini Jayaraman738c9312011-09-08 15:22:38 -0600150static struct msm_spi_platform_data msm9615_qup_spi_gsbi3_pdata = {
151 .max_clock_speed = 24000000,
152};
153
Harini Jayaramaneba52672011-09-08 15:13:00 -0600154static struct msm_i2c_platform_data msm9615_i2c_qup_gsbi5_pdata = {
155 .clk_freq = 100000,
156 .src_clk_rate = 24000000,
157};
158
159static void __init msm9615_i2c_init(void)
160{
161 msm9615_device_qup_i2c_gsbi5.dev.platform_data =
162 &msm9615_i2c_qup_gsbi5_pdata;
163}
164
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700165static void __init msm9615_common_init(void)
166{
167 msm9615_device_init();
168 gpiomux_init();
Harini Jayaramaneba52672011-09-08 15:13:00 -0600169 msm9615_i2c_init();
Harini Jayaraman738c9312011-09-08 15:22:38 -0600170 msm9615_device_qup_spi_gsbi3.dev.platform_data =
171 &msm9615_qup_spi_gsbi3_pdata;
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700172 msm9615_device_ssbi_pmic1.dev.platform_data =
173 &msm9615_ssbi_pm8018_pdata;
Rohit Vaswani09666872011-08-23 17:41:54 -0700174 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700175}
176
177static void __init msm9615_cdp_init(void)
178{
179 msm9615_common_init();
180}
181
182static void __init msm9615_mtp_init(void)
183{
184 msm9615_common_init();
185}
186
187MACHINE_START(MSM9615_CDP, "QCT MSM9615 CDP")
188 .map_io = msm9615_map_io,
189 .init_irq = msm9615_init_irq,
190 .timer = &msm_timer,
191 .init_machine = msm9615_cdp_init,
192MACHINE_END
193
194MACHINE_START(MSM9615_MTP, "QCT MSM9615 MTP")
195 .map_io = msm9615_map_io,
196 .init_irq = msm9615_init_irq,
197 .timer = &msm_timer,
198 .init_machine = msm9615_mtp_init,
199MACHINE_END