cpu_init.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. flexbus->cscr0 = CFG_CS0_CTRL;
  52. flexbus->csmr0 = ((CFG_CS0_MASK - 1) & 0xffff0000) | 1;
  53. __asm__ volatile ("sync");
  54. #endif
  55. #if defined (CFG_CS1_BASE)
  56. flexbus->csar1 = CFG_CS1_BASE;
  57. flexbus->cscr1 = CFG_CS1_CTRL;
  58. flexbus->csmr1 = ((CFG_CS1_MASK - 1) & 0xffff0000) | 1;
  59. __asm__ volatile ("sync");
  60. #endif
  61. #if defined (CFG_CS2_BASE)
  62. flexbus->csar2 = CFG_CS2_BASE;
  63. flexbus->cscr2 = CFG_CS2_CTRL;
  64. flexbus->csmr2 = ((CFG_CS2_MASK - 1) & 0xffff0000) | 1;
  65. portcfg->pcfg3 |= CFG_CS2_PORT3_CONFIG;
  66. __asm__ volatile ("sync");
  67. #endif
  68. #if defined (CFG_CS3_BASE)
  69. flexbus->csar3 = CFG_CS3_BASE;
  70. flexbus->cscr3 = CFG_CS3_CTRL;
  71. flexbus->csmr3 = ((CFG_CS3_MASK - 1) & 0xffff0000) | 1;
  72. portcfg->pcfg3 |= CFG_CS3_PORT3_CONFIG;
  73. __asm__ volatile ("sync");
  74. #endif
  75. #if defined (CFG_CS4_BASE)
  76. flexbus->csar4 = CFG_CS4_BASE;
  77. flexbus->cscr4 = CFG_CS4_CTRL;
  78. flexbus->csmr4 = ((CFG_CS4_MASK - 1) & 0xffff0000) | 1;
  79. portcfg->pcfg3 |= CFG_CS4_PORT3_CONFIG;
  80. __asm__ volatile ("sync");
  81. #endif
  82. #if defined (CFG_CS5_BASE)
  83. flexbus->csar5 = CFG_CS5_BASE;
  84. flexbus->cscr5 = CFG_CS5_CTRL;
  85. flexbus->csmr5 = ((CFG_CS5_MASK - 1) & 0xffff0000) | 1;
  86. portcfg->pcfg3 |= CFG_CS5_PORT3_CONFIG;
  87. __asm__ volatile ("sync");
  88. #endif
  89. /* This section of the code cannot place in cpu_init_r(),
  90. it will cause the system to hang */
  91. /* enable timebase */
  92. xlbarb->config = 0x00002000;
  93. xlbarb->addrTenTimeOut = 0x1000;
  94. xlbarb->dataTenTimeOut = 0x1000;
  95. xlbarb->busActTimeOut = 0x2000;
  96. /* Master Priority Enable */
  97. xlbarb->mastPriEn = 0x1f;
  98. xlbarb->mastPriority = 0;
  99. }
  100. /*
  101. * initialize higher level parts of CPU like time base and timers
  102. */
  103. int cpu_init_r (void)
  104. {
  105. /* this may belongs to disable interrupt section */
  106. /* mask all interrupts */
  107. *(vu_long *) 0xf0000700 = 0xfffffc00;
  108. *(vu_long *) 0xf0000714 |= 0x0001ffff;
  109. *(vu_long *) 0xf0000710 &= ~0x00000f00;
  110. /* route critical ints to normal ints */
  111. *(vu_long *) 0xf0000710 |= 0x00000001;
  112. #if (CONFIG_COMMANDS & CFG_CMD_NET) && defined(CONFIG_MPC8220_FEC)
  113. /* load FEC microcode */
  114. loadtask (0, 2);
  115. #endif
  116. return (0);
  117. }