blob: 8e99377dd050c2b5f0f2865ab466322608c201a8 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001;create clocks area
2local &pll_reg
3local &foutvco
4local &fout2
5local &fout3
6
7area.create clocks 200 300
8area.clear clocks
9
10area.select clocks
11area.view clocks
12
13if state.run()
14(
15 break
16)
17
18;disable mmu
19&cr=data.long(c15:0x1)
20&tmp=&cr&(~0x1)
21per.s c15:0x1 %LONG &tmp
22
23print "*********************PLL********************************************"
24&pll_reg=0x0013b008
25&fref=26000000.
26print "check mpll..."
27Gosub calc_pll
28
29&pll_reg=0x0013b010
30&fref=26000000.
31print "check upll..."
32Gosub calc_pll
33
34&pll_reg=0x0013B018
35&tmp=data.long(D:0x0013B018)
36&tmp=(&tmp>>25)&0x3
37if (&tmp==1)
38(
39&fref=30720000.
40)
41else
42(
43&fref=26000000.
44)
45print "check dpll..."
46Gosub calc_pll
47
48&pll_reg=0x0013b110
49&fref=26000000.
50print "check gpll..."
51Gosub calc_pll
52
53print "*********************M0 CLK********************************************"
54&tmp=data.long(D:0x0013b038)
55&tmp=&tmp&0x3
56if (&tmp==0)
57(
58 print "M0 clk sel main_clk"
59)
60if (&tmp==1)
61(
62 print "M0 clk sel 104M"
63)
64if (&tmp==2)
65(
66 print "M0 clk sel 78M"
67)
68if (&tmp==3)
69(
70 print "M0 clk sel 32K"
71)
72
73print "*********************A53 CLK********************************************"
74&tmp=data.long(D:0x01306040)
75&tmp=&tmp&0x3
76if (&tmp==0)
77(
78
79 print "ufi clk sel main_clk"
80)
81if (&tmp==1)
82(
83 print "ufi clk sel 624M"
84)
85if (&tmp==2)
86(
87 print "ufi clk sel 312M"
88)
89if (&tmp==3)
90(
91 print "ufi clk sel 156M"
92)
93
94print "*********************PS CLK********************************************"
95&tmp=data.long(D:0x01306020)
96&tmp=&tmp&0x3
97if (&tmp==0)
98(
99 print "pscpu clk sel main_clk"
100)
101if (&tmp==1)
102(
103 print "pscpu clk sel 624M"
104)
105if (&tmp==2)
106(
107 print "pscpu clk sel 312M"
108)
109if (&tmp==3)
110(
111 print "pscpu clk sel 156M"
112)
113
114print "*********************PHY CLK********************************************"
115&tmp=data.long(D:0x01306030)
116&tmp=&tmp&0x3
117if (&tmp==0)
118(
119 print "phycpu clk sel main_clk"
120)
121if (&tmp==1)
122(
123 print "phycpu clk sel 491M"
124)
125if (&tmp==2)
126(
127 print "phycpu clk sel 312M"
128)
129if (&tmp==3)
130(
131 print "phycpu clk sel 156M"
132)
133
134print "*********************AXI CLK********************************************"
135&tmp=data.long(D:0x01306000)
136&tmp=&tmp&0x7
137if (&tmp==0)
138(
139 print "axi clk sel main_clk"
140)
141if (&tmp==1)
142(
143 print "axi clk sel 156M"
144)
145if (&tmp==2)
146(
147 print "axi clk sel 124.8M"
148)
149if (&tmp==3)
150(
151 print "axi clk sel 104M"
152)
153if (&tmp==4)
154(
155 print "axi clk sel 78M"
156)
157if (&tmp==5)
158(
159 print "axi clk sel 52M"
160)
161if (&tmp==6)
162(
163 print "axi clk sel 39M"
164)
165if (&tmp==7)
166(
167 print "axi clk sel 6.5M"
168)
169
170print "*********************DDR CLK********************************************"
171&tmp=data.long(D:0x01306050)
172&tmp=&tmp&0x3
173if (&tmp==0)
174(
175 print "ddr io clk sel 312M"
176)
177if (&tmp==1)
178(
179 print "ddr io clk sel 400M"
180)
181if (&tmp==2)
182(
183 print "ddr io clk sel 208M"
184)
185if (&tmp==3)
186(
187 print "ddr io clk sel 156M"
188)
189;restore mmu config
190per.s c15:0x1 %LONG &cr
191ENDDO
192
193
194;*****************************************************************
195calc_pll:
196
197local &tmp1
198local &tmp2
199&tmp1=data.long(D:&pll_reg)
200&tmp2=data.long(D:&pll_reg+0x4)
201&power=(&tmp1>>0x1f)&0x1
202if (&power==1)
203(
204 print "pll is power down"
205)
206else
207(
208 print "pll is power up"
209)
210
211&lock=(&tmp1>>0x1e)&0x1
212if (&lock==1)
213(
214 print "pll is locked"
215)
216else
217(
218 print "pll is unlocked"
219)
220
221&refdiv=(&tmp1>>0x12)&((0x1<<0x6)-1)
222&fbdiv=(&tmp1>>0x6)&((0x1<<0xc)-1)
223&frac=(&tmp2)&((0x1<<0x18)-1)
224&foutvco=(&fref/&refdiv)*(&fbdiv+&frac)
225print "pll foutvco="+"&foutvco"
226
227&postdiv1=(&tmp1>>0x3)&((0x1<<0x3)-0x1)
228&postdiv2=(&tmp1)&((0x1<<0x3)-0x1)
229&foutpostdiv=&foutvco/&postdiv1/&postdiv2
230&fout2=&foutpostdiv/0x2
231&fout3=&foutpostdiv/0x3
232&fout4=&foutpostdiv/0x4
233print "pll foutpostdiv="+"&foutpostdiv"
234print "pll fout2="+"&fout2"
235print "pll fout3="+"&fout3"
236print "pll fout4="+"&fout4"
237
238RETURN