1 /* $Id: start.S.1006.1.25,v 1.1.1.1 2006/09/14 01:59:08 root Exp $ */
4 * Copyright (c) 2001 Opsycon AB (www.opsycon.se)
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Opsycon AB, Sweden.
17 * 4. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
21 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
44 #include "pmon/dev/ns16550.h"
45 #include "target/i82371eb.h"
46 #include "target/prid.h"
47 #include "target/sbd.h"
48 #include "target/bonito.h"
49 #include "target/i8254.h"
50 #include "target/pc97307.h"
51 #include "target/isapnpreg.h"
56 .rdata;98: .asciz x; .text; la a0, 98b; bal stringserial; nop
61 .rdata;98: .asciz x; .text; la a0, 98b; bal stringserial; nop
63 #define CONFIG_CACHE_64K_4WAY 1
72 #define CFG_IB 0x00000020
73 #define CFG_DB 0x00000010
75 #define CFG_BE 0x00008000
76 #define CFG_EPMASK 0x0f000000
77 #define CFG_EPD 0x00000000
78 #define CFG_EM_R4K 0x00000000
79 #define CFG_EMMASK 0x00c00000
80 #define CFG_AD 0x00800000
82 #define CP0_CONFIG $16
86 #define DDR100 0x04041091
87 #define DDR266 0x0410435e
88 #define DDR300 0x041453df
91 #define DEBUG_WR(num) \
102 * s0 link versus load offset, used to relocate absolute adresses.
106 * s4 Bonito base address.
121 stack = start - 0x4000 /* Place PMON stack below PMON start in RAM */
123 /* NOTE!! Not more that 16 instructions here!!! Right now it's FULL! */
124 mtc0 zero, COP_0_STATUS_REG
125 mtc0 zero, COP_0_CAUSE_REG
126 li t0, SR_BOOT_EXC_VEC /* Exception to Boostrap Location */
127 mtc0 t0, COP_0_STATUS_REG
131 bal uncached /* Switch to uncached address space */
134 bal locate /* Get current execute address */
138 or ra, UNCACHED_MEMORY_ADDR
143 * Reboot vector usable from outside pmon.
163 * Exception vectors here for rom, before we are up and running. Catch
164 * whatever comes up before we have a fully fledged exception handler.
166 .align 9 /* bfc00200 */
172 .align 7 /* bfc00280 */
179 .align 8 /* bfc00300 */
180 PRINTSTR("\r\nPANIC! Unexpected Cache Error exception! ")
181 mfc0 a0, COP_0_CACHE_ERR
186 /* General exception */
187 .align 7 /* bfc00380 */
193 .align 8 /* bfc00400 */
201 PRINTSTR("\r\nCAUSE=")
202 mfc0 a0, COP_0_CAUSE_REG
205 PRINTSTR("\r\nSTATUS=")
206 mfc0 a0, COP_0_STATUS_REG
209 PRINTSTR("\r\nERRORPC=")
210 mfc0 a0, COP_0_ERROR_PC
214 mfc0 a0, COP_0_EXC_PC
217 PRINTSTR("\r\nDERR0=")
218 cfc0 a0, COP_0_DERR_0
221 PRINTSTR("\r\nDERR1=")
222 cfc0 a0, COP_0_DERR_1
226 // b ext_map_and_reboot
249 * We get here from executing a bal to get the PC value of the current execute
250 * location into ra. Check to see if we run from ROM or if this is ramloaded.
257 li t0,SR_BOOT_EXC_VEC
258 mtc0 t0,COP_0_STATUS_REG
259 mtc0 zero,COP_0_CAUSE_REG
262 li bonito,PHYS_TO_UNCACHED(BONITO_REG_BASE)
265 #define MOD_MASK 0x00000003
266 #define MOD_B 0x00000000 /* byte "modifier" */
267 #define MOD_H 0x00000001 /* halfword "modifier" */
268 #define MOD_W 0x00000002 /* word "modifier" */
270 # define MOD_D 0x00000003 /* doubleword "modifier" */
273 #define OP_MASK 0x000000fc
274 #define OP_EXIT 0x00000000 /* exit (status) */
275 #define OP_DELAY 0x00000008 /* delay (cycles) */
276 #define OP_RD 0x00000010 /* read (addr) */
277 #define OP_WR 0x00000014 /* write (addr, val) */
278 #define OP_RMW 0x00000018 /* read-modify-write (addr, and, or) */
279 #define OP_WAIT 0x00000020 /* wait (addr, mask, value) */
281 #define WR_INIT(mod,addr,val) \
282 .word OP_WR|mod,PHYS_TO_UNCACHED(addr);\
285 #define RD_INIT(mod,addr) \
286 .word OP_RD|mod,PHYS_TO_UNCACHED(addr);\
289 #define RMW_INIT(mod,addr,and,or) \
290 .word OP_RMW|mod,PHYS_TO_UNCACHED(addr);\
293 #define WAIT_INIT(mod,addr,and,or) \
294 .word OP_WAIT|mod,PHYS_TO_UNCACHED(addr);\
297 #define DELAY_INIT(cycles) \
298 .word OP_DELAY,(cycles);\
301 #define EXIT_INIT(status) \
302 .word OP_EXIT,(status);\
305 #define BONITO_INIT(r,v) WR_INIT(MOD_W,BONITO_BASE+/**/r,v)
306 #define BONITO_BIS(r,b) RMW_INIT(MOD_W,BONITO_BASE+(r),~0,b)
307 #define BONITO_BIC(r,b) RMW_INIT(MOD_W,BONITO_BASE+(r),~(b),0)
308 #define BONITO_RMW(r,c,s) RMW_INIT(MOD_W,BONITO_BASE+(r),~(c),s)
310 #define CFGADDR(idsel,function,reg) ((1<<(11+(idsel)))+((function)<<8)+(reg))
311 #define _ISABWR_INIT(mod,function,isabreg,val) \
312 WR_INIT(MOD_W,BONITO_BASE+BONITO_PCIMAP_CFG,CFGADDR(PCI_IDSEL_I82371,function,isabreg)>>16) ; \
313 RD_INIT(MOD_W,BONITO_BASE+BONITO_PCIMAP_CFG) ; \
314 WR_INIT(mod,PCI_CFG_SPACE+(CFGADDR(PCI_IDSEL_I82371,function,isabreg)&0xffff),val)
316 #define _ISABRD_INIT(mod,function,isabreg) \
317 WR_INIT(MOD_W,BONITO_BASE+BONITO_PCIMAP_CFG,CFGADDR(PCI_IDSEL_I82371,function,isabreg)>>16) ; \
318 RD_INIT(MOD_W,BONITO_BASE+BONITO_PCIMAP_CFG) ; \
319 RD_INIT(mod,PCI_CFG_SPACE+(CFGADDR(PCI_IDSEL_I82371,function,isabreg)&0xffff))
322 #define _ISAWR_INIT(isareg,val) \
323 WR_INIT(MOD_B,PCI_IO_SPACE+(isareg),val)
325 #define _ISARD_INIT(isareg) \
326 RD_INIT(MOD_B,PCI_IO_SPACE+(isareg))
329 #define ISABBWR_INIT(function,isabreg,val) \
330 _ISABWR_INIT(MOD_B,function,(isabreg),val)
331 #define ISABHWR_INIT(function,isabreg,val) \
332 _ISABWR_INIT(MOD_H,function,(isabreg),val)
333 #define ISABWWR_INIT(function,isabreg,val) \
334 _ISABWR_INIT(MOD_W,function,isabreg,val)
335 #define ISAWR_INIT(isareg,val) \
336 _ISAWR_INIT(isareg,val)
337 #define ISARD_INIT(isareg) \
343 /* bonito endianess */
344 BONITO_BIC(BONITO_BONPONCFG,BONITO_BONPONCFG_CPUBIGEND)
345 BONITO_BIC(BONITO_BONGENCFG,BONITO_BONGENCFG_BYTESWAP|BONITO_BONGENCFG_MSTRBYTESWAP)
346 BONITO_BIS(BONITO_BONPONCFG, BONITO_BONPONCFG_IS_ARBITER)
349 * In certain situations it is possible for the Bonito ASIC
350 * to come up with the PCI registers uninitialised, so do them here
352 #define PCI_CLASS_BRIDGE 0x06
353 #define PCI_CLASS_SHIFT 24
354 #define PCI_SUBCLASS_BRIDGE_HOST 0x00
355 #define PCI_SUBCLASS_SHIFT 16
356 #define PCI_COMMAND_IO_ENABLE 0x00000001
357 #define PCI_COMMAND_MEM_ENABLE 0x00000002
358 #define PCI_COMMAND_MASTER_ENABLE 0x00000004
359 #define PCI_COMMAND_STATUS_REG 0x04
360 #define PCI_MAP_IO 0X00000001
361 #define PCI_DEV_I82371 17
362 #define PCI_CFG_SPACE BONITO_PCICFG_BASE
364 BONITO_INIT(BONITO_PCICLASS,(PCI_CLASS_BRIDGE << PCI_CLASS_SHIFT) | (PCI_SUBCLASS_BRIDGE_HOST << PCI_SUBCLASS_SHIFT))
365 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)
366 BONITO_INIT(BONITO_PCILTIMER, 0)
367 BONITO_INIT(BONITO_PCIBASE0, 0)
368 BONITO_INIT(BONITO_PCIBASE1, 0)
369 BONITO_INIT(BONITO_PCIBASE2, 0)
370 BONITO_INIT(BONITO_PCIEXPRBASE, 0)
371 BONITO_INIT(BONITO_PCIINT, 0)
373 BONITO_BIS(BONITO_PCICMD, BONITO_PCICMD_PERRRESPEN)
375 BONITO_BIS(BONITO_PCICMD, PCI_COMMAND_IO_ENABLE|PCI_COMMAND_MEM_ENABLE|PCI_COMMAND_MASTER_ENABLE)
377 /* enable i/o buffer cache and other go faster bits */
378 BONITO_BIS(BONITO_BONGENCFG, \
379 BONITO_BONGENCFG_BUSERREN| \
380 BONITO_BONGENCFG_PREFETCHEN| \
381 BONITO_BONGENCFG_WBEHINDEN| \
382 BONITO_BONGENCFG_PCIQUEUE| \
383 BONITO_BONGENCFG_SNOOPEN)
385 BONITO_BIC(BONITO_BONGENCFG, 0x80) #½ûÖ¹iobc
387 # BONITO_BIS(BONITO_BONGENCFG, BONITO_BONGENCFG_BUSERREN)
390 BONITO_BIS(BONITO_BONGENCFG, BONITO_BONGENCFG_DEBUGMODE)
392 /******** added to void init southbridge*/
395 ISABWWR_INIT(2, 0x20, 0x8040|PCI_MAP_IO)
396 ISABWWR_INIT(2, PCI_COMMAND_STATUS_REG, 5)
398 /* zhb init floppy-disk */
399 ISABWWR_INIT(3, I82371_PCI3_DEVRESD, 0x1800)
400 ISABWWR_INIT(3, I82371_PCI3_DEVRESB, 0x20000000)
402 /* Turn most special purpose pins into GPIO; set ISA mode */
403 ISABWWR_INIT(0, I82371_GENCFG, I82371_GENCFG_CFG)
405 /* disable RTC & KBD chip selects */
406 // ISABHWR_INIT(0, I82371_XBCS, 0)
408 /* Enable PCI 2.1 timing support */
409 ISABBWR_INIT(0, I82371_DLC, I82371_DLC_DT /* | I82371_DLC_PR */ | I82371_DLC_USBPR | I82371_DLC_DTTE)
411 /* Set top of memory to 16MB, so all ISA bus master & DMA
412 accesses are forwarded to PCI mem space
414 ISABBWR_INIT(0, I82371_TOM, I82371_TOM_TOM(16) | I82371_TOM_FWD_LBIOS | I82371_TOM_FWD_AB | I82371_TOM_FWD_89)
416 /* Set the SMB base address */
417 ISABWWR_INIT(3, I82371_PCI3_SMBBA, SMB_PORT|PCI_MAP_IO)
418 /* enable the host controller */
419 ISABBWR_INIT(3, I82371_PCI3_SMBHSTCFG, I82371_PCI3_SMB_HST_EN)
420 /* enable the SMB IO ports */
421 ISABBWR_INIT(3, PCI_COMMAND_STATUS_REG, PCI_COMMAND_IO_ENABLE)
423 ISABWWR_INIT(3, I82371_PCI3_PMBA, PM_PORT|PCI_MAP_IO) /*notice*/
424 #define GPO_REG (0x34+PM_PORT)
425 #define UART1_485 (1<<17)
426 #define UART1_422 (1<<18)
427 #define UART2_485 (1<<19)
428 #define UART2_422 (1<<20)
429 #define UART1_232 (1<<21)
430 #define UART2_232 (1<<0)
431 #define LAN1_EN (1<<8)
432 #define LAN2A_EN (1<<27)
433 #define LAN2B_EN (1<<28)
434 /*ĬÈÏʹÄÜË«Íø¿¨,Á½¸ö´®¿Ú¶¼¹¤×÷ÔÚ232ģʽÏÂ*/
435 #define GPO_INITDATA (UART1_232|UART2_232|LAN1_EN|LAN2B_EN)
436 // WR_INIT(MOD_W,PCI_IO_SPACE+GPO_REG,GPO_INITDATA)
437 #define A82371_RST_REG 0xcf9
438 // WR_INIT(MOD_B,PCI_IO_SPACE+82371_RST_REG,3)/*notice*/
440 ISABBWR_INIT(3, I82371_PCI3_PMREGMISC, 0x01)
442 /* 15us ISA bus refresh clock */
443 #define ISAREFRESH (PT_CRYSTAL/(1000000/15))
444 ISARD_INIT(CTC_PORT+PT_CONTROL)
446 /* program i8254 ISA refresh counter */
447 ISAWR_INIT(CTC_PORT+PT_CONTROL,PTCW_SC(PT_REFRESH)|PTCW_16B|PTCW_MODE(MODE_RG))
448 ISAWR_INIT(CTC_PORT+PT_REFRESH, ISAREFRESH & 0xff)
449 ISAWR_INIT(CTC_PORT+PT_REFRESH, ISAREFRESH >> 8)
451 /* program ISA ICU */
452 ISAWR_INIT(ICU1_PORT, 0x11) /* ICW1 */
453 ISAWR_INIT(ICU1_PORT+1,0x00) /* ICW2: vector */
454 ISAWR_INIT(ICU1_PORT+1,0x04) /* ICW3: cascade on IRQ2 */
455 ISAWR_INIT(ICU1_PORT+1,0x01) /* ICW4: 8086 mode */
456 ISAWR_INIT(ICU1_PORT+1,0xff) /* OCW1: mask all */
458 ISAWR_INIT(ICU2_PORT, 0x11) /* ICW1 */
459 ISAWR_INIT(ICU2_PORT+1,0x08) /* ICW2: vector */
460 ISAWR_INIT(ICU2_PORT+1,0x02) /* ICW3: */
461 ISAWR_INIT(ICU2_PORT+1,0x01) /* ICW4: 8086 mode */
462 ISAWR_INIT(ICU2_PORT+1,0xff) /* OCW1: mask all */
464 ISAWR_INIT(ICU1_PORT+1,~(1<<2)) /* enable IRQ2 */
465 /* set up ISA devices */
467 /* select logical device 1 (mouse) */
468 ISAWR_INIT(ISAPNP_MBADDR,ISAPNP_LOGICAL_DEV_NUM)
469 ISAWR_INIT(ISAPNP_MBDATA,1)
470 ISAWR_INIT(ISAPNP_MBADDR,ISAPNP_ACTIVATE)
471 ISAWR_INIT(ISAPNP_MBDATA,1)
473 /* select logical device 4 (parallel) */
474 ISAWR_INIT(ISAPNP_MBADDR,ISAPNP_LOGICAL_DEV_NUM)
475 ISAWR_INIT(ISAPNP_MBDATA,4)
476 ISAWR_INIT(ISAPNP_MBADDR,ISAPNP_IO_DESC0+ISAPNP_IO_BASE_15_8)
477 ISAWR_INIT(ISAPNP_MBDATA,(ECP_PORT>>8) & 0xff)
478 ISAWR_INIT(ISAPNP_MBADDR,ISAPNP_IO_DESC0+ISAPNP_IO_BASE_7_0)
479 ISAWR_INIT(ISAPNP_MBDATA,ECP_PORT & 0xff)
480 ISAWR_INIT(ISAPNP_MBADDR,ISAPNP_IRQ_DESC0+ISAPNP_IRQ_CONTROL)
481 ISAWR_INIT(ISAPNP_MBDATA,ISAPNP_IRQ_HIGH)
482 ISAWR_INIT(ISAPNP_MBADDR,ISAPNP_ACTIVATE)
483 ISAWR_INIT(ISAPNP_MBDATA,1)
485 /* select logical device 5 (COM2) */
486 ISAWR_INIT(ISAPNP_MBADDR,ISAPNP_LOGICAL_DEV_NUM)
487 ISAWR_INIT(ISAPNP_MBDATA,5)
488 ISAWR_INIT(ISAPNP_MBADDR,ISAPNP_ACTIVATE)
489 ISAWR_INIT(ISAPNP_MBDATA,1)
491 /* select logical device 6 (COM1) */
492 ISAWR_INIT(ISAPNP_MBADDR,ISAPNP_LOGICAL_DEV_NUM)
493 ISAWR_INIT(ISAPNP_MBDATA,6)
494 ISAWR_INIT(ISAPNP_MBADDR,ISAPNP_ACTIVATE)
495 ISAWR_INIT(ISAPNP_MBDATA,1)
508 reginit: /* local name */
526 8: bne t4, OP_DELAY, 8f
652 * WAIT(ADDR,MASK,VAL)
698 .next: addu a0,Init_Size
708 /* Initialise other low-level I/O devices */
714 PRINTSTR("\r\nPMON2000 MIPS Initializing. Standby...\r\n")
718 mfc0 a0, COP_0_ERROR_PC
723 mfc0 a0, COP_0_CONFIG
734 PRINTSTR("Raw word read of SMB base address: ");
735 li a0,CFGADDR(PCI_DEV_I82371,3,I82371_PCI3_SMBBA)
736 li a1,PHYS_TO_UNCACHED(PCI_CFG_SPACE)
740 li a2,BONITO_BASE+BONITO_PCIMAP_CFG
741 sw a0,BONITO_PCIMAP_CFG(bonito)
742 lw zero,BONITO_PCIMAP_CFG(bonito)
751 /***(qiaochong) memeory initialization use macro,not smbbus ***/
752 /*bit 31: DDRÅäÖýáÊø±êÖ¾£¬1±íʾ½áÊø£¬Ö»¶Á*/
753 #define DDR_DQS_SELECT (0<<30) /*bit 30 Ñ¡ÔñÊý¾ÝÀ´Ô´£¬0: Ë«ÑزÉÑù£»1£ºDQS²ÉÑù*/
754 #define DDR_DIMM_DIC (1<<29) /*bit 29 ±êʶDIMM_slot0ÊÇ·ñ²åÓÐÄÚ´æÌõ¡£
756 #define DDR_DIMM_MODULE_NUM (3<<27) /*bit 28:27 DIMM0/DIMM1ÉÏMOUDLEµÄÊýÄ¿£º
757 2¡¯b00£ºDIMM1: 1; DIMM0: 1
758 2¡¯b01£ºDIMM1: 1; DIMM0: 2
759 2¡¯b10£ºDIMM1: 2; DIMM0: 1
760 2¡¯b11£ºDIMM1: 2; DIMM0: 2
762 #define DDR_IS_SEQ (1<<26) /*bit 26 ÒåÍ»·¢Ê½¶ÁдʱµÄ¿éÄÚ˳Ðò£¬
763 1¡¯b0£ºË³Ðò£»1¡¯b1£º½»Ì棬ÏÖÔÚÖ»Ö§³Ö½»Ì淽ʽ*/
764 #define DDR_TYPE (5<<22) /*bit 25:22 ±í2£ºDDR ¿ØÖÆÆ÷ËùÖ§³ÖµÄDDR SDRAM ¼ÆоƬÀàÐÍ
765 BITS Density Org. Row Addr. Col Addr.
766 0000 64Mb 16Mb X 4 DA[11:0] DA[9:0]
768 0001 64Mb 8Mb X 8 DA[11:0] DA[8:0]
770 0010 64Mb 4Mb X 16 DA[11:0] DA[7:0]
771 0011 128Mb 32Mb X 4 DA[11:0] DA[11],DA[9:0]
772 0100 256Mb 64Mb X 4 DA[12:0] DA[11],DA[9:0]
774 0101 256Mb 32Mb X 8 DA[12:0] DA[9:0]
776 0110 256Mb 16Mb X 16 DA[12:0] DA[8:0]
777 0111 512Mb 128Mb X 4 DA[12:0] DA[12:11],DA[9:0]
778 1000 1Gb 256Mb X 4 DA[13:0] DA[12:11],DA[9:0]
779 1001 1Gb 128Mb X 8 DA[13:0] DA[11],DA[9:0]
780 1010 1Gb 64Mb X 16 DA[13:0] DA[9:0]
782 #define DDR_tREF (100<<10) /*bit 21:10 SDRAMˢвÙ×÷Ö®¼ä¼ÆÊý£¨Ö÷Ƶ100MHz£©£º
785 SDRAMˢвÙ×÷Ö®¼ä¼ÆÊý£¨Ö÷Ƶ133MHz£©£º
788 SDRAMˢвÙ×÷Ö®¼ä¼ÆÊý£¨Ö÷Ƶ166MHz£©£º
792 #define DDR_TRCD (0<<9) /*bit 9 ÐеØÖ·ÓÐЧµ½ÁеØÖ·ÓÐЧ֮¼äÐè¾¹ýµÄ¼ÆÊý
793 1¡¯b0 2 cycles£¨DDR100£©
794 1¡¯b1 3 cycles£¨DDR266¡¢DDR333£©*/
795 #define DDR_TRPC (1<<7) /*bit 8:7 AUTO_REFRESHµ½ACTIVEÖ®¼äÐè¾¹ýµÄ¼ÆÊý
797 2¡¯b01 8 cylces £¨DDR100£©
798 2¡¯b10 10 cycles£¨DDR266£©
799 2¡¯b11 12 cycles£¨DDR333£©
801 #define DDR_TRAS (0<<6) /*bit 6 ACTIVEµ½PRECHARGEÖ®¼äÐè¾¹ýµÄ¼ÆÊý
802 1¡¯b0 5 cycles£¨DDR100£©
803 1¡¯b1 7 cycles£¨DDR266¡¢DDR333£©
805 #define DDR_TCAS (1<<4) /*bit 5:4 ´Ó¶ÁÃüÁîµ½µÚÒ»¸öÊý¾Ýµ½À´Ðè¾¹ýµÄ¼ÆÊý
811 #define DDR_TWR (0<<3) /*bit 3 д²Ù×÷×îºóÒ»¸öÊý¾Ýµ½PRECHARGEÖ®¼äÐè¾¹ýµÄ¼ÆÊý
812 1¡¯b0 2 cycles£¨DDR100£©
813 1¡¯b1 3 cycles£¨DDR266¡¢DDR333£©
815 #define DDR_TRP (0<<2) /*bit 2 PRECHARGEÃüÁîÖ´ÐÐʱ¼ä¼ÆÊý
816 1¡¯b0 2 cycles£¨DDR100£©
817 1¡¯b1 3 cycles£¨DDR266¡¢DDR333£©
819 #define DDR_TRC (1<<0) /*bit 1:0 ACTIVEÓëACTIVE/AUTO_REFRESHÃüÁîÖ®¼ä¼ÆÊý
821 2¡¯b01 7 cycles£¨DDR100£©
822 2¡¯b10 9 cycles£¨DDR266£©
823 2¡¯b11 10cycles£¨DDR333£©
824 ×¢£¨ÓÉÓÚprechargeºÍras casµÄÑÓʱ¼ÓÆðÀ´ÕýºÃÂú×ãÕâ¸öÑÓʱ£¬ËùÒÔÔÚDDR¿ØÖÆÆ÷ÀïûÓоßÌ忼ÂÇÕâ¸ö²ÎÊý£©
826 #define sdcfg_DATA DDR_DQS_SELECT|DDR_DIMM_DIC|DDR_DIMM_MODULE_NUM|DDR_IS_SEQ|DDR_TYPE|DDR_tREF|DDR_TRCD|DDR_TRPC|DDR_TRAS|DDR_TCAS|DDR_TWR|DDR_TRP|DDR_TRC
829 # li sdCfg,0x05441091
830 sw sdCfg,BONITO_SDCFG(bonito)
839 sw a0,BONITO_MEMSIZE(bonito)
843 li msize,0x10000000 # only 256m allowed in pmon now
845 li t1,0 # accumulate pcimembasecfg settings
847 /* set bar0 mask and translation to point to SDRAM */
850 srl t0,BONITO_PCIMEMBASECFG_ASHIFT-BONITO_PCIMEMBASECFG_MEMBASE0_MASK_SHIFT
851 and t0,BONITO_PCIMEMBASECFG_MEMBASE0_MASK
855 srl t0,BONITO_PCIMEMBASECFG_ASHIFT-BONITO_PCIMEMBASECFG_MEMBASE0_TRANS_SHIFT
856 and t0,BONITO_PCIMEMBASECFG_MEMBASE0_TRANS
858 or t1,BONITO_PCIMEMBASECFG_MEMBASE0_CACHED
860 /* set bar1 to minimum size to conserve PCI space */
862 srl t0,BONITO_PCIMEMBASECFG_ASHIFT-BONITO_PCIMEMBASECFG_MEMBASE1_MASK_SHIFT
863 and t0,BONITO_PCIMEMBASECFG_MEMBASE1_MASK
867 srl t0,BONITO_PCIMEMBASECFG_ASHIFT-BONITO_PCIMEMBASECFG_MEMBASE1_TRANS_SHIFT
868 and t0,BONITO_PCIMEMBASECFG_MEMBASE1_TRANS
870 or t1,BONITO_PCIMEMBASECFG_MEMBASE1_CACHED
872 sw t1,BONITO_PCIMEMBASECFG(bonito)
874 /* enable configuration cycles now */
875 lw t0,BONITO_BONPONCFG(bonito)
876 and t0,~BONITO_BONPONCFG_CONFIG_DIS
877 sw t0,BONITO_BONPONCFG(bonito)
879 PRINTSTR("Init SDRAM Done!\r\n");
882 * Reset and initialize caches to a known state.
884 #define IndexStoreTagI 0x08
885 #define IndexStoreTagD 0x09
886 #define IndexStoreTagS 0x0b
887 #define IndexStoreTagT 0x0a
891 * RM7000 config register bits.
893 #define CF_7_SE (1 << 3) /* Secondary cache enable */
894 #define CF_7_SC (1 << 31) /* Secondary cache not present */
895 #define CF_7_TE (1 << 12) /* Tertiary cache enable */
896 #define CF_7_TC (1 << 17) /* Tertiary cache not present */
897 #define CF_7_TS (3 << 20) /* Tertiary cache size */
898 #define CF_7_TS_AL 20 /* Shift to align */
899 #define NOP8 nop;nop;nop;nop;nop;nop;nop;nop
901 TTYDBG("Sizing caches...\r\n");
906 bne a0, a1, cache_done
908 TTYDBG("godson2 caches found\r\n")
909 bal godson2_cache_init
914 TTYDBG("Init caches done, cfg = ")
915 mfc0 a0, COP_0_CONFIG
928 //#include "testmem0.S"
929 TTYDBG("Copy PMON to execute location...\r\n")
930 #include "copypmon.S"
931 TTYDBG("Copy PMON to execute location done.\r\n")
932 //#include "test_after_copy.S"
936 sw a0, CpuTertiaryCacheSize /* Set L3 cache size */
945 TTYDBG("Dumping GT64240 setup.\r\n")
946 TTYDBG("offset----data------------------------.\r\n")
977 * Clear the TLB. Normally called from start.S.
985 li a3, 0 # First TLB index.
988 MTC0 a2, COP_0_TLB_PG_MASK # Whatever...
991 MTC0 zero, COP_0_TLB_HI # Clear entry high.
992 MTC0 zero, COP_0_TLB_LO0 # Clear entry low0.
993 MTC0 zero, COP_0_TLB_LO1 # Clear entry low1.
995 mtc0 a3, COP_0_TLB_INDEX # Set the index.
1000 tlbwi # Write the TLB
1010 * Set up the TLB. Normally called from start.S.
1013 li a3, 0 # First TLB index.
1016 MTC0 a2, COP_0_TLB_PG_MASK # All pages are 16Mb.
1020 MTC0 a2, COP_0_TLB_HI # Set up entry high.
1023 srl a2, a0, PG_SHIFT
1024 and a2, a2, PG_FRAME
1026 MTC0 a2, COP_0_TLB_LO0 # Set up entry low0.
1027 addu a2, (0x01000000 >> PG_SHIFT)
1028 MTC0 a2, COP_0_TLB_LO1 # Set up entry low1.
1030 mtc0 a3, COP_0_TLB_INDEX # Set the index.
1035 tlbwi # Write the TLB
1038 addu a0, a2 # Step address 32Mb.
1045 * Simple character printing routine used before full initialization
1101 # la v0, COM1_BASE_ADDR
1102 la v0, COM3_BASE_ADDR
1104 lbu v1, NSREG(NS16550_LSR)(v0)
1109 sb a0, NSREG(NS16550_DATA)(v0)
1112 la v0, COM1_BASE_ADDR
1119 /* baud rate definitions, matching include/termios.h */
1134 #define B19200 19200
1135 #define B38400 38400
1136 #define B57600 57600
1137 #define B115200 115200
1140 # la v0, COM1_BASE_ADDR
1141 la v0, COM3_BASE_ADDR
1143 li v1, FIFO_ENABLE|FIFO_RCV_RST|FIFO_XMT_RST|FIFO_TRIGGER_4
1144 sb v1, NSREG(NS16550_FIFO)(v0)
1146 sb v1, NSREG(NS16550_CFCR)(v0)
1147 li v1, NS16550HZ/(16*CONS_BAUD)
1148 sb v1, NSREG(NS16550_DATA)(v0)
1150 sb v1, NSREG(NS16550_IER)(v0)
1152 sb v1, NSREG(NS16550_CFCR)(v0)
1153 li v1, MCR_DTR|MCR_RTS
1154 sb v1, NSREG(NS16550_MCR)(v0)
1156 sb v1, NSREG(NS16550_IER)(v0)
1159 la v0, COM1_BASE_ADDR
1160 # bne v0, v1, 1b /*qiaochong notice*/
1167 #define SMBOFFS(reg) I82371_SMB_SMB##reg
1172 li a0,PHYS_TO_UNCACHED(ISAPORT_BASE(SMB_PORT))
1173 lbu a0,SMBOFFS(HSTSTS)(a0)
1179 li a0,PHYS_TO_UNCACHED(ISAPORT_BASE(SMB_PORT))
1180 lbu a0,SMBOFFS(SLVSTS)(a0)
1186 li a0,PHYS_TO_UNCACHED(ISAPORT_BASE(SMB_PORT))
1187 lbu a0,SMBOFFS(HSTCNT)(a0)
1193 li a0,PHYS_TO_UNCACHED(ISAPORT_BASE(SMB_PORT))
1194 lbu a0,SMBOFFS(HSTCMD)(a0)
1200 li a0,PHYS_TO_UNCACHED(ISAPORT_BASE(SMB_PORT))
1201 lbu a0,SMBOFFS(HSTADD)(a0)
1207 li a0,PHYS_TO_UNCACHED(ISAPORT_BASE(SMB_PORT))
1208 lbu a0,SMBOFFS(HSTDAT0)(a0)
1214 li a0,PHYS_TO_UNCACHED(ISAPORT_BASE(SMB_PORT))
1215 lbu a0,SMBOFFS(HSTDAT1)(a0)
1221 li a0,PHYS_TO_UNCACHED(ISAPORT_BASE(SMB_PORT))
1222 lbu a0,SMBOFFS(BLKDAT)(a0)
1228 li a0,PHYS_TO_UNCACHED(ISAPORT_BASE(SMB_PORT))
1229 lbu a0,SMBOFFS(SLVCNT)(a0)
1235 li a0,PHYS_TO_UNCACHED(ISAPORT_BASE(SMB_PORT))
1236 lbu a0,SMBOFFS(SHDWCMD)(a0)
1242 li a0,PHYS_TO_UNCACHED(ISAPORT_BASE(SMB_PORT))
1243 lbu a0,SMBOFFS(SLVEVT)(a0)
1249 li a0,PHYS_TO_UNCACHED(ISAPORT_BASE(SMB_PORT))
1250 lbu a0,SMBOFFS(SLVDAT)(a0)
1263 li t0,PHYS_TO_UNCACHED(ISAPORT_BASE(SMB_PORT))
1265 lbu t1,SMBOFFS(HSTSTS)(t0)
1266 and t1,~(I82371_SMB_FAILED|I82371_SMB_BUS_ERR|I82371_SMB_DEV_ERR|I82371_SMB_INTER)
1267 sb t1,SMBOFFS(HSTSTS)(t0)
1270 or t1,0xa1 # DIMM base address and read bit
1271 sb t1,SMBOFFS(HSTADD)(t0)
1272 sb a1,SMBOFFS(HSTCMD)(t0)
1275 li t1,I82371_SMB_START|I82371_SMB_BDRW
1276 sb t1,SMBOFFS(HSTCNT)(t0)
1279 1: lbu t1,SMBOFFS(HSTSTS)(t0)
1280 and t2,t1,I82371_SMB_FAILED|I82371_SMB_BUS_ERR|I82371_SMB_DEV_ERR|I82371_SMB_INTER
1289 # clear pending errors/interrupts
1290 sb t1,SMBOFFS(HSTSTS)(t0)
1292 and t2,t1,I82371_SMB_FAILED|I82371_SMB_BUS_ERR|I82371_SMB_DEV_ERR
1295 lbu v0,SMBOFFS(HSTDAT0)(t0)
1311 .asciz "\r\nInvalid transmit pattern. Must be DDDD or DDxDDx\r\n"
1313 .asciz "\r\nPANIC! Unexpected TLB refill exception!\r\n"
1315 .asciz "\r\nPANIC! Unexpected XTLB refill exception!\r\n"
1317 .asciz "\r\nPANIC! Unexpected General exception!\r\n"
1319 .asciz "\r\nPANIC! Unexpected Interrupt exception!\r\n"
1321 .ascii "0123456789abcdef"
1326 * I2C Functions used in early startup code to get SPD info from
1327 * SDRAM modules. This code must be entirely PIC and RAM independent.
1331 #define DELAY(count) \
1338 #define I2C_INT_ENABLE 0x80
1339 #define I2C_ENABLE 0x40
1340 #define I2C_ACK 0x04
1341 #define I2C_INT_FLAG 0x08
1342 #define I2C_STOP_BIT 0x10
1343 #define I2C_START_BIT 0x20
1345 #define I2C_AMOD_RD 0x01
1347 #define BUS_ERROR 0x00
1348 #define START_CONDITION_TRA 0x08
1349 #define RSTART_CONDITION_TRA 0x10
1350 #define ADDR_AND_WRITE_BIT_TRA_ACK_REC 0x18
1351 #define ADDR_AND_READ_BIT_TRA_ACK_REC 0x40
1352 #define SLAVE_REC_WRITE_DATA_ACK_TRA 0x28
1353 #define MAS_REC_READ_DATA_ACK_NOT_TRA 0x58
1355 #define Index_Store_Tag_D 0x05
1356 #define Index_Invalidate_I 0x00
1357 #define Index_Writeback_Inv_D 0x01
1364 LEAF(godson2_cache_init)
1366 cache_detect_size_way:
1380 srlv t6, t6, t7 /* 4way */
1388 #a0=0x80000000, a1=icache_size, a2=dcache_size
1389 #a3, v0 and v1 used as local registers
1397 cache Index_Store_Tag_D, 0x0(v0)
1398 cache Index_Store_Tag_D, 0x1(v0)
1402 cache Index_Store_Tag_D, 0x2(v0)
1403 cache Index_Store_Tag_D, 0x3(v0)
1414 cache Index_Invalidate_I, 0x0(v0)
1424 cache Index_Writeback_Inv_D, 0x0(v0)
1425 cache Index_Writeback_Inv_D, 0x1(v0)
1429 cache Index_Writeback_Inv_D, 0x2(v0)
1430 cache Index_Writeback_Inv_D, 0x3(v0)
1441 TTYDBG("cache init panic\r\n");
1444 .end godson2_cache_init