diff options
author | Stephen Warren <swarren@nvidia.com> | 2011-12-16 17:12:31 -0500 |
---|---|---|
committer | Olof Johansson <olof@lixom.net> | 2011-12-19 21:03:11 -0500 |
commit | 54862bf00968427cf8f7ffcb6dacf03161eae862 (patch) | |
tree | a8990b08d6380e23f8569d196c234306769f5501 /arch/arm/mach-tegra | |
parent | b49cae59e12348474f7a82bbec187877f83381a9 (diff) |
arm/tegra: Refactor board-*-pinmux.c to share code
This moves the implementation of *_pinmux_init() into a single location.
The board-specific pinmux data is left in each board's own file. This
will allow future changes that set up the pinmux in a more complex
fashion to do so without duplicating that code in each board's pinmux
file.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Olof Johansson <olof@lixom.net>
Diffstat (limited to 'arch/arm/mach-tegra')
-rw-r--r-- | arch/arm/mach-tegra/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/mach-tegra/board-harmony-pinmux.c | 22 | ||||
-rw-r--r-- | arch/arm/mach-tegra/board-paz00-pinmux.c | 22 | ||||
-rw-r--r-- | arch/arm/mach-tegra/board-pinmux.c | 52 | ||||
-rw-r--r-- | arch/arm/mach-tegra/board-pinmux.h | 38 | ||||
-rw-r--r-- | arch/arm/mach-tegra/board-seaboard-pinmux.c | 51 | ||||
-rw-r--r-- | arch/arm/mach-tegra/board-trimslice-pinmux.c | 22 |
7 files changed, 144 insertions, 64 deletions
diff --git a/arch/arm/mach-tegra/Makefile b/arch/arm/mach-tegra/Makefile index 91a07e187208..e98c49aabd10 100644 --- a/arch/arm/mach-tegra/Makefile +++ b/arch/arm/mach-tegra/Makefile | |||
@@ -1,3 +1,4 @@ | |||
1 | obj-y += board-pinmux.o | ||
1 | obj-y += common.o | 2 | obj-y += common.o |
2 | obj-y += devices.o | 3 | obj-y += devices.o |
3 | obj-y += io.o | 4 | obj-y += io.o |
diff --git a/arch/arm/mach-tegra/board-harmony-pinmux.c b/arch/arm/mach-tegra/board-harmony-pinmux.c index 7a4a26d5174c..5038f5b130e6 100644 --- a/arch/arm/mach-tegra/board-harmony-pinmux.c +++ b/arch/arm/mach-tegra/board-harmony-pinmux.c | |||
@@ -22,7 +22,7 @@ | |||
22 | 22 | ||
23 | #include "gpio-names.h" | 23 | #include "gpio-names.h" |
24 | #include "board-harmony.h" | 24 | #include "board-harmony.h" |
25 | #include "devices.h" | 25 | #include "board-pinmux.h" |
26 | 26 | ||
27 | static struct tegra_pingroup_config harmony_pinmux[] = { | 27 | static struct tegra_pingroup_config harmony_pinmux[] = { |
28 | {TEGRA_PINGROUP_ATA, TEGRA_MUX_IDE, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL}, | 28 | {TEGRA_PINGROUP_ATA, TEGRA_MUX_IDE, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL}, |
@@ -143,11 +143,6 @@ static struct tegra_pingroup_config harmony_pinmux[] = { | |||
143 | {TEGRA_PINGROUP_XM2D, TEGRA_MUX_NONE, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL}, | 143 | {TEGRA_PINGROUP_XM2D, TEGRA_MUX_NONE, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL}, |
144 | }; | 144 | }; |
145 | 145 | ||
146 | static struct platform_device *pinmux_devices[] = { | ||
147 | &tegra_gpio_device, | ||
148 | &tegra_pinmux_device, | ||
149 | }; | ||
150 | |||
151 | static struct tegra_gpio_table gpio_table[] = { | 146 | static struct tegra_gpio_table gpio_table[] = { |
152 | { .gpio = TEGRA_GPIO_SD2_CD, .enable = true }, | 147 | { .gpio = TEGRA_GPIO_SD2_CD, .enable = true }, |
153 | { .gpio = TEGRA_GPIO_SD2_WP, .enable = true }, | 148 | { .gpio = TEGRA_GPIO_SD2_WP, .enable = true }, |
@@ -161,13 +156,14 @@ static struct tegra_gpio_table gpio_table[] = { | |||
161 | { .gpio = TEGRA_GPIO_EXT_MIC_EN, .enable = true }, | 156 | { .gpio = TEGRA_GPIO_EXT_MIC_EN, .enable = true }, |
162 | }; | 157 | }; |
163 | 158 | ||
159 | static struct tegra_board_pinmux_conf conf = { | ||
160 | .pgs = harmony_pinmux, | ||
161 | .pg_count = ARRAY_SIZE(harmony_pinmux), | ||
162 | .gpios = gpio_table, | ||
163 | .gpio_count = ARRAY_SIZE(gpio_table), | ||
164 | }; | ||
165 | |||
164 | void harmony_pinmux_init(void) | 166 | void harmony_pinmux_init(void) |
165 | { | 167 | { |
166 | if (!of_machine_is_compatible("nvidia,tegra20")) | 168 | tegra_board_pinmux_init(&conf, NULL); |
167 | platform_add_devices(pinmux_devices, | ||
168 | ARRAY_SIZE(pinmux_devices)); | ||
169 | |||
170 | tegra_pinmux_config_table(harmony_pinmux, ARRAY_SIZE(harmony_pinmux)); | ||
171 | |||
172 | tegra_gpio_config(gpio_table, ARRAY_SIZE(gpio_table)); | ||
173 | } | 169 | } |
diff --git a/arch/arm/mach-tegra/board-paz00-pinmux.c b/arch/arm/mach-tegra/board-paz00-pinmux.c index 126892cfddce..d6b37daf3252 100644 --- a/arch/arm/mach-tegra/board-paz00-pinmux.c +++ b/arch/arm/mach-tegra/board-paz00-pinmux.c | |||
@@ -22,7 +22,7 @@ | |||
22 | 22 | ||
23 | #include "gpio-names.h" | 23 | #include "gpio-names.h" |
24 | #include "board-paz00.h" | 24 | #include "board-paz00.h" |
25 | #include "devices.h" | 25 | #include "board-pinmux.h" |
26 | 26 | ||
27 | static struct tegra_pingroup_config paz00_pinmux[] = { | 27 | static struct tegra_pingroup_config paz00_pinmux[] = { |
28 | {TEGRA_PINGROUP_ATA, TEGRA_MUX_GMI, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL}, | 28 | {TEGRA_PINGROUP_ATA, TEGRA_MUX_GMI, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL}, |
@@ -143,11 +143,6 @@ static struct tegra_pingroup_config paz00_pinmux[] = { | |||
143 | {TEGRA_PINGROUP_XM2D, TEGRA_MUX_NONE, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL}, | 143 | {TEGRA_PINGROUP_XM2D, TEGRA_MUX_NONE, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL}, |
144 | }; | 144 | }; |
145 | 145 | ||
146 | static struct platform_device *pinmux_devices[] = { | ||
147 | &tegra_gpio_device, | ||
148 | &tegra_pinmux_device, | ||
149 | }; | ||
150 | |||
151 | static struct tegra_gpio_table gpio_table[] = { | 146 | static struct tegra_gpio_table gpio_table[] = { |
152 | { .gpio = TEGRA_GPIO_SD1_CD, .enable = true }, | 147 | { .gpio = TEGRA_GPIO_SD1_CD, .enable = true }, |
153 | { .gpio = TEGRA_GPIO_SD1_WP, .enable = true }, | 148 | { .gpio = TEGRA_GPIO_SD1_WP, .enable = true }, |
@@ -158,13 +153,14 @@ static struct tegra_gpio_table gpio_table[] = { | |||
158 | { .gpio = TEGRA_WIFI_LED, .enable = true }, | 153 | { .gpio = TEGRA_WIFI_LED, .enable = true }, |
159 | }; | 154 | }; |
160 | 155 | ||
156 | static struct tegra_board_pinmux_conf conf = { | ||
157 | .pgs = paz00_pinmux, | ||
158 | .pg_count = ARRAY_SIZE(paz00_pinmux), | ||
159 | .gpios = gpio_table, | ||
160 | .gpio_count = ARRAY_SIZE(gpio_table), | ||
161 | }; | ||
162 | |||
161 | void paz00_pinmux_init(void) | 163 | void paz00_pinmux_init(void) |
162 | { | 164 | { |
163 | if (!of_machine_is_compatible("nvidia,tegra20")) | 165 | tegra_board_pinmux_init(&conf, NULL); |
164 | platform_add_devices(pinmux_devices, | ||
165 | ARRAY_SIZE(pinmux_devices)); | ||
166 | |||
167 | tegra_pinmux_config_table(paz00_pinmux, ARRAY_SIZE(paz00_pinmux)); | ||
168 | |||
169 | tegra_gpio_config(gpio_table, ARRAY_SIZE(gpio_table)); | ||
170 | } | 166 | } |
diff --git a/arch/arm/mach-tegra/board-pinmux.c b/arch/arm/mach-tegra/board-pinmux.c new file mode 100644 index 000000000000..103ef65ca62a --- /dev/null +++ b/arch/arm/mach-tegra/board-pinmux.c | |||
@@ -0,0 +1,52 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2011, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * This software is licensed under the terms of the GNU General Public | ||
5 | * License version 2, as published by the Free Software Foundation, and | ||
6 | * may be copied, distributed, and modified under those terms. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #include <linux/of.h> | ||
16 | |||
17 | #include <mach/gpio-tegra.h> | ||
18 | #include <mach/pinmux.h> | ||
19 | |||
20 | #include "board-pinmux.h" | ||
21 | #include "devices.h" | ||
22 | |||
23 | static struct platform_device *devices[] = { | ||
24 | &tegra_gpio_device, | ||
25 | &tegra_pinmux_device, | ||
26 | }; | ||
27 | |||
28 | void tegra_board_pinmux_init(struct tegra_board_pinmux_conf *conf_a, | ||
29 | struct tegra_board_pinmux_conf *conf_b) | ||
30 | { | ||
31 | struct tegra_board_pinmux_conf *confs[] = {conf_a, conf_b}; | ||
32 | int i; | ||
33 | |||
34 | if (of_machine_is_compatible("nvidia,tegra20")) | ||
35 | platform_add_devices(devices, ARRAY_SIZE(devices)); | ||
36 | |||
37 | for (i = 0; i < ARRAY_SIZE(confs); i++) { | ||
38 | if (!confs[i]) | ||
39 | continue; | ||
40 | |||
41 | tegra_pinmux_config_table(confs[i]->pgs, confs[i]->pg_count); | ||
42 | |||
43 | if (confs[i]->drives) | ||
44 | tegra_drive_pinmux_config_table(confs[i]->drives, | ||
45 | confs[i]->drive_count); | ||
46 | |||
47 | tegra_gpio_config(confs[i]->gpios, confs[i]->gpio_count); | ||
48 | } | ||
49 | |||
50 | if (!of_machine_is_compatible("nvidia,tegra20")) | ||
51 | platform_add_devices(devices, ARRAY_SIZE(devices)); | ||
52 | } | ||
diff --git a/arch/arm/mach-tegra/board-pinmux.h b/arch/arm/mach-tegra/board-pinmux.h new file mode 100644 index 000000000000..4aac73546f54 --- /dev/null +++ b/arch/arm/mach-tegra/board-pinmux.h | |||
@@ -0,0 +1,38 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2011, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * This software is licensed under the terms of the GNU General Public | ||
5 | * License version 2, as published by the Free Software Foundation, and | ||
6 | * may be copied, distributed, and modified under those terms. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #ifndef __MACH_TEGRA_BOARD_PINMUX_H | ||
16 | #define __MACH_TEGRA_BOARD_PINMUX_H | ||
17 | |||
18 | #define GPIO_DEV "tegra-gpio" | ||
19 | #define PINMUX_DEV "tegra-pinmux" | ||
20 | |||
21 | struct tegra_pingroup_config; | ||
22 | struct tegra_gpio_table; | ||
23 | |||
24 | struct tegra_board_pinmux_conf { | ||
25 | struct tegra_pingroup_config *pgs; | ||
26 | int pg_count; | ||
27 | |||
28 | struct tegra_drive_pingroup_config *drives; | ||
29 | int drive_count; | ||
30 | |||
31 | struct tegra_gpio_table *gpios; | ||
32 | int gpio_count; | ||
33 | }; | ||
34 | |||
35 | void tegra_board_pinmux_init(struct tegra_board_pinmux_conf *conf_a, | ||
36 | struct tegra_board_pinmux_conf *conf_b); | ||
37 | |||
38 | #endif | ||
diff --git a/arch/arm/mach-tegra/board-seaboard-pinmux.c b/arch/arm/mach-tegra/board-seaboard-pinmux.c index 04cff836aa23..af28fd30c997 100644 --- a/arch/arm/mach-tegra/board-seaboard-pinmux.c +++ b/arch/arm/mach-tegra/board-seaboard-pinmux.c | |||
@@ -22,8 +22,8 @@ | |||
22 | #include <mach/pinmux-t2.h> | 22 | #include <mach/pinmux-t2.h> |
23 | 23 | ||
24 | #include "gpio-names.h" | 24 | #include "gpio-names.h" |
25 | #include "board-pinmux.h" | ||
25 | #include "board-seaboard.h" | 26 | #include "board-seaboard.h" |
26 | #include "devices.h" | ||
27 | 27 | ||
28 | #define DEFAULT_DRIVE(_name) \ | 28 | #define DEFAULT_DRIVE(_name) \ |
29 | { \ | 29 | { \ |
@@ -179,11 +179,6 @@ static __initdata struct tegra_pingroup_config ventana_pinmux[] = { | |||
179 | {TEGRA_PINGROUP_SPIG, TEGRA_MUX_SPI2_ALT, TEGRA_PUPD_NORMAL, TEGRA_TRI_TRISTATE}, | 179 | {TEGRA_PINGROUP_SPIG, TEGRA_MUX_SPI2_ALT, TEGRA_PUPD_NORMAL, TEGRA_TRI_TRISTATE}, |
180 | }; | 180 | }; |
181 | 181 | ||
182 | static struct platform_device *pinmux_devices[] = { | ||
183 | &tegra_gpio_device, | ||
184 | &tegra_pinmux_device, | ||
185 | }; | ||
186 | |||
187 | static struct tegra_gpio_table common_gpio_table[] = { | 182 | static struct tegra_gpio_table common_gpio_table[] = { |
188 | { .gpio = TEGRA_GPIO_SD2_CD, .enable = true }, | 183 | { .gpio = TEGRA_GPIO_SD2_CD, .enable = true }, |
189 | { .gpio = TEGRA_GPIO_SD2_WP, .enable = true }, | 184 | { .gpio = TEGRA_GPIO_SD2_WP, .enable = true }, |
@@ -208,31 +203,35 @@ static struct tegra_gpio_table ventana_gpio_table[] = { | |||
208 | { .gpio = TEGRA_GPIO_PX1, .enable = true }, | 203 | { .gpio = TEGRA_GPIO_PX1, .enable = true }, |
209 | }; | 204 | }; |
210 | 205 | ||
211 | void __init seaboard_common_pinmux_init(void) | 206 | static struct tegra_board_pinmux_conf common_conf = { |
212 | { | 207 | .pgs = common_pinmux, |
213 | if (!of_machine_is_compatible("nvidia,tegra20")) | 208 | .pg_count = ARRAY_SIZE(common_pinmux), |
214 | platform_add_devices(pinmux_devices, | 209 | .gpios = common_gpio_table, |
215 | ARRAY_SIZE(pinmux_devices)); | 210 | .gpio_count = ARRAY_SIZE(common_gpio_table), |
216 | 211 | }; | |
217 | tegra_pinmux_config_table(common_pinmux, ARRAY_SIZE(common_pinmux)); | ||
218 | 212 | ||
219 | tegra_drive_pinmux_config_table(seaboard_drive_pinmux, | 213 | static struct tegra_board_pinmux_conf seaboard_conf = { |
220 | ARRAY_SIZE(seaboard_drive_pinmux)); | 214 | .pgs = seaboard_pinmux, |
215 | .pg_count = ARRAY_SIZE(seaboard_pinmux), | ||
216 | .drives = seaboard_drive_pinmux, | ||
217 | .drive_count = ARRAY_SIZE(seaboard_drive_pinmux), | ||
218 | .gpios = seaboard_gpio_table, | ||
219 | .gpio_count = ARRAY_SIZE(seaboard_gpio_table), | ||
220 | }; | ||
221 | 221 | ||
222 | tegra_gpio_config(common_gpio_table, ARRAY_SIZE(common_gpio_table)); | 222 | static struct tegra_board_pinmux_conf ventana_conf = { |
223 | } | 223 | .pgs = ventana_pinmux, |
224 | .pg_count = ARRAY_SIZE(ventana_pinmux), | ||
225 | .gpios = ventana_gpio_table, | ||
226 | .gpio_count = ARRAY_SIZE(ventana_gpio_table), | ||
227 | }; | ||
224 | 228 | ||
225 | void __init seaboard_pinmux_init(void) | 229 | void seaboard_pinmux_init(void) |
226 | { | 230 | { |
227 | seaboard_common_pinmux_init(); | 231 | tegra_board_pinmux_init(&common_conf, &seaboard_conf); |
228 | tegra_pinmux_config_table(seaboard_pinmux, ARRAY_SIZE(seaboard_pinmux)); | ||
229 | tegra_gpio_config(seaboard_gpio_table, ARRAY_SIZE(seaboard_gpio_table)); | ||
230 | } | 232 | } |
231 | 233 | ||
232 | void __init ventana_pinmux_init(void) | 234 | void ventana_pinmux_init(void) |
233 | { | 235 | { |
234 | seaboard_common_pinmux_init(); | 236 | tegra_board_pinmux_init(&common_conf, &ventana_conf); |
235 | tegra_pinmux_config_table(ventana_pinmux, ARRAY_SIZE(ventana_pinmux)); | ||
236 | tegra_gpio_config(ventana_gpio_table, ARRAY_SIZE(ventana_gpio_table)); | ||
237 | } | 237 | } |
238 | |||
diff --git a/arch/arm/mach-tegra/board-trimslice-pinmux.c b/arch/arm/mach-tegra/board-trimslice-pinmux.c index 5daa6e858a1e..be2f3e8f95f1 100644 --- a/arch/arm/mach-tegra/board-trimslice-pinmux.c +++ b/arch/arm/mach-tegra/board-trimslice-pinmux.c | |||
@@ -21,8 +21,8 @@ | |||
21 | #include <mach/pinmux.h> | 21 | #include <mach/pinmux.h> |
22 | 22 | ||
23 | #include "gpio-names.h" | 23 | #include "gpio-names.h" |
24 | #include "board-pinmux.h" | ||
24 | #include "board-trimslice.h" | 25 | #include "board-trimslice.h" |
25 | #include "devices.h" | ||
26 | 26 | ||
27 | static __initdata struct tegra_pingroup_config trimslice_pinmux[] = { | 27 | static __initdata struct tegra_pingroup_config trimslice_pinmux[] = { |
28 | {TEGRA_PINGROUP_ATA, TEGRA_MUX_IDE, TEGRA_PUPD_NORMAL, TEGRA_TRI_TRISTATE}, | 28 | {TEGRA_PINGROUP_ATA, TEGRA_MUX_IDE, TEGRA_PUPD_NORMAL, TEGRA_TRI_TRISTATE}, |
@@ -143,11 +143,6 @@ static __initdata struct tegra_pingroup_config trimslice_pinmux[] = { | |||
143 | {TEGRA_PINGROUP_XM2D, TEGRA_MUX_NONE, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL}, | 143 | {TEGRA_PINGROUP_XM2D, TEGRA_MUX_NONE, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL}, |
144 | }; | 144 | }; |
145 | 145 | ||
146 | static struct platform_device *pinmux_devices[] = { | ||
147 | &tegra_gpio_device, | ||
148 | &tegra_pinmux_device, | ||
149 | }; | ||
150 | |||
151 | static struct tegra_gpio_table gpio_table[] = { | 146 | static struct tegra_gpio_table gpio_table[] = { |
152 | { .gpio = TRIMSLICE_GPIO_SD4_CD, .enable = true }, /* mmc4 cd */ | 147 | { .gpio = TRIMSLICE_GPIO_SD4_CD, .enable = true }, /* mmc4 cd */ |
153 | { .gpio = TRIMSLICE_GPIO_SD4_WP, .enable = true }, /* mmc4 wp */ | 148 | { .gpio = TRIMSLICE_GPIO_SD4_WP, .enable = true }, /* mmc4 wp */ |
@@ -156,11 +151,14 @@ static struct tegra_gpio_table gpio_table[] = { | |||
156 | { .gpio = TRIMSLICE_GPIO_USB2_RST, .enable = true }, /* USB2 PHY rst */ | 151 | { .gpio = TRIMSLICE_GPIO_USB2_RST, .enable = true }, /* USB2 PHY rst */ |
157 | }; | 152 | }; |
158 | 153 | ||
159 | void __init trimslice_pinmux_init(void) | 154 | static struct tegra_board_pinmux_conf conf = { |
155 | .pgs = trimslice_pinmux, | ||
156 | .pg_count = ARRAY_SIZE(trimslice_pinmux), | ||
157 | .gpios = gpio_table, | ||
158 | .gpio_count = ARRAY_SIZE(gpio_table), | ||
159 | }; | ||
160 | |||
161 | void trimslice_pinmux_init(void) | ||
160 | { | 162 | { |
161 | if (!of_machine_is_compatible("nvidia,tegra20")) | 163 | tegra_board_pinmux_init(&conf, NULL); |
162 | platform_add_devices(pinmux_devices, | ||
163 | ARRAY_SIZE(pinmux_devices)); | ||
164 | tegra_pinmux_config_table(trimslice_pinmux, ARRAY_SIZE(trimslice_pinmux)); | ||
165 | tegra_gpio_config(gpio_table, ARRAY_SIZE(gpio_table)); | ||
166 | } | 164 | } |