bamboo.c 71 KB

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