diff options
Diffstat (limited to 'arch/arm/mach-tegra/board-pinmux.c')
-rw-r--r-- | arch/arm/mach-tegra/board-pinmux.c | 105 |
1 files changed, 44 insertions, 61 deletions
diff --git a/arch/arm/mach-tegra/board-pinmux.c b/arch/arm/mach-tegra/board-pinmux.c index adc3efe979b3..a5574c71b931 100644 --- a/arch/arm/mach-tegra/board-pinmux.c +++ b/arch/arm/mach-tegra/board-pinmux.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2011, NVIDIA CORPORATION. All rights reserved. | 2 | * Copyright (c) 2011,2012, NVIDIA CORPORATION. All rights reserved. |
3 | * | 3 | * |
4 | * This software is licensed under the terms of the GNU General Public | 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 | 5 | * License version 2, as published by the Free Software Foundation, and |
@@ -15,75 +15,59 @@ | |||
15 | #include <linux/device.h> | 15 | #include <linux/device.h> |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/notifier.h> | 17 | #include <linux/notifier.h> |
18 | #include <linux/of.h> | ||
19 | #include <linux/string.h> | 18 | #include <linux/string.h> |
20 | 19 | ||
21 | #include <mach/gpio-tegra.h> | ||
22 | #include <mach/pinmux.h> | ||
23 | |||
24 | #include "board-pinmux.h" | 20 | #include "board-pinmux.h" |
25 | #include "devices.h" | 21 | #include "devices.h" |
26 | 22 | ||
27 | struct tegra_board_pinmux_conf *confs[2]; | 23 | unsigned long tegra_pincfg_pullnone_driven[2] = { |
28 | 24 | TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_PULL, TEGRA_PINCONFIG_PULL_NONE), | |
29 | static void tegra_board_pinmux_setup_gpios(void) | 25 | TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_TRISTATE, TEGRA_PINCONFIG_DRIVEN), |
30 | { | 26 | }; |
31 | int i; | ||
32 | |||
33 | for (i = 0; i < ARRAY_SIZE(confs); i++) { | ||
34 | if (!confs[i]) | ||
35 | continue; | ||
36 | |||
37 | tegra_gpio_config(confs[i]->gpios, confs[i]->gpio_count); | ||
38 | } | ||
39 | } | ||
40 | |||
41 | static void tegra_board_pinmux_setup_pinmux(void) | ||
42 | { | ||
43 | int i; | ||
44 | 27 | ||
45 | for (i = 0; i < ARRAY_SIZE(confs); i++) { | 28 | unsigned long tegra_pincfg_pullnone_tristate[2] = { |
46 | if (!confs[i]) | 29 | TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_PULL, TEGRA_PINCONFIG_PULL_NONE), |
47 | continue; | 30 | TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_TRISTATE, TEGRA_PINCONFIG_TRISTATE), |
31 | }; | ||
48 | 32 | ||
49 | tegra_pinmux_config_table(confs[i]->pgs, confs[i]->pg_count); | 33 | unsigned long tegra_pincfg_pullnone_na[1] = { |
34 | TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_PULL, TEGRA_PINCONFIG_PULL_NONE), | ||
35 | }; | ||
50 | 36 | ||
51 | if (confs[i]->drives) | 37 | unsigned long tegra_pincfg_pullup_driven[2] = { |
52 | tegra_drive_pinmux_config_table(confs[i]->drives, | 38 | TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_PULL, TEGRA_PINCONFIG_PULL_UP), |
53 | confs[i]->drive_count); | 39 | TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_TRISTATE, TEGRA_PINCONFIG_DRIVEN), |
54 | } | 40 | }; |
55 | } | ||
56 | 41 | ||
57 | static int tegra_board_pinmux_bus_notify(struct notifier_block *nb, | 42 | unsigned long tegra_pincfg_pullup_tristate[2] = { |
58 | unsigned long event, void *vdev) | 43 | TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_PULL, TEGRA_PINCONFIG_PULL_UP), |
59 | { | 44 | TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_TRISTATE, TEGRA_PINCONFIG_TRISTATE), |
60 | static bool had_gpio; | 45 | }; |
61 | static bool had_pinmux; | ||
62 | 46 | ||
63 | struct device *dev = vdev; | 47 | unsigned long tegra_pincfg_pullup_na[1] = { |
64 | const char *devname; | 48 | TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_PULL, TEGRA_PINCONFIG_PULL_UP), |
49 | }; | ||
65 | 50 | ||
66 | if (event != BUS_NOTIFY_BOUND_DRIVER) | 51 | unsigned long tegra_pincfg_pulldown_driven[2] = { |
67 | return NOTIFY_DONE; | 52 | TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_PULL, TEGRA_PINCONFIG_PULL_DOWN), |
53 | TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_TRISTATE, TEGRA_PINCONFIG_DRIVEN), | ||
54 | }; | ||
68 | 55 | ||
69 | devname = dev_name(dev); | 56 | unsigned long tegra_pincfg_pulldown_tristate[2] = { |
57 | TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_PULL, TEGRA_PINCONFIG_PULL_DOWN), | ||
58 | TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_TRISTATE, TEGRA_PINCONFIG_TRISTATE), | ||
59 | }; | ||
70 | 60 | ||
71 | if (!had_gpio && !strcmp(devname, GPIO_DEV)) { | 61 | unsigned long tegra_pincfg_pulldown_na[1] = { |
72 | tegra_board_pinmux_setup_gpios(); | 62 | TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_PULL, TEGRA_PINCONFIG_PULL_DOWN), |
73 | had_gpio = true; | 63 | }; |
74 | } else if (!had_pinmux && !strcmp(devname, PINMUX_DEV)) { | ||
75 | tegra_board_pinmux_setup_pinmux(); | ||
76 | had_pinmux = true; | ||
77 | } | ||
78 | 64 | ||
79 | if (had_gpio && had_pinmux) | 65 | unsigned long tegra_pincfg_pullna_driven[1] = { |
80 | return NOTIFY_STOP_MASK; | 66 | TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_TRISTATE, TEGRA_PINCONFIG_DRIVEN), |
81 | else | 67 | }; |
82 | return NOTIFY_DONE; | ||
83 | } | ||
84 | 68 | ||
85 | static struct notifier_block nb = { | 69 | unsigned long tegra_pincfg_pullna_tristate[1] = { |
86 | .notifier_call = tegra_board_pinmux_bus_notify, | 70 | TEGRA_PINCONF_PACK(TEGRA_PINCONF_PARAM_TRISTATE, TEGRA_PINCONFIG_TRISTATE), |
87 | }; | 71 | }; |
88 | 72 | ||
89 | static struct platform_device *devices[] = { | 73 | static struct platform_device *devices[] = { |
@@ -94,11 +78,10 @@ static struct platform_device *devices[] = { | |||
94 | void tegra_board_pinmux_init(struct tegra_board_pinmux_conf *conf_a, | 78 | void tegra_board_pinmux_init(struct tegra_board_pinmux_conf *conf_a, |
95 | struct tegra_board_pinmux_conf *conf_b) | 79 | struct tegra_board_pinmux_conf *conf_b) |
96 | { | 80 | { |
97 | confs[0] = conf_a; | 81 | if (conf_a) |
98 | confs[1] = conf_b; | 82 | pinctrl_register_mappings(conf_a->maps, conf_a->map_count); |
99 | 83 | if (conf_b) | |
100 | bus_register_notifier(&platform_bus_type, &nb); | 84 | pinctrl_register_mappings(conf_b->maps, conf_b->map_count); |
101 | 85 | ||
102 | if (!of_machine_is_compatible("nvidia,tegra20")) | 86 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
103 | platform_add_devices(devices, ARRAY_SIZE(devices)); | ||
104 | } | 87 | } |