xref: /openbmc/linux/arch/mips/kernel/prom.c (revision 877336c1)
1d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
2f2ffa5abSDezhong Diao /*
3f2ffa5abSDezhong Diao  * MIPS support for CONFIG_OF device tree support
4f2ffa5abSDezhong Diao  *
5f2ffa5abSDezhong Diao  * Copyright (C) 2010 Cisco Systems Inc. <dediao@cisco.com>
6f2ffa5abSDezhong Diao  */
7f2ffa5abSDezhong Diao 
8f2ffa5abSDezhong Diao #include <linux/init.h>
973bc256dSPaul Gortmaker #include <linux/export.h>
10f2ffa5abSDezhong Diao #include <linux/errno.h>
11f2ffa5abSDezhong Diao #include <linux/types.h>
1257c8a661SMike Rapoport #include <linux/memblock.h>
13f2ffa5abSDezhong Diao #include <linux/debugfs.h>
14f2ffa5abSDezhong Diao #include <linux/of.h>
15f2ffa5abSDezhong Diao #include <linux/of_fdt.h>
1684988c06SKevin Cernekee #include <linux/of_platform.h>
17f2ffa5abSDezhong Diao 
1801306aeaSRob Herring #include <asm/bootinfo.h>
19f2ffa5abSDezhong Diao #include <asm/page.h>
20f2ffa5abSDezhong Diao #include <asm/prom.h>
21f2ffa5abSDezhong Diao 
229169a5d0SJohn Crispin static char mips_machine_name[64] = "Unknown";
239169a5d0SJohn Crispin 
mips_set_machine_name(const char * name)249169a5d0SJohn Crispin __init void mips_set_machine_name(const char *name)
259169a5d0SJohn Crispin {
269169a5d0SJohn Crispin 	if (name == NULL)
279169a5d0SJohn Crispin 		return;
289169a5d0SJohn Crispin 
29*877336c1SWolfram Sang 	strscpy(mips_machine_name, name, sizeof(mips_machine_name));
309169a5d0SJohn Crispin 	pr_info("MIPS: machine is %s\n", mips_get_machine_name());
319169a5d0SJohn Crispin }
329169a5d0SJohn Crispin 
mips_get_machine_name(void)339169a5d0SJohn Crispin char *mips_get_machine_name(void)
349169a5d0SJohn Crispin {
359169a5d0SJohn Crispin 	return mips_machine_name;
369169a5d0SJohn Crispin }
379169a5d0SJohn Crispin 
38d3557d96SJonas Gorski #ifdef CONFIG_USE_OF
3973346081SMarcin Nowakowski 
__dt_setup_arch(void * bph)400cdde839SRob Herring void __init __dt_setup_arch(void *bph)
41f2ffa5abSDezhong Diao {
42f75813c0SRob Herring 	if (!early_init_dt_scan(bph))
43f75813c0SRob Herring 		return;
449169a5d0SJohn Crispin 
4597e7f455SRob Herring 	mips_set_machine_name(of_flat_dt_get_machine_name());
46f2ffa5abSDezhong Diao }
4784988c06SKevin Cernekee 
__dt_register_buses(const char * bus0,const char * bus1)4884988c06SKevin Cernekee int __init __dt_register_buses(const char *bus0, const char *bus1)
4984988c06SKevin Cernekee {
5084988c06SKevin Cernekee 	static struct of_device_id of_ids[3];
5184988c06SKevin Cernekee 
5284988c06SKevin Cernekee 	if (!of_have_populated_dt())
5384988c06SKevin Cernekee 		panic("device tree not present");
5484988c06SKevin Cernekee 
55*877336c1SWolfram Sang 	strscpy(of_ids[0].compatible, bus0, sizeof(of_ids[0].compatible));
569127dc47SKevin Cernekee 	if (bus1) {
57*877336c1SWolfram Sang 		strscpy(of_ids[1].compatible, bus1,
589127dc47SKevin Cernekee 			sizeof(of_ids[1].compatible));
599127dc47SKevin Cernekee 	}
6084988c06SKevin Cernekee 
6184988c06SKevin Cernekee 	if (of_platform_populate(NULL, of_ids, NULL, NULL))
6284988c06SKevin Cernekee 		panic("failed to populate DT");
6384988c06SKevin Cernekee 
6484988c06SKevin Cernekee 	return 0;
6584988c06SKevin Cernekee }
6684988c06SKevin Cernekee 
device_tree_init(void)67cd04d58eSTiezhu Yang void __weak __init device_tree_init(void)
68cd04d58eSTiezhu Yang {
69cd04d58eSTiezhu Yang 	unflatten_and_copy_device_tree();
70cd04d58eSTiezhu Yang }
71cd04d58eSTiezhu Yang 
729169a5d0SJohn Crispin #endif
73