sc520_spunk.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708
  1. /*
  2. *
  3. * (C) Copyright 2002
  4. * Daniel Engström, Omicron Ceti AB <daniel@omicron.se>.
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #include <common.h>
  25. #include <pci.h>
  26. #include <netdev.h>
  27. #include <ds1722.h>
  28. #include <asm/io.h>
  29. #include <asm/pci.h>
  30. #include <asm/ic/sc520.h>
  31. #include <asm/ic/pci.h>
  32. #include <asm/ic/ssi.h>
  33. DECLARE_GLOBAL_DATA_PTR;
  34. /*
  35. * Theory:
  36. * We first set up all IRQs to be non-pci, edge triggered,
  37. * when we later enumerate the pci bus and pci_sc520_fixup_irq() gets
  38. * called we reallocate irqs to the pci bus with sc520_pci_set_irq()
  39. * as needed. Whe choose the irqs to gram from a configurable list
  40. * inside pci_sc520_fixup_irq() (If this list contains stupid irq's
  41. * such as 0 thngas will not work)
  42. */
  43. static void irq_init(void)
  44. {
  45. /* disable global interrupt mode */
  46. sc520_mmcr->picicr = 0x40;
  47. /* set all irqs to edge */
  48. sc520_mmcr->pic_mode[0] = 0x00;
  49. sc520_mmcr->pic_mode[1] = 0x00;
  50. sc520_mmcr->pic_mode[2] = 0x00;
  51. /* active low polarity on PIC interrupt pins,
  52. * active high polarity on all other irq pins */
  53. sc520_mmcr->intpinpol = 0x0000;
  54. /* set irq number mapping */
  55. sc520_mmcr->gp_tmr_int_map[0] = SC520_IRQ_DISABLED; /* disable GP timer 0 INT */
  56. sc520_mmcr->gp_tmr_int_map[1] = SC520_IRQ_DISABLED; /* disable GP timer 1 INT */
  57. sc520_mmcr->gp_tmr_int_map[2] = SC520_IRQ_DISABLED; /* disable GP timer 2 INT */
  58. sc520_mmcr->pit_int_map[0] = SC520_IRQ0; /* Set PIT timer 0 INT to IRQ0 */
  59. sc520_mmcr->pit_int_map[1] = SC520_IRQ_DISABLED; /* disable PIT timer 1 INT */
  60. sc520_mmcr->pit_int_map[2] = SC520_IRQ_DISABLED; /* disable PIT timer 2 INT */
  61. sc520_mmcr->pci_int_map[0] = SC520_IRQ_DISABLED; /* disable PCI INT A */
  62. sc520_mmcr->pci_int_map[1] = SC520_IRQ_DISABLED; /* disable PCI INT B */
  63. sc520_mmcr->pci_int_map[2] = SC520_IRQ_DISABLED; /* disable PCI INT C */
  64. sc520_mmcr->pci_int_map[3] = SC520_IRQ_DISABLED; /* disable PCI INT D */
  65. sc520_mmcr->dmabcintmap = SC520_IRQ_DISABLED; /* disable DMA INT */
  66. sc520_mmcr->ssimap = SC520_IRQ6; /* Set Synchronius serial INT to IRQ6*/
  67. sc520_mmcr->wdtmap = SC520_IRQ_DISABLED; /* disable Watchdog INT */
  68. sc520_mmcr->rtcmap = SC520_IRQ8; /* Set RTC int to 8 */
  69. sc520_mmcr->wpvmap = SC520_IRQ_DISABLED; /* disable write protect INT */
  70. sc520_mmcr->icemap = SC520_IRQ1; /* Set ICE Debug Serielport INT to IRQ1 */
  71. sc520_mmcr->ferrmap = SC520_IRQ13; /* Set FP error INT to IRQ13 */
  72. sc520_mmcr->uart_int_map[0] = SC520_IRQ4; /* Set internal UART1 INT to IRQ4 */
  73. sc520_mmcr->uart_int_map[1] = SC520_IRQ3; /* Set internal UART2 INT to IRQ3 */
  74. sc520_mmcr->gp_int_map[0] = SC520_IRQ7; /* Set GPIRQ0 (PC-Card AUX IRQ) to IRQ7 */
  75. sc520_mmcr->gp_int_map[1] = SC520_IRQ14; /* Set GPIRQ1 (CF IRQ) to IRQ14 */
  76. sc520_mmcr->gp_int_map[3] = SC520_IRQ5; /* Set GPIRQ3 ( CAN IRQ ) ti IRQ5 */
  77. sc520_mmcr->gp_int_map[4] = SC520_IRQ_DISABLED; /* disbale GIRQ4 ( IRR IRQ ) */
  78. sc520_mmcr->gp_int_map[5] = SC520_IRQ_DISABLED; /* disable GPIRQ5 */
  79. sc520_mmcr->gp_int_map[6] = SC520_IRQ_DISABLED; /* disable GPIRQ6 */
  80. sc520_mmcr->gp_int_map[7] = SC520_IRQ_DISABLED; /* disable GPIRQ7 */
  81. sc520_mmcr->gp_int_map[8] = SC520_IRQ_DISABLED; /* disable GPIRQ8 */
  82. sc520_mmcr->gp_int_map[9] = SC520_IRQ_DISABLED; /* disable GPIRQ9 */
  83. sc520_mmcr->gp_int_map[2] = SC520_IRQ_DISABLED; /* disable GPIRQ2 */
  84. sc520_mmcr->gp_int_map[10] = SC520_IRQ_DISABLED; /* disable GPIRQ10 */
  85. sc520_mmcr->pcihostmap = 0x11f; /* Map PCI hostbridge INT to NMI */
  86. sc520_mmcr->eccmap = 0x100; /* Map SDRAM ECC failure INT to NMI */
  87. }
  88. /* PCI stuff */
  89. static void pci_sc520_spunk_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
  90. {
  91. int version = sc520_mmcr->sysinfo;
  92. /* a configurable lists of irqs to steal
  93. * when we need one (a board with more pci interrupt pins
  94. * would use a larger table */
  95. static int irq_list[] = {
  96. CONFIG_SYS_FIRST_PCI_IRQ,
  97. CONFIG_SYS_SECOND_PCI_IRQ,
  98. CONFIG_SYS_THIRD_PCI_IRQ,
  99. CONFIG_SYS_FORTH_PCI_IRQ
  100. };
  101. static int next_irq_index=0;
  102. uchar tmp_pin;
  103. int pin;
  104. pci_hose_read_config_byte(hose, dev, PCI_INTERRUPT_PIN, &tmp_pin);
  105. pin = tmp_pin;
  106. pin-=1; /* pci config space use 1-based numbering */
  107. if (-1 == pin) {
  108. return; /* device use no irq */
  109. }
  110. /* map device number + pin to a pin on the sc520 */
  111. switch (PCI_DEV(dev)) {
  112. case 6: /* ETH0 */
  113. pin+=SC520_PCI_INTA;
  114. break;
  115. case 7: /* ETH1 */
  116. pin+=SC520_PCI_INTB;
  117. break;
  118. case 8: /* Crypto */
  119. pin+=SC520_PCI_INTC;
  120. break;
  121. case 9: /* PMC slot */
  122. pin+=SC520_PCI_INTD;
  123. break;
  124. case 10: /* PC-Card */
  125. if (version < 10) {
  126. pin+=SC520_PCI_INTD;
  127. } else {
  128. pin+=SC520_PCI_INTC;
  129. }
  130. break;
  131. default:
  132. return;
  133. }
  134. pin&=3; /* wrap around */
  135. if (sc520_pci_ints[pin] == -1) {
  136. /* re-route one interrupt for us */
  137. if (next_irq_index > 3) {
  138. return;
  139. }
  140. if (pci_sc520_set_irq(pin, irq_list[next_irq_index])) {
  141. return;
  142. }
  143. next_irq_index++;
  144. }
  145. if (-1 != sc520_pci_ints[pin]) {
  146. pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE,
  147. sc520_pci_ints[pin]);
  148. }
  149. #if 0
  150. printf("fixup_irq: device %d pin %c irq %d\n",
  151. PCI_DEV(dev), 'A' + pin, sc520_pci_ints[pin]);
  152. #endif
  153. }
  154. static void pci_sc520_spunk_configure_cardbus(struct pci_controller *hose,
  155. pci_dev_t dev, struct pci_config_table *te)
  156. {
  157. u32 io_base;
  158. u32 temp;
  159. pciauto_config_device(hose, dev);
  160. pci_hose_write_config_word(hose, dev, PCI_COMMAND, 0x07); /* enable device */
  161. pci_hose_write_config_byte(hose, dev, 0x0c, 0x10); /* cacheline size */
  162. pci_hose_write_config_byte(hose, dev, 0x0d, 0x40); /* latency timer */
  163. pci_hose_write_config_byte(hose, dev, 0x1b, 0x40); /* cardbus latency timer */
  164. pci_hose_write_config_word(hose, dev, PCI_BRIDGE_CONTROL, 0x0040); /* reset cardbus */
  165. pci_hose_write_config_word(hose, dev, PCI_BRIDGE_CONTROL, 0x0080); /* route interrupts though ExCA */
  166. pci_hose_write_config_word(hose, dev, 0x44, 0x3e0); /* map legacy I/O port to 0x3e0 */
  167. pci_hose_read_config_dword(hose, dev, 0x80, &temp); /* System control */
  168. pci_hose_write_config_dword(hose, dev, 0x80, temp | 0x60); /* System control: disable clockrun */
  169. /* route MF0 to ~INT and MF3 to IRQ7
  170. * reserve all others */
  171. pci_hose_write_config_dword(hose, dev, 0x8c, 0x00007002);
  172. pci_hose_write_config_byte(hose, dev, 0x91, 0x00); /* card control */
  173. pci_hose_write_config_byte(hose, dev, 0x92, 0x62); /* device control */
  174. if (te->device != 0xac56) {
  175. pci_hose_write_config_byte(hose, dev, 0x93, 0x21); /* async interrupt enable */
  176. pci_hose_write_config_word(hose, dev, 0xa8, 0x0000); /* reset GPIO */
  177. pci_hose_write_config_word(hose, dev, 0xac, 0x0000); /* reset GPIO */
  178. pci_hose_write_config_word(hose, dev, 0xaa, 0x0000); /* reset GPIO */
  179. pci_hose_write_config_word(hose, dev, 0xae, 0x0000); /* reset GPIO */
  180. } else {
  181. pci_hose_write_config_byte(hose, dev, 0x93, 0x20); /* */
  182. }
  183. pci_hose_write_config_word(hose, dev, 0xa4, 0x8000); /* reset power management */
  184. pci_hose_read_config_dword(hose, dev, PCI_BASE_ADDRESS_0, &io_base);
  185. io_base &= ~0xfL;
  186. writeb(0x07, io_base+0x803); /* route CSC irq though ExCA and enable IRQ7 */
  187. writel(0, io_base+0x10); /* CLKRUN default */
  188. writel(0, io_base+0x20); /* CLKRUN default */
  189. }
  190. static struct pci_config_table pci_sc520_spunk_config_table[] = {
  191. { 0x104c, 0xac50, PCI_ANY_ID, 0, 0x0a, 0, pci_sc520_spunk_configure_cardbus, { 0, 0, 0} },
  192. { 0x104c, 0xac56, PCI_ANY_ID, 0, 0x0a, 0, pci_sc520_spunk_configure_cardbus, { 0, 0, 0} },
  193. { 0, 0, 0, 0, 0, 0, NULL, {0,0,0}}
  194. };
  195. static struct pci_controller sc520_spunk_hose = {
  196. fixup_irq: pci_sc520_spunk_fixup_irq,
  197. config_table: pci_sc520_spunk_config_table,
  198. first_busno: 0x00,
  199. last_busno: 0xff,
  200. };
  201. void pci_init_board(void)
  202. {
  203. pci_sc520_init(&sc520_spunk_hose);
  204. }
  205. /* set up the ISA bus timing and system address mappings */
  206. static void bus_init(void)
  207. {
  208. /* versions
  209. * 0 Hyglo versions 0.95 and 0.96 (large baords)
  210. * ?? Hyglo version 0.97 (small board)
  211. * 10 Spunk board
  212. */
  213. int version = sc520_mmcr->sysinfo;
  214. if (version) {
  215. /* set up the GP IO pins (for the Spunk board) */
  216. sc520_mmcr->piopfs31_16 = 0xfff0; /* set the GPIO pin function 31-16 reg */
  217. sc520_mmcr->piopfs15_0 = 0x000f; /* set the GPIO pin function 15-0 reg */
  218. sc520_mmcr->piodir31_16 = 0x000f; /* set the GPIO direction 31-16 reg */
  219. sc520_mmcr->piodir15_0 = 0x1ff0; /* set the GPIO direction 15-0 reg */
  220. sc520_mmcr->cspfs = 0xc0; /* set the CS pin function reg */
  221. sc520_mmcr->clksel = 0x70;
  222. sc520_mmcr->pioclr31_16 = 0x0003; /* reset SSI chip-selects */
  223. sc520_mmcr->pioset31_16 = 0x000c;
  224. } else {
  225. /* set up the GP IO pins (for the Hyglo board) */
  226. sc520_mmcr->piopfs31_16 = 0xffc0; /* set the GPIO pin function 31-16 reg */
  227. sc520_mmcr->piopfs15_0 = 0x1e7f; /* set the GPIO pin function 15-0 reg */
  228. sc520_mmcr->piodir31_16 = 0x003f; /* set the GPIO direction 31-16 reg */
  229. sc520_mmcr->piodir15_0 = 0xe180; /* set the GPIO direction 15-0 reg */
  230. sc520_mmcr->cspfs = 0x00; /* set the CS pin function reg */
  231. sc520_mmcr->clksel = 0x70;
  232. sc520_mmcr->pioclr15_0 = 0x0180; /* reset SSI chip-selects */
  233. }
  234. sc520_mmcr->gpcsrt = 1; /* set the GP CS offset */
  235. sc520_mmcr->gpcspw = 3; /* set the GP CS pulse width */
  236. sc520_mmcr->gpcsoff = 1; /* set the GP CS offset */
  237. sc520_mmcr->gprdw = 3; /* set the RD pulse width */
  238. sc520_mmcr->gprdoff = 1; /* set the GP RD offset */
  239. sc520_mmcr->gpwrw = 3; /* set the GP WR pulse width */
  240. sc520_mmcr->gpwroff = 1; /* set the GP WR offset */
  241. sc520_mmcr->bootcsctl = 0x0407; /* set up timing of BOOTCS */
  242. /* adjust the memory map:
  243. * by default the first 256MB (0x00000000 - 0x0fffffff) is mapped to SDRAM
  244. * and 256MB to 1G-128k (0x1000000 - 0x37ffffff) is mapped to PCI mmio
  245. * we need to map 1G-128k - 1G (0x38000000 - 0x3fffffff) to CS1 */
  246. /* bootcs */
  247. sc520_mmcr->par[12] = 0x8bffe800;
  248. /* IDE0 = GPCS6 1f0-1f7 */
  249. sc520_mmcr->par[3] = 0x380801f0;
  250. /* IDE1 = GPCS7 3f6 */
  251. sc520_mmcr->par[4] = 0x3c0003f6;
  252. asm ("wbinvd\n"); /* Flush cache, req. after setting the unchached attribute ona PAR */
  253. sc520_mmcr->adddecctl = sc520_mmcr->adddecctl & ~(UART2_DIS|UART1_DIS);
  254. }
  255. /* par usage:
  256. * PAR0 (legacy_video)
  257. * PAR1 (PCI ROM mapping)
  258. * PAR2
  259. * PAR3 IDE
  260. * PAR4 IDE
  261. * PAR5 (legacy_video)
  262. * PAR6
  263. * PAR7 (legacy_video)
  264. * PAR8 (legacy_video)
  265. * PAR9 (legacy_video)
  266. * PAR10
  267. * PAR11 (ISAROM)
  268. * PAR12 BOOTCS
  269. * PAR13
  270. * PAR14
  271. * PAR15
  272. */
  273. /*
  274. * This function should map a chunk of size bytes
  275. * of the system address space to the ISA bus
  276. *
  277. * The function will return the memory address
  278. * as seen by the host (which may very will be the
  279. * same as the bus address)
  280. */
  281. u32 isa_map_rom(u32 bus_addr, int size)
  282. {
  283. u32 par;
  284. printf("isa_map_rom asked to map %d bytes at %x\n",
  285. size, bus_addr);
  286. par = size;
  287. if (par < 0x80000) {
  288. par = 0x80000;
  289. }
  290. par >>= 12;
  291. par--;
  292. par&=0x7f;
  293. par <<= 18;
  294. par |= (bus_addr>>12);
  295. par |= 0x50000000;
  296. printf ("setting PAR11 to %x\n", par);
  297. /* Map rom 0x10000 with PAR1 */
  298. sc520_mmcr->par[11] = par;
  299. return bus_addr;
  300. }
  301. /*
  302. * this function removed any mapping created
  303. * with pci_get_rom_window()
  304. */
  305. void isa_unmap_rom(u32 addr)
  306. {
  307. printf("isa_unmap_rom asked to unmap %x", addr);
  308. if ((addr>>12) == (sc520_mmcr->par[11] & 0x3ffff)) {
  309. sc520_mmcr->par[11] = 0;
  310. printf(" done\n");
  311. return;
  312. }
  313. printf(" not ours\n");
  314. }
  315. #ifdef CONFIG_PCI
  316. #define PCI_ROM_TEMP_SPACE 0x10000
  317. /*
  318. * This function should map a chunk of size bytes
  319. * of the system address space to the PCI bus,
  320. * suitable to map PCI ROMS (bus address < 16M)
  321. * the function will return the host memory address
  322. * which should be converted into a bus address
  323. * before used to configure the PCI rom address
  324. * decoder
  325. */
  326. u32 pci_get_rom_window(struct pci_controller *hose, int size)
  327. {
  328. u32 par;
  329. par = size;
  330. if (par < 0x80000) {
  331. par = 0x80000;
  332. }
  333. par >>= 16;
  334. par--;
  335. par&=0x7ff;
  336. par <<= 14;
  337. par |= (PCI_ROM_TEMP_SPACE>>16);
  338. par |= 0x72000000;
  339. printf ("setting PAR1 to %x\n", par);
  340. /* Map rom 0x10000 with PAR1 */
  341. sc520_mmcr->par[1] = par;
  342. return PCI_ROM_TEMP_SPACE;
  343. }
  344. /*
  345. * this function removed any mapping created
  346. * with pci_get_rom_window()
  347. */
  348. void pci_remove_rom_window(struct pci_controller *hose, u32 addr)
  349. {
  350. printf("pci_remove_rom_window: %x", addr);
  351. if (addr == PCI_ROM_TEMP_SPACE) {
  352. sc520_mmcr->par[1] = 0;
  353. printf(" done\n");
  354. return;
  355. }
  356. printf(" not ours\n");
  357. }
  358. /*
  359. * This function is called in order to provide acces to the
  360. * legacy video I/O ports on the PCI bus.
  361. * After this function accesses to I/O ports 0x3b0-0x3bb and
  362. * 0x3c0-0x3df shuld result in transactions on the PCI bus.
  363. *
  364. */
  365. int pci_enable_legacy_video_ports(struct pci_controller *hose)
  366. {
  367. /* Map video memory to 0xa0000*/
  368. sc520_mmcr->par[0] = 0x7200400a;
  369. /* forward all I/O accesses to PCI */
  370. sc520_mmcr->adddecctl = sc520_mmcr->adddecctl | IO_HOLE_DEST_PCI;
  371. /* so we map away all io ports to pci (only way to access pci io
  372. * below 0x400. But then we have to map back the portions that we dont
  373. * use so that the generate cycles on the GPIO bus where the sio and
  374. * ISA slots are connected, this requre the use of several PAR registers
  375. */
  376. /* bring 0x100 - 0x2f7 back to ISA using PAR5 */
  377. sc520_mmcr->par[5] = 0x31f70100;
  378. /* com2 use 2f8-2ff */
  379. /* bring 0x300 - 0x3af back to ISA using PAR7 */
  380. sc520_mmcr->par[7] = 0x30af0300;
  381. /* vga use 3b0-3bb */
  382. /* bring 0x3bc - 0x3bf back to ISA using PAR8 */
  383. sc520_mmcr->par[8] = 0x300303bc;
  384. /* vga use 3c0-3df */
  385. /* bring 0x3e0 - 0x3f7 back to ISA using PAR9 */
  386. sc520_mmcr->par[9] = 0x301703e0;
  387. /* com1 use 3f8-3ff */
  388. return 0;
  389. }
  390. #endif
  391. /*
  392. * Miscelaneous platform dependent initialisations
  393. */
  394. int board_init(void)
  395. {
  396. init_sc520();
  397. bus_init();
  398. irq_init();
  399. /* max drive current on SDRAM */
  400. sc520_mmcr->dsctl = 0x0100;
  401. /* enter debug mode after next reset (only if jumper is also set) */
  402. sc520_mmcr->rescfg = 0x08;
  403. /* configure the software timer to 33.000MHz */
  404. sc520_mmcr->swtmrcfg = 1;
  405. gd->bus_clk = 33000000;
  406. return 0;
  407. }
  408. int dram_init(void)
  409. {
  410. init_sc520_dram();
  411. return 0;
  412. }
  413. void show_boot_progress(int val)
  414. {
  415. int version = sc520_mmcr->sysinfo;
  416. if (val < -32) val = -1; /* let things compatible */
  417. if (version == 0) {
  418. /* PIO31-PIO16 Data */
  419. sc520_mmcr->piodata31_16 = (sc520_mmcr->piodata31_16 & 0xffc0) | ((val&0x7e)>>1); /* 0x1f8 >> 3 */
  420. /* PIO0-PIO15 Data */
  421. sc520_mmcr->piodata15_0 = (sc520_mmcr->piodata15_0 & 0x1fff)| ((val&0x7)<<13);
  422. } else {
  423. /* newer boards use PIO4-PIO12 */
  424. /* PIO0-PIO15 Data */
  425. #if 0
  426. val = (val & 0x007) | ((val & 0x038) << 3) | ((val & 0x1c0) >> 3);
  427. #else
  428. val = (val & 0x007) | ((val & 0x07e) << 2);
  429. #endif
  430. sc520_mmcr->piodata15_0 = (sc520_mmcr->piodata15_0 & 0xe00f) | ((val&0x01ff)<<4);
  431. }
  432. }
  433. int last_stage_init(void)
  434. {
  435. int version = sc520_mmcr->sysinfo;
  436. printf("Omicron Ceti SC520 Spunk revision %x\n", version);
  437. #if 0
  438. if (version) {
  439. int x, y;
  440. printf("eeprom probe %d\n", spi_eeprom_probe(1));
  441. spi_eeprom_read(1, 0, (u8*)&x, 2);
  442. spi_eeprom_read(1, 1, (u8*)&y, 2);
  443. printf("eeprom bytes %04x%04x\n", x, y);
  444. x ^= 0xffff;
  445. y ^= 0xffff;
  446. spi_eeprom_write(1, 0, (u8*)&x, 2);
  447. spi_eeprom_write(1, 1, (u8*)&y, 2);
  448. spi_eeprom_read(1, 0, (u8*)&x, 2);
  449. spi_eeprom_read(1, 1, (u8*)&y, 2);
  450. printf("eeprom bytes %04x%04x\n", x, y);
  451. } else {
  452. int x, y;
  453. printf("eeprom probe %d\n", mw_eeprom_probe(1));
  454. mw_eeprom_read(1, 0, (u8*)&x, 2);
  455. mw_eeprom_read(1, 1, (u8*)&y, 2);
  456. printf("eeprom bytes %04x%04x\n", x, y);
  457. x ^= 0xffff;
  458. y ^= 0xffff;
  459. mw_eeprom_write(1, 0, (u8*)&x, 2);
  460. mw_eeprom_write(1, 1, (u8*)&y, 2);
  461. mw_eeprom_read(1, 0, (u8*)&x, 2);
  462. mw_eeprom_read(1, 1, (u8*)&y, 2);
  463. printf("eeprom bytes %04x%04x\n", x, y);
  464. }
  465. #endif
  466. ds1722_probe(2);
  467. return 0;
  468. }
  469. void ssi_chip_select(int dev)
  470. {
  471. int version = sc520_mmcr->sysinfo;
  472. if (version) {
  473. /* Spunk board: EEPROM and CAN are actove-low, TEMP and AUX are active high */
  474. switch (dev) {
  475. case 1: /* EEPROM */
  476. sc520_mmcr->pioclr31_16 = 0x0004;
  477. break;
  478. case 2: /* Temp Probe */
  479. sc520_mmcr->pioset31_16 = 0x0002;
  480. break;
  481. case 3: /* CAN */
  482. sc520_mmcr->pioclr31_16 = 0x0008;
  483. break;
  484. case 4: /* AUX */
  485. sc520_mmcr->pioset31_16 = 0x0001;
  486. break;
  487. case 0:
  488. sc520_mmcr->pioclr31_16 = 0x0003;
  489. sc520_mmcr->pioset31_16 = 0x000c;
  490. break;
  491. default:
  492. printf("Illegal SSI device requested: %d\n", dev);
  493. }
  494. } else {
  495. /* Globox board: Both EEPROM and TEMP are active-high */
  496. switch (dev) {
  497. case 1: /* EEPROM */
  498. sc520_mmcr->pioset15_0 = 0x0100;
  499. break;
  500. case 2: /* Temp Probe */
  501. sc520_mmcr->pioset15_0 = 0x0080;
  502. break;
  503. case 0:
  504. sc520_mmcr->pioclr15_0 = 0x0180;
  505. break;
  506. default:
  507. printf("Illegal SSI device requested: %d\n", dev);
  508. }
  509. }
  510. }
  511. void spi_eeprom_probe(int x)
  512. {
  513. }
  514. int spi_eeprom_read(int x, int offset, uchar *buffer, int len)
  515. {
  516. return 0;
  517. }
  518. int spi_eeprom_write(int x, int offset, uchar *buffer, int len)
  519. {
  520. return 0;
  521. }
  522. void mw_eeprom_probe(int x)
  523. {
  524. }
  525. int mw_eeprom_read(int x, int offset, uchar *buffer, int len)
  526. {
  527. return 0;
  528. }
  529. int mw_eeprom_write(int x, int offset, uchar *buffer, int len)
  530. {
  531. return 0;
  532. }
  533. void spi_init_f(void)
  534. {
  535. sc520_mmcr->sysinfo ? spi_eeprom_probe(1) : mw_eeprom_probe(1);
  536. }
  537. ssize_t spi_read(uchar *addr, int alen, uchar *buffer, int len)
  538. {
  539. int offset;
  540. int i;
  541. offset = 0;
  542. for (i=0;i<alen;i++) {
  543. offset <<= 8;
  544. offset |= addr[i];
  545. }
  546. return sc520_mmcr->sysinfo ?
  547. spi_eeprom_read(1, offset, buffer, len) :
  548. mw_eeprom_read(1, offset, buffer, len);
  549. }
  550. ssize_t spi_write(uchar *addr, int alen, uchar *buffer, int len)
  551. {
  552. int offset;
  553. int i;
  554. offset = 0;
  555. for (i=0;i<alen;i++) {
  556. offset <<= 8;
  557. offset |= addr[i];
  558. }
  559. return sc520_mmcr->sysinfo ?
  560. spi_eeprom_write(1, offset, buffer, len) :
  561. mw_eeprom_write(1, offset, buffer, len);
  562. }
  563. int board_eth_init(bd_t *bis)
  564. {
  565. return pci_eth_init(bis);
  566. }