cpu_init.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * (C) Copyright 2000
  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 <watchdog.h>
  25. #include <405gp_enet.h>
  26. #include <asm/processor.h>
  27. #include <ppc4xx.h>
  28. #define mtebc(reg, data) mtdcr(ebccfga,reg);mtdcr(ebccfgd,data)
  29. /*
  30. * Breath some life into the CPU...
  31. *
  32. * Set up the memory map,
  33. * initialize a bunch of registers
  34. */
  35. void
  36. cpu_init_f (void)
  37. {
  38. /*
  39. * External Bus Controller (EBC) Setup
  40. */
  41. #if (defined(CFG_EBC_PB0AP) && defined(CFG_EBC_PB0CR))
  42. /*
  43. * Move the next instructions into icache, since these modify the flash
  44. * we are running from!
  45. */
  46. asm volatile(" bl 0f" ::: "lr");
  47. asm volatile("0: mflr 3" ::: "r3");
  48. asm volatile(" addi 4, 0, 14" ::: "r4");
  49. asm volatile(" mtctr 4" ::: "ctr");
  50. asm volatile("1: icbt 0, 3");
  51. asm volatile(" addi 3, 3, 32" ::: "r3");
  52. asm volatile(" bdnz 1b" ::: "ctr", "cr0");
  53. asm volatile(" addis 3, 0, 0x0" ::: "r3");
  54. asm volatile(" ori 3, 3, 0xA000" ::: "r3");
  55. asm volatile(" mtctr 3" ::: "ctr");
  56. asm volatile("2: bdnz 2b" ::: "ctr", "cr0");
  57. mtebc(pb0ap, CFG_EBC_PB0AP);
  58. mtebc(pb0cr, CFG_EBC_PB0CR);
  59. #endif
  60. #if (defined(CFG_EBC_PB1AP) && defined(CFG_EBC_PB1CR))
  61. mtebc(pb1ap, CFG_EBC_PB1AP);
  62. mtebc(pb1cr, CFG_EBC_PB1CR);
  63. #endif
  64. #if (defined(CFG_EBC_PB2AP) && defined(CFG_EBC_PB2CR))
  65. mtebc(pb2ap, CFG_EBC_PB2AP);
  66. mtebc(pb2cr, CFG_EBC_PB2CR);
  67. #endif
  68. #if (defined(CFG_EBC_PB3AP) && defined(CFG_EBC_PB3CR))
  69. mtebc(pb3ap, CFG_EBC_PB3AP);
  70. mtebc(pb3cr, CFG_EBC_PB3CR);
  71. #endif
  72. #if (defined(CFG_EBC_PB4AP) && defined(CFG_EBC_PB4CR))
  73. mtebc(pb4ap, CFG_EBC_PB4AP);
  74. mtebc(pb4cr, CFG_EBC_PB4CR);
  75. #endif
  76. #if (defined(CFG_EBC_PB5AP) && defined(CFG_EBC_PB5CR))
  77. mtebc(pb5ap, CFG_EBC_PB5AP);
  78. mtebc(pb5cr, CFG_EBC_PB5CR);
  79. #endif
  80. #if (defined(CFG_EBC_PB6AP) && defined(CFG_EBC_PB6CR))
  81. mtebc(pb6ap, CFG_EBC_PB6AP);
  82. mtebc(pb6cr, CFG_EBC_PB6CR);
  83. #endif
  84. #if (defined(CFG_EBC_PB7AP) && defined(CFG_EBC_PB7CR))
  85. mtebc(pb7ap, CFG_EBC_PB7AP);
  86. mtebc(pb7cr, CFG_EBC_PB7CR);
  87. #endif
  88. #if defined(CONFIG_WATCHDOG)
  89. unsigned long val;
  90. val = mfspr(tcr);
  91. val |= 0xf0000000; /* generate system reset after 2.684 seconds */
  92. mtspr(tcr, val);
  93. val = mfspr(tsr);
  94. val |= 0x80000000; /* enable watchdog timer */
  95. mtspr(tsr, val);
  96. reset_4xx_watchdog();
  97. #endif /* CONFIG_WATCHDOG */
  98. }
  99. /*
  100. * initialize higher level parts of CPU like time base and timers
  101. */
  102. int cpu_init_r (void)
  103. {
  104. #ifdef CONFIG_405GP
  105. DECLARE_GLOBAL_DATA_PTR;
  106. bd_t *bd = gd->bd;
  107. unsigned long reg;
  108. /*
  109. * Write Ethernetaddress into on-chip register
  110. */
  111. reg = 0x00000000;
  112. reg |= bd->bi_enetaddr[0]; /* set high address */
  113. reg = reg << 8;
  114. reg |= bd->bi_enetaddr[1];
  115. out32 (EMAC_IAH, reg);
  116. reg = 0x00000000;
  117. reg |= bd->bi_enetaddr[2]; /* set low address */
  118. reg = reg << 8;
  119. reg |= bd->bi_enetaddr[3];
  120. reg = reg << 8;
  121. reg |= bd->bi_enetaddr[4];
  122. reg = reg << 8;
  123. reg |= bd->bi_enetaddr[5];
  124. out32 (EMAC_IAL, reg);
  125. #endif /* CONFIG_405GP */
  126. return (0);
  127. }