aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorKevin Cernekee <cernekee@gmail.com>2014-10-21 00:28:02 -0400
committerRalf Baechle <ralf@linux-mips.org>2014-11-24 01:45:12 -0500
commit84988c068108c99cf0e7d2391f5bf6bd91e2494c (patch)
tree6e0fcbfa1e23b9606a424fbaf9edd1e70d572bac /arch
parent68e6a78373a6d3ab6d2811f891596fdd8408efec (diff)
MIPS: Create a helper function for DT setup
A couple of platforms register two buses and call of_platform_populate(). Move this into a common function to reduce duplication. Signed-off-by: Kevin Cernekee <cernekee@gmail.com> Cc: f.fainelli@gmail.com Cc: mbizon@freebox.fr Cc: jogo@openwrt.org Cc: jfraser@broadcom.com Cc: linux-mips@linux-mips.org Cc: devicetree@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/8167/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/mips/include/asm/prom.h1
-rw-r--r--arch/mips/kernel/prom.c18
-rw-r--r--arch/mips/lantiq/prom.c11
-rw-r--r--arch/mips/ralink/of.c14
4 files changed, 22 insertions, 22 deletions
diff --git a/arch/mips/include/asm/prom.h b/arch/mips/include/asm/prom.h
index a9494c0141fb..eaa26270a5e5 100644
--- a/arch/mips/include/asm/prom.h
+++ b/arch/mips/include/asm/prom.h
@@ -22,6 +22,7 @@ extern void device_tree_init(void);
22struct boot_param_header; 22struct boot_param_header;
23 23
24extern void __dt_setup_arch(void *bph); 24extern void __dt_setup_arch(void *bph);
25extern int __dt_register_buses(const char *bus0, const char *bus1);
25 26
26#define dt_setup_arch(sym) \ 27#define dt_setup_arch(sym) \
27({ \ 28({ \
diff --git a/arch/mips/kernel/prom.c b/arch/mips/kernel/prom.c
index 5d39bb85bf35..452d4350ce42 100644
--- a/arch/mips/kernel/prom.c
+++ b/arch/mips/kernel/prom.c
@@ -16,6 +16,7 @@
16#include <linux/debugfs.h> 16#include <linux/debugfs.h>
17#include <linux/of.h> 17#include <linux/of.h>
18#include <linux/of_fdt.h> 18#include <linux/of_fdt.h>
19#include <linux/of_platform.h>
19 20
20#include <asm/page.h> 21#include <asm/page.h>
21#include <asm/prom.h> 22#include <asm/prom.h>
@@ -54,4 +55,21 @@ void __init __dt_setup_arch(void *bph)
54 55
55 mips_set_machine_name(of_flat_dt_get_machine_name()); 56 mips_set_machine_name(of_flat_dt_get_machine_name());
56} 57}
58
59int __init __dt_register_buses(const char *bus0, const char *bus1)
60{
61 static struct of_device_id of_ids[3];
62
63 if (!of_have_populated_dt())
64 panic("device tree not present");
65
66 strlcpy(of_ids[0].compatible, bus0, sizeof(of_ids[0].compatible));
67 strlcpy(of_ids[1].compatible, bus1, sizeof(of_ids[1].compatible));
68
69 if (of_platform_populate(NULL, of_ids, NULL, NULL))
70 panic("failed to populate DT");
71
72 return 0;
73}
74
57#endif 75#endif
diff --git a/arch/mips/lantiq/prom.c b/arch/mips/lantiq/prom.c
index 7447d322d14e..758970e3815b 100644
--- a/arch/mips/lantiq/prom.c
+++ b/arch/mips/lantiq/prom.c
@@ -97,16 +97,7 @@ void __init prom_init(void)
97 97
98int __init plat_of_setup(void) 98int __init plat_of_setup(void)
99{ 99{
100 static struct of_device_id of_ids[3]; 100 return __dt_register_buses(soc_info.compatible, "simple-bus");
101
102 if (!of_have_populated_dt())
103 panic("device tree not present");
104
105 strlcpy(of_ids[0].compatible, soc_info.compatible,
106 sizeof(of_ids[0].compatible));
107 strncpy(of_ids[1].compatible, "simple-bus",
108 sizeof(of_ids[1].compatible));
109 return of_platform_populate(NULL, of_ids, NULL, NULL);
110} 101}
111 102
112arch_initcall(plat_of_setup); 103arch_initcall(plat_of_setup);
diff --git a/arch/mips/ralink/of.c b/arch/mips/ralink/of.c
index 7c4598cb6de8..f68115fd98ef 100644
--- a/arch/mips/ralink/of.c
+++ b/arch/mips/ralink/of.c
@@ -74,19 +74,9 @@ void __init plat_mem_setup(void)
74 74
75static int __init plat_of_setup(void) 75static int __init plat_of_setup(void)
76{ 76{
77 static struct of_device_id of_ids[3]; 77 __dt_register_buses(soc_info.compatible, "palmbus");
78 int len = sizeof(of_ids[0].compatible);
79 78
80 if (!of_have_populated_dt()) 79 /* make sure that the reset controller is setup early */
81 panic("device tree not present");
82
83 strlcpy(of_ids[0].compatible, soc_info.compatible, len);
84 strlcpy(of_ids[1].compatible, "palmbus", len);
85
86 if (of_platform_populate(NULL, of_ids, NULL, NULL))
87 panic("failed to populate DT");
88
89 /* make sure ithat the reset controller is setup early */
90 ralink_rst_init(); 80 ralink_rst_init();
91 81
92 return 0; 82 return 0;