prom.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * MIPS support for CONFIG_OF device tree support
  4. *
  5. * Copyright (C) 2010 Cisco Systems Inc. <[email protected]>
  6. */
  7. #include <linux/init.h>
  8. #include <linux/export.h>
  9. #include <linux/errno.h>
  10. #include <linux/types.h>
  11. #include <linux/memblock.h>
  12. #include <linux/debugfs.h>
  13. #include <linux/of.h>
  14. #include <linux/of_fdt.h>
  15. #include <linux/of_platform.h>
  16. #include <asm/bootinfo.h>
  17. #include <asm/page.h>
  18. #include <asm/prom.h>
  19. static char mips_machine_name[64] = "Unknown";
  20. __init void mips_set_machine_name(const char *name)
  21. {
  22. if (name == NULL)
  23. return;
  24. strscpy(mips_machine_name, name, sizeof(mips_machine_name));
  25. pr_info("MIPS: machine is %s\n", mips_get_machine_name());
  26. }
  27. char *mips_get_machine_name(void)
  28. {
  29. return mips_machine_name;
  30. }
  31. #ifdef CONFIG_USE_OF
  32. void __init __dt_setup_arch(void *bph)
  33. {
  34. if (!early_init_dt_scan(bph))
  35. return;
  36. mips_set_machine_name(of_flat_dt_get_machine_name());
  37. }
  38. int __init __dt_register_buses(const char *bus0, const char *bus1)
  39. {
  40. static struct of_device_id of_ids[3];
  41. if (!of_have_populated_dt())
  42. panic("device tree not present");
  43. strscpy(of_ids[0].compatible, bus0, sizeof(of_ids[0].compatible));
  44. if (bus1) {
  45. strscpy(of_ids[1].compatible, bus1,
  46. sizeof(of_ids[1].compatible));
  47. }
  48. if (of_platform_populate(NULL, of_ids, NULL, NULL))
  49. panic("failed to populate DT");
  50. return 0;
  51. }
  52. void __weak __init device_tree_init(void)
  53. {
  54. unflatten_and_copy_device_tree();
  55. }
  56. #endif