bamboo.c 71 KB

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