cpu_init.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * (C) Copyright 2000-2003
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <mpc8220.h>
  25. /*
  26. * Breath some life into the CPU...
  27. *
  28. * Set up the memory map,
  29. * initialize a bunch of registers.
  30. */
  31. void cpu_init_f (void)
  32. {
  33. DECLARE_GLOBAL_DATA_PTR;
  34. volatile flexbus8220_t *flexbus = (volatile flexbus8220_t *) MMAP_FB;
  35. volatile pcfg8220_t *portcfg = (volatile pcfg8220_t *) MMAP_PCFG;
  36. volatile xlbarb8220_t *xlbarb = (volatile xlbarb8220_t *) MMAP_XLBARB;
  37. /* Pointer is writable since we allocated a register for it */
  38. gd = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET);
  39. /* Clear initial global data */
  40. memset ((void *) gd, 0, sizeof (gd_t));
  41. /* Clear all port configuration */
  42. portcfg->pcfg0 = 0;
  43. portcfg->pcfg1 = 0;
  44. portcfg->pcfg2 = 0;
  45. portcfg->pcfg3 = 0;
  46. /*
  47. * Flexbus Controller: configure chip selects and enable them
  48. */
  49. #if defined (CFG_CS0_BASE)
  50. flexbus->csar0 = CFG_CS0_BASE;
  51. /* Sorcery-C can hang-up after CTRL reg initialization */
  52. #if defined (CFG_CS0_CTRL)
  53. flexbus->cscr0 = CFG_CS0_CTRL;
  54. #endif
  55. flexbus->csmr0 = ((CFG_CS0_MASK - 1) & 0xffff0000) | 1;
  56. __asm__ volatile ("sync");
  57. #endif
  58. #if defined (CFG_CS1_BASE)
  59. flexbus->csar1 = CFG_CS1_BASE;
  60. flexbus->cscr1 = CFG_CS1_CTRL;
  61. flexbus->csmr1 = ((CFG_CS1_MASK - 1) & 0xffff0000) | 1;
  62. __asm__ volatile ("sync");
  63. #endif
  64. #if defined (CFG_CS2_BASE)
  65. flexbus->csar2 = CFG_CS2_BASE;
  66. flexbus->cscr2 = CFG_CS2_CTRL;
  67. flexbus->csmr2 = ((CFG_CS2_MASK - 1) & 0xffff0000) | 1;
  68. portcfg->pcfg3 |= CFG_CS2_PORT3_CONFIG;
  69. __asm__ volatile ("sync");
  70. #endif
  71. #if defined (CFG_CS3_BASE)
  72. flexbus->csar3 = CFG_CS3_BASE;
  73. flexbus->cscr3 = CFG_CS3_CTRL;
  74. flexbus->csmr3 = ((CFG_CS3_MASK - 1) & 0xffff0000) | 1;
  75. portcfg->pcfg3 |= CFG_CS3_PORT3_CONFIG;
  76. __asm__ volatile ("sync");
  77. #endif
  78. #if defined (CFG_CS4_BASE)
  79. flexbus->csar4 = CFG_CS4_BASE;
  80. flexbus->cscr4 = CFG_CS4_CTRL;
  81. flexbus->csmr4 = ((CFG_CS4_MASK - 1) & 0xffff0000) | 1;
  82. portcfg->pcfg3 |= CFG_CS4_PORT3_CONFIG;
  83. __asm__ volatile ("sync");
  84. #endif
  85. #if defined (CFG_CS5_BASE)
  86. flexbus->csar5 = CFG_CS5_BASE;
  87. flexbus->cscr5 = CFG_CS5_CTRL;
  88. flexbus->csmr5 = ((CFG_CS5_MASK - 1) & 0xffff0000) | 1;
  89. portcfg->pcfg3 |= CFG_CS5_PORT3_CONFIG;
  90. __asm__ volatile ("sync");
  91. #endif
  92. /* This section of the code cannot place in cpu_init_r(),
  93. it will cause the system to hang */
  94. /* enable timebase */
  95. xlbarb->addrTenTimeOut = 0x1000;
  96. xlbarb->dataTenTimeOut = 0x1000;
  97. xlbarb->busActTimeOut = 0x2000;
  98. xlbarb->config = 0x00002000;
  99. /* Master Priority Enable */
  100. xlbarb->mastPriority = 0;
  101. xlbarb->mastPriEn = 0x1f;
  102. }
  103. /*
  104. * initialize higher level parts of CPU like time base and timers
  105. */
  106. int cpu_init_r (void)
  107. {
  108. /* this may belongs to disable interrupt section */
  109. /* mask all interrupts */
  110. *(vu_long *) 0xf0000700 = 0xfffffc00;
  111. *(vu_long *) 0xf0000714 |= 0x0001ffff;
  112. *(vu_long *) 0xf0000710 &= ~0x00000f00;
  113. /* route critical ints to normal ints */
  114. *(vu_long *) 0xf0000710 |= 0x00000001;
  115. #if (CONFIG_COMMANDS & CFG_CMD_NET) && defined(CONFIG_MPC8220_FEC)
  116. /* load FEC microcode */
  117. loadtask (0, 2);
  118. #endif
  119. return (0);
  120. }