cpu_init.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright 2004,2009-2011 Freescale Semiconductor, Inc.
  3. * Jeff Brown
  4. * Srikanth Srinivasan (srikanth.srinivasan@freescale.com)
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. /*
  9. * cpu_init.c - low level cpu init
  10. */
  11. #include <config.h>
  12. #include <common.h>
  13. #include <mpc86xx.h>
  14. #include <asm/mmu.h>
  15. #include <asm/fsl_law.h>
  16. #include <asm/fsl_serdes.h>
  17. #include <asm/mp.h>
  18. extern void srio_init(void);
  19. DECLARE_GLOBAL_DATA_PTR;
  20. /*
  21. * Breathe some life into the CPU...
  22. *
  23. * Set up the memory map
  24. * initialize a bunch of registers
  25. */
  26. void cpu_init_f(void)
  27. {
  28. /* Pointer is writable since we allocated a register for it */
  29. gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
  30. /* Clear initial global data */
  31. memset ((void *) gd, 0, sizeof (gd_t));
  32. #ifdef CONFIG_FSL_LAW
  33. init_laws();
  34. #endif
  35. setup_bats();
  36. init_early_memctl_regs();
  37. #if defined(CONFIG_FSL_DMA)
  38. dma_init();
  39. #endif
  40. /* enable the timebase bit in HID0 */
  41. set_hid0(get_hid0() | 0x4000000);
  42. /* enable EMCP, SYNCBE | ABE bits in HID1 */
  43. set_hid1(get_hid1() | 0x80000C00);
  44. }
  45. /*
  46. * initialize higher level parts of CPU like timers
  47. */
  48. int cpu_init_r(void)
  49. {
  50. /* needs to be in ram since code uses global static vars */
  51. fsl_serdes_init();
  52. #ifdef CONFIG_SYS_SRIO
  53. srio_init();
  54. #endif
  55. #if defined(CONFIG_MP)
  56. setup_mp();
  57. #endif
  58. return 0;
  59. }
  60. #ifdef CONFIG_ADDR_MAP
  61. /* Initialize address mapping array */
  62. void init_addr_map(void)
  63. {
  64. int i;
  65. ppc_bat_t bat = DBAT0;
  66. phys_size_t size;
  67. unsigned long upper, lower;
  68. for (i = 0; i < CONFIG_SYS_NUM_ADDR_MAP; i++, bat++) {
  69. if (read_bat(bat, &upper, &lower) != -1) {
  70. if (!BATU_VALID(upper))
  71. size = 0;
  72. else
  73. size = BATU_SIZE(upper);
  74. addrmap_set_entry(BATU_VADDR(upper), BATL_PADDR(lower),
  75. size, i);
  76. }
  77. #ifdef CONFIG_HIGH_BATS
  78. /* High bats are not contiguous with low BAT numbers */
  79. if (bat == DBAT3)
  80. bat = DBAT4 - 1;
  81. #endif
  82. }
  83. }
  84. #endif