Browse Source

Support Orange Pi 4A

Xunlong26765483 7 months ago
parent
commit
b4f0ff770b

+ 15 - 0
.gitignore

@@ -98,3 +98,18 @@ GTAGS
 prelink-riscv
 *.dtb
 tools/sunxi_proftool
+
+/boot0_sdcard.fex
+/boot0_sdcard.fex-linux5.15_360M
+/boot_package.cfg
+/boot_package.fex
+/dts/orangepi4a-u-boot-current.dts
+/dts/orangepi4a-u-boot-current.dts-bootargs
+/dts/orangepi4a-u-boot-current.dts-no-boot
+/dts/orangepi4a-u-boot.dts
+/dts/orangepizero3-u-boot-current.dts
+/monitor.fex
+/scp.fex
+/sunxi.fex
+/sys_config.fex
+/sys_config/

+ 1 - 1
Makefile

@@ -331,7 +331,7 @@ HOSTCXXFLAGS = -O2
 # Some Linux distributions (including RHEL7, SLES13, Debian 8) still
 # have older compilers as their default, so we make it explicit for
 # these that our host tools are GNU11 (i.e. C11 w/ GNU extensions).
-CSTD_FLAG := -std=gnu11
+#CSTD_FLAG := -std=gnu11
 ifeq ($(HOSTOS),linux)
 HOSTCFLAGS += $(CSTD_FLAG)
 endif

+ 1068 - 0
arch/arm/dts/board-uboot.dts

@@ -0,0 +1,1068 @@
+/*
+ * Allwinner Technology CO., Ltd. sun50iw10p1 soc board.
+ *
+ * soc board support.
+ */
+ #include <media_bus_format.h>
+
+/{
+	edp_panel_backlight: edp_backlight {
+		compatible = "pwm-backlight";
+		status = "okay";
+		brightness-levels = <
+			  0   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>;
+		default-brightness-level = <200>;
+		enable-gpios = <&pio PI 5 1 0 3 1>;
+		/* power-supply = <&reg_backlight_12v>; */
+		pwms = <&pwm 5 5000000 0>;
+	};
+
+	edp_panel: edp_panel {
+		compatible = "edp-general-panel";
+		status = "okay";
+		//enable1-gpios = <&pio PI 4 1 0 3 1>;
+		//enable2-gpios = <&pio PI 5 1 0 3 1>;
+		power0-supply = <&reg_dcdc4>;
+		backlight = <&edp_panel_backlight>;
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			panel_in: port@0 {
+				#address-cells = <1>;
+				#size-cells = <0>;
+				reg = <0>;
+				edp_panel_in: endpoint@0 {
+					reg = <0>;
+					remote-endpoint = <&edp_panel_out>;
+				};
+			};
+		};
+	};
+
+	backlight0: backlight0 {
+		compatible = "pwm-backlight";
+		status = "okay";
+		brightness-levels = <
+			  0   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>;
+		default-brightness-level = <200>;
+		enable-gpios = <&pio PI 2 1 0 3 1>;
+		pwms = <&pwm 4 50000 0>;
+	};
+
+	lvds_panel: lvds_panel@0 {
+		compatible = "sunxi-lvds";
+		status = "okay";
+		reg = <0>;
+		//power0-supply = <&reg_cldo3>;
+		//power1-supply = <&reg_dcdc4>;
+		//power2-supply = <&reg_cldo1>;
+		backlight = <&backlight0>;
+		bus-format = <MEDIA_BUS_FMT_RGB888_1X7X4_SPWG>;
+		display-timings {
+			native-mode = <&lvds_timing0>;
+			lvds_timing0: timing0 {
+				clock-frequency = <74871600>;
+				hback-porch = <70>;
+				hactive = <1280>;
+				hfront-porch = <83>;
+				hsync-len = <18>;
+				vback-porch = <13>;
+				vactive = <800>;
+				vfront-porch = <37>;
+				vsync-len = <10>;
+			};
+		};
+		port {
+			lvds_panel_in: endpoint {
+				remote-endpoint = <&lvds_panel_out>;
+			};
+		};
+	};
+	rgb_panel1: rgb_panel@1 {
+		compatible = "sunxi-rgb";
+		status = "disabled";
+		reg = <0>;
+		//power0-supply = <&reg_cldo3>;
+		//power1-supply = <&reg_dcdc4>;
+		//power2-supply = <&reg_cldo1>;
+
+		backlight = <&edp_panel_backlight>;
+
+		display-timings {
+			native-mode = <&rgb1_timing0>;
+
+			rgb1_timing0: timing0 {
+				clock-frequency = <74871600>;
+				hback-porch = <35>;
+				hactive = <1024>;
+				hfront-porch = <83>;
+				hsync-len = <161>;
+				vback-porch = <25>;
+				vactive = <600>;
+				vfront-porch = <15>;
+				vsync-len = <10>;
+			};
+		};
+		port {
+			rgb1_panel_in: endpoint {
+				remote-endpoint = <&rgb1_panel_out>;
+			};
+		};
+	};
+
+};
+
+&sunxi_drm {
+	route {
+		disp0_hdmi {
+			status = "okay";
+		};
+	};
+};
+
+&rgb1 {
+	status = "disabled";
+	pinctrl-0 = <&rgb24_pins_a>;
+	pinctrl-1 = <&rgb24_pins_b>;
+	pinctrl-names = "active","sleep";
+	ports {
+		port@1 {
+			reg = <1>;
+			rgb1_panel_out: endpoint@0 {
+				reg = <0>;
+				remote-endpoint = <&rgb1_panel_in>;
+			};
+		};
+	};
+};
+
+&lvds0 {
+	status = "disabled";
+//	dual-channel = <0>;
+	pinctrl-0 = <&lvds0_pins_a>;
+	pinctrl-1 = <&lvds0_pins_b>;
+	pinctrl-names = "active","sleep";
+	ports {
+		port@1 {
+			reg = <1>;
+			lvds_panel_out: endpoint@0 {
+				reg = <0>;
+				remote-endpoint = <&lvds_panel_in>;
+			};
+		};
+	};
+};
+
+&dsi0combophy {
+	status = "disabled";
+};
+
+&dsi1combophy {
+	status = "disabled";
+};
+
+&dlcd0 {
+	status = "disabled";
+};
+
+&dlcd1 {
+	status = "disabled";
+};
+
+&vo0 {
+	status = "okay";
+};
+
+&vo1 {
+	status = "disabled";
+};
+
+&tv0 {
+	status = "okay";
+};
+
+&tv1 {
+	status = "disabled";
+};
+
+&de {
+	chn_cfg_mode = <3>;
+	status = "okay";
+};
+
+&hdmi {
+	hdmi_used = <1>;
+	cldo1-supply = <&reg_cldo1>;
+	hdmi_power0 = "cldo1";
+	//vmid-supply = <&reg_vmid>;
+	hdmi_power1 = "vmid";
+	hdmi_power_cnt = <2>;
+	hdmi_hdcp_enable = <1>;
+	hdmi_hdcp22_enable = <0>;
+	hdmi_cts_compatibility = <0>;
+	hdmi_cec_support = <1>;
+	hdmi_cec_super_standby = <1>;
+	hdmi_skip_bootedid = <1>;
+
+	ddc_en_io_ctrl = <0>;
+	power_io_ctrl = <0>;
+
+	status = "okay";
+};
+
+&drm_edp {
+	status = "disabled";
+
+	edp_colordepth = <8>; /* 6/8/10/12/16 */
+	edp_color_fmt = <0>; /* 0:RGB  1: YUV444  2: YUV422 */
+
+	vcc-edp-supply = <&reg_bldo3>;
+	vdd-edp-supply = <&reg_dcdc2>;
+	ports {
+		edp_out: port@1 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <1>;
+			edp_panel_out: endpoint@0 {
+				reg = <0>;
+				remote-endpoint = <&edp_panel_in>;
+			};
+		};
+	};
+};
+
+&power_sply {
+	bldo1_vol = <1800>;
+	bldo2_vol = <1001800>;
+	bldo3_vol = <1001800>;
+	cldo2_vol = <1001800>;
+	cldo4_vol = <1103300>;
+	dcdc1_mode = <1>;
+	dcdc3_mode = <1>;
+	ext_dcdc0_mode = <1>;
+	ext_dcdc1_mode = <1>;
+	ext_dcdc2_mode = <1>;
+	dcdc2_mode = <1>;
+	bc12_mode = <0>;
+	ntc_status = <2>;
+	battery_exist = <0>;
+};
+
+&platform {
+	eraseflag   = <1>;
+	next_work   = <3>;
+	debug_mode  = <1>;
+};
+
+/*
+ *recovery_key_used :  模块使能端,    1:开启,0:关闭
+ *press_mode_enable :  长短按模式使能,1:开启,0:关闭
+ *                     a)如果开启了该模式,则key_work_mode失效,short_press_mode和long_press_mode生效,
+ *                     recovery按键可以通过长按和短按来触发两种不同的模式;
+ *                     b)如果关闭了该模式,则key_work_mode生效,recovery按键只能触发一种模式.
+ *key_work_mode     :  模式选择
+ *                     0: 刷机,
+ *                     1: 一键恢复(uboot阶段),
+ *                     2: 安卓recovery,
+ *                     3: 安卓恢复出厂设置.
+ *                     如果不设置,模式为安卓recovery.
+ *short_press_mode  :  长按触发的模式,选项同上.
+ *long_press_mode   :  短按触发的模式,选项同上.
+ *key_press_time    :  定义长按的时间,单位:毫秒.
+ *recovery_key      :  按键配置.
+ */
+&adc_boot_recovery {
+       recovery_adc_used = <0x1>;
+       recovery_adc_channel = <0x1>;
+       press_mode_enable = <0x1>;
+       adc_work_mode = <0x2>;
+       short_press_mode = <0x0>;
+       long_press_mode = <0x2>;
+       key_press_time = <0x1388>;
+       key_min = <9>;
+       key_max = <11>;
+};
+
+&target {
+	boot_clock = <1008>;	/*CPU boot frequency, Unit: MHz*/
+	storage_type = <0xffffffff>; /*boot medium, 0-nand, 1-card0, 2-card2, -1(defualt)auto scan*/
+	burn_key = <1>;		/*1:support burn key; 0:not support burn key*/
+	dragonboard_test = <0>;	/*1:support card boot dragonboard; 0:not support card boot dragonboard*/
+};
+
+&charger0 {
+	pmu_safe_vol = <3400>;
+	ntc_cur = <50>;
+	safe_temp_H = <600>;//60
+	safe_temp_L = <0xFFFFFFCE>;//-5
+	pmu_bat_temp_para1 = <4592>;
+	pmu_bat_temp_para2 = <2781>;
+	pmu_bat_temp_para3 = <2125>;
+	pmu_bat_temp_para4 = <1738>;
+	pmu_bat_temp_para5 = <1390>;
+	pmu_bat_temp_para6 = <1118>;
+	pmu_bat_temp_para7 = <906>;
+	pmu_bat_temp_para8 = <606>;
+	pmu_bat_temp_para9 = <415>;
+	pmu_bat_temp_para10 = <290>;
+	pmu_bat_temp_para11 = <244>;
+	pmu_bat_temp_para12 = <206>;
+	pmu_bat_temp_para13 = <175>;
+	pmu_bat_temp_para14 = <150>;
+	pmu_bat_temp_para15 = <110>;
+	pmu_bat_temp_para16 = <83>;
+};
+
+&twi6 {
+	clock-frequency = <200000>;
+	pinctrl-0 = <&s_twi0_pins_a>;
+	pinctrl-1 = <&s_twi0_pins_b>;
+	twi-supply = <&reg_aldo3>;
+	no_suspend = <1>;
+	twi_drv_used = <1>;
+	status = "okay";
+	pmu0: pmu@34 {
+		compatible = "x-powers,axp2202";
+		status = "okay";
+		reg = <0x35>;
+		/* interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
+		 * interrupt-parent = <&gic>; */
+		x-powers,drive-vbus-en;
+
+		wakeup-source;
+
+		regulator0: regulators@0 {
+			reg_dcdc1: dcdc1 {
+				regulator-name = "axp2202-dcdc1";
+			};
+			reg_dcdc2: dcdc2 {
+				regulator-name = "axp2202-dcdc2";
+			};
+			reg_dcdc3: dcdc3 {
+				regulator-name = "axp2202-dcdc3";
+			};
+			reg_dcdc4: dcdc4 {
+				regulator-name = "axp2202-dcdc4";
+			};
+			reg_rtcldo: rtcldo {
+				/* RTC_LDO is a fixed, always-on regulator */
+				regulator-name = "axp2202-rtcldo";
+			};
+			reg_aldo1: aldo1 {
+				regulator-name = "axp2202-aldo1";
+			};
+			reg_aldo2: aldo2 {
+				regulator-name = "axp2202-aldo2";
+			};
+			reg_aldo3: aldo3 {
+				regulator-name = "axp2202-aldo3";
+			};
+			reg_aldo4: aldo4 {
+				regulator-name = "axp2202-aldo4";
+			};
+			reg_bldo1: bldo1 {
+				regulator-name = "axp2202-bldo1";
+			};
+			reg_bldo2: bldo2 {
+				regulator-name = "axp2202-bldo2";
+			};
+			reg_bldo3: bldo3 {
+				regulator-name = "axp2202-bldo3";
+			};
+			reg_bldo4: bldo4 {
+				regulator-name = "axp2202-bldo4";
+			};
+			reg_cldo1: cldo1 {
+				regulator-name = "axp2202-cldo1";
+			};
+			reg_cldo2: cldo2 {
+				regulator-name = "axp2202-cldo2";
+			};
+			reg_cldo4: cldo4 {
+				regulator-name = "axp2202-cldo4";
+			};
+			reg_cpusldo: cpusldo {
+				regulator-name = "axp2202-cpusldo";
+			};
+		};
+	};
+};
+
+&recovery_key {
+	device_type = "recovery_key";
+	key_max = <11>;
+	key_min = <9>;
+};
+
+&pwm0_pin_a {
+	allwinner,pins = "PD23";
+	allwinner,function = "pwm0";
+	allwinner,drive = <0>;
+	allwinner,muxsel = <0x02>;
+};
+
+&pwm0_pin_b {
+	allwinner,pins = "PD23";
+	allwinner,function = "io_disabled";
+	allwinner,muxsel = <0x0f>;
+	allwinner,drive = <0>;
+	allwinner,pull = <0>;
+};
+
+&pwm1_pin_a {
+	allwinner,pins = "PD22";
+	allwinner,function = "pwm1";
+	allwinner,drive = <0>;
+	allwinner,muxsel = <0x02>;
+};
+
+&pwm1_pin_b {
+	allwinner,pins = "PD22";
+	allwinner,function = "io_disabled";
+	allwinner,muxsel = <0x0f>;
+	allwinner,drive = <0>;
+	allwinner,pull = <0>;
+};
+
+&pwm2_pin_a {
+	allwinner,pins = "PB11";
+	allwinner,function = "pwm2";
+	allwinner,drive = <0>;
+	allwinner,muxsel = <0x05>;
+};
+
+&pwm2_pin_b {
+	allwinner,pins = "PB11";
+	allwinner,function = "io_disabled";
+	allwinner,muxsel = <0x0f>;
+	allwinner,drive = <0>;
+	allwinner,pull = <0>;
+};
+
+&pwm3_pin_a {
+	allwinner,pins = "PB12";
+	allwinner,function = "pwm3";
+	allwinner,drive = <0>;
+	allwinner,muxsel = <0x05>;
+};
+
+&pwm3_pin_b {
+	allwinner,pins = "PB12";
+	allwinner,function = "io_disabled";
+	allwinner,muxsel = <0x0f>;
+	allwinner,drive = <0>;
+	allwinner,pull = <0>;
+};
+
+&pwm4_pin_a {
+	allwinner,pins = "PI3";
+	allwinner,function = "pwm4";
+	allwinner,drive = <0>;
+	allwinner,muxsel = <0x04>;
+};
+
+&pwm4_pin_b {
+	allwinner,pins = "PI3";
+	allwinner,function = "io_disabled";
+	allwinner,muxsel = <0x0f>;
+	allwinner,drive = <0>;
+	allwinner,pull = <0>;
+};
+
+&pwm5_pin_a {
+	allwinner,pins = "PI4";
+	allwinner,function = "pwm5";
+	allwinner,drive = <0>;
+	allwinner,muxsel = <0x04>;
+};
+
+&pwm5_pin_b {
+	allwinner,pins = "PI4";
+	allwinner,function = "io_disabled";
+	allwinner,muxsel = <0x0f>;
+	allwinner,drive = <0>;
+	allwinner,pull = <0>;
+};
+
+&pwm0 {
+	pinctrl-names = "active", "sleep";
+	pinctrl-0 = <&pwm0_pin_a>;
+	pinctrl-1 = <&pwm0_pin_b>;
+	status = "okay";
+};
+
+&pwm1 {
+	pinctrl-names = "active", "sleep";
+	pinctrl-0 = <&pwm1_pin_a>;
+	pinctrl-1 = <&pwm1_pin_b>;
+	status = "okay";
+};
+
+&pwm2 {
+	pinctrl-names = "active", "sleep";
+	pinctrl-0 = <&pwm2_pin_a>;
+	pinctrl-1 = <&pwm2_pin_b>;
+	status = "disabled";
+};
+
+&pwm3 {
+	pinctrl-names = "active", "sleep";
+	pinctrl-0 = <&pwm3_pin_a>;
+	pinctrl-1 = <&pwm3_pin_b>;
+	status = "disabled";
+};
+
+&pwm4 {
+	pinctrl-names = "active", "sleep";
+	pinctrl-0 = <&pwm4_pin_a>;
+	pinctrl-1 = <&pwm4_pin_b>;
+	status = "okay";
+};
+
+&pwm5 {
+	pinctrl-names = "active", "sleep";
+	pinctrl-0 = <&pwm5_pin_a>;
+	pinctrl-1 = <&pwm5_pin_b>;
+	status = "okay";
+};
+
+&sdc0_pins_a {
+	allwinner,pins = "PF0", "PF1", "PF2",
+			 "PF3", "PF4", "PF5";
+	allwinner,function = "sdc0";
+	allwinner,muxsel = <2>;
+	allwinner,drive = <3>;
+	allwinner,pull = <1>;
+};
+
+&sdc0_pins_b {
+	allwinner,pins = "PF0", "PF1", "PF2",
+			 "PF3", "PF4", "PF5";
+	allwinner,function = "io_disabled";
+	allwinner,muxsel = <7>;
+	allwinner,drive = <1>;
+	allwinner,pull = <1>;
+};
+
+&sdc0_pins_c {
+	allwinner,pins = "PF0", "PF1", "PF2",
+			 "PF3", "PF4", "PF5";
+	allwinner,function = "uart0_jtag";
+	allwinner,muxsel = <3>;
+	allwinner,drive = <1>;
+	allwinner,pull = <1>;
+};
+
+
+&sdc2_pins_a {
+	allwinner,pins = "PC1", "PC5", "PC6",
+			 "PC8", "PC9", "PC10", "PC11",
+			 "PC13", "PC14", "PC15", "PC16";
+	allwinner,function = "sdc2";
+	allwinner,muxsel = <3>;
+	allwinner,drive = <3>;
+	allwinner,pull = <1>;
+};
+
+&sdc2_pins_b {
+	allwinner,pins = "PC0", "PC1", "PC5", "PC6",
+			 "PC8", "PC9", "PC10", "PC11",
+			 "PC13", "PC14", "PC15", "PC16";
+	allwinner,function = "io_disabled";
+	allwinner,muxsel = <7>;
+	allwinner,drive = <1>;
+	allwinner,pull = <1>;
+};
+
+&sdc2_pins_c {
+	allwinner,pins = "PC0";
+	allwinner,function = "sdc2";
+	allwinner,muxsel = <3>;
+	allwinner,drive = <3>;
+	allwinner,pull = <2>;
+};
+
+&nand0_pins_a {
+	allwinner,pins = "PC0", "PC1", "PC2", "PC5",
+			 "PC8", "PC9", "PC10", "PC11",
+			 "PC12", "PC13", "PC14", "PC15",
+			 "PC16";
+	allwinner,pname= "nand0_we", "nand0_ale","nand0_cle", "nand0_nre",
+			 "nand0_d0", "nand0_d1", "nand0_d2", "nand0_d3",
+			 "nand0_d4", "nand0_d5", "nand0_d6", "nand0_d7",
+			 "nand0_ndqs";
+	allwinner,function = "nand0";
+	allwinner,muxsel = <2>;
+	allwinner,drive = <1>;
+	allwinner,pull = <0>;
+};
+
+&nand0_pins_b {
+	allwinner,pins = "PC4", "PC6", "PC03", "PC07";
+	allwinner,pname= "nand0_ce0", "nand0_rb0", "nand0_ce1", "nand0_rb1";
+	allwinner,function = "nand0";
+	allwinner,muxsel = <2>;
+	allwinner,drive = <1>;
+	allwinner,pull = <1>;	/* only RB&CE should be pulled up */
+};
+
+&nand0_pins_c {
+	allwinner,pins = "PC0", "PC1", "PC2", "PC3",
+			 "PC4", "PC5", "PC6", "PC7",
+			 "PC8", "PC9", "PC10", "PC11",
+			 "PC12", "PC13", "PC14", "PC15",
+			 "PC16";
+	allwinner,function = "io_disabled";
+	allwinner,muxsel = <7>;
+	allwinner,drive = <1>;
+	allwinner,pull = <0>;
+};
+
+&spi0_pins_a {
+	allwinner,pins = "PC12", "PC2", "PC4";
+	allwinner,pname = "spi0_clk", "spi0_mosi", "spi0_miso";
+	allwinner,function = "spi0";
+	allwinner,muxsel = <4>;
+	allwinner,drive = <1>;
+	allwinner,pull = <0>;
+};
+
+&spi0_pins_b {
+	allwinner,pins = "PC3", "PC15", "PC16";
+	allwinner,pname = "spi0_cs0", "spi0_wp", "spi0_hold";
+	allwinner,function = "spi0";
+	allwinner,muxsel = <4>;
+	allwinner,drive = <1>;
+	allwinner,pull = <1>;   // only CS should be pulled up
+};
+
+&spi0_pins_c {
+	allwinner,pins = "PC12", "PC2", "PC4", "PC3", "PC15", "PC16";
+	allwinner,function = "io_disabled";
+	allwinner,muxsel = <15>;
+	allwinner,drive = <1>;
+	allwinner,pull = <0>;
+};
+
+&lvds0_pins_a {
+	allwinner,pins = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD8", "PD9", "PD6", "PD7";
+	allwinner,pname = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD8", "PD9", "PD6", "PD7";
+	allwinner,function = "lvds0";
+	allwinner,muxsel = <3>;
+	allwinner,drive = <3>;
+	allwinner,pull = <0>;
+};
+
+&lvds0_pins_b {
+	allwinner,pins = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD8", "PD9", "PD6", "PD7";
+	allwinner,pname = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD8", "PD9", "PD6", "PD7";
+	allwinner,function = "lvds0_suspend";
+	allwinner,muxsel = <7>;
+	allwinner,drive = <3>;
+	allwinner,pull = <0>;
+};
+
+&lvds1_pins_a {
+	allwinner,pins = "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD18", "PD19", "PD16", "PD17";
+	allwinner,pname = "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD18", "PD19", "PD16", "PD17";
+	allwinner,function = "lvds1";
+	allwinner,muxsel = <3>;
+	allwinner,drive = <3>;
+	allwinner,pull = <0>;
+};
+
+&lvds1_pins_b {
+	allwinner,pins = "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD18", "PD19", "PD16", "PD17";
+	allwinner,pname = "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD18", "PD19", "PD16", "PD17";
+	allwinner,function = "lvds1_suspend";
+	allwinner,muxsel = <7>;
+	allwinner,drive = <3>;
+	allwinner,pull = <0>;
+};
+
+&lvds2_pins_a {
+	allwinner,pins = "PJ7", "PJ6", "PJ5", "PJ4", "PJ3", "PJ2", "PJ1", "PJ0", "PJ8", "PJ9";
+	allwinner,pname = "PJ7", "PJ6", "PJ5", "PJ4", "PJ3", "PJ2", "PJ1", "PJ0", "PJ8", "PJ9";
+	allwinner,function = "lvds2";
+	allwinner,muxsel = <3>;
+	allwinner,drive = <3>;
+	allwinner,pull = <0>;
+};
+
+&lvds2_pins_b {
+	allwinner,pins = "PJ7", "PJ6", "PJ5", "PJ4", "PJ3", "PJ2", "PJ1", "PJ0", "PJ8", "PJ9";
+	allwinner,pname = "PJ7", "PJ6", "PJ5", "PJ4", "PJ3", "PJ2", "PJ1", "PJ0", "PJ8", "PJ9";
+	allwinner,function = "lvds2_suspend";
+	allwinner,muxsel = <7>;
+	allwinner,drive = <3>;
+	allwinner,pull = <0>;
+};
+
+&lvds3_pins_a {
+	allwinner,pins = "PJ10", "PJ11", "PJ12", "PJ13", "PJ14", "PJ15", "PJ16", "PJ17", "PJ18", "PJ19";
+	allwinner,pname = "PJ10", "PJ11", "PJ12", "PJ13", "PJ14", "PJ15", "PJ16", "PJ17", "PJ18", "PJ19";
+	allwinner,function = "lvds3";
+	allwinner,muxsel = <3>;
+	allwinner,drive = <3>;
+	allwinner,pull = <0>;
+};
+
+&lvds3_pins_b {
+	allwinner,pins = "PJ10", "PJ11", "PJ12", "PJ13", "PJ14", "PJ15", "PJ16", "PJ17", "PJ18", "PJ19";
+	allwinner,pname = "PJ10", "PJ11", "PJ12", "PJ13", "PJ14", "PJ15", "PJ16", "PJ17", "PJ18", "PJ19";
+	allwinner,function = "lvds3_suspend";
+	allwinner,muxsel = <7>;
+	allwinner,drive = <3>;
+	allwinner,pull = <0>;
+};
+
+&lcd1_lvds2link_pins_a {
+	allwinner,pins = "PJ10", "PJ11", "PJ12", "PJ13", "PJ14", "PJ15", "PJ16", "PJ17", "PJ18", "PJ19", \
+	"PJ7", "PJ6", "PJ5", "PJ4", "PJ3", "PJ2", "PJ1", "PJ0", "PJ8", "PJ9";
+	allwinner,pname = "PJ10", "PJ11", "PJ12", "PJ13", "PJ14", "PJ15", "PJ16", "PJ17", "PJ18", "PJ19", \
+	"PJ7", "PJ6", "PJ5", "PJ4", "PJ3", "PJ2", "PJ1", "PJ0", "PJ8", "PJ9";
+	allwinner,function = "lvds3";
+	allwinner,muxsel = <3>;
+	allwinner,drive = <3>;
+	allwinner,pull = <0>;
+};
+
+&lcd1_lvds2link_pins_b {
+	allwinner,pins = "PJ10", "PJ11", "PJ12", "PJ13", "PJ14", "PJ15", "PJ16", "PJ17", "PJ18", "PJ19", \
+	"PJ7", "PJ6", "PJ5", "PJ4", "PJ3", "PJ2", "PJ1", "PJ0", "PJ8", "PJ9";
+	allwinner,pname = "PJ10", "PJ11", "PJ12", "PJ13", "PJ14", "PJ15", "PJ16", "PJ17", "PJ18", "PJ19", \
+	"PJ7", "PJ6", "PJ5", "PJ4", "PJ3", "PJ2", "PJ1", "PJ0", "PJ8", "PJ9";
+	allwinner,function = "lvds3_suspend";
+	allwinner,muxsel = <7>;
+	allwinner,drive = <3>;
+	allwinner,pull = <0>;
+};
+
+&lvds2link_pins_a {
+	allwinner,pins = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD8", "PD9", "PD6", "PD7", \
+	"PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD18", "PD19", "PD16", "PD17";
+	allwinner,pname = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD8", "PD9", "PD6", "PD7", \
+	"PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD18", "PD19", "PD16", "PD17";
+	allwinner,function = "lvds2link";
+	allwinner,muxsel = <3>;
+	allwinner,drive = <3>;
+	allwinner,pull = <0>;
+};
+
+&lvds2link_pins_b {
+	allwinner,pins = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD8", "PD9", "PD6", "PD7", \
+	"PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD18", "PD19", "PD16", "PD17";
+	allwinner,pname = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD8", "PD9", "PD6", "PD7", \
+	"PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD18", "PD19", "PD16", "PD17";
+	allwinner,function = "lvds2link_suspend";
+	allwinner,muxsel = <7>;
+	allwinner,drive = <3>;
+	allwinner,pull = <0>;
+};
+
+&rgb24_pins_a {
+	allwinner,pins = "PJ0", "PJ1", "PJ2", "PJ3", "PJ4", "PJ5", "PJ6", "PJ7", "PJ8", "PJ9", \
+	"PJ10", "PJ11", "PJ12", "PJ13", "PJ14", "PJ15", "PJ16", "PJ17", "PJ18", "PJ19", \
+	"PJ20", "PJ21", "PJ22", "PJ23", "PJ24", "PJ25", "PJ26", "PJ27";
+	allwinner,pname = "PJ0", "PJ1", "PJ2", "PJ3", "PJ4", "PJ5", "PJ6", "PJ7", "PJ8", "PJ9", \
+	"PJ10", "PJ11", "PJ12", "PJ13", "PJ14", "PJ15", "PJ16", "PJ17", "PJ18", "PJ19", \
+	"PJ20", "PJ21", "PJ22", "PJ23", "PJ24", "PJ25", "PJ26", "PJ27";
+	allwinner,function = "rgb24";
+	allwinner,muxsel = <2>;
+	allwinner,drive = <3>;
+	allwinner,pull = <0>;
+};
+
+&rgb24_pins_b {
+	allwinner,pins = "PJ0", "PJ1", "PJ2", "PJ3", "PJ4", "PJ5", "PJ6", "PJ7", "PJ8", "PJ9", \
+	"PJ10", "PJ11", "PJ12", "PJ13", "PJ14", "PJ15", "PJ16", "PJ17", "PJ18", "PJ19", \
+	"PJ20", "PJ21", "PJ22", "PJ23", "PJ24", "PJ25", "PJ26", "PJ27";
+	allwinner,pname = "PJ0", "PJ1", "PJ2", "PJ3", "PJ4", "PJ5", "PJ6", "PJ7", "PJ8", "PJ9", \
+	"PJ10", "PJ11", "PJ12", "PJ13", "PJ14", "PJ15", "PJ16", "PJ17", "PJ18", "PJ19", \
+	"PJ20", "PJ21", "PJ22", "PJ23", "PJ24", "PJ25", "PJ26", "PJ27";
+	allwinner,function = "rgb24_suspend";
+	allwinner,muxsel = <7>;
+	allwinner,drive = <3>;
+	allwinner,pull = <0>;
+};
+
+&rgb18_pins_a {
+	allwinner,pins = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", \
+	"PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD16", "PD17", "PD18", "PD19", \
+	"PD20", "PD21";
+	allwinner,pname = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", \
+	"PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD16", "PD17", "PD18", "PD19", \
+	"PD20", "PD21";
+	allwinner,function = "rgb18";
+	allwinner,muxsel = <2>;
+	allwinner,drive = <3>;
+	allwinner,pull = <0>;
+};
+
+&rgb18_pins_b {
+	allwinner,pins = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", \
+	"PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD16", "PD17", "PD18", "PD19", \
+	"PD20", "PD21";
+	allwinner,pname = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", \
+	"PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD16", "PD17", "PD18", "PD19", \
+	"PD20", "PD21";
+	allwinner,function = "rgb18_suspend";
+	allwinner,muxsel = <7>;
+	allwinner,drive = <1>;
+	allwinner,pull = <0>;
+};
+
+&eink_pins_a {
+	allwinner,pins = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", \
+	"PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD16", "PD17", "PD18", "PD19", \
+	"PD20", "PD21", "PD22";
+	allwinner,pname = "eink_pin0", "eink_pin1", "eink_pin2", "eink_pin3", "eink_pin4", \
+			  "eink_pin5", "eink_pin6", "eink_pin7", "eink_pin8", "eink_pin9", \
+			  "eink_pin10", "eink_pin11", "eink_pin12", "eink_pin13", "eink_pin14", \
+			  "eink_pin15", "eink_pinoeh", "eink_pinleh", "eink_pinckh", "eink_pinsth", \
+			  "eink_pinckv", "eink_pinmod", "eink_pinstv";
+	allwinner,function = "eink";
+	allwinner,muxsel = <5>;
+	allwinner,drive = <3>;
+	allwinner,pull = <0>;
+};
+
+&eink_pins_b {
+	allwinner,pins = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", \
+	"PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD16", "PD17", "PD18", "PD19", \
+	"PD20", "PD21", "PD22";
+	allwinner,pname = "eink_pin0", "eink_pin1", "eink_pin2", "eink_pin3", "eink_pin4", \
+			  "eink_pin5", "eink_pin6", "eink_pin7", "eink_pin8", "eink_pin9", \
+			  "eink_pin10", "eink_pin11", "eink_pin12", "eink_pin13", "eink_pin14", \
+			  "eink_pin15", "eink_pinoeh", "eink_pinleh", "eink_pinckh", "eink_pinsth", \
+			  "eink_pinckv", "eink_pinmod", "eink_pinstv";
+	allwinner,function = "eink_suspend";
+	allwinner,muxsel = <7>;
+	allwinner,drive = <1>;
+	allwinner,pull = <0>;
+};
+
+&dsi0_4lane_pins_a {
+        allwinner,pins = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9";
+        allwinner,pname = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9";
+        allwinner,function = "dsi4lane";
+        allwinner,muxsel = <4>;
+        allwinner,drive = <3>;
+        allwinner,pull = <0>;
+};
+
+&dsi0_4lane_pins_b {
+        allwinner,pins = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9";
+        allwinner,pname = "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9";
+        allwinner,function = "dsi4lane_suspend";
+        allwinner,muxsel = <7>;
+        allwinner,drive = <1>;
+        allwinner,pull = <0>;
+};
+
+&dsi1_4lane_pins_a {
+        allwinner,pins = "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD16", "PD17", "PD18", "PD19";
+        allwinner,pname = "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD16", "PD17", "PD18", "PD19";
+        allwinner,function = "dsi1";
+        allwinner,muxsel = <4>;
+        allwinner,drive = <3>;
+        allwinner,pull = <0>;
+};
+
+&dsi1_4lane_pins_b {
+        allwinner,pins = "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD16", "PD17", "PD18", "PD19";
+        allwinner,pname = "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD16", "PD17", "PD18", "PD19";
+        allwinner,function = "io_disabled";
+        allwinner,muxsel = <7>;
+        allwinner,drive = <1>;
+        allwinner,pull = <0>;
+};
+
+
+&card0_boot_para {  /* Avoid dtc compiling warnings. @TODO: Developer should modify this to the actual value */
+	/* reg = <0x0 0x2 0x0 0x0>;  [> Avoid dtc compiling warnings. @TODO: Developer should modify this to the actual value <] */
+	device_type = "card0_boot_para";
+	card_ctrl = <0x0>;
+	card_high_speed = <0x1>;
+	card_line = <0x4>;
+	clk_mmc = "sdmmc0_mod";
+	pll-0 = "hosc";
+	pll-1 = "pll_periph1_400m";
+	pll-2 = "pll_periph1_300m";
+	pinctrl-0 = <&sdc0_pins_a>;
+};
+
+&card2_boot_para {
+	/*
+	* Avoid dtc compiling warnings.
+	* @TODO: Developer should modify this to the actual value
+	*/
+	reg = <0x0 0x3 0x0 0x0>;
+	device_type = "card2_boot_para";
+	card_ctrl = <0x2>;
+	card_high_speed = <0x1>;
+	card_line = <0x8>;
+	clk_mmc = "sdmmc2_mod";
+	pll-0 = "hosc";
+	pll-1 = "pll_periph1_800m";
+	pll-2 = "pll_periph1_600m";
+	pinctrl-0 = <&sdc2_pins_a &sdc2_pins_c>;
+	sdc_ex_dly_used = <0x2>;
+	sdc_tm4_hs200_max_freq = <150>;
+	sdc_tm4_hs400_max_freq = <150>;
+	sdc_io_1v8 = <0x1>;
+	sdc_type = "tm4";
+};
+
+&gpio_bias {  /* Avoid dtc compiling warnings. @TODO: Developer should modify this to the actual value */
+	device_type = "gpio_bias";
+	pc_bias = <1800>;
+	pl_supply = "aldo3_vol";
+};
+
+&power_delay {
+	device_type = "power_delay";
+	aldo3_vol_delay = <20000>;
+};
+
+&nand0 {
+	compatible = "allwinner,sun55iw3-nand";
+	device_type = "nand0";
+	//reg = <0x0 0x04011000 0x0 0x1000>;/* nand0 */
+	pinctrl-names = "default", "sleep";
+	pinctrl-0 = <&nand0_pins_a &nand0_pins_b>;
+	pinctrl-1 = <&nand0_pins_c>;
+	nand0_regulator1 = "vcc-nand";
+	nand0_regulator2 = "none";
+	nand0_cache_level = <0x55aaaa55>;
+	nand0_flush_cache_num = <0x55aaaa55>;
+	nand0_capacity_level = <0x55aaaa55>;
+	nand0_id_number_ctl = <0x55aaaa55>;
+	nand0_print_level = <0x55aaaa55>;
+	nand0_p0 = <0x55aaaa55>;
+	nand0_p1 = <0x55aaaa55>;
+	nand0_p2 = <0x55aaaa55>;
+	nand0_p3 = <0x55aaaa55>;
+	chip_code = "sun50iw10";
+	status = "disabled";
+};
+
+&spi0 {
+	clock-frequency = <100000000>;
+	pinctrl-0 = <&spi0_pins_a &spi0_pins_b>;
+	pinctrl-1 = <&spi0_pins_c>;
+	pinctrl-names = "default", "sleep";
+	spi_slave_mode = <0>;
+	spi_dbi_enable = <0>;
+	spi0_cs_number = <1>;
+	status = "disabled";
+
+	spi_board0 {
+		device_type = "spi_board0";
+		compatible = "spi-nor";
+		spi-max-frequency = <100000000>;
+		m25p,fast-read = <1>;
+		/*individual_lock;*/
+		reg = <0x0>;
+		spi-rx-bus-width=<0x01>;
+		spi-tx-bus-width=<0x01>;
+		status="disabled";
+	};
+
+	spi-nand@0 {
+		compatible = "spi-nand";
+		spi-max-frequency=<50000000>;
+		reg = <0x0>;
+		spi-rx-bus-width=<0x01>;
+		spi-tx-bus-width=<0x01>;
+		status="disabled";
+	};
+};
+
+
+&aliases {
+	nand0 = &nand0;
+	twi6 = &twi6;
+	pwm = &pwm;
+	pwm0 = &pwm0;
+	pwm1 = &pwm1;
+	pwm2 = &pwm2;
+	pwm3 = &pwm3;
+	pwm4 = &pwm4;
+	pwm5 = &pwm5;
+	pwm6 = &pwm6;
+	pwm7 = &pwm7;
+	pwm8 = &pwm8;
+	pwm9 = &pwm9;
+	disp = &disp;
+	lcd0 = &lcd0;
+	lcd1 = &lcd1;
+	lcd2 = &lcd2;
+	eink = &eink;
+	edp0 = &edp0;
+	pmu0 = &pmu0;
+
+};

+ 1 - 1
arch/arm/dts/sun55iw3p1-soc-system.dts

@@ -1204,4 +1204,4 @@ pwm: pwm@2000c00 {
 };
 
 #include "sun55iw3p1-clk.dtsi"
-#include ".board-uboot.dts"
+#include "board-uboot.dts"

+ 23 - 1
arch/arm/lib/bootm.c

@@ -226,11 +226,25 @@ static void do_nonsec_virt_switch(void)
 }
 #endif
 
+int sunxi_drm_kernel_para_flush(void);
+
 /* Subcommand: PREP */
 static void boot_prep_linux(bootm_headers_t *images)
 {
 	char *commandline = env_get("bootargs");
 
+#if defined(CONFIG_OF_LIBFDT)
+	int off;
+
+	if (images->ft_addr) {
+		off = fdt_path_offset(images->ft_addr, "/memory");
+		if (off > 0) {
+			if (arch_fixup_fdt(images->ft_addr))
+				puts("## WARNING: fixup memory failed!\n");
+		}
+	}
+#endif
+
 	if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) {
 #ifdef CONFIG_OF_LIBFDT
 		debug("using: FDT\n");
@@ -258,6 +272,7 @@ static void boot_prep_linux(bootm_headers_t *images)
 			 * addresses. So use them instead of images->rd_start &
 			 * images->rd_end when possible.
 			 */
+			printf("images->initrd_start: %#lx, images->initrd_end: %#lx\n", images->initrd_start, images->initrd_end);
 			if (images->initrd_start && images->initrd_end) {
 				setup_initrd_tag(gd->bd, images->initrd_start,
 						 images->initrd_end);
@@ -338,6 +353,7 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
 	unsigned long r2;
 	int fake = (flag & BOOTM_STATE_OS_FAKE_GO);
 	u32 ARM_SVC_RUNNSOS = 0x8000ff04;
+	//phys_size_t fdt_size;
 
 	kernel_entry = (void (*)(int, int, uint))images->ep;
 
@@ -364,7 +380,10 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
 		}
 #endif
 		sunxi_mem_info("fdt", (void *)r2, images->ft_len);
-		memcpy((void *)r2, images->ft_addr, images->ft_len);
+		//memcpy((void *)r2, images->ft_addr, images->ft_len);
+		//printf("======images->ft_len = %ld, images->ft_addr = %p\n", images->ft_len, images->ft_addr);
+		r2 = (unsigned long)images->ft_addr;
+		//printf("=== fdt_size = %lld\n", fdt_size);
 	} else
 		r2 = gd->bd->bi_boot_params;
 	debug("## Linux machid: %08lx, FDT addr: %08lx\n", machid, r2);
@@ -379,6 +398,9 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
 #endif
 	announce_and_cleanup(fake);
 
+	//run_command("sunxi_show_logo", 0);
+	sunxi_drm_kernel_para_flush();
+
 	if (!fake) {
 
 #ifdef CONFIG_ARISC_DEASSERT_BEFORE_KERNEL

+ 1 - 1
arch/arm/mach-sunxi/Kconfig

@@ -79,7 +79,7 @@ config SUNXI_COMPARE_IMAGE_AND_FLASH
 
 config SUNXI_INITRD_ROUTINE
 	bool "Sunxi ramdisk init routine"
-	default y
+	default n
 	help
 		use sunxi ramdisk init routine ,witch copy ramdisk to addr defined
 		in boot.img head, instead of original one, whitch will copy ramdisk

+ 11 - 10
board/sunxi/board_common.c

@@ -603,6 +603,7 @@ void sunxi_early_logo_display(void)
 	if (work_mode == WORK_MODE_CARD_PRODUCT
 		|| work_mode == WORK_MODE_CARD_UPDATE || work_mode == WORK_MODE_UDISK_UPDATE) {
 		boot_gui_init();
+
 	} else if (gd->boot_logo_addr) {
 		boot_gui_init();
 		bpk_logo_addr = sunxi_prepare_bpk_bootlogo();
@@ -639,11 +640,11 @@ void board_bootlogo_display(void)
 	}
 #endif
 
-#if defined(CONFIG_CMD_SUNXI_BMP)
-	sunxi_bmp_display("bootlogo.bmp");
-#elif defined(CONFIG_CMD_SUNXI_JPEG)
-	sunxi_jpeg_display("bootlogo.jpg");
-#endif
+//#if defined(CONFIG_CMD_SUNXI_BMP)
+//	sunxi_bmp_display("bootlogo.bmp");
+//#elif defined(CONFIG_CMD_SUNXI_JPEG)
+//	sunxi_jpeg_display("bootlogo.jpg");
+//#endif
 }
 #endif
 
@@ -797,10 +798,10 @@ int board_late_init(void)
 		else
 #endif
 #ifndef CONFIG_SUNXI_RTOS
-		sunxi_update_partinfo();
-		if (sunxi_update_rotpk_info()) {
-			return -1;
-		}
+		//sunxi_update_partinfo();
+		//if (sunxi_update_rotpk_info()) {
+		//	return -1;
+		//}
 #endif
 #ifdef CONFIG_SUNXI_POWER
 #ifdef CONFIG_SUNXI_BMU
@@ -808,7 +809,7 @@ int board_late_init(void)
 #endif
 #endif
 		sunxi_respond_ir_key_action();
-		sunxi_update_bootcmd();
+		//sunxi_update_bootcmd();
 #ifdef CONFIG_SUNXI_SERIAL
 		sunxi_set_serial_num();
 #endif

+ 1 - 0
board/sunxi/sunxi_bootargs.c

@@ -227,6 +227,7 @@ int update_user_data(void)
 	if (get_boot_work_mode() != WORK_MODE_BOOT) {
 		return 0;
 	}
+	return 0;
 
 	check_user_data(); //从env中检测用户的环境变量
 

+ 5 - 214
cmd/bootm.c

@@ -19,11 +19,6 @@
 #include <linux/ctype.h>
 #include <linux/err.h>
 #include <u-boot/zlib.h>
-#include <sunxi_image_verifier.h>
-#include <sunxi_board.h>
-#include <android_image.h>
-#include <fdt_support.h>
-#include <sunxi_eink.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -89,143 +84,12 @@ static int do_bootm_subcommand(cmd_tbl_t *cmdtp, int flag, int argc,
 	return ret;
 }
 
-#if CONFIG_SUNXI_INITRD_ROUTINE
-__maybe_unused static void sunxi_update_initrd(ulong os_load_addr)
-{
-	const struct andr_img_hdr *hdr =
-		(const struct andr_img_hdr *)os_load_addr;
-	ulong initrd_start;
-	ulong initrd_size;
-	unsigned long ramdisk_addr = env_get_hex("load_ramdisk_addr", hdr->ramdisk_addr);
-	android_image_get_ramdisk(hdr, &initrd_start, &initrd_size);
-
-	if ((!strncmp(hdr->magic, ANDR_BOOT_MAGIC, ANDR_BOOT_MAGIC_SIZE)) && (hdr->unused >= 0x3)) {
-		ulong vendor_initrd_start, vendor_initrd_size;
-		struct vendor_boot_img_hdr *vendor_hdr = get_vendor_hdr_addr();
-		ramdisk_addr = env_get_hex("load_ramdisk_addr", vendor_hdr->ramdisk_addr);
-		android_image_get_vendor_ramdisk(hdr, &vendor_initrd_start, &vendor_initrd_size);
-		memmove_wd((void *)(ramdisk_addr), (void *)vendor_initrd_start, vendor_initrd_size, CHUNKSZ);
-		memmove_wd((void *)(ramdisk_addr + vendor_initrd_size), (void *)initrd_start, initrd_size, CHUNKSZ);
-
-		initrd_size += vendor_initrd_size;
-
-		/*bootconfig exist*/
-		if (android_image_is_vendor_bootconfig_used(vendor_hdr)) {
-			ulong bootconfig_start = 0;
-			ulong bootconfig_size  = 0;
-			android_image_get_vendor_bootconfig(
-				hdr, &bootconfig_start, &bootconfig_size);
-			android_image_cmdline_to_vendorbootconfig(&bootconfig_start, &bootconfig_size);
-			memmove_wd((void *)(ramdisk_addr + initrd_size),
-				   (void *)bootconfig_start, bootconfig_size,
-				   CHUNKSZ);
-			initrd_size += bootconfig_size;
-			env_set_hex("bootconfig_addr", bootconfig_start);
-			env_set_hex("bootconfig_size", bootconfig_size);
-		}
-
-		if (vendor_hdr->dtb_addr) {
-			env_set_hex("load_dtb_addr", env_get_hex("load_dtb_addr", vendor_hdr->dtb_addr));
-		}
-	} else {
-		if ((!strncmp(hdr->magic, ANDR_BOOT_MAGIC, ANDR_BOOT_MAGIC_SIZE)) && (hdr->dtb_addr)) {
-			env_set_hex("load_dtb_addr", env_get_hex("load_dtb_addr", hdr->dtb_addr));
-		}
-		memmove_wd((void *)ramdisk_addr, (void *)initrd_start, initrd_size, CHUNKSZ);
-	}
-	sunxi_mem_info("ramdisk", (void *)ramdisk_addr, initrd_size);
-	env_set_hex("ramdisk_sum",
-		    sunxi_generate_checksum((void *)ramdisk_addr, initrd_size,
-					    8, STAMP_VALUE));
-	debug("   Loading Ramdisk from %08lx to %08lx, size %08lx ... ",
-		initrd_start, ramdisk_addr, initrd_size);
-#ifdef CONFIG_MP
-	/*
-			 * Ensure the image is flushed to memory to handle
-			 * AMP boot scenarios in which we might not be
-			 * HW cache coherent
-			 */
-	flush_cache((unsigned long)*initrd_start,
-		    ALIGN(rd_len, ARCH_DMA_MINALIGN));
-#endif
-	debug("OK\n");
-	env_set_hex("ramdisk_start", ramdisk_addr);
-	env_set_hex("ramdisk_size", initrd_size);
-	if (initrd_size) {
-		fdt_initrd(working_fdt, (ulong)ramdisk_addr,
-			(ulong)(ramdisk_addr + initrd_size));
-	}
-
-
-}
-#endif
-
-/*
- * depends on boot header, not correct with sunxi-compressed kernel(no header)
- * maybe not always accurate, but good enough in our use case:
- *     run 32 bit os in 64 bit platform for memory usage reducing
- */
-__maybe_unused static void check_os_run_arch(ulong os_load_addr)
-{
-	andr_img_hdr *hdr		       = (andr_img_hdr *)os_load_addr;
-	struct vendor_boot_img_hdr *vendor_hdr = get_vendor_hdr_addr();
-	const char *active_name		       = NULL;
-
-	/*default value*/
-	sunxi_set_force_32bit_os(0);
-
-	/*32 bit platform(no monitor) always 32bit os*/
-	if (!sunxi_probe_secure_monitor())
-		return;
-
-	/*try a valid head, either vendor boot or android boot is acceptable*/
-	if (vendor_hdr != NULL) {
-		active_name = (char *)vendor_hdr->name;
-#if 0 //debug print
-		pr_msg("vendor boot header\n");
-		printf("kernel_addr:%x kernel_size:%x\n"
-		       "dtb_addr:%llx dtb_size:%x\n"
-		       "ramdisk_addr:%x ramdisk_size:%x\n",
-		       vendor_hdr->kernel_addr, hdr->kernel_size,
-		       vendor_hdr->dtb_addr, vendor_hdr->dtb_size,
-		       vendor_hdr->ramdisk_addr,
-		       vendor_hdr->vendor_ramdisk_size);
-		pr_msg("boot header\n");
-		printf("kernel_addr:%x kernel_size:%x\n"
-		       "dtb_addr:%llx dtb_size:%x\n"
-		       "ramdisk_addr:%x ramdisk_size:%x\n",
-		       hdr->kernel_addr, hdr->kernel_size, hdr->dtb_addr,
-		       hdr->dtb_size, hdr->ramdisk_addr, hdr->ramdisk_size);
-#endif
-	} else if (memcmp(ANDR_BOOT_MAGIC, hdr->magic, ANDR_BOOT_MAGIC_SIZE) ==
-		   0) {
-		active_name = hdr->name;
-	} else {
-		return;
-	}
-
-	/*os 64 bit*/
-	if (strstr(active_name, "arm64") != NULL)
-		return;
-
-	if (strstr(active_name, "arm") != NULL) {
-		pr_msg("force run 32bit os on this device\n");
-		sunxi_set_force_32bit_os(1);
-	}
-}
-
 /*******************************************************************/
 /* bootm - boot application image from image in memory */
 /*******************************************************************/
-void update_bootargs(void);
-int sunxi_get_lcd_op_finished(void);
+
 int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-	ulong os_load_addr = simple_strtoul(argv[1], NULL, 16);
-	int fake_go = 0;
-	if (env_get("fake_go"))
-		fake_go = BOOTM_STATE_OS_FAKE_GO;
-
 #ifdef CONFIG_NEEDS_MANUAL_RELOC
 	static int relocated = 0;
 
@@ -240,75 +104,6 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	}
 #endif
 
-#ifdef CONFIG_SUNXI_ANDROID_BOOT
-	if (sunxi_android_boot(env_get("boot_from_partion"),
-			       os_load_addr)) {
-		return -1;
-	}
-#else
-
-#ifdef CONFIG_SUNXI_SECURE_BOOT
-	/* verify image before booting in secure boot*/
-	if (gd->securemode) {
-
-#if defined(CONFIG_SUNXI_DM_VERITY)
-		if (sunxi_verity_hash_tree("rootfs", "rootfs") != 0) {
-			pr_err("sunxi verity rootfs error\n");
-			return -1;
-		}
-#elif defined(CONFIG_SUNXI_PART_VERIFY)
-		pr_msg("begin to verify rootfs\n");
-		int full = 0;
-		struct sunxi_image_verify_pattern_st verify_pattern = {
-			0x1000, 0x100000, -1
-		};
-		char *rootfs_name = env_get("root_partition");
-		char *s = env_get("rootfs_per_MB");
-		if (strcmp(s, "full") == 0) {
-			full = 1;
-		} else {
-			int rootfs_per_MB =
-				s ? (int)simple_strtol(s, NULL, 10) : 0;
-			if ((rootfs_per_MB >= 4096 && rootfs_per_MB <= 1048576)
-				 && (rootfs_per_MB % 4096 == 0))
-				verify_pattern.size = rootfs_per_MB;
-			else if (rootfs_per_MB != 0) {
-				return -1;
-			}
-
-			full = 0;
-		}
-		if (sunxi_verify_partion(&verify_pattern, rootfs_name, "rootfs", full) != 0) {
-			return -1;
-		}
-#endif /*CONFIG_SUNXI_PART_VERIFY*/
-
-		if (sunxi_verify_os(os_load_addr,
-				    env_get("boot_from_partion")) != 0) {
-			return -1;
-		}
-	}
-#endif /*CONFIG_SUNXI_SECURE_BOOT*/
-
-#endif /*CONFIG_SUNXI_ANDROID_BOOT*/
-
-#if defined(CONFIG_EINK200_SUNXI)
-	struct eink_fb_info_t *p_inst = eink_get_fb_inst();
-	if (p_inst) {
-		p_inst->wait_pipe_finish(p_inst);
-	}
-#elif defined(CONFIG_DISP2_SUNXI)
-	while (!sunxi_get_lcd_op_finished()) {
-		mdelay(10);
-	}
-#endif
-
-#if CONFIG_SUNXI_INITRD_ROUTINE
-	sunxi_update_initrd(os_load_addr);
-#endif
-
-	check_os_run_arch(os_load_addr);
-
 	/* determine if we have a sub command */
 	argc--; argv++;
 	if (argc > 0) {
@@ -326,21 +121,17 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		if ((*endp != 0) && (*endp != ':') && (*endp != '#'))
 			return do_bootm_subcommand(cmdtp, flag, argc, argv);
 	}
-	update_bootargs();
-	update_vendorbootconfig_and_bootgargs();
 
 	return do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START |
 		BOOTM_STATE_FINDOS | BOOTM_STATE_FINDOTHER |
 		BOOTM_STATE_LOADOS |
-#ifndef CONFIG_SUNXI_INITRD_ROUTINE
 #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
 		BOOTM_STATE_RAMDISK |
 #endif
-#endif
 #if defined(CONFIG_PPC) || defined(CONFIG_MIPS)
 		BOOTM_STATE_OS_CMDLINE |
 #endif
-		BOOTM_STATE_OS_PREP | fake_go |
+		BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
 		BOOTM_STATE_OS_GO, &images, 1);
 }
 
@@ -491,7 +282,7 @@ static int image_info(ulong addr)
 	case IMAGE_FORMAT_FIT:
 		puts("   FIT image found\n");
 
-		if (fit_check_format(hdr, IMAGE_SIZE_INVAL)) {
+		if (!fit_check_format(hdr)) {
 			puts("Bad FIT image format!\n");
 			return 1;
 		}
@@ -564,7 +355,7 @@ static int do_imls_nor(void)
 #endif
 #if defined(CONFIG_FIT)
 			case IMAGE_FORMAT_FIT:
-				if (fit_check_format(hdr, IMAGE_SIZE_INVAL))
+				if (!fit_check_format(hdr))
 					goto next_sector;
 
 				printf("FIT Image at %08lX:\n", (ulong)hdr);
@@ -644,7 +435,7 @@ static int nand_imls_fitimage(struct mtd_info *mtd, int nand_dev, loff_t off,
 		return ret;
 	}
 
-	if (fit_check_format(imgdata, IMAGE_SIZE_INVAL)) {
+	if (!fit_check_format(imgdata)) {
 		free(imgdata);
 		return 0;
 	}

+ 4 - 4
cmd/mmc.c

@@ -909,7 +909,7 @@ static cmd_tbl_t cmd_mmc[] = {
 	U_BOOT_CMD_MKENT(swrite, 3, 0, do_mmc_sparse_write, "", ""),
 #endif
 	U_BOOT_CMD_MKENT(rescan, 1, 1, do_mmc_rescan, "", ""),
-	U_BOOT_CMD_MKENT(part, 1, 1, do_mmc_part, "", ""),
+	U_BOOT_CMD_MKENT(part, 2, 1, do_mmc_part, "", ""),
 	U_BOOT_CMD_MKENT(dev, 3, 0, do_mmc_dev, "", ""),
 	U_BOOT_CMD_MKENT(list, 1, 1, do_mmc_list, "", ""),
 #if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING)
@@ -949,7 +949,7 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		return CMD_RET_SUCCESS;
 
 	if (curr_device < 0) {
-		if (get_mmc_num() > 0) {
+		if (get_mmc_num() >= 0) {
 			curr_device = 0;
 		} else {
 			puts("No MMC device available\n");
@@ -1039,8 +1039,8 @@ int do_card0_probe(cmd_tbl_t *cmdtp, int flag,
 		puts("card0 init failed\n");
 		return  -1;
 	}
-	run_command("mmcinfo", 0);
-	run_command("mmc part", 0);
+	//run_command("mmcinfo", 0);
+	//run_command("mmc part", 0);
 	card0_init = 1;
 	return 0;
 }

+ 138 - 0
cmd/pxe.c

@@ -12,12 +12,27 @@
 #include <linux/ctype.h>
 #include <errno.h>
 #include <linux/list.h>
+#include <fdt_support.h>
+#include <linux/libfdt.h>
 #include <fs.h>
 #include <asm/io.h>
 
 #include "menu.h"
 #include "cli.h"
 
+#include <common.h>
+#include <command.h>
+#include <linux/ctype.h>
+#include <linux/types.h>
+#include <asm/global_data.h>
+#include <linux/libfdt.h>
+#include <fdt_support.h>
+#include <mapmem.h>
+#include <asm/io.h>
+
+
+DECLARE_GLOBAL_DATA_PTR;
+
 #define MAX_TFTP_PATH_LEN 127
 
 const char *pxe_default_paths[] = {
@@ -475,6 +490,7 @@ struct pxe_label {
 	char *initrd;
 	char *fdt;
 	char *fdtdir;
+	char *fdtoverlays;
 	int ipappend;
 	int attempted;
 	int localboot;
@@ -550,6 +566,9 @@ static void label_destroy(struct pxe_label *label)
 	if (label->fdtdir)
 		free(label->fdtdir);
 
+	if (label->fdtoverlays)
+		free(label->fdtoverlays);
+
 	free(label);
 }
 
@@ -597,6 +616,111 @@ static int label_localboot(struct pxe_label *label)
 	return run_command_list(localcmd, strlen(localcmd), 0);
 }
 
+static void fdt_file_resize(void)
+{
+	struct fdt_header *working_fdt;
+	ulong fdt_addr;
+	int err;
+
+	/* Get the main fdt and map it */
+	fdt_addr = simple_strtoul(env_get("fdt_addr_r"), NULL, 16);
+	working_fdt = map_sysmem(fdt_addr, 0);
+	err = fdt_check_header(working_fdt);
+	if (err)
+		return;
+
+	/* Resize main fdt */
+	fdt_shrink_to_minimum(working_fdt, 8192);
+}
+
+
+/*
+ * Loads fdt overlays specified in 'fdtoverlays'.
+ */
+#ifdef CONFIG_OF_LIBFDT_OVERLAY
+static void label_boot_fdtoverlay(cmd_tbl_t *cmdtp, struct pxe_label *label)
+{
+	char *fdtoverlay = label->fdtoverlays;
+	struct fdt_header *working_fdt;
+	char *fdtoverlay_addr_env;
+	ulong fdtoverlay_addr;
+	ulong fdt_addr;
+	int err;
+
+	/* Get the main fdt and map it */
+	fdt_addr = simple_strtoul(env_get("fdt_addr_r"), NULL, 16);
+	//fdt_addr = (ulong)gd->fdt_blob;
+	working_fdt = map_sysmem(fdt_addr, 0);
+	err = fdt_check_header(working_fdt);
+	if (err)
+		return;
+
+	/* Get the specific overlay loading address */
+	fdtoverlay_addr_env = env_get("fdtoverlay_addr_r");
+	if (!fdtoverlay_addr_env) {
+		printf("Invalid fdtoverlay_addr_r for loading overlays\n");
+		return;
+	}
+
+	fdtoverlay_addr = simple_strtoul(fdtoverlay_addr_env, NULL, 16);
+
+	/* Cycle over the overlay files and apply them in order */
+	do {
+		struct fdt_header *blob;
+		char *overlayfile;
+		char *end;
+		int len;
+
+		/* Drop leading spaces */
+		while (*fdtoverlay == ' ')
+			++fdtoverlay;
+
+		/* Copy a single filename if multiple provided */
+		end = strstr(fdtoverlay, " ");
+		if (end) {
+			len = (int)(end - fdtoverlay);
+			overlayfile = malloc(len + 1);
+			strncpy(overlayfile, fdtoverlay, len);
+			overlayfile[len] = '\0';
+		} else
+			overlayfile = fdtoverlay;
+
+		if (!strlen(overlayfile))
+			goto skip_overlay;
+
+		/* Load overlay file */
+		err = get_relfile_envaddr(cmdtp, overlayfile,
+					  "fdtoverlay_addr_r");
+		if (err < 0) {
+			printf("Failed loading overlay %s\n", overlayfile);
+			goto skip_overlay;
+		}
+
+		/* Resize main fdt */
+		fdt_shrink_to_minimum(working_fdt, 8192);
+
+		blob = map_sysmem(fdtoverlay_addr, 0);
+		err = fdt_check_header(blob);
+		if (err) {
+			printf("Invalid overlay %s, skipping\n",
+			       overlayfile);
+			goto skip_overlay;
+		}
+
+		err = fdt_overlay_apply_verbose(working_fdt, blob);
+		if (err) {
+			printf("Failed to apply overlay %s, skipping\n",
+			       overlayfile);
+			goto skip_overlay;
+		}
+
+skip_overlay:
+		if (end)
+			free(overlayfile);
+	} while ((fdtoverlay = strstr(fdtoverlay, " ")));
+}
+#endif
+
 /*
  * Boot according to the contents of a pxe_label.
  *
@@ -774,6 +898,13 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
 						label->name);
 				return 1;
 			}
+
+			fdt_file_resize();
+
+#ifdef CONFIG_OF_LIBFDT_OVERLAY
+			if (label->fdtoverlays)
+				label_boot_fdtoverlay(cmdtp, label);
+#endif
 		} else {
 			bootm_argv[3] = NULL;
 		}
@@ -827,6 +958,7 @@ enum token_type {
 	T_INCLUDE,
 	T_FDT,
 	T_FDTDIR,
+	T_FDTOVERLAYS,
 	T_ONTIMEOUT,
 	T_IPAPPEND,
 	T_INVALID
@@ -860,6 +992,7 @@ static const struct token keywords[] = {
 	{"fdt", T_FDT},
 	{"devicetreedir", T_FDTDIR},
 	{"fdtdir", T_FDTDIR},
+	{"fdtoverlays", T_FDTOVERLAYS},
 	{"ontimeout", T_ONTIMEOUT,},
 	{"ipappend", T_IPAPPEND,},
 	{NULL, T_INVALID}
@@ -1261,6 +1394,11 @@ static int parse_label(char **c, struct pxe_menu *cfg)
 				err = parse_sliteral(c, &label->fdtdir);
 			break;
 
+		case T_FDTOVERLAYS:
+			if (!label->fdtoverlays)
+				err = parse_sliteral(c, &label->fdtoverlays);
+			break;
+
 		case T_LOCALBOOT:
 			label->localboot = 1;
 			err = parse_integer(c, &label->localboot_val);

+ 1 - 0
common/autoboot.c

@@ -216,6 +216,7 @@ static int __abortboot(int bootdelay)
 	int abort = 0;
 	unsigned long ts;
 
+	bootdelay = 1;
 #ifdef CONFIG_MENUPROMPT
 	printf(CONFIG_MENUPROMPT);
 #else

+ 6 - 4
common/board_r.c

@@ -532,7 +532,7 @@ static int initr_sunxi_plat(void)
 	check_ir_boot_recovery();
 #endif
 #if defined(CONFIG_SUNXI_HOMLET)
-	sunxi_boot_init_gpio();
+	//sunxi_boot_init_gpio();
 #endif
 
 #ifdef CONFIG_RECOVERY_KEY
@@ -603,13 +603,13 @@ extern int usb_auto_detect_device(void);
 	if (workmode == WORK_MODE_BOOT) {
 #ifdef CONFIG_SUNXI_UPDATE_GPT
 		int sunxi_update_gpt(void);
-		sunxi_update_gpt();
+		//sunxi_update_gpt();
 #endif
 
 #ifdef CONFIG_ENABLE_MTD_CMDLINE_PARTS_BY_ENV
 		initr_env();
 #endif
-		sunxi_probe_partition_map();
+		//sunxi_probe_partition_map();
 	}
 
 #ifdef CONFIG_SUNXI_ROTPK_BURN_ENABLE_BY_TOOL
@@ -657,6 +657,7 @@ static int sunxi_fast_burn_key(void)
 
 static int sunxi_burn_key(void)
 {
+	return 0;
 #ifdef CONFIG_CMD_SUNXI_AUTO_FEL
 	sunxi_auto_fel_by_usb();
 #endif
@@ -698,8 +699,9 @@ static int should_load_env(void)
 static int initr_env(void)
 {
 	/* initialize environment */
-	if (should_load_env())
+	if (should_load_env()) {
 		env_relocate();
+	}
 	else
 		set_default_env(NULL);
 #ifdef CONFIG_OF_CONTROL

+ 2 - 45
common/bootm.c

@@ -287,14 +287,10 @@ int use_android_image_dtb(void)
  *     0, if all existing images were loaded correctly
  *     1, if an image is found but corrupted, or invalid
  */
-int sunxi_update_fdt_para_for_kernel(void);
-
 int bootm_find_images(int flag, int argc, char * const argv[])
 {
-	 __attribute__((unused)) int ret;
+	int ret;
 
-#if !defined(CONFIG_SUNXI_INITRD_ROUTINE)
-	/* ramdisk manually processed, pass*/
 	/* find ramdisk */
 	ret = boot_get_ramdisk(argc, argv, &images, IH_INITRD_ARCH,
 			       &images.rd_start, &images.rd_end);
@@ -302,42 +298,9 @@ int bootm_find_images(int flag, int argc, char * const argv[])
 		puts("Ramdisk image is corrupt or invalid\n");
 		return 1;
 	}
-#endif
-
 
 #if IMAGE_ENABLE_OF_LIBFDT
-#ifdef CONFIG_ARCH_SUNXI
-#if defined(CONFIG_OF_SEPARATE) && !defined(CONFIG_SUNXI_NECESSARY_REPLACE_FDT)
-/* If CONFIG_SUNXI_REPLACE_FDT_FROM_PARTITION is defined,
- * the dtb in the partition will be used and will not be executed here.
- *
- * If CONFIG_SUNXI_REPLACE_FDT_FROM_PARTITION is not defined,
- * Will use dtb in the Android image.
- * */
-#ifndef CONFIG_SUNXI_REPLACE_FDT_FROM_PARTITION
-	if (use_android_image_dtb()) {
-		puts("Use android image dtb fail!\n");
-		return 1;
-	}
-#endif
-#endif
-	images.ft_addr = (char *)gd->fdt_blob;
-	images.ft_len  = gd->fdt_size;
-	set_working_fdt_addr((ulong)images.ft_addr);
-
-	/* set this env variable for  function boot_relocate_fdt.
-	     use fdt in place
-	  */
 	env_set("fdt_high", "0xffffffff");
-#if defined(CONFIG_OF_SEPARATE) && !defined(CONFIG_SUNXI_NECESSARY_REPLACE_FDT)
-/* If CONFIG_SUNXI_REPLACE_FDT_FROM_PARTITION is defined,
- * this function will be called earlier,
- * so there is no need to call this function again. */
-#ifndef CONFIG_SUNXI_REPLACE_FDT_FROM_PARTITION
-	sunxi_update_fdt_para_for_kernel();
-#endif
-#endif
-#else
 	/* find flattened device tree */
 	ret = boot_get_fdt(flag, argc, argv, IH_ARCH_DEFAULT, &images,
 			   &images.ft_addr, &images.ft_len);
@@ -347,7 +310,6 @@ int bootm_find_images(int flag, int argc, char * const argv[])
 	}
 	set_working_fdt_addr((ulong)images.ft_addr);
 #endif
-#endif
 
 #if IMAGE_ENABLE_FIT
 #if defined(CONFIG_FPGA)
@@ -1045,11 +1007,6 @@ static int bootm_host_load_image(const void *fit, int req_image_type)
 	void *load_buf;
 	int ret;
 
-#ifdef CONFIG_ENV_IS_IN_SUNXI_FLASH
-	ulong bootm_len = env_get_hex("load_boot_len_max", CONFIG_SYS_BOOTM_LEN);
-#else
-	ulong bootm_len = CONFIG_SYS_BOOTM_LEN;
-#endif
 	memset(&images, '\0', sizeof(images));
 	images.verify = 1;
 	noffset = fit_image_load(&images, (ulong)fit,
@@ -1071,7 +1028,7 @@ static int bootm_host_load_image(const void *fit, int req_image_type)
 	/* Allow the image to expand by a factor of 4, should be safe */
 	load_buf = malloc((1 << 20) + len * 4);
 	ret = bootm_decomp_image(imape_comp, 0, data, image_type, load_buf,
-				 (void *)data, len, bootm_len,
+				 (void *)data, len, CONFIG_SYS_BOOTM_LEN,
 				 &load_end);
 	free(load_buf);
 

+ 23 - 7
configs/sun55iw3p1_t527_defconfig

@@ -11,9 +11,9 @@ CONFIG_CONSOLE_MUX=y
 CONFIG_SYS_TEXT_BASE=0x4A000000
 CONFIG_SUNXI_TEXT_SIZE=0x150000
 #secure
-CONFIG_SUNXI_SECURE_BOOT=y
-CONFIG_SUNXI_IMAGE_VERIFIER=y
-CONFIG_SUNXI_KEYBOX=y
+#CONFIG_SUNXI_SECURE_BOOT=y
+#CONFIG_SUNXI_IMAGE_VERIFIER=y
+#CONFIG_SUNXI_KEYBOX=y
 CONFIG_SUNXI_DRM_SUPPORT=y
 #system
 CONFIG_ARM_SMCCC=y
@@ -21,6 +21,22 @@ CONFIG_SUNXI_DMA=y
 CONFIG_PHYS_64BIT=y
 CONFIG_RECOVERY_KEY=y
 
+CONFIG_ARM_SMCCC=y
+CONFIG_SUNXI_DMA=y
+CONFIG_PHYS_64BIT=y
+
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_PXE=y
+
+CONFIG_DISTRO_DEFAULTS=y
+CONFIG_ENV_VARS_UBOOT_CONFIG=y
+
+CONFIG_EXT4_WRITE=y
+CONFIG_CMD_EXT4_WRITE=y
+CONFIG_ENV_IS_IN_EXT4=y
+#CONFIG_ENV_IS_IN_SUNXI_FLASH=y
+
+
 #I2C
 CONFIG_SYS_I2C_SUNXI=y
 CONFIG_SYS_SUNXI_R_I2C0_SLAVE=0x35
@@ -81,14 +97,14 @@ CONFIG_ANDROID_BOOT_IMAGE=y
 
 #sprite
 CONFIG_SUNXI_SPRITE=y
-CONFIG_SUNXI_SECURE_STORAGE=y
+#CONFIG_SUNXI_SECURE_STORAGE=y
 CONFIG_SUNXI_SPRITE_CARTOON=y
 
 #android
 CONFIG_SUNXI_MAC=y
 CONFIG_SUNXI_USER_KEY=y
 CONFIG_SUNXI_AVB=y
-CONFIG_SUNXI_ANDROID_BOOT=y
+#CONFIG_SUNXI_ANDROID_BOOT=y
 CONFIG_SUNXI_SERIAL=y
 CONFIG_SUNXI_VERIFY_BOOT_INFO_INSTALL=y
 CONFIG_ANDROID_AB=y
@@ -121,7 +137,7 @@ CONFIG_BOOT_RISCV=y
 CONFIG_ARISC_DEASSERT_BEFORE_KERNEL=y
 
 #overlay
-CONFIG_SUNXI_ANDROID_OVERLAY=y
+#CONFIG_SUNXI_ANDROID_OVERLAY=y
 
 
 #
@@ -303,7 +319,7 @@ CONFIG_BOOT_GUI=y
 # CONFIG_BOOT_GUI_DOUBLE_BUF is not set
 # CONFIG_BOOT_GUI_TEST is not set
 CONFIG_OF_SEPARATE=y
-CONFIG_SUNXI_NECESSARY_REPLACE_FDT=y
+#CONFIG_SUNXI_NECESSARY_REPLACE_FDT=y
 CONFIG_SUNXI_BOOT_PARAM=y
 
 CONFIG_PWM_SUNXI=y

+ 2 - 0
drivers/video/drm/drm_framebuffer.c

@@ -270,6 +270,8 @@ FREE_FB:
 		kfree(fb);
 	}
 
+	printf("test\n");
+
 	return ret;
 
 }

+ 37 - 20
drivers/video/drm/load_file.c

@@ -24,10 +24,14 @@
 #include <command.h>
 #include <linux/string.h>
 #include <fs.h>
+#include <ext4fs.h>
 
 extern int sunxi_partition_get_partno_byname(const char *part_name);
 extern int disp_fat_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 extern int do_fat_size(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+extern int do_ext4_size(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]);
+
+extern int do_ext4_load(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]);
 
 static int __unload_file(struct file_info_t *file)
 {
@@ -52,9 +56,10 @@ static int __print_file_info(struct file_info_t *file)
 
 struct file_info_t *load_file(char *name, char *part_name)
 {
-	int partno = -1;
+	//int partno = -1;
 	char *argv[6], file_addr[32];
-	char part_info[16] = { 0 }, size[32] = { 0 };
+	//char part_info[16] = { 0 }, 
+	char size[32] = { 0 };
 	struct file_info_t *file = NULL;
 
 	if (!name || !part_name) {
@@ -63,47 +68,59 @@ struct file_info_t *load_file(char *name, char *part_name)
 		goto OUT;
 	}
 
-	partno = sunxi_partition_get_partno_byname(part_name);
-	if (partno < 0) {
-		pr_err("%s is not found!\n", part_name);
-		goto OUT;
-	}
-	snprintf(part_info, 16, "0:%x", partno);
+	//partno = sunxi_partition_get_partno_byname(part_name);
+	//if (partno < 0) {
+	//	pr_err("%s is not found!\n", part_name);
+	//	goto OUT;
+	//}
+	//snprintf(part_info, 16, "0:%x", partno);
+
+	strncpy(name, "/boot/boot.bmp", 15);
+	printf("bmp_name=%s\n", name);
 
-	argv[0] = "fatsize";
-	argv[1] = "sunxi_flash";
-	argv[2] = part_info;
+	argv[0] = "ext4size";
+	argv[1] = "mmc";
+	argv[2] = "0:1";
 	argv[3] = name;
 	argv[4] = NULL;
 	argv[5] = NULL;
 
-	if (!do_fat_size(0, 0, 4, argv)) {
+	run_command("mmc dev 0", 0);
+	run_command("mmc part", 0);
+
+	if (!do_ext4_size(0, 0, 4, argv)) {
 		file = (struct file_info_t *)malloc(sizeof(struct file_info_t));
 		memset(file, 0, sizeof(struct file_info_t));
 		file->file_size = env_get_hex("filesize", 0);
 	} else {
-		pr_err("get file(%s) size from %s error\n", name, part_name);
-		goto OUT;
+		run_command("mmc dev 2", 0);
+		run_command("mmc part", 0);
+		argv[2] = "2:1";
+		if (!do_ext4_size(0, 0, 4, argv)) {
+			memset(file, 0, sizeof(struct file_info_t));
+			file->file_size = env_get_hex("filesize", 0);
+		} else {
+			pr_err("get file(%s) size from %s error\n", name, part_name);
+			goto OUT;
+		}
 	}
 
 	file->name = (char *)malloc(strlen(name) + 1);
 	strncpy(file->name, name, strlen(name) + 1);
 	file->path = (char *)malloc(strlen(part_name) + 1);
-	strncpy(file->path, part_name, strlen(part_name) + 1);
+	strncpy(file->path, name, strlen(name) + 1);
 	file->file_addr =
 		memalign(4096, file->file_size);
 
 	sprintf(file_addr, "%lx", (unsigned long)file->file_addr);
 	snprintf(size, 16, "%lx", (unsigned long)file->file_size);
 
-	argv[0] = "fatload";
-	argv[1] = "sunxi_flash";
-	argv[2] = part_info;
+	argv[0] = "ext4load";
 	argv[3] = file_addr;
 	argv[4] = name;
-	argv[5] = size;
+	argv[5] = NULL;
 
-	if (disp_fat_load(0, 0, 6, argv)) {
+	if (do_ext4_load(0, 0, 6, argv)) {
 		pr_err("Unable to open file %s from %s\n", name, part_name);
 		goto FREE_FILE;
 	}

+ 8 - 0
drivers/video/drm/sunxi_drm_drv.c

@@ -109,6 +109,7 @@ int sunxi_drm_kernel_para_flush(void)
 			sunxi_drm_connector_save_para(state);
 		}
 	}
+
 	return 0;
 }
 
@@ -600,7 +601,14 @@ static int sunxi_drm_drv_probe(struct udevice *dev)
 		cmd2.pixel_format = DRM_FORMAT_ARGB8888;
 		cmd2.pitches[0] = cmd2.width * (ALIGN(32, 8) >> 3);
 		cmd2.offsets[0] = 0;
+
 		tmp_s->fb_id = drm_framebuffer_alloc(drm, &cmd2);
+
+		if (tmp_s->fb_id  < 0) {
+			DRM_ERROR("drm_framebuffer_alloc fail!\n");
+			return -ENODEV;
+		}
+
 		fb = drm_framebuffer_lookup(drm, tmp_s->fb_id);
 
 		if (!uc_priv->xsize || !uc_priv->ysize) {

+ 1 - 0
drivers/video/sunxi/bootGUI/boot_gui.c

@@ -57,6 +57,7 @@ int boot_gui_init(void)
 #endif
 
 	tick_printf("%s:start\n", __func__);
+	printf("%s:start\n", __func__);
 	dev_num = disp_devices_open();
 	if (dev_num < 0) {
 		ret = dev_num;

+ 1 - 1
env/Kconfig

@@ -436,7 +436,7 @@ if ARCH_SUNXI
 
 config ENV_IS_IN_SUNXI_FLASH
 	bool "Environment is in sunxi flash"
-	default y
+	default n
 	help
 	  Define this if you have a sunxi Flash memory device which you
 	  want to use for the environment.

+ 1 - 0
fs/btrfs/btrfs.h

@@ -13,6 +13,7 @@
 
 struct btrfs_info {
 	struct btrfs_super_block sb;
+	struct btrfs_root_backup *root_backup;
 
 	struct btrfs_root tree_root;
 	struct btrfs_root fs_root;

+ 1 - 1
fs/btrfs/chunk-map.c

@@ -158,7 +158,7 @@ int btrfs_read_chunk_tree(void)
 	do {
 		found_key = btrfs_path_leaf_key(&path);
 		if (btrfs_comp_keys_type(&key, found_key))
-			continue;
+			break;
 
 		chunk = btrfs_path_item_ptr(&path, struct btrfs_chunk);
 		btrfs_chunk_to_cpu(chunk);

+ 8 - 22
fs/btrfs/super.c

@@ -15,34 +15,18 @@
 
 #define BTRFS_SUPER_INFO_SIZE	4096
 
-/*
- * checks if a valid root backup is present.
- * considers the case when all root backups empty valid.
- * returns -1 in case of invalid root backup and 0 for valid.
- */
-static int btrfs_check_super_roots(struct btrfs_super_block *sb)
+static int btrfs_newest_root_backup(struct btrfs_super_block *sb)
 {
 	struct btrfs_root_backup *root_backup;
 	int i, newest = -1;
-	int num_empty = 0;
 
 	for (i = 0; i < BTRFS_NUM_BACKUP_ROOTS; ++i) {
 		root_backup = sb->super_roots + i;
-
-		if (root_backup->tree_root == 0 && root_backup->tree_root_gen == 0)
-			num_empty++;
-
 		if (root_backup->tree_root_gen == sb->generation)
 			newest = i;
 	}
 
-	if (num_empty == BTRFS_NUM_BACKUP_ROOTS) {
-		return 0;
-	} else if (newest >= 0) {
-		return 0;
-	}
-
-	return -1;
+	return newest;
 }
 
 static inline int is_power_of_2(u64 x)
@@ -182,7 +166,7 @@ int btrfs_read_superblock(void)
 	char raw_sb[BTRFS_SUPER_INFO_SIZE];
 	struct btrfs_super_block *sb = (struct btrfs_super_block *) raw_sb;
 	u64 dev_total_bytes;
-	int i;
+	int i, root_backup_idx;
 
 	dev_total_bytes = (u64) btrfs_part_info->size * btrfs_part_info->blksz;
 
@@ -227,15 +211,17 @@ int btrfs_read_superblock(void)
 		return -1;
 	}
 
-	if (btrfs_check_super_roots(&btrfs_info.sb)) {
+	root_backup_idx = btrfs_newest_root_backup(&btrfs_info.sb);
+	if (root_backup_idx < 0) {
 		printf("%s: No valid root_backup found!\n", __func__);
 		return -1;
 	}
+	btrfs_info.root_backup = btrfs_info.sb.super_roots + root_backup_idx;
 
-	if (btrfs_info.sb.num_devices != 1) {
+	if (btrfs_info.root_backup->num_devices != 1) {
 		printf("%s: Unsupported number of devices (%lli). This driver "
 		       "only supports filesystem on one device.\n", __func__,
-		       btrfs_info.sb.num_devices);
+		       btrfs_info.root_backup->num_devices);
 		return -1;
 	}
 

+ 4 - 15
fs/ext4/ext4_common.c

@@ -1585,7 +1585,7 @@ static int ext4fs_blockgroup
 
 int ext4fs_read_inode(struct ext2_data *data, int ino, struct ext2_inode *inode)
 {
-	struct ext2_block_group *blkgrp;
+	struct ext2_block_group blkgrp;
 	struct ext2_sblock *sblock = &data->sblock;
 	struct ext_filesystem *fs = get_fs();
 	int log2blksz = get_fs()->dev_desc->log2blksz;
@@ -1593,28 +1593,17 @@ int ext4fs_read_inode(struct ext2_data *data, int ino, struct ext2_inode *inode)
 	long int blkno;
 	unsigned int blkoff;
 
-	/* Allocate blkgrp based on gdsize (for 64-bit support). */
-	blkgrp = zalloc(get_fs()->gdsize);
-	if (!blkgrp)
-		return 0;
-
 	/* It is easier to calculate if the first inode is 0. */
 	ino--;
 	status = ext4fs_blockgroup(data, ino / le32_to_cpu
-				   (sblock->inodes_per_group), blkgrp);
-	if (status == 0) {
-		free(blkgrp);
+				   (sblock->inodes_per_group), &blkgrp);
+	if (status == 0)
 		return 0;
-	}
 
 	inodes_per_block = EXT2_BLOCK_SIZE(data) / fs->inodesz;
-	blkno = ext4fs_bg_get_inode_table_id(blkgrp, fs) +
+	blkno = ext4fs_bg_get_inode_table_id(&blkgrp, fs) +
 	    (ino % le32_to_cpu(sblock->inodes_per_group)) / inodes_per_block;
 	blkoff = (ino % inodes_per_block) * fs->inodesz;
-
-	/* Free blkgrp as it is no longer required. */
-	free(blkgrp);
-
 	/* Read the inode. */
 	status = ext4fs_devread((lbaint_t)blkno << (LOG2_BLOCK_SIZE(data) -
 				log2blksz), blkoff,

+ 7 - 13
fs/ext4/ext4fs.c

@@ -61,18 +61,15 @@ int ext4fs_read_file(struct ext2fs_node *node, loff_t pos,
 	lbaint_t delayed_skipfirst = 0;
 	lbaint_t delayed_next = 0;
 	char *delayed_buf = NULL;
-	char *start_buf = buf;
 	short status;
 
+	if (blocksize <= 0)
+		return -1;
+
 	/* Adjust len so it we can't read past the end of the file. */
 	if (len + pos > filesize)
 		len = (filesize - pos);
 
-	if (blocksize <= 0 || len <= 0) {
-		ext_cache_fini(&cache);
-		return -1;
-	}
-
 	blockcnt = lldiv(((len + pos) + blocksize - 1), blocksize);
 
 	for (i = lldiv(pos, blocksize); i < blockcnt; i++) {
@@ -133,7 +130,6 @@ int ext4fs_read_file(struct ext2fs_node *node, loff_t pos,
 			}
 		} else {
 			int n;
-			int n_left;
 			if (previous_block_number != -1) {
 				/* spill */
 				status = ext4fs_devread(delayed_start,
@@ -146,9 +142,8 @@ int ext4fs_read_file(struct ext2fs_node *node, loff_t pos,
 			}
 			/* Zero no more than `len' bytes. */
 			n = blocksize - skipfirst;
-			n_left = len - ( buf - start_buf );
-			if (n > n_left)
-				n = n_left;
+			if (n > len)
+				n = len;
 			memset(buf, 0, n);
 		}
 		buf += blocksize - skipfirst;
@@ -169,7 +164,7 @@ int ext4fs_read_file(struct ext2fs_node *node, loff_t pos,
 
 int ext4fs_ls(const char *dirname)
 {
-	struct ext2fs_node *dirnode = NULL;
+	struct ext2fs_node *dirnode;
 	int status;
 
 	if (dirname == NULL)
@@ -179,8 +174,7 @@ int ext4fs_ls(const char *dirname)
 				  FILETYPE_DIRECTORY);
 	if (status != 1) {
 		printf("** Can not find directory. **\n");
-		if (dirnode)
-			ext4fs_free_node(dirnode, &ext4fs_root->diropen);
+		ext4fs_free_node(dirnode, &ext4fs_root->diropen);
 		return 1;
 	}
 

+ 3 - 66
fs/fs.c

@@ -265,19 +265,6 @@ static struct fstype_info *fs_get_info(int fstype)
 	return info;
 }
 
-/**
- * fs_get_type_name() - Get type of current filesystem
- *
- * Return: Pointer to filesystem name
- *
- * Returns a string describing the current filesystem, or the sentinel
- * "unsupported" for any unrecognised filesystem.
- */
-const char *fs_get_type_name(void)
-{
-	return fs_get_info(fs_type)->name;
-}
-
 int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype)
 {
 	struct fstype_info *info;
@@ -402,57 +389,13 @@ int fs_size(const char *filename, loff_t *size)
 	return ret;
 }
 
-#ifdef CONFIG_LMB
-/* Check if a file may be read to the given address */
-static int fs_read_lmb_check(const char *filename, ulong addr, loff_t offset,
-			     loff_t len, struct fstype_info *info)
-{
-	struct lmb lmb;
-	int ret;
-	loff_t size;
-	loff_t read_len;
-
-	/* get the actual size of the file */
-	ret = info->size(filename, &size);
-	if (ret)
-		return ret;
-	if (offset >= size) {
-		/* offset >= EOF, no bytes will be written */
-		return 0;
-	}
-	read_len = size - offset;
-
-	/* limit to 'len' if it is smaller */
-	if (len && len < read_len)
-		read_len = len;
-
-	lmb_init_and_reserve(&lmb, gd->bd->bi_dram[0].start,
-			     gd->bd->bi_dram[0].size, (void *)gd->fdt_blob);
-	lmb_dump_all(&lmb);
-
-	if (lmb_alloc_addr(&lmb, addr, read_len) == addr)
-		return 0;
-
-	printf("** Reading file would overwrite reserved memory **\n");
-	return -ENOSPC;
-}
-#endif
-
-static int _fs_read(const char *filename, ulong addr, loff_t offset, loff_t len,
-		    int do_lmb_check, loff_t *actread)
+int fs_read(const char *filename, ulong addr, loff_t offset, loff_t len,
+	    loff_t *actread)
 {
 	struct fstype_info *info = fs_get_info(fs_type);
 	void *buf;
 	int ret;
 
-#ifdef CONFIG_LMB
-	if (do_lmb_check) {
-		ret = fs_read_lmb_check(filename, addr, offset, len, info);
-		if (ret)
-			return ret;
-	}
-#endif
-
 	/*
 	 * We don't actually know how many bytes are being read, since len==0
 	 * means read the whole file.
@@ -469,12 +412,6 @@ static int _fs_read(const char *filename, ulong addr, loff_t offset, loff_t len,
 	return ret;
 }
 
-int fs_read(const char *filename, ulong addr, loff_t offset, loff_t len,
-	    loff_t *actread)
-{
-	return _fs_read(filename, addr, offset, len, 0, actread);
-}
-
 int fs_write(const char *filename, ulong addr, loff_t offset, loff_t len,
 	     loff_t *actwrite)
 {
@@ -618,7 +555,7 @@ int do_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
 		pos = 0;
 
 	time = get_timer(0);
-	ret = _fs_read(filename, addr, pos, bytes, 1, &len_read);
+	ret = fs_read(filename, addr, pos, bytes, &len_read);
 	time = get_timer(time);
 	if (ret < 0)
 		return 1;

+ 206 - 12
include/configs/sunxi-common.h

@@ -62,13 +62,22 @@
 /* ns16550 reg in the low bits of cpu reg */
 #define CONFIG_SYS_NS16550_CLK		24000000
 #ifndef CONFIG_DM_SERIAL
-#define CONFIG_SYS_NS16550_REG_SIZE	-4
-#define CONFIG_SYS_NS16550_COM1		(SUNXI_UART0_BASE + 0x400 * (0))
-#define CONFIG_SYS_NS16550_COM2		(SUNXI_UART0_BASE + 0x400 * (1))
-#define CONFIG_SYS_NS16550_COM3		(SUNXI_UART0_BASE + 0x400 * (2))
-#define CONFIG_SYS_NS16550_COM4		(SUNXI_UART0_BASE + 0x400 * (3))
-#define CONFIG_SYS_NS16550_COM5		(SUNXI_UART0_BASE + 0x400 * (4))
-#define CONFIG_SYS_NS16550_COM6		(SUNXI_UART0_BASE + 0x400 * (5))
+# define CONFIG_SYS_NS16550_REG_SIZE	-4
+#if CONFIG_CONS_INDEX == 1
+# define CONFIG_SYS_NS16550_COM1		(SUNXI_UART0_BASE + 0x400 * (CONFIG_CONS_INDEX - 1))
+#elif CONFIG_CONS_INDEX == 2
+# define CONFIG_SYS_NS16550_COM2		(SUNXI_UART0_BASE + 0x400 * (CONFIG_CONS_INDEX - 1))
+#elif CONFIG_CONS_INDEX == 3
+# define CONFIG_SYS_NS16550_COM3		(SUNXI_UART0_BASE + 0x400 * (CONFIG_CONS_INDEX - 1))
+#elif CONFIG_CONS_INDEX == 4
+# define CONFIG_SYS_NS16550_COM4		(SUNXI_UART0_BASE + 0x400 * (CONFIG_CONS_INDEX - 1))
+#elif CONFIG_CONS_INDEX == 5
+# define CONFIG_SYS_NS16550_COM5		(SUNXI_UART0_BASE + 0x400 * (CONFIG_CONS_INDEX - 1))
+#elif CONFIG_CONS_INDEX == 6
+# define CONFIG_SYS_NS16550_COM6		(SUNXI_UART0_BASE + 0x400 * (CONFIG_CONS_INDEX - 1))
+#else
+#error "bad com index"
+#endif
 #endif
 /* CPU */
 #define COUNTER_FREQUENCY		24000000
@@ -285,6 +294,91 @@
 
 #ifndef CONFIG_SPL_BUILD
 
+#ifdef CONFIG_ARM64
+/*
+ * Boards seem to come with at least 512MB of DRAM.
+ * The kernel should go at 512K, which is the default text offset (that will
+ * be adjusted at runtime if needed).
+ * There is no compression for arm64 kernels (yet), so leave some space
+ * for really big kernels, say 256MB for now.
+ * Scripts, PXE and DTBs should go afterwards, leaving the rest for the initrd.
+ * Align the initrd to a 2MB page.
+ */
+#define BOOTM_SIZE	__stringify(0xa000000)
+#define KERNEL_ADDR_R	__stringify(SDRAM_OFFSET(0080000))
+#define FDT_ADDR_R	__stringify(SDRAM_OFFSET(FA00000))
+#define SCRIPT_ADDR_R	__stringify(SDRAM_OFFSET(FC00000))
+#define PXEFILE_ADDR_R	__stringify(SDRAM_OFFSET(FD00000))
+#define RAMDISK_ADDR_R	__stringify(SDRAM_OFFSET(FE00000))
+
+#else
+/*
+ * 160M RAM (256M minimum minus 64MB heap + 32MB for u-boot, stack, fb, etc.
+ * 32M uncompressed kernel, 16M compressed kernel, 1M fdt,
+ * 1M script, 1M pxe and the ramdisk at the end.
+ */
+#ifndef CONFIG_MACH_SUN8I_V3S
+#define BOOTM_SIZE     __stringify(0xa000000)
+#define KERNEL_ADDR_R  __stringify(SDRAM_OFFSET(1000000))
+#define FDT_ADDR_R     __stringify(SDRAM_OFFSET(3000000))
+#define SCRIPT_ADDR_R  __stringify(SDRAM_OFFSET(3100000))
+#define PXEFILE_ADDR_R __stringify(SDRAM_OFFSET(3200000))
+#define RAMDISK_ADDR_R __stringify(SDRAM_OFFSET(3300000))
+#else
+/*
+ * 64M RAM minus 2MB heap + 16MB for u-boot, stack, fb, etc.
+ * 16M uncompressed kernel, 8M compressed kernel, 1M fdt,
+ * 1M script, 1M pxe and the ramdisk at the end.
+ */
+#define BOOTM_SIZE     __stringify(0x2e00000)
+#define KERNEL_ADDR_R  __stringify(SDRAM_OFFSET(1000000))
+#define FDT_ADDR_R     __stringify(SDRAM_OFFSET(1800000))
+#define SCRIPT_ADDR_R  __stringify(SDRAM_OFFSET(1900000))
+#define PXEFILE_ADDR_R __stringify(SDRAM_OFFSET(1A00000))
+#define RAMDISK_ADDR_R __stringify(SDRAM_OFFSET(1B00000))
+#endif
+#endif
+
+#define MEM_LAYOUT_ENV_SETTINGS \
+	"bootm_size=" BOOTM_SIZE "\0" \
+	"kernel_addr_r=" KERNEL_ADDR_R "\0" \
+	"fdtoverlay_addr_r=0x45000000\0" \
+	"fdt_addr_r=" FDT_ADDR_R "\0" \
+	"scriptaddr=" SCRIPT_ADDR_R "\0" \
+	"pxefile_addr_r=" PXEFILE_ADDR_R "\0" \
+	"ramdisk_addr_r=" RAMDISK_ADDR_R "\0"
+
+#define DFU_ALT_INFO_RAM \
+	"dfu_alt_info_ram=" \
+	"kernel ram " KERNEL_ADDR_R " 0x1000000;" \
+	"fdt ram " FDT_ADDR_R " 0x100000;" \
+	"ramdisk ram " RAMDISK_ADDR_R " 0x4000000\0"
+
+#ifdef CONFIG_MMC
+#if CONFIG_MMC_SUNXI_SLOT_EXTRA != -1
+#define BOOTENV_DEV_MMC_AUTO(devtypeu, devtypel, instance)		\
+	BOOTENV_DEV_MMC(MMC, mmc, 0)					\
+	BOOTENV_DEV_MMC(MMC, mmc, 2)					\
+	"bootcmd_mmc_auto="						\
+		"if test ${mmc_bootdev} -eq 1; then "			\
+			"run bootcmd_mmc2; "				\
+			"run bootcmd_mmc0; "				\
+		"elif test ${mmc_bootdev} -eq 0; then "			\
+			"run bootcmd_mmc0; "				\
+			"run bootcmd_mmc2; "				\
+		"fi\0"
+
+#define BOOTENV_DEV_NAME_MMC_AUTO(devtypeu, devtypel, instance) \
+	"mmc_auto "
+
+#define BOOT_TARGET_DEVICES_MMC(func) func(MMC_AUTO, mmc_auto, na)
+#else
+#define BOOT_TARGET_DEVICES_MMC(func) func(MMC, mmc, 0)
+#endif
+#else
+#define BOOT_TARGET_DEVICES_MMC(func)
+#endif
+
 #ifdef CONFIG_AHCI
 #define BOOT_TARGET_DEVICES_SCSI(func) func(SCSI, scsi, 0)
 #else
@@ -297,16 +391,115 @@
 #define BOOT_TARGET_DEVICES_USB(func)
 #endif
 
+/* FEL boot support, auto-execute boot.scr if a script address was provided */
+#define BOOTENV_DEV_FEL(devtypeu, devtypel, instance) \
+	"bootcmd_fel=" \
+		"if test -n ${fel_booted} && test -n ${fel_scriptaddr}; then " \
+			"echo '(FEL boot)'; " \
+			"source ${fel_scriptaddr}; " \
+		"fi\0"
+#define BOOTENV_DEV_NAME_FEL(devtypeu, devtypel, instance) \
+	"fel "
+
+#define BOOT_TARGET_DEVICES(func) \
+	func(FEL, fel, na) \
+	BOOT_TARGET_DEVICES_MMC(func) \
+	BOOT_TARGET_DEVICES_SCSI(func) \
+	BOOT_TARGET_DEVICES_USB(func)
+
+#ifdef CONFIG_OLD_SUNXI_KERNEL_COMPAT
+#define BOOTCMD_SUNXI_COMPAT \
+	"bootcmd_sunxi_compat=" \
+		"setenv root /dev/mmcblk0p3 rootwait; " \
+		"if ext2load mmc 0 0x44000000 uEnv.txt; then " \
+			"echo Loaded environment from uEnv.txt; " \
+			"env import -t 0x44000000 ${filesize}; " \
+		"fi; " \
+		"setenv bootargs console=${console} root=${root} ${extraargs}; " \
+		"ext2load mmc 0 0x43000000 script.bin && " \
+		"ext2load mmc 0 0x48000000 uImage && " \
+		"bootm 0x48000000\0"
+#else
+#define BOOTCMD_SUNXI_COMPAT
+#endif
 
 #include <config_distro_bootcmd.h>
 
+#ifdef CONFIG_USB_KEYBOARD
+#define CONSOLE_STDIN_SETTINGS \
+	"preboot=usb start\0" \
+	"stdin=serial,usbkbd\0"
+#else
+#define CONSOLE_STDIN_SETTINGS \
+	"stdin=serial\0"
+#endif
+
+#ifdef CONFIG_VIDEO
+#define CONSOLE_STDOUT_SETTINGS \
+	"stdout=serial,vga\0" \
+	"stderr=serial,vga\0"
+#elif CONFIG_DM_VIDEO
+#define CONFIG_SYS_WHITE_ON_BLACK
+#define CONSOLE_STDOUT_SETTINGS \
+	"stdout=serial,vidconsole\0" \
+	"stderr=serial,vidconsole\0"
+#else
+#define CONSOLE_STDOUT_SETTINGS \
+	"stdout=serial\0" \
+	"stderr=serial\0"
+#endif
+
+#ifdef CONFIG_MTDIDS_DEFAULT
+#define SUNXI_MTDIDS_DEFAULT \
+	"mtdids=" CONFIG_MTDIDS_DEFAULT "\0"
+#else
+#define SUNXI_MTDIDS_DEFAULT
+#endif
+
+#ifdef CONFIG_MTDPARTS_DEFAULT
+#define SUNXI_MTDPARTS_DEFAULT \
+	"mtdparts=" CONFIG_MTDPARTS_DEFAULT "\0"
+#else
+#define SUNXI_MTDPARTS_DEFAULT
+#endif
+
+#define PARTS_DEFAULT \
+	"name=loader1,start=8k,size=32k,uuid=${uuid_gpt_loader1};" \
+	"name=loader2,size=984k,uuid=${uuid_gpt_loader2};" \
+	"name=esp,size=128M,bootable,uuid=${uuid_gpt_esp};" \
+	"name=system,size=-,uuid=${uuid_gpt_system};"
+
+#define UUID_GPT_ESP "c12a7328-f81f-11d2-ba4b-00a0c93ec93b"
+
+#ifdef CONFIG_ARM64
+#define UUID_GPT_SYSTEM "b921b045-1df0-41c3-af44-4c6f280d3fae"
+#else
+#define UUID_GPT_SYSTEM "69dad710-2ce4-4e3c-b16c-21a1d49abed3"
+#endif
+
+#define CONSOLE_ENV_SETTINGS \
+	CONSOLE_STDIN_SETTINGS \
+	CONSOLE_STDOUT_SETTINGS
+
 #ifdef CONFIG_ARM64
 #define FDTFILE "allwinner/" CONFIG_DEFAULT_DEVICE_TREE ".dtb"
 #else
-#define FDTFILE CONFIG_DEFAULT_DEVICE_TREE ".dtb"
+#define FDTFILE "sunxi/" CONFIG_DEFAULT_DEVICE_TREE ".dtb"
 #endif
 
-#define CONFIG_EXTRA_ENV_SETTINGS
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	MEM_LAYOUT_ENV_SETTINGS \
+	DFU_ALT_INFO_RAM \
+	"fdtfile=" FDTFILE "\0" \
+	"console=ttyS0,115200\0" \
+	SUNXI_MTDIDS_DEFAULT \
+	SUNXI_MTDPARTS_DEFAULT \
+	"uuid_gpt_esp=" UUID_GPT_ESP "\0" \
+	"uuid_gpt_system=" UUID_GPT_SYSTEM "\0" \
+	"partitions=" PARTS_DEFAULT "\0" \
+	BOOTCMD_SUNXI_COMPAT \
+	BOOTENV
+
 #else /* ifndef CONFIG_SPL_BUILD */
 #define CONFIG_EXTRA_ENV_SETTINGS
 
@@ -320,10 +513,11 @@
 
 #define CONFIG_BOARD_LATE_INIT
 #define CONFIG_BOARD_EARLY_INIT_R
+
 /* copies of last seen 'mtdids', 'mtdparts' and 'partition' env variables */
-#define MTDIDS_MAXLEN		128
-#define MTDPARTS_MAXLEN		512
-#define PARTITION_MAXLEN	16
+#define MTDIDS_MAXLEN          128
+#define MTDPARTS_MAXLEN                512
+#define PARTITION_MAXLEN       16
 
 #ifdef CONFIG_SUNXI_FPGA_PLATFORM
 #define FPGA_PLATFORM

+ 1 - 0
sprite/sunxi_boot_param.c

@@ -96,6 +96,7 @@ int sunxi_bootparam_format(typedef_sunxi_boot_param *sunxi_boot_param)
 
 int sunxi_bootparam_down(void)
 {
+	return 0;
 	typedef_sunxi_boot_param *sunxi_boot_param = gd->boot_param;
 
 	if (sunxi_bootparam_format(sunxi_boot_param) < 0) {