Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * MIPS support for CONFIG_OF device tree support
0004  *
0005  * Copyright (C) 2010 Cisco Systems Inc. <dediao@cisco.com>
0006  */
0007 
0008 #include <linux/init.h>
0009 #include <linux/export.h>
0010 #include <linux/errno.h>
0011 #include <linux/types.h>
0012 #include <linux/memblock.h>
0013 #include <linux/debugfs.h>
0014 #include <linux/of.h>
0015 #include <linux/of_fdt.h>
0016 #include <linux/of_platform.h>
0017 
0018 #include <asm/bootinfo.h>
0019 #include <asm/page.h>
0020 #include <asm/prom.h>
0021 
0022 static char mips_machine_name[64] = "Unknown";
0023 
0024 __init void mips_set_machine_name(const char *name)
0025 {
0026     if (name == NULL)
0027         return;
0028 
0029     strlcpy(mips_machine_name, name, sizeof(mips_machine_name));
0030     pr_info("MIPS: machine is %s\n", mips_get_machine_name());
0031 }
0032 
0033 char *mips_get_machine_name(void)
0034 {
0035     return mips_machine_name;
0036 }
0037 
0038 #ifdef CONFIG_USE_OF
0039 
0040 void __init __dt_setup_arch(void *bph)
0041 {
0042     if (!early_init_dt_scan(bph))
0043         return;
0044 
0045     mips_set_machine_name(of_flat_dt_get_machine_name());
0046 }
0047 
0048 int __init __dt_register_buses(const char *bus0, const char *bus1)
0049 {
0050     static struct of_device_id of_ids[3];
0051 
0052     if (!of_have_populated_dt())
0053         panic("device tree not present");
0054 
0055     strlcpy(of_ids[0].compatible, bus0, sizeof(of_ids[0].compatible));
0056     if (bus1) {
0057         strlcpy(of_ids[1].compatible, bus1,
0058             sizeof(of_ids[1].compatible));
0059     }
0060 
0061     if (of_platform_populate(NULL, of_ids, NULL, NULL))
0062         panic("failed to populate DT");
0063 
0064     return 0;
0065 }
0066 
0067 void __weak __init device_tree_init(void)
0068 {
0069     unflatten_and_copy_device_tree();
0070 }
0071 
0072 #endif