cpu_init.c 1.9 KB

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