2 * p6032/sbdreset.sx: low level reset code for P-6032/P-6064
4 * Copyright (c) 2000 Algorithmics Ltd - all rights reserved.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the "Free MIPS" License Agreement, a copy of
8 * which is available at:
10 * http://www.algor.co.uk/ftp/pub/doc/freemips-license.txt
12 * You may not, however, modify or remove any part of this copyright
13 * message if this program is redistributed or reused in whole or in
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * "Free MIPS" License for more details.
32 #include "isapnpreg.h"
36 #include "mipsmacros.h"
39 * R4000 Config Register
42 #define CFG_CM 0x80000000 /* Master-Checker mode */
43 #define CFG_ECMASK 0x70000000 /* System Clock Ratio */
44 #define CFG_ECSHIFT 28
45 #define CFG_ECBY2 0x00000000 /* divide by 2 */
46 #define CFG_ECBY3 0x00000000 /* divide by 3 */
47 #define CFG_ECBY4 0x00000000 /* divide by 4 */
48 #define CFG_EPMASK 0x0f000000 /* Transmit data pattern */
49 #define CFG_EPD 0x00000000 /* D */
50 #define CFG_EPDDX 0x01000000 /* DDX */
51 #define CFG_EPDDXX 0x02000000 /* DDXX */
52 #define CFG_EPDXDX 0x03000000 /* DXDX */
53 #define CFG_EPDDXXX 0x04000000 /* DDXXX */
54 #define CFG_EPDDXXXX 0x05000000 /* DDXXXX */
55 #define CFG_EPDXXDXX 0x06000000 /* DXXDXX */
56 #define CFG_EPDDXXXXX 0x07000000 /* DDXXXXX */
57 #define CFG_EPDXXXDXXX 0x08000000 /* DXXXDXXX */
58 #define CFG_SBMASK 0x00c00000 /* Secondary cache block size */
59 #define CFG_SBSHIFT 22
60 #define CFG_SB4 0x00000000 /* 4 words */
61 #define CFG_SB8 0x00400000 /* 8 words */
62 #define CFG_SB16 0x00800000 /* 16 words */
63 #define CFG_SB32 0x00c00000 /* 32 words */
64 #define CFG_EMMASK 0x00c00000 /* Vr54xx: SysAD mode */
65 #define CFG_EMSHIFT 22
66 #define CFG_EM_R4K 0x00000000 /* Vr54xx: R4x000 compatible */
67 #define CFG_EM_SPLITRD 0x00400000 /* Vr54xx: Multiple split reads */
68 #define CFG_EM_PIPEWR 0x00800000 /* Vr54xx: Pipeline writes */
69 #define CFG_EM_WRREISSU 0x00c00000 /* Vr54xx: Write-reissue */
70 #define CFG_AD 0x00800000 /* Accelerated data (R4100) */
71 #define CFG_SS 0x00200000 /* Split secondary cache */
72 #define CFG_SW 0x00100000 /* Secondary cache port width */
73 #define CFG_EWMASK 0x000c0000 /* System port width */
74 #define CFG_EWSHIFT 18
75 #define CFG_EW64 0x00000000 /* 64 bit */
76 #define CFG_EW32 0x00040000 /* 32 bit */
77 #define CFG_SC 0x00020000 /* Secondary cache absent */
78 #define CFG_SM 0x00010000 /* Dirty Shared mode disabled */
79 #define CFG_BE 0x00008000 /* Big Endian */
80 #define CFG_EM 0x00004000 /* ECC mode enable */
81 #define CFG_EB 0x00002000 /* Block ordering */
82 #define CFG_ICMASK 0x00000e00 /* Instruction cache size */
84 #define CFG_DCMASK 0x000001c0 /* Data cache size */
86 #define CFG_IB 0x00000020 /* Instruction cache block size */
87 #define CFG_DB 0x00000010 /* Data cache block size */
88 #define CFG_CU 0x00000008 /* Update on Store Conditional */
89 #define CFG_K0MASK 0x00000007 /* KSEG0 coherency algorithm */
95 #define CFG_C_WTHRU_NOALLOC 0 /* r4600 only */
96 #define CFG_C_WTHRU_ALLOC 1 /* r4600 only */
97 #define CFG_C_UNCACHED 2
98 #define CFG_C_NONCOHERENT 3
100 #define CFG_C_COHERENTXCL 4
101 #define CFG_C_COHERENTXCLW 5
102 #define CFG_C_COHERENTUPD 6 /* r4000/r4400 only */
103 #define CFG_C_UNCACHED_ACCEL 7 /* t5 only */
110 /* CPU-specific bootmode bitstreams */
112 #define BOOTMODE_RM7000 0x02034100
113 #define BOOTMODE_RM52XX 0x00230100
114 #define BOOTMODE_R4650 0x00001100
115 #define BOOTMODE_RC6447X 0x00001100
116 #define BOOTMODE_RC6457X 0x06001100
118 #define BOOTMODE_RM7000 0x02034000
119 #define BOOTMODE_RM52XX 0x00230000
120 #define BOOTMODE_R4650 0x00001000
121 #define BOOTMODE_RC6447X 0x00001000
122 #define BOOTMODE_RC6457X 0x06001000
129 #define DISPLAY(d0,d1,d2,d3,d4,d5,d6,d7) \
130 li t8,PHYS_TO_K1(LED_BASE+HD2532_CRAM); \
132 sw t9,HD2532_CHAR(0)(t8); \
134 sw t9,HD2532_CHAR(1)(t8); \
136 sw t9,HD2532_CHAR(2)(t8); \
138 sw t9,HD2532_CHAR(3)(t8); \
140 sw t9,HD2532_CHAR(4)(t8); \
142 sw t9,HD2532_CHAR(5)(t8); \
144 sw t9,HD2532_CHAR(6)(t8); \
146 sw t9,HD2532_CHAR(7)(t8)
151 #define DBGDISPLAY(d0,d1,d2,d3,d4,d5,d6,d7)
152 #define DBGLA(reg, label)
153 #define DBGLW(reg, label)
154 #define DBGSTRING(label, string)
155 #define DBGTSTRING(string)
156 #define DBGLSTR(reg, string)
157 #define DBGPSTR(string)
159 #define DBGDISPLAY(d0,d1,d2,d3,d4,d5,d6,d7) \
160 DISPLAY(d0,d1,d2,d3,d4,d5,d6,d7); \
167 #define DBGLA(reg, label) \
168 LOADREL(reg,label); \
171 #define DBGLW(reg, label) \
175 #define DBGSTRING(label, string) \
177 label: .asciiz string; \
180 #define DBGTSTRING(string) \
186 #define DBGLSTR(reg, string) \
191 #define DBGPSTR(string) \
192 DBGLSTR(a0,string); \
200 #define NS16550_INB(dst,offs,base) \
205 #define NS16550_OUTB(src,offs,base) \
215 * Print a character on console device
218 /* blocking transmit, with timeout */
219 li t0,TXWAIT # timeout
220 li t1,PHYS_TO_K1(UART0_BASE)
221 1: NS16550_INB(v0,LSR,t1) # get LSR
222 and v0,LSR_TXRDY # tx ready?
223 bnez v0,1f # yup - go and write
224 subu t0,1 # continue until timeout
226 1: NS16550_OUTB(a0,DATA,t1) # write data
233 * Print <CR, LF> on console device
247 * Print a string on console device
264 * rom_prx (unsigned int x, unsigned int log2size)
265 * Print a register on console device as hex digits
270 li t5,8 # t5 = bitcnt = 8 << log2size
274 li t6,64 # t6 = regsize - bitcnt
276 dsll t6,a0,t6 # get sig part of a0 to top of t6
277 1: dsrl a0,t6,60 # get top 4 bits
286 li t6,32 # t6 = regsize - bitcnt
288 sll t6,a0,t6 # get sig part of a0 to top of t6
289 1: srl a0,t6,28 # get top 4 bits
303 li v0,PHYS_TO_K1(UART0_BASE)
304 # enable 16550 fifo if it is there
305 li t0,FIFO_ENABLE|FIFO_RCV_RST|FIFO_XMT_RST|FIFO_TRIGGER_4
306 NS16550_OUTB(t0,FIFO,v0)
317 /* wait for all tx data to be sent */
319 1: NS16550_INB(t1,LSR,v0)
325 /* convert baud rate in a1 into register value */
326 2: beqz a1,.fail # don't want divide error
327 li t2,NS16550_HZ/16 # brtc = CLK/16/speed
329 blez t2,.fail # brtc must be > 0
331 li t0,CFCR_DLAB # select brtc divisor
332 NS16550_OUTB(t0,CFCR,v0)
333 NS16550_OUTB(t2,DLL,v0) # store divisor lsb
335 NS16550_OUTB(t2,DLM,v0) # store divisor msb
336 li t0,CFCR_8BITS # set 8N1 mode
337 NS16550_OUTB(t0,CFCR,v0)
339 li t0,MCR_DTR|MCR_RTS|MCR_IENABLE # enable DTR & RTS
340 NS16550_OUTB(t0,MCR,v0)
342 li t0,IER_ERXRDY # enable receive interrupt(!)
343 NS16550_OUTB(t0,IER,v0)
345 move v0,zero # indicate success
355 * Basic board initialisation, called straight from RESET.
356 * It is only called if this program is built for ROM.
357 * It can use any registers except s8, k0 and k1.
359 * Note that s8 holds a "relocation factor" (see ../share/romlow.sx)
360 * which must be added to any address before it is used. This
361 * is to support relocatable roms.
372 LEAF(board_earlyinit)
376 /* Initialise the LED so we can write to it */
377 li a1, PHYS_TO_K1(LED_BASE+HD2532_CW)
387 DBGDISPLAY('P','6','0','6','4',' ',' ',' ');
390 mfc0 t2,C0_PRID # get PrID
391 mtc0 zero,$18 # C0_IWATCH/C0_WATCHLO
392 mtc0 zero,$19 # C0_DWATCH/C0_WATCHHI
394 /* get global pointer to Bonito registers */
395 li bonito,PHYS_TO_K1(BONITO_BASE)
401 * some CPUs need a non-zero bootmode stream
402 * we achieve this by loading the bitstream into the intpol
403 * register and issuing a self-reset
404 * but first we must avoid getting into an infinite loop...
407 lw t3,BONITO_BONGENCFG(bonito)
408 and t3,BONITO_BONGENCFG_CPUSELFRESET
416 #define QEDCDIV(mb20,mb7_5) \
417 .word 0+((mb20<<20)|(mb7_5<<5))
431 #define CPU(prid,bootmode,cdiv,xtra) \
432 .word prid,bootmode,cdiv,xtra
434 CPU_BOOTMODE: .word 0
440 CPU(PRID_RM7000,BOOTMODE_RM7000,cdiv_qed,xtra_rm7000)
441 CPU(PRID_RM52XX,BOOTMODE_RM52XX,cdiv_qed,0)
442 CPU(PRID_RC6447X,0,0,BOOTMODE_RC6447X)
443 CPU(PRID_RC6457X,0,BOOTMODE_RC6457X,0)
444 CPU(PRID_R4650,0,BOOTMODE_R4650,0)
448 DISPLAY('R','e','s','e','t','C','h','k')
453 1: lw t3,CPU_PRID(t1)
454 beqz t3,.noreset # off end of table
460 DISPLAY('R','e','s','e','t','R','e','q')
461 # use the switch settings to modify the base settings
463 # to access the switches we need to enable CS0 buffbit
464 li t4,BONITO_IODEVCFG_BUFFBIT_CS0
465 sw t4,BONITO_IODEVCFG(bonito)
466 lw zero,BONITO_IODEVCFG(bonito)
468 li t4,PHYS_TO_K1(CPLD_BASE)
469 lw t4,CPLD_SWITCHES(t4)
471 lw t3,CPU_BOOTMODE(t1) # base setting
473 beqz t5,1f # skip CDIV settings if we don't know how
475 # get clock multiplier switches
478 and t6,t4,CPLD_CLKMULT
479 srl t7,t6,CPLD_CLKMULT_SHIFT
484 or t3,t6 # set multiplier bits
498 DISPLAY('R','e','s','e','t','G','o',' ')
499 sw t3,BONITO_INTPOL(bonito)
500 lw t3,BONITO_BONGENCFG(bonito)
501 or t3,BONITO_BONGENCFG_CPUSELFRESET
502 sw t3,BONITO_BONGENCFG(bonito)
503 lw t3,BONITO_BONGENCFG(bonito)
504 1: b 1b # loop forever
507 DISPLAY('N','o',' ','R','e','s','e','t')
509 /* if we get here, the cpu has been correctly initialised */
512 /* r4640/50 initialisation */
513 mtc0 zero,$0 # C0_IBASE
514 mtc0 zero,$1 # C0_IBOUND
515 mtc0 zero,$2 # C0_DBASE
516 mtc0 zero,$3 # C0_DBOUND
518 /* Making this dependent on BOOTPKG is wrong, but it is done this
519 * way to stop PMON reenabling the caches if ITROM has detected an
523 mtc0 t3,$17 # C0_CALG
527 2: /* r4xxx/r5xxx initialisation */
528 /* set config register for 32b/32b cachelines, kseg0 cacheable */
529 and t1,~0x3f # set bits 5..0 only
530 or t1,CFG_IB | CFG_DB | CFG_C_WBACK
531 /* Vr4300/5432: software controls the endianness (r/o on other CPUs) */
537 /* set DDDD rate for CPUs that aren't hardware configured */
541 /* Vr5400: set R4x00 compatible bus mode */
545 /* Vr4100: switch off accelerated data (undefined on other CPUs)*/
549 3: mfc0 t1,C0_STATUS # get Status
551 and t1,M_SR_SR # leave the SoftReset bit
552 or t1,M_SR_BEV # force Boot Exception Vec
555 /* Initialise other low-level I/O devices */
557 LOADREL(a0,reginittab)
559 LOADREL(t1,reset_table)
564 DISPLAY('R','e','g','i','n','i','t',' ')
570 li a0,PHYS_TO_K1(PCI_IO_SPACE)
593 DBGPSTR("In _sbd_reset\r\n")
602 LEAF(board_dram_init)
606 li bonito,PHYS_TO_K1(BONITO_BASE)
610 * Now determine DRAM configuration and size by
611 * reading the I2C EEROM on the DIMMS
617 DISPLAY ('D','I','M','M','0',' ',' ',' ')
619 /* start with DIMM #0 */
621 /* Do a RMW on SDCFG to preserve power up values */
622 lw sdCfg,BONITO_SDCFG(bonito)
623 /* use parity if DIMMS support it */
624 or sdCfg,BONITO_SDCFG_DRAMPARITY
629 /* read DIMM memory type (must be SDRAM) */
634 /* read DIMM memory size per side */
638 sll tmpsize,v0,22 # multiply by 4M
640 /* read DIMM number of rows */
644 bgtu v0,14-11,.nodimm
645 sll v0,BONITO_SDCFG_AROWBITS_SHIFT
646 and v0,BONITO_SDCFG_AROWBITS
649 2: /* read DIMM number of cols */
654 sll v0,BONITO_SDCFG_ACOLBITS_SHIFT
655 and v0,BONITO_SDCFG_ACOLBITS
658 2: /* read DIMM number of blocks-per-dram */
663 or sdShape,BONITO_SDCFG_ABANKBIT
665 2: /* read DIMM number of sides (banks) */
670 or sdShape,BONITO_SDCFG_ASIDES
671 sll tmpsize,1 # msize *= 2
673 2: /* read DIMM width */
678 or sdShape,BONITO_SDCFG_AWIDTH64
680 2: /* check width for parity operation */
684 and sdCfg,~BONITO_SDCFG_DRAMPARITY
691 or sdShape,BONITO_SDCFG_AABSENT
692 li v0,0xff<<BONITO_SDCFG_AROWBITS_SHIFT
694 sll sdShape,BONITO_SDCFG_BROWBITS_SHIFT
695 li v0,0xff<<BONITO_SDCFG_BROWBITS_SHIFT
700 DISPLAY ('D','I','M','M','1',' ',' ',' ')
704 /* If we are running in SDRAM, chop 4MB off the memory size,
705 and don't modify sdCfg register (assume someone in
706 PCI-world has already set it up). */
707 lw t0,BONITO_BONPONCFG(bonito)
708 and t0,BONITO_BONPONCFG_ROMBOOT
709 bne t0,BONITO_BONPONCFG_ROMBOOT_SDRAM,1f
711 beqz msize,2f # already zero!
712 subu msize,4*1024*1024
715 1: sw sdCfg,BONITO_SDCFG(bonito)
724 li t1,0 # accumulate pcimembasecfg settings
726 /* set bar0 mask and translation to point to all memory */
729 srl t0,BONITO_PCIMEMBASECFG_ASHIFT-BONITO_PCIMEMBASECFG_MEMBASE0_MASK_SHIFT
730 and t0,BONITO_PCIMEMBASECFG_MEMBASE0_MASK
734 srl t0,BONITO_PCIMEMBASECFG_ASHIFT-BONITO_PCIMEMBASECFG_MEMBASE0_TRANS_SHIFT
735 and t0,BONITO_PCIMEMBASECFG_MEMBASE0_TRANS
737 or t1,BONITO_PCIMEMBASECFG_MEMBASE0_CACHED
739 /* set bar1 to minimum size to conserve PCI space */
741 srl t0,BONITO_PCIMEMBASECFG_ASHIFT-BONITO_PCIMEMBASECFG_MEMBASE1_MASK_SHIFT
742 and t0,BONITO_PCIMEMBASECFG_MEMBASE1_MASK
746 srl t0,BONITO_PCIMEMBASECFG_ASHIFT-BONITO_PCIMEMBASECFG_MEMBASE1_TRANS_SHIFT
747 and t0,BONITO_PCIMEMBASECFG_MEMBASE1_TRANS
749 or t1,BONITO_PCIMEMBASECFG_MEMBASE1_CACHED
751 sw t1,BONITO_PCIMEMBASECFG(bonito)
753 /* enable configuration cycles now */
754 lw t0,BONITO_BONPONCFG(bonito)
755 and t0,~BONITO_BONPONCFG_CONFIG_DIS
756 sw t0,BONITO_BONPONCFG(bonito)
759 /* We have to clear memory to initialise parity */
761 /* Skip memory clear if no memory */
764 /* Skip memory clear if non-parity memory */
765 lw t1,BONITO_SDCFG(bonito)
766 and t1,BONITO_SDCFG_DRAMPARITY
769 /* Skip memory clear if a soft reset */
774 /* Clear bottom 256K running uncached */
775 DISPLAY ('Z','2','5','6','K',' ',' ',' ')
787 /* We can now initialise the caches for a fast clear_mem */
788 // DISPLAY ('C','A','C','H',' ',' ',' ',' ')
789 // bal mips_init_cache
791 /* Finally clear rest of memory running cached */
792 li a0,PHYS_TO_K1(256*1024)
793 subu a1,msize,256*1024
797 /* clear all of memory (to set correct parity) */
798 DISPLAY ('Z','M','E','M',' ',' ',' ',' ')
817 #endif /* P60XX_PARITY */
819 /* return to generic code, with available memory size */
820 DISPLAY ('R','U','N',' ',' ',' ',' ',' ')
825 srl v0,20 /* return in megabytes */
832 DISPLAY ('!','M','E','M','O','R','Y',' ')
837 #define SMBOFFS(reg) I82371_SMB_SMB##reg
845 /* i2cread (unsigned dev, unsigned offs) */
847 li t0,PHYS_TO_K1(ISAPORT_BASE(SMB_PORT))
849 lbu t1,SMBOFFS(HSTSTS)(t0)
850 and t1,~(I82371_SMB_FAILED|I82371_SMB_BUS_ERR|I82371_SMB_DEV_ERR|I82371_SMB_INTER)
851 sb t1,SMBOFFS(HSTSTS)(t0)
854 or t1,0xa1 # DIMM base address and read bit
855 sb t1,SMBOFFS(HSTADD)(t0)
856 sb a1,SMBOFFS(HSTCMD)(t0)
859 li t1,I82371_SMB_START|I82371_SMB_BDRW
860 sb t1,SMBOFFS(HSTCNT)(t0)
863 1: lbu t1,SMBOFFS(HSTSTS)(t0)
864 and t2,t1,I82371_SMB_FAILED|I82371_SMB_BUS_ERR|I82371_SMB_DEV_ERR|I82371_SMB_INTER
870 # clear pending errors/interrupts
871 sb t1,SMBOFFS(HSTSTS)(t0)
873 and t2,t1,I82371_SMB_FAILED|I82371_SMB_BUS_ERR|I82371_SMB_DEV_ERR
876 lbu v0,SMBOFFS(HSTDAT0)(t0)
890 #define BONITO_INIT(r,v) WR_INIT(W,BONITO_BASE+BONITO_##r,v)
891 #define BONITO_BIS(r,b) RMW_INIT(W,BONITO_BASE+BONITO_##r,~0,b)
892 #define BONITO_BIC(r,b) RMW_INIT(W,BONITO_BASE+BONITO_##r,~(b),0)
893 #define BONITO_RMW(r,c,s) RMW_INIT(W,BONITO_BASE+BONITO_##r,~(c),s)
895 #define CFGADDR(idsel,function,reg) ((1<<(11+(idsel)))+((function)<<8)+(reg))
896 /* generic ISA Bridge (PIIX) configuration accesses */
897 #define _ISABWR_INIT(mod,function,isabreg,val) \
898 WR_INIT(W,BONITO_BASE+BONITO_PCIMAP_CFG,CFGADDR(PCI_DEV_I82371,function,isabreg)>>16) ; \
899 RD_INIT(W,BONITO_BASE+BONITO_PCIMAP_CFG) ; \
900 WR_INIT(mod,PCI_CFG_SPACE+(CFGADDR(PCI_DEV_I82371,function,isabreg)&0xffff),val)
901 #define _ISABRD_INIT(mod,function,isabreg) \
902 WR_INIT(W,BONITO_BASE+BONITO_PCIMAP_CFG,CFGADDR(PCI_DEV_I82371,function,isabreg)>>16) ; \
903 RD_INIT(W,BONITO_BASE+BONITO_PCIMAP_CFG) ; \
904 RD_INIT(mod,PCI_CFG_SPACE+(CFGADDR(PCI_DEV_I82371,function,isabreg)&0xffff))
906 /* generic ISA I/O accesses */
907 #define _ISAWR_INIT(isareg,val) \
908 WR_INIT(B,PCI_IO_SPACE+(isareg),val)
909 #define _ISARD_INIT(isareg) \
910 RD_INIT(B,PCI_IO_SPACE+(isareg))
912 /* ISA Bridge (PIIX) configuration accesses */
915 * byte swapper disabled for config cycles
916 * twiddle addresses but not data
918 #define ISABBWR_INIT(function,isabreg,val) \
919 _ISABWR_INIT(B,function,(isabreg)^3,val)
920 #define ISABHWR_INIT(function,isabreg,val) \
921 _ISABWR_INIT(H,function,(isabreg)^2,val)
922 #define ISABWWR_INIT(function,isabreg,val) \
923 _ISABWR_INIT(W,function,isabreg,val)
925 #define ISABBWR_INIT(function,isabreg,val) \
926 _ISABWR_INIT(B,function,(isabreg),val)
927 #define ISABHWR_INIT(function,isabreg,val) \
928 _ISABWR_INIT(H,function,(isabreg),val)
929 #define ISABWWR_INIT(function,isabreg,val) \
930 _ISABWR_INIT(W,function,isabreg,val)
933 /* ISA I/O accesses */
934 #define ISAWR_INIT(isareg,val) \
935 _ISAWR_INIT(isareg,val)
936 #define ISARD_INIT(isareg) \
939 #define DISPLAY_INIT(d0,d1,d2,d3,d4,d5,d6,d7) \
940 WR_INIT(W, LED_BASE+HD2532_CRAM+HD2532_CHAR(0), 0+d0); \
941 WR_INIT(W, LED_BASE+HD2532_CRAM+HD2532_CHAR(1), 0+d1); \
942 WR_INIT(W, LED_BASE+HD2532_CRAM+HD2532_CHAR(2), 0+d2); \
943 WR_INIT(W, LED_BASE+HD2532_CRAM+HD2532_CHAR(3), 0+d3); \
944 WR_INIT(W, LED_BASE+HD2532_CRAM+HD2532_CHAR(4), 0+d4); \
945 WR_INIT(W, LED_BASE+HD2532_CRAM+HD2532_CHAR(5), 0+d5); \
946 WR_INIT(W, LED_BASE+HD2532_CRAM+HD2532_CHAR(6), 0+d6); \
947 WR_INIT(W, LED_BASE+HD2532_CRAM+HD2532_CHAR(7), 0+d7)
949 #define ISAREFRESH (PT_CRYSTAL/(1000000/15))
952 /* bonito endianess */
954 BONITO_BIS(BONPONCFG,BONITO_BONPONCFG_CPUBIGEND)
955 BONITO_BIS(BONGENCFG,BONITO_BONGENCFG_BYTESWAP|BONITO_BONGENCFG_MSTRBYTESWAP)
957 BONITO_BIC(BONPONCFG,BONITO_BONPONCFG_CPUBIGEND)
958 BONITO_BIC(BONGENCFG,BONITO_BONGENCFG_BYTESWAP|BONITO_BONGENCFG_MSTRBYTESWAP)
960 BONITO_BIS(BONPONCFG, BONITO_BONPONCFG_IS_ARBITER|BONITO_BONPONCFG_PCIRESET_OUT)
962 /* Bonito PIO initialisation */
964 BONITO_INIT(GPIODATA,PIO_PIIXRESET) # initial value
965 BONITO_INIT(GPIOIE,PIO_IE)
967 /* Clear PCI reset and enable PIIX */
969 BONITO_BIC(BONPONCFG,BONITO_BONPONCFG_PCIRESET_OUT)
971 BONITO_BIC(GPIODATA,PIO_PIIXRESET)
972 DELAY_INIT(ROMMS(50))
974 /* PCI bus and PIIX should now be usable */
976 BONITO_BIS(PCICMD, BONITO_PCICMD_PERRRESPEN)
978 BONITO_BIS(PCICMD, PCI_COMMAND_IO_ENABLE|PCI_COMMAND_MEM_ENABLE|PCI_COMMAND_MASTER_ENABLE)
980 /* enable i/o buffer cache and other go faster bits */
981 BONITO_BIS(BONGENCFG, \
982 BONITO_BONGENCFG_BUSERREN| \
983 BONITO_BONGENCFG_PREFETCHEN| \
984 BONITO_BONGENCFG_WBEHINDEN| \
985 BONITO_BONGENCFG_PCIQUEUE| \
986 BONITO_BONGENCFG_SNOOPEN)
989 BONITO_BIS(BONGENCFG, BONITO_BONGENCFG_DEBUGMODE)
991 BONITO_BIS(IODEVCFG, BONITO_IODEVCFG_BUFFBIT_CS0|\
992 BONITO_IODEVCFG_BUFFBIT_CS1|\
993 BONITO_IODEVCFG_SPEEDBIT_CS2|BONITO_IODEVCFG_BUFFBIT_CS2|\
994 BONITO_IODEVCFG_SPEEDBIT_CS3|BONITO_IODEVCFG_BUFFBIT_CS3|\
995 BONITO_IODEVCFG_BUFFBIT_IDE)
997 /* switch on the LED */
998 WR_INIT(W, LED_BASE+HD2532_CW,HD2532_CW_C)
999 DELAY_INIT(ROMUS(110))
1002 * Initialise the ISA bridge via its CONF space
1005 DISPLAY_INIT ('I','s','a','B','r','i','d','g')
1007 /* Turn most special purpose pins into GPIO; set ISA mode */
1008 ISABWWR_INIT(0, I82371_GENCFG, I82371_GENCFG_CFG)
1010 /* disable RTC & KBD chip selects */
1011 ISABHWR_INIT(0, I82371_XBCS, 0)
1013 /* Enable PCI 2.1 timing support */
1014 ISABBWR_INIT(0, I82371_DLC, I82371_DLC_DT /* | I82371_DLC_PR */ | I82371_DLC_USBPR | I82371_DLC_DTTE)
1016 /* Set top of memory to 16MB, so all ISA bus master & DMA
1017 accesses are forwarded to PCI mem space
1019 ISABBWR_INIT(0, I82371_TOM, I82371_TOM_TOM(16) | I82371_TOM_FWD_LBIOS | I82371_TOM_FWD_AB | I82371_TOM_FWD_89)
1021 /* disable the internal RTC */
1022 ISABBWR_INIT(0, I82371_RTCCFG, 0);
1024 /* Set the SMB base address */
1025 ISABWWR_INIT(3, I82371_PCI3_SMBBA, SMB_PORT|PCI_MAP_IO)
1026 /* enable the host controller */
1027 ISABBWR_INIT(3, I82371_PCI3_SMBHSTCFG, I82371_PCI3_SMB_HST_EN)
1028 /* enable the SMB IO ports */
1029 ISABBWR_INIT(3, PCI_COMMAND_STATUS_REG, PCI_COMMAND_IO_ENABLE)
1031 /* Set the PIIX power management base address */
1032 ISABWWR_INIT(3, I82371_PCI3_PMBA, PM_PORT|PCI_MAP_IO)
1033 /* enable the power management ports */
1034 ISABBWR_INIT(3, I82371_PCI3_PMREGMISC, I82371_PCI3_PMIOSE)
1036 /* Initialise ISA bus low-level I/O devices */
1037 DISPLAY_INIT('I','s','a','D','e','v',' ',' ')
1039 /* 15us ISA bus refresh clock */
1040 #define ISAREFRESH (PT_CRYSTAL/(1000000/15))
1042 ISARD_INIT(CTC_PORT+PT_CONTROL)
1044 /* program i8254 ISA refresh counter */
1045 ISAWR_INIT(CTC_PORT+PT_CONTROL,PTCW_SC(PT_REFRESH)|PTCW_16B|PTCW_MODE(MODE_RG))
1046 ISAWR_INIT(CTC_PORT+PT_REFRESH, ISAREFRESH & 0xff)
1047 ISAWR_INIT(CTC_PORT+PT_REFRESH, ISAREFRESH >> 8)
1049 /* program ISA ICU */
1050 ISAWR_INIT(ICU1_PORT, 0x11) /* ICW1 */
1051 ISAWR_INIT(ICU1_PORT+1,0x00) /* ICW2: vector */
1052 ISAWR_INIT(ICU1_PORT+1,0x04) /* ICW3: cascade on IRQ2 */
1053 ISAWR_INIT(ICU1_PORT+1,0x01) /* ICW4: 8086 mode */
1054 ISAWR_INIT(ICU1_PORT+1,0xff) /* OCW1: mask all */
1056 ISAWR_INIT(ICU2_PORT, 0x11) /* ICW1 */
1057 ISAWR_INIT(ICU2_PORT+1,0x08) /* ICW2: vector */
1058 ISAWR_INIT(ICU2_PORT+1,0x02) /* ICW3: */
1059 ISAWR_INIT(ICU2_PORT+1,0x01) /* ICW4: 8086 mode */
1060 ISAWR_INIT(ICU2_PORT+1,0xff) /* OCW1: mask all */
1062 ISAWR_INIT(ICU1_PORT+1,~(1<<2)) /* enable IRQ2 */
1064 /* set up ISA devices */
1066 /* select logical device 1 (mouse) */
1067 ISAWR_INIT(ISAPNP_MBADDR,ISAPNP_LOGICAL_DEV_NUM)
1068 ISAWR_INIT(ISAPNP_MBDATA,1)
1069 ISAWR_INIT(ISAPNP_MBADDR,ISAPNP_ACTIVATE)
1070 ISAWR_INIT(ISAPNP_MBDATA,1)
1072 /* select logical device 4 (parallel) */
1073 ISAWR_INIT(ISAPNP_MBADDR,ISAPNP_LOGICAL_DEV_NUM)
1074 ISAWR_INIT(ISAPNP_MBDATA,4)
1075 ISAWR_INIT(ISAPNP_MBADDR,ISAPNP_IO_DESC0+ISAPNP_IO_BASE_15_8)
1076 ISAWR_INIT(ISAPNP_MBDATA,(ECP_PORT>>8) & 0xff)
1077 ISAWR_INIT(ISAPNP_MBADDR,ISAPNP_IO_DESC0+ISAPNP_IO_BASE_7_0)
1078 ISAWR_INIT(ISAPNP_MBDATA,ECP_PORT & 0xff)
1079 ISAWR_INIT(ISAPNP_MBADDR,ISAPNP_IRQ_DESC0+ISAPNP_IRQ_CONTROL)
1080 ISAWR_INIT(ISAPNP_MBDATA,ISAPNP_IRQ_HIGH)
1081 ISAWR_INIT(ISAPNP_MBADDR,ISAPNP_ACTIVATE)
1082 ISAWR_INIT(ISAPNP_MBDATA,1)
1084 /* select logical device 5 (COM2) */
1085 ISAWR_INIT(ISAPNP_MBADDR,ISAPNP_LOGICAL_DEV_NUM)
1086 ISAWR_INIT(ISAPNP_MBDATA,5)
1087 ISAWR_INIT(ISAPNP_MBADDR,ISAPNP_ACTIVATE)
1088 ISAWR_INIT(ISAPNP_MBDATA,1)
1090 /* select logical device 6 (COM1) */
1091 ISAWR_INIT(ISAPNP_MBADDR,ISAPNP_LOGICAL_DEV_NUM)
1092 ISAWR_INIT(ISAPNP_MBDATA,6)
1093 ISAWR_INIT(ISAPNP_MBADDR,ISAPNP_ACTIVATE)
1094 ISAWR_INIT(ISAPNP_MBDATA,1)
1098 DISPLAY_INIT('I','n','i','t','d','o','n','e')
1104 #define M_SR_DE _MM_MAKEMASK1(16)
1110 or t1,v0,t0 # disable cache/parity errors (SR_DE = 1)
1112 1: not t1,t0 # enable cache/parity errors (SR_DE = 0)
1115 and v0,t0 # get old SR_DE bit
1116 xor v0,t0 # and invert to make it an enable bit
1139 li t1,CACHEMISS+ROMCYCLE
1141 beq t0,CFG_C_UNCACHED,1f
1142 and t0,ra,0x20000000
1149 subu a0,48 # approx number of loops so far