prom.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Procedures for creating, accessing and interpreting the device tree.
  3. *
  4. * Paul Mackerras August 1996.
  5. * Copyright (C) 1996-2005 Paul Mackerras.
  6. *
  7. * Adapted for 64bit PowerPC by Dave Engebretsen and Peter Bergner.
  8. * {engebret|bergner}@us.ibm.com
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License
  12. * as published by the Free Software Foundation; either version
  13. * 2 of the License, or (at your option) any later version.
  14. */
  15. #include <stdarg.h>
  16. #include <linux/export.h>
  17. #include <linux/kernel.h>
  18. #include <linux/string.h>
  19. #include <linux/init.h>
  20. #include <linux/threads.h>
  21. #include <linux/spinlock.h>
  22. #include <linux/types.h>
  23. #include <linux/pci.h>
  24. #include <linux/stringify.h>
  25. #include <linux/delay.h>
  26. #include <linux/initrd.h>
  27. #include <linux/bitops.h>
  28. #include <linux/kexec.h>
  29. #include <linux/debugfs.h>
  30. #include <linux/irq.h>
  31. #include <linux/memblock.h>
  32. #include <linux/of_fdt.h>
  33. #include <asm/prom.h>
  34. #include <asm/page.h>
  35. #include <asm/processor.h>
  36. #include <asm/irq.h>
  37. #include <linux/io.h>
  38. #include <asm/mmu.h>
  39. #include <asm/pgtable.h>
  40. #include <asm/sections.h>
  41. #include <asm/pci-bridge.h>
  42. #ifdef CONFIG_EARLY_PRINTK
  43. static const char *stdout;
  44. static int __init early_init_dt_scan_chosen_serial(unsigned long node,
  45. const char *uname, int depth, void *data)
  46. {
  47. int l;
  48. const char *p;
  49. pr_debug("%s: depth: %d, uname: %s\n", __func__, depth, uname);
  50. if (depth == 1 && (strcmp(uname, "chosen") == 0 ||
  51. strcmp(uname, "chosen@0") == 0)) {
  52. p = of_get_flat_dt_prop(node, "linux,stdout-path", &l);
  53. if (p != NULL && l > 0)
  54. stdout = p; /* store pointer to stdout-path */
  55. }
  56. if (stdout && strstr(stdout, uname)) {
  57. p = of_get_flat_dt_prop(node, "compatible", &l);
  58. pr_debug("Compatible string: %s\n", p);
  59. if ((strncmp(p, "xlnx,xps-uart16550", 18) == 0) ||
  60. (strncmp(p, "xlnx,axi-uart16550", 18) == 0)) {
  61. unsigned int addr;
  62. *(u32 *)data = UART16550;
  63. addr = *(u32 *)of_get_flat_dt_prop(node, "reg", &l);
  64. addr += *(u32 *)of_get_flat_dt_prop(node,
  65. "reg-offset", &l);
  66. /* clear register offset */
  67. return be32_to_cpu(addr) & ~3;
  68. }
  69. if ((strncmp(p, "xlnx,xps-uartlite", 17) == 0) ||
  70. (strncmp(p, "xlnx,opb-uartlite", 17) == 0) ||
  71. (strncmp(p, "xlnx,axi-uartlite", 17) == 0) ||
  72. (strncmp(p, "xlnx,mdm", 8) == 0)) {
  73. const unsigned int *addrp;
  74. *(u32 *)data = UARTLITE;
  75. addrp = of_get_flat_dt_prop(node, "reg", &l);
  76. return be32_to_cpup(addrp); /* return address */
  77. }
  78. }
  79. return 0;
  80. }
  81. /* this function is looking for early console - Microblaze specific */
  82. int __init of_early_console(void *version)
  83. {
  84. return of_scan_flat_dt(early_init_dt_scan_chosen_serial, version);
  85. }
  86. #endif
  87. void __init early_init_devtree(void *params)
  88. {
  89. pr_debug(" -> early_init_devtree(%p)\n", params);
  90. early_init_dt_scan(params);
  91. if (!strlen(boot_command_line))
  92. strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE);
  93. parse_early_param();
  94. memblock_allow_resize();
  95. pr_debug("Phys. mem: %lx\n", (unsigned long) memblock_phys_mem_size());
  96. pr_debug(" <- early_init_devtree()\n");
  97. }