bamboo.c 70 KB

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