init.S 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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 or Multi Purpose Socket
  14. * Bank 1 - Multi Purpose Socket or Flash
  15. * Bank 2 - not used
  16. * Bank 3 - not used
  17. * Bank 4 - not used
  18. * Bank 5 - not used
  19. * Bank 6 - used to switch on the 12V for the Multipurpose socket
  20. * Bank 7 - Config Register
  21. *-----------------------------------------------------------------------------*/
  22. #include <configs/PIP405.h>
  23. #include <ppc_asm.tmpl>
  24. #include <ppc_defs.h>
  25. #include <asm/cache.h>
  26. #include <asm/mmu.h>
  27. #include <asm/ppc4xx.h>
  28. #include "pip405.h"
  29. .globl ext_bus_cntlr_init
  30. ext_bus_cntlr_init:
  31. mflr r4 /* save link register */
  32. mfdcr r3,CPC0_PSR /* get strapping reg */
  33. andi. r0, r3, PSR_ROM_LOC /* mask out irrelevant bits */
  34. bnelr /* jump back if PCI boot */
  35. bl ..getAddr
  36. ..getAddr:
  37. mflr r3 /* get address of ..getAddr */
  38. mtlr r4 /* restore link register */
  39. addi r4,0,14 /* set ctr to 14; used to prefetch */
  40. mtctr r4 /* 14 cache lines to fit this function */
  41. /* in cache (gives us 8x14=112 instrctns) */
  42. ..ebcloop:
  43. icbt r0,r3 /* prefetch cache line for addr in r3 */
  44. addi r3,r3,32 /* move to next cache line */
  45. bdnz ..ebcloop /* continue for 14 cache lines */
  46. /*-------------------------------------------------------------------
  47. * Delay to ensure all accesses to ROM are complete before changing
  48. * bank 0 timings.
  49. *------------------------------------------------------------------- */
  50. addis r3,0,0x0
  51. ori r3,r3,0xA000
  52. mtctr r3
  53. ..spinlp:
  54. bdnz ..spinlp /* spin loop */
  55. /*-----------------------------------------------------------------------
  56. * decide boot up mode
  57. *----------------------------------------------------------------------- */
  58. addi r4,0,PB0CR
  59. mtdcr EBC0_CFGADDR,r4
  60. mfdcr r4,EBC0_CFGDATA
  61. andi. r0, r4, 0x2000 /* mask out irrelevant bits */
  62. beq 0f /* jump if 8 bit bus width */
  63. /* setup 16 bit things
  64. *-----------------------------------------------------------------------
  65. * Memory Bank 0 (16 Bit Flash) initialization
  66. *---------------------------------------------------------------------- */
  67. addi r4,0,PB1AP
  68. mtdcr EBC0_CFGADDR,r4
  69. addis r4,0,(FLASH_AP_B)@h
  70. ori r4,r4,(FLASH_AP_B)@l
  71. mtdcr EBC0_CFGDATA,r4
  72. addi r4,0,PB0CR
  73. mtdcr EBC0_CFGADDR,r4
  74. /* BS=0x010(4MB),BU=0x3(R/W), */
  75. addis r4,0,(FLASH_CR_B)@h
  76. ori r4,r4,(FLASH_CR_B)@l
  77. mtdcr EBC0_CFGDATA,r4
  78. b 1f
  79. 0:
  80. /* 8Bit boot mode: */
  81. /*-----------------------------------------------------------------------
  82. * Memory Bank 0 Multi Purpose Socket initialization
  83. *----------------------------------------------------------------------- */
  84. /* 0x7F8FFE80 slowest boot */
  85. addi r4,0,PB1AP
  86. mtdcr EBC0_CFGADDR,r4
  87. addis r4,0,(MPS_AP_B)@h
  88. ori r4,r4,(MPS_AP_B)@l
  89. mtdcr EBC0_CFGDATA,r4
  90. addi r4,0,PB0CR
  91. mtdcr EBC0_CFGADDR,r4
  92. /* BS=0x010(4MB),BU=0x3(R/W), */
  93. addis r4,0,(MPS_CR_B)@h
  94. ori r4,r4,(MPS_CR_B)@l
  95. mtdcr EBC0_CFGDATA,r4
  96. 1:
  97. /*-----------------------------------------------------------------------
  98. * Memory Bank 2-3-4-5-6 (not used) initialization
  99. *-----------------------------------------------------------------------*/
  100. addi r4,0,PB1CR
  101. mtdcr EBC0_CFGADDR,r4
  102. addis r4,0,0x0000
  103. ori r4,r4,0x0000
  104. mtdcr EBC0_CFGDATA,r4
  105. addi r4,0,PB2CR
  106. mtdcr EBC0_CFGADDR,r4
  107. addis r4,0,0x0000
  108. ori r4,r4,0x0000
  109. mtdcr EBC0_CFGDATA,r4
  110. addi r4,0,PB3CR
  111. mtdcr EBC0_CFGADDR,r4
  112. addis r4,0,0x0000
  113. ori r4,r4,0x0000
  114. mtdcr EBC0_CFGDATA,r4
  115. addi r4,0,PB4CR
  116. mtdcr EBC0_CFGADDR,r4
  117. addis r4,0,0x0000
  118. ori r4,r4,0x0000
  119. mtdcr EBC0_CFGDATA,r4
  120. addi r4,0,PB5CR
  121. mtdcr EBC0_CFGADDR,r4
  122. addis r4,0,0x0000
  123. ori r4,r4,0x0000
  124. mtdcr EBC0_CFGDATA,r4
  125. addi r4,0,PB6CR
  126. mtdcr EBC0_CFGADDR,r4
  127. addis r4,0,0x0000
  128. ori r4,r4,0x0000
  129. mtdcr EBC0_CFGDATA,r4
  130. addi r4,0,PB7CR
  131. mtdcr EBC0_CFGADDR,r4
  132. addis r4,0,0x0000
  133. ori r4,r4,0x0000
  134. mtdcr EBC0_CFGDATA,r4
  135. nop /* pass2 DCR errata #8 */
  136. blr
  137. #if defined(CONFIG_BOOT_PCI)
  138. .section .bootpg,"ax"
  139. .globl _start_pci
  140. /*******************************************
  141. */
  142. _start_pci:
  143. /* first handle errata #68 / PCI_18 */
  144. iccci r0, r0 /* invalidate I-cache */
  145. lis r31, 0
  146. mticcr r31 /* ICCR = 0 (all uncachable) */
  147. isync
  148. mfccr0 r28 /* set CCR0[24] = 1 */
  149. ori r28, r28, 0x0080
  150. mtccr0 r28
  151. /* setup PMM0MA (0xEF400004) and PMM0PCIHA (0xEF40000C) */
  152. lis r28, 0xEF40
  153. addi r28, r28, 0x0004
  154. stw r31, 0x0C(r28) /* clear PMM0PCIHA */
  155. lis r29, 0xFFF8 /* open 512 kByte */
  156. addi r29, r29, 0x0001/* and enable this region */
  157. stwbrx r29, r0, r28 /* write PMM0MA */
  158. lis r28, 0xEEC0 /* address of PCIC0_CFGADDR */
  159. addi r29, r28, 4 /* add 4 to r29 -> PCIC0_CFGDATA */
  160. lis r31, 0x8000 /* set en bit bus 0 */
  161. ori r31, r31, 0x304C/* device 6 func 0 reg 4C (XBCS register) */
  162. stwbrx r31, r0, r28 /* write it */
  163. lwbrx r31, r0, r29 /* load XBCS register */
  164. oris r31, r31, 0x02C4/* clear BIOSCS WPE, set lower, extended and 1M extended BIOS enable */
  165. stwbrx r31, r0, r29 /* write back XBCS register */
  166. nop
  167. nop
  168. b _start /* normal start */
  169. #endif