yucca.c 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223
  1. /*
  2. * (C) Copyright 2006
  3. * Wolfgang Denk, DENX Software Engineering, wd@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. * Port to AMCC-440SPE Evaluation Board SOP - April 2005
  24. *
  25. * PCIe supporting routines derived from Linux 440SPe PCIe driver.
  26. */
  27. #include <common.h>
  28. #include <ppc4xx.h>
  29. #include <asm/processor.h>
  30. #include <i2c.h>
  31. #include <asm-ppc/io.h>
  32. #include "yucca.h"
  33. void fpga_init (void);
  34. void get_sys_info(PPC440_SYS_INFO *board_cfg );
  35. int compare_to_true(char *str );
  36. char *remove_l_w_space(char *in_str );
  37. char *remove_t_w_space(char *in_str );
  38. int get_console_port(void);
  39. unsigned long ppcMfcpr(unsigned long cpr_reg);
  40. unsigned long ppcMfsdr(unsigned long sdr_reg);
  41. int ppc440spe_init_pcie_rootport(int port);
  42. void ppc440spe_setup_pcie(struct pci_controller *hose, int port);
  43. #define DEBUG_ENV
  44. #ifdef DEBUG_ENV
  45. #define DEBUGF(fmt,args...) printf(fmt ,##args)
  46. #else
  47. #define DEBUGF(fmt,args...)
  48. #endif
  49. #define FALSE 0
  50. #define TRUE 1
  51. int board_early_init_f (void)
  52. {
  53. /*----------------------------------------------------------------------------+
  54. | Define Boot devices
  55. +----------------------------------------------------------------------------*/
  56. #define BOOT_FROM_SMALL_FLASH 0x00
  57. #define BOOT_FROM_LARGE_FLASH_OR_SRAM 0x01
  58. #define BOOT_FROM_PCI 0x02
  59. #define BOOT_DEVICE_UNKNOWN 0x03
  60. /*----------------------------------------------------------------------------+
  61. | EBC Devices Characteristics
  62. | Peripheral Bank Access Parameters - EBC_BxAP
  63. | Peripheral Bank Configuration Register - EBC_BxCR
  64. +----------------------------------------------------------------------------*/
  65. /*
  66. * Small Flash and FRAM
  67. * BU Value
  68. * BxAP : 0x03800000 - 0 00000111 0 00 00 00 00 00 000 0 0 0 0 00000
  69. * B0CR : 0xff098000 - BAS = ff0 - 100 11 00 0000000000000
  70. * B2CR : 0xe7098000 - BAS = e70 - 100 11 00 0000000000000
  71. */
  72. #define EBC_BXAP_SMALL_FLASH EBC_BXAP_BME_DISABLED | \
  73. EBC_BXAP_TWT_ENCODE(7) | \
  74. EBC_BXAP_BCE_DISABLE | \
  75. EBC_BXAP_BCT_2TRANS | \
  76. EBC_BXAP_CSN_ENCODE(0) | \
  77. EBC_BXAP_OEN_ENCODE(0) | \
  78. EBC_BXAP_WBN_ENCODE(0) | \
  79. EBC_BXAP_WBF_ENCODE(0) | \
  80. EBC_BXAP_TH_ENCODE(0) | \
  81. EBC_BXAP_RE_DISABLED | \
  82. EBC_BXAP_SOR_DELAYED | \
  83. EBC_BXAP_BEM_WRITEONLY | \
  84. EBC_BXAP_PEN_DISABLED
  85. #define EBC_BXCR_SMALL_FLASH_CS0 EBC_BXCR_BAS_ENCODE(0xFF000000) | \
  86. EBC_BXCR_BS_16MB | \
  87. EBC_BXCR_BU_RW | \
  88. EBC_BXCR_BW_8BIT
  89. #define EBC_BXCR_SMALL_FLASH_CS2 EBC_BXCR_BAS_ENCODE(0xe7000000) | \
  90. EBC_BXCR_BS_16MB | \
  91. EBC_BXCR_BU_RW | \
  92. EBC_BXCR_BW_8BIT
  93. /*
  94. * Large Flash and SRAM
  95. * BU Value
  96. * BxAP : 0x048ff240 - 0 00000111 0 00 00 00 00 00 000 0 0 0 0 00000
  97. * B0CR : 0xff09a000 - BAS = ff0 - 100 11 01 0000000000000
  98. * B2CR : 0xe709a000 - BAS = e70 - 100 11 01 0000000000000
  99. */
  100. #define EBC_BXAP_LARGE_FLASH EBC_BXAP_BME_DISABLED | \
  101. EBC_BXAP_TWT_ENCODE(7) | \
  102. EBC_BXAP_BCE_DISABLE | \
  103. EBC_BXAP_BCT_2TRANS | \
  104. EBC_BXAP_CSN_ENCODE(0) | \
  105. EBC_BXAP_OEN_ENCODE(0) | \
  106. EBC_BXAP_WBN_ENCODE(0) | \
  107. EBC_BXAP_WBF_ENCODE(0) | \
  108. EBC_BXAP_TH_ENCODE(0) | \
  109. EBC_BXAP_RE_DISABLED | \
  110. EBC_BXAP_SOR_DELAYED | \
  111. EBC_BXAP_BEM_WRITEONLY | \
  112. EBC_BXAP_PEN_DISABLED
  113. #define EBC_BXCR_LARGE_FLASH_CS0 EBC_BXCR_BAS_ENCODE(0xFF000000) | \
  114. EBC_BXCR_BS_16MB | \
  115. EBC_BXCR_BU_RW | \
  116. EBC_BXCR_BW_16BIT
  117. #define EBC_BXCR_LARGE_FLASH_CS2 EBC_BXCR_BAS_ENCODE(0xE7000000) | \
  118. EBC_BXCR_BS_16MB | \
  119. EBC_BXCR_BU_RW | \
  120. EBC_BXCR_BW_16BIT
  121. /*
  122. * FPGA
  123. * BU value :
  124. * B1AP = 0x05895240 - 0 00001011 0 00 10 01 01 01 001 0 0 1 0 00000
  125. * B1CR = 0xe201a000 - BAS = e20 - 000 11 01 00000000000000
  126. */
  127. #define EBC_BXAP_FPGA EBC_BXAP_BME_DISABLED | \
  128. EBC_BXAP_TWT_ENCODE(11) | \
  129. EBC_BXAP_BCE_DISABLE | \
  130. EBC_BXAP_BCT_2TRANS | \
  131. EBC_BXAP_CSN_ENCODE(10) | \
  132. EBC_BXAP_OEN_ENCODE(1) | \
  133. EBC_BXAP_WBN_ENCODE(1) | \
  134. EBC_BXAP_WBF_ENCODE(1) | \
  135. EBC_BXAP_TH_ENCODE(1) | \
  136. EBC_BXAP_RE_DISABLED | \
  137. EBC_BXAP_SOR_DELAYED | \
  138. EBC_BXAP_BEM_RW | \
  139. EBC_BXAP_PEN_DISABLED
  140. #define EBC_BXCR_FPGA_CS1 EBC_BXCR_BAS_ENCODE(0xe2000000) | \
  141. EBC_BXCR_BS_1MB | \
  142. EBC_BXCR_BU_RW | \
  143. EBC_BXCR_BW_16BIT
  144. unsigned long mfr;
  145. /*
  146. * Define Variables for EBC initialization depending on BOOTSTRAP option
  147. */
  148. unsigned long sdr0_pinstp, sdr0_sdstp1 ;
  149. unsigned long bootstrap_settings, ebc_data_width, boot_selection;
  150. int computed_boot_device = BOOT_DEVICE_UNKNOWN;
  151. /*-------------------------------------------------------------------+
  152. | Initialize EBC CONFIG -
  153. | Keep the Default value, but the bit PDT which has to be set to 1 ?TBC
  154. | default value :
  155. | 0x07C00000 - 0 0 000 1 1 1 1 1 0000 0 00000 000000000000
  156. |
  157. +-------------------------------------------------------------------*/
  158. mtebc(xbcfg, EBC_CFG_LE_UNLOCK |
  159. EBC_CFG_PTD_ENABLE |
  160. EBC_CFG_RTC_16PERCLK |
  161. EBC_CFG_ATC_PREVIOUS |
  162. EBC_CFG_DTC_PREVIOUS |
  163. EBC_CFG_CTC_PREVIOUS |
  164. EBC_CFG_OEO_PREVIOUS |
  165. EBC_CFG_EMC_DEFAULT |
  166. EBC_CFG_PME_DISABLE |
  167. EBC_CFG_PR_16);
  168. /*-------------------------------------------------------------------+
  169. |
  170. | PART 1 : Initialize EBC Bank 1
  171. | ==============================
  172. | Bank1 is always associated to the EPLD.
  173. | It has to be initialized prior to other banks settings computation
  174. | since some board registers values may be needed to determine the
  175. | boot type
  176. |
  177. +-------------------------------------------------------------------*/
  178. mtebc(pb1ap, EBC_BXAP_FPGA);
  179. mtebc(pb1cr, EBC_BXCR_FPGA_CS1);
  180. /*-------------------------------------------------------------------+
  181. |
  182. | PART 2 : Determine which boot device was selected
  183. | =================================================
  184. |
  185. | Read Pin Strap Register in PPC440SPe
  186. | Result can either be :
  187. | - Boot strap = boot from EBC 8bits => Small Flash
  188. | - Boot strap = boot from PCI
  189. | - Boot strap = IIC
  190. | In case of boot from IIC, read Serial Device Strap Register1
  191. |
  192. | Result can either be :
  193. | - Boot from EBC - EBC Bus Width = 8bits => Small Flash
  194. | - Boot from EBC - EBC Bus Width = 16bits => Large Flash or SRAM
  195. | - Boot from PCI
  196. |
  197. +-------------------------------------------------------------------*/
  198. /* Read Pin Strap Register in PPC440SP */
  199. sdr0_pinstp = ppcMfsdr(SDR0_PINSTP);
  200. bootstrap_settings = sdr0_pinstp & SDR0_PINSTP_BOOTSTRAP_MASK;
  201. switch (bootstrap_settings) {
  202. case SDR0_PINSTP_BOOTSTRAP_SETTINGS0:
  203. /*
  204. * Strapping Option A
  205. * Boot from EBC - 8 bits , Small Flash
  206. */
  207. computed_boot_device = BOOT_FROM_SMALL_FLASH;
  208. break;
  209. case SDR0_PINSTP_BOOTSTRAP_SETTINGS1:
  210. /*
  211. * Strappping Option B
  212. * Boot from PCI
  213. */
  214. computed_boot_device = BOOT_FROM_PCI;
  215. break;
  216. case SDR0_PINSTP_BOOTSTRAP_IIC_50_EN:
  217. case SDR0_PINSTP_BOOTSTRAP_IIC_54_EN:
  218. /*
  219. * Strapping Option C or D
  220. * Boot Settings in IIC EEprom address 0x50 or 0x54
  221. * Read Serial Device Strap Register1 in PPC440SPe
  222. */
  223. sdr0_sdstp1 = ppcMfsdr(SDR0_SDSTP1);
  224. boot_selection = sdr0_sdstp1 & SDR0_SDSTP1_ERPN_MASK;
  225. ebc_data_width = sdr0_sdstp1 & SDR0_SDSTP1_EBCW_MASK;
  226. switch (boot_selection) {
  227. case SDR0_SDSTP1_ERPN_EBC:
  228. switch (ebc_data_width) {
  229. case SDR0_SDSTP1_EBCW_16_BITS:
  230. computed_boot_device =
  231. BOOT_FROM_LARGE_FLASH_OR_SRAM;
  232. break;
  233. case SDR0_SDSTP1_EBCW_8_BITS :
  234. computed_boot_device = BOOT_FROM_SMALL_FLASH;
  235. break;
  236. }
  237. break;
  238. case SDR0_SDSTP1_ERPN_PCI:
  239. computed_boot_device = BOOT_FROM_PCI;
  240. break;
  241. default:
  242. /* should not occure */
  243. computed_boot_device = BOOT_DEVICE_UNKNOWN;
  244. }
  245. break;
  246. default:
  247. /* should not be */
  248. computed_boot_device = BOOT_DEVICE_UNKNOWN;
  249. break;
  250. }
  251. /*-------------------------------------------------------------------+
  252. |
  253. | PART 3 : Compute EBC settings depending on selected boot device
  254. | ====== ======================================================
  255. |
  256. | Resulting EBC init will be among following configurations :
  257. |
  258. | - Boot from EBC 8bits => boot from Small Flash selected
  259. | EBC-CS0 = Small Flash
  260. | EBC-CS2 = Large Flash and SRAM
  261. |
  262. | - Boot from EBC 16bits => boot from Large Flash or SRAM
  263. | EBC-CS0 = Large Flash or SRAM
  264. | EBC-CS2 = Small Flash
  265. |
  266. | - Boot from PCI
  267. | EBC-CS0 = not initialized to avoid address contention
  268. | EBC-CS2 = same as boot from Small Flash selected
  269. |
  270. +-------------------------------------------------------------------*/
  271. unsigned long ebc0_cs0_bxap_value = 0, ebc0_cs0_bxcr_value = 0;
  272. unsigned long ebc0_cs2_bxap_value = 0, ebc0_cs2_bxcr_value = 0;
  273. switch (computed_boot_device) {
  274. /*-------------------------------------------------------------------*/
  275. case BOOT_FROM_PCI:
  276. /*-------------------------------------------------------------------*/
  277. /*
  278. * By Default CS2 is affected to LARGE Flash
  279. * do not initialize SMALL FLASH to avoid address contention
  280. * Large Flash
  281. */
  282. ebc0_cs2_bxap_value = EBC_BXAP_LARGE_FLASH;
  283. ebc0_cs2_bxcr_value = EBC_BXCR_LARGE_FLASH_CS2;
  284. break;
  285. /*-------------------------------------------------------------------*/
  286. case BOOT_FROM_SMALL_FLASH:
  287. /*-------------------------------------------------------------------*/
  288. ebc0_cs0_bxap_value = EBC_BXAP_SMALL_FLASH;
  289. ebc0_cs0_bxcr_value = EBC_BXCR_SMALL_FLASH_CS0;
  290. /*
  291. * Large Flash or SRAM
  292. */
  293. /* ebc0_cs2_bxap_value = EBC_BXAP_LARGE_FLASH; */
  294. ebc0_cs2_bxap_value = 0x048ff240;
  295. ebc0_cs2_bxcr_value = EBC_BXCR_LARGE_FLASH_CS2;
  296. break;
  297. /*-------------------------------------------------------------------*/
  298. case BOOT_FROM_LARGE_FLASH_OR_SRAM:
  299. /*-------------------------------------------------------------------*/
  300. ebc0_cs0_bxap_value = EBC_BXAP_LARGE_FLASH;
  301. ebc0_cs0_bxcr_value = EBC_BXCR_LARGE_FLASH_CS0;
  302. /* Small flash */
  303. ebc0_cs2_bxap_value = EBC_BXAP_SMALL_FLASH;
  304. ebc0_cs2_bxcr_value = EBC_BXCR_SMALL_FLASH_CS2;
  305. break;
  306. /*-------------------------------------------------------------------*/
  307. default:
  308. /*-------------------------------------------------------------------*/
  309. /* BOOT_DEVICE_UNKNOWN */
  310. break;
  311. }
  312. mtebc(pb0ap, ebc0_cs0_bxap_value);
  313. mtebc(pb0cr, ebc0_cs0_bxcr_value);
  314. mtebc(pb2ap, ebc0_cs2_bxap_value);
  315. mtebc(pb2cr, ebc0_cs2_bxcr_value);
  316. /*--------------------------------------------------------------------+
  317. | Interrupt controller setup for the AMCC 440SPe Evaluation board.
  318. +--------------------------------------------------------------------+
  319. +---------------------------------------------------------------------+
  320. |Interrupt| Source | Pol. | Sensi.| Crit. |
  321. +---------+-----------------------------------+-------+-------+-------+
  322. | IRQ 00 | UART0 | High | Level | Non |
  323. | IRQ 01 | UART1 | High | Level | Non |
  324. | IRQ 02 | IIC0 | High | Level | Non |
  325. | IRQ 03 | IIC1 | High | Level | Non |
  326. | IRQ 04 | PCI0X0 MSG IN | High | Level | Non |
  327. | IRQ 05 | PCI0X0 CMD Write | High | Level | Non |
  328. | IRQ 06 | PCI0X0 Power Mgt | High | Level | Non |
  329. | IRQ 07 | PCI0X0 VPD Access | Rising| Edge | Non |
  330. | IRQ 08 | PCI0X0 MSI level 0 | High | Lvl/ed| Non |
  331. | IRQ 09 | External IRQ 15 - (PCI-Express) | pgm H | Pgm | Non |
  332. | IRQ 10 | UIC2 Non-critical Int. | NA | NA | Non |
  333. | IRQ 11 | UIC2 Critical Interrupt | NA | NA | Crit |
  334. | IRQ 12 | PCI Express MSI Level 0 | Rising| Edge | Non |
  335. | IRQ 13 | PCI Express MSI Level 1 | Rising| Edge | Non |
  336. | IRQ 14 | PCI Express MSI Level 2 | Rising| Edge | Non |
  337. | IRQ 15 | PCI Express MSI Level 3 | Rising| Edge | Non |
  338. | IRQ 16 | UIC3 Non-critical Int. | NA | NA | Non |
  339. | IRQ 17 | UIC3 Critical Interrupt | NA | NA | Crit |
  340. | IRQ 18 | External IRQ 14 - (PCI-Express) | Pgm | Pgm | Non |
  341. | IRQ 19 | DMA Channel 0 FIFO Full | High | Level | Non |
  342. | IRQ 20 | DMA Channel 0 Stat FIFO | High | Level | Non |
  343. | IRQ 21 | DMA Channel 1 FIFO Full | High | Level | Non |
  344. | IRQ 22 | DMA Channel 1 Stat FIFO | High | Level | Non |
  345. | IRQ 23 | I2O Inbound Doorbell | High | Level | Non |
  346. | IRQ 24 | Inbound Post List FIFO Not Empt | High | Level | Non |
  347. | IRQ 25 | I2O Region 0 LL PLB Write | High | Level | Non |
  348. | IRQ 26 | I2O Region 1 LL PLB Write | High | Level | Non |
  349. | IRQ 27 | I2O Region 0 HB PLB Write | High | Level | Non |
  350. | IRQ 28 | I2O Region 1 HB PLB Write | High | Level | Non |
  351. | IRQ 29 | GPT Down Count Timer | Rising| Edge | Non |
  352. | IRQ 30 | UIC1 Non-critical Int. | NA | NA | Non |
  353. | IRQ 31 | UIC1 Critical Interrupt | NA | NA | Crit. |
  354. |----------------------------------------------------------------------
  355. | IRQ 32 | Ext. IRQ 13 - (PCI-Express) |pgm (H)|pgm/Lvl| Non |
  356. | IRQ 33 | MAL Serr | High | Level | Non |
  357. | IRQ 34 | MAL Txde | High | Level | Non |
  358. | IRQ 35 | MAL Rxde | High | Level | Non |
  359. | IRQ 36 | DMC CE or DMC UE | High | Level | Non |
  360. | IRQ 37 | EBC or UART2 | High |Lvl Edg| Non |
  361. | IRQ 38 | MAL TX EOB | High | Level | Non |
  362. | IRQ 39 | MAL RX EOB | High | Level | Non |
  363. | IRQ 40 | PCIX0 MSI Level 1 | High |Lvl Edg| Non |
  364. | IRQ 41 | PCIX0 MSI level 2 | High |Lvl Edg| Non |
  365. | IRQ 42 | PCIX0 MSI level 3 | High |Lvl Edg| Non |
  366. | IRQ 43 | L2 Cache | Risin | Edge | Non |
  367. | IRQ 44 | GPT Compare Timer 0 | Risin | Edge | Non |
  368. | IRQ 45 | GPT Compare Timer 1 | Risin | Edge | Non |
  369. | IRQ 46 | GPT Compare Timer 2 | Risin | Edge | Non |
  370. | IRQ 47 | GPT Compare Timer 3 | Risin | Edge | Non |
  371. | IRQ 48 | GPT Compare Timer 4 | Risin | Edge | Non |
  372. | IRQ 49 | Ext. IRQ 12 - PCI-X |pgm/Fal|pgm/Lvl| Non |
  373. | IRQ 50 | Ext. IRQ 11 - |pgm (H)|pgm/Lvl| Non |
  374. | IRQ 51 | Ext. IRQ 10 - |pgm (H)|pgm/Lvl| Non |
  375. | IRQ 52 | Ext. IRQ 9 |pgm (H)|pgm/Lvl| Non |
  376. | IRQ 53 | Ext. IRQ 8 |pgm (H)|pgm/Lvl| Non |
  377. | IRQ 54 | DMA Error | High | Level | Non |
  378. | IRQ 55 | DMA I2O Error | High | Level | Non |
  379. | IRQ 56 | Serial ROM | High | Level | Non |
  380. | IRQ 57 | PCIX0 Error | High | Edge | Non |
  381. | IRQ 58 | Ext. IRQ 7- |pgm (H)|pgm/Lvl| Non |
  382. | IRQ 59 | Ext. IRQ 6- |pgm (H)|pgm/Lvl| Non |
  383. | IRQ 60 | EMAC0 Interrupt | High | Level | Non |
  384. | IRQ 61 | EMAC0 Wake-up | High | Level | Non |
  385. | IRQ 62 | Reserved | High | Level | Non |
  386. | IRQ 63 | XOR | High | Level | Non |
  387. |----------------------------------------------------------------------
  388. | IRQ 64 | PE0 AL | High | Level | Non |
  389. | IRQ 65 | PE0 VPD Access | Risin | Edge | Non |
  390. | IRQ 66 | PE0 Hot Reset Request | Risin | Edge | Non |
  391. | IRQ 67 | PE0 Hot Reset Request | Falli | Edge | Non |
  392. | IRQ 68 | PE0 TCR | High | Level | Non |
  393. | IRQ 69 | PE0 BusMaster VCO | Falli | Edge | Non |
  394. | IRQ 70 | PE0 DCR Error | High | Level | Non |
  395. | IRQ 71 | Reserved | N/A | N/A | Non |
  396. | IRQ 72 | PE1 AL | High | Level | Non |
  397. | IRQ 73 | PE1 VPD Access | Risin | Edge | Non |
  398. | IRQ 74 | PE1 Hot Reset Request | Risin | Edge | Non |
  399. | IRQ 75 | PE1 Hot Reset Request | Falli | Edge | Non |
  400. | IRQ 76 | PE1 TCR | High | Level | Non |
  401. | IRQ 77 | PE1 BusMaster VCO | Falli | Edge | Non |
  402. | IRQ 78 | PE1 DCR Error | High | Level | Non |
  403. | IRQ 79 | Reserved | N/A | N/A | Non |
  404. | IRQ 80 | PE2 AL | High | Level | Non |
  405. | IRQ 81 | PE2 VPD Access | Risin | Edge | Non |
  406. | IRQ 82 | PE2 Hot Reset Request | Risin | Edge | Non |
  407. | IRQ 83 | PE2 Hot Reset Request | Falli | Edge | Non |
  408. | IRQ 84 | PE2 TCR | High | Level | Non |
  409. | IRQ 85 | PE2 BusMaster VCO | Falli | Edge | Non |
  410. | IRQ 86 | PE2 DCR Error | High | Level | Non |
  411. | IRQ 87 | Reserved | N/A | N/A | Non |
  412. | IRQ 88 | External IRQ(5) | Progr | Progr | Non |
  413. | IRQ 89 | External IRQ 4 - Ethernet | Progr | Progr | Non |
  414. | IRQ 90 | External IRQ 3 - PCI-X | Progr | Progr | Non |
  415. | IRQ 91 | External IRQ 2 - PCI-X | Progr | Progr | Non |
  416. | IRQ 92 | External IRQ 1 - PCI-X | Progr | Progr | Non |
  417. | IRQ 93 | External IRQ 0 - PCI-X | Progr | Progr | Non |
  418. | IRQ 94 | Reserved | N/A | N/A | Non |
  419. | IRQ 95 | Reserved | N/A | N/A | Non |
  420. |---------------------------------------------------------------------
  421. | IRQ 96 | PE0 INTA | High | Level | Non |
  422. | IRQ 97 | PE0 INTB | High | Level | Non |
  423. | IRQ 98 | PE0 INTC | High | Level | Non |
  424. | IRQ 99 | PE0 INTD | High | Level | Non |
  425. | IRQ 100 | PE1 INTA | High | Level | Non |
  426. | IRQ 101 | PE1 INTB | High | Level | Non |
  427. | IRQ 102 | PE1 INTC | High | Level | Non |
  428. | IRQ 103 | PE1 INTD | High | Level | Non |
  429. | IRQ 104 | PE2 INTA | High | Level | Non |
  430. | IRQ 105 | PE2 INTB | High | Level | Non |
  431. | IRQ 106 | PE2 INTC | High | Level | Non |
  432. | IRQ 107 | PE2 INTD | Risin | Edge | Non |
  433. | IRQ 108 | PCI Express MSI Level 4 | Risin | Edge | Non |
  434. | IRQ 109 | PCI Express MSI Level 5 | Risin | Edge | Non |
  435. | IRQ 110 | PCI Express MSI Level 6 | Risin | Edge | Non |
  436. | IRQ 111 | PCI Express MSI Level 7 | Risin | Edge | Non |
  437. | IRQ 116 | PCI Express MSI Level 12 | Risin | Edge | Non |
  438. | IRQ 112 | PCI Express MSI Level 8 | Risin | Edge | Non |
  439. | IRQ 113 | PCI Express MSI Level 9 | Risin | Edge | Non |
  440. | IRQ 114 | PCI Express MSI Level 10 | Risin | Edge | Non |
  441. | IRQ 115 | PCI Express MSI Level 11 | Risin | Edge | Non |
  442. | IRQ 117 | PCI Express MSI Level 13 | Risin | Edge | Non |
  443. | IRQ 118 | PCI Express MSI Level 14 | Risin | Edge | Non |
  444. | IRQ 119 | PCI Express MSI Level 15 | Risin | Edge | Non |
  445. | IRQ 120 | PCI Express MSI Level 16 | Risin | Edge | Non |
  446. | IRQ 121 | PCI Express MSI Level 17 | Risin | Edge | Non |
  447. | IRQ 122 | PCI Express MSI Level 18 | Risin | Edge | Non |
  448. | IRQ 123 | PCI Express MSI Level 19 | Risin | Edge | Non |
  449. | IRQ 124 | PCI Express MSI Level 20 | Risin | Edge | Non |
  450. | IRQ 125 | PCI Express MSI Level 21 | Risin | Edge | Non |
  451. | IRQ 126 | PCI Express MSI Level 22 | Risin | Edge | Non |
  452. | IRQ 127 | PCI Express MSI Level 23 | Risin | Edge | Non |
  453. +---------+-----------------------------------+-------+-------+------*/
  454. /*--------------------------------------------------------------------+
  455. | Put UICs in PowerPC440SPemode.
  456. | Initialise UIC registers. Clear all interrupts. Disable all
  457. | interrupts.
  458. | Set critical interrupt values. Set interrupt polarities. Set
  459. | interrupt trigger levels. Make bit 0 High priority. Clear all
  460. | interrupts again.
  461. +-------------------------------------------------------------------*/
  462. mtdcr (uic3sr, 0xffffffff); /* Clear all interrupts */
  463. mtdcr (uic3er, 0x00000000); /* disable all interrupts */
  464. mtdcr (uic3cr, 0x00000000); /* Set Critical / Non Critical
  465. * interrupts */
  466. mtdcr (uic3pr, 0xffffffff); /* Set Interrupt Polarities */
  467. mtdcr (uic3tr, 0x001fffff); /* Set Interrupt Trigger Levels */
  468. mtdcr (uic3vr, 0x00000001); /* Set Vect base=0,INT31 Highest
  469. * priority */
  470. mtdcr (uic3sr, 0x00000000); /* clear all interrupts */
  471. mtdcr (uic3sr, 0xffffffff); /* clear all interrupts */
  472. mtdcr (uic2sr, 0xffffffff); /* Clear all interrupts */
  473. mtdcr (uic2er, 0x00000000); /* disable all interrupts */
  474. mtdcr (uic2cr, 0x00000000); /* Set Critical / Non Critical
  475. * interrupts */
  476. mtdcr (uic2pr, 0xebebebff); /* Set Interrupt Polarities */
  477. mtdcr (uic2tr, 0x74747400); /* Set Interrupt Trigger Levels */
  478. mtdcr (uic2vr, 0x00000001); /* Set Vect base=0,INT31 Highest
  479. * priority */
  480. mtdcr (uic2sr, 0x00000000); /* clear all interrupts */
  481. mtdcr (uic2sr, 0xffffffff); /* clear all interrupts */
  482. mtdcr (uic1sr, 0xffffffff); /* Clear all interrupts */
  483. mtdcr (uic1er, 0x00000000); /* disable all interrupts */
  484. mtdcr (uic1cr, 0x00000000); /* Set Critical / Non Critical
  485. * interrupts */
  486. mtdcr (uic1pr, 0xffffffff); /* Set Interrupt Polarities */
  487. mtdcr (uic1tr, 0x001f8040); /* Set Interrupt Trigger Levels */
  488. mtdcr (uic1vr, 0x00000001); /* Set Vect base=0,INT31 Highest
  489. * priority */
  490. mtdcr (uic1sr, 0x00000000); /* clear all interrupts */
  491. mtdcr (uic1sr, 0xffffffff); /* clear all interrupts */
  492. mtdcr (uic0sr, 0xffffffff); /* Clear all interrupts */
  493. mtdcr (uic0er, 0x00000000); /* disable all interrupts excepted
  494. * cascade to be checked */
  495. mtdcr (uic0cr, 0x00104001); /* Set Critical / Non Critical
  496. * interrupts */
  497. mtdcr (uic0pr, 0xffffffff); /* Set Interrupt Polarities */
  498. mtdcr (uic0tr, 0x010f0004); /* Set Interrupt Trigger Levels */
  499. mtdcr (uic0vr, 0x00000001); /* Set Vect base=0,INT31 Highest
  500. * priority */
  501. mtdcr (uic0sr, 0x00000000); /* clear all interrupts */
  502. mtdcr (uic0sr, 0xffffffff); /* clear all interrupts */
  503. /* SDR0_MFR should be part of Ethernet init */
  504. mfsdr (sdr_mfr, mfr);
  505. mfr &= ~SDR0_MFR_ECS_MASK;
  506. /*mtsdr(sdr_mfr, mfr);*/
  507. fpga_init();
  508. return 0;
  509. }
  510. int checkboard (void)
  511. {
  512. char *s = getenv("serial#");
  513. printf("Board: Yucca - AMCC 440SPe Evaluation Board");
  514. if (s != NULL) {
  515. puts(", serial# ");
  516. puts(s);
  517. }
  518. putc('\n');
  519. return 0;
  520. }
  521. static long int yucca_probe_for_dimms(void)
  522. {
  523. long int dimm_installed[MAXDIMMS];
  524. long int dimm_num, probe_result;
  525. long int dimms_found = 0;
  526. uchar dimm_addr = IIC0_DIMM0_ADDR;
  527. for (dimm_num = 0; dimm_num < MAXDIMMS; dimm_num++) {
  528. /* check if there is a chip at the dimm address */
  529. switch (dimm_num) {
  530. case 0:
  531. dimm_addr = IIC0_DIMM0_ADDR;
  532. break;
  533. case 1:
  534. dimm_addr = IIC0_DIMM1_ADDR;
  535. break;
  536. }
  537. probe_result = i2c_probe(dimm_addr);
  538. if (probe_result == 0) {
  539. dimm_installed[dimm_num] = TRUE;
  540. dimms_found++;
  541. debug("DIMM slot %d: DDR2 SDRAM detected\n",dimm_num);
  542. } else {
  543. dimm_installed[dimm_num] = FALSE;
  544. debug("DIMM slot %d: Not populated or cannot sucessfully probe the DIMM\n", dimm_num);
  545. }
  546. }
  547. if (dimms_found == 0) {
  548. printf("ERROR - No memory installed. Install a DDR-SDRAM DIMM.\n\n");
  549. hang();
  550. }
  551. if (dimm_installed[0] != TRUE) {
  552. printf("\nERROR - DIMM slot 0 must be populated before DIMM slot 1.\n");
  553. printf(" Unsupported configuration. Move DIMM module from DIMM slot 1 to slot 0.\n\n");
  554. hang();
  555. }
  556. return dimms_found;
  557. }
  558. /*************************************************************************
  559. * init SDRAM controller with fixed value
  560. * the initialization values are for 2x MICRON DDR2
  561. * PN: MT18HTF6472DY-53EB2
  562. * 512MB, DDR2, 533, CL4, ECC, REG
  563. ************************************************************************/
  564. static long int fixed_sdram(void)
  565. {
  566. long int yucca_dimms = 0;
  567. yucca_dimms = yucca_probe_for_dimms();
  568. /* SDRAM0_MCOPT2 (0X21) Clear DCEN BIT */
  569. mtdcr( 0x10, 0x00000021 );
  570. mtdcr( 0x11, 0x84000000 );
  571. /* SDRAM0_MCOPT1 (0X20) ECC OFF / 64 bits / 4 banks / DDR2 */
  572. mtdcr( 0x10, 0x00000020 );
  573. mtdcr( 0x11, 0x2D122000 );
  574. /* SET MCIF0_CODT Die Termination On */
  575. mtdcr( 0x10, 0x00000026 );
  576. if (yucca_dimms == 2)
  577. mtdcr( 0x11, 0x2A800021 );
  578. else if (yucca_dimms == 1)
  579. mtdcr( 0x11, 0x02800021 );
  580. /* On-Die Termination for Bank 0 */
  581. mtdcr( 0x10, 0x00000022 );
  582. if (yucca_dimms == 2)
  583. mtdcr( 0x11, 0x18000000 );
  584. else if (yucca_dimms == 1)
  585. mtdcr( 0x11, 0x06000000 );
  586. /* On-Die Termination for Bank 1 */
  587. mtdcr( 0x10, 0x00000023 );
  588. if (yucca_dimms == 2)
  589. mtdcr( 0x11, 0x18000000 );
  590. else if (yucca_dimms == 1)
  591. mtdcr( 0x11, 0x01800000 );
  592. /* On-Die Termination for Bank 2 */
  593. mtdcr( 0x10, 0x00000024 );
  594. if (yucca_dimms == 2)
  595. mtdcr( 0x11, 0x01800000 );
  596. else if (yucca_dimms == 1)
  597. mtdcr( 0x11, 0x00000000 );
  598. /* On-Die Termination for Bank 3 */
  599. mtdcr( 0x10, 0x00000025 );
  600. if (yucca_dimms == 2)
  601. mtdcr( 0x11, 0x01800000 );
  602. else if (yucca_dimms == 1)
  603. mtdcr( 0x11, 0x00000000 );
  604. /* Refresh Time register (0x30) Refresh every 7.8125uS */
  605. mtdcr( 0x10, 0x00000030 );
  606. mtdcr( 0x11, 0x08200000 );
  607. /* SET MCIF0_MMODE CL 4 */
  608. mtdcr( 0x10, 0x00000088 );
  609. mtdcr( 0x11, 0x00000642 );
  610. /* MCIF0_MEMODE */
  611. mtdcr( 0x10, 0x00000089 );
  612. mtdcr( 0x11, 0x00000004 );
  613. /*SET MCIF0_MB0CF */
  614. mtdcr( 0x10, 0x00000040 );
  615. mtdcr( 0x11, 0x00000201 );
  616. /* SET MCIF0_MB1CF */
  617. mtdcr( 0x10, 0x00000044 );
  618. mtdcr( 0x11, 0x00000201 );
  619. /* SET MCIF0_MB2CF */
  620. mtdcr( 0x10, 0x00000048 );
  621. if (yucca_dimms == 2)
  622. mtdcr( 0x11, 0x00000201 );
  623. else if (yucca_dimms == 1)
  624. mtdcr( 0x11, 0x00000000 );
  625. /* SET MCIF0_MB3CF */
  626. mtdcr( 0x10, 0x0000004c );
  627. if (yucca_dimms == 2)
  628. mtdcr( 0x11, 0x00000201 );
  629. else if (yucca_dimms == 1)
  630. mtdcr( 0x11, 0x00000000 );
  631. /* SET MCIF0_INITPLR0 # NOP */
  632. mtdcr( 0x10, 0x00000050 );
  633. mtdcr( 0x11, 0xB5380000 );
  634. /* SET MCIF0_INITPLR1 # PRE */
  635. mtdcr( 0x10, 0x00000051 );
  636. mtdcr( 0x11, 0x82100400 );
  637. /* SET MCIF0_INITPLR2 # EMR2 */
  638. mtdcr( 0x10, 0x00000052 );
  639. mtdcr( 0x11, 0x80820000 );
  640. /* SET MCIF0_INITPLR3 # EMR3 */
  641. mtdcr( 0x10, 0x00000053 );
  642. mtdcr( 0x11, 0x80830000 );
  643. /* SET MCIF0_INITPLR4 # EMR DLL ENABLE */
  644. mtdcr( 0x10, 0x00000054 );
  645. mtdcr( 0x11, 0x80810000 );
  646. /* SET MCIF0_INITPLR5 # MR DLL RESET */
  647. mtdcr( 0x10, 0x00000055 );
  648. mtdcr( 0x11, 0x80800542 );
  649. /* SET MCIF0_INITPLR6 # PRE */
  650. mtdcr( 0x10, 0x00000056 );
  651. mtdcr( 0x11, 0x82100400 );
  652. /* SET MCIF0_INITPLR7 # Refresh */
  653. mtdcr( 0x10, 0x00000057 );
  654. mtdcr( 0x11, 0x8A080000 );
  655. /* SET MCIF0_INITPLR8 # Refresh */
  656. mtdcr( 0x10, 0x00000058 );
  657. mtdcr( 0x11, 0x8A080000 );
  658. /* SET MCIF0_INITPLR9 # Refresh */
  659. mtdcr( 0x10, 0x00000059 );
  660. mtdcr( 0x11, 0x8A080000 );
  661. /* SET MCIF0_INITPLR10 # Refresh */
  662. mtdcr( 0x10, 0x0000005A );
  663. mtdcr( 0x11, 0x8A080000 );
  664. /* SET MCIF0_INITPLR11 # MR */
  665. mtdcr( 0x10, 0x0000005B );
  666. mtdcr( 0x11, 0x80800442 );
  667. /* SET MCIF0_INITPLR12 # EMR OCD Default*/
  668. mtdcr( 0x10, 0x0000005C );
  669. mtdcr( 0x11, 0x80810380 );
  670. /* SET MCIF0_INITPLR13 # EMR OCD Exit */
  671. mtdcr( 0x10, 0x0000005D );
  672. mtdcr( 0x11, 0x80810000 );
  673. /* 0x80: Adv Addr clock by 180 deg */
  674. mtdcr( 0x10, 0x00000080 );
  675. mtdcr( 0x11, 0x80000000 );
  676. /* 0x21: Exit self refresh, set DC_EN */
  677. mtdcr( 0x10, 0x00000021 );
  678. mtdcr( 0x11, 0x28000000 );
  679. /* 0x81: Write DQS Adv 90 + Fractional DQS Delay */
  680. mtdcr( 0x10, 0x00000081 );
  681. mtdcr( 0x11, 0x80000800 );
  682. /* MCIF0_SDTR1 */
  683. mtdcr( 0x10, 0x00000085 );
  684. mtdcr( 0x11, 0x80201000 );
  685. /* MCIF0_SDTR2 */
  686. mtdcr( 0x10, 0x00000086 );
  687. mtdcr( 0x11, 0x42103242 );
  688. /* MCIF0_SDTR3 */
  689. mtdcr( 0x10, 0x00000087 );
  690. mtdcr( 0x11, 0x0C100D14 );
  691. /* SET MQ0_B0BAS base addr 00000000 / 256MB */
  692. mtdcr( 0x40, 0x0000F800 );
  693. /* SET MQ0_B1BAS base addr 10000000 / 256MB */
  694. mtdcr( 0x41, 0x0400F800 );
  695. /* SET MQ0_B2BAS base addr 20000000 / 256MB */
  696. if (yucca_dimms == 2)
  697. mtdcr( 0x42, 0x0800F800 );
  698. else if (yucca_dimms == 1)
  699. mtdcr( 0x42, 0x00000000 );
  700. /* SET MQ0_B3BAS base addr 30000000 / 256MB */
  701. if (yucca_dimms == 2)
  702. mtdcr( 0x43, 0x0C00F800 );
  703. else if (yucca_dimms == 1)
  704. mtdcr( 0x43, 0x00000000 );
  705. /* SDRAM_RQDC */
  706. mtdcr( 0x10, 0x00000070 );
  707. mtdcr( 0x11, 0x8000003F );
  708. /* SDRAM_RDCC */
  709. mtdcr( 0x10, 0x00000078 );
  710. mtdcr( 0x11, 0x80000000 );
  711. /* SDRAM_RFDC */
  712. mtdcr( 0x10, 0x00000074 );
  713. mtdcr( 0x11, 0x00000220 );
  714. return (yucca_dimms * 512) << 20;
  715. }
  716. long int initdram (int board_type)
  717. {
  718. long dram_size = 0;
  719. dram_size = fixed_sdram();
  720. return dram_size;
  721. }
  722. #if defined(CFG_DRAM_TEST)
  723. int testdram (void)
  724. {
  725. uint *pstart = (uint *) 0x00000000;
  726. uint *pend = (uint *) 0x08000000;
  727. uint *p;
  728. for (p = pstart; p < pend; p++)
  729. *p = 0xaaaaaaaa;
  730. for (p = pstart; p < pend; p++) {
  731. if (*p != 0xaaaaaaaa) {
  732. printf ("SDRAM test fails at: %08x\n", (uint) p);
  733. return 1;
  734. }
  735. }
  736. for (p = pstart; p < pend; p++)
  737. *p = 0x55555555;
  738. for (p = pstart; p < pend; p++) {
  739. if (*p != 0x55555555) {
  740. printf ("SDRAM test fails at: %08x\n", (uint) p);
  741. return 1;
  742. }
  743. }
  744. return 0;
  745. }
  746. #endif
  747. /*************************************************************************
  748. * pci_pre_init
  749. *
  750. * This routine is called just prior to registering the hose and gives
  751. * the board the opportunity to check things. Returning a value of zero
  752. * indicates that things are bad & PCI initialization should be aborted.
  753. *
  754. * Different boards may wish to customize the pci controller structure
  755. * (add regions, override default access routines, etc) or perform
  756. * certain pre-initialization actions.
  757. *
  758. ************************************************************************/
  759. #if defined(CONFIG_PCI) && defined(CFG_PCI_PRE_INIT)
  760. int pci_pre_init(struct pci_controller * hose )
  761. {
  762. unsigned long strap;
  763. /*-------------------------------------------------------------------+
  764. * The yucca board is always configured as the host & requires the
  765. * PCI arbiter to be enabled.
  766. *-------------------------------------------------------------------*/
  767. mfsdr(sdr_sdstp1, strap);
  768. if( (strap & SDR0_SDSTP1_PAE_MASK) == 0 ) {
  769. printf("PCI: SDR0_STRP1[%08lX] - PCI Arbiter disabled.\n",strap);
  770. return 0;
  771. }
  772. return 1;
  773. }
  774. #endif /* defined(CONFIG_PCI) && defined(CFG_PCI_PRE_INIT) */
  775. /*************************************************************************
  776. * pci_target_init
  777. *
  778. * The bootstrap configuration provides default settings for the pci
  779. * inbound map (PIM). But the bootstrap config choices are limited and
  780. * may not be sufficient for a given board.
  781. *
  782. ************************************************************************/
  783. #if defined(CONFIG_PCI) && defined(CFG_PCI_TARGET_INIT)
  784. void pci_target_init(struct pci_controller * hose )
  785. {
  786. DECLARE_GLOBAL_DATA_PTR;
  787. /*-------------------------------------------------------------------+
  788. * Disable everything
  789. *-------------------------------------------------------------------*/
  790. out32r( PCIX0_PIM0SA, 0 ); /* disable */
  791. out32r( PCIX0_PIM1SA, 0 ); /* disable */
  792. out32r( PCIX0_PIM2SA, 0 ); /* disable */
  793. out32r( PCIX0_EROMBA, 0 ); /* disable expansion rom */
  794. /*-------------------------------------------------------------------+
  795. * Map all of SDRAM to PCI address 0x0000_0000. Note that the 440
  796. * strapping options to not support sizes such as 128/256 MB.
  797. *-------------------------------------------------------------------*/
  798. out32r( PCIX0_PIM0LAL, CFG_SDRAM_BASE );
  799. out32r( PCIX0_PIM0LAH, 0 );
  800. out32r( PCIX0_PIM0SA, ~(gd->ram_size - 1) | 1 );
  801. out32r( PCIX0_BAR0, 0 );
  802. /*-------------------------------------------------------------------+
  803. * Program the board's subsystem id/vendor id
  804. *-------------------------------------------------------------------*/
  805. out16r( PCIX0_SBSYSVID, CFG_PCI_SUBSYS_VENDORID );
  806. out16r( PCIX0_SBSYSID, CFG_PCI_SUBSYS_DEVICEID );
  807. out16r( PCIX0_CMD, in16r(PCIX0_CMD) | PCI_COMMAND_MEMORY );
  808. }
  809. #endif /* defined(CONFIG_PCI) && defined(CFG_PCI_TARGET_INIT) */
  810. #if defined(CONFIG_PCI)
  811. /*************************************************************************
  812. * is_pci_host
  813. *
  814. * This routine is called to determine if a pci scan should be
  815. * performed. With various hardware environments (especially cPCI and
  816. * PPMC) it's insufficient to depend on the state of the arbiter enable
  817. * bit in the strap register, or generic host/adapter assumptions.
  818. *
  819. * Rather than hard-code a bad assumption in the general 440 code, the
  820. * 440 pci code requires the board to decide at runtime.
  821. *
  822. * Return 0 for adapter mode, non-zero for host (monarch) mode.
  823. *
  824. *
  825. ************************************************************************/
  826. int is_pci_host(struct pci_controller *hose)
  827. {
  828. /* The yucca board is always configured as host. */
  829. return 1;
  830. }
  831. int yucca_pcie_card_present(int port)
  832. {
  833. u16 reg;
  834. reg = in_be16((u16 *)FPGA_REG1C);
  835. switch(port) {
  836. case 0:
  837. return !(reg & FPGA_REG1C_PE0_PRSNT);
  838. case 1:
  839. return !(reg & FPGA_REG1C_PE1_PRSNT);
  840. case 2:
  841. return !(reg & FPGA_REG1C_PE2_PRSNT);
  842. default:
  843. return 0;
  844. }
  845. }
  846. /*
  847. * For the given slot, set rootpoint mode, send power to the slot,
  848. * turn on the green LED and turn off the yellow LED, enable the clock
  849. * and turn off reset.
  850. */
  851. void yucca_setup_pcie_fpga_rootpoint(int port)
  852. {
  853. u16 power, clock, green_led, yellow_led, reset_off, rootpoint, endpoint;
  854. switch(port) {
  855. case 0:
  856. rootpoint = FPGA_REG1C_PE0_ROOTPOINT;
  857. endpoint = 0;
  858. power = FPGA_REG1A_PE0_PWRON;
  859. green_led = FPGA_REG1A_PE0_GLED;
  860. clock = FPGA_REG1A_PE0_REFCLK_ENABLE;
  861. yellow_led = FPGA_REG1A_PE0_YLED;
  862. reset_off = FPGA_REG1C_PE0_PERST;
  863. break;
  864. case 1:
  865. rootpoint = 0;
  866. endpoint = FPGA_REG1C_PE1_ENDPOINT;
  867. power = FPGA_REG1A_PE1_PWRON;
  868. green_led = FPGA_REG1A_PE1_GLED;
  869. clock = FPGA_REG1A_PE1_REFCLK_ENABLE;
  870. yellow_led = FPGA_REG1A_PE1_YLED;
  871. reset_off = FPGA_REG1C_PE1_PERST;
  872. break;
  873. case 2:
  874. rootpoint = 0;
  875. endpoint = FPGA_REG1C_PE2_ENDPOINT;
  876. power = FPGA_REG1A_PE2_PWRON;
  877. green_led = FPGA_REG1A_PE2_GLED;
  878. clock = FPGA_REG1A_PE2_REFCLK_ENABLE;
  879. yellow_led = FPGA_REG1A_PE2_YLED;
  880. reset_off = FPGA_REG1C_PE2_PERST;
  881. break;
  882. default:
  883. return;
  884. }
  885. out_be16((u16 *)FPGA_REG1A,
  886. ~(power | clock | green_led) &
  887. (yellow_led | in_be16((u16 *)FPGA_REG1A)));
  888. out_be16((u16 *)FPGA_REG1C,
  889. ~(endpoint | reset_off) &
  890. (rootpoint | in_be16((u16 *)FPGA_REG1C)));
  891. /*
  892. * Leave device in reset for a while after powering on the
  893. * slot to give it a chance to initialize.
  894. */
  895. udelay(250 * 1000);
  896. out_be16((u16 *)FPGA_REG1C, reset_off | in_be16((u16 *)FPGA_REG1C));
  897. }
  898. static struct pci_controller pcie_hose[3] = {{0},{0},{0}};
  899. void pcie_setup_hoses(void)
  900. {
  901. struct pci_controller *hose;
  902. int i, bus;
  903. /*
  904. * assume we're called after the PCIX hose is initialized, which takes
  905. * bus ID 0 and therefore start numbering PCIe's from 1.
  906. */
  907. bus = 1;
  908. for (i = 0; i <= 2; i++) {
  909. /* Check for yucca card presence */
  910. if (!yucca_pcie_card_present(i))
  911. continue;
  912. yucca_setup_pcie_fpga_rootpoint(i);
  913. if (ppc440spe_init_pcie_rootport(i)) {
  914. printf("PCIE%d: initialization failed\n", i);
  915. continue;
  916. }
  917. hose = &pcie_hose[i];
  918. hose->first_busno = bus;
  919. hose->last_busno = bus;
  920. bus++;
  921. /* setup mem resource */
  922. pci_set_region(hose->regions + 0,
  923. CFG_PCIE_MEMBASE + i * CFG_PCIE_MEMSIZE,
  924. CFG_PCIE_MEMBASE + i * CFG_PCIE_MEMSIZE,
  925. CFG_PCIE_MEMSIZE,
  926. PCI_REGION_MEM
  927. );
  928. hose->region_count = 1;
  929. pci_register_hose(hose);
  930. ppc440spe_setup_pcie(hose, i);
  931. hose->last_busno = pci_hose_scan(hose);
  932. }
  933. }
  934. #endif /* defined(CONFIG_PCI) */
  935. int misc_init_f (void)
  936. {
  937. uint reg;
  938. #if defined(CONFIG_STRESS)
  939. uint i ;
  940. uint disp;
  941. #endif
  942. out16(FPGA_REG10, (in16(FPGA_REG10) &
  943. ~(FPGA_REG10_AUTO_NEG_DIS|FPGA_REG10_RESET_ETH)) |
  944. FPGA_REG10_10MHZ_ENABLE |
  945. FPGA_REG10_100MHZ_ENABLE |
  946. FPGA_REG10_GIGABIT_ENABLE |
  947. FPGA_REG10_FULL_DUPLEX );
  948. udelay(10000); /* wait 10ms */
  949. out16(FPGA_REG10, (in16(FPGA_REG10) | FPGA_REG10_RESET_ETH));
  950. /* minimal init for PCIe */
  951. /* pci express 0 Endpoint Mode */
  952. mfsdr(SDR0_PE0DLPSET, reg);
  953. reg &= (~0x00400000);
  954. mtsdr(SDR0_PE0DLPSET, reg);
  955. /* pci express 1 Rootpoint Mode */
  956. mfsdr(SDR0_PE1DLPSET, reg);
  957. reg |= 0x00400000;
  958. mtsdr(SDR0_PE1DLPSET, reg);
  959. /* pci express 2 Rootpoint Mode */
  960. mfsdr(SDR0_PE2DLPSET, reg);
  961. reg |= 0x00400000;
  962. mtsdr(SDR0_PE2DLPSET, reg);
  963. out16(FPGA_REG1C,(in16 (FPGA_REG1C) &
  964. ~FPGA_REG1C_PE0_ROOTPOINT &
  965. ~FPGA_REG1C_PE1_ENDPOINT &
  966. ~FPGA_REG1C_PE2_ENDPOINT));
  967. #if defined(CONFIG_STRESS)
  968. /*
  969. * all this setting done by linux only needed by stress an charac. test
  970. * procedure
  971. * PCIe 1 Rootpoint PCIe2 Endpoint
  972. * PCIe 0 FIR Pre-emphasis Filter Coefficients & Transmit Driver
  973. * Power Level
  974. */
  975. for (i = 0, disp = 0; i < 8; i++, disp += 3) {
  976. mfsdr(SDR0_PE0HSSSET1L0 + disp, reg);
  977. reg |= 0x33000000;
  978. mtsdr(SDR0_PE0HSSSET1L0 + disp, reg);
  979. }
  980. /*
  981. * PCIe 1 FIR Pre-emphasis Filter Coefficients & Transmit Driver
  982. * Power Level
  983. */
  984. for (i = 0, disp = 0; i < 4; i++, disp += 3) {
  985. mfsdr(SDR0_PE1HSSSET1L0 + disp, reg);
  986. reg |= 0x33000000;
  987. mtsdr(SDR0_PE1HSSSET1L0 + disp, reg);
  988. }
  989. /*
  990. * PCIE 2 FIR Pre-emphasis Filter Coefficients & Transmit Driver
  991. * Power Level
  992. */
  993. for (i = 0, disp = 0; i < 4; i++, disp += 3) {
  994. mfsdr(SDR0_PE2HSSSET1L0 + disp, reg);
  995. reg |= 0x33000000;
  996. mtsdr(SDR0_PE2HSSSET1L0 + disp, reg);
  997. }
  998. reg = 0x21242222;
  999. mtsdr(SDR0_PE2UTLSET1, reg);
  1000. reg = 0x11000000;
  1001. mtsdr(SDR0_PE2UTLSET2, reg);
  1002. /* pci express 1 Endpoint Mode */
  1003. reg = 0x00004000;
  1004. mtsdr(SDR0_PE2DLPSET, reg);
  1005. mtsdr(SDR0_UART1, 0x2080005a); /* patch for TG */
  1006. #endif
  1007. return 0;
  1008. }
  1009. void fpga_init(void)
  1010. {
  1011. /*
  1012. * by default sdram access is disabled by fpga
  1013. */
  1014. out16(FPGA_REG10, (in16 (FPGA_REG10) |
  1015. FPGA_REG10_SDRAM_ENABLE |
  1016. FPGA_REG10_ENABLE_DISPLAY ));
  1017. return;
  1018. }
  1019. #ifdef CONFIG_POST
  1020. /*
  1021. * Returns 1 if keys pressed to start the power-on long-running tests
  1022. * Called from board_init_f().
  1023. */
  1024. int post_hotkeys_pressed(void)
  1025. {
  1026. return (ctrlc());
  1027. }
  1028. #endif
  1029. /*---------------------------------------------------------------------------+
  1030. | onboard_pci_arbiter_selected => from EPLD
  1031. +---------------------------------------------------------------------------*/
  1032. int onboard_pci_arbiter_selected(int core_pci)
  1033. {
  1034. #if 0
  1035. unsigned long onboard_pci_arbiter_sel;
  1036. onboard_pci_arbiter_sel = in16(FPGA_REG0) & FPGA_REG0_EXT_ARB_SEL_MASK;
  1037. if (onboard_pci_arbiter_sel == FPGA_REG0_EXT_ARB_SEL_EXTERNAL)
  1038. return (BOARD_OPTION_SELECTED);
  1039. else
  1040. #endif
  1041. return (BOARD_OPTION_NOT_SELECTED);
  1042. }
  1043. /*---------------------------------------------------------------------------+
  1044. | ppcMfcpr.
  1045. +---------------------------------------------------------------------------*/
  1046. unsigned long ppcMfcpr(unsigned long cpr_reg)
  1047. {
  1048. unsigned long msr;
  1049. unsigned long cpr_cfgaddr_temp;
  1050. unsigned long cpr_value;
  1051. msr = (mfmsr () & ~(MSR_EE));
  1052. cpr_cfgaddr_temp = mfdcr(CPR0_CFGADDR);
  1053. mtdcr(CPR0_CFGADDR, cpr_reg);
  1054. cpr_value = mfdcr(CPR0_CFGDATA);
  1055. mtdcr(CPR0_CFGADDR, cpr_cfgaddr_temp);
  1056. mtmsr(msr);
  1057. return (cpr_value);
  1058. }
  1059. /*----------------------------------------------------------------------------+
  1060. | Indirect Access of the System DCR's (SDR)
  1061. | ppcMfsdr
  1062. +----------------------------------------------------------------------------*/
  1063. unsigned long ppcMfsdr(unsigned long sdr_reg)
  1064. {
  1065. unsigned long msr;
  1066. unsigned long sdr_cfgaddr_temp;
  1067. unsigned long sdr_value;
  1068. msr = (mfmsr () & ~(MSR_EE));
  1069. sdr_cfgaddr_temp = mfdcr(SDR0_CFGADDR);
  1070. mtdcr(SDR0_CFGADDR, sdr_reg);
  1071. sdr_value = mfdcr(SDR0_CFGDATA);
  1072. mtdcr(SDR0_CFGADDR, sdr_cfgaddr_temp);
  1073. mtmsr(msr);
  1074. return (sdr_value);
  1075. }