init.S 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*------------------------------------------------------------------------------+
  2. * This source code is dual-licensed. You may use it under the terms of
  3. * the GNU General Public License version 2, or under the license below.
  4. *
  5. * This source code has been made available to you by IBM on an AS-IS
  6. * basis. Anyone receiving this source is licensed under IBM
  7. * copyrights to use it in any way he or she deems fit, including
  8. * copying it, modifying it, compiling it, and redistributing it either
  9. * with or without modifications. No license under IBM patents or
  10. * patent applications is to be implied by the copyright license.
  11. *
  12. * Any user of this software should understand that IBM cannot provide
  13. * technical support for this software and will not be responsible for
  14. * any consequences resulting from the use of this software.
  15. *
  16. * Any person who transfers this source code or any derivative work
  17. * must include the IBM copyright notice, this paragraph, and the
  18. * preceding two paragraphs in the transferred software.
  19. *
  20. * COPYRIGHT I B M CORPORATION 1995
  21. * LICENSED MATERIAL - PROGRAM PROPERTY OF I B M
  22. *-------------------------------------------------------------------------------*/
  23. /*-----------------------------------------------------------------------------
  24. * Function: ext_bus_cntlr_init
  25. * Description: Initializes the External Bus Controller for the external
  26. * peripherals. IMPORTANT: For pass1 this code must run from
  27. * cache since you can not reliably change a peripheral banks
  28. * timing register (pbxap) while running code from that bank.
  29. * For ex., since we are running from ROM on bank 0, we can NOT
  30. * execute the code that modifies bank 0 timings from ROM, so
  31. * we run it from cache.
  32. * Bank 0 - Flash or Multi Purpose Socket
  33. * Bank 1 - Multi Purpose Socket or Flash
  34. * Bank 2 - not used
  35. * Bank 3 - not used
  36. * Bank 4 - not used
  37. * Bank 5 - not used
  38. * Bank 6 - used to switch on the 12V for the Multipurpose socket
  39. * Bank 7 - Config Register
  40. *-----------------------------------------------------------------------------*/
  41. #define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
  42. #include <configs/PIP405.h>
  43. #include <ppc_asm.tmpl>
  44. #include <ppc_defs.h>
  45. #include <asm/cache.h>
  46. #include <asm/mmu.h>
  47. #include <asm/ppc4xx.h>
  48. #include "pip405.h"
  49. .globl ext_bus_cntlr_init
  50. ext_bus_cntlr_init:
  51. mflr r4 /* save link register */
  52. mfdcr r3,CPC0_PSR /* get strapping reg */
  53. andi. r0, r3, PSR_ROM_LOC /* mask out irrelevant bits */
  54. bnelr /* jump back if PCI boot */
  55. bl ..getAddr
  56. ..getAddr:
  57. mflr r3 /* get address of ..getAddr */
  58. mtlr r4 /* restore link register */
  59. addi r4,0,14 /* set ctr to 14; used to prefetch */
  60. mtctr r4 /* 14 cache lines to fit this function */
  61. /* in cache (gives us 8x14=112 instrctns) */
  62. ..ebcloop:
  63. icbt r0,r3 /* prefetch cache line for addr in r3 */
  64. addi r3,r3,32 /* move to next cache line */
  65. bdnz ..ebcloop /* continue for 14 cache lines */
  66. /*-------------------------------------------------------------------
  67. * Delay to ensure all accesses to ROM are complete before changing
  68. * bank 0 timings.
  69. *------------------------------------------------------------------- */
  70. addis r3,0,0x0
  71. ori r3,r3,0xA000
  72. mtctr r3
  73. ..spinlp:
  74. bdnz ..spinlp /* spin loop */
  75. /*-----------------------------------------------------------------------
  76. * decide boot up mode
  77. *----------------------------------------------------------------------- */
  78. addi r4,0,PB0CR
  79. mtdcr EBC0_CFGADDR,r4
  80. mfdcr r4,EBC0_CFGDATA
  81. andi. r0, r4, 0x2000 /* mask out irrelevant bits */
  82. beq 0f /* jump if 8 bit bus width */
  83. /* setup 16 bit things
  84. *-----------------------------------------------------------------------
  85. * Memory Bank 0 (16 Bit Flash) initialization
  86. *---------------------------------------------------------------------- */
  87. addi r4,0,PB1AP
  88. mtdcr EBC0_CFGADDR,r4
  89. addis r4,0,(FLASH_AP_B)@h
  90. ori r4,r4,(FLASH_AP_B)@l
  91. mtdcr EBC0_CFGDATA,r4
  92. addi r4,0,PB0CR
  93. mtdcr EBC0_CFGADDR,r4
  94. /* BS=0x010(4MB),BU=0x3(R/W), */
  95. addis r4,0,(FLASH_CR_B)@h
  96. ori r4,r4,(FLASH_CR_B)@l
  97. mtdcr EBC0_CFGDATA,r4
  98. b 1f
  99. 0:
  100. /* 8Bit boot mode: */
  101. /*-----------------------------------------------------------------------
  102. * Memory Bank 0 Multi Purpose Socket initialization
  103. *----------------------------------------------------------------------- */
  104. /* 0x7F8FFE80 slowest boot */
  105. addi r4,0,PB1AP
  106. mtdcr EBC0_CFGADDR,r4
  107. addis r4,0,(MPS_AP_B)@h
  108. ori r4,r4,(MPS_AP_B)@l
  109. mtdcr EBC0_CFGDATA,r4
  110. addi r4,0,PB0CR
  111. mtdcr EBC0_CFGADDR,r4
  112. /* BS=0x010(4MB),BU=0x3(R/W), */
  113. addis r4,0,(MPS_CR_B)@h
  114. ori r4,r4,(MPS_CR_B)@l
  115. mtdcr EBC0_CFGDATA,r4
  116. 1:
  117. /*-----------------------------------------------------------------------
  118. * Memory Bank 2-3-4-5-6 (not used) initialization
  119. *-----------------------------------------------------------------------*/
  120. addi r4,0,PB1CR
  121. mtdcr EBC0_CFGADDR,r4
  122. addis r4,0,0x0000
  123. ori r4,r4,0x0000
  124. mtdcr EBC0_CFGDATA,r4
  125. addi r4,0,PB2CR
  126. mtdcr EBC0_CFGADDR,r4
  127. addis r4,0,0x0000
  128. ori r4,r4,0x0000
  129. mtdcr EBC0_CFGDATA,r4
  130. addi r4,0,PB3CR
  131. mtdcr EBC0_CFGADDR,r4
  132. addis r4,0,0x0000
  133. ori r4,r4,0x0000
  134. mtdcr EBC0_CFGDATA,r4
  135. addi r4,0,PB4CR
  136. mtdcr EBC0_CFGADDR,r4
  137. addis r4,0,0x0000
  138. ori r4,r4,0x0000
  139. mtdcr EBC0_CFGDATA,r4
  140. addi r4,0,PB5CR
  141. mtdcr EBC0_CFGADDR,r4
  142. addis r4,0,0x0000
  143. ori r4,r4,0x0000
  144. mtdcr EBC0_CFGDATA,r4
  145. addi r4,0,PB6CR
  146. mtdcr EBC0_CFGADDR,r4
  147. addis r4,0,0x0000
  148. ori r4,r4,0x0000
  149. mtdcr EBC0_CFGDATA,r4
  150. addi r4,0,PB7CR
  151. mtdcr EBC0_CFGADDR,r4
  152. addis r4,0,0x0000
  153. ori r4,r4,0x0000
  154. mtdcr EBC0_CFGDATA,r4
  155. nop /* pass2 DCR errata #8 */
  156. blr
  157. #if defined(CONFIG_BOOT_PCI)
  158. .section .bootpg,"ax"
  159. .globl _start_pci
  160. /*******************************************
  161. */
  162. _start_pci:
  163. /* first handle errata #68 / PCI_18 */
  164. iccci r0, r0 /* invalidate I-cache */
  165. lis r31, 0
  166. mticcr r31 /* ICCR = 0 (all uncachable) */
  167. isync
  168. mfccr0 r28 /* set CCR0[24] = 1 */
  169. ori r28, r28, 0x0080
  170. mtccr0 r28
  171. /* setup PMM0MA (0xEF400004) and PMM0PCIHA (0xEF40000C) */
  172. lis r28, 0xEF40
  173. addi r28, r28, 0x0004
  174. stw r31, 0x0C(r28) /* clear PMM0PCIHA */
  175. lis r29, 0xFFF8 /* open 512 kByte */
  176. addi r29, r29, 0x0001/* and enable this region */
  177. stwbrx r29, r0, r28 /* write PMM0MA */
  178. lis r28, 0xEEC0 /* address of PCIC0_CFGADDR */
  179. addi r29, r28, 4 /* add 4 to r29 -> PCIC0_CFGDATA */
  180. lis r31, 0x8000 /* set en bit bus 0 */
  181. ori r31, r31, 0x304C/* device 6 func 0 reg 4C (XBCS register) */
  182. stwbrx r31, r0, r28 /* write it */
  183. lwbrx r31, r0, r29 /* load XBCS register */
  184. oris r31, r31, 0x02C4/* clear BIOSCS WPE, set lower, extended and 1M extended BIOS enable */
  185. stwbrx r31, r0, r29 /* write back XBCS register */
  186. nop
  187. nop
  188. b _start /* normal start */
  189. #endif