3 * Copyright (c) 2001 Opsycon AB (www.opsycon.se)
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Opsycon AB, Sweden.
16 * 4. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
20 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42 #include "pmon/dev/ns16550.h"
43 #include "target/prid.h"
44 #include "target/sbd.h"
45 #include "target/bonito.h"
46 #include "target/via686b.h"
47 #include "target/i8254.h"
48 #include "target/isapnpreg.h"
53 .rdata;98: .asciz x; .text; la a0, 98b; bal stringserial; nop
59 .rdata;98: .asciz x; .text; la a0, 98b; bal stringserial; nop
61 #define CONFIG_CACHE_64K_4WAY 1
69 #define CP0_CONFIG $16
73 #define DDR100 0x1d441091
75 #define DDR100 0x0c011091*/
76 #define DDR266 0x0410435e
77 #define DDR300 0x041453df
82 * s0 link versus load offset, used to relocate absolute adresses.
86 * s4 Bonito base address.
101 stack = start - 0x4000 /* Place PMON stack below PMON start in RAM */
103 /* NOTE!! Not more that 16 instructions here!!! Right now it's FULL! */
104 mtc0 zero, COP_0_STATUS_REG
105 mtc0 zero, COP_0_CAUSE_REG
106 li t0, SR_BOOT_EXC_VEC /* Exception to Boostrap Location */
107 mtc0 t0, COP_0_STATUS_REG
111 bal uncached /* Switch to uncached address space */
114 bal locate /* Get current execute address */
118 or ra, UNCACHED_MEMORY_ADDR
123 * Reboot vector usable from outside pmon.
143 * Exception vectors here for rom, before we are up and running. Catch
144 * whatever comes up before we have a fully fledged exception handler.
146 .align 9 /* bfc00200 */
152 .align 7 /* bfc00280 */
159 .align 8 /* bfc00300 */
160 PRINTSTR("\r\nPANIC! Unexpected Cache Error exception! ")
161 mfc0 a0, COP_0_CACHE_ERR
166 /* General exception */
167 .align 7 /* bfc00380 */
173 .align 8 /* bfc00400 */
181 PRINTSTR("\r\nCAUSE=")
182 mfc0 a0, COP_0_CAUSE_REG
185 PRINTSTR("\r\nSTATUS=")
186 mfc0 a0, COP_0_STATUS_REG
189 PRINTSTR("\r\nERRORPC=")
190 mfc0 a0, COP_0_ERROR_PC
194 mfc0 a0, COP_0_EXC_PC
197 PRINTSTR("\r\nDERR0=")
198 cfc0 a0, COP_0_DERR_0
201 PRINTSTR("\r\nDERR1=")
202 cfc0 a0, COP_0_DERR_1
206 // b ext_map_and_reboot
229 * We get here from executing a bal to get the PC value of the current execute
230 * location into ra. Check to see if we run from ROM or if this is ramloaded.
237 li t0,SR_BOOT_EXC_VEC
238 mtc0 t0,COP_0_STATUS_REG
239 mtc0 zero,COP_0_CAUSE_REG
242 li bonito,PHYS_TO_UNCACHED(BONITO_REG_BASE)
244 #define MOD_MASK 0x00000003
245 #define MOD_B 0x00000000 /* byte "modifier" */
246 #define MOD_H 0x00000001 /* halfword "modifier" */
247 #define MOD_W 0x00000002 /* word "modifier" */
249 # define MOD_D 0x00000003 /* doubleword "modifier" */
252 #define OP_MASK 0x000000fc
253 #define OP_EXIT 0x00000000 /* exit (status) */
254 #define OP_DELAY 0x00000008 /* delay (cycles) */
255 #define OP_RD 0x00000010 /* read (addr) */
256 #define OP_WR 0x00000014 /* write (addr, val) */
257 #define OP_RMW 0x00000018 /* read-modify-write (addr, and, or) */
258 #define OP_WAIT 0x00000020 /* wait (addr, mask, value) */
260 #define WR_INIT(mod,addr,val) \
261 .word OP_WR|mod,PHYS_TO_UNCACHED(addr);\
264 #define RD_INIT(mod,addr) \
265 .word OP_RD|mod,PHYS_TO_UNCACHED(addr);\
268 #define RMW_INIT(mod,addr,and,or) \
269 .word OP_RMW|mod,PHYS_TO_UNCACHED(addr);\
272 #define WAIT_INIT(mod,addr,and,or) \
273 .word OP_WAIT|mod,PHYS_TO_UNCACHED(addr);\
276 #define DELAY_INIT(cycles) \
277 .word OP_DELAY,(cycles);\
280 #define EXIT_INIT(status) \
281 .word OP_EXIT,(status);\
284 #define BONITO_INIT(r,v) WR_INIT(MOD_W,BONITO_BASE+/**/r,v)
285 #define BONITO_BIS(r,b) RMW_INIT(MOD_W,BONITO_BASE+(r),~0,b)
286 #define BONITO_BIC(r,b) RMW_INIT(MOD_W,BONITO_BASE+(r),~(b),0)
287 #define BONITO_RMW(r,c,s) RMW_INIT(MOD_W,BONITO_BASE+(r),~(c),s)
289 #define CFGADDR(idsel,function,reg) ((1<<(11+(idsel)))+((function)<<8)+(reg))
290 #define _ISABWR_INIT(mod,function,isabreg,val) \
291 WR_INIT(MOD_W,BONITO_BASE+BONITO_PCIMAP_CFG,CFGADDR(PCI_IDSEL_VIA686B,function,isabreg)>>16) ; \
292 RD_INIT(MOD_W,BONITO_BASE+BONITO_PCIMAP_CFG) ; \
293 WR_INIT(mod,PCI_CFG_SPACE+(CFGADDR(PCI_IDSEL_VIA686B,function,isabreg)&0xffff),val)
295 #define _ISABRD_INIT(mod,function,isabreg) \
296 WR_INIT(MOD_W,BONITO_BASE+BONITO_PCIMAP_CFG,CFGADDR(PCI_IDSEL_VIA686B,function,isabreg)>>16) ; \
297 RD_INIT(MOD_W,BONITO_BASE+BONITO_PCIMAP_CFG) ; \
298 RD_INIT(mod,PCI_CFG_SPACE+(CFGADDR(PCI_IDSEL_VIA686B,function,isabreg)&0xffff))
301 #define _ISAWR_INIT(isareg,val) \
302 WR_INIT(MOD_B,PCI_IO_SPACE+(isareg),val)
304 #define _ISARD_INIT(isareg) \
305 RD_INIT(MOD_B,PCI_IO_SPACE+(isareg))
308 #define ISABBWR_INIT(function,isabreg,val) \
309 _ISABWR_INIT(MOD_B,function,(isabreg),val)
310 #define ISABHWR_INIT(function,isabreg,val) \
311 _ISABWR_INIT(MOD_H,function,(isabreg),val)
312 #define ISABWWR_INIT(function,isabreg,val) \
313 _ISABWR_INIT(MOD_W,function,isabreg,val)
314 #define ISAWR_INIT(isareg,val) \
315 _ISAWR_INIT(isareg,val)
316 #define ISARD_INIT(isareg) \
322 /* bonito endianess */
323 BONITO_BIC(BONITO_BONPONCFG,BONITO_BONPONCFG_CPUBIGEND)
324 BONITO_BIC(BONITO_BONGENCFG,BONITO_BONGENCFG_BYTESWAP|BONITO_BONGENCFG_MSTRBYTESWAP)
325 BONITO_BIS(BONITO_BONPONCFG, BONITO_BONPONCFG_IS_ARBITER)
328 * In certain situations it is possible for the Bonito ASIC
329 * to come up with the PCI registers uninitialised, so do them here
331 #define PCI_CLASS_BRIDGE 0x06
332 #define PCI_CLASS_SHIFT 24
333 #define PCI_SUBCLASS_BRIDGE_HOST 0x00
334 #define PCI_SUBCLASS_SHIFT 16
335 #define PCI_COMMAND_IO_ENABLE 0x00000001
336 #define PCI_COMMAND_MEM_ENABLE 0x00000002
337 #define PCI_COMMAND_MASTER_ENABLE 0x00000004
338 #define PCI_COMMAND_STATUS_REG 0x04
339 #define PCI_MAP_IO 0X00000001
340 #define PCI_CFG_SPACE BONITO_PCICFG_BASE
342 BONITO_INIT(BONITO_PCICLASS,(PCI_CLASS_BRIDGE << PCI_CLASS_SHIFT) | (PCI_SUBCLASS_BRIDGE_HOST << PCI_SUBCLASS_SHIFT))
343 BONITO_INIT(BONITO_PCICMD, BONITO_PCICMD_PERR_CLR|BONITO_PCICMD_SERR_CLR|BONITO_PCICMD_MABORT_CLR|BONITO_PCICMD_MTABORT_CLR|BONITO_PCICMD_TABORT_CLR|BONITO_PCICMD_MPERR_CLR)
344 //BONITO_INIT(BONITO_PCILTIMER, 0)
345 BONITO_INIT(BONITO_PCILTIMER, 255)
346 BONITO_INIT(BONITO_PCIBASE0, 0)
347 BONITO_INIT(BONITO_PCIBASE1, 0)
348 BONITO_INIT(BONITO_PCIBASE2, 0)
349 BONITO_INIT(BONITO_PCIEXPRBASE, 0)
350 BONITO_INIT(BONITO_PCIINT, 0)
352 BONITO_BIS(BONITO_PCICMD, BONITO_PCICMD_PERRRESPEN)
354 BONITO_BIS(BONITO_PCICMD, PCI_COMMAND_IO_ENABLE|PCI_COMMAND_MEM_ENABLE|PCI_COMMAND_MASTER_ENABLE)
356 BONITO_BIC(BONITO_BONGENCFG, 0x80) #½ûÖ¹iobc
358 #BONITO_BIS(BONITO_BONGENCFG, BONITO_BONGENCFG_BUSERREN)
361 BONITO_BIS(BONITO_BONGENCFG, BONITO_BONGENCFG_DEBUGMODE)
363 /******** added to init southbridge*/
365 /* Set the SMB base address */
366 ISABWWR_INIT(4, SMBUS_IO_BASE_ADDR, SMBUS_IO_BASE_VALUE | 0x1)
367 /* enable the host controller */
368 ISABHWR_INIT(4, SMBUS_HOST_CONFIG_ADDR, SMBUS_HOST_CONFIG_ENABLE_BIT)
369 /* enable the SMB IO ports */
370 ISABBWR_INIT(4, PCI_COMMAND_STATUS_REG, PCI_COMMAND_IO_ENABLE)
372 /* 15us ISA bus refresh clock */
373 #define ISAREFRESH (PT_CRYSTAL/(1000000/15))
374 ISARD_INIT(CTC_PORT+PT_CONTROL)
376 /* program i8254 ISA refresh counter */
377 ISAWR_INIT(CTC_PORT+PT_CONTROL,PTCW_SC(PT_REFRESH)|PTCW_16B|PTCW_MODE(MODE_RG))
378 ISAWR_INIT(CTC_PORT+PT_REFRESH, ISAREFRESH & 0xff)
379 ISAWR_INIT(CTC_PORT+PT_REFRESH, ISAREFRESH >> 8)
392 reginit: /* local name */
410 8: bne t4, OP_DELAY, 8f
536 * WAIT(ADDR,MASK,VAL)
582 .next: addu a0,Init_Size
599 PRINTSTR("\r\nPMON2000 MIPS Initializing. Standby...\r\n")
601 mfc0 a0, COP_0_ERROR_PC
606 mfc0 a0, COP_0_CONFIG
630 * Now determine DRAM configuration and size by
631 * reading the I2C EEROM on the DIMMS
633 PRINTSTR("DIMM read\r\n")
635 /* only one memory slot, slave address is 1010000b */
662 # set some parameters for DDR333
663 # rank number and DDR type field will be filled later
664 # to check: fix TCAS?
669 /* read DIMM memory type (must be DDRAM) */
675 PRINTSTR("read memory type\r\n")
677 /* read DIMM number of rows */
688 PRINTSTR("read number of rows\r\n")
690 2: /* read DIMM number of cols */
763 33: PRINTSTR("DDR type not supported!\r\n");
768 #bit 25:22 is DDR type field
773 /* read DIMM memory size per side */
780 sll tmpsize,v0,22 # multiply by 4M
781 PRINTSTR("read memory size per side\r\n")
783 2: /* read DIMM number of blocks-per-ddrram */
791 PRINTSTR("read blocks per ddrram\r\n")
793 2: /* read DIMM number of sides (banks) */
801 sll tmpsize,1 # msize *= 2
803 PRINTSTR("read number of sides\r\n")
805 2: /* read DIMM width */
813 PRINTSTR("read width\r\n")
815 2: addu msize,tmpsize
821 PRINTSTR ("\r\nNo DIMM in slot ")
828 li sdCfg,0x255043df /* zgj-8-7-14-13 */
829 # li sdCfg,0x3d9043df
832 PRINTSTR("DIMM SIZE=")
841 #### gx 2006-03-17: mode ####
865 li t1,0 # accumulate pcimembasecfg settings
867 /* set bar0 mask and translation to point to SDRAM */
870 srl t0,BONITO_PCIMEMBASECFG_ASHIFT-BONITO_PCIMEMBASECFG_MEMBASE0_MASK_SHIFT
871 and t0,BONITO_PCIMEMBASECFG_MEMBASE0_MASK
875 srl t0,BONITO_PCIMEMBASECFG_ASHIFT-BONITO_PCIMEMBASECFG_MEMBASE0_TRANS_SHIFT
876 and t0,BONITO_PCIMEMBASECFG_MEMBASE0_TRANS
878 or t1,BONITO_PCIMEMBASECFG_MEMBASE0_CACHED
880 /* set bar1 to minimum size to conserve PCI space */
882 srl t0,BONITO_PCIMEMBASECFG_ASHIFT-BONITO_PCIMEMBASECFG_MEMBASE1_MASK_SHIFT
883 and t0,BONITO_PCIMEMBASECFG_MEMBASE1_MASK
887 srl t0,BONITO_PCIMEMBASECFG_ASHIFT-BONITO_PCIMEMBASECFG_MEMBASE1_TRANS_SHIFT
888 and t0,BONITO_PCIMEMBASECFG_MEMBASE1_TRANS
890 or t1,BONITO_PCIMEMBASECFG_MEMBASE1_CACHED
892 sw t1,BONITO_PCIMEMBASECFG(bonito)
894 /* enable configuration cycles now */
895 lw t0,BONITO_BONPONCFG(bonito)
896 and t0,~BONITO_BONPONCFG_CONFIG_DIS
897 sw t0,BONITO_BONPONCFG(bonito)
899 PRINTSTR("Init SDRAM Done!\r\n");
901 * Reset and initialize caches to a known state.
903 #define IndexStoreTagI 0x08
904 #define IndexStoreTagD 0x09
905 #define IndexStoreTagS 0x0b
906 #define IndexStoreTagT 0x0a
910 * RM7000 config register bits.
912 #define CF_7_SE (1 << 3) /* Secondary cache enable */
913 #define CF_7_SC (1 << 31) /* Secondary cache not present */
914 #define CF_7_TE (1 << 12) /* Tertiary cache enable */
915 #define CF_7_TC (1 << 17) /* Tertiary cache not present */
916 #define CF_7_TS (3 << 20) /* Tertiary cache size */
917 #define CF_7_TS_AL 20 /* Shift to align */
918 #define NOP8 nop;nop;nop;nop;nop;nop;nop;nop
920 TTYDBG("Sizing caches...\r\n");
922 mfc0 t3, COP_0_CONFIG /* t3 = original config */
923 and t3, 0xffffeff0 /* Make sure coherency is OK */
925 and t3, ~(CF_7_TE|CF_7_SE|CF_7_TC|CF_7_SC) /* disable L2/L3 cache */
926 mtc0 t3, COP_0_CONFIG
932 sllv s3, t2, t1 /* s3 = I cache size */
934 #ifdef CONFIG_CACHE_64K_4WAY
940 addu s4, t1, 16 /* s4 = I cache line size */
944 sllv s5, t2, t1 /* s5 = D cache size */
946 #ifdef CONFIG_CACHE_64K_4WAY
951 addu s6, t1, 16 /* s6 = D cache line size */
952 TTYDBG("Init caches...\r\n")
954 li s7, 0 /* no L2 cache */
955 li s8, 0 /* no L3 cache */
963 TTYDBG("godson2 caches found\r\n")
964 bal godson2_cache_init
972 and a0,a0,~((1<<12) | 3)
977 TTYDBG("Init caches done, cfg = ")
978 mfc0 a0, COP_0_CONFIG
992 TTYDBG("Testing memory...\r\n")
996 li t0, 0xa0000000+1*1024*1024
1014 and t4, t1, 0x000fffff
1023 TTYDBG("Memory test failed at ");
1027 TTYDBG("\r\nWrite=");
1031 TTYDBG("\r\nRead=");
1039 TTYDBG("Testing ok...\r\n");
1049 #include "machine/newtest/mydebug.S"
1051 TTYDBG("Copy PMON to execute location...\r\n")
1053 TTYDBG(" start = 0x")
1057 TTYDBG("\r\n s0 = 0x")
1075 /* copy text section */
1077 1: and t3,t0,0x0000ffff
1094 PRINTSTR("\ncopy text section done.\r\n")
1104 TTYDBG("Copy PMON to execute location done.\r\n")
1108 TTYDBG("Testing...\r\n")
1114 /* subu s6, a2, a0*/
1120 /* copy text section */
1144 TTYDBG ("test ok!\r\n")
1159 sw a0, CpuTertiaryCacheSize /* Set L3 cache size */
1162 mfc0 a0,COP_0_CONFIG
1163 and a0,a0,0xfffffff8
1165 mtc0 a0,COP_0_CONFIG
1170 /* pass pointer to kseg1 tgt_putchar */
1182 TTYDBG("Dumping GT64240 setup.\r\n")
1183 TTYDBG("offset----data------------------------.\r\n")
1214 * Clear the TLB. Normally called from start.S.
1222 li a3, 0 # First TLB index.
1225 MTC0 a2, COP_0_TLB_PG_MASK # Whatever...
1228 MTC0 zero, COP_0_TLB_HI # Clear entry high.
1229 MTC0 zero, COP_0_TLB_LO0 # Clear entry low0.
1230 MTC0 zero, COP_0_TLB_LO1 # Clear entry low1.
1232 mtc0 a3, COP_0_TLB_INDEX # Set the index.
1237 tlbwi # Write the TLB
1247 * Set up the TLB. Normally called from start.S.
1250 li a3, 0 # First TLB index.
1253 MTC0 a2, COP_0_TLB_PG_MASK # All pages are 16Mb.
1257 MTC0 a2, COP_0_TLB_HI # Set up entry high.
1260 srl a2, a0, PG_SHIFT
1261 and a2, a2, PG_FRAME
1263 MTC0 a2, COP_0_TLB_LO0 # Set up entry low0.
1264 addu a2, (0x01000000 >> PG_SHIFT)
1265 MTC0 a2, COP_0_TLB_LO1 # Set up entry low1.
1267 mtc0 a3, COP_0_TLB_INDEX # Set the index.
1272 tlbwi # Write the TLB
1275 addu a0, a2 # Step address 32Mb.
1337 la v0, COM1_BASE_ADDR
1338 # la v0, COM3_BASE_ADDR
1340 lbu v1, NSREG(NS16550_LSR)(v0)
1345 sb a0, NSREG(NS16550_DATA)(v0)
1348 la v0, COM3_BASE_ADDR
1356 /* baud rate definitions, matching include/termios.h */
1371 #define B19200 19200
1372 #define B38400 38400
1373 #define B57600 57600
1374 #define B115200 115200
1377 la v0, COM1_BASE_ADDR
1378 # la v0, COM3_BASE_ADDR
1380 li v1, FIFO_ENABLE|FIFO_RCV_RST|FIFO_XMT_RST|FIFO_TRIGGER_4
1381 sb v1, NSREG(NS16550_FIFO)(v0)
1383 sb v1, NSREG(NS16550_CFCR)(v0)
1384 li v1, NS16550HZ/(16*CONS_BAUD)/2
1385 sb v1, NSREG(NS16550_DATA)(v0)
1387 sb v1, NSREG(NS16550_IER)(v0)
1389 sb v1, NSREG(NS16550_CFCR)(v0)
1390 li v1, MCR_DTR|MCR_RTS
1391 sb v1, NSREG(NS16550_MCR)(v0)
1393 sb v1, NSREG(NS16550_IER)(v0)
1401 /* a0: slave address
1405 /* set device address */
1406 li v0, 0xbfd00000 + SMBUS_HOST_ADDRESS
1410 /* store register offset */
1411 li v0, 0xbfd00000 + SMBUS_HOST_COMMAND
1414 /* read byte data protocol */
1416 li v1, 0xbfd00000 + SMBUS_HOST_CONTROL
1419 /* make sure SMB host ready to start, important!--zfx */
1420 li v1, 0xbfd00000 + SMBUS_HOST_STATUS
1426 lbu v0, 0(v1) #flush the write
1430 li v1, 0xbfd00000 + SMBUS_HOST_CONTROL
1436 li v1, 0xbfd00000 + SMBUS_HOST_STATUS
1448 andi v0, SMBUS_HOST_STATUS_BUSY
1452 li v1, 0xbfd00000 + SMBUS_HOST_STATUS
1458 lbu v0, 0(v1) #flush the write
1461 li v1, 0xbfd00000 + SMBUS_HOST_DATA0
1476 .asciz "\r\nInvalid transmit pattern. Must be DDDD or DDxDDx\r\n"
1478 .asciz "\r\nPANIC! Unexpected TLB refill exception!\r\n"
1480 .asciz "\r\nPANIC! Unexpected XTLB refill exception!\r\n"
1482 .asciz "\r\nPANIC! Unexpected General exception!\r\n"
1484 .asciz "\r\nPANIC! Unexpected Interrupt exception!\r\n"
1486 .ascii "0123456789abcdef"
1491 * I2C Functions used in early startup code to get SPD info from
1492 * SDRAM modules. This code must be entirely PIC and RAM independent.
1496 #define DELAY(count) \
1503 #define I2C_INT_ENABLE 0x80
1504 #define I2C_ENABLE 0x40
1505 #define I2C_ACK 0x04
1506 #define I2C_INT_FLAG 0x08
1507 #define I2C_STOP_BIT 0x10
1508 #define I2C_START_BIT 0x20
1510 #define I2C_AMOD_RD 0x01
1512 #define BUS_ERROR 0x00
1513 #define START_CONDITION_TRA 0x08
1514 #define RSTART_CONDITION_TRA 0x10
1515 #define ADDR_AND_WRITE_BIT_TRA_ACK_REC 0x18
1516 #define ADDR_AND_READ_BIT_TRA_ACK_REC 0x40
1517 #define SLAVE_REC_WRITE_DATA_ACK_TRA 0x28
1518 #define MAS_REC_READ_DATA_ACK_NOT_TRA 0x58
1520 #define Index_Store_Tag_D 0x05
1521 #define Index_Invalidate_I 0x00
1522 #define Index_Writeback_Inv_D 0x01
1523 #define Index_Store_Tag_S 0x0b
1524 #define Index_Writeback_Inv_S 0x03
1531 LEAF(godson2_cache_init)
1552 #a0=0x80000000, a1=icache_size, a2=dcache_size
1553 #a3, v0 and v1 used as local registers
1561 cache Index_Store_Tag_D, 0x0(v0)
1563 cache Index_Store_Tag_D, 0x1(v0)
1565 cache Index_Store_Tag_D, 0x2(v0)
1567 cache Index_Store_Tag_D, 0x3(v0)
1576 addu v1, a0, 128*1024
1581 cache Index_Store_Tag_S, 0x0(v0)
1583 cache Index_Store_Tag_S, 0x1(v0)
1585 cache Index_Store_Tag_S, 0x2(v0)
1587 cache Index_Store_Tag_S, 0x3(v0)
1595 addu v1, a0, 128*1024
1599 cache Index_Writeback_Inv_S, 0x0(v0)
1600 cache Index_Writeback_Inv_S, 0x1(v0)
1601 cache Index_Writeback_Inv_S, 0x2(v0)
1602 cache Index_Writeback_Inv_S, 0x3(v0)
1614 cache Index_Invalidate_I, 0x0(v0)
1615 # cache Index_Invalidate_I, 0x1(v0)
1616 # cache Index_Invalidate_I, 0x2(v0)
1617 # cache Index_Invalidate_I, 0x3(v0)
1627 cache Index_Writeback_Inv_D, 0x0(v0)
1628 cache Index_Writeback_Inv_D, 0x1(v0)
1629 cache Index_Writeback_Inv_D, 0x2(v0)
1630 cache Index_Writeback_Inv_D, 0x3(v0)
1640 TTYDBG("cache init panic\r\n");
1643 .end godson2_cache_init
1645 #define PCICONF_WRITEB(dev,func,reg,data) \
1646 li a0,CFGADDR(dev,func,reg); \
1647 li a1,PHYS_TO_UNCACHED(PCI_CFG_SPACE); \
1651 li a2,BONITO_BASE+BONITO_PCIMAP_CFG; \
1652 sw a0,BONITO_PCIMAP_CFG(bonito); \
1653 lw zero,BONITO_PCIMAP_CFG(bonito); \
1657 #define PCICONF_WRITEW(dev,func,reg,data) \
1658 li a0,CFGADDR(dev,func,reg); \
1659 li a1,PHYS_TO_UNCACHED(PCI_CFG_SPACE); \
1663 li a2,BONITO_BASE+BONITO_PCIMAP_CFG; \
1664 sw a0,BONITO_PCIMAP_CFG(bonito); \
1665 lw zero,BONITO_PCIMAP_CFG(bonito); \
1668 #define PCICONF_ORB(dev,func,reg,data) \
1669 li a0,CFGADDR(dev,func,reg); \
1670 li a1,PHYS_TO_UNCACHED(PCI_CFG_SPACE); \
1674 li a2,BONITO_BASE+BONITO_PCIMAP_CFG; \
1675 sw a0,BONITO_PCIMAP_CFG(bonito); \
1676 lw zero,BONITO_PCIMAP_CFG(bonito); \
1679 sw a0,BONITO_PCIMAP_CFG(bonito); \
1680 lw zero,BONITO_PCIMAP_CFG(bonito); \
1682 #define SUPERIO_WR(idx,data) \
1683 li v0,BONITO_PCIIO_BASE_VA+0x3f0; \
1690 #define E2_S1 (1<<2)
1691 #define E2_S2 (1<<3)
1692 #define E2_FLOPPY (1<<4)
1696 PCICONF_WRITEW(PCI_IDSEL_VIA686B,0,4,7);
1698 PCICONF_ORB(PCI_IDSEL_VIA686B,0,0x81,0x80);
1699 PCICONF_WRITEB(PCI_IDSEL_VIA686B,0,0x83,0x80|0x1| 0x8);
1700 PCICONF_WRITEB(PCI_IDSEL_VIA686B,0,0x85,3);
1701 /* enable RTC/PS2/KBC */
1702 PCICONF_WRITEB(PCI_IDSEL_VIA686B,0,0x5A,7);
1704 SUPERIO_WR(0xe2,E2_S2|E2_S1|E2_EPP|E2_FLOPPY) /*enable serial and floppy */
1705 SUPERIO_WR(0xe3,0x3f0>>2) /*floppy base address*/
1706 SUPERIO_WR(0xe6,0x378>>2) /*parallel port*/
1707 SUPERIO_WR(0xe7,0x3f8>>2) /*set serial port1 base addr 0x3f8*/
1708 SUPERIO_WR(0xe8,0x2f8>>2) /*set serial port2 base addr 0x2f8*/
1709 SUPERIO_WR(0xee,0xc0) /* both ports on high speed*/
1711 PCICONF_WRITEB(PCI_IDSEL_VIA686B,0,0x85,1)