# board init script

echo "1.init PLL..."

#PLL init start
#switch system to slow mode
mww 0x101e0000 0x2           
sleep 100
#xtal wait time
mww 0x101e0010 0x0007fff0    
#APLL wait time	
mww 0x101e0014 0x0fffffb0    
sleep 100

#config APLL	
mww 0x101e0018 0x89000000    
sleep 100
#pd=0
mww 0x101e001c 0x005c1023   
sleep 100
#pd=1
mww 0x101e001c 0x007c1023    
sleep 100

#config VPLL0	
mww 0x101e0020 0x91000000    
sleep 100
#pd=0        	
mww 0x101e0024 0x005c40a5    
sleep 100
#pd=1        	
mww 0x101e0024 0x007c40a5    
sleep 100

#config VPLL1	
mww 0x101e0028 0x91000000    
sleep 100
#pd=0               
mww 0x101e002c 0x005c40a5     
sleep 100
#pd=1
mww 0x101e002c 0x007c40a5
sleep 100

#config QPLL 	
mww 0x101e0038 0x91000000    
sleep 100
#pd=0               
mww 0x101e003c 0x005c307d    
sleep 100
#pd=1        	
mww 0x101e003c 0x007c307d    
sleep 100

#wait pll to be locked            	 
sleep 100
#NANDC timing
mww 0x60010004 0xaaa    
#switch system to normal mode          
mww 0x101e0000 0x4     
sleep 100

#PLL init done


echo "2.init DDRC..."
#DDR reset deassert
mww 0x101e0054 0x1
sleep 100



#PHY IO settings
mww 0x10100830 0x31
mww 0x101008d4 0xb 	
mww 0x10100914 0xb 	
mww 0x10100a04 0x1d 	
mww 0x10100ac0 0x55 	
 	
mww 0x10100840 0xcc 	
mww 0x10100844 0xff   
mww 0x10100848 0x70   
mww 0x10100854 0xcc   
mww 0x10100858 0xff   
mww 0x1010085c 0x50   
mww 0x10100870 0x88   
mww 0x10100874 0xff   
mww 0x10100878 0x3  
mww 0x10100880 0xcc   
mww 0x10100884 0x88   
mww 0x10100888 0x3f   
mww 0x1010088c 0x4  
mww 0x10100ac4 0x0
mww 0x10100ac8 0x0
mww 0x10100acc 0x0
mww 0x10100ad0 0x0
mww 0x10100ad4 0x0
mww 0x10100ad8 0x0
mww 0x10100adc 0x0
mww 0x10100ae0 0x0
mww 0x10100ae4 0x0
mww 0x10100ae8 0x0
mww 0x10100af0 0x0
mww 0x10100af4 0x0
mww 0x10100af8 0x0
mww 0x10100b20 0x0
mww 0x10100b24 0x0
mww 0x10100aec 0x0
mww 0x10100b28 0x0
mww 0x10100b50 0x0

#PHY TXDQ deskew
mww 0x10100afc 0x0
mww 0x10100b00 0x0
mww 0x10100b04 0x0
mww 0x10100b08 0x0
mww 0x10100b0c 0x0
mww 0x10100b10 0x0
mww 0x10100b14 0x0
mww 0x10100b18 0x0
#PHY TXDQS deskew
mww 0x10100b1c 0x0
#PHY RXDQ deskew
mww 0x10100b2c 0x9
mww 0x10100b30 0x1
mww 0x10100b34 0x1
mww 0x10100b38 0x1
mww 0x10100b3c 0x9
mww 0x10100b40 0x9
mww 0x10100b44 0x9
mww 0x10100b48 0x9
#PHY RXDQS deskew
mww 0x10100b4c 0x9
#IO settings finish



#DDR init start
#set CL in PHY
mww 0x10100838 0xa0
#PHY init
mww 0x10100408 0x0
sleep 100
mww 0x1010002c 0x132
#close auto refresh
mww 0x10100058 0x8360f000
#exit self-refresh
mww 0x10100004 0x0
sleep 100
#set EMRS
mww 0x10100014 0x41b60
mww 0x10100018 0x10
#MDDRC config
mww 0x1010001c 0x80000600
mww 0x10100020 0x785
#DDR timing
mww 0x10100050 0xd555100c
mww 0x10100054 0xff037a31
mww 0x10100058 0x8360f093
mww 0x1010005c 0xffdff6f4
#dtrctrl close ddrc training
mww 0x101000ac 0x3000301
#odt of DDR write enable/read disable
mww 0x101000f4 0x1
#start DDR initialization
mww 0x10100008 0x1
sleep 100
#start PHY training
mww 0x10100808 0x2
mww 0x1010083c 0xa
mww 0x101008e0 0x19
mww 0x10100920 0x29
mww 0x101009c0 0x2c
#DDR init done

#QoS settings
mww 0x10100100  0x67  
#MCU
mww 0x10100150  0x6   
#A9
mww 0x10100154  0x2   
#DMAC
mww 0x10100158  0x4   
#PCIE
mww 0x1010015c  0x4   
#USB/NANDC/SFC/SDIO
mww 0x10100160  0x2   
#SF
mww 0x10100164  0x1   
#PVR
mww 0x10100168  0x1   
#VO(low)
mww 0x1010016c  0x10ff1   
#TDE
mww 0x10100170  0x3   
#JPEG
mww 0x10100174  0x10ff1   
#VEDU
mww 0x10100178  0x10ff1   
#VDH  3/4?
mww 0x10100180  0x3   
#AO
mww 0x10100188  0x100f1   
#VO(high)
mww 0x1010018c  0x10000
#QoS settings finish

echo "---init ok---"
