blob: 5a76897a033db36327f5bb09e51375d8cc503e77 [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,
37 .drv = GPIOMUX_DRV_8MA,
38 .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,
44 .drv = GPIOMUX_DRV_8MA,
45 .pull = GPIOMUX_PULL_NONE,
46};
47
48struct msm_gpiomux_config apq8064_ethernet_configs[] = {
49 {
50 .gpio = 43,
51 .settings = {
52 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
53 [GPIOMUX_ACTIVE] = &gpio_eth_config,
54 }
55 },
56};
57#endif
58
Swaminathan Sathappancef966d2011-12-15 17:27:04 -080059static struct gpiomux_setting cdc_mclk = {
60 .func = GPIOMUX_FUNC_1,
61 .drv = GPIOMUX_DRV_8MA,
62 .pull = GPIOMUX_PULL_NONE,
63};
64
Stepan Moskovchenko2327a952011-12-14 16:31:28 -080065static struct gpiomux_setting audio_auxpcm[] = {
66 /* Suspended state */
67 {
68 .func = GPIOMUX_FUNC_GPIO,
69 .drv = GPIOMUX_DRV_2MA,
70 .pull = GPIOMUX_PULL_NONE,
71 },
72 /* Active state */
73 {
74 .func = GPIOMUX_FUNC_1,
75 .drv = GPIOMUX_DRV_2MA,
76 .pull = GPIOMUX_PULL_NONE,
77 },
78};
79
Swaminathan Sathappancef966d2011-12-15 17:27:04 -080080static struct gpiomux_setting slimbus = {
81 .func = GPIOMUX_FUNC_1,
82 .drv = GPIOMUX_DRV_8MA,
83 .pull = GPIOMUX_PULL_KEEPER,
84};
85
Stepan Moskovchenko5ea3c312012-01-31 18:19:40 -080086static struct gpiomux_setting gsbi1_uart_config = {
87 .func = GPIOMUX_FUNC_1,
88 .drv = GPIOMUX_DRV_16MA,
89 .pull = GPIOMUX_PULL_NONE,
90};
91
David Collinsf0d00732012-01-25 15:46:50 -080092static struct gpiomux_setting ext_regulator_config = {
93 .func = GPIOMUX_FUNC_GPIO,
94 .drv = GPIOMUX_DRV_8MA,
95 .pull = GPIOMUX_PULL_NONE,
96 .dir = GPIOMUX_OUT_LOW,
97};
98
Stepan Moskovchenko2327a952011-12-14 16:31:28 -080099static struct msm_gpiomux_config apq8064_gsbi_configs[] __initdata = {
Stepan Moskovchenko5ea3c312012-01-31 18:19:40 -0800100 {
101 .gpio = 18, /* GSBI1 UART TX */
102 .settings = {
103 [GPIOMUX_SUSPENDED] = &gsbi1_uart_config,
104 },
105 },
106 {
107 .gpio = 19, /* GSBI1 UART RX */
108 .settings = {
109 [GPIOMUX_SUSPENDED] = &gsbi1_uart_config,
110 },
111 },
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800112#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
113 {
114 .gpio = 51, /* GSBI5 QUP SPI_DATA_MOSI */
115 .settings = {
116 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
117 },
118 },
119 {
120 .gpio = 52, /* GSBI5 QUP SPI_DATA_MISO */
121 .settings = {
122 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
123 },
124 },
125 {
126 .gpio = 31, /* GSBI5 QUP SPI_CS2_N */
127 .settings = {
128 [GPIOMUX_SUSPENDED] = &gpio_spi_cs2_config,
129 },
130 },
131 {
132 .gpio = 54, /* GSBI5 QUP SPI_CLK */
133 .settings = {
134 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
135 },
136 },
137#endif
138};
139
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800140static struct msm_gpiomux_config apq8064_slimbus_config[] __initdata = {
141 {
142 .gpio = 40, /* slimbus clk */
143 .settings = {
144 [GPIOMUX_SUSPENDED] = &slimbus,
145 },
146 },
147 {
148 .gpio = 41, /* slimbus data */
149 .settings = {
150 [GPIOMUX_SUSPENDED] = &slimbus,
151 },
152 },
153};
154
155static struct msm_gpiomux_config apq8064_audio_codec_configs[] __initdata = {
156 {
157 .gpio = 39,
158 .settings = {
159 [GPIOMUX_SUSPENDED] = &cdc_mclk,
160 },
161 },
162};
163
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800164static struct msm_gpiomux_config apq8064_audio_auxpcm_configs[] __initdata = {
165 {
166 .gpio = 43,
167 .settings = {
168 [GPIOMUX_SUSPENDED] = &audio_auxpcm[0],
169 [GPIOMUX_ACTIVE] = &audio_auxpcm[1],
170 },
171 },
172 {
173 .gpio = 44,
174 .settings = {
175 [GPIOMUX_SUSPENDED] = &audio_auxpcm[0],
176 [GPIOMUX_ACTIVE] = &audio_auxpcm[1],
177 },
178 },
179 {
180 .gpio = 45,
181 .settings = {
182 [GPIOMUX_SUSPENDED] = &audio_auxpcm[0],
183 [GPIOMUX_ACTIVE] = &audio_auxpcm[1],
184 },
185 },
186 {
187 .gpio = 46,
188 .settings = {
189 [GPIOMUX_SUSPENDED] = &audio_auxpcm[0],
190 [GPIOMUX_ACTIVE] = &audio_auxpcm[1],
191 },
192 },
193};
194
David Collinsf0d00732012-01-25 15:46:50 -0800195/* External 3.3 V regulator enable */
196static struct msm_gpiomux_config apq8064_ext_regulator_configs[] __initdata = {
197 {
198 .gpio = APQ8064_EXT_3P3V_REG_EN_GPIO,
199 .settings = {
200 [GPIOMUX_SUSPENDED] = &ext_regulator_config,
201 },
202 },
203};
204
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800205void __init apq8064_init_gpiomux(void)
206{
207 int rc;
208
209 rc = msm_gpiomux_init(NR_GPIO_IRQS);
210 if (rc) {
211 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
212 return;
213 }
214
215#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
216 msm_gpiomux_install(apq8064_ethernet_configs,
217 ARRAY_SIZE(apq8064_ethernet_configs));
218#endif
219
220 msm_gpiomux_install(apq8064_gsbi_configs,
221 ARRAY_SIZE(apq8064_gsbi_configs));
222
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800223 msm_gpiomux_install(apq8064_slimbus_config,
224 ARRAY_SIZE(apq8064_slimbus_config));
225
226 msm_gpiomux_install(apq8064_audio_codec_configs,
227 ARRAY_SIZE(apq8064_audio_codec_configs));
228
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800229 msm_gpiomux_install(apq8064_audio_auxpcm_configs,
230 ARRAY_SIZE(apq8064_audio_auxpcm_configs));
David Collinsf0d00732012-01-25 15:46:50 -0800231
232 msm_gpiomux_install(apq8064_ext_regulator_configs,
233 ARRAY_SIZE(apq8064_ext_regulator_configs));
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800234}