sc3.c 22 KB

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