xref: /OK3568_Linux_fs/device/rockchip/common/scripts/check-power-domain.sh (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1#!/bin/bash -e
2
3tmpdir=`mktemp -d`
4dump_kernel_dtb_file=`mktemp -p $tmpdir`
5tmp_phandle_file=`mktemp -p $tmpdir`
6tmp_io_domain_file=`mktemp -p $tmpdir`
7tmp_regulator_microvolt_file=`mktemp -p $tmpdir`
8tmp_final_target=`mktemp -p $tmpdir`
9tmp_grep_file=`mktemp -p $tmpdir`
10
11dtc -q -I dtb -O dts -o ${dump_kernel_dtb_file} "$RK_KERNEL_DTB"
12
13if [ "$RK_SECURITY_CHECK_METHOD" = "DM-E" ] ; then
14	if ! grep -q "compatible = \"linaro,optee-tz\";" $dump_kernel_dtb_file; then
15		echo "Please add: "
16		echo "        optee: optee {"
17		echo "                compatible = \"linaro,optee-tz\";"
18		echo "                method = \"smc\";"
19		echo "                status = \"okay\";"
20		echo "        }"
21		echo "To your dts file"
22		rm -rf $tmpdir
23		exit 1;
24	fi
25fi
26
27if ! grep -Pzo "io-domains\s*{(\n|\w|-|;|=|<|>|\"|_|\s|,)*};" $dump_kernel_dtb_file 1>$tmp_grep_file 2>/dev/null; then
28	echo "Not Found io-domains in $RK_KERNEL_DTS"
29	rm -rf $tmpdir
30	exit 0
31fi
32grep -a supply $tmp_grep_file > $tmp_io_domain_file || true
33rm -f $tmp_grep_file
34awk '{print "phandle = " $3}' $tmp_io_domain_file > $tmp_phandle_file
35
36while IFS= read -r item_phandle && IFS= read -u 3 -r item_domain
37do
38	echo "${item_domain% *}" >> $tmp_regulator_microvolt_file
39	tmp_none_item=${item_domain% *}
40	cmds="grep -Pzo \"{(\\n|\w|-|;|=|<|>|\\\"|_|\s)*"$item_phandle\"
41
42	eval "$cmds $dump_kernel_dtb_file | strings | grep "regulator-m..-microvolt" >> $tmp_regulator_microvolt_file" || \
43		eval "sed -i \"/${tmp_none_item}/d\" $tmp_regulator_microvolt_file" && continue
44
45	echo >> $tmp_regulator_microvolt_file
46done < $tmp_phandle_file 3<$tmp_io_domain_file
47
48while read -r regulator_val
49do
50	if echo ${regulator_val} | grep supply &>/dev/null; then
51		echo -e "\n\n\e[1;33m${regulator_val%*=}\e[0m" >> $tmp_final_target
52	else
53		tmp_none_item=${regulator_val##*<}
54		tmp_none_item=${tmp_none_item%%>*}
55		echo -e "${regulator_val%%<*} \e[1;31m$(( $tmp_none_item / 1000 ))mV\e[0m" >> $tmp_final_target
56	fi
57done < $tmp_regulator_microvolt_file
58
59echo -e "\e[41;1;30m PLEASE CHECK BOARD GPIO POWER DOMAIN CONFIGURATION !!!!!\e[0m"
60echo -e "\e[41;1;30m <<< ESPECIALLY Wi-Fi/Flash/Ethernet IO power domain >>> !!!!!\e[0m"
61echo -e "\e[41;1;30m Check Node [pmu_io_domains] in the file: $RK_KERNEL_DTS \e[0m"
62echo
63echo -e "\e[41;1;30m 请再次确认板级的电源域配置!!!!!!\e[0m"
64echo -e "\e[41;1;30m <<< 特别是Wi-Fi,FLASH,以太网这几路IO电源的配置 >>> !!!!!\e[0m"
65echo -e "\e[41;1;30m 检查内核文件 $RK_KERNEL_DTS 的节点 [pmu_io_domains] \e[0m"
66cat $tmp_final_target
67
68rm -rf $tmpdir
69