treeboot-iss4xx.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright 2010 Ben. Herrenschmidt, IBM Corporation.
  3. *
  4. * Based on earlier code:
  5. * Copyright (C) Paul Mackerras 1997.
  6. *
  7. * Matt Porter <mporter@kernel.crashing.org>
  8. * Copyright 2002-2005 MontaVista Software Inc.
  9. *
  10. * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
  11. * Copyright (c) 2003, 2004 Zultys Technologies
  12. *
  13. * Copyright 2007 David Gibson, IBM Corporation.
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License
  17. * as published by the Free Software Foundation; either version
  18. * 2 of the License, or (at your option) any later version.
  19. */
  20. #include <stdarg.h>
  21. #include <stddef.h>
  22. #include "types.h"
  23. #include "elf.h"
  24. #include "string.h"
  25. #include "stdio.h"
  26. #include "page.h"
  27. #include "ops.h"
  28. #include "reg.h"
  29. #include "io.h"
  30. #include "dcr.h"
  31. #include "4xx.h"
  32. #include "44x.h"
  33. #include "libfdt.h"
  34. BSS_STACK(4096);
  35. static u32 ibm4xx_memstart;
  36. static void iss_4xx_fixups(void)
  37. {
  38. void *memory;
  39. u32 reg[3];
  40. memory = finddevice("/memory");
  41. if (!memory)
  42. fatal("Can't find memory node\n");
  43. /* This assumes #address-cells = 2, #size-cells =1 and that */
  44. getprop(memory, "reg", reg, sizeof(reg));
  45. if (reg[2])
  46. /* If the device tree specifies the memory range, use it */
  47. ibm4xx_memstart = reg[1];
  48. else
  49. /* othersize, read it from the SDRAM controller */
  50. ibm4xx_sdram_fixup_memsize();
  51. }
  52. static void *iss_4xx_vmlinux_alloc(unsigned long size)
  53. {
  54. return (void *)ibm4xx_memstart;
  55. }
  56. #define SPRN_PIR 0x11E /* Processor Identification Register */
  57. void platform_init(void)
  58. {
  59. unsigned long end_of_ram = 0x08000000;
  60. unsigned long avail_ram = end_of_ram - (unsigned long)_end;
  61. u32 pir_reg;
  62. simple_alloc_init(_end, avail_ram, 128, 64);
  63. platform_ops.fixups = iss_4xx_fixups;
  64. platform_ops.vmlinux_alloc = iss_4xx_vmlinux_alloc;
  65. platform_ops.exit = ibm44x_dbcr_reset;
  66. pir_reg = mfspr(SPRN_PIR);
  67. fdt_set_boot_cpuid_phys(_dtb_start, pir_reg);
  68. fdt_init(_dtb_start);
  69. serial_console_init();
  70. }