bamboo.c 68 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009
  1. /*
  2. * (C) Copyright 2005
  3. * Stefan Roese, DENX Software Engineering, sr@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 <asm/processor.h>
  25. #include <asm/gpio.h>
  26. #include <spd_sdram.h>
  27. #include <ppc440.h>
  28. #include "bamboo.h"
  29. void ext_bus_cntlr_init(void);
  30. void configure_ppc440ep_pins(void);
  31. int is_nand_selected(void);
  32. unsigned char cfg_simulate_spd_eeprom[128];
  33. gpio_param_s gpio_tab[GPIO_GROUP_MAX][GPIO_MAX];
  34. #if 0
  35. { /* GPIO Alternate1 Alternate2 Alternate3 */
  36. {
  37. /* GPIO Core 0 */
  38. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_0 -> EBC_ADDR(7) DMA_REQ(2) */
  39. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_1 -> EBC_ADDR(6) DMA_ACK(2) */
  40. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_2 -> EBC_ADDR(5) DMA_EOT/TC(2) */
  41. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_3 -> EBC_ADDR(4) DMA_REQ(3) */
  42. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_4 -> EBC_ADDR(3) DMA_ACK(3) */
  43. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_5 ................. */
  44. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_6 -> EBC_CS_N(1) */
  45. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_7 -> EBC_CS_N(2) */
  46. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_8 -> EBC_CS_N(3) */
  47. { GPIO0_BASE, GPIO_DIS, GPIO_ALT1 }, /* GPIO0_9 -> EBC_CS_N(4) */
  48. { GPIO0_BASE, GPIO_OUT, GPIO_ALT1 }, /* GPIO0_10 -> EBC_CS_N(5) */
  49. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_11 -> EBC_BUS_ERR */
  50. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_12 -> ZII_p0Rxd(0) */
  51. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_13 -> ZII_p0Rxd(1) */
  52. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_14 -> ZII_p0Rxd(2) */
  53. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_15 -> ZII_p0Rxd(3) */
  54. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_16 -> ZII_p0Txd(0) */
  55. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_17 -> ZII_p0Txd(1) */
  56. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_18 -> ZII_p0Txd(2) */
  57. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_19 -> ZII_p0Txd(3) */
  58. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_20 -> ZII_p0Rx_er */
  59. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_21 -> ZII_p0Rx_dv */
  60. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_22 -> ZII_p0RxCrs */
  61. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_23 -> ZII_p0Tx_er */
  62. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_24 -> ZII_p0Tx_en */
  63. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_25 -> ZII_p0Col */
  64. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_26 -> USB2D_RXVALID */
  65. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_27 -> EXT_EBC_REQ USB2D_RXERROR */
  66. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_28 -> USB2D_TXVALID */
  67. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_29 -> EBC_EXT_HDLA USB2D_PAD_SUSPNDM */
  68. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_30 -> EBC_EXT_ACK USB2D_XCVRSELECT */
  69. { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_31 -> EBC_EXR_BUSREQ USB2D_TERMSELECT */
  70. },
  71. {
  72. /* GPIO Core 1 */
  73. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_0 -> USB2D_OPMODE0 */
  74. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_1 -> USB2D_OPMODE1 */
  75. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_2 -> UART0_DCD_N UART1_DSR_CTS_N UART2_SOUT */
  76. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_3 -> UART0_8PIN_DSR_N UART1_RTS_DTR_N UART2_SIN */
  77. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_4 -> UART0_8PIN_CTS_N UART3_SIN */
  78. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_5 -> UART0_RTS_N */
  79. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_6 -> UART0_DTR_N UART1_SOUT */
  80. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_7 -> UART0_RI_N UART1_SIN */
  81. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_8 -> UIC_IRQ(0) */
  82. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_9 -> UIC_IRQ(1) */
  83. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_10 -> UIC_IRQ(2) */
  84. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_11 -> UIC_IRQ(3) */
  85. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_12 -> UIC_IRQ(4) DMA_ACK(1) */
  86. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_13 -> UIC_IRQ(6) DMA_EOT/TC(1) */
  87. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_14 -> UIC_IRQ(7) DMA_REQ(0) */
  88. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_15 -> UIC_IRQ(8) DMA_ACK(0) */
  89. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_16 -> UIC_IRQ(9) DMA_EOT/TC(0) */
  90. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_17 -> - */
  91. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_18 -> | */
  92. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_19 -> | */
  93. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_20 -> | */
  94. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_21 -> | */
  95. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_22 -> | */
  96. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_23 -> \ Can be unselected thru TraceSelect Bit */
  97. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_24 -> / in PowerPC440EP Chip */
  98. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_25 -> | */
  99. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_26 -> | */
  100. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_27 -> | */
  101. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_28 -> | */
  102. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_29 -> | */
  103. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_30 -> | */
  104. { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_31 -> - */
  105. }
  106. };
  107. #endif
  108. /*----------------------------------------------------------------------------+
  109. | EBC Devices Characteristics
  110. | Peripheral Bank Access Parameters - EBC0_BnAP
  111. | Peripheral Bank Configuration Register - EBC0_BnCR
  112. +----------------------------------------------------------------------------*/
  113. /* Small Flash */
  114. #define EBC0_BNAP_SMALL_FLASH \
  115. EBC0_BNAP_BME_DISABLED | \
  116. EBC0_BNAP_TWT_ENCODE(6) | \
  117. EBC0_BNAP_CSN_ENCODE(0) | \
  118. EBC0_BNAP_OEN_ENCODE(1) | \
  119. EBC0_BNAP_WBN_ENCODE(1) | \
  120. EBC0_BNAP_WBF_ENCODE(3) | \
  121. EBC0_BNAP_TH_ENCODE(1) | \
  122. EBC0_BNAP_RE_ENABLED | \
  123. EBC0_BNAP_SOR_DELAYED | \
  124. EBC0_BNAP_BEM_WRITEONLY | \
  125. EBC0_BNAP_PEN_DISABLED
  126. #define EBC0_BNCR_SMALL_FLASH_CS0 \
  127. EBC0_BNCR_BAS_ENCODE(0xFFF00000) | \
  128. EBC0_BNCR_BS_1MB | \
  129. EBC0_BNCR_BU_RW | \
  130. EBC0_BNCR_BW_8BIT
  131. #define EBC0_BNCR_SMALL_FLASH_CS4 \
  132. EBC0_BNCR_BAS_ENCODE(0x87F00000) | \
  133. EBC0_BNCR_BS_1MB | \
  134. EBC0_BNCR_BU_RW | \
  135. EBC0_BNCR_BW_8BIT
  136. /* Large Flash or SRAM */
  137. #define EBC0_BNAP_LARGE_FLASH_OR_SRAM \
  138. EBC0_BNAP_BME_DISABLED | \
  139. EBC0_BNAP_TWT_ENCODE(8) | \
  140. EBC0_BNAP_CSN_ENCODE(0) | \
  141. EBC0_BNAP_OEN_ENCODE(1) | \
  142. EBC0_BNAP_WBN_ENCODE(1) | \
  143. EBC0_BNAP_WBF_ENCODE(1) | \
  144. EBC0_BNAP_TH_ENCODE(2) | \
  145. EBC0_BNAP_SOR_DELAYED | \
  146. EBC0_BNAP_BEM_RW | \
  147. EBC0_BNAP_PEN_DISABLED
  148. #define EBC0_BNCR_LARGE_FLASH_OR_SRAM_CS0 \
  149. EBC0_BNCR_BAS_ENCODE(0xFF800000) | \
  150. EBC0_BNCR_BS_8MB | \
  151. EBC0_BNCR_BU_RW | \
  152. EBC0_BNCR_BW_16BIT
  153. #define EBC0_BNCR_LARGE_FLASH_OR_SRAM_CS4 \
  154. EBC0_BNCR_BAS_ENCODE(0x87800000) | \
  155. EBC0_BNCR_BS_8MB | \
  156. EBC0_BNCR_BU_RW | \
  157. EBC0_BNCR_BW_16BIT
  158. /* NVRAM - FPGA */
  159. #define EBC0_BNAP_NVRAM_FPGA \
  160. EBC0_BNAP_BME_DISABLED | \
  161. EBC0_BNAP_TWT_ENCODE(9) | \
  162. EBC0_BNAP_CSN_ENCODE(0) | \
  163. EBC0_BNAP_OEN_ENCODE(1) | \
  164. EBC0_BNAP_WBN_ENCODE(1) | \
  165. EBC0_BNAP_WBF_ENCODE(0) | \
  166. EBC0_BNAP_TH_ENCODE(2) | \
  167. EBC0_BNAP_RE_ENABLED | \
  168. EBC0_BNAP_SOR_DELAYED | \
  169. EBC0_BNAP_BEM_WRITEONLY | \
  170. EBC0_BNAP_PEN_DISABLED
  171. #define EBC0_BNCR_NVRAM_FPGA_CS5 \
  172. EBC0_BNCR_BAS_ENCODE(0x80000000) | \
  173. EBC0_BNCR_BS_1MB | \
  174. EBC0_BNCR_BU_RW | \
  175. EBC0_BNCR_BW_8BIT
  176. /* Nand Flash */
  177. #define EBC0_BNAP_NAND_FLASH \
  178. EBC0_BNAP_BME_DISABLED | \
  179. EBC0_BNAP_TWT_ENCODE(3) | \
  180. EBC0_BNAP_CSN_ENCODE(0) | \
  181. EBC0_BNAP_OEN_ENCODE(0) | \
  182. EBC0_BNAP_WBN_ENCODE(0) | \
  183. EBC0_BNAP_WBF_ENCODE(0) | \
  184. EBC0_BNAP_TH_ENCODE(1) | \
  185. EBC0_BNAP_RE_ENABLED | \
  186. EBC0_BNAP_SOR_NOT_DELAYED | \
  187. EBC0_BNAP_BEM_RW | \
  188. EBC0_BNAP_PEN_DISABLED
  189. #define EBC0_BNCR_NAND_FLASH_CS0 0xB8400000
  190. /* NAND0 */
  191. #define EBC0_BNCR_NAND_FLASH_CS1 \
  192. EBC0_BNCR_BAS_ENCODE(0x90000000) | \
  193. EBC0_BNCR_BS_1MB | \
  194. EBC0_BNCR_BU_RW | \
  195. EBC0_BNCR_BW_32BIT
  196. /* NAND1 - Bank2 */
  197. #define EBC0_BNCR_NAND_FLASH_CS2 \
  198. EBC0_BNCR_BAS_ENCODE(0x94000000) | \
  199. EBC0_BNCR_BS_1MB | \
  200. EBC0_BNCR_BU_RW | \
  201. EBC0_BNCR_BW_32BIT
  202. /* NAND1 - Bank3 */
  203. #define EBC0_BNCR_NAND_FLASH_CS3 \
  204. EBC0_BNCR_BAS_ENCODE(0x94000000) | \
  205. EBC0_BNCR_BS_1MB | \
  206. EBC0_BNCR_BU_RW | \
  207. EBC0_BNCR_BW_32BIT
  208. int board_early_init_f(void)
  209. {
  210. ext_bus_cntlr_init();
  211. /*--------------------------------------------------------------------
  212. * Setup the interrupt controller polarities, triggers, etc.
  213. *-------------------------------------------------------------------*/
  214. mtdcr(uic0sr, 0xffffffff); /* clear all */
  215. mtdcr(uic0er, 0x00000000); /* disable all */
  216. mtdcr(uic0cr, 0x00000009); /* ATI & UIC1 crit are critical */
  217. mtdcr(uic0pr, 0xfffffe13); /* per ref-board manual */
  218. mtdcr(uic0tr, 0x01c00008); /* per ref-board manual */
  219. mtdcr(uic0vr, 0x00000001); /* int31 highest, base=0x000 */
  220. mtdcr(uic0sr, 0xffffffff); /* clear all */
  221. mtdcr(uic1sr, 0xffffffff); /* clear all */
  222. mtdcr(uic1er, 0x00000000); /* disable all */
  223. mtdcr(uic1cr, 0x00000000); /* all non-critical */
  224. mtdcr(uic1pr, 0xffffe0ff); /* per ref-board manual */
  225. mtdcr(uic1tr, 0x00ffc000); /* per ref-board manual */
  226. mtdcr(uic1vr, 0x00000001); /* int31 highest, base=0x000 */
  227. mtdcr(uic1sr, 0xffffffff); /* clear all */
  228. /*--------------------------------------------------------------------
  229. * Setup the GPIO pins
  230. *-------------------------------------------------------------------*/
  231. out32(GPIO0_OSRL, 0x00000400);
  232. out32(GPIO0_OSRH, 0x00000000);
  233. out32(GPIO0_TSRL, 0x00000400);
  234. out32(GPIO0_TSRH, 0x00000000);
  235. out32(GPIO0_ISR1L, 0x00000000);
  236. out32(GPIO0_ISR1H, 0x00000000);
  237. out32(GPIO0_ISR2L, 0x00000000);
  238. out32(GPIO0_ISR2H, 0x00000000);
  239. out32(GPIO0_ISR3L, 0x00000000);
  240. out32(GPIO0_ISR3H, 0x00000000);
  241. out32(GPIO1_OSRL, 0x0C380000);
  242. out32(GPIO1_OSRH, 0x00000000);
  243. out32(GPIO1_TSRL, 0x0C380000);
  244. out32(GPIO1_TSRH, 0x00000000);
  245. out32(GPIO1_ISR1L, 0x0FC30000);
  246. out32(GPIO1_ISR1H, 0x00000000);
  247. out32(GPIO1_ISR2L, 0x0C010000);
  248. out32(GPIO1_ISR2H, 0x00000000);
  249. out32(GPIO1_ISR3L, 0x01400000);
  250. out32(GPIO1_ISR3H, 0x00000000);
  251. configure_ppc440ep_pins();
  252. return 0;
  253. }
  254. int checkboard(void)
  255. {
  256. char *s = getenv("serial#");
  257. printf("Board: Bamboo - AMCC PPC440EP Evaluation Board");
  258. if (s != NULL) {
  259. puts(", serial# ");
  260. puts(s);
  261. }
  262. putc('\n');
  263. return (0);
  264. }
  265. /*************************************************************************
  266. *
  267. * init_spd_array -- Bamboo has one bank onboard sdram (plus DIMM)
  268. *
  269. * Fixed memory is composed of :
  270. * MT46V16M16TG-75 from Micron (x 2), 256Mb, 16 M x16, DDR266,
  271. * 13 row add bits, 10 column add bits (but 12 row used only).
  272. * ECC device: MT46V16M8TG-75 from Micron (x 1), 128Mb, x8, DDR266,
  273. * 12 row add bits, 10 column add bits.
  274. * Prepare a subset (only the used ones) of SPD data
  275. *
  276. * Note : if the ECC is enabled (SDRAM_ECC_ENABLE) the size of
  277. * the corresponding bank is divided by 2 due to number of Row addresses
  278. * 12 in the ECC module
  279. *
  280. * Assumes: 64 MB, ECC, non-registered
  281. * PLB @ 133 MHz
  282. *
  283. ************************************************************************/
  284. static void init_spd_array(void)
  285. {
  286. cfg_simulate_spd_eeprom[8] = 0x04; /* 2.5 Volt */
  287. cfg_simulate_spd_eeprom[2] = 0x07; /* DDR ram */
  288. #ifdef CONFIG_DDR_ECC
  289. cfg_simulate_spd_eeprom[11] = 0x02; /* ECC ON : 02 OFF : 00 */
  290. cfg_simulate_spd_eeprom[31] = 0x08; /* bankSizeID: 32MB */
  291. cfg_simulate_spd_eeprom[3] = 0x0C; /* num Row Addr: 12 */
  292. #else
  293. cfg_simulate_spd_eeprom[11] = 0x00; /* ECC ON : 02 OFF : 00 */
  294. cfg_simulate_spd_eeprom[31] = 0x10; /* bankSizeID: 64MB */
  295. cfg_simulate_spd_eeprom[3] = 0x0D; /* num Row Addr: 13 */
  296. #endif
  297. cfg_simulate_spd_eeprom[4] = 0x09; /* numColAddr: 9 */
  298. cfg_simulate_spd_eeprom[5] = 0x01; /* numBanks: 1 */
  299. cfg_simulate_spd_eeprom[0] = 0x80; /* number of SPD bytes used: 128 */
  300. cfg_simulate_spd_eeprom[1] = 0x08; /* total number bytes in SPD device = 256 */
  301. cfg_simulate_spd_eeprom[21] = 0x00; /* not registered: 0 registered : 0x02*/
  302. cfg_simulate_spd_eeprom[6] = 0x20; /* Module data width: 32 bits */
  303. cfg_simulate_spd_eeprom[7] = 0x00; /* Module data width continued: +0 */
  304. cfg_simulate_spd_eeprom[15] = 0x01; /* wcsbc = 1 */
  305. cfg_simulate_spd_eeprom[27] = 0x50; /* tRpNs = 20 ns */
  306. cfg_simulate_spd_eeprom[29] = 0x50; /* tRcdNs = 20 ns */
  307. cfg_simulate_spd_eeprom[30] = 45; /* tRasNs */
  308. cfg_simulate_spd_eeprom[18] = 0x0C; /* casBit (2,2.5) */
  309. cfg_simulate_spd_eeprom[9] = 0x75; /* SDRAM Cycle Time (cas latency 2.5) = 7.5 ns */
  310. cfg_simulate_spd_eeprom[23] = 0xA0; /* SDRAM Cycle Time (cas latency 2) = 10 ns */
  311. cfg_simulate_spd_eeprom[25] = 0x00; /* SDRAM Cycle Time (cas latency 1.5) = N.A */
  312. cfg_simulate_spd_eeprom[12] = 0x82; /* refresh Rate Type: Normal (15.625us) + Self refresh */
  313. }
  314. long int initdram (int board_type)
  315. {
  316. long dram_size = 0;
  317. /*
  318. * First write simulated values in eeprom array for onboard bank 0
  319. */
  320. init_spd_array();
  321. dram_size = spd_sdram();
  322. return dram_size;
  323. }
  324. #if defined(CFG_DRAM_TEST)
  325. int testdram(void)
  326. {
  327. unsigned long *mem = (unsigned long *)0;
  328. const unsigned long kend = (1024 / sizeof(unsigned long));
  329. unsigned long k, n;
  330. mtmsr(0);
  331. for (k = 0; k < CFG_KBYTES_SDRAM;
  332. ++k, mem += (1024 / sizeof(unsigned long))) {
  333. if ((k & 1023) == 0) {
  334. printf("%3d MB\r", k / 1024);
  335. }
  336. memset(mem, 0xaaaaaaaa, 1024);
  337. for (n = 0; n < kend; ++n) {
  338. if (mem[n] != 0xaaaaaaaa) {
  339. printf("SDRAM test fails at: %08x\n",
  340. (uint) & mem[n]);
  341. return 1;
  342. }
  343. }
  344. memset(mem, 0x55555555, 1024);
  345. for (n = 0; n < kend; ++n) {
  346. if (mem[n] != 0x55555555) {
  347. printf("SDRAM test fails at: %08x\n",
  348. (uint) & mem[n]);
  349. return 1;
  350. }
  351. }
  352. }
  353. printf("SDRAM test passes\n");
  354. return 0;
  355. }
  356. #endif
  357. /*************************************************************************
  358. * pci_pre_init
  359. *
  360. * This routine is called just prior to registering the hose and gives
  361. * the board the opportunity to check things. Returning a value of zero
  362. * indicates that things are bad & PCI initialization should be aborted.
  363. *
  364. * Different boards may wish to customize the pci controller structure
  365. * (add regions, override default access routines, etc) or perform
  366. * certain pre-initialization actions.
  367. *
  368. ************************************************************************/
  369. #if defined(CONFIG_PCI) && defined(CFG_PCI_PRE_INIT)
  370. int pci_pre_init(struct pci_controller *hose)
  371. {
  372. unsigned long addr;
  373. /*-------------------------------------------------------------------------+
  374. | Set priority for all PLB3 devices to 0.
  375. | Set PLB3 arbiter to fair mode.
  376. +-------------------------------------------------------------------------*/
  377. mfsdr(sdr_amp1, addr);
  378. mtsdr(sdr_amp1, (addr & 0x000000FF) | 0x0000FF00);
  379. addr = mfdcr(plb3_acr);
  380. mtdcr(plb3_acr, addr | 0x80000000);
  381. /*-------------------------------------------------------------------------+
  382. | Set priority for all PLB4 devices to 0.
  383. +-------------------------------------------------------------------------*/
  384. mfsdr(sdr_amp0, addr);
  385. mtsdr(sdr_amp0, (addr & 0x000000FF) | 0x0000FF00);
  386. addr = mfdcr(plb4_acr) | 0xa0000000; /* Was 0x8---- */
  387. mtdcr(plb4_acr, addr);
  388. /*-------------------------------------------------------------------------+
  389. | Set Nebula PLB4 arbiter to fair mode.
  390. +-------------------------------------------------------------------------*/
  391. /* Segment0 */
  392. addr = (mfdcr(plb0_acr) & ~plb0_acr_ppm_mask) | plb0_acr_ppm_fair;
  393. addr = (addr & ~plb0_acr_hbu_mask) | plb0_acr_hbu_enabled;
  394. addr = (addr & ~plb0_acr_rdp_mask) | plb0_acr_rdp_4deep;
  395. addr = (addr & ~plb0_acr_wrp_mask) | plb0_acr_wrp_2deep;
  396. mtdcr(plb0_acr, addr);
  397. /* Segment1 */
  398. addr = (mfdcr(plb1_acr) & ~plb1_acr_ppm_mask) | plb1_acr_ppm_fair;
  399. addr = (addr & ~plb1_acr_hbu_mask) | plb1_acr_hbu_enabled;
  400. addr = (addr & ~plb1_acr_rdp_mask) | plb1_acr_rdp_4deep;
  401. addr = (addr & ~plb1_acr_wrp_mask) | plb1_acr_wrp_2deep;
  402. mtdcr(plb1_acr, addr);
  403. return 1;
  404. }
  405. #endif /* defined(CONFIG_PCI) && defined(CFG_PCI_PRE_INIT) */
  406. /*************************************************************************
  407. * pci_target_init
  408. *
  409. * The bootstrap configuration provides default settings for the pci
  410. * inbound map (PIM). But the bootstrap config choices are limited and
  411. * may not be sufficient for a given board.
  412. *
  413. ************************************************************************/
  414. #if defined(CONFIG_PCI) && defined(CFG_PCI_TARGET_INIT)
  415. void pci_target_init(struct pci_controller *hose)
  416. {
  417. /*--------------------------------------------------------------------------+
  418. * Set up Direct MMIO registers
  419. *--------------------------------------------------------------------------*/
  420. /*--------------------------------------------------------------------------+
  421. | PowerPC440 EP PCI Master configuration.
  422. | Map one 1Gig range of PLB/processor addresses to PCI memory space.
  423. | PLB address 0xA0000000-0xDFFFFFFF ==> PCI address 0xA0000000-0xDFFFFFFF
  424. | Use byte reversed out routines to handle endianess.
  425. | Make this region non-prefetchable.
  426. +--------------------------------------------------------------------------*/
  427. out32r(PCIX0_PMM0MA, 0x00000000); /* PMM0 Mask/Attribute - disabled b4 setting */
  428. out32r(PCIX0_PMM0LA, CFG_PCI_MEMBASE); /* PMM0 Local Address */
  429. out32r(PCIX0_PMM0PCILA, CFG_PCI_MEMBASE); /* PMM0 PCI Low Address */
  430. out32r(PCIX0_PMM0PCIHA, 0x00000000); /* PMM0 PCI High Address */
  431. out32r(PCIX0_PMM0MA, 0xE0000001); /* 512M + No prefetching, and enable region */
  432. out32r(PCIX0_PMM1MA, 0x00000000); /* PMM0 Mask/Attribute - disabled b4 setting */
  433. out32r(PCIX0_PMM1LA, CFG_PCI_MEMBASE2); /* PMM0 Local Address */
  434. out32r(PCIX0_PMM1PCILA, CFG_PCI_MEMBASE2); /* PMM0 PCI Low Address */
  435. out32r(PCIX0_PMM1PCIHA, 0x00000000); /* PMM0 PCI High Address */
  436. out32r(PCIX0_PMM1MA, 0xE0000001); /* 512M + No prefetching, and enable region */
  437. out32r(PCIX0_PTM1MS, 0x00000001); /* Memory Size/Attribute */
  438. out32r(PCIX0_PTM1LA, 0); /* Local Addr. Reg */
  439. out32r(PCIX0_PTM2MS, 0); /* Memory Size/Attribute */
  440. out32r(PCIX0_PTM2LA, 0); /* Local Addr. Reg */
  441. /*--------------------------------------------------------------------------+
  442. * Set up Configuration registers
  443. *--------------------------------------------------------------------------*/
  444. /* Program the board's subsystem id/vendor id */
  445. pci_write_config_word(0, PCI_SUBSYSTEM_VENDOR_ID,
  446. CFG_PCI_SUBSYS_VENDORID);
  447. pci_write_config_word(0, PCI_SUBSYSTEM_ID, CFG_PCI_SUBSYS_ID);
  448. /* Configure command register as bus master */
  449. pci_write_config_word(0, PCI_COMMAND, PCI_COMMAND_MASTER);
  450. /* 240nS PCI clock */
  451. pci_write_config_word(0, PCI_LATENCY_TIMER, 1);
  452. /* No error reporting */
  453. pci_write_config_word(0, PCI_ERREN, 0);
  454. pci_write_config_dword(0, PCI_BRDGOPT2, 0x00000101);
  455. }
  456. #endif /* defined(CONFIG_PCI) && defined(CFG_PCI_TARGET_INIT) */
  457. /*************************************************************************
  458. * pci_master_init
  459. *
  460. ************************************************************************/
  461. #if defined(CONFIG_PCI) && defined(CFG_PCI_MASTER_INIT)
  462. void pci_master_init(struct pci_controller *hose)
  463. {
  464. unsigned short temp_short;
  465. /*--------------------------------------------------------------------------+
  466. | Write the PowerPC440 EP PCI Configuration regs.
  467. | Enable PowerPC440 EP to be a master on the PCI bus (PMM).
  468. | Enable PowerPC440 EP to act as a PCI memory target (PTM).
  469. +--------------------------------------------------------------------------*/
  470. pci_read_config_word(0, PCI_COMMAND, &temp_short);
  471. pci_write_config_word(0, PCI_COMMAND,
  472. temp_short | PCI_COMMAND_MASTER |
  473. PCI_COMMAND_MEMORY);
  474. }
  475. #endif /* defined(CONFIG_PCI) && defined(CFG_PCI_MASTER_INIT) */
  476. /*************************************************************************
  477. * is_pci_host
  478. *
  479. * This routine is called to determine if a pci scan should be
  480. * performed. With various hardware environments (especially cPCI and
  481. * PPMC) it's insufficient to depend on the state of the arbiter enable
  482. * bit in the strap register, or generic host/adapter assumptions.
  483. *
  484. * Rather than hard-code a bad assumption in the general 440 code, the
  485. * 440 pci code requires the board to decide at runtime.
  486. *
  487. * Return 0 for adapter mode, non-zero for host (monarch) mode.
  488. *
  489. *
  490. ************************************************************************/
  491. #if defined(CONFIG_PCI)
  492. int is_pci_host(struct pci_controller *hose)
  493. {
  494. /* Bamboo is always configured as host. */
  495. return (1);
  496. }
  497. #endif /* defined(CONFIG_PCI) */
  498. /*----------------------------------------------------------------------------+
  499. | is_powerpc440ep_pass1.
  500. +----------------------------------------------------------------------------*/
  501. int is_powerpc440ep_pass1(void)
  502. {
  503. unsigned long pvr;
  504. pvr = get_pvr();
  505. if (pvr == PVR_POWERPC_440EP_PASS1)
  506. return TRUE;
  507. else if (pvr == PVR_POWERPC_440EP_PASS2)
  508. return FALSE;
  509. else {
  510. printf("brdutil error 3\n");
  511. for (;;)
  512. ;
  513. }
  514. return(FALSE);
  515. }
  516. /*----------------------------------------------------------------------------+
  517. | is_nand_selected.
  518. +----------------------------------------------------------------------------*/
  519. int is_nand_selected(void)
  520. {
  521. #ifdef CONFIG_BAMBOO_NAND
  522. return TRUE;
  523. #else
  524. return FALSE;
  525. #endif
  526. }
  527. /*----------------------------------------------------------------------------+
  528. | config_on_ebc_cs4_is_small_flash => from EPLD
  529. +----------------------------------------------------------------------------*/
  530. unsigned char config_on_ebc_cs4_is_small_flash(void)
  531. {
  532. /* Not implemented yet => returns constant value */
  533. return TRUE;
  534. }
  535. /*----------------------------------------------------------------------------+
  536. | Ext_bus_cntlr_init.
  537. | Initialize the external bus controller
  538. +----------------------------------------------------------------------------*/
  539. void ext_bus_cntlr_init(void)
  540. {
  541. unsigned long sdr0_pstrp0, sdr0_sdstp1;
  542. unsigned long bootstrap_settings, boot_selection, ebc_boot_size;
  543. int computed_boot_device = BOOT_DEVICE_UNKNOWN;
  544. unsigned long ebc0_cs0_bnap_value = 0, ebc0_cs0_bncr_value = 0;
  545. unsigned long ebc0_cs1_bnap_value = 0, ebc0_cs1_bncr_value = 0;
  546. unsigned long ebc0_cs2_bnap_value = 0, ebc0_cs2_bncr_value = 0;
  547. unsigned long ebc0_cs3_bnap_value = 0, ebc0_cs3_bncr_value = 0;
  548. unsigned long ebc0_cs4_bnap_value = 0, ebc0_cs4_bncr_value = 0;
  549. /*-------------------------------------------------------------------------+
  550. |
  551. | PART 1 : Initialize EBC Bank 5
  552. | ==============================
  553. | Bank5 is always associated to the NVRAM/EPLD.
  554. | It has to be initialized prior to other banks settings computation since
  555. | some board registers values may be needed
  556. |
  557. +-------------------------------------------------------------------------*/
  558. /* NVRAM - FPGA */
  559. mtebc(pb5ap, EBC0_BNAP_NVRAM_FPGA);
  560. mtebc(pb5cr, EBC0_BNCR_NVRAM_FPGA_CS5);
  561. /*-------------------------------------------------------------------------+
  562. |
  563. | PART 2 : Determine which boot device was selected
  564. | =========================================
  565. |
  566. | Read Pin Strap Register in PPC440EP
  567. | In case of boot from IIC, read Serial Device Strap Register1
  568. |
  569. | Result can either be :
  570. | - Boot from EBC 8bits => SMALL FLASH
  571. | - Boot from EBC 16bits => Large Flash or SRAM
  572. | - Boot from NAND Flash
  573. | - Boot from PCI
  574. |
  575. +-------------------------------------------------------------------------*/
  576. /* Read Pin Strap Register in PPC440EP */
  577. mfsdr(sdr_pstrp0, sdr0_pstrp0);
  578. bootstrap_settings = sdr0_pstrp0 & SDR0_PSTRP0_BOOTSTRAP_MASK;
  579. /*-------------------------------------------------------------------------+
  580. | PPC440EP Pass1
  581. +-------------------------------------------------------------------------*/
  582. if (is_powerpc440ep_pass1() == TRUE) {
  583. switch(bootstrap_settings) {
  584. case SDR0_PSTRP0_BOOTSTRAP_SETTINGS0:
  585. /* Default Strap Settings 0 : CPU 400 - PLB 133 - Boot EBC 8 bit 33MHz */
  586. /* Boot from Small Flash */
  587. computed_boot_device = BOOT_FROM_SMALL_FLASH;
  588. break;
  589. case SDR0_PSTRP0_BOOTSTRAP_SETTINGS1:
  590. /* Default Strap Settings 1 : CPU 533 - PLB 133 - Boot PCI 66MHz */
  591. /* Boot from PCI */
  592. computed_boot_device = BOOT_FROM_PCI;
  593. break;
  594. case SDR0_PSTRP0_BOOTSTRAP_SETTINGS2:
  595. /* Default Strap Settings 2 : CPU 500 - PLB 100 - Boot NDFC16 66MHz */
  596. /* Boot from Nand Flash */
  597. computed_boot_device = BOOT_FROM_NAND_FLASH0;
  598. break;
  599. case SDR0_PSTRP0_BOOTSTRAP_SETTINGS3:
  600. /* Default Strap Settings 3 : CPU 333 - PLB 133 - Boot EBC 8 bit 66MHz */
  601. /* Boot from Small Flash */
  602. computed_boot_device = BOOT_FROM_SMALL_FLASH;
  603. break;
  604. case SDR0_PSTRP0_BOOTSTRAP_IIC_A8_EN:
  605. case SDR0_PSTRP0_BOOTSTRAP_IIC_A4_EN:
  606. /* Boot Settings in IIC EEprom address 0xA8 or 0xA4 */
  607. /* Read Serial Device Strap Register1 in PPC440EP */
  608. mfsdr(sdr_sdstp1, sdr0_sdstp1);
  609. boot_selection = sdr0_sdstp1 & SDR0_SDSTP1_BOOT_SEL_MASK;
  610. ebc_boot_size = sdr0_sdstp1 & SDR0_SDSTP1_EBC_ROM_BS_MASK;
  611. switch(boot_selection) {
  612. case SDR0_SDSTP1_BOOT_SEL_EBC:
  613. switch(ebc_boot_size) {
  614. case SDR0_SDSTP1_EBC_ROM_BS_16BIT:
  615. computed_boot_device = BOOT_FROM_LARGE_FLASH_OR_SRAM;
  616. break;
  617. case SDR0_SDSTP1_EBC_ROM_BS_8BIT:
  618. computed_boot_device = BOOT_FROM_SMALL_FLASH;
  619. break;
  620. }
  621. break;
  622. case SDR0_SDSTP1_BOOT_SEL_PCI:
  623. computed_boot_device = BOOT_FROM_PCI;
  624. break;
  625. case SDR0_SDSTP1_BOOT_SEL_NDFC:
  626. computed_boot_device = BOOT_FROM_NAND_FLASH0;
  627. break;
  628. }
  629. break;
  630. }
  631. }
  632. /*-------------------------------------------------------------------------+
  633. | PPC440EP Pass2
  634. +-------------------------------------------------------------------------*/
  635. else {
  636. switch(bootstrap_settings) {
  637. case SDR0_PSTRP0_BOOTSTRAP_SETTINGS0:
  638. /* Default Strap Settings 0 : CPU 400 - PLB 133 - Boot EBC 8 bit 33MHz */
  639. /* Boot from Small Flash */
  640. computed_boot_device = BOOT_FROM_SMALL_FLASH;
  641. break;
  642. case SDR0_PSTRP0_BOOTSTRAP_SETTINGS1:
  643. /* Default Strap Settings 1 : CPU 333 - PLB 133 - Boot PCI 66MHz */
  644. /* Boot from PCI */
  645. computed_boot_device = BOOT_FROM_PCI;
  646. break;
  647. case SDR0_PSTRP0_BOOTSTRAP_SETTINGS2:
  648. /* Default Strap Settings 2 : CPU 400 - PLB 100 - Boot NDFC16 33MHz */
  649. /* Boot from Nand Flash */
  650. computed_boot_device = BOOT_FROM_NAND_FLASH0;
  651. break;
  652. case SDR0_PSTRP0_BOOTSTRAP_SETTINGS3:
  653. /* Default Strap Settings 3 : CPU 400 - PLB 100 - Boot EBC 16 bit 33MHz */
  654. /* Boot from Large Flash or SRAM */
  655. computed_boot_device = BOOT_FROM_LARGE_FLASH_OR_SRAM;
  656. break;
  657. case SDR0_PSTRP0_BOOTSTRAP_SETTINGS4:
  658. /* Default Strap Settings 4 : CPU 333 - PLB 133 - Boot EBC 16 bit 66MHz */
  659. /* Boot from Large Flash or SRAM */
  660. computed_boot_device = BOOT_FROM_LARGE_FLASH_OR_SRAM;
  661. break;
  662. case SDR0_PSTRP0_BOOTSTRAP_SETTINGS6:
  663. /* Default Strap Settings 6 : CPU 400 - PLB 100 - Boot PCI 33MHz */
  664. /* Boot from PCI */
  665. computed_boot_device = BOOT_FROM_PCI;
  666. break;
  667. case SDR0_PSTRP0_BOOTSTRAP_IIC_A8_EN:
  668. case SDR0_PSTRP0_BOOTSTRAP_IIC_A4_EN:
  669. /* Default Strap Settings 5-7 */
  670. /* Boot Settings in IIC EEprom address 0xA8 or 0xA4 */
  671. /* Read Serial Device Strap Register1 in PPC440EP */
  672. mfsdr(sdr_sdstp1, sdr0_sdstp1);
  673. boot_selection = sdr0_sdstp1 & SDR0_SDSTP1_BOOT_SEL_MASK;
  674. ebc_boot_size = sdr0_sdstp1 & SDR0_SDSTP1_EBC_ROM_BS_MASK;
  675. switch(boot_selection) {
  676. case SDR0_SDSTP1_BOOT_SEL_EBC:
  677. switch(ebc_boot_size) {
  678. case SDR0_SDSTP1_EBC_ROM_BS_16BIT:
  679. computed_boot_device = BOOT_FROM_LARGE_FLASH_OR_SRAM;
  680. break;
  681. case SDR0_SDSTP1_EBC_ROM_BS_8BIT:
  682. computed_boot_device = BOOT_FROM_SMALL_FLASH;
  683. break;
  684. }
  685. break;
  686. case SDR0_SDSTP1_BOOT_SEL_PCI:
  687. computed_boot_device = BOOT_FROM_PCI;
  688. break;
  689. case SDR0_SDSTP1_BOOT_SEL_NDFC:
  690. computed_boot_device = BOOT_FROM_NAND_FLASH0;
  691. break;
  692. }
  693. break;
  694. }
  695. }
  696. /*-------------------------------------------------------------------------+
  697. |
  698. | PART 3 : Compute EBC settings depending on selected boot device
  699. | ====== ======================================================
  700. |
  701. | Resulting EBC init will be among following configurations :
  702. |
  703. | - Boot from EBC 8bits => boot from SMALL FLASH selected
  704. | EBC-CS0 = Small Flash
  705. | EBC-CS1,2,3 = NAND Flash or
  706. | Exp.Slot depending on Soft Config
  707. | EBC-CS4 = SRAM/Large Flash or
  708. | Large Flash/SRAM depending on jumpers
  709. | EBC-CS5 = NVRAM / EPLD
  710. |
  711. | - Boot from EBC 16bits => boot from Large Flash or SRAM selected
  712. | EBC-CS0 = SRAM/Large Flash or
  713. | Large Flash/SRAM depending on jumpers
  714. | EBC-CS1,2,3 = NAND Flash or
  715. | Exp.Slot depending on Software Configuration
  716. | EBC-CS4 = Small Flash
  717. | EBC-CS5 = NVRAM / EPLD
  718. |
  719. | - Boot from NAND Flash
  720. | EBC-CS0 = NAND Flash0
  721. | EBC-CS1,2,3 = NAND Flash1
  722. | EBC-CS4 = SRAM/Large Flash or
  723. | Large Flash/SRAM depending on jumpers
  724. | EBC-CS5 = NVRAM / EPLD
  725. |
  726. | - Boot from PCI
  727. | EBC-CS0 = ...
  728. | EBC-CS1,2,3 = NAND Flash or
  729. | Exp.Slot depending on Software Configuration
  730. | EBC-CS4 = SRAM/Large Flash or
  731. | Large Flash/SRAM or
  732. | Small Flash depending on jumpers
  733. | EBC-CS5 = NVRAM / EPLD
  734. |
  735. +-------------------------------------------------------------------------*/
  736. switch(computed_boot_device) {
  737. /*------------------------------------------------------------------------- */
  738. case BOOT_FROM_SMALL_FLASH:
  739. /*------------------------------------------------------------------------- */
  740. ebc0_cs0_bnap_value = EBC0_BNAP_SMALL_FLASH;
  741. ebc0_cs0_bncr_value = EBC0_BNCR_SMALL_FLASH_CS0;
  742. if ((is_nand_selected()) == TRUE) {
  743. /* NAND Flash */
  744. ebc0_cs1_bnap_value = EBC0_BNAP_NAND_FLASH;
  745. ebc0_cs1_bncr_value = EBC0_BNCR_NAND_FLASH_CS1;
  746. ebc0_cs2_bnap_value = EBC0_BNAP_NAND_FLASH;
  747. ebc0_cs2_bncr_value = EBC0_BNCR_NAND_FLASH_CS2;
  748. ebc0_cs3_bnap_value = 0;
  749. ebc0_cs3_bncr_value = 0;
  750. } else {
  751. /* Expansion Slot */
  752. ebc0_cs1_bnap_value = 0;
  753. ebc0_cs1_bncr_value = 0;
  754. ebc0_cs2_bnap_value = 0;
  755. ebc0_cs2_bncr_value = 0;
  756. ebc0_cs3_bnap_value = 0;
  757. ebc0_cs3_bncr_value = 0;
  758. }
  759. ebc0_cs4_bnap_value = EBC0_BNAP_LARGE_FLASH_OR_SRAM;
  760. ebc0_cs4_bncr_value = EBC0_BNCR_LARGE_FLASH_OR_SRAM_CS4;
  761. break;
  762. /*------------------------------------------------------------------------- */
  763. case BOOT_FROM_LARGE_FLASH_OR_SRAM:
  764. /*------------------------------------------------------------------------- */
  765. ebc0_cs0_bnap_value = EBC0_BNAP_LARGE_FLASH_OR_SRAM;
  766. ebc0_cs0_bncr_value = EBC0_BNCR_LARGE_FLASH_OR_SRAM_CS0;
  767. if ((is_nand_selected()) == TRUE) {
  768. /* NAND Flash */
  769. ebc0_cs1_bnap_value = EBC0_BNAP_NAND_FLASH;
  770. ebc0_cs1_bncr_value = EBC0_BNCR_NAND_FLASH_CS1;
  771. ebc0_cs2_bnap_value = 0;
  772. ebc0_cs2_bncr_value = 0;
  773. ebc0_cs3_bnap_value = 0;
  774. ebc0_cs3_bncr_value = 0;
  775. } else {
  776. /* Expansion Slot */
  777. ebc0_cs1_bnap_value = 0;
  778. ebc0_cs1_bncr_value = 0;
  779. ebc0_cs2_bnap_value = 0;
  780. ebc0_cs2_bncr_value = 0;
  781. ebc0_cs3_bnap_value = 0;
  782. ebc0_cs3_bncr_value = 0;
  783. }
  784. ebc0_cs4_bnap_value = EBC0_BNAP_SMALL_FLASH;
  785. ebc0_cs4_bncr_value = EBC0_BNCR_SMALL_FLASH_CS4;
  786. break;
  787. /*------------------------------------------------------------------------- */
  788. case BOOT_FROM_NAND_FLASH0:
  789. /*------------------------------------------------------------------------- */
  790. ebc0_cs0_bnap_value = 0;
  791. ebc0_cs0_bncr_value = 0;
  792. ebc0_cs1_bnap_value = EBC0_BNAP_NAND_FLASH;
  793. ebc0_cs1_bncr_value = EBC0_BNCR_NAND_FLASH_CS1;
  794. ebc0_cs2_bnap_value = 0;
  795. ebc0_cs2_bncr_value = 0;
  796. ebc0_cs3_bnap_value = 0;
  797. ebc0_cs3_bncr_value = 0;
  798. /* Large Flash or SRAM */
  799. ebc0_cs4_bnap_value = EBC0_BNAP_LARGE_FLASH_OR_SRAM;
  800. ebc0_cs4_bncr_value = EBC0_BNCR_LARGE_FLASH_OR_SRAM_CS4;
  801. break;
  802. /*------------------------------------------------------------------------- */
  803. case BOOT_FROM_PCI:
  804. /*------------------------------------------------------------------------- */
  805. ebc0_cs0_bnap_value = 0;
  806. ebc0_cs0_bncr_value = 0;
  807. if ((is_nand_selected()) == TRUE) {
  808. /* NAND Flash */
  809. ebc0_cs1_bnap_value = EBC0_BNAP_NAND_FLASH;
  810. ebc0_cs1_bncr_value = EBC0_BNCR_NAND_FLASH_CS1;
  811. ebc0_cs2_bnap_value = 0;
  812. ebc0_cs2_bncr_value = 0;
  813. ebc0_cs3_bnap_value = 0;
  814. ebc0_cs3_bncr_value = 0;
  815. } else {
  816. /* Expansion Slot */
  817. ebc0_cs1_bnap_value = 0;
  818. ebc0_cs1_bncr_value = 0;
  819. ebc0_cs2_bnap_value = 0;
  820. ebc0_cs2_bncr_value = 0;
  821. ebc0_cs3_bnap_value = 0;
  822. ebc0_cs3_bncr_value = 0;
  823. }
  824. if ((config_on_ebc_cs4_is_small_flash()) == TRUE) {
  825. /* Small Flash */
  826. ebc0_cs4_bnap_value = EBC0_BNAP_SMALL_FLASH;
  827. ebc0_cs4_bncr_value = EBC0_BNCR_SMALL_FLASH_CS4;
  828. } else {
  829. /* Large Flash or SRAM */
  830. ebc0_cs4_bnap_value = EBC0_BNAP_LARGE_FLASH_OR_SRAM;
  831. ebc0_cs4_bncr_value = EBC0_BNCR_LARGE_FLASH_OR_SRAM_CS4;
  832. }
  833. break;
  834. /*------------------------------------------------------------------------- */
  835. case BOOT_DEVICE_UNKNOWN:
  836. /*------------------------------------------------------------------------- */
  837. /* Error */
  838. break;
  839. }
  840. /*-------------------------------------------------------------------------+
  841. | Initialize EBC CONFIG
  842. +-------------------------------------------------------------------------*/
  843. mtdcr(ebccfga, xbcfg);
  844. mtdcr(ebccfgd, EBC0_CFG_EBTC_DRIVEN |
  845. EBC0_CFG_PTD_ENABLED |
  846. EBC0_CFG_RTC_2048PERCLK |
  847. EBC0_CFG_EMPL_LOW |
  848. EBC0_CFG_EMPH_LOW |
  849. EBC0_CFG_CSTC_DRIVEN |
  850. EBC0_CFG_BPF_ONEDW |
  851. EBC0_CFG_EMS_8BIT |
  852. EBC0_CFG_PME_DISABLED |
  853. EBC0_CFG_PMT_ENCODE(0) );
  854. /*-------------------------------------------------------------------------+
  855. | Initialize EBC Bank 0-4
  856. +-------------------------------------------------------------------------*/
  857. /* EBC Bank0 */
  858. mtebc(pb0ap, ebc0_cs0_bnap_value);
  859. mtebc(pb0cr, ebc0_cs0_bncr_value);
  860. /* EBC Bank1 */
  861. mtebc(pb1ap, ebc0_cs1_bnap_value);
  862. mtebc(pb1cr, ebc0_cs1_bncr_value);
  863. /* EBC Bank2 */
  864. mtebc(pb2ap, ebc0_cs2_bnap_value);
  865. mtebc(pb2cr, ebc0_cs2_bncr_value);
  866. /* EBC Bank3 */
  867. mtebc(pb3ap, ebc0_cs3_bnap_value);
  868. mtebc(pb3cr, ebc0_cs3_bncr_value);
  869. /* EBC Bank4 */
  870. mtebc(pb4ap, ebc0_cs4_bnap_value);
  871. mtebc(pb4cr, ebc0_cs4_bncr_value);
  872. return;
  873. }
  874. /*----------------------------------------------------------------------------+
  875. | get_uart_configuration.
  876. +----------------------------------------------------------------------------*/
  877. uart_config_nb_t get_uart_configuration(void)
  878. {
  879. return (L4);
  880. }
  881. /*----------------------------------------------------------------------------+
  882. | set_phy_configuration_through_fpga => to EPLD
  883. +----------------------------------------------------------------------------*/
  884. void set_phy_configuration_through_fpga(zmii_config_t config)
  885. {
  886. unsigned long fpga_selection_reg;
  887. fpga_selection_reg = in8(FPGA_SELECTION_1_REG) & ~FPGA_SEL_1_REG_PHY_MASK;
  888. switch(config)
  889. {
  890. case ZMII_CONFIGURATION_IS_MII:
  891. fpga_selection_reg = fpga_selection_reg | FPGA_SEL_1_REG_MII;
  892. break;
  893. case ZMII_CONFIGURATION_IS_RMII:
  894. fpga_selection_reg = fpga_selection_reg | FPGA_SEL_1_REG_RMII;
  895. break;
  896. case ZMII_CONFIGURATION_IS_SMII:
  897. fpga_selection_reg = fpga_selection_reg | FPGA_SEL_1_REG_SMII;
  898. break;
  899. case ZMII_CONFIGURATION_UNKNOWN:
  900. default:
  901. break;
  902. }
  903. out8(FPGA_SELECTION_1_REG,fpga_selection_reg);
  904. }
  905. /*----------------------------------------------------------------------------+
  906. | scp_selection_in_fpga.
  907. +----------------------------------------------------------------------------*/
  908. void scp_selection_in_fpga(void)
  909. {
  910. unsigned long fpga_selection_2_reg;
  911. fpga_selection_2_reg = in8(FPGA_SELECTION_2_REG) & ~FPGA_SEL2_REG_IIC1_SCP_SEL_MASK;
  912. fpga_selection_2_reg |= FPGA_SEL2_REG_SEL_SCP;
  913. out8(FPGA_SELECTION_2_REG,fpga_selection_2_reg);
  914. }
  915. /*----------------------------------------------------------------------------+
  916. | iic1_selection_in_fpga.
  917. +----------------------------------------------------------------------------*/
  918. void iic1_selection_in_fpga(void)
  919. {
  920. unsigned long fpga_selection_2_reg;
  921. fpga_selection_2_reg = in8(FPGA_SELECTION_2_REG) & ~FPGA_SEL2_REG_IIC1_SCP_SEL_MASK;
  922. fpga_selection_2_reg |= FPGA_SEL2_REG_SEL_IIC1;
  923. out8(FPGA_SELECTION_2_REG,fpga_selection_2_reg);
  924. }
  925. /*----------------------------------------------------------------------------+
  926. | dma_a_b_selection_in_fpga.
  927. +----------------------------------------------------------------------------*/
  928. void dma_a_b_selection_in_fpga(void)
  929. {
  930. unsigned long fpga_selection_2_reg;
  931. fpga_selection_2_reg = in8(FPGA_SELECTION_2_REG) | FPGA_SEL2_REG_SEL_DMA_A_B;
  932. out8(FPGA_SELECTION_2_REG,fpga_selection_2_reg);
  933. }
  934. /*----------------------------------------------------------------------------+
  935. | dma_a_b_unselect_in_fpga.
  936. +----------------------------------------------------------------------------*/
  937. void dma_a_b_unselect_in_fpga(void)
  938. {
  939. unsigned long fpga_selection_2_reg;
  940. fpga_selection_2_reg = in8(FPGA_SELECTION_2_REG) & ~FPGA_SEL2_REG_SEL_DMA_A_B;
  941. out8(FPGA_SELECTION_2_REG,fpga_selection_2_reg);
  942. }
  943. /*----------------------------------------------------------------------------+
  944. | dma_c_d_selection_in_fpga.
  945. +----------------------------------------------------------------------------*/
  946. void dma_c_d_selection_in_fpga(void)
  947. {
  948. unsigned long fpga_selection_2_reg;
  949. fpga_selection_2_reg = in8(FPGA_SELECTION_2_REG) | FPGA_SEL2_REG_SEL_DMA_C_D;
  950. out8(FPGA_SELECTION_2_REG,fpga_selection_2_reg);
  951. }
  952. /*----------------------------------------------------------------------------+
  953. | dma_c_d_unselect_in_fpga.
  954. +----------------------------------------------------------------------------*/
  955. void dma_c_d_unselect_in_fpga(void)
  956. {
  957. unsigned long fpga_selection_2_reg;
  958. fpga_selection_2_reg = in8(FPGA_SELECTION_2_REG) & ~FPGA_SEL2_REG_SEL_DMA_C_D;
  959. out8(FPGA_SELECTION_2_REG,fpga_selection_2_reg);
  960. }
  961. /*----------------------------------------------------------------------------+
  962. | usb2_device_selection_in_fpga.
  963. +----------------------------------------------------------------------------*/
  964. void usb2_device_selection_in_fpga(void)
  965. {
  966. unsigned long fpga_selection_1_reg;
  967. fpga_selection_1_reg = in8(FPGA_SELECTION_1_REG) | FPGA_SEL_1_REG_USB2_DEV_SEL;
  968. out8(FPGA_SELECTION_1_REG,fpga_selection_1_reg);
  969. }
  970. /*----------------------------------------------------------------------------+
  971. | usb2_device_reset_through_fpga.
  972. +----------------------------------------------------------------------------*/
  973. void usb2_device_reset_through_fpga(void)
  974. {
  975. /* Perform soft Reset pulse */
  976. unsigned long fpga_reset_reg;
  977. int i;
  978. fpga_reset_reg = in8(FPGA_RESET_REG);
  979. out8(FPGA_RESET_REG,fpga_reset_reg | FPGA_RESET_REG_RESET_USB20_DEV);
  980. for (i=0; i<500; i++)
  981. udelay(1000);
  982. out8(FPGA_RESET_REG,fpga_reset_reg);
  983. }
  984. /*----------------------------------------------------------------------------+
  985. | usb2_host_selection_in_fpga.
  986. +----------------------------------------------------------------------------*/
  987. void usb2_host_selection_in_fpga(void)
  988. {
  989. unsigned long fpga_selection_1_reg;
  990. fpga_selection_1_reg = in8(FPGA_SELECTION_1_REG) | FPGA_SEL_1_REG_USB2_HOST_SEL;
  991. out8(FPGA_SELECTION_1_REG,fpga_selection_1_reg);
  992. }
  993. /*----------------------------------------------------------------------------+
  994. | ndfc_selection_in_fpga.
  995. +----------------------------------------------------------------------------*/
  996. void ndfc_selection_in_fpga(void)
  997. {
  998. unsigned long fpga_selection_1_reg;
  999. fpga_selection_1_reg = in8(FPGA_SELECTION_1_REG) &~FPGA_SEL_1_REG_NF_SELEC_MASK;
  1000. fpga_selection_1_reg |= FPGA_SEL_1_REG_NF0_SEL_BY_NFCS1;
  1001. fpga_selection_1_reg |= FPGA_SEL_1_REG_NF1_SEL_BY_NFCS2;
  1002. out8(FPGA_SELECTION_1_REG,fpga_selection_1_reg);
  1003. }
  1004. /*----------------------------------------------------------------------------+
  1005. | uart_selection_in_fpga.
  1006. +----------------------------------------------------------------------------*/
  1007. void uart_selection_in_fpga(uart_config_nb_t uart_config)
  1008. {
  1009. /* FPGA register */
  1010. unsigned char fpga_selection_3_reg;
  1011. /* Read FPGA Reagister */
  1012. fpga_selection_3_reg = in8(FPGA_SELECTION_3_REG);
  1013. switch (uart_config)
  1014. {
  1015. case L1:
  1016. /* ----------------------------------------------------------------------- */
  1017. /* L1 configuration: UART0 = 8 pins */
  1018. /* ----------------------------------------------------------------------- */
  1019. /* Configure FPGA */
  1020. fpga_selection_3_reg = fpga_selection_3_reg & ~FPGA_SEL3_REG_SEL_UART_CONFIG_MASK;
  1021. fpga_selection_3_reg = fpga_selection_3_reg | FPGA_SEL3_REG_SEL_UART_CONFIG1;
  1022. out8(FPGA_SELECTION_3_REG, fpga_selection_3_reg);
  1023. break;
  1024. case L2:
  1025. /* ----------------------------------------------------------------------- */
  1026. /* L2 configuration: UART0 = 4 pins */
  1027. /* UART1 = 4 pins */
  1028. /* ----------------------------------------------------------------------- */
  1029. /* Configure FPGA */
  1030. fpga_selection_3_reg = fpga_selection_3_reg & ~FPGA_SEL3_REG_SEL_UART_CONFIG_MASK;
  1031. fpga_selection_3_reg = fpga_selection_3_reg | FPGA_SEL3_REG_SEL_UART_CONFIG2;
  1032. out8(FPGA_SELECTION_3_REG, fpga_selection_3_reg);
  1033. break;
  1034. case L3:
  1035. /* ----------------------------------------------------------------------- */
  1036. /* L3 configuration: UART0 = 4 pins */
  1037. /* UART1 = 2 pins */
  1038. /* UART2 = 2 pins */
  1039. /* ----------------------------------------------------------------------- */
  1040. /* Configure FPGA */
  1041. fpga_selection_3_reg = fpga_selection_3_reg & ~FPGA_SEL3_REG_SEL_UART_CONFIG_MASK;
  1042. fpga_selection_3_reg = fpga_selection_3_reg | FPGA_SEL3_REG_SEL_UART_CONFIG3;
  1043. out8(FPGA_SELECTION_3_REG, fpga_selection_3_reg);
  1044. break;
  1045. case L4:
  1046. /* Configure FPGA */
  1047. fpga_selection_3_reg = fpga_selection_3_reg & ~FPGA_SEL3_REG_SEL_UART_CONFIG_MASK;
  1048. fpga_selection_3_reg = fpga_selection_3_reg | FPGA_SEL3_REG_SEL_UART_CONFIG4;
  1049. out8(FPGA_SELECTION_3_REG, fpga_selection_3_reg);
  1050. break;
  1051. default:
  1052. /* Unsupported UART configuration number */
  1053. for (;;)
  1054. ;
  1055. break;
  1056. }
  1057. }
  1058. /*----------------------------------------------------------------------------+
  1059. | init_default_gpio
  1060. +----------------------------------------------------------------------------*/
  1061. void init_default_gpio(void)
  1062. {
  1063. int i;
  1064. /* Init GPIO0 */
  1065. for(i=0; i<GPIO_MAX; i++)
  1066. {
  1067. gpio_tab[GPIO0][i].add = GPIO0_BASE;
  1068. gpio_tab[GPIO0][i].in_out = GPIO_DIS;
  1069. gpio_tab[GPIO0][i].alt_nb = GPIO_SEL;
  1070. }
  1071. /* Init GPIO1 */
  1072. for(i=0; i<GPIO_MAX; i++)
  1073. {
  1074. gpio_tab[GPIO1][i].add = GPIO1_BASE;
  1075. gpio_tab[GPIO1][i].in_out = GPIO_DIS;
  1076. gpio_tab[GPIO1][i].alt_nb = GPIO_SEL;
  1077. }
  1078. /* EBC_CS_N(5) - GPIO0_10 */
  1079. gpio_tab[GPIO0][10].in_out = GPIO_OUT;
  1080. gpio_tab[GPIO0][10].alt_nb = GPIO_ALT1;
  1081. /* EBC_CS_N(4) - GPIO0_9 */
  1082. gpio_tab[GPIO0][9].in_out = GPIO_OUT;
  1083. gpio_tab[GPIO0][9].alt_nb = GPIO_ALT1;
  1084. }
  1085. /*----------------------------------------------------------------------------+
  1086. | update_uart_ios
  1087. +------------------------------------------------------------------------------
  1088. |
  1089. | Set UART Configuration in PowerPC440EP
  1090. |
  1091. | +---------------------------------------------------------------------+
  1092. | | Configuartion | Connector | Nb of pins | Pins | Associated |
  1093. | | Number | Port Name | available | naming | CORE |
  1094. | +-----------------+---------------+------------+--------+-------------+
  1095. | | L1 | Port_A | 8 | UART | UART core 0 |
  1096. | +-----------------+---------------+------------+--------+-------------+
  1097. | | L2 | Port_A | 4 | UART1 | UART core 0 |
  1098. | | (L2D) | Port_B | 4 | UART2 | UART core 1 |
  1099. | +-----------------+---------------+------------+--------+-------------+
  1100. | | L3 | Port_A | 4 | UART1 | UART core 0 |
  1101. | | (L3D) | Port_B | 2 | UART2 | UART core 1 |
  1102. | | | Port_C | 2 | UART3 | UART core 2 |
  1103. | +-----------------+---------------+------------+--------+-------------+
  1104. | | | Port_A | 2 | UART1 | UART core 0 |
  1105. | | L4 | Port_B | 2 | UART2 | UART core 1 |
  1106. | | (L4D) | Port_C | 2 | UART3 | UART core 2 |
  1107. | | | Port_D | 2 | UART4 | UART core 3 |
  1108. | +-----------------+---------------+------------+--------+-------------+
  1109. |
  1110. | Involved GPIOs
  1111. |
  1112. | +------------------------------------------------------------------------------+
  1113. | | GPIO | Aternate 1 | I/O | Alternate 2 | I/O | Alternate 3 | I/O |
  1114. | +---------+------------------+-----+-----------------+-----+-------------+-----+
  1115. | | GPIO1_2 | UART0_DCD_N | I | UART1_DSR_CTS_N | I | UART2_SOUT | O |
  1116. | | GPIO1_3 | UART0_8PIN_DSR_N | I | UART1_RTS_DTR_N | O | UART2_SIN | I |
  1117. | | GPIO1_4 | UART0_8PIN_CTS_N | I | NA | NA | UART3_SIN | I |
  1118. | | GPIO1_5 | UART0_RTS_N | O | NA | NA | UART3_SOUT | O |
  1119. | | GPIO1_6 | UART0_DTR_N | O | UART1_SOUT | O | NA | NA |
  1120. | | GPIO1_7 | UART0_RI_N | I | UART1_SIN | I | NA | NA |
  1121. | +------------------------------------------------------------------------------+
  1122. |
  1123. |
  1124. +----------------------------------------------------------------------------*/
  1125. void update_uart_ios(uart_config_nb_t uart_config)
  1126. {
  1127. switch (uart_config)
  1128. {
  1129. case L1:
  1130. /* ----------------------------------------------------------------------- */
  1131. /* L1 configuration: UART0 = 8 pins */
  1132. /* ----------------------------------------------------------------------- */
  1133. /* Update GPIO Configuration Table */
  1134. gpio_tab[GPIO1][2].in_out = GPIO_IN;
  1135. gpio_tab[GPIO1][2].alt_nb = GPIO_ALT1;
  1136. gpio_tab[GPIO1][3].in_out = GPIO_IN;
  1137. gpio_tab[GPIO1][3].alt_nb = GPIO_ALT1;
  1138. gpio_tab[GPIO1][4].in_out = GPIO_IN;
  1139. gpio_tab[GPIO1][4].alt_nb = GPIO_ALT1;
  1140. gpio_tab[GPIO1][5].in_out = GPIO_OUT;
  1141. gpio_tab[GPIO1][5].alt_nb = GPIO_ALT1;
  1142. gpio_tab[GPIO1][6].in_out = GPIO_OUT;
  1143. gpio_tab[GPIO1][6].alt_nb = GPIO_ALT1;
  1144. gpio_tab[GPIO1][7].in_out = GPIO_IN;
  1145. gpio_tab[GPIO1][7].alt_nb = GPIO_ALT1;
  1146. break;
  1147. case L2:
  1148. /* ----------------------------------------------------------------------- */
  1149. /* L2 configuration: UART0 = 4 pins */
  1150. /* UART1 = 4 pins */
  1151. /* ----------------------------------------------------------------------- */
  1152. /* Update GPIO Configuration Table */
  1153. gpio_tab[GPIO1][2].in_out = GPIO_IN;
  1154. gpio_tab[GPIO1][2].alt_nb = GPIO_ALT2;
  1155. gpio_tab[GPIO1][3].in_out = GPIO_OUT;
  1156. gpio_tab[GPIO1][3].alt_nb = GPIO_ALT2;
  1157. gpio_tab[GPIO1][4].in_out = GPIO_IN;
  1158. gpio_tab[GPIO1][4].alt_nb = GPIO_ALT1;
  1159. gpio_tab[GPIO1][5].in_out = GPIO_OUT;
  1160. gpio_tab[GPIO1][5].alt_nb = GPIO_ALT1;
  1161. gpio_tab[GPIO1][6].in_out = GPIO_OUT;
  1162. gpio_tab[GPIO1][6].alt_nb = GPIO_ALT2;
  1163. gpio_tab[GPIO1][7].in_out = GPIO_IN;
  1164. gpio_tab[GPIO1][7].alt_nb = GPIO_ALT2;
  1165. break;
  1166. case L3:
  1167. /* ----------------------------------------------------------------------- */
  1168. /* L3 configuration: UART0 = 4 pins */
  1169. /* UART1 = 2 pins */
  1170. /* UART2 = 2 pins */
  1171. /* ----------------------------------------------------------------------- */
  1172. /* Update GPIO Configuration Table */
  1173. gpio_tab[GPIO1][2].in_out = GPIO_OUT;
  1174. gpio_tab[GPIO1][2].alt_nb = GPIO_ALT3;
  1175. gpio_tab[GPIO1][3].in_out = GPIO_IN;
  1176. gpio_tab[GPIO1][3].alt_nb = GPIO_ALT3;
  1177. gpio_tab[GPIO1][4].in_out = GPIO_IN;
  1178. gpio_tab[GPIO1][4].alt_nb = GPIO_ALT1;
  1179. gpio_tab[GPIO1][5].in_out = GPIO_OUT;
  1180. gpio_tab[GPIO1][5].alt_nb = GPIO_ALT1;
  1181. gpio_tab[GPIO1][6].in_out = GPIO_OUT;
  1182. gpio_tab[GPIO1][6].alt_nb = GPIO_ALT2;
  1183. gpio_tab[GPIO1][7].in_out = GPIO_IN;
  1184. gpio_tab[GPIO1][7].alt_nb = GPIO_ALT2;
  1185. break;
  1186. case L4:
  1187. /* ----------------------------------------------------------------------- */
  1188. /* L4 configuration: UART0 = 2 pins */
  1189. /* UART1 = 2 pins */
  1190. /* UART2 = 2 pins */
  1191. /* UART3 = 2 pins */
  1192. /* ----------------------------------------------------------------------- */
  1193. /* Update GPIO Configuration Table */
  1194. gpio_tab[GPIO1][2].in_out = GPIO_OUT;
  1195. gpio_tab[GPIO1][2].alt_nb = GPIO_ALT3;
  1196. gpio_tab[GPIO1][3].in_out = GPIO_IN;
  1197. gpio_tab[GPIO1][3].alt_nb = GPIO_ALT3;
  1198. gpio_tab[GPIO1][4].in_out = GPIO_IN;
  1199. gpio_tab[GPIO1][4].alt_nb = GPIO_ALT3;
  1200. gpio_tab[GPIO1][5].in_out = GPIO_OUT;
  1201. gpio_tab[GPIO1][5].alt_nb = GPIO_ALT3;
  1202. gpio_tab[GPIO1][6].in_out = GPIO_OUT;
  1203. gpio_tab[GPIO1][6].alt_nb = GPIO_ALT2;
  1204. gpio_tab[GPIO1][7].in_out = GPIO_IN;
  1205. gpio_tab[GPIO1][7].alt_nb = GPIO_ALT2;
  1206. break;
  1207. default:
  1208. /* Unsupported UART configuration number */
  1209. printf("ERROR - Unsupported UART configuration number.\n\n");
  1210. for (;;)
  1211. ;
  1212. break;
  1213. }
  1214. /* Set input Selection Register on Alt_Receive for UART Input Core */
  1215. out32(GPIO1_IS1L, (in32(GPIO1_IS1L) | 0x0FC30000));
  1216. out32(GPIO1_IS2L, (in32(GPIO1_IS2L) | 0x0C030000));
  1217. out32(GPIO1_IS3L, (in32(GPIO1_IS3L) | 0x03C00000));
  1218. }
  1219. /*----------------------------------------------------------------------------+
  1220. | update_ndfc_ios(void).
  1221. +----------------------------------------------------------------------------*/
  1222. void update_ndfc_ios(void)
  1223. {
  1224. /* Update GPIO Configuration Table */
  1225. gpio_tab[GPIO0][6].in_out = GPIO_OUT; /* EBC_CS_N(1) */
  1226. gpio_tab[GPIO0][6].alt_nb = GPIO_ALT1;
  1227. #if 0
  1228. gpio_tab[GPIO0][7].in_out = GPIO_OUT; /* EBC_CS_N(2) */
  1229. gpio_tab[GPIO0][7].alt_nb = GPIO_ALT1;
  1230. gpio_tab[GPIO0][7].in_out = GPIO_OUT; /* EBC_CS_N(3) */
  1231. gpio_tab[GPIO0][7].alt_nb = GPIO_ALT1;
  1232. #endif
  1233. }
  1234. /*----------------------------------------------------------------------------+
  1235. | update_zii_ios(void).
  1236. +----------------------------------------------------------------------------*/
  1237. void update_zii_ios(void)
  1238. {
  1239. /* Update GPIO Configuration Table */
  1240. gpio_tab[GPIO0][12].in_out = GPIO_IN; /* ZII_p0Rxd(0) */
  1241. gpio_tab[GPIO0][12].alt_nb = GPIO_ALT1;
  1242. gpio_tab[GPIO0][13].in_out = GPIO_IN; /* ZII_p0Rxd(1) */
  1243. gpio_tab[GPIO0][13].alt_nb = GPIO_ALT1;
  1244. gpio_tab[GPIO0][14].in_out = GPIO_IN; /* ZII_p0Rxd(2) */
  1245. gpio_tab[GPIO0][14].alt_nb = GPIO_ALT1;
  1246. gpio_tab[GPIO0][15].in_out = GPIO_IN; /* ZII_p0Rxd(3) */
  1247. gpio_tab[GPIO0][15].alt_nb = GPIO_ALT1;
  1248. gpio_tab[GPIO0][16].in_out = GPIO_OUT; /* ZII_p0Txd(0) */
  1249. gpio_tab[GPIO0][16].alt_nb = GPIO_ALT1;
  1250. gpio_tab[GPIO0][17].in_out = GPIO_OUT; /* ZII_p0Txd(1) */
  1251. gpio_tab[GPIO0][17].alt_nb = GPIO_ALT1;
  1252. gpio_tab[GPIO0][18].in_out = GPIO_OUT; /* ZII_p0Txd(2) */
  1253. gpio_tab[GPIO0][18].alt_nb = GPIO_ALT1;
  1254. gpio_tab[GPIO0][19].in_out = GPIO_OUT; /* ZII_p0Txd(3) */
  1255. gpio_tab[GPIO0][19].alt_nb = GPIO_ALT1;
  1256. gpio_tab[GPIO0][20].in_out = GPIO_IN; /* ZII_p0Rx_er */
  1257. gpio_tab[GPIO0][20].alt_nb = GPIO_ALT1;
  1258. gpio_tab[GPIO0][21].in_out = GPIO_IN; /* ZII_p0Rx_dv */
  1259. gpio_tab[GPIO0][21].alt_nb = GPIO_ALT1;
  1260. gpio_tab[GPIO0][22].in_out = GPIO_IN; /* ZII_p0Crs */
  1261. gpio_tab[GPIO0][22].alt_nb = GPIO_ALT1;
  1262. gpio_tab[GPIO0][23].in_out = GPIO_OUT; /* ZII_p0Tx_er */
  1263. gpio_tab[GPIO0][23].alt_nb = GPIO_ALT1;
  1264. gpio_tab[GPIO0][24].in_out = GPIO_OUT; /* ZII_p0Tx_en */
  1265. gpio_tab[GPIO0][24].alt_nb = GPIO_ALT1;
  1266. gpio_tab[GPIO0][25].in_out = GPIO_IN; /* ZII_p0Col */
  1267. gpio_tab[GPIO0][25].alt_nb = GPIO_ALT1;
  1268. }
  1269. /*----------------------------------------------------------------------------+
  1270. | update_uic_0_3_irq_ios().
  1271. +----------------------------------------------------------------------------*/
  1272. void update_uic_0_3_irq_ios(void)
  1273. {
  1274. gpio_tab[GPIO1][8].in_out = GPIO_IN; /* UIC_IRQ(0) */
  1275. gpio_tab[GPIO1][8].alt_nb = GPIO_ALT1;
  1276. gpio_tab[GPIO1][9].in_out = GPIO_IN; /* UIC_IRQ(1) */
  1277. gpio_tab[GPIO1][9].alt_nb = GPIO_ALT1;
  1278. gpio_tab[GPIO1][10].in_out = GPIO_IN; /* UIC_IRQ(2) */
  1279. gpio_tab[GPIO1][10].alt_nb = GPIO_ALT1;
  1280. gpio_tab[GPIO1][11].in_out = GPIO_IN; /* UIC_IRQ(3) */
  1281. gpio_tab[GPIO1][11].alt_nb = GPIO_ALT1;
  1282. }
  1283. /*----------------------------------------------------------------------------+
  1284. | update_uic_4_9_irq_ios().
  1285. +----------------------------------------------------------------------------*/
  1286. void update_uic_4_9_irq_ios(void)
  1287. {
  1288. gpio_tab[GPIO1][12].in_out = GPIO_IN; /* UIC_IRQ(4) */
  1289. gpio_tab[GPIO1][12].alt_nb = GPIO_ALT1;
  1290. gpio_tab[GPIO1][13].in_out = GPIO_IN; /* UIC_IRQ(6) */
  1291. gpio_tab[GPIO1][13].alt_nb = GPIO_ALT1;
  1292. gpio_tab[GPIO1][14].in_out = GPIO_IN; /* UIC_IRQ(7) */
  1293. gpio_tab[GPIO1][14].alt_nb = GPIO_ALT1;
  1294. gpio_tab[GPIO1][15].in_out = GPIO_IN; /* UIC_IRQ(8) */
  1295. gpio_tab[GPIO1][15].alt_nb = GPIO_ALT1;
  1296. gpio_tab[GPIO1][16].in_out = GPIO_IN; /* UIC_IRQ(9) */
  1297. gpio_tab[GPIO1][16].alt_nb = GPIO_ALT1;
  1298. }
  1299. /*----------------------------------------------------------------------------+
  1300. | update_dma_a_b_ios().
  1301. +----------------------------------------------------------------------------*/
  1302. void update_dma_a_b_ios(void)
  1303. {
  1304. gpio_tab[GPIO1][12].in_out = GPIO_OUT; /* DMA_ACK(1) */
  1305. gpio_tab[GPIO1][12].alt_nb = GPIO_ALT2;
  1306. gpio_tab[GPIO1][13].in_out = GPIO_BI; /* DMA_EOT/TC(1) */
  1307. gpio_tab[GPIO1][13].alt_nb = GPIO_ALT2;
  1308. gpio_tab[GPIO1][14].in_out = GPIO_IN; /* DMA_REQ(0) */
  1309. gpio_tab[GPIO1][14].alt_nb = GPIO_ALT2;
  1310. gpio_tab[GPIO1][15].in_out = GPIO_OUT; /* DMA_ACK(0) */
  1311. gpio_tab[GPIO1][15].alt_nb = GPIO_ALT2;
  1312. gpio_tab[GPIO1][16].in_out = GPIO_BI; /* DMA_EOT/TC(0) */
  1313. gpio_tab[GPIO1][16].alt_nb = GPIO_ALT2;
  1314. }
  1315. /*----------------------------------------------------------------------------+
  1316. | update_dma_c_d_ios().
  1317. +----------------------------------------------------------------------------*/
  1318. void update_dma_c_d_ios(void)
  1319. {
  1320. gpio_tab[GPIO0][0].in_out = GPIO_IN; /* DMA_REQ(2) */
  1321. gpio_tab[GPIO0][0].alt_nb = GPIO_ALT2;
  1322. gpio_tab[GPIO0][1].in_out = GPIO_OUT; /* DMA_ACK(2) */
  1323. gpio_tab[GPIO0][1].alt_nb = GPIO_ALT2;
  1324. gpio_tab[GPIO0][2].in_out = GPIO_BI; /* DMA_EOT/TC(2) */
  1325. gpio_tab[GPIO0][2].alt_nb = GPIO_ALT2;
  1326. gpio_tab[GPIO0][3].in_out = GPIO_IN; /* DMA_REQ(3) */
  1327. gpio_tab[GPIO0][3].alt_nb = GPIO_ALT2;
  1328. gpio_tab[GPIO0][4].in_out = GPIO_OUT; /* DMA_ACK(3) */
  1329. gpio_tab[GPIO0][4].alt_nb = GPIO_ALT2;
  1330. gpio_tab[GPIO0][5].in_out = GPIO_BI; /* DMA_EOT/TC(3) */
  1331. gpio_tab[GPIO0][5].alt_nb = GPIO_ALT2;
  1332. }
  1333. /*----------------------------------------------------------------------------+
  1334. | update_ebc_master_ios().
  1335. +----------------------------------------------------------------------------*/
  1336. void update_ebc_master_ios(void)
  1337. {
  1338. gpio_tab[GPIO0][27].in_out = GPIO_IN; /* EXT_EBC_REQ */
  1339. gpio_tab[GPIO0][27].alt_nb = GPIO_ALT1;
  1340. gpio_tab[GPIO0][29].in_out = GPIO_OUT; /* EBC_EXT_HDLA */
  1341. gpio_tab[GPIO0][29].alt_nb = GPIO_ALT1;
  1342. gpio_tab[GPIO0][30].in_out = GPIO_OUT; /* EBC_EXT_ACK */
  1343. gpio_tab[GPIO0][30].alt_nb = GPIO_ALT1;
  1344. gpio_tab[GPIO0][31].in_out = GPIO_OUT; /* EBC_EXR_BUSREQ */
  1345. gpio_tab[GPIO0][31].alt_nb = GPIO_ALT1;
  1346. }
  1347. /*----------------------------------------------------------------------------+
  1348. | update_usb2_device_ios().
  1349. +----------------------------------------------------------------------------*/
  1350. void update_usb2_device_ios(void)
  1351. {
  1352. gpio_tab[GPIO0][26].in_out = GPIO_IN; /* USB2D_RXVALID */
  1353. gpio_tab[GPIO0][26].alt_nb = GPIO_ALT2;
  1354. gpio_tab[GPIO0][27].in_out = GPIO_IN; /* USB2D_RXERROR */
  1355. gpio_tab[GPIO0][27].alt_nb = GPIO_ALT2;
  1356. gpio_tab[GPIO0][28].in_out = GPIO_OUT; /* USB2D_TXVALID */
  1357. gpio_tab[GPIO0][28].alt_nb = GPIO_ALT2;
  1358. gpio_tab[GPIO0][29].in_out = GPIO_OUT; /* USB2D_PAD_SUSPNDM */
  1359. gpio_tab[GPIO0][29].alt_nb = GPIO_ALT2;
  1360. gpio_tab[GPIO0][30].in_out = GPIO_OUT; /* USB2D_XCVRSELECT */
  1361. gpio_tab[GPIO0][30].alt_nb = GPIO_ALT2;
  1362. gpio_tab[GPIO0][31].in_out = GPIO_OUT; /* USB2D_TERMSELECT */
  1363. gpio_tab[GPIO0][31].alt_nb = GPIO_ALT2;
  1364. gpio_tab[GPIO1][0].in_out = GPIO_OUT; /* USB2D_OPMODE0 */
  1365. gpio_tab[GPIO1][0].alt_nb = GPIO_ALT1;
  1366. gpio_tab[GPIO1][1].in_out = GPIO_OUT; /* USB2D_OPMODE1 */
  1367. gpio_tab[GPIO1][1].alt_nb = GPIO_ALT1;
  1368. }
  1369. /*----------------------------------------------------------------------------+
  1370. | update_pci_patch_ios().
  1371. +----------------------------------------------------------------------------*/
  1372. void update_pci_patch_ios(void)
  1373. {
  1374. gpio_tab[GPIO0][29].in_out = GPIO_OUT; /* EBC_EXT_HDLA */
  1375. gpio_tab[GPIO0][29].alt_nb = GPIO_ALT1;
  1376. }
  1377. /*----------------------------------------------------------------------------+
  1378. | set_chip_gpio_configuration(unsigned char gpio_core)
  1379. | Put the core impacted by clock modification and sharing in reset.
  1380. | Config the select registers to resolve the sharing depending of the config.
  1381. | Configure the GPIO registers.
  1382. |
  1383. +----------------------------------------------------------------------------*/
  1384. void set_chip_gpio_configuration(unsigned char gpio_core)
  1385. {
  1386. unsigned char i=0, j=0, reg_offset = 0;
  1387. unsigned long gpio_reg, gpio_core_add;
  1388. /* GPIO config of the GPIOs 0 to 31 */
  1389. for (i=0; i<GPIO_MAX; i++, j++)
  1390. {
  1391. if (i == GPIO_MAX/2)
  1392. {
  1393. reg_offset = 4;
  1394. j = i-16;
  1395. }
  1396. gpio_core_add = gpio_tab[gpio_core][i].add;
  1397. if ( (gpio_tab[gpio_core][i].in_out == GPIO_IN) ||
  1398. (gpio_tab[gpio_core][i].in_out == GPIO_BI ))
  1399. {
  1400. switch (gpio_tab[gpio_core][i].alt_nb)
  1401. {
  1402. case GPIO_SEL:
  1403. break;
  1404. case GPIO_ALT1:
  1405. gpio_reg = in32(GPIO_IS1(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
  1406. gpio_reg = gpio_reg | (GPIO_IN_SEL >> (j*2));
  1407. out32(GPIO_IS1(gpio_core_add+reg_offset), gpio_reg);
  1408. break;
  1409. case GPIO_ALT2:
  1410. gpio_reg = in32(GPIO_IS2(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
  1411. gpio_reg = gpio_reg | (GPIO_IN_SEL >> (j*2));
  1412. out32(GPIO_IS2(gpio_core_add+reg_offset), gpio_reg);
  1413. break;
  1414. case GPIO_ALT3:
  1415. gpio_reg = in32(GPIO_IS3(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
  1416. gpio_reg = gpio_reg | (GPIO_IN_SEL >> (j*2));
  1417. out32(GPIO_IS3(gpio_core_add+reg_offset), gpio_reg);
  1418. break;
  1419. }
  1420. }
  1421. if ( (gpio_tab[gpio_core][i].in_out == GPIO_OUT) ||
  1422. (gpio_tab[gpio_core][i].in_out == GPIO_BI ))
  1423. {
  1424. switch (gpio_tab[gpio_core][i].alt_nb)
  1425. {
  1426. case GPIO_SEL:
  1427. break;
  1428. case GPIO_ALT1:
  1429. gpio_reg = in32(GPIO_OS(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
  1430. gpio_reg = gpio_reg | (GPIO_ALT1_SEL >> (j*2));
  1431. out32(GPIO_OS(gpio_core_add+reg_offset), gpio_reg);
  1432. gpio_reg = in32(GPIO_TS(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
  1433. gpio_reg = gpio_reg | (GPIO_ALT1_SEL >> (j*2));
  1434. out32(GPIO_TS(gpio_core_add+reg_offset), gpio_reg);
  1435. break;
  1436. case GPIO_ALT2:
  1437. gpio_reg = in32(GPIO_OS(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
  1438. gpio_reg = gpio_reg | (GPIO_ALT2_SEL >> (j*2));
  1439. out32(GPIO_OS(gpio_core_add+reg_offset), gpio_reg);
  1440. gpio_reg = in32(GPIO_TS(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
  1441. gpio_reg = gpio_reg | (GPIO_ALT2_SEL >> (j*2));
  1442. out32(GPIO_TS(gpio_core_add+reg_offset), gpio_reg);
  1443. break;
  1444. case GPIO_ALT3:
  1445. gpio_reg = in32(GPIO_OS(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
  1446. gpio_reg = gpio_reg | (GPIO_ALT3_SEL >> (j*2));
  1447. out32(GPIO_OS(gpio_core_add+reg_offset), gpio_reg);
  1448. gpio_reg = in32(GPIO_TS(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
  1449. gpio_reg = gpio_reg | (GPIO_ALT3_SEL >> (j*2));
  1450. out32(GPIO_TS(gpio_core_add+reg_offset), gpio_reg);
  1451. break;
  1452. }
  1453. }
  1454. }
  1455. }
  1456. /*----------------------------------------------------------------------------+
  1457. | force_bup_core_selection.
  1458. +----------------------------------------------------------------------------*/
  1459. void force_bup_core_selection(core_selection_t *core_select_P, config_validity_t *config_val_P)
  1460. {
  1461. /* Pointer invalid */
  1462. if (core_select_P == NULL)
  1463. {
  1464. printf("Configuration invalid pointer 1\n");
  1465. for (;;)
  1466. ;
  1467. }
  1468. /* L4 Selection */
  1469. *(core_select_P+UART_CORE0) = CORE_SELECTED;
  1470. *(core_select_P+UART_CORE1) = CORE_SELECTED;
  1471. *(core_select_P+UART_CORE2) = CORE_SELECTED;
  1472. *(core_select_P+UART_CORE3) = CORE_SELECTED;
  1473. /* RMII Selection */
  1474. *(core_select_P+RMII_SEL) = CORE_SELECTED;
  1475. /* External Interrupt 0-9 selection */
  1476. *(core_select_P+UIC_0_3) = CORE_SELECTED;
  1477. *(core_select_P+UIC_4_9) = CORE_SELECTED;
  1478. *(core_select_P+SCP_CORE) = CORE_SELECTED;
  1479. *(core_select_P+DMA_CHANNEL_CD) = CORE_SELECTED;
  1480. *(core_select_P+PACKET_REJ_FUNC_AVAIL) = CORE_SELECTED;
  1481. *(core_select_P+USB1_DEVICE) = CORE_SELECTED;
  1482. if (is_nand_selected()) {
  1483. *(core_select_P+NAND_FLASH) = CORE_SELECTED;
  1484. }
  1485. *config_val_P = CONFIG_IS_VALID;
  1486. }
  1487. /*----------------------------------------------------------------------------+
  1488. | configure_ppc440ep_pins.
  1489. +----------------------------------------------------------------------------*/
  1490. void configure_ppc440ep_pins(void)
  1491. {
  1492. uart_config_nb_t uart_configuration;
  1493. config_validity_t config_val = CONFIG_IS_INVALID;
  1494. /* Create Core Selection Table */
  1495. core_selection_t ppc440ep_core_selection[MAX_CORE_SELECT_NB] =
  1496. {
  1497. CORE_NOT_SELECTED, /* IIC_CORE, */
  1498. CORE_NOT_SELECTED, /* SPC_CORE, */
  1499. CORE_NOT_SELECTED, /* DMA_CHANNEL_AB, */
  1500. CORE_NOT_SELECTED, /* UIC_4_9, */
  1501. CORE_NOT_SELECTED, /* USB2_HOST, */
  1502. CORE_NOT_SELECTED, /* DMA_CHANNEL_CD, */
  1503. CORE_NOT_SELECTED, /* USB2_DEVICE, */
  1504. CORE_NOT_SELECTED, /* PACKET_REJ_FUNC_AVAIL, */
  1505. CORE_NOT_SELECTED, /* USB1_DEVICE, */
  1506. CORE_NOT_SELECTED, /* EBC_MASTER, */
  1507. CORE_NOT_SELECTED, /* NAND_FLASH, */
  1508. CORE_NOT_SELECTED, /* UART_CORE0, */
  1509. CORE_NOT_SELECTED, /* UART_CORE1, */
  1510. CORE_NOT_SELECTED, /* UART_CORE2, */
  1511. CORE_NOT_SELECTED, /* UART_CORE3, */
  1512. CORE_NOT_SELECTED, /* MII_SEL, */
  1513. CORE_NOT_SELECTED, /* RMII_SEL, */
  1514. CORE_NOT_SELECTED, /* SMII_SEL, */
  1515. CORE_NOT_SELECTED, /* PACKET_REJ_FUNC_EN */
  1516. CORE_NOT_SELECTED, /* UIC_0_3 */
  1517. CORE_NOT_SELECTED, /* USB1_HOST */
  1518. CORE_NOT_SELECTED /* PCI_PATCH */
  1519. };
  1520. /* Table Default Initialisation + FPGA Access */
  1521. init_default_gpio();
  1522. set_chip_gpio_configuration(GPIO0);
  1523. set_chip_gpio_configuration(GPIO1);
  1524. /* Update Table */
  1525. force_bup_core_selection(ppc440ep_core_selection, &config_val);
  1526. #if 0 /* test-only */
  1527. /* If we are running PIBS 1, force known configuration */
  1528. update_core_selection_table(ppc440ep_core_selection, &config_val);
  1529. #endif
  1530. /*----------------------------------------------------------------------------+
  1531. | SDR + ios table update + fpga initialization
  1532. +----------------------------------------------------------------------------*/
  1533. unsigned long sdr0_pfc1 = 0;
  1534. unsigned long sdr0_usb0 = 0;
  1535. unsigned long sdr0_mfr = 0;
  1536. /* PCI Always selected */
  1537. /* I2C Selection */
  1538. if (ppc440ep_core_selection[IIC_CORE] == CORE_SELECTED)
  1539. {
  1540. sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_SIS_MASK) | SDR0_PFC1_SIS_IIC1_SEL;
  1541. iic1_selection_in_fpga();
  1542. }
  1543. /* SCP Selection */
  1544. if (ppc440ep_core_selection[SCP_CORE] == CORE_SELECTED)
  1545. {
  1546. sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_SIS_MASK) | SDR0_PFC1_SIS_SCP_SEL;
  1547. scp_selection_in_fpga();
  1548. }
  1549. /* UIC 0:3 Selection */
  1550. if (ppc440ep_core_selection[UIC_0_3] == CORE_SELECTED)
  1551. {
  1552. update_uic_0_3_irq_ios();
  1553. dma_a_b_unselect_in_fpga();
  1554. }
  1555. /* UIC 4:9 Selection */
  1556. if (ppc440ep_core_selection[UIC_4_9] == CORE_SELECTED)
  1557. {
  1558. sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_DIS_MASK) | SDR0_PFC1_DIS_UICIRQ5_SEL;
  1559. update_uic_4_9_irq_ios();
  1560. }
  1561. /* DMA AB Selection */
  1562. if (ppc440ep_core_selection[DMA_CHANNEL_AB] == CORE_SELECTED)
  1563. {
  1564. sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_DIS_MASK) | SDR0_PFC1_DIS_DMAR_SEL;
  1565. update_dma_a_b_ios();
  1566. dma_a_b_selection_in_fpga();
  1567. }
  1568. /* DMA CD Selection */
  1569. if (ppc440ep_core_selection[DMA_CHANNEL_CD] == CORE_SELECTED)
  1570. {
  1571. update_dma_c_d_ios();
  1572. dma_c_d_selection_in_fpga();
  1573. }
  1574. /* EBC Master Selection */
  1575. if (ppc440ep_core_selection[EBC_MASTER] == CORE_SELECTED)
  1576. {
  1577. sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_ERE_MASK) | SDR0_PFC1_ERE_EXTR_SEL;
  1578. sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_UES_MASK) | SDR0_PFC1_UES_EBCHR_SEL;
  1579. update_ebc_master_ios();
  1580. }
  1581. /* PCI Patch Enable */
  1582. if (ppc440ep_core_selection[PCI_PATCH] == CORE_SELECTED)
  1583. {
  1584. sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_UES_MASK) | SDR0_PFC1_UES_EBCHR_SEL;
  1585. update_pci_patch_ios();
  1586. }
  1587. /* USB2 Host Selection - Not Implemented in PowerPC 440EP Pass1 */
  1588. if (ppc440ep_core_selection[USB2_HOST] == CORE_SELECTED)
  1589. {
  1590. /* Not Implemented in PowerPC 440EP Pass1-Pass2 */
  1591. printf("Invalid configuration => USB2 Host selected\n");
  1592. for (;;)
  1593. ;
  1594. /*usb2_host_selection_in_fpga(); */
  1595. }
  1596. /* USB2.0 Device Selection */
  1597. if (ppc440ep_core_selection[USB2_DEVICE] == CORE_SELECTED)
  1598. {
  1599. update_usb2_device_ios();
  1600. sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_UES_MASK) | SDR0_PFC1_UES_USB2D_SEL;
  1601. sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_UPR_MASK) | SDR0_PFC1_UPR_DISABLE;
  1602. mfsdr(sdr_usb0, sdr0_usb0);
  1603. sdr0_usb0 = sdr0_usb0 &~SDR0_USB0_USB_DEVSEL_MASK;
  1604. sdr0_usb0 = sdr0_usb0 | SDR0_USB0_USB20D_DEVSEL;
  1605. mtsdr(sdr_usb0, sdr0_usb0);
  1606. usb2_device_selection_in_fpga();
  1607. }
  1608. /* USB1.1 Device Selection */
  1609. if (ppc440ep_core_selection[USB1_DEVICE] == CORE_SELECTED)
  1610. {
  1611. mfsdr(sdr_usb0, sdr0_usb0);
  1612. sdr0_usb0 = sdr0_usb0 &~SDR0_USB0_USB_DEVSEL_MASK;
  1613. sdr0_usb0 = sdr0_usb0 | SDR0_USB0_USB11D_DEVSEL;
  1614. mtsdr(sdr_usb0, sdr0_usb0);
  1615. }
  1616. /* USB1.1 Host Selection */
  1617. if (ppc440ep_core_selection[USB1_HOST] == CORE_SELECTED)
  1618. {
  1619. mfsdr(sdr_usb0, sdr0_usb0);
  1620. sdr0_usb0 = sdr0_usb0 &~SDR0_USB0_LEEN_MASK;
  1621. sdr0_usb0 = sdr0_usb0 | SDR0_USB0_LEEN_ENABLE;
  1622. mtsdr(sdr_usb0, sdr0_usb0);
  1623. }
  1624. /* NAND Flash Selection */
  1625. if (ppc440ep_core_selection[NAND_FLASH] == CORE_SELECTED)
  1626. {
  1627. update_ndfc_ios();
  1628. mtsdr(sdr_cust0, SDR0_CUST0_MUX_NDFC_SEL |
  1629. SDR0_CUST0_NDFC_ENABLE |
  1630. SDR0_CUST0_NDFC_BW_8_BIT |
  1631. SDR0_CUST0_NDFC_ARE_MASK |
  1632. SDR0_CUST0_CHIPSELGAT_EN1 |
  1633. SDR0_CUST0_CHIPSELGAT_EN2);
  1634. ndfc_selection_in_fpga();
  1635. }
  1636. else
  1637. {
  1638. /* Set Mux on EMAC */
  1639. mtsdr(sdr_cust0, SDR0_CUST0_MUX_EMAC_SEL);
  1640. }
  1641. /* MII Selection */
  1642. if (ppc440ep_core_selection[MII_SEL] == CORE_SELECTED)
  1643. {
  1644. update_zii_ios();
  1645. mfsdr(sdr_mfr, sdr0_mfr);
  1646. sdr0_mfr = (sdr0_mfr & ~SDR0_MFR_ZMII_MODE_MASK) | SDR0_MFR_ZMII_MODE_MII;
  1647. mtsdr(sdr_mfr, sdr0_mfr);
  1648. set_phy_configuration_through_fpga(ZMII_CONFIGURATION_IS_MII);
  1649. }
  1650. /* RMII Selection */
  1651. if (ppc440ep_core_selection[RMII_SEL] == CORE_SELECTED)
  1652. {
  1653. update_zii_ios();
  1654. mfsdr(sdr_mfr, sdr0_mfr);
  1655. sdr0_mfr = (sdr0_mfr & ~SDR0_MFR_ZMII_MODE_MASK) | SDR0_MFR_ZMII_MODE_RMII_10M;
  1656. mtsdr(sdr_mfr, sdr0_mfr);
  1657. set_phy_configuration_through_fpga(ZMII_CONFIGURATION_IS_RMII);
  1658. }
  1659. /* SMII Selection */
  1660. if (ppc440ep_core_selection[SMII_SEL] == CORE_SELECTED)
  1661. {
  1662. update_zii_ios();
  1663. mfsdr(sdr_mfr, sdr0_mfr);
  1664. sdr0_mfr = (sdr0_mfr & ~SDR0_MFR_ZMII_MODE_MASK) | SDR0_MFR_ZMII_MODE_SMII;
  1665. mtsdr(sdr_mfr, sdr0_mfr);
  1666. set_phy_configuration_through_fpga(ZMII_CONFIGURATION_IS_SMII);
  1667. }
  1668. /* UART Selection */
  1669. uart_configuration = get_uart_configuration();
  1670. switch (uart_configuration)
  1671. {
  1672. case L1: /* L1 Selection */
  1673. /* UART0 8 pins Only */
  1674. /*sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0ME_MASK) | SDR0_PFC1_U0ME_DSR_DTR; */
  1675. sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0ME_MASK) |SDR0_PFC1_U0ME_CTS_RTS; /* Chip Pb */
  1676. sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0IM_MASK) | SDR0_PFC1_U0IM_8PINS;
  1677. break;
  1678. case L2: /* L2 Selection */
  1679. /* UART0 and UART1 4 pins */
  1680. sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0ME_MASK) | SDR0_PFC1_U1ME_DSR_DTR;
  1681. sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0IM_MASK) | SDR0_PFC1_U0IM_4PINS;
  1682. sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U1ME_MASK) | SDR0_PFC1_U1ME_DSR_DTR;
  1683. break;
  1684. case L3: /* L3 Selection */
  1685. /* UART0 4 pins, UART1 and UART2 2 pins */
  1686. sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0ME_MASK) | SDR0_PFC1_U1ME_DSR_DTR;
  1687. sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0IM_MASK) | SDR0_PFC1_U0IM_4PINS;
  1688. sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U1ME_MASK) | SDR0_PFC1_U1ME_DSR_DTR;
  1689. break;
  1690. case L4: /* L4 Selection */
  1691. /* UART0, UART1, UART2 and UART3 2 pins */
  1692. sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0ME_MASK) | SDR0_PFC1_U0ME_DSR_DTR;
  1693. sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0IM_MASK) | SDR0_PFC1_U0IM_4PINS;
  1694. sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U1ME_MASK) | SDR0_PFC1_U1ME_DSR_DTR;
  1695. break;
  1696. }
  1697. update_uart_ios(uart_configuration);
  1698. /* UART Selection in all cases */
  1699. uart_selection_in_fpga(uart_configuration);
  1700. /* Packet Reject Function Available */
  1701. if (ppc440ep_core_selection[PACKET_REJ_FUNC_AVAIL] == CORE_SELECTED)
  1702. {
  1703. /* Set UPR Bit in SDR0_PFC1 Register */
  1704. sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_UPR_MASK) | SDR0_PFC1_UPR_ENABLE;
  1705. }
  1706. /* Packet Reject Function Enable */
  1707. if (ppc440ep_core_selection[PACKET_REJ_FUNC_EN] == CORE_SELECTED)
  1708. {
  1709. mfsdr(sdr_mfr, sdr0_mfr);
  1710. sdr0_mfr = (sdr0_mfr & ~SDR0_MFR_PKT_REJ_MASK) | SDR0_MFR_PKT_REJ_EN;;
  1711. mtsdr(sdr_mfr, sdr0_mfr);
  1712. }
  1713. /* Perform effective access to hardware */
  1714. mtsdr(sdr_pfc1, sdr0_pfc1);
  1715. set_chip_gpio_configuration(GPIO0);
  1716. set_chip_gpio_configuration(GPIO1);
  1717. /* USB2.0 Device Reset must be done after GPIO setting */
  1718. if (ppc440ep_core_selection[USB2_DEVICE] == CORE_SELECTED)
  1719. usb2_device_reset_through_fpga();
  1720. }