fdt.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright 2008 Freescale Semiconductor, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * Version 2 as published by the Free Software Foundation.
  7. */
  8. #include <common.h>
  9. #include <libfdt.h>
  10. #include <fdt_support.h>
  11. #include "mp.h"
  12. DECLARE_GLOBAL_DATA_PTR;
  13. void ft_cpu_setup(void *blob, bd_t *bd)
  14. {
  15. #if (CONFIG_NUM_CPUS > 1)
  16. int off;
  17. u32 bootpg;
  18. #endif
  19. do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
  20. "timebase-frequency", bd->bi_busfreq / 4, 1);
  21. do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
  22. "bus-frequency", bd->bi_busfreq, 1);
  23. do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
  24. "clock-frequency", bd->bi_intfreq, 1);
  25. do_fixup_by_prop_u32(blob, "device_type", "soc", 4,
  26. "bus-frequency", bd->bi_busfreq, 1);
  27. #if defined(CONFIG_MPC8641)
  28. do_fixup_by_compat_u32(blob, "fsl,mpc8641-localbus",
  29. "bus-frequency", gd->lbc_clk, 1);
  30. #endif
  31. do_fixup_by_compat_u32(blob, "fsl,elbc",
  32. "bus-frequency", gd->lbc_clk, 1);
  33. fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
  34. #if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) \
  35. || defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
  36. fdt_fixup_ethernet(blob);
  37. #endif
  38. #ifdef CONFIG_SYS_NS16550
  39. do_fixup_by_compat_u32(blob, "ns16550",
  40. "clock-frequency", CONFIG_SYS_NS16550_CLK, 1);
  41. #endif
  42. #if (CONFIG_NUM_CPUS > 1)
  43. /* if we have 4G or more of memory, put the boot page at 4Gb-1M */
  44. if (gd->ram_size > 0xfffff000)
  45. bootpg = 0xfff00000;
  46. else
  47. bootpg = gd->ram_size - (1024 * 1024);
  48. /* Reserve the boot page so OSes dont use it */
  49. off = fdt_add_mem_rsv(blob, bootpg, (u64)4096);
  50. if (off < 0)
  51. printf("%s: %s\n", __FUNCTION__, fdt_strerror(off));
  52. #endif
  53. }