sc3.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  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. return(0);
  327. }
  328. int misc_init_r (void)
  329. {
  330. char *s1;
  331. int i, xilinx_val;
  332. volatile char *xilinx_adr;
  333. xilinx_adr = (char *)0x79000102;
  334. *xilinx_adr = 0x00;
  335. /* customer settings ***************************************** */
  336. /*
  337. s1 = getenv ("function");
  338. if (s1) {
  339. if (!strcmp (s1, "Rosho")) {
  340. printf ("function 'Rosho' activated\n");
  341. *xilinx_adr = 0x40;
  342. }
  343. else {
  344. printf (">>>>>>>>>> function %s not recognized\n",s1);
  345. }
  346. }
  347. */
  348. /* individual settings ***************************************** */
  349. if ((s1 = getenv ("xilinx"))) {
  350. i=0;
  351. xilinx_val = 0;
  352. while (i < 3 && s1[i]) {
  353. if (s1[i] >= '0' && s1[i] <= '9')
  354. xilinx_val = (xilinx_val << 4) + s1[i] - '0';
  355. else
  356. if (s1[i] >= 'A' && s1[i] <= 'F')
  357. xilinx_val = (xilinx_val << 4) + s1[i] - 'A' + 10;
  358. else
  359. if (s1[i] >= 'a' && s1[i] <= 'f')
  360. xilinx_val = (xilinx_val << 4) + s1[i] - 'a' + 10;
  361. else {
  362. xilinx_val = -1;
  363. break;
  364. }
  365. i++;
  366. }
  367. if (xilinx_val >= 0 && xilinx_val <=255 && i < 3) {
  368. printf ("Xilinx: set to %s\n", s1);
  369. *xilinx_adr = (unsigned char) xilinx_val;
  370. } else
  371. printf ("Xilinx: rejected value %s\n", s1);
  372. }
  373. return 0;
  374. }
  375. /* -------------------------------------------------------------------------
  376. * printCSConfig
  377. *
  378. * Print some informations about chips select configurations
  379. * Only used while debugging.
  380. *
  381. * Params:
  382. * - No. of CS pin
  383. * - AP of this CS
  384. * - CR of this CS
  385. *
  386. * Returns
  387. * nothing
  388. ------------------------------------------------------------------------- */
  389. #ifdef SC3_DEBUGOUT
  390. static void printCSConfig(int reg,unsigned long ap,unsigned long cr)
  391. {
  392. const char *bsize[4] = {"8","16","32","?"};
  393. const unsigned char banks[8] = {1, 2, 4, 8, 16, 32, 64, 128};
  394. const char *bankaccess[4] = {"disabled", "RO", "WO", "RW"};
  395. #define CYCLE 30 /* time of one clock (based on 33MHz) */
  396. printf("\nCS#%d",reg);
  397. if (!(cr & 0x00018000))
  398. puts(" unused");
  399. else {
  400. if (((cr&0xFFF00000U) & ((banks[(cr & 0x000E0000) >> 17]-1) << 20)))
  401. puts(" Address is not multiple of bank size!");
  402. printf("\n -%s bit device",
  403. bsize[(cr & 0x00006000) >> 13]);
  404. printf(" at 0x%08lX", cr & 0xFFF00000U);
  405. printf(" size: %u MB", banks[(cr & 0x000E0000) >> 17]);
  406. printf(" rights: %s", bankaccess[(cr & 0x00018000) >> 15]);
  407. if (ap & 0x80000000) {
  408. printf("\n -Burst device (%luns/%luns)",
  409. (((ap & 0x7C000000) >> 26) + 1) * CYCLE,
  410. (((ap & 0x03800000) >> 23) + 1) * CYCLE);
  411. } else {
  412. printf("\n -Non burst device, active cycle %luns",
  413. (((ap & 0x7F800000) >> 23) + 1) * CYCLE);
  414. printf("\n -Address setup %luns",
  415. ((ap & 0xC0000) >> 18) * CYCLE);
  416. printf("\n -CS active to RD %luns/WR %luns",
  417. ((ap & 0x30000) >> 16) * CYCLE,
  418. ((ap & 0xC000) >> 14) * CYCLE);
  419. printf("\n -WR to CS inactive %luns",
  420. ((ap & 0x3000) >> 12) * CYCLE);
  421. printf("\n -Hold after access %luns",
  422. ((ap & 0xE00) >> 9) * CYCLE);
  423. printf("\n -Ready is %sabled",
  424. ap & 0x100 ? "en" : "dis");
  425. }
  426. }
  427. }
  428. #endif
  429. #ifdef SC3_DEBUGOUT
  430. static unsigned int ap[] = {pb0ap, pb1ap, pb2ap, pb3ap, pb4ap,
  431. pb5ap, pb6ap, pb7ap};
  432. static unsigned int cr[] = {pb0cr, pb1cr, pb2cr, pb3cr, pb4cr,
  433. pb5cr, pb6cr, pb7cr};
  434. static int show_reg (int nr)
  435. {
  436. unsigned long ul1, ul2;
  437. mtdcr (ebccfga, ap[nr]);
  438. ul1 = mfdcr (ebccfgd);
  439. mtdcr (ebccfga, cr[nr]);
  440. ul2 = mfdcr(ebccfgd);
  441. printCSConfig(nr, ul1, ul2);
  442. return 0;
  443. }
  444. #endif
  445. int checkboard (void)
  446. {
  447. #ifdef SC3_DEBUGOUT
  448. unsigned long ul1;
  449. int i;
  450. for (i = 0; i < 8; i++) {
  451. show_reg (i);
  452. }
  453. mtdcr (ebccfga, epcr);
  454. ul1 = mfdcr (ebccfgd);
  455. puts ("\nGeneral configuration:\n");
  456. if (ul1 & 0x80000000)
  457. printf(" -External Bus is always driven\n");
  458. if (ul1 & 0x400000)
  459. printf(" -CS signals are always driven\n");
  460. if (ul1 & 0x20000)
  461. printf(" -PowerDown after %lu clocks\n",
  462. (ul1 & 0x1F000) >> 7);
  463. switch (ul1 & 0xC0000)
  464. {
  465. case 0xC0000:
  466. printf(" -No external master present\n");
  467. break;
  468. case 0x00000:
  469. printf(" -8 bit external master present\n");
  470. break;
  471. case 0x40000:
  472. printf(" -16 bit external master present\n");
  473. break;
  474. case 0x80000:
  475. printf(" -32 bit external master present\n");
  476. break;
  477. }
  478. switch (ul1 & 0x300000)
  479. {
  480. case 0x300000:
  481. printf(" -Prefetch: Illegal setting!\n");
  482. break;
  483. case 0x000000:
  484. printf(" -1 doubleword prefetch\n");
  485. break;
  486. case 0x100000:
  487. printf(" -2 doublewords prefetch\n");
  488. break;
  489. case 0x200000:
  490. printf(" -4 doublewords prefetch\n");
  491. break;
  492. }
  493. putc ('\n');
  494. #endif
  495. printf("Board: SolidCard III %s %s version.\n",
  496. (IS_CAMERON ? "Cameron" : "Eurodesign"), CONFIG_SC3_VERSION);
  497. return 0;
  498. }
  499. static int printSDRAMConfig(char reg, unsigned long cr)
  500. {
  501. const int bisize[8]={4, 8, 16, 32, 64, 128, 256, 0};
  502. #ifdef SC3_DEBUGOUT
  503. const char *basize[8]=
  504. {"4", "8", "16", "32", "64", "128", "256", "Reserved"};
  505. printf("SDRAM bank %d",reg);
  506. if (!(cr & 0x01))
  507. puts(" disabled\n");
  508. else {
  509. printf(" at 0x%08lX, size %s MB",cr & 0xFFC00000,basize[(cr&0xE0000)>>17]);
  510. printf(" mode %lu\n",((cr & 0xE000)>>13)+1);
  511. }
  512. #endif
  513. if (cr & 0x01)
  514. return(bisize[(cr & 0xE0000) >> 17]);
  515. return 0;
  516. }
  517. #ifdef SC3_DEBUGOUT
  518. static unsigned int mbcf[] = {mem_mb0cf, mem_mb1cf, mem_mb2cf, mem_mb3cf};
  519. #endif
  520. long int initdram (int board_type)
  521. {
  522. unsigned int mems=0;
  523. unsigned long ul1;
  524. #ifdef SC3_DEBUGOUT
  525. unsigned long ul2;
  526. int i;
  527. puts("\nSDRAM configuration:\n");
  528. mtdcr (memcfga, mem_mcopt1);
  529. ul1 = mfdcr(memcfgd);
  530. if (!(ul1 & 0x80000000)) {
  531. puts(" Controller disabled\n");
  532. return 0;
  533. }
  534. for (i = 0; i < 4; i++) {
  535. mtdcr (memcfga, mbcf[i]);
  536. ul1 = mfdcr (memcfgd);
  537. mems += printSDRAMConfig (i, ul1);
  538. }
  539. mtdcr (memcfga, mem_sdtr1);
  540. ul1 = mfdcr(memcfgd);
  541. printf ("Timing:\n -CAS latency %lu\n", ((ul1 & 0x1800000) >> 23)+1);
  542. printf (" -Precharge %lu (PTA) \n", ((ul1 & 0xC0000) >> 18) + 1);
  543. printf (" -R/W to Precharge %lu (CTP)\n", ((ul1 & 0x30000) >> 16) + 1);
  544. printf (" -Leadoff %lu\n", ((ul1 & 0xC000) >> 14) + 1);
  545. printf (" -CAS to RAS %lu\n", ((ul1 & 0x1C) >> 2) + 4);
  546. printf (" -RAS to CAS %lu\n", ((ul1 & 0x3) + 1));
  547. puts ("Misc:\n");
  548. mtdcr (memcfga, mem_rtr);
  549. ul1 = mfdcr(memcfgd);
  550. printf (" -Refresh rate: %luns\n", (ul1 >> 16) * 7);
  551. mtdcr(memcfga,mem_pmit);
  552. ul2=mfdcr(memcfgd);
  553. mtdcr(memcfga,mem_mcopt1);
  554. ul1=mfdcr(memcfgd);
  555. if (ul1 & 0x20000000)
  556. printf(" -Power Down after: %luns\n",
  557. ((ul2 & 0xFFC00000) >> 22) * 7);
  558. else
  559. puts(" -Power Down disabled\n");
  560. if (ul1 & 0x40000000)
  561. printf(" -Self refresh feature active\n");
  562. else
  563. puts(" -Self refresh disabled\n");
  564. if (ul1 & 0x10000000)
  565. puts(" -ECC enabled\n");
  566. else
  567. puts(" -ECC disabled\n");
  568. if (ul1 & 0x8000000)
  569. puts(" -Using registered SDRAM\n");
  570. if (!(ul1 & 0x6000000))
  571. puts(" -Using 32 bit data width\n");
  572. else
  573. puts(" -Illegal data width!\n");
  574. if (ul1 & 0x400000)
  575. puts(" -ECC drivers inactive\n");
  576. else
  577. puts(" -ECC drivers active\n");
  578. if (ul1 & 0x200000)
  579. puts(" -Memory lines always active outputs\n");
  580. else
  581. puts(" -Memory lines only at write cycles active outputs\n");
  582. mtdcr (memcfga, mem_status);
  583. ul1 = mfdcr (memcfgd);
  584. if (ul1 & 0x80000000)
  585. puts(" -SDRAM Controller ready\n");
  586. else
  587. puts(" -SDRAM Controller not ready\n");
  588. if (ul1 & 0x4000000)
  589. puts(" -SDRAM in self refresh mode!\n");
  590. return (mems * 1024 * 1024);
  591. #else
  592. mtdcr (memcfga, mem_mb0cf);
  593. ul1 = mfdcr (memcfgd);
  594. mems = printSDRAMConfig (0, ul1);
  595. mtdcr (memcfga, mem_mb1cf);
  596. ul1 = mfdcr (memcfgd);
  597. mems += printSDRAMConfig (1, ul1);
  598. mtdcr (memcfga, mem_mb2cf);
  599. ul1 = mfdcr(memcfgd);
  600. mems += printSDRAMConfig (2, ul1);
  601. mtdcr (memcfga, mem_mb3cf);
  602. ul1 = mfdcr(memcfgd);
  603. mems += printSDRAMConfig (3, ul1);
  604. return (mems * 1024 * 1024);
  605. #endif
  606. }
  607. static void pci_solidcard3_fixup_irq (struct pci_controller *hose, pci_dev_t dev)
  608. {
  609. /*-------------------------------------------------------------------------+
  610. | ,-. ,-. ,-. ,-. ,-.
  611. | INTD# ----|B|-----|P|-. ,-|P|-. ,-| |-. ,-|G|
  612. | |R| |C| \ / |C| \ / |E| \ / |r|
  613. | INTC# ----|I|-----|1|-. `/---|1|-. `/---|t|-. `/---|a|
  614. | |D| |0| \/ |0| \/ |h| \/ |f|
  615. | INTB# ----|G|-----|4|-./`----|4|-./`----|e|-./`----|i|
  616. | |E| |+| /\ |+| /\ |r| /\ |k|
  617. | INTA# ----| |-----| |- `----| |- `----| |- `----| |
  618. | `-' `-' `-' `-' `-'
  619. | Slot 0 10 11 12 13
  620. | REQ# 0 1 2 *
  621. | GNT# 0 1 2 *
  622. +-------------------------------------------------------------------------*/
  623. unsigned char int_line = 0xff;
  624. switch (PCI_DEV(dev)) {
  625. case 10:
  626. int_line = 31; /* INT A */
  627. POST_OUT(0x42);
  628. break;
  629. case 11:
  630. int_line = 30; /* INT B */
  631. POST_OUT(0x43);
  632. break;
  633. case 12:
  634. int_line = 29; /* INT C */
  635. POST_OUT(0x44);
  636. break;
  637. case 13:
  638. int_line = 28; /* INT D */
  639. POST_OUT(0x45);
  640. break;
  641. }
  642. pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, int_line);
  643. }
  644. extern void pci_405gp_init(struct pci_controller *hose);
  645. extern void pci_405gp_fixup_irq(struct pci_controller *hose, pci_dev_t dev);
  646. extern void pci_405gp_setup_bridge(struct pci_controller *hose, pci_dev_t dev,struct pci_config_table *entry);
  647. /*
  648. * The following table is used when there is a special need to setup a PCI device.
  649. * For every PCI device found in this table is called the given init function with given
  650. * parameters. So never let all IDs at PCI_ANY_ID. In this case any found device gets the same
  651. * parameters!
  652. *
  653. */
  654. static struct pci_config_table pci_solidcard3_config_table[] =
  655. {
  656. /* Host to PCI Bridge device (405GP) */
  657. {
  658. vendor: 0x1014,
  659. device: 0x0156,
  660. class: PCI_CLASS_BRIDGE_HOST,
  661. bus: 0,
  662. dev: 0,
  663. func: 0,
  664. config_device: pci_405gp_setup_bridge
  665. },
  666. { }
  667. };
  668. /*-------------------------------------------------------------------------+
  669. | pci_init_board (Called from pci_init() in drivers/pci.c)
  670. |
  671. | Init the PCI part of the SolidCard III
  672. |
  673. | Params:
  674. * - Pointer to current PCI hose
  675. * - Current Device
  676. *
  677. * Returns
  678. * nothing
  679. +-------------------------------------------------------------------------*/
  680. void pci_init_board(void)
  681. {
  682. POST_OUT(0x41);
  683. /*
  684. * we want the ptrs to RAM not flash (ie don't use init list)
  685. */
  686. hose.fixup_irq = pci_solidcard3_fixup_irq;
  687. hose.config_table = pci_solidcard3_config_table;
  688. pci_405gp_init(&hose);
  689. }