blob: f391e30549a50e6d703e1baf781320aa4ab35ae6 [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>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070016#include <asm/mach-types.h>
17#include <asm/mach/arch.h>
18#include <mach/board.h>
19#include <mach/msm_iomap.h>
20#include <mach/gpio.h>
21#include <mach/gpiomux.h>
Harini Jayaraman738c9312011-09-08 15:22:38 -060022#include <mach/msm_spi.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070023#include "timer.h"
24#include "devices.h"
25
Rohit Vaswani09666872011-08-23 17:41:54 -070026static struct platform_device *common_devices[] = {
27 &msm9615_device_uart_gsbi4,
Harini Jayaramaneba52672011-09-08 15:13:00 -060028 &msm9615_device_qup_i2c_gsbi5,
Harini Jayaraman738c9312011-09-08 15:22:38 -060029 &msm9615_device_qup_spi_gsbi3,
Rohit Vaswani09666872011-08-23 17:41:54 -070030};
31
32static struct gpiomux_setting gsbi4 = {
33 .func = GPIOMUX_FUNC_1,
34 .drv = GPIOMUX_DRV_8MA,
35 .pull = GPIOMUX_PULL_NONE,
36};
37
Harini Jayaramaneba52672011-09-08 15:13:00 -060038static struct gpiomux_setting gsbi5 = {
39 .func = GPIOMUX_FUNC_1,
40 .drv = GPIOMUX_DRV_8MA,
41 .pull = GPIOMUX_PULL_NONE,
42};
43
Harini Jayaraman738c9312011-09-08 15:22:38 -060044static struct gpiomux_setting gsbi3 = {
45 .func = GPIOMUX_FUNC_1,
46 .drv = GPIOMUX_DRV_8MA,
47 .pull = GPIOMUX_PULL_NONE,
48};
49
50static struct gpiomux_setting gsbi3_cs1_config = {
51 .func = GPIOMUX_FUNC_4,
52 .drv = GPIOMUX_DRV_8MA,
53 .pull = GPIOMUX_PULL_NONE,
54};
55
Rohit Vaswani09666872011-08-23 17:41:54 -070056struct msm_gpiomux_config msm9615_gsbi_configs[] __initdata = {
57 {
Harini Jayaraman738c9312011-09-08 15:22:38 -060058 .gpio = 8, /* GSBI3 QUP SPI_CLK */
59 .settings = {
60 [GPIOMUX_SUSPENDED] = &gsbi3,
61 },
62 },
63 {
64 .gpio = 9, /* GSBI3 QUP SPI_CS_N */
65 .settings = {
66 [GPIOMUX_SUSPENDED] = &gsbi3,
67 },
68 },
69 {
70 .gpio = 10, /* GSBI3 QUP SPI_DATA_MISO */
71 .settings = {
72 [GPIOMUX_SUSPENDED] = &gsbi3,
73 },
74 },
75 {
76 .gpio = 11, /* GSBI3 QUP SPI_DATA_MOSI */
77 .settings = {
78 [GPIOMUX_SUSPENDED] = &gsbi3,
79 },
80 },
81 {
Rohit Vaswani09666872011-08-23 17:41:54 -070082 .gpio = 12, /* GSBI4 UART */
83 .settings = {
84 [GPIOMUX_SUSPENDED] = &gsbi4,
85 },
86 },
87 {
88 .gpio = 13, /* GSBI4 UART */
89 .settings = {
90 [GPIOMUX_SUSPENDED] = &gsbi4,
91 },
92 },
93 {
94 .gpio = 14, /* GSBI4 UART */
95 .settings = {
96 [GPIOMUX_SUSPENDED] = &gsbi4,
97 },
98 },
99 {
100 .gpio = 15, /* GSBI4 UART */
101 .settings = {
102 [GPIOMUX_SUSPENDED] = &gsbi4,
103 },
104 },
Harini Jayaramaneba52672011-09-08 15:13:00 -0600105 {
106 .gpio = 16, /* GSBI5 I2C QUP SCL */
107 .settings = {
108 [GPIOMUX_SUSPENDED] = &gsbi5,
109 },
110 },
111 {
112 .gpio = 17, /* GSBI5 I2C QUP SDA */
113 .settings = {
114 [GPIOMUX_SUSPENDED] = &gsbi5,
115 },
116 },
Harini Jayaraman738c9312011-09-08 15:22:38 -0600117 {
118 /* GPIO 19 can be used for I2C/UART on GSBI5 */
119 .gpio = 19, /* GSBI3 QUP SPI_CS_1 */
120 .settings = {
121 [GPIOMUX_SUSPENDED] = &gsbi3_cs1_config,
122 },
123 },
Rohit Vaswani09666872011-08-23 17:41:54 -0700124};
125
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700126static int __init gpiomux_init(void)
127{
128 int rc;
129
130 rc = msm_gpiomux_init(NR_GPIO_IRQS);
131 if (rc) {
132 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
133 return rc;
134 }
Rohit Vaswani09666872011-08-23 17:41:54 -0700135 msm_gpiomux_install(msm9615_gsbi_configs,
136 ARRAY_SIZE(msm9615_gsbi_configs));
137
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700138 return 0;
139}
140
Harini Jayaraman738c9312011-09-08 15:22:38 -0600141static struct msm_spi_platform_data msm9615_qup_spi_gsbi3_pdata = {
142 .max_clock_speed = 24000000,
143};
144
Harini Jayaramaneba52672011-09-08 15:13:00 -0600145static struct msm_i2c_platform_data msm9615_i2c_qup_gsbi5_pdata = {
146 .clk_freq = 100000,
147 .src_clk_rate = 24000000,
148};
149
150static void __init msm9615_i2c_init(void)
151{
152 msm9615_device_qup_i2c_gsbi5.dev.platform_data =
153 &msm9615_i2c_qup_gsbi5_pdata;
154}
155
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700156static void __init msm9615_common_init(void)
157{
158 msm9615_device_init();
159 gpiomux_init();
Harini Jayaramaneba52672011-09-08 15:13:00 -0600160 msm9615_i2c_init();
Harini Jayaraman738c9312011-09-08 15:22:38 -0600161 msm9615_device_qup_spi_gsbi3.dev.platform_data =
162 &msm9615_qup_spi_gsbi3_pdata;
Rohit Vaswani09666872011-08-23 17:41:54 -0700163 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700164}
165
166static void __init msm9615_cdp_init(void)
167{
168 msm9615_common_init();
169}
170
171static void __init msm9615_mtp_init(void)
172{
173 msm9615_common_init();
174}
175
176MACHINE_START(MSM9615_CDP, "QCT MSM9615 CDP")
177 .map_io = msm9615_map_io,
178 .init_irq = msm9615_init_irq,
179 .timer = &msm_timer,
180 .init_machine = msm9615_cdp_init,
181MACHINE_END
182
183MACHINE_START(MSM9615_MTP, "QCT MSM9615 MTP")
184 .map_io = msm9615_map_io,
185 .init_irq = msm9615_init_irq,
186 .timer = &msm_timer,
187 .init_machine = msm9615_mtp_init,
188MACHINE_END