aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-tegra/board-dt.c14
-rw-r--r--arch/arm/mach-tegra/board-pinmux.c72
2 files changed, 69 insertions, 17 deletions
diff --git a/arch/arm/mach-tegra/board-dt.c b/arch/arm/mach-tegra/board-dt.c
index 96f4df598238..909065f62e38 100644
--- a/arch/arm/mach-tegra/board-dt.c
+++ b/arch/arm/mach-tegra/board-dt.c
@@ -103,13 +103,6 @@ static void __init tegra_dt_init(void)
103 103
104 tegra_clk_init_from_table(tegra_dt_clk_init_table); 104 tegra_clk_init_from_table(tegra_dt_clk_init_table);
105 105
106 /*
107 * Finished with the static registrations now; fill in the missing
108 * devices
109 */
110 of_platform_populate(NULL, tegra_dt_match_table,
111 tegra20_auxdata_lookup, NULL);
112
113 for (i = 0; i < ARRAY_SIZE(pinmux_configs); i++) { 106 for (i = 0; i < ARRAY_SIZE(pinmux_configs); i++) {
114 if (of_machine_is_compatible(pinmux_configs[i].machine)) { 107 if (of_machine_is_compatible(pinmux_configs[i].machine)) {
115 pinmux_configs[i].init(); 108 pinmux_configs[i].init();
@@ -119,6 +112,13 @@ static void __init tegra_dt_init(void)
119 112
120 WARN(i == ARRAY_SIZE(pinmux_configs), 113 WARN(i == ARRAY_SIZE(pinmux_configs),
121 "Unknown platform! Pinmuxing not initialized\n"); 114 "Unknown platform! Pinmuxing not initialized\n");
115
116 /*
117 * Finished with the static registrations now; fill in the missing
118 * devices
119 */
120 of_platform_populate(NULL, tegra_dt_match_table,
121 tegra20_auxdata_lookup, NULL);
122} 122}
123 123
124static const char * tegra_dt_board_compat[] = { 124static const char * tegra_dt_board_compat[] = {
diff --git a/arch/arm/mach-tegra/board-pinmux.c b/arch/arm/mach-tegra/board-pinmux.c
index 103ef65ca62a..adc3efe979b3 100644
--- a/arch/arm/mach-tegra/board-pinmux.c
+++ b/arch/arm/mach-tegra/board-pinmux.c
@@ -12,7 +12,11 @@
12 * 12 *
13 */ 13 */
14 14
15#include <linux/device.h>
16#include <linux/kernel.h>
17#include <linux/notifier.h>
15#include <linux/of.h> 18#include <linux/of.h>
19#include <linux/string.h>
16 20
17#include <mach/gpio-tegra.h> 21#include <mach/gpio-tegra.h>
18#include <mach/pinmux.h> 22#include <mach/pinmux.h>
@@ -20,19 +24,23 @@
20#include "board-pinmux.h" 24#include "board-pinmux.h"
21#include "devices.h" 25#include "devices.h"
22 26
23static struct platform_device *devices[] = { 27struct tegra_board_pinmux_conf *confs[2];
24 &tegra_gpio_device,
25 &tegra_pinmux_device,
26};
27 28
28void tegra_board_pinmux_init(struct tegra_board_pinmux_conf *conf_a, 29static void tegra_board_pinmux_setup_gpios(void)
29 struct tegra_board_pinmux_conf *conf_b)
30{ 30{
31 struct tegra_board_pinmux_conf *confs[] = {conf_a, conf_b};
32 int i; 31 int i;
33 32
34 if (of_machine_is_compatible("nvidia,tegra20")) 33 for (i = 0; i < ARRAY_SIZE(confs); i++) {
35 platform_add_devices(devices, ARRAY_SIZE(devices)); 34 if (!confs[i])
35 continue;
36
37 tegra_gpio_config(confs[i]->gpios, confs[i]->gpio_count);
38 }
39}
40
41static void tegra_board_pinmux_setup_pinmux(void)
42{
43 int i;
36 44
37 for (i = 0; i < ARRAY_SIZE(confs); i++) { 45 for (i = 0; i < ARRAY_SIZE(confs); i++) {
38 if (!confs[i]) 46 if (!confs[i])
@@ -43,10 +51,54 @@ void tegra_board_pinmux_init(struct tegra_board_pinmux_conf *conf_a,
43 if (confs[i]->drives) 51 if (confs[i]->drives)
44 tegra_drive_pinmux_config_table(confs[i]->drives, 52 tegra_drive_pinmux_config_table(confs[i]->drives,
45 confs[i]->drive_count); 53 confs[i]->drive_count);
54 }
55}
46 56
47 tegra_gpio_config(confs[i]->gpios, confs[i]->gpio_count); 57static int tegra_board_pinmux_bus_notify(struct notifier_block *nb,
58 unsigned long event, void *vdev)
59{
60 static bool had_gpio;
61 static bool had_pinmux;
62
63 struct device *dev = vdev;
64 const char *devname;
65
66 if (event != BUS_NOTIFY_BOUND_DRIVER)
67 return NOTIFY_DONE;
68
69 devname = dev_name(dev);
70
71 if (!had_gpio && !strcmp(devname, GPIO_DEV)) {
72 tegra_board_pinmux_setup_gpios();
73 had_gpio = true;
74 } else if (!had_pinmux && !strcmp(devname, PINMUX_DEV)) {
75 tegra_board_pinmux_setup_pinmux();
76 had_pinmux = true;
48 } 77 }
49 78
79 if (had_gpio && had_pinmux)
80 return NOTIFY_STOP_MASK;
81 else
82 return NOTIFY_DONE;
83}
84
85static struct notifier_block nb = {
86 .notifier_call = tegra_board_pinmux_bus_notify,
87};
88
89static struct platform_device *devices[] = {
90 &tegra_gpio_device,
91 &tegra_pinmux_device,
92};
93
94void tegra_board_pinmux_init(struct tegra_board_pinmux_conf *conf_a,
95 struct tegra_board_pinmux_conf *conf_b)
96{
97 confs[0] = conf_a;
98 confs[1] = conf_b;
99
100 bus_register_notifier(&platform_bus_type, &nb);
101
50 if (!of_machine_is_compatible("nvidia,tegra20")) 102 if (!of_machine_is_compatible("nvidia,tegra20"))
51 platform_add_devices(devices, ARRAY_SIZE(devices)); 103 platform_add_devices(devices, ARRAY_SIZE(devices));
52} 104}