bamboo.c 70 KB

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