sc3.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787
  1. /*
  2. * (C) Copyright 2007
  3. * Heiko Schocher, DENX Software Engineering, <hs@denx.de>.
  4. *
  5. * (C) Copyright 2003
  6. * Juergen Beisert, EuroDesign embedded technologies, info@eurodsn.de
  7. * Derived from walnut.c
  8. *
  9. * (C) Copyright 2000
  10. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  11. *
  12. * See file CREDITS for list of people who contributed to this
  13. * project.
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License as
  17. * published by the Free Software Foundation; either version 2 of
  18. * the License, or (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, write to the Free Software
  27. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  28. * MA 02111-1307 USA
  29. *
  30. * $Log:$
  31. */
  32. #include <common.h>
  33. #include <asm/processor.h>
  34. #include <asm/io.h>
  35. #include "sc3.h"
  36. #include <pci.h>
  37. #include <i2c.h>
  38. #include <malloc.h>
  39. #include <netdev.h>
  40. #undef writel
  41. #undef writeb
  42. #define writeb(b,addr) ((*(volatile u8 *) (addr)) = (b))
  43. #define writel(b,addr) ((*(volatile u32 *) (addr)) = (b))
  44. /* write only register to configure things in our CPLD */
  45. #define CPLD_CONTROL_1 0x79000102
  46. #define CPLD_VERSION 0x79000103
  47. #define IS_CAMERON ((*(unsigned char *)(CPLD_VERSION)== 0x32) ? 1 : 0)
  48. static struct pci_controller hose={0,};
  49. /************************************************************
  50. * Standard definition
  51. ************************************************************/
  52. /* CPC0_CR0 Function ISA bus
  53. - GPIO0
  54. - GPIO1 -> Output: NAND-Command Latch Enable
  55. - GPIO2 -> Output: NAND Address Latch Enable
  56. - GPIO3 -> IRQ input ISA-IRQ #5 (through CPLD)
  57. - GPIO4 -> Output: NAND-Chip Enable
  58. - GPIO5 -> IRQ input ISA-IRQ#7 (through CPLD)
  59. - GPIO6 -> IRQ input ISA-IRQ#9 (through CPLD)
  60. - GPIO7 -> IRQ input ISA-IRQ#10 (through CPLD)
  61. - GPIO8 -> IRQ input ISA-IRQ#11 (through CPLD)
  62. - GPIO9 -> IRQ input ISA-IRQ#12 (through CPLD)
  63. - GPIO10/CS1# -> CS1# NAND ISA-CS#0
  64. - GPIO11/CS2# -> CS2# ISA emulation ISA-CS#1
  65. - GPIO12/CS3# -> CS3# 2nd Flash-Bank ISA-CS#2 or ISA-CS#7
  66. - GPIO13/CS4# -> CS4# USB HC or ISA emulation ISA-CS#3
  67. - GPIO14/CS5# -> CS5# Boosted IDE access ISA-CS#4
  68. - GPIO15/CS6# -> CS6# ISA emulation ISA-CS#5
  69. - GPIO16/CS7# -> CS7# ISA emulation ISA-CS#6
  70. - GPIO17/IRQ0 -> GPIO, in, NAND-Ready/Busy# line ISA-IRQ#3
  71. - GPIO18/IRQ1 -> IRQ input ISA-IRQ#14
  72. - GPIO19/IRQ2 -> IRQ input or USB ISA-IRQ#4
  73. - GPIO20/IRQ3 -> IRQ input PCI-IRQ#D
  74. - GPIO21/IRQ4 -> IRQ input PCI-IRQ#C
  75. - GPIO22/IRQ5 -> IRQ input PCI-IRQ#B
  76. - GPIO23/IRQ6 -> IRQ input PCI-IRQ#A
  77. - GPIO24 -> if GPIO output: 0=JTAG CPLD activ, 1=JTAG CPLD inactiv
  78. */
  79. /*
  80. | CPLD register: io-space at offset 0x102 (write only)
  81. | 0
  82. | 1
  83. | 2 0=CS#4 USB CS#, 1=ISA or GP bus
  84. | 3
  85. | 4
  86. | 5
  87. | 6 1=enable faster IDE access
  88. | 7
  89. */
  90. #define USB_CHIP_ENABLE 0x04
  91. #define IDE_BOOSTING 0x40
  92. /* --------------- USB stuff ------------------------------------- */
  93. #ifdef CONFIG_ISP1161_PRESENT
  94. /**
  95. * initUsbHost- Initialize the Philips isp1161 HC part if present
  96. * @cpldConfig: Pointer to value in write only CPLD register
  97. *
  98. * Initialize the USB host controller if present and fills the
  99. * scratch register to inform the driver about used resources
  100. */
  101. static void initUsbHost (unsigned char *cpldConfig)
  102. {
  103. int i;
  104. unsigned long usbBase;
  105. /*
  106. * Read back where init.S has located the USB chip
  107. */
  108. mtdcr (0x012, 0x04);
  109. usbBase = mfdcr (0x013);
  110. if (!(usbBase & 0x18000)) /* enabled? */
  111. return;
  112. usbBase &= 0xFFF00000;
  113. /*
  114. * to test for the USB controller enable using of CS#4 and DMA 3 for USB access
  115. */
  116. writeb (*cpldConfig | USB_CHIP_ENABLE,CPLD_CONTROL_1);
  117. /*
  118. * first check: is the controller assembled?
  119. */
  120. hcWriteWord (usbBase, 0x5555, HcScratch);
  121. if (hcReadWord (usbBase, HcScratch) == 0x5555) {
  122. hcWriteWord (usbBase, 0xAAAA, HcScratch);
  123. if (hcReadWord (usbBase, HcScratch) == 0xAAAA) {
  124. if ((hcReadWord (usbBase, HcChipID) & 0xFF00) != 0x6100)
  125. return; /* this is not our controller */
  126. /*
  127. * try a software reset. This needs up to 10 seconds (see datasheet)
  128. */
  129. hcWriteDWord (usbBase, 0x00000001, HcCommandStatus);
  130. for (i = 1000; i > 0; i--) { /* loop up to 10 seconds */
  131. udelay (10);
  132. if (!(hcReadDWord (usbBase, HcCommandStatus) & 0x01))
  133. break;
  134. }
  135. if (!i)
  136. return; /* the controller doesn't responding. Broken? */
  137. /*
  138. * OK. USB controller is ready. Initialize it in such way the later driver
  139. * can us it (without any knowing about specific implementation)
  140. */
  141. hcWriteDWord (usbBase, 0x00000000, HcControl);
  142. /*
  143. * disable all interrupt sources. Because we
  144. * don't know where we come from (hard reset, cold start, soft reset...)
  145. */
  146. hcWriteDWord (usbBase, 0x8000007D, HcInterruptDisable);
  147. /*
  148. * our current setup hardware configuration
  149. * - every port power supply can switched indepently
  150. * - every port can signal overcurrent
  151. * - every port is "outside" and the devices are removeable
  152. */
  153. hcWriteDWord (usbBase, 0x32000902, HcRhDescriptorA);
  154. hcWriteDWord (usbBase, 0x00060000, HcRhDescriptorB);
  155. /*
  156. * don't forget to switch off power supply of each port
  157. * The later running driver can reenable them to find and use
  158. * the (maybe) connected devices.
  159. *
  160. */
  161. hcWriteDWord (usbBase, 0x00000200, HcRhPortStatus1);
  162. hcWriteDWord (usbBase, 0x00000200, HcRhPortStatus2);
  163. hcWriteWord (usbBase, 0x0428, HcHardwareConfiguration);
  164. hcWriteWord (usbBase, 0x0040, HcDMAConfiguration);
  165. hcWriteWord (usbBase, 0x0000, HcuPInterruptEnable);
  166. hcWriteWord (usbBase, 0xA000 | (0x03 << 8) | 27, HcScratch);
  167. /*
  168. * controller is present and usable
  169. */
  170. *cpldConfig |= USB_CHIP_ENABLE;
  171. }
  172. }
  173. }
  174. #endif
  175. #if defined(CONFIG_START_IDE)
  176. int board_start_ide(void)
  177. {
  178. if (IS_CAMERON) {
  179. puts ("no IDE on cameron board.\n");
  180. return 0;
  181. }
  182. return 1;
  183. }
  184. #endif
  185. static int sc3_cameron_init (void)
  186. {
  187. /* Set up the Memory Controller for the CAMERON version */
  188. mtebc (pb4ap, 0x01805940);
  189. mtebc (pb4cr, 0x7401a000);
  190. mtebc (pb5ap, 0x01805940);
  191. mtebc (pb5cr, 0x7401a000);
  192. mtebc (pb6ap, 0x0);
  193. mtebc (pb6cr, 0x0);
  194. mtebc (pb7ap, 0x0);
  195. mtebc (pb7cr, 0x0);
  196. return 0;
  197. }
  198. void sc3_read_eeprom (void)
  199. {
  200. uchar i2c_buffer[18];
  201. i2c_read (0x50, 0x03, 1, i2c_buffer, 9);
  202. i2c_buffer[9] = 0;
  203. setenv ("serial#", (char *)i2c_buffer);
  204. /* read mac-address from eeprom */
  205. i2c_read (0x50, 0x11, 1, i2c_buffer, 15);
  206. i2c_buffer[17] = 0;
  207. i2c_buffer[16] = i2c_buffer[14];
  208. i2c_buffer[15] = i2c_buffer[13];
  209. i2c_buffer[14] = ':';
  210. i2c_buffer[13] = i2c_buffer[12];
  211. i2c_buffer[12] = i2c_buffer[11];
  212. i2c_buffer[11] = ':';
  213. i2c_buffer[8] = ':';
  214. i2c_buffer[5] = ':';
  215. i2c_buffer[2] = ':';
  216. setenv ("ethaddr", (char *)i2c_buffer);
  217. }
  218. int board_early_init_f (void)
  219. {
  220. /* write only register to configure things in our CPLD */
  221. unsigned char cpldConfig_1=0x00;
  222. /*-------------------------------------------------------------------------+
  223. | Interrupt controller setup for the SolidCard III CPU card (plus Evaluation board).
  224. |
  225. | Note: IRQ 0 UART 0, active high; level sensitive
  226. | IRQ 1 UART 1, active high; level sensitive
  227. | IRQ 2 IIC, active high; level sensitive
  228. | IRQ 3 Ext. master, rising edge, edge sensitive
  229. | IRQ 4 PCI, active high; level sensitive
  230. | IRQ 5 DMA Channel 0, active high; level sensitive
  231. | IRQ 6 DMA Channel 1, active high; level sensitive
  232. | IRQ 7 DMA Channel 2, active high; level sensitive
  233. | IRQ 8 DMA Channel 3, active high; level sensitive
  234. | IRQ 9 Ethernet Wakeup, active high; level sensitive
  235. | IRQ 10 MAL System Error (SERR), active high; level sensitive
  236. | IRQ 11 MAL Tx End of Buffer, active high; level sensitive
  237. | IRQ 12 MAL Rx End of Buffer, active high; level sensitive
  238. | IRQ 13 MAL Tx Descriptor Error, active high; level sensitive
  239. | IRQ 14 MAL Rx Descriptor Error, active high; level sensitive
  240. | IRQ 15 Ethernet, active high; level sensitive
  241. | IRQ 16 External PCI SERR, active high; level sensitive
  242. | IRQ 17 ECC Correctable Error, active high; level sensitive
  243. | IRQ 18 PCI Power Management, active high; level sensitive
  244. |
  245. | IRQ 19 (EXT IRQ7 405GPr only)
  246. | IRQ 20 (EXT IRQ8 405GPr only)
  247. | IRQ 21 (EXT IRQ9 405GPr only)
  248. | IRQ 22 (EXT IRQ10 405GPr only)
  249. | IRQ 23 (EXT IRQ11 405GPr only)
  250. | IRQ 24 (EXT IRQ12 405GPr only)
  251. |
  252. | IRQ 25 (EXT IRQ 0) NAND-Flash R/B# (raising edge means flash is ready)
  253. | IRQ 26 (EXT IRQ 1) IDE0 interrupt (x86 = IRQ14). Active high (edge sensitive)
  254. | IRQ 27 (EXT IRQ 2) USB controller
  255. | IRQ 28 (EXT IRQ 3) INT D, VGA; active low; level sensitive
  256. | IRQ 29 (EXT IRQ 4) INT C, Ethernet; active low; level sensitive
  257. | IRQ 30 (EXT IRQ 5) INT B, PC104+ SLOT; active low; level sensitive
  258. | IRQ 31 (EXT IRQ 6) INT A, PC104+ SLOT; active low; level sensitive
  259. |
  260. | Direct Memory Access Controller Signal Polarities
  261. | DRQ0 active high (like ISA)
  262. | ACK0 active low (like ISA)
  263. | EOT0 active high (like ISA)
  264. | DRQ1 active high (like ISA)
  265. | ACK1 active low (like ISA)
  266. | EOT1 active high (like ISA)
  267. | DRQ2 active high (like ISA)
  268. | ACK2 active low (like ISA)
  269. | EOT2 active high (like ISA)
  270. | DRQ3 active high (like ISA)
  271. | ACK3 active low (like ISA)
  272. | EOT3 active high (like ISA)
  273. |
  274. +-------------------------------------------------------------------------*/
  275. writeb (cpldConfig_1, CPLD_CONTROL_1); /* disable everything in CPLD */
  276. mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */
  277. mtdcr (uicer, 0x00000000); /* disable all ints */
  278. mtdcr (uiccr, 0x00000000); /* set all to be non-critical */
  279. if (IS_CAMERON) {
  280. sc3_cameron_init();
  281. mtdcr (0x0B6, 0x18000000);
  282. mtdcr (uicpr, 0xFFFFFFF0);
  283. mtdcr (uictr, 0x10001030);
  284. } else {
  285. mtdcr (0x0B6, 0x0000000);
  286. mtdcr (uicpr, 0xFFFFFFE0);
  287. mtdcr (uictr, 0x10000020);
  288. }
  289. mtdcr (uicvcr, 0x00000001); /* set vect base=0,INT0 highest priority */
  290. mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */
  291. /* setup other implementation specific details */
  292. mtdcr (ecr, 0x60606000);
  293. mtdcr (cntrl1, 0x000042C0);
  294. if (IS_CAMERON) {
  295. mtdcr (cntrl0, 0x01380000);
  296. /* Setup the GPIOs */
  297. writel (0x08008000, 0xEF600700); /* Output states */
  298. writel (0x00000000, 0xEF600718); /* Open Drain control */
  299. writel (0x68098000, 0xEF600704); /* Output control */
  300. } else {
  301. mtdcr (cntrl0,0x00080000);
  302. /* Setup the GPIOs */
  303. writel (0x08000000, 0xEF600700); /* Output states */
  304. writel (0x14000000, 0xEF600718); /* Open Drain control */
  305. writel (0x7C000000, 0xEF600704); /* Output control */
  306. }
  307. /* Code decompression disabled */
  308. mtdcr (kiar, kconf);
  309. mtdcr (kidr, 0x2B);
  310. /* CPC0_ER: enable sleep mode of (currently) unused components */
  311. /* CPC0_FR: force unused components into sleep mode */
  312. mtdcr (cpmer, 0x3F800000);
  313. mtdcr (cpmfr, 0x14000000);
  314. /* set PLB priority */
  315. mtdcr (0x87, 0x08000000);
  316. /* --------------- DMA stuff ------------------------------------- */
  317. mtdcr (0x126, 0x49200000);
  318. #ifndef IDE_USES_ISA_EMULATION
  319. cpldConfig_1 |= IDE_BOOSTING; /* enable faster IDE */
  320. /* cpldConfig |= 0x01; */ /* enable 8.33MHz output, if *not* present on your baseboard */
  321. writeb (cpldConfig_1, CPLD_CONTROL_1);
  322. #endif
  323. #ifdef CONFIG_ISP1161_PRESENT
  324. initUsbHost (&cpldConfig_1);
  325. writeb (cpldConfig_1, CPLD_CONTROL_1);
  326. #endif
  327. /* FIXME: for what must we do this */
  328. *(unsigned long *)0x79000080 = 0x0001;
  329. return(0);
  330. }
  331. int misc_init_r (void)
  332. {
  333. char *s1;
  334. int i, xilinx_val;
  335. volatile char *xilinx_adr;
  336. xilinx_adr = (char *)0x79000102;
  337. *xilinx_adr = 0x00;
  338. /* customer settings ***************************************** */
  339. /*
  340. s1 = getenv ("function");
  341. if (s1) {
  342. if (!strcmp (s1, "Rosho")) {
  343. printf ("function 'Rosho' activated\n");
  344. *xilinx_adr = 0x40;
  345. }
  346. else {
  347. printf (">>>>>>>>>> function %s not recognized\n",s1);
  348. }
  349. }
  350. */
  351. /* individual settings ***************************************** */
  352. if ((s1 = getenv ("xilinx"))) {
  353. i=0;
  354. xilinx_val = 0;
  355. while (i < 3 && s1[i]) {
  356. if (s1[i] >= '0' && s1[i] <= '9')
  357. xilinx_val = (xilinx_val << 4) + s1[i] - '0';
  358. else
  359. if (s1[i] >= 'A' && s1[i] <= 'F')
  360. xilinx_val = (xilinx_val << 4) + s1[i] - 'A' + 10;
  361. else
  362. if (s1[i] >= 'a' && s1[i] <= 'f')
  363. xilinx_val = (xilinx_val << 4) + s1[i] - 'a' + 10;
  364. else {
  365. xilinx_val = -1;
  366. break;
  367. }
  368. i++;
  369. }
  370. if (xilinx_val >= 0 && xilinx_val <=255 && i < 3) {
  371. printf ("Xilinx: set to %s\n", s1);
  372. *xilinx_adr = (unsigned char) xilinx_val;
  373. } else
  374. printf ("Xilinx: rejected value %s\n", s1);
  375. }
  376. return 0;
  377. }
  378. /* -------------------------------------------------------------------------
  379. * printCSConfig
  380. *
  381. * Print some informations about chips select configurations
  382. * Only used while debugging.
  383. *
  384. * Params:
  385. * - No. of CS pin
  386. * - AP of this CS
  387. * - CR of this CS
  388. *
  389. * Returns
  390. * nothing
  391. ------------------------------------------------------------------------- */
  392. #ifdef SC3_DEBUGOUT
  393. static void printCSConfig(int reg,unsigned long ap,unsigned long cr)
  394. {
  395. const char *bsize[4] = {"8","16","32","?"};
  396. const unsigned char banks[8] = {1, 2, 4, 8, 16, 32, 64, 128};
  397. const char *bankaccess[4] = {"disabled", "RO", "WO", "RW"};
  398. #define CYCLE 30 /* time of one clock (based on 33MHz) */
  399. printf("\nCS#%d",reg);
  400. if (!(cr & 0x00018000))
  401. puts(" unused");
  402. else {
  403. if (((cr&0xFFF00000U) & ((banks[(cr & 0x000E0000) >> 17]-1) << 20)))
  404. puts(" Address is not multiple of bank size!");
  405. printf("\n -%s bit device",
  406. bsize[(cr & 0x00006000) >> 13]);
  407. printf(" at 0x%08lX", cr & 0xFFF00000U);
  408. printf(" size: %u MB", banks[(cr & 0x000E0000) >> 17]);
  409. printf(" rights: %s", bankaccess[(cr & 0x00018000) >> 15]);
  410. if (ap & 0x80000000) {
  411. printf("\n -Burst device (%luns/%luns)",
  412. (((ap & 0x7C000000) >> 26) + 1) * CYCLE,
  413. (((ap & 0x03800000) >> 23) + 1) * CYCLE);
  414. } else {
  415. printf("\n -Non burst device, active cycle %luns",
  416. (((ap & 0x7F800000) >> 23) + 1) * CYCLE);
  417. printf("\n -Address setup %luns",
  418. ((ap & 0xC0000) >> 18) * CYCLE);
  419. printf("\n -CS active to RD %luns/WR %luns",
  420. ((ap & 0x30000) >> 16) * CYCLE,
  421. ((ap & 0xC000) >> 14) * CYCLE);
  422. printf("\n -WR to CS inactive %luns",
  423. ((ap & 0x3000) >> 12) * CYCLE);
  424. printf("\n -Hold after access %luns",
  425. ((ap & 0xE00) >> 9) * CYCLE);
  426. printf("\n -Ready is %sabled",
  427. ap & 0x100 ? "en" : "dis");
  428. }
  429. }
  430. }
  431. #endif
  432. #ifdef SC3_DEBUGOUT
  433. static unsigned int ap[] = {pb0ap, pb1ap, pb2ap, pb3ap, pb4ap,
  434. pb5ap, pb6ap, pb7ap};
  435. static unsigned int cr[] = {pb0cr, pb1cr, pb2cr, pb3cr, pb4cr,
  436. pb5cr, pb6cr, pb7cr};
  437. static int show_reg (int nr)
  438. {
  439. unsigned long ul1, ul2;
  440. mtdcr (ebccfga, ap[nr]);
  441. ul1 = mfdcr (ebccfgd);
  442. mtdcr (ebccfga, cr[nr]);
  443. ul2 = mfdcr(ebccfgd);
  444. printCSConfig(nr, ul1, ul2);
  445. return 0;
  446. }
  447. #endif
  448. int checkboard (void)
  449. {
  450. #ifdef SC3_DEBUGOUT
  451. unsigned long ul1;
  452. int i;
  453. for (i = 0; i < 8; i++) {
  454. show_reg (i);
  455. }
  456. mtdcr (ebccfga, epcr);
  457. ul1 = mfdcr (ebccfgd);
  458. puts ("\nGeneral configuration:\n");
  459. if (ul1 & 0x80000000)
  460. printf(" -External Bus is always driven\n");
  461. if (ul1 & 0x400000)
  462. printf(" -CS signals are always driven\n");
  463. if (ul1 & 0x20000)
  464. printf(" -PowerDown after %lu clocks\n",
  465. (ul1 & 0x1F000) >> 7);
  466. switch (ul1 & 0xC0000)
  467. {
  468. case 0xC0000:
  469. printf(" -No external master present\n");
  470. break;
  471. case 0x00000:
  472. printf(" -8 bit external master present\n");
  473. break;
  474. case 0x40000:
  475. printf(" -16 bit external master present\n");
  476. break;
  477. case 0x80000:
  478. printf(" -32 bit external master present\n");
  479. break;
  480. }
  481. switch (ul1 & 0x300000)
  482. {
  483. case 0x300000:
  484. printf(" -Prefetch: Illegal setting!\n");
  485. break;
  486. case 0x000000:
  487. printf(" -1 doubleword prefetch\n");
  488. break;
  489. case 0x100000:
  490. printf(" -2 doublewords prefetch\n");
  491. break;
  492. case 0x200000:
  493. printf(" -4 doublewords prefetch\n");
  494. break;
  495. }
  496. putc ('\n');
  497. #endif
  498. printf("Board: SolidCard III %s %s version.\n",
  499. (IS_CAMERON ? "Cameron" : "Eurodesign"), CONFIG_SC3_VERSION);
  500. return 0;
  501. }
  502. static int printSDRAMConfig(char reg, unsigned long cr)
  503. {
  504. const int bisize[8]={4, 8, 16, 32, 64, 128, 256, 0};
  505. #ifdef SC3_DEBUGOUT
  506. const char *basize[8]=
  507. {"4", "8", "16", "32", "64", "128", "256", "Reserved"};
  508. printf("SDRAM bank %d",reg);
  509. if (!(cr & 0x01))
  510. puts(" disabled\n");
  511. else {
  512. printf(" at 0x%08lX, size %s MB",cr & 0xFFC00000,basize[(cr&0xE0000)>>17]);
  513. printf(" mode %lu\n",((cr & 0xE000)>>13)+1);
  514. }
  515. #endif
  516. if (cr & 0x01)
  517. return(bisize[(cr & 0xE0000) >> 17]);
  518. return 0;
  519. }
  520. #ifdef SC3_DEBUGOUT
  521. static unsigned int mbcf[] = {mem_mb0cf, mem_mb1cf, mem_mb2cf, mem_mb3cf};
  522. #endif
  523. phys_size_t initdram (int board_type)
  524. {
  525. unsigned int mems=0;
  526. unsigned long ul1;
  527. #ifdef SC3_DEBUGOUT
  528. unsigned long ul2;
  529. int i;
  530. puts("\nSDRAM configuration:\n");
  531. mtdcr (memcfga, mem_mcopt1);
  532. ul1 = mfdcr(memcfgd);
  533. if (!(ul1 & 0x80000000)) {
  534. puts(" Controller disabled\n");
  535. return 0;
  536. }
  537. for (i = 0; i < 4; i++) {
  538. mtdcr (memcfga, mbcf[i]);
  539. ul1 = mfdcr (memcfgd);
  540. mems += printSDRAMConfig (i, ul1);
  541. }
  542. mtdcr (memcfga, mem_sdtr1);
  543. ul1 = mfdcr(memcfgd);
  544. printf ("Timing:\n -CAS latency %lu\n", ((ul1 & 0x1800000) >> 23)+1);
  545. printf (" -Precharge %lu (PTA) \n", ((ul1 & 0xC0000) >> 18) + 1);
  546. printf (" -R/W to Precharge %lu (CTP)\n", ((ul1 & 0x30000) >> 16) + 1);
  547. printf (" -Leadoff %lu\n", ((ul1 & 0xC000) >> 14) + 1);
  548. printf (" -CAS to RAS %lu\n", ((ul1 & 0x1C) >> 2) + 4);
  549. printf (" -RAS to CAS %lu\n", ((ul1 & 0x3) + 1));
  550. puts ("Misc:\n");
  551. mtdcr (memcfga, mem_rtr);
  552. ul1 = mfdcr(memcfgd);
  553. printf (" -Refresh rate: %luns\n", (ul1 >> 16) * 7);
  554. mtdcr(memcfga,mem_pmit);
  555. ul2=mfdcr(memcfgd);
  556. mtdcr(memcfga,mem_mcopt1);
  557. ul1=mfdcr(memcfgd);
  558. if (ul1 & 0x20000000)
  559. printf(" -Power Down after: %luns\n",
  560. ((ul2 & 0xFFC00000) >> 22) * 7);
  561. else
  562. puts(" -Power Down disabled\n");
  563. if (ul1 & 0x40000000)
  564. printf(" -Self refresh feature active\n");
  565. else
  566. puts(" -Self refresh disabled\n");
  567. if (ul1 & 0x10000000)
  568. puts(" -ECC enabled\n");
  569. else
  570. puts(" -ECC disabled\n");
  571. if (ul1 & 0x8000000)
  572. puts(" -Using registered SDRAM\n");
  573. if (!(ul1 & 0x6000000))
  574. puts(" -Using 32 bit data width\n");
  575. else
  576. puts(" -Illegal data width!\n");
  577. if (ul1 & 0x400000)
  578. puts(" -ECC drivers inactive\n");
  579. else
  580. puts(" -ECC drivers active\n");
  581. if (ul1 & 0x200000)
  582. puts(" -Memory lines always active outputs\n");
  583. else
  584. puts(" -Memory lines only at write cycles active outputs\n");
  585. mtdcr (memcfga, mem_status);
  586. ul1 = mfdcr (memcfgd);
  587. if (ul1 & 0x80000000)
  588. puts(" -SDRAM Controller ready\n");
  589. else
  590. puts(" -SDRAM Controller not ready\n");
  591. if (ul1 & 0x4000000)
  592. puts(" -SDRAM in self refresh mode!\n");
  593. return (mems * 1024 * 1024);
  594. #else
  595. mtdcr (memcfga, mem_mb0cf);
  596. ul1 = mfdcr (memcfgd);
  597. mems = printSDRAMConfig (0, ul1);
  598. mtdcr (memcfga, mem_mb1cf);
  599. ul1 = mfdcr (memcfgd);
  600. mems += printSDRAMConfig (1, ul1);
  601. mtdcr (memcfga, mem_mb2cf);
  602. ul1 = mfdcr(memcfgd);
  603. mems += printSDRAMConfig (2, ul1);
  604. mtdcr (memcfga, mem_mb3cf);
  605. ul1 = mfdcr(memcfgd);
  606. mems += printSDRAMConfig (3, ul1);
  607. return (mems * 1024 * 1024);
  608. #endif
  609. }
  610. static void pci_solidcard3_fixup_irq (struct pci_controller *hose, pci_dev_t dev)
  611. {
  612. /*-------------------------------------------------------------------------+
  613. | ,-. ,-. ,-. ,-. ,-.
  614. | INTD# ----|B|-----|P|-. ,-|P|-. ,-| |-. ,-|G|
  615. | |R| |C| \ / |C| \ / |E| \ / |r|
  616. | INTC# ----|I|-----|1|-. `/---|1|-. `/---|t|-. `/---|a|
  617. | |D| |0| \/ |0| \/ |h| \/ |f|
  618. | INTB# ----|G|-----|4|-./`----|4|-./`----|e|-./`----|i|
  619. | |E| |+| /\ |+| /\ |r| /\ |k|
  620. | INTA# ----| |-----| |- `----| |- `----| |- `----| |
  621. | `-' `-' `-' `-' `-'
  622. | Slot 0 10 11 12 13
  623. | REQ# 0 1 2 *
  624. | GNT# 0 1 2 *
  625. +-------------------------------------------------------------------------*/
  626. unsigned char int_line = 0xff;
  627. switch (PCI_DEV(dev)) {
  628. case 10:
  629. int_line = 31; /* INT A */
  630. POST_OUT(0x42);
  631. break;
  632. case 11:
  633. int_line = 30; /* INT B */
  634. POST_OUT(0x43);
  635. break;
  636. case 12:
  637. int_line = 29; /* INT C */
  638. POST_OUT(0x44);
  639. break;
  640. case 13:
  641. int_line = 28; /* INT D */
  642. POST_OUT(0x45);
  643. break;
  644. }
  645. pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, int_line);
  646. }
  647. extern void pci_405gp_init(struct pci_controller *hose);
  648. extern void pci_405gp_fixup_irq(struct pci_controller *hose, pci_dev_t dev);
  649. extern void pci_405gp_setup_bridge(struct pci_controller *hose, pci_dev_t dev,struct pci_config_table *entry);
  650. /*
  651. * The following table is used when there is a special need to setup a PCI device.
  652. * For every PCI device found in this table is called the given init function with given
  653. * parameters. So never let all IDs at PCI_ANY_ID. In this case any found device gets the same
  654. * parameters!
  655. *
  656. */
  657. static struct pci_config_table pci_solidcard3_config_table[] =
  658. {
  659. /* Host to PCI Bridge device (405GP) */
  660. {
  661. vendor: 0x1014,
  662. device: 0x0156,
  663. class: PCI_CLASS_BRIDGE_HOST,
  664. bus: 0,
  665. dev: 0,
  666. func: 0,
  667. config_device: pci_405gp_setup_bridge
  668. },
  669. { }
  670. };
  671. /*-------------------------------------------------------------------------+
  672. | pci_init_board (Called from pci_init() in drivers/pci/pci.c)
  673. |
  674. | Init the PCI part of the SolidCard III
  675. |
  676. | Params:
  677. * - Pointer to current PCI hose
  678. * - Current Device
  679. *
  680. * Returns
  681. * nothing
  682. +-------------------------------------------------------------------------*/
  683. void pci_init_board(void)
  684. {
  685. POST_OUT(0x41);
  686. /*
  687. * we want the ptrs to RAM not flash (ie don't use init list)
  688. */
  689. hose.fixup_irq = pci_solidcard3_fixup_irq;
  690. hose.config_table = pci_solidcard3_config_table;
  691. pci_405gp_init(&hose);
  692. }
  693. int board_eth_init(bd_t *bis)
  694. {
  695. return pci_eth_init(bis);
  696. }