prom.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * MIPS support for CONFIG_OF device tree support
  3. *
  4. * Copyright (C) 2010 Cisco Systems Inc. <dediao@cisco.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/init.h>
  11. #include <linux/export.h>
  12. #include <linux/errno.h>
  13. #include <linux/types.h>
  14. #include <linux/bootmem.h>
  15. #include <linux/initrd.h>
  16. #include <linux/debugfs.h>
  17. #include <linux/of.h>
  18. #include <linux/of_fdt.h>
  19. #include <linux/of_irq.h>
  20. #include <linux/of_platform.h>
  21. #include <asm/page.h>
  22. #include <asm/prom.h>
  23. int __init early_init_dt_scan_memory_arch(unsigned long node,
  24. const char *uname, int depth,
  25. void *data)
  26. {
  27. return early_init_dt_scan_memory(node, uname, depth, data);
  28. }
  29. void __init early_init_dt_add_memory_arch(u64 base, u64 size)
  30. {
  31. return add_memory_region(base, size, BOOT_MEM_RAM);
  32. }
  33. void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
  34. {
  35. return __alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS));
  36. }
  37. #ifdef CONFIG_BLK_DEV_INITRD
  38. void __init early_init_dt_setup_initrd_arch(unsigned long start,
  39. unsigned long end)
  40. {
  41. initrd_start = (unsigned long)__va(start);
  42. initrd_end = (unsigned long)__va(end);
  43. initrd_below_start_ok = 1;
  44. }
  45. #endif
  46. void __init early_init_devtree(void *params)
  47. {
  48. /* Setup flat device-tree pointer */
  49. initial_boot_params = params;
  50. /* Retrieve various informations from the /chosen node of the
  51. * device-tree, including the platform type, initrd location and
  52. * size, and more ...
  53. */
  54. of_scan_flat_dt(early_init_dt_scan_chosen, arcs_cmdline);
  55. /* Scan memory nodes */
  56. of_scan_flat_dt(early_init_dt_scan_root, NULL);
  57. of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL);
  58. }
  59. void __init __dt_setup_arch(struct boot_param_header *bph)
  60. {
  61. if (be32_to_cpu(bph->magic) != OF_DT_HEADER) {
  62. pr_err("DTB has bad magic, ignoring builtin OF DTB\n");
  63. return;
  64. }
  65. initial_boot_params = bph;
  66. early_init_devtree(initial_boot_params);
  67. }