forked from JuanMiguelBG/rk356x-kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathio-domain.sh
executable file
·307 lines (280 loc) · 8.31 KB
/
io-domain.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
#!/bin/sh
# SPDX-License-Identifier: (GPL-2.0+ OR MIT)
# Copyright (c) 2021 Rockchip Electronics Co., Ltd.
exit 0
PMUIO2=0
VCCIO1=0
VCCIO3=0
VCCIO4=0
VCCIO5=0
VCCIO6=0
VCCIO7=0
DTS_PMUIO2=0
DTS_VCCIO1=0
DTS_VCCIO3=0
DTS_VCCIO4=0
DTS_VCCIO5=0
DTS_VCCIO6=0
DTS_VCCIO7=0
DTS_NAME=$1.dts.tmp
CheckBckfileRet=0
checklistRst=0
GetVoltageFromDtsVal=0
ShowChecklist()
{
PMUIO2=$(whiptail --title "IO Domain Checklist" --menu --nocancel\
"Get the corresponding value from the hardware schematic diagram" 15 60 2 \
"1800000" "PMUIO2 Supply Power Voltage(uV)" \
"3300000" "PMUIO2 Supply Power Voltage(uV)" 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose Cancel."
checklistRst=1
fi
VCCIO1=$(whiptail --title "IO Domain Checklist" --menu --nocancel\
"Get the corresponding value from the hardware schematic diagram" 15 60 2 \
"1800000" "VCCIO1 Supply Power Voltage(uV)" \
"3300000" "VCCIO1 Supply Power Voltage(uV)" 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose Cancel."
checklistRst=1
fi
VCCIO3=$(whiptail --title "IO Domain Checklist" --menu --nocancel\
"Get the corresponding value from the hardware schematic diagram" 15 60 2 \
"1800000" "VCCIO3 Supply Power Voltage(uV)" \
"3300000" "VCCIO3 Supply Power Voltage(uV)" 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose Cancel."
checklistRst=1
fi
VCCIO4=$(whiptail --title "IO Domain Checklist" --menu --nocancel\
"Get the corresponding value from the hardware schematic diagram" 15 60 2 \
"1800000" "VCCIO4 Supply Power Voltage(uV)" \
"3300000" "VCCIO4 Supply Power Voltage(uV)" 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose Cancel."
checklistRst=1
fi
VCCIO5=$(whiptail --title "IO Domain Checklist" --menu --nocancel\
"Get the corresponding value from the hardware schematic diagram" 15 60 2 \
"1800000" "VCCIO5 Supply Power Voltage(uV)" \
"3300000" "VCCIO5 Supply Power Voltage(uV)" 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose Cancel."
checklistRst=1
fi
VCCIO6=$(whiptail --title "IO Domain Checklist" --menu --nocancel\
"Get the corresponding value from the hardware schematic diagram" 15 60 2 \
"1800000" "VCCIO6 Supply Power Voltage(uV)" \
"3300000" "VCCIO6 Supply Power Voltage(uV)" 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose Cancel."
checklistRst=1
fi
VCCIO7=$(whiptail --title "IO Domain Checklist" --menu --nocancel\
"Get the corresponding value from the hardware schematic diagram" 15 60 2 \
"1800000" "VCCIO7 Supply Power Voltage(uV)" \
"3300000" "VCCIO7 Supply Power Voltage(uV)" 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose Cancel."
checklistRst=1
fi
}
DtsIoDomainVoltageVal=0
DtsIoDomainVoltage()
{
DtsIoDomainVoltageVal=0
flags=0
if [ -f $DTS_NAME ];then
echo "found $DTS_NAME"
fi
supply=$(cat $DTS_NAME \
| grep $1 \
| cut -d "&" -f 2 \
| cut -d ">" -f 1)
#supply_str=$supply":"
ldo_str=$(cat $DTS_NAME \
| awk 'BEGIN {RS="\n\n+";ORS="\n\n"}/regulator-name/{print $0}' \
| awk BEGIN{RS=EOF}'{gsub(/\n/," ");print $0}' \
| grep $supply \
| awk '{print $2}' \
| awk -F 'SWITCH_REG' '{print $2}')
if [ "$ldo_str" != "" ];then
DtsIoDomainVoltageVal=3300000
else
DtsIoDomainVoltageVal=$(cat $DTS_NAME \
| awk 'BEGIN {RS="\n\n+";ORS="\n\n"}/regulator-name/{print $0}' \
| awk BEGIN{RS=EOF}'{gsub(/\n/," ");print $0}' \
|grep $supply \
| awk -F 'regulator-max-microvolt' '{print $2}' \
| cut -d "<" -f 2 \
| cut -d ">" -f 1)
fi
}
GetIoDomainVoltageFromDts()
{
DtsIoDomainVoltage "pmuio2-supply"
DTS_PMUIO2=$DtsIoDomainVoltageVal
DtsIoDomainVoltage "vccio1-supply"
DTS_VCCIO1=$DtsIoDomainVoltageVal
DtsIoDomainVoltage "vccio3-supply"
DTS_VCCIO3=$DtsIoDomainVoltageVal
DtsIoDomainVoltage "vccio4-supply"
DTS_VCCIO4=$DtsIoDomainVoltageVal
DtsIoDomainVoltage "vccio5-supply"
DTS_VCCIO5=$DtsIoDomainVoltageVal
DtsIoDomainVoltage "vccio6-supply"
DTS_VCCIO6=$DtsIoDomainVoltageVal
DtsIoDomainVoltage "vccio7-supply"
DTS_VCCIO7=$DtsIoDomainVoltageVal
}
CheckVoltageWithBackupfile()
{
CheckBckfileRet=2
val=$(cat $DTS_NAME.domain \
| grep PMUIO2 \
| cut -d ":" -f 2)
if [ "$val" != "$DTS_PMUIO2" ];then
CheckBckfileRet=1
echo "PMUIO2 Supply Power Voltage has changed!!! please reconfirm!!!"
fi
val=$(cat $DTS_NAME.domain \
| grep VCCIO1 \
| cut -d ":" -f 2)
if [ "$val" != "$DTS_VCCIO1" ];then
CheckBckfileRet=1
echo "VCCIO1 Supply Power Voltage has changed!!! please reconfirm!!!"
fi
val=$(cat $DTS_NAME.domain \
| grep VCCIO3 \
| cut -d ":" -f 2)
if [ "$val" != "$DTS_VCCIO3" ];then
CheckBckfileRet=1
echo "VCCIO3 Supply Power Voltage has changed!!! please reconfirm!!!"
fi
val=$(cat $DTS_NAME.domain | grep VCCIO4 | cut -d ":" -f 2)
if [ "$val" != "$DTS_VCCIO4" ];then
ret=1
echo "VCCIO4 Supply Power Voltage has changed!!! please reconfirm!!!"
fi
val=$(cat $DTS_NAME.domain \
| grep VCCIO5 \
| cut -d ":" -f 2)
if [ "$val" != "$DTS_VCCIO5" ];then
CheckBckfileRet=1
echo "VCCIO5 Supply Power Voltage has changed!!! please reconfirm!!!"
fi
val=$(cat $DTS_NAME.domain \
| grep VCCIO6 \
| cut -d ":" -f 2)
if [ "$val" != "$DTS_VCCIO6" ];then
CheckBckfileRet=1
echo "VCCIO6 Supply Power Voltage has changed!!! please reconfirm!!!"
fi
val=$(cat $DTS_NAME.domain \
| grep VCCIO7 \
| cut -d ":" -f 2)
if [ "$val" != "$DTS_VCCIO7" ];then
CheckBckfileRet=1
echo "VCCIO7 Supply Power Voltage has changed!!! please reconfirm!!!"
fi
}
CheckVoltageWithEnter()
{
checklistRst=0
if [ $PMUIO2 -ne $DTS_PMUIO2 ];then
checklistRst=1
echo "PMUIO2 Supply Power Voltage has changed!!! please reconfirm!!!"
fi
if [ $VCCIO1 -ne $DTS_VCCIO1 ];then
checklistRst=1
echo "VCCIO1 Supply Power Voltage has changed!!! please reconfirm!!!"
fi
if [ $VCCIO3 -ne $DTS_VCCIO3 ];then
checklistRst=1
echo "VCCIO3 Supply Power Voltage has changed!!! please reconfirm!!!"
fi
if [ $VCCIO4 -ne $DTS_VCCIO4 ];then
checklistRst=1
echo "VCCIO4 Supply Power Voltage has changed!!! please reconfirm!!!"
fi
if [ $VCCIO5 -ne $DTS_VCCIO5 ];then
checklistRst=1
echo "VCCIO5 Supply Power Voltage has changed!!! please reconfirm!!!"
fi
if [ $VCCIO6 -ne $DTS_VCCIO6 ];then
checklistRst=1
echo "VCCIO6 Supply Power Voltage has changed!!! please reconfirm!!!"
fi
if [ $VCCIO7 -ne $DTS_VCCIO7 ];then
checklistRst=1
echo "VCCIO7 Supply Power Voltage has changed!!! please reconfirm!!!"
fi
}
IsRK356x=$(cat $DTS_NAME | grep sdhci@fe310000)
if [ "$IsRK356x" = "" ];then
echo "is not rk356x"
exit 0
fi
GetIoDomainVoltageFromDts
if [ -f $DTS_NAME.domain ];then
CheckVoltageWithBackupfile
fi
if [ "$CheckBckfileRet" != "2" ];then
ShowChecklist
CheckVoltageWithEnter
if [ $checklistRst -eq 0 ]; then
if [ -f $DTS_NAME.domain ];then
rm -rf $DTS_NAME.domain
fi
echo "PMUIO2 Supply Power Voltage1:$PMUIO2" >> $DTS_NAME.domain
echo "VCCIO1 Supply Power Voltage1:$VCCIO1" >> $DTS_NAME.domain
echo "VCCIO3 Supply Power Voltage1:$VCCIO3" >> $DTS_NAME.domain
echo "VCCIO4 Supply Power Voltage1:$VCCIO4" >> $DTS_NAME.domain
echo "VCCIO5 Supply Power Voltage1:$VCCIO5" >> $DTS_NAME.domain
echo "VCCIO6 Supply Power Voltage1:$VCCIO6" >> $DTS_NAME.domain
echo "VCCIO7 Supply Power Voltage1:$VCCIO7" >> $DTS_NAME.domain
echo 0
else
echo "io-domian default as:
&pmu_io_domains {
status = "okay";
pmuio1-supply = <&vcc3v3_pmu>;
pmuio2-supply = <&vcc3v3_pmu>;
vccio1-supply = <&vccio_acodec>;
vccio3-supply = <&vccio_sd>;
vccio4-supply = <&vcc_3v3>;
vccio5-supply = <&vcc_3v3>;
vccio6-supply = <&vcc_3v3>;
vccio7-supply = <&vcc_3v3>;
};
TODO:
Need to be modified according to the actual hardware
for example rk3568-evb:
&pmu_io_domains {
status = "okay";
pmuio1-supply = <&vcc3v3_pmu>;
pmuio2-supply = <&vcc3v3_pmu>;
vccio1-supply = <&vccio_acodec>;
vccio3-supply = <&vccio_sd>;
vccio4-supply = <&vcc_1v8>;
vccio5-supply = <&vcc_3v3>;
vccio6-supply = <&vcc_1v8>;
vccio7-supply = <&vcc_3v3>;
};
io-domain docs:
Android11 SDK:
RKDocs/android/Rockchip_Developer_Guide_Android11_SDK_V1.1.2_CN.pdf or newer.
RK356X Linux SDK:
docs/RK356X/Rockchip_RK356X_Introduction_IO_Power_Domains_Configuration.pdf
docs/Common/IO-DOMAIN/Rockchip_Developer_Guide_Linux_IO_DOMAIN_CN.pdf
"
exit 1
fi
fi