init.S 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * SPDX-License-Identifier: GPL-2.0 IBM-pibs
  3. */
  4. /*----------------------------------------------------------------------------- */
  5. /* Function: ext_bus_cntlr_init */
  6. /* Description: Initializes the External Bus Controller for the external */
  7. /* peripherals. IMPORTANT: For pass1 this code must run from */
  8. /* cache since you can not reliably change a peripheral banks */
  9. /* timing register (pbxap) while running code from that bank. */
  10. /* For ex., since we are running from ROM on bank 0, we can NOT */
  11. /* execute the code that modifies bank 0 timings from ROM, so */
  12. /* we run it from cache. */
  13. /* Bank 0 - Flash and SRAM */
  14. /* Bank 1 - NVRAM/RTC */
  15. /* Bank 2 - Keyboard/Mouse controller */
  16. /* Bank 3 - IR controller */
  17. /* Bank 4 - not used */
  18. /* Bank 5 - not used */
  19. /* Bank 6 - not used */
  20. /* Bank 7 - FPGA registers */
  21. /*-----------------------------------------------------------------------------#include <config.h> */
  22. #include <asm/ppc4xx.h>
  23. #include <ppc_asm.tmpl>
  24. #include <ppc_defs.h>
  25. #include <asm/cache.h>
  26. #include <asm/mmu.h>
  27. /* CRAY - L1: only nominally a 'walnut', since ext.Bus.Cntlr is all empty */
  28. /* except for #1 which we use for DMA'ing to IOCA-like things, so the */
  29. /* control registers to set that up are determined by what we've */
  30. /* empirically discovered work there. */
  31. .globl ext_bus_cntlr_init
  32. ext_bus_cntlr_init:
  33. mflr r4 /* save link register */
  34. bl ..getAddr
  35. ..getAddr:
  36. mflr r3 /* get address of ..getAddr */
  37. mtlr r4 /* restore link register */
  38. addi r4,0,14 /* set ctr to 10; used to prefetch */
  39. mtctr r4 /* 10 cache lines to fit this function */
  40. /* in cache (gives us 8x10=80 instrctns) */
  41. ..ebcloop:
  42. icbt r0,r3 /* prefetch cache line for addr in r3 */
  43. addi r3,r3,32 /* move to next cache line */
  44. bdnz ..ebcloop /* continue for 10 cache lines */
  45. /*------------------------------------------------------------------- */
  46. /* Delay to ensure all accesses to ROM are complete before changing */
  47. /* bank 0 timings. 200usec should be enough. */
  48. /* 200,000,000 (cycles/sec) X .000200 (sec) = 0x9C40 cycles */
  49. /*------------------------------------------------------------------- */
  50. addis r3,0,0x0
  51. ori r3,r3,0xA000 /* ensure 200usec have passed since reset */
  52. mtctr r3
  53. ..spinlp:
  54. bdnz ..spinlp /* spin loop */
  55. /*---------------------------------------------------------------------- */
  56. /* Peripheral Bank 0 (Flash) initialization */
  57. /*---------------------------------------------------------------------- */
  58. /* 0x7F8FFE80 slowest boot */
  59. addi r4,0,PB1AP
  60. mtdcr EBC0_CFGADDR,r4
  61. addis r4,0,0x9B01
  62. ori r4,r4,0x5480
  63. mtdcr EBC0_CFGDATA,r4
  64. addi r4,0,PB0CR
  65. mtdcr EBC0_CFGADDR,r4
  66. addis r4,0,0xFFC5 /* BAS=0xFFC,BS=0x4(4MB),BU=0x3(R/W), */
  67. ori r4,r4,0x8000 /* BW=0x0( 8 bits) */
  68. mtdcr EBC0_CFGDATA,r4
  69. blr
  70. /*---------------------------------------------------------------------- */
  71. /* Peripheral Bank 1 (NVRAM/RTC) initialization */
  72. /* CRAY:the L1 has NOT this bank, it is tied to SV2/IOCA/etc/ instead */
  73. /* and we do DMA on it. The ConfigurationRegister part is threfore */
  74. /* almost arbitrary, except that our linux driver needs to know the */
  75. /* address, but it can query, it.. */
  76. /* */
  77. /* The AccessParameter is CRITICAL, */
  78. /* thouch, since it needs to agree with the electrical timings on the */
  79. /* IOCA parallel interface. That value is: 0x0185,4380 */
  80. /* BurstModeEnable BME=0 */
  81. /* TransferWait TWT=3 */
  82. /* ChipSelectOnTiming CSN=1 */
  83. /* OutputEnableOnTimimg OEN=1 */
  84. /* WriteByteEnableOnTiming WBN=1 */
  85. /* WriteByteEnableOffTiming WBF=0 */
  86. /* TransferHold TH=1 */
  87. /* ReadyEnable RE=1 */
  88. /* SampleOnReady SOR=1 */
  89. /* ByteEnableMode BEM=0 */
  90. /* ParityEnable PEN=0 */
  91. /* all reserved bits=0 */
  92. /*---------------------------------------------------------------------- */
  93. /*---------------------------------------------------------------------- */
  94. addi r4,0,PB1AP
  95. mtdcr EBC0_CFGADDR,r4
  96. addis r4,0,0x0185 /* hiword */
  97. ori r4,r4,0x4380 /* loword */
  98. mtdcr EBC0_CFGDATA,r4
  99. addi r4,0,PB1CR
  100. mtdcr EBC0_CFGADDR,r4
  101. addis r4,0,0xF001 /* BAS=0xF00,BS=0x0(1MB),BU=0x3(R/W), */
  102. ori r4,r4,0x8000 /* BW=0x0( 8 bits) */
  103. mtdcr EBC0_CFGDATA,r4
  104. blr