📄 reset_pb1100.s
字号:
/********************************************************************* * * Copyright: * Advanced Micro Devices, AMD. All Rights Reserved. * You are hereby granted a copyright license to use, modify, and * distribute the SOFTWARE so long as this entire notice is * retained without alteration in any modified and/or redistributed * versions, and that such modified versions are clearly identified * as such. No licenses are granted by implication, estoppel or * otherwise under any patents or trademarks of AMD. This * software is provided on an "AS IS" basis and without warranty. * * To the maximum extent permitted by applicable law, AMD * DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED, INCLUDING * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR * PURPOSE AND ANY WARRANTY AGAINST INFRINGEMENT WITH REGARD TO THE * SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF) AND ANY * ACCOMPANYING WRITTEN MATERIALS. * * To the maximum extent permitted by applicable law, IN NO EVENT * SHALL AMD BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING * WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS * INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY * LOSS) ARISING OF THE USE OR INABILITY TO USE THE SOFTWARE. * * AMD assumes no responsibility for the maintenance and support * of this software. ********************************************************************//*This file represents all the activities necessary to bringthe Au1100 out of reset. It sets all Au1100 resources toknown, usually disabled and safe, state.This is an example startup file, tailored for the Pb1100reference board. Pb1100-specific items are commented assuch, but in general are confined to the CPU endianselection and memory controller values.*//********************************************************************//* * MIPS ABI register defintions */#define zero $0#define v0 $2#define v1 $3#define a0 $4#define a1 $5#define a2 $6#define a3 $7#define t0 $8#define t1 $9#define t2 $10#define t3 $11#define t4 $12#define t5 $13#define t6 $14#define t7 $15#define s0 $16#define s1 $17#define s2 $18#define s3 $19#define s4 $20#define s5 $21#define s6 $22#define s7 $23#define t8 $24#define t9 $25#define k0 $26#define k1 $27#define gp $28#define sp $29#define fp $30// #define s8 $30 Conflicts with MIPS.H#define ra $31/********************************************************************//* * Au1100 CP0 registers */#define CP0_Index $0#define CP0_Random $1#define CP0_EntryLo0 $2#define CP0_EntryLo1 $3#define CP0_Context $4#define CP0_PageMask $5#define CP0_Wired $6#define CP0_BadVAddr $8#define CP0_Count $9#define CP0_EntryHi $10#define CP0_Compare $11#define CP0_Status $12#define CP0_Cause $13#define CP0_EPC $14#define CP0_PRId $15#define CP0_Config $16#define CP0_Config0 $16#define CP0_Config1 $16,1#define CP0_LLAddr $17#define CP0_WatchLo $18#define CP0_IWatchLo $18,1#define CP0_WatchHi $19#define CP0_IWatchHi $19,1#define CP0_Scratch $22#define CP0_Debug $23#define CP0_DEPC $24#define CP0_PerfCnt $25#define CP0_PerfCtrl $25,1#define CP0_DTag $28#define CP0_DData $28,1#define CP0_ITag $29#define CP0_IData $29,1#define CP0_ErrorEPC $30#define CP0_DESave $31/********************************************************************//* * Au1100 base addresses (in KSEG1 region) */#define AU1100_MEM_ADDR 0xB4000000#define AU1100_AC97_ADDR 0xB0000000#define AU1100_USBH_ADDR 0xB0100000#define AU1100_USBD_ADDR 0xB0200000#define AU1100_IC0_ADDR 0xB0400000#define AU1100_MACEN_ADDR 0xB0520000#define AU1100_UART0_ADDR 0xB1100000#define AU1100_UART3_ADDR 0xB1400000#define AU1100_IC1_ADDR 0xB1800000#define AU1100_SYS_ADDR 0xB1900000/* * Au1100 memory controller register offsets */#define mem_sdmode0 0x0000#define mem_sdmode1 0x0004#define mem_sdmode2 0x0008#define mem_sdaddr0 0x000C#define mem_sdaddr1 0x0010#define mem_sdaddr2 0x0014#define mem_sdrefcfg 0x0018#define mem_sdprecmd 0x001C#define mem_sdautoref 0x0020#define mem_sdwrmd0 0x0024#define mem_sdwrmd1 0x0028#define mem_sdwrmd2 0x002C#define mem_sdsleep 0x0030#define mem_sdsmcke 0x0034#define mem_stcfg0 0x1000#define mem_sttime0 0x1004#define mem_staddr0 0x1008#define mem_stcfg1 0x1010#define mem_sttime1 0x1014#define mem_staddr1 0x1018#define mem_stcfg2 0x1020#define mem_sttime2 0x1024#define mem_staddr2 0x1028#define mem_stcfg3 0x1030#define mem_sttime3 0x1034#define mem_staddr3 0x1038/* * Au1100 peripheral register offsets */#define ac97_enable 0x0010#define usbh_enable 0x0007FFFC#define usbd_enable 0x0058#define irda_enable 0x0040#define macen_mac0 0x0000#define macen_mac1 0x0004#define i2s_enable 0x0008#define uart_enable 0x0100#define ssi_enable 0x0100#define ic_cfg0clr 0x0044#define ic_cfg1clr 0x004C#define ic_cfg2clr 0x0054#define ic_srcset 0x0058#define ic_assignset 0x0060#define ic_wakeclr 0x006C#define ic_maskclr 0x0074#define ic_risingclr 0x0078#define ic_fallingclr 0x007C#define ic_testbit 0x0080#define sys_scratch0 0x0018#define sys_scratch1 0x001c#define sys_cntctrl 0x0014#define sys_freqctrl0 0x0020#define sys_freqctrl1 0x0024#define sys_clksrc 0x0028#define sys_pinfunc 0x002C#define sys_wakemsk 0x0034#define sys_powerctrl 0x003C#define sys_endian 0x0038#define sys_wakesrc 0x005C#define sys_cpupll 0x0060#define sys_auxpll 0x0064#define sys_trioutclr 0x0100#define sys_outputclr 0x010C#define sys_pininputen 0x0110/********************************************************************//* * Pb1100-specific values * NOTE: All values are for operation at 396MHz, SD=2 */#define SYS_CPUPLL 33 /* 396MHz */#define SYS_POWERCTRL 0 /* SD=2 */#define SYS_AUXPLL 8 /* 96MHz *//* RCE0: 64MB StrataFlash plus new bits for sync mode *//* Switch S15, ROM_SIZ: dot visible=16-bit boot, no dot=32-bit boot */#ifdef BOOT_16BIT#ifdef EB#define MEM_STCFG0 0x00042243 /* 16-bit big-endian */#endif#ifdef EL#define MEM_STCFG0 0x00042043 /* 16-bit little-endian */#endif#else#define MEM_STCFG0 0x00002003 /* 32-bit either-endian */#endif#define MEM_STTIME0 0x22080b20#define MEM_STADDR0 0x11c03f00/* RCE1: Dallas Semi RTC, DiskOnChip, Pb1100 regs, HexLEDs */#define MEM_STCFG1 0x000400C0 /* old 0x80, ext regs are 16-bit */#define MEM_STTIME1 0x22080a20#define MEM_STADDR1 0x10c03f00/* RCE2: (not SRAM) LCD type, Epson S1D13806, DaughterCard */#define MEM_STCFG2 0x001c00c4#define MEM_STTIME2 0x0201c007#define MEM_STADDR2 0x11803f00/* RCE3: PCMCIA */#define MEM_STCFG3 0x00000002#define MEM_STTIME3 0x280E3E07#define MEM_STADDR3 0x10000000/* * SDCS0 - 32MB Samsung K4S28163LD-RF75 * SDCS1 - 32MB Samsung K4S28163LD-RF75 * SDCS2 - Not used */#define MEM_SDMODE0 0x00552229#define MEM_SDMODE1 0x00552229#define MEM_SDMODE2 0x00000000#define MEM_SDADDR0 0x001003F8 #define MEM_SDADDR1 0x001023F8#define MEM_SDADDR2 0x00000000#define MEM_SDREFCFG_D 0x64000C24 /* disable */#define MEM_SDREFCFG_E 0x66000C24 /* enable */#define MEM_SDWRMD0 0x00000023#define MEM_SDWRMD1 0x00000023#define MEM_SDWRMD2 0x00000000#define MEM_1MS ((396000000/1000000) * 1000)/********************************************************************//********************************************************************//********************************************************************//********************************************************************/ .text .set noreorder .set mips32#ifndef BOOT_16BIT /* * Step 1) Establish CPU endian mode. */ li t0, AU1100_MEM_ADDR /* RCE1 */ li t1, MEM_STCFG1 sw t1, mem_stcfg1(t0) li t1, MEM_STTIME1 sw t1, mem_sttime1(t0) li t1, MEM_STADDR1 sw t1, mem_staddr1(t0) /* Enable GPIO2 - Pb1100 specific */ li t1, 0xb1700000 // point to secondary GPIO regs li t2, 0x03 // enable clocks sw t2, 0x14(t1) nop nop nop li t2, 0x01 // clear reset sw t2, 0x14(t1) nop nop /* Determine Endianess - Pb1100 specific */ li t1, 0xb1900000 // point to primary GPIO regs sw zero, sys_pininputen(t1) // enable gpio inputs nop lw t2, 0x110(t1) // read pin state and t2, 0x00100000 // test GP212 beq t2,zero, big_endian nop /* Set to little endian */little_endian: li t0, AU1100_SYS_ADDR li t1, 1 sw t1, sys_endian(t0) sync mfc0 t2, CP0_Config mtc0 t2, CP0_Config nop nop /* Big Endian is default so nothing to do but fall through */big_endian:#else /* BOOT_16BIT */#ifdef EB /* Big Endian is default so nothing to do but fall through */#endif#ifdef EL /* Change Au1 core to little endian */ li t0, AU1100_SYS_ADDR li t1, 1 sw t1, sys_endian(t0) mfc0 t2, CP0_Config mtc0 t2, CP0_Config nop nop#endif#endif /* BOOT_16BIT */ /* * NOTE: Config0[BE] now reflects endian mode */ /* * Step 2) Establish Status Register * (set BEV, clear ERL, clear EXL, clear IE) */ li t1, 0x00400000 mtc0 t1, CP0_Status /* * Step 3) Establish CP0 Config0 * (set K0=3) */ li t1, 0x00000003 mtc0 t1, CP0_Config0 /* * Step 4) Disable Watchpoint facilities */ li t1, 0x00000000 mtc0 t1, CP0_WatchLo mtc0 t1, CP0_IWatchLo /* * Step 5) Disable the performance counters */ mtc0 zero, CP0_PerfCtrl nop /* * Step 6) Establish EJTAG Debug register */ mtc0 zero, CP0_Debug nop /* * Step 7) Establish Cause * (set IV bit) */ li t1, 0x00800000 mtc0 t1, CP0_Cause /* * Step 8) Initialize the caches */ li t0, (16*1024) li t1, 32 li t2, 0x80000000 addu t3, t0, t2cacheloop: cache 0, 0(t2) cache 1, 0(t2) addu t2, t1 bne t2, t3, cacheloop nop /* Run from cacheable space now */ bal cachehere nopcachehere: li t1, ~0x20000000 /* convert to KSEG0 */ and t0, ra, t1 addi t0, 5*4 /* 5 insns beyond cachehere */ jr t0 nop /* * Step 9) Initialize the TLB */ li t0, 0 # index value li t1, 0x00000000 # entryhi value li t2, 32 # 32 entriestlbloop: /* Probe TLB for matching EntryHi */ mtc0 t1, CP0_EntryHi tlbp nop /* Examine Index[P], 1=no matching entry */ mfc0 t3, CP0_Index li t4, 0x80000000 and t3, t4, t3 addiu t1, t1, 1 # increment t1 (asid) beq zero, t3, tlbloop nop /* Initialize the TLB entry */ mtc0 t0, CP0_Index mtc0 zero, CP0_EntryLo0 mtc0 zero, CP0_EntryLo1 mtc0 zero, CP0_PageMask tlbwi /* Do it again */ addiu t0, t0, 1 bne t0, t2, tlbloop nop /* Establish Wired (and Random) */ mtc0 zero, CP0_Wired nop /* * Step 10) Establish CPU PLL frequency */ li t0, AU1100_SYS_ADDR li t1, SYS_CPUPLL sw t1, sys_cpupll(t0) sync nop nop /* * Step 11) Establish system bus divider */ li t1, SYS_POWERCTRL sw t1, sys_powerctrl(t0) sync /* * Step 12) Establish AUX PLL frequency */ li t1, SYS_AUXPLL sw t1, sys_auxpll(t0) sync /* * Step 13) Start the 32kHz oscillator */ li t1, 0x00000100 sw t1, sys_cntctrl(t0) sync /* * Step 14) Initialize static memory controller */ li t0, AU1100_MEM_ADDR /* RCE0 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -