1setenv bootargs ''
2
3m4=''
4kernelimage=zImage
5bootcommand=bootz
6a_base=0x10000000
7
8#grab 1st 2/3 characters of string
9setexpr cpu2 sub "^(..?).*" "\\1" "${imx_cpu}"
10setexpr cpu3 sub "^(..?.?).*" "\\1" "${imx_cpu}"
11if itest.s x51 == "x${cpu2}" ; then
12	a_base=0x90000000
13elif itest.s x53 == "x${cpu2}"; then
14	a_base=0x70000000
15elif itest.s x6SX == "x${cpu3}" || itest.s x6U == "x${cpu2}" || itest.s x7D == "x${cpu2}"; then
16	a_base=0x80000000
17elif itest.s x8M == "x${cpu2}"; then
18	a_base=0x40000000
19	kernelimage=Image
20	bootcommand=booti
21fi
22if itest.s "x1" == "x${m4enabled}" ; then
23	run m4boot;
24	m4='-m4';
25fi
26
27setexpr a_script  ${a_base} + 0x00800000
28setexpr a_zImage  ${a_base} + 0x00800000
29setexpr a_fdt     ${a_base} + 0x03000000
30setexpr a_initrd  ${a_base} + 0x03100000
31setexpr a_reset_cause_marker ${a_base} + 0x80
32setexpr a_reset_cause	     ${a_base} + 0x84
33
34if itest.s "x" == "x${board}" ; then
35	echo "!!!! Error: Your u-boot is outdated. Please upgrade.";
36	exit;
37fi
38
39if itest.s "x" == "x${fdt_file}" ; then
40	if itest.s x51 == "x${cpu2}" ; then
41		fdt_file=imx51-${board}${m4}.dtb;
42	elif itest.s x53 == "x${cpu2}" ; then
43		fdt_file=imx53-${board}${m4}.dtb;
44	elif itest.s x6DL == "x${cpu3}" || itest.s x6SO == "x${cpu3}" ; then
45		fdt_file=imx6dl-${board}.dtb;
46	elif itest.s x6QP == "x${cpu3}" ; then
47		fdt_file=imx6qp-${board}.dtb;
48	elif itest.s x6SX == "x${cpu3}" ; then
49		fdt_file=imx6sx-${board}${m4}.dtb;
50	elif itest.s x6UL == "x${cpu3}" ; then
51		fdt_file=imx6ull-${board}.dtb;
52	elif itest.s x7D == "x${cpu2}" ; then
53		fdt_file=imx7d-${board}${m4}.dtb;
54	elif itest.s x8MM == "x${cpu3}" ; then
55		fdt_file=imx8mm-${board}${m4}.dtb;
56	elif itest.s x8MN == "x${cpu3}" ; then
57		fdt_file=imx8mn-${board}${m4}.dtb;
58	elif itest.s x8MP == "x${cpu3}" ; then
59		if itest *0x30360800 == 0x00824310 ; then
60			fdt_file=imx8mp-a0-${board}${m4}.dtb;
61		else
62			fdt_file=imx8mp-${board}${m4}.dtb;
63		fi
64	elif itest.s x8MQ == "x${cpu3}" ; then
65		fdt_file=imx8mq-${board}${m4}.dtb;
66	else
67		fdt_file=imx6q-${board}.dtb;
68	fi
69fi
70
71if itest.s x${distro_bootpart} == x ; then
72	distro_bootpart=1
73fi
74
75if load ${devtype} ${devnum}:${distro_bootpart} ${a_script} uEnv.txt ; then
76    env import -t ${a_script} ${filesize}
77fi
78
79if itest.s x${console} != x ; then
80	setenv bootargs ${bootargs} console=${console},115200
81fi
82if itest.s "x" == "x$vmalloc" ; then
83	vmalloc=400M
84fi
85if itest.s x${consoleblank} == x ; then
86	consoleblank=0
87fi
88setenv bootargs ${bootargs} vmalloc=${vmalloc} consoleblank=${consoleblank} rootwait fixrtc cpu=${imx_cpu} board=${board} uboot_release=${uboot_release}
89
90if load ${devtype} ${devnum}:${distro_bootpart} ${a_fdt} ${prefix}${fdt_file} ; then
91	fdt addr ${a_fdt}
92else
93	echo "!!!! Error loading ${prefix}${fdt_file}";
94	exit;
95fi
96
97fdt resize 4096
98if itest.s "x" != "x${cmd_board}" ; then
99	run cmd_board
100fi
101if itest.s "x" != "x${cmd_custom}" ; then
102	run cmd_custom
103fi
104if itest.s "x" != "x${cmd_hdmi}" ; then
105	run cmd_hdmi
106	if itest.s x != x${allow_noncea} ; then
107		setenv bootargs ${bootargs} mxc_hdmi.only_cea=0;
108		echo "non-CEA modes allowed on HDMI, audio may be affected";
109	fi
110fi
111if itest.s "x" != "x${cmd_lcd}" ; then
112	run cmd_lcd
113fi
114if itest.s "x" != "x${cmd_lcd2}" ; then
115	run cmd_lcd2
116fi
117if itest.s "x" != "x${cmd_lvds}" ; then
118	run cmd_lvds
119fi
120if itest.s "x" != "x${cmd_lvds2}" ; then
121	run cmd_lvds2
122fi
123if itest.s "x" != "x${cmd_mipi}" ; then
124	run cmd_mipi
125fi
126
127if test "sata" = "${devtype}" ; then
128	setenv bootargs "${bootargs} root=/dev/sda${distro_bootpart}" ;
129elif test "usb" = "${devtype}" ; then
130	setenv bootargs "${bootargs} root=/dev/sda${distro_bootpart}" ;
131else
132	setenv bootargs "${bootargs} root=/dev/mmcblk${devnum}p${distro_bootpart}"
133fi
134
135if itest.s "x" != "x${disable_msi}" ; then
136	setenv bootargs ${bootargs} pci=nomsi
137fi;
138
139if itest.s "x" != "x${disable_giga}" ; then
140	setenv bootargs ${bootargs} fec.disable_giga=1
141fi
142
143if itest.s "x" != "x${wlmac}" ; then
144	setenv bootargs ${bootargs} wlcore.mac=${wlmac}
145fi
146
147if itest.s "x" != "x${gpumem}" ; then
148	setenv bootargs ${bootargs} galcore.contiguousSize=${gpumem}
149fi
150
151if itest.s "x" != "x${cma}" ; then
152	setenv bootargs ${bootargs} cma=${cma}
153fi
154
155if itest.s "x" != "x${loglevel}" ; then
156	setenv bootargs ${bootargs} loglevel=${loglevel}
157fi
158
159if itest.s "x" != "x${show_fdt}" ; then
160	fdt print /
161fi
162
163if itest.s "x" != "x${show_env}" ; then
164	printenv
165fi
166
167if load ${devtype} ${devnum}:${distro_bootpart} ${a_zImage} ${prefix}${kernelimage} ; then
168	${bootcommand} ${a_zImage} - ${a_fdt}
169fi
170echo "Error loading kernel image"
171