blob: 7e6020e007190f0170b419d65bb1c7dfbb94992d [file] [log] [blame]
Stepan Moskovchenko5ea3c312012-01-31 18:19:40 -08001/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Stepan Moskovchenko2327a952011-12-14 16:31:28 -08002 *
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
14#include <linux/init.h>
15#include <linux/ioport.h>
16#include <linux/platform_device.h>
17#include <linux/bootmem.h>
18#include <asm/mach-types.h>
19#include <asm/mach/mmc.h>
20#include <mach/msm_bus_board.h>
21#include <mach/board.h>
22#include <mach/gpio.h>
23#include <mach/gpiomux.h>
24#include "devices.h"
25#include "board-8064.h"
26
27#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
28static struct gpiomux_setting gpio_eth_config = {
29 .pull = GPIOMUX_PULL_NONE,
30 .drv = GPIOMUX_DRV_8MA,
31 .func = GPIOMUX_FUNC_GPIO,
32};
33
34/* The SPI configurations apply to GSBI 5*/
35static struct gpiomux_setting gpio_spi_config = {
36 .func = GPIOMUX_FUNC_2,
Stepan Moskovchenkoc71c9792012-01-31 18:12:44 -080037 .drv = GPIOMUX_DRV_12MA,
Stepan Moskovchenko2327a952011-12-14 16:31:28 -080038 .pull = GPIOMUX_PULL_NONE,
39};
40
41/* The SPI configurations apply to GSBI 5 chip select 2*/
42static struct gpiomux_setting gpio_spi_cs2_config = {
43 .func = GPIOMUX_FUNC_3,
Stepan Moskovchenkoc71c9792012-01-31 18:12:44 -080044 .drv = GPIOMUX_DRV_12MA,
Stepan Moskovchenko2327a952011-12-14 16:31:28 -080045 .pull = GPIOMUX_PULL_NONE,
46};
47
Stepan Moskovchenkoc71c9792012-01-31 18:12:44 -080048/* Chip selects for SPI clients */
49static struct gpiomux_setting gpio_spi_cs_config = {
50 .func = GPIOMUX_FUNC_GPIO,
51 .drv = GPIOMUX_DRV_12MA,
52 .pull = GPIOMUX_PULL_UP,
53};
54
Stepan Moskovchenko2327a952011-12-14 16:31:28 -080055struct msm_gpiomux_config apq8064_ethernet_configs[] = {
56 {
57 .gpio = 43,
58 .settings = {
59 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
60 [GPIOMUX_ACTIVE] = &gpio_eth_config,
61 }
62 },
63};
64#endif
65
Swaminathan Sathappancef966d2011-12-15 17:27:04 -080066static struct gpiomux_setting cdc_mclk = {
67 .func = GPIOMUX_FUNC_1,
68 .drv = GPIOMUX_DRV_8MA,
69 .pull = GPIOMUX_PULL_NONE,
70};
71
Stepan Moskovchenko2327a952011-12-14 16:31:28 -080072static struct gpiomux_setting audio_auxpcm[] = {
73 /* Suspended state */
74 {
75 .func = GPIOMUX_FUNC_GPIO,
76 .drv = GPIOMUX_DRV_2MA,
77 .pull = GPIOMUX_PULL_NONE,
78 },
79 /* Active state */
80 {
81 .func = GPIOMUX_FUNC_1,
82 .drv = GPIOMUX_DRV_2MA,
83 .pull = GPIOMUX_PULL_NONE,
84 },
85};
86
Swaminathan Sathappancef966d2011-12-15 17:27:04 -080087static struct gpiomux_setting slimbus = {
88 .func = GPIOMUX_FUNC_1,
89 .drv = GPIOMUX_DRV_8MA,
90 .pull = GPIOMUX_PULL_KEEPER,
91};
92
Stepan Moskovchenko5ea3c312012-01-31 18:19:40 -080093static struct gpiomux_setting gsbi1_uart_config = {
94 .func = GPIOMUX_FUNC_1,
95 .drv = GPIOMUX_DRV_16MA,
96 .pull = GPIOMUX_PULL_NONE,
97};
98
David Collinsf0d00732012-01-25 15:46:50 -080099static struct gpiomux_setting ext_regulator_config = {
100 .func = GPIOMUX_FUNC_GPIO,
101 .drv = GPIOMUX_DRV_8MA,
102 .pull = GPIOMUX_PULL_NONE,
103 .dir = GPIOMUX_OUT_LOW,
104};
105
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800106static struct msm_gpiomux_config apq8064_gsbi_configs[] __initdata = {
Stepan Moskovchenko5ea3c312012-01-31 18:19:40 -0800107 {
108 .gpio = 18, /* GSBI1 UART TX */
109 .settings = {
110 [GPIOMUX_SUSPENDED] = &gsbi1_uart_config,
111 },
112 },
113 {
114 .gpio = 19, /* GSBI1 UART RX */
115 .settings = {
116 [GPIOMUX_SUSPENDED] = &gsbi1_uart_config,
117 },
118 },
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800119#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
120 {
121 .gpio = 51, /* GSBI5 QUP SPI_DATA_MOSI */
122 .settings = {
123 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
124 },
125 },
126 {
127 .gpio = 52, /* GSBI5 QUP SPI_DATA_MISO */
128 .settings = {
129 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
130 },
131 },
132 {
Stepan Moskovchenkoc71c9792012-01-31 18:12:44 -0800133 .gpio = 53, /* Funny CS0 */
134 .settings = {
135 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
136 },
137 },
138 {
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800139 .gpio = 31, /* GSBI5 QUP SPI_CS2_N */
140 .settings = {
141 [GPIOMUX_SUSPENDED] = &gpio_spi_cs2_config,
142 },
143 },
144 {
145 .gpio = 54, /* GSBI5 QUP SPI_CLK */
146 .settings = {
147 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
148 },
149 },
150#endif
Stepan Moskovchenkoc71c9792012-01-31 18:12:44 -0800151 {
152 .gpio = 30, /* FP CS */
153 .settings = {
154 [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config,
155 },
156 },
157 {
158 .gpio = 32, /* EPM CS */
159 .settings = {
160 [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config,
161 },
162 },
163 {
164 .gpio = 53, /* NOR CS */
165 .settings = {
166 [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config,
167 },
168 },
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800169};
170
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800171static struct msm_gpiomux_config apq8064_slimbus_config[] __initdata = {
172 {
173 .gpio = 40, /* slimbus clk */
174 .settings = {
175 [GPIOMUX_SUSPENDED] = &slimbus,
176 },
177 },
178 {
179 .gpio = 41, /* slimbus data */
180 .settings = {
181 [GPIOMUX_SUSPENDED] = &slimbus,
182 },
183 },
184};
185
186static struct msm_gpiomux_config apq8064_audio_codec_configs[] __initdata = {
187 {
188 .gpio = 39,
189 .settings = {
190 [GPIOMUX_SUSPENDED] = &cdc_mclk,
191 },
192 },
193};
194
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800195static struct msm_gpiomux_config apq8064_audio_auxpcm_configs[] __initdata = {
196 {
197 .gpio = 43,
198 .settings = {
199 [GPIOMUX_SUSPENDED] = &audio_auxpcm[0],
200 [GPIOMUX_ACTIVE] = &audio_auxpcm[1],
201 },
202 },
203 {
204 .gpio = 44,
205 .settings = {
206 [GPIOMUX_SUSPENDED] = &audio_auxpcm[0],
207 [GPIOMUX_ACTIVE] = &audio_auxpcm[1],
208 },
209 },
210 {
211 .gpio = 45,
212 .settings = {
213 [GPIOMUX_SUSPENDED] = &audio_auxpcm[0],
214 [GPIOMUX_ACTIVE] = &audio_auxpcm[1],
215 },
216 },
217 {
218 .gpio = 46,
219 .settings = {
220 [GPIOMUX_SUSPENDED] = &audio_auxpcm[0],
221 [GPIOMUX_ACTIVE] = &audio_auxpcm[1],
222 },
223 },
224};
225
David Collinsf0d00732012-01-25 15:46:50 -0800226/* External 3.3 V regulator enable */
227static struct msm_gpiomux_config apq8064_ext_regulator_configs[] __initdata = {
228 {
229 .gpio = APQ8064_EXT_3P3V_REG_EN_GPIO,
230 .settings = {
231 [GPIOMUX_SUSPENDED] = &ext_regulator_config,
232 },
233 },
234};
235
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800236void __init apq8064_init_gpiomux(void)
237{
238 int rc;
239
240 rc = msm_gpiomux_init(NR_GPIO_IRQS);
241 if (rc) {
242 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
243 return;
244 }
245
246#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
247 msm_gpiomux_install(apq8064_ethernet_configs,
248 ARRAY_SIZE(apq8064_ethernet_configs));
249#endif
250
251 msm_gpiomux_install(apq8064_gsbi_configs,
252 ARRAY_SIZE(apq8064_gsbi_configs));
253
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800254 msm_gpiomux_install(apq8064_slimbus_config,
255 ARRAY_SIZE(apq8064_slimbus_config));
256
257 msm_gpiomux_install(apq8064_audio_codec_configs,
258 ARRAY_SIZE(apq8064_audio_codec_configs));
259
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800260 msm_gpiomux_install(apq8064_audio_auxpcm_configs,
261 ARRAY_SIZE(apq8064_audio_auxpcm_configs));
David Collinsf0d00732012-01-25 15:46:50 -0800262
263 msm_gpiomux_install(apq8064_ext_regulator_configs,
264 ARRAY_SIZE(apq8064_ext_regulator_configs));
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800265}