init.S 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*------------------------------------------------------------------------+ */
  2. /* */
  3. /* This source code has been made available to you by IBM on an AS-IS */
  4. /* basis. Anyone receiving this source is licensed under IBM */
  5. /* copyrights to use it in any way he or she deems fit, including */
  6. /* copying it, modifying it, compiling it, and redistributing it either */
  7. /* with or without modifications. No license under IBM patents or */
  8. /* patent applications is to be implied by the copyright license. */
  9. /* */
  10. /* Any user of this software should understand that IBM cannot provide */
  11. /* technical support for this software and will not be responsible for */
  12. /* any consequences resulting from the use of this software. */
  13. /* */
  14. /* Any person who transfers this source code or any derivative work */
  15. /* must include the IBM copyright notice, this paragraph, and the */
  16. /* preceding two paragraphs in the transferred software. */
  17. /* */
  18. /* COPYRIGHT I B M CORPORATION 1995 */
  19. /* LICENSED MATERIAL - PROGRAM PROPERTY OF I B M */
  20. /*------------------------------------------------------------------------- */
  21. /*------------------------------------------------------------------------- */
  22. /* Function: ext_bus_cntlr_init */
  23. /* Description: Initializes the External Bus Controller for the external */
  24. /* peripherals. IMPORTANT: For pass1 this code must run from */
  25. /* cache since you can not reliably change a peripheral banks */
  26. /* timing register (pbxap) while running code from that bank. */
  27. /* For ex., since we are running from ROM on bank 0, we can NOT */
  28. /* execute the code that modifies bank 0 timings from ROM, so */
  29. /* we run it from cache. */
  30. /* */
  31. /* */
  32. /* The layout for the PEI JSE board: */
  33. /* Bank 0 - Flash and SRAM */
  34. /* Bank 1 - SystemACE */
  35. /* Bank 2 - not used */
  36. /* Bank 3 - not used */
  37. /* Bank 4 - not used */
  38. /* Bank 5 - not used */
  39. /* Bank 6 - not used */
  40. /* Bank 7 - not used */
  41. /*------------------------------------------------------------------------- */
  42. #include <ppc4xx.h>
  43. #include <ppc_asm.tmpl>
  44. #include <ppc_defs.h>
  45. #include <asm/cache.h>
  46. #include <asm/mmu.h>
  47. #define cpc0_cr0 0xB1
  48. .globl ext_bus_cntlr_init
  49. ext_bus_cntlr_init:
  50. mflr r4 /* save link register */
  51. bl ..getAddr
  52. ..getAddr:
  53. mflr r3 /* get address of ..getAddr */
  54. mtlr r4 /* restore link register */
  55. addi r4,0,14 /* set ctr to 10; used to prefetch */
  56. mtctr r4 /* 10 cache lines to fit this function */
  57. /* in cache (gives us 8x10=80 instrctns) */
  58. ..ebcloop:
  59. icbt r0,r3 /* prefetch cache line for addr in r3 */
  60. addi r3,r3,32 /* move to next cache line */
  61. bdnz ..ebcloop /* continue for 10 cache lines */
  62. /*----------------------------------------------------------------- */
  63. /* Delay to ensure all accesses to ROM are complete before changing */
  64. /* bank 0 timings. 200usec should be enough. */
  65. /* 200,000,000 (cycles/sec) X .000200 (sec) = 0x9C40 cycles */
  66. /*----------------------------------------------------------------- */
  67. addis r3,0,0x0
  68. ori r3,r3,0xA000 /* ensure 200usec have passed since reset */
  69. mtctr r3
  70. ..spinlp:
  71. bdnz ..spinlp /* spin loop */
  72. /*----------------------------------------------------------------- */
  73. /* Memory Bank 0 (Flash) initialization */
  74. /*----------------------------------------------------------------- */
  75. addi r4,0,pb0ap
  76. mtdcr ebccfga,r4
  77. addis r4,0,0x9B01
  78. ori r4,r4,0x5480
  79. mtdcr ebccfgd,r4
  80. addi r4,0,pb0cr
  81. mtdcr ebccfga,r4
  82. addis r4,0,0xFFF1 /* BAS=0xFFF,BS=0x0(1MB),BU=0x3(R/W), */
  83. ori r4,r4,0x8000 /* BW=0x0( 8 bits) */
  84. mtdcr ebccfgd,r4
  85. blr