bamboo.c 70 KB

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