This repository has been archived by the owner on Dec 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
0001-add-hatlab-gateboard-one.patch
1424 lines (1408 loc) · 56 KB
/
0001-add-hatlab-gateboard-one.patch
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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
From cd54d0e5d58d1c29c534cde561c2360655762c79 Mon Sep 17 00:00:00 2001
From: septs <github@septs.pw>
Date: Thu, 10 Aug 2023 19:26:02 +0800
Subject: [PATCH] add hatlab gateboard-one
---
arch/mips/dts/hatlab,gateboard-one.dts | 94 +++++++
arch/mips/mach-mtmips/mt7621/Kconfig | 13 +-
arch/mips/mach-mtmips/mt7621/spl/start.S | 5 +
board/mediatek/mt7621/Makefile | 1 +
board/mediatek/mt7621/hatlab,gateboard-one.c | 260 ++++++++++++++++++
.../mediatek/mt7621/hatlab,gateboard-one.env | 70 +++++
board/mediatek/mt7621/hatlab,gateboard-one.h | 41 +++
configs/hatlab_gateboard_one_1000_defconfig | 125 +++++++++
configs/hatlab_gateboard_one_1200_defconfig | 125 +++++++++
configs/hatlab_gateboard_one_880_defconfig | 125 +++++++++
drivers/mtd/spi/spi-nor-ids.c | 1 +
helper/build.sh | 21 ++
mt7621_stage_sram.blob | Bin 0 -> 21424 bytes
mt7621_stage_sram.quiet.blob | Bin 0 -> 13928 bytes
14 files changed, 877 insertions(+), 4 deletions(-)
create mode 100644 arch/mips/dts/hatlab,gateboard-one.dts
create mode 100644 board/mediatek/mt7621/hatlab,gateboard-one.c
create mode 100644 board/mediatek/mt7621/hatlab,gateboard-one.env
create mode 100644 board/mediatek/mt7621/hatlab,gateboard-one.h
create mode 100644 configs/hatlab_gateboard_one_1000_defconfig
create mode 100644 configs/hatlab_gateboard_one_1200_defconfig
create mode 100644 configs/hatlab_gateboard_one_880_defconfig
create mode 100755 helper/build.sh
create mode 100644 mt7621_stage_sram.blob
create mode 100644 mt7621_stage_sram.quiet.blob
diff --git a/arch/mips/dts/hatlab,gateboard-one.dts b/arch/mips/dts/hatlab,gateboard-one.dts
new file mode 100644
index 0000000000..a555ff7b15
--- /dev/null
+++ b/arch/mips/dts/hatlab,gateboard-one.dts
@@ -0,0 +1,94 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2022 MediaTek Inc. All rights reserved.
+ *
+ * Author: Weijie Gao <weijie.gao@mediatek.com>
+ */
+
+/dts-v1/;
+
+#include <dt-bindings/gpio/gpio.h>
+#include "mt7621.dtsi"
+
+/ {
+ compatible = "hatlab,gateboard-one", "mediatek,mt7621-soc";
+ model = "HATLab GateBoard-One";
+
+ aliases {
+ serial0 = &uart0;
+ spi0 = &spi;
+ };
+
+ chosen {
+ stdout-path = &uart0;
+ };
+};
+
+&pinctrl {
+ state_default: pin_state {
+ gpios {
+ groups = "wdt", "pcie reset", "i2c";
+ function = "gpio";
+ };
+
+ jtag {
+ groups = "jtag";
+ function = "jtag";
+ };
+ };
+};
+
+&uart0 {
+ status = "okay";
+};
+
+&gpio {
+ status = "okay";
+};
+
+&spi {
+ status = "okay";
+ num-cs = <2>;
+
+ spi-flash@0 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "jedec,spi-nor";
+ spi-max-frequency = <30000000>;
+ reg = <0>;
+ };
+
+ spi-nand@1 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "spi-nand";
+ reg = <1>;
+ spi-max-frequency = <30000000>;
+ };
+};
+
+ð {
+ status = "okay";
+};
+
+&mmc {
+ cap-sd-highspeed;
+
+ status = "okay";
+};
+
+&ssusb {
+ status = "okay";
+};
+
+&u3phy {
+ status = "okay";
+};
+
+&i2c {
+ status = "okay";
+ gpios = <&gpio0 3 GPIO_ACTIVE_HIGH>, /* PIN3 as SDA */
+ <&gpio0 4 GPIO_ACTIVE_HIGH>; /* PIN4 as CLK */
+ i2c-gpio,delay-us = <50>;
+ i2c-gpio,scl-output-only;
+};
diff --git a/arch/mips/mach-mtmips/mt7621/Kconfig b/arch/mips/mach-mtmips/mt7621/Kconfig
index 008a28f991..2f719f7d83 100644
--- a/arch/mips/mach-mtmips/mt7621/Kconfig
+++ b/arch/mips/mach-mtmips/mt7621/Kconfig
@@ -5,7 +5,7 @@ menu "CPU & DDR configuration"
config MT7621_CPU_FREQ
int "CPU Frequency (MHz)"
- range 400 1200
+ range 400 1300
default 880
choice
@@ -99,17 +99,22 @@ config BOARD_MT7621_NAND_RFB
sockets, 1 RGMII to external GbE PHY, 2 audio jacks (in/out),
JTAG pins and expansion GPIO pins.
+config BOARD_MT7621_HATLAB_GATEBOARD_ONE
+ bool "HATLab GateBoard One"
+ help
+ HATLab GateBoard One
+
endchoice
config SYS_CONFIG_NAME
string "Board configuration name"
- default "mt7621" if BOARD_MT7621_RFB || BOARD_MT7621_NAND_RFB
+ default "mt7621" if BOARD_MT7621_RFB || BOARD_MT7621_NAND_RFB || BOARD_MT7621_HATLAB_GATEBOARD_ONE
config SYS_BOARD
string "Board name"
- default "mt7621" if BOARD_MT7621_RFB || BOARD_MT7621_NAND_RFB
+ default "mt7621" if BOARD_MT7621_RFB || BOARD_MT7621_NAND_RFB || BOARD_MT7621_HATLAB_GATEBOARD_ONE
config SYS_VENDOR
- default "mediatek" if BOARD_MT7621_RFB || BOARD_MT7621_NAND_RFB
+ default "mediatek" if BOARD_MT7621_RFB || BOARD_MT7621_NAND_RFB || BOARD_MT7621_HATLAB_GATEBOARD_ONE
endif
diff --git a/arch/mips/mach-mtmips/mt7621/spl/start.S b/arch/mips/mach-mtmips/mt7621/spl/start.S
index 3cad3567e7..f385eb6412 100644
--- a/arch/mips/mach-mtmips/mt7621/spl/start.S
+++ b/arch/mips/mach-mtmips/mt7621/spl/start.S
@@ -143,6 +143,11 @@ ENTRY(_start)
bal mt7621_cps_init
nop
+#if defined(CONFIG_BOARD_MT7621_HATLAB_GATEBOARD_ONE)
+ bal hatlab_gateboard_one_early_init
+ nop
+#endif
+
/* Prepare for CPU/DDR initialization binary blob */
bal prepare_stage_bin
nop
diff --git a/board/mediatek/mt7621/Makefile b/board/mediatek/mt7621/Makefile
index db129c5aba..fa11ba6bef 100644
--- a/board/mediatek/mt7621/Makefile
+++ b/board/mediatek/mt7621/Makefile
@@ -1,3 +1,4 @@
# SPDX-License-Identifier: GPL-2.0
obj-y += board.o
+obj-$(CONFIG_BOARD_MT7621_HATLAB_GATEBOARD_ONE) += hatlab,gateboard-one.o
diff --git a/board/mediatek/mt7621/hatlab,gateboard-one.c b/board/mediatek/mt7621/hatlab,gateboard-one.c
new file mode 100644
index 0000000000..3324557b59
--- /dev/null
+++ b/board/mediatek/mt7621/hatlab,gateboard-one.c
@@ -0,0 +1,260 @@
+#include "hatlab,gateboard-one.h"
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/addrspace.h>
+
+/*
+ WDT_RST_N GPIO 18
+ MDIO GPIO 20
+ MDC GPIO 21
+*/
+
+volatile static void _udelay(unsigned int usec)
+{
+ usec = (((F_CPU / 1000000) * usec) / 4) + 1;
+ while (--usec)
+ __asm__ __volatile__("");
+}
+
+static void _set_mdio_data(int val)
+{
+ void __iomem *base_gpio;
+
+ base_gpio = (void __iomem *)CKSEG1ADDR(MT7621_GPIO_BASE);
+
+ if (val)
+ setbits_le32(base_gpio + MT7621_GPIO_DATA_0_REG, (1 << 20));
+ else
+ clrbits_le32(base_gpio + MT7621_GPIO_DATA_0_REG, (1 << 20));
+}
+
+static int _get_mdio_data(void)
+{
+ void __iomem *base_gpio;
+ u32 data;
+
+ base_gpio = (void __iomem *)CKSEG1ADDR(MT7621_GPIO_BASE);
+ data = readl(base_gpio + MT7621_GPIO_DATA_0_REG);
+
+ return (data & (1 << 20)) ? 1 : 0;
+}
+
+static void _set_mdc(int val)
+{
+ void __iomem *base_gpio;
+
+ base_gpio = (void __iomem *)CKSEG1ADDR(MT7621_GPIO_BASE);
+
+ if (val)
+ setbits_le32(base_gpio + MT7621_GPIO_DATA_0_REG, (1 << 21));
+ else
+ clrbits_le32(base_gpio + MT7621_GPIO_DATA_0_REG, (1 << 21));
+}
+
+static void _set_mdio_dir(int val)
+{
+ void __iomem *base_gpio;
+
+ base_gpio = (void __iomem *)CKSEG1ADDR(MT7621_GPIO_BASE);
+
+ if (val)
+ setbits_le32(base_gpio + MT7621_GPIO_CTRL_0_REG, (1 << 20));
+ else
+ clrbits_le32(base_gpio + MT7621_GPIO_CTRL_0_REG, (1 << 20));
+}
+
+/* MDIO must already be configured as output. */
+static void _mdiobb_send_bit(int val)
+{
+ _set_mdio_data(val);
+ _udelay(MDIO_DELAY);
+ _set_mdc(1);
+ _udelay(MDIO_DELAY);
+ _set_mdc(0);
+}
+
+/* MDIO must already be configured as input. */
+static int _mdiobb_get_bit(void)
+{
+ _udelay(MDIO_DELAY);
+ _set_mdc(1);
+ _udelay(MDIO_READ_DELAY);
+ _set_mdc(0);
+
+ return _get_mdio_data();
+}
+
+/* MDIO must already be configured as output. */
+static void _mdiobb_send_num(u16 val, int bits)
+{
+ int i;
+
+ for (i = bits - 1; i >= 0; i--)
+ _mdiobb_send_bit((val >> i) & 1);
+}
+
+/* MDIO must already be configured as input. */
+static u16 _mdiobb_get_num(int bits)
+{
+ int i;
+ u16 ret = 0;
+
+ for (i = bits - 1; i >= 0; i--)
+ {
+ ret <<= 1;
+ ret |= _mdiobb_get_bit();
+ }
+
+ return ret;
+}
+
+/* Utility to send the preamble, address, and
+ * register (common to read and write).
+ */
+static void _mdiobb_cmd(int read, u8 phy, u8 reg)
+{
+ int i;
+
+ _set_mdio_dir(1);
+
+ /*
+ * Send a 32 bit preamble ('1's) with an extra '1' bit for good
+ * measure. The IEEE spec says this is a PHY optional
+ * requirement. The AMD 79C874 requires one after power up and
+ * one after a MII communications error. This means that we are
+ * doing more preambles than we need, but it is safer and will be
+ * much more robust.
+ */
+
+ for (i = 0; i < 32; i++)
+ _mdiobb_send_bit(1);
+
+ /* send the start bit (01) and the read opcode (10) or write (10) */
+ _mdiobb_send_bit(0);
+ _mdiobb_send_bit(1);
+ _mdiobb_send_bit(read);
+ _mdiobb_send_bit(!read);
+
+ _mdiobb_send_num(phy, 5);
+ _mdiobb_send_num(reg, 5);
+}
+
+static int _mdiobb_read(int phy, int reg)
+{
+ int ret, i;
+
+ _mdiobb_cmd(MDIO_READ, phy, reg);
+ _set_mdio_dir(0);
+
+ /* check the turnaround bit: the PHY should be driving it to zero */
+ if (_mdiobb_get_bit() != 0)
+ {
+ /* PHY didn't drive TA low -- flush any bits it
+ * may be trying to send.
+ */
+ for (i = 0; i < 32; i++)
+ _mdiobb_get_bit();
+
+ return 0xffff;
+ }
+
+ ret = _mdiobb_get_num(16);
+ _mdiobb_get_bit();
+ return ret;
+}
+
+static int _mdiobb_write(int phy, int reg, u16 val)
+{
+ _mdiobb_cmd(MDIO_WRITE, phy, reg);
+
+ /* send the turnaround (10) */
+ _mdiobb_send_bit(1);
+ _mdiobb_send_bit(0);
+
+ _mdiobb_send_num(val, 16);
+
+ _set_mdio_dir(0);
+ _mdiobb_get_bit();
+ return 0;
+}
+
+static void _mdiobb_init(void)
+{
+ void __iomem *base_sysctl, *base_gpio;
+
+ base_sysctl = (void __iomem *)CKSEG1ADDR(MT7621_SYSCTL_BASE);
+ base_gpio = (void __iomem *)CKSEG1ADDR(MT7621_GPIO_BASE);
+
+ // Set MDC/MDIO as GPIO
+ setbits_le32(base_sysctl + MT7621_SYS_GPIO_MODE_REG, REG_SET_VAL(MDIO_MODE, 1));
+ // Set MDC as output GPIO
+ setbits_le32(base_gpio + MT7621_GPIO_CTRL_0_REG, (1 << 21));
+}
+
+static void _mdiobb_exit(void)
+{
+ void __iomem *base_sysctl, *base_gpio;
+
+ base_sysctl = (void __iomem *)CKSEG1ADDR(MT7621_SYSCTL_BASE);
+ base_gpio = (void __iomem *)CKSEG1ADDR(MT7621_GPIO_BASE);
+
+ // Set MDC as float GPIO
+ clrbits_le32(base_gpio + MT7621_GPIO_CTRL_0_REG, (1 << 21));
+ // Set MDC/MDIO back to MDIO
+ setbits_le32(base_sysctl + MT7621_SYS_GPIO_MODE_REG, REG_SET_VAL(MDIO_MODE, 0));
+}
+
+void hatlab_gateboard_one_early_init(void)
+{
+ u16 phy_val;
+ void __iomem *base_sysctl, *base_gpio;
+
+ base_sysctl = (void __iomem *)CKSEG1ADDR(MT7621_SYSCTL_BASE);
+ base_gpio = (void __iomem *)CKSEG1ADDR(MT7621_GPIO_BASE);
+
+ // Reset MT7530
+ setbits_le32(base_sysctl + MT7621_SYS_RSTCTL_REG, REG_SET_VAL(MCM_RST, 1));
+ _udelay(10);
+ clrbits_le32(base_sysctl + MT7621_SYS_RSTCTL_REG, REG_MASK(MCM_RST));
+ _udelay(10);
+
+ // Reset PIO
+ setbits_le32(base_sysctl + MT7621_SYS_RSTCTL_REG, REG_SET_VAL(PIO_RST, 1));
+ _udelay(10);
+ clrbits_le32(base_sysctl + MT7621_SYS_RSTCTL_REG, REG_MASK(PIO_RST));
+ _udelay(10);
+
+ // Light up system led
+ setbits_le32(base_gpio + MT7621_GPIO_CTRL_0_REG, (1 << 0));
+ setbits_le32(base_gpio + MT7621_GPIO_DATA_0_REG, (1 << 0));
+
+ // Set WDT_RST_N as output GPIO
+ setbits_le32(base_sysctl + MT7621_SYS_GPIO_MODE_REG, REG_SET_VAL(WDT_MODE, 1));
+ setbits_le32(base_gpio + MT7621_GPIO_CTRL_0_REG, (1 << 18));
+
+ // Set RGMII2 as float GPIO for PHY bootstrap pin
+ setbits_le32(base_sysctl + MT7621_SYS_GPIO_MODE_REG, REG_SET_VAL(RGMII2_MODE, 1));
+
+ // WDT_RST_N = 1, NMOS drain, Peripherals RST assert, Peripherals DC-DC turn off
+ setbits_le32(base_gpio + MT7621_GPIO_DATA_0_REG, (1 << 18));
+
+ // Delay for peripherals power down
+ _udelay(500000);
+
+ // WDT_RST_N = 0, NMOS off, Peripherals RST deassert, Peripherals DC-DC turn on
+ clrbits_le32(base_gpio + MT7621_GPIO_DATA_0_REG, (1 << 18));
+
+ // Delay for peripherals power on
+ _udelay(400000);
+
+ // Set RGMII2 back to RGMII
+ clrbits_le32(base_sysctl + MT7621_SYS_GPIO_MODE_REG, REG_MASK(RGMII2_MODE));
+
+ // According to RTL8211FS datasheet, use bitbang MDIO turn off broadcast phy addr 0 before MT7530 init
+ _mdiobb_init();
+ phy_val = _mdiobb_read(7, 0x18);
+ phy_val &= ~(1 << 13);
+ _mdiobb_write(7, 0x18, phy_val);
+ _mdiobb_exit();
+}
diff --git a/board/mediatek/mt7621/hatlab,gateboard-one.env b/board/mediatek/mt7621/hatlab,gateboard-one.env
new file mode 100644
index 0000000000..706dff9236
--- /dev/null
+++ b/board/mediatek/mt7621/hatlab,gateboard-one.env
@@ -0,0 +1,70 @@
+gateboard_bios_version=20230318
+
+bios_flash_size=80000
+
+blob_load_addr=81000000
+itb_load_addr=84000000
+dtoverride_load_addr=82000000
+initrd_high=84000000
+
+
+
+kernel_name=vmlinux.itb
+dtoverride_name=dtoverride.dtb
+initrd_conf_name=initrd-1
+firmware_name=hatlab_gateboard-one-combined.img
+bios_name=hatlab_gateboard-one-bios.bin
+
+ubikrnl_name=hatlab_gateboard-one-kernel.itb
+ubiroot_name=hatlab_gateboard-one-squashfs-rootfs.img
+
+ubi_mtd=spi-nand0
+ubi_part=nand0-ubi
+ubi_volume_kernel=vmlinux.itb
+ubi_volume_kernel_size=0
+ubi_volume_rootfs=rootfs
+ubi_volume_rootfs_size=0
+ubi_volume_rootfs_index=1
+ubi_volume_data=rootfs_data
+ubi_volume_data_size=4000000
+
+
+
+ewdt_disable=i2c dev 0; i2c probe; i2c mw 51 0f ff; i2c mw 51 5e 00;
+
+
+
+bootargs_template=console=ttyS0,115200
+
+_boot_ubi=ubi part ${ubi_part}; ubi read ${itb_load_addr} ${ubi_volume_kernel}; setenv bootargs ${bootargs_template} ubi.mtd=${ubi_part} ubi.block=0,${ubi_volume_rootfs} root=/dev/ubiblock0_${ubi_volume_rootfs_index}; bootm ${itb_load_addr};
+
+_boot_bootfs=if load ${interface} ${dev}:${bootable} ${itb_load_addr} ${kernel_name}; then setexpr rootpart ${bootable} + 1; part uuid ${interface} ${dev}:${rootpart} rootuuid; setenv bootargs ${bootargs_template} root=PARTUUID=${rootuuid}; if load ${interface} ${dev}:${bootable} ${dtoverride_load_addr} ${dtoverride_name}; then bootm ${itb_load_addr} :${initrd_conf_name} ${dtoverride_load_addr}; fi; bootm ${itb_load_addr}; fi; echo "================================"; echo "Bad bootable media: [${interface}]${dev}:${bootable}"; echo "================================";
+
+_flash_firmware=if load ${interface} ${dev}:1 ${blob_load_addr} ${firmware_name}; then echo "================================"; echo "Found firmware image: [${interface}]${dev}"; echo "================================"; setexpr filesize ${filesize} / 200; setexpr filesize ${filesize} + 1; setenv flashing_cmd ${interface} write ${blob_load_addr} 0 ${filesize}; run ewdt_disable; run flashing_cmd; sleep 1; reset; fi;
+
+_scan_boot_usb_dev=if usb dev ${usb_dev}; then setenv interface usb; setenv dev ${usb_dev}; part list usb ${usb_dev} -bootable bootable; if test "${bootable}" != ""; then run _boot_bootfs; fi; fi; run _flash_firmware;
+
+_scan_boot_usb=usb reset; for i in 0 1 2 3; do setenv usb_dev ${i}; run _scan_boot_usb_dev; done;
+
+_scan_boot_mmc=if mmc dev 0; then setenv interface mmc; setenv dev 0; part list mmc 0 -bootable bootable; if test "${bootable}" != ""; then run _boot_bootfs; fi; fi; run _flash_firmware;
+
+scan_boot=run _scan_boot_mmc; run _scan_boot_usb; run _boot_ubi; echo "================================"; echo "No bootable media."; echo "================================";
+
+hellomessage=echo ""; echo "================================"; echo "DAS-Security HATLab u-boot BIOS"; echo "Version: ${gateboard_bios_version}"; echo "================================"; echo "";
+
+bootcmd=run hellomessage; run scan_boot;
+
+
+
+_update_bios=if load ${interface} 0:1 ${blob_load_addr} ${bios_name}; then sf probe; sf erase 0 ${bios_flash_size}; sf write ${blob_load_addr} 0 ${filesize}; sleep 1; reset; fi;
+_update_bios_usb=usb reset; setenv interface usb; run _update_bios;
+_update_bios_mmc=mmc rescan; setenv interface mmc; run _update_bios;
+update_bios=run ewdt_disable; run _update_bios_usb; run _update_bios_mmc;
+
+
+
+_format_ubi=if size ${interface} 0:1 ${ubikrnl_name}; then setenv ubi_volume_kernel_size ${filesize}; if size ${interface} 0:1 ${ubiroot_name}; then setenv ubi_volume_rootfs_size ${filesize}; ubi detach; mtd erase ${ubi_mtd}; ubi part ${ubi_part}; ubi create ${ubi_volume_kernel} ${ubi_volume_kernel_size} s; ubi create ${ubi_volume_rootfs} ${ubi_volume_rootfs_size}; ubi create ${ubi_volume_data} ${ubi_volume_data_size}; fi; fi;
+_flash_ubi_part=if load ${interface} 0:1 ${blob_load_addr} ${ubikrnl_name}; then ubi write ${blob_load_addr} ${ubi_volume_kernel} ${filesize}; fi; if load ${interface} 0:1 ${blob_load_addr} ${ubiroot_name}; then ubi write ${blob_load_addr} ${ubi_volume_rootfs} ${filesize}; fi;
+_flash_ubi=run ewdt_disable; run _format_ubi; run _flash_ubi_part;
+flash_ubi_usb=usb reset; setenv interface usb; run _flash_ubi; reset;
+flash_ubi_mmc=mmc rescan; setenv interface mmc; run _flash_ubi; reset;
diff --git a/board/mediatek/mt7621/hatlab,gateboard-one.h b/board/mediatek/mt7621/hatlab,gateboard-one.h
new file mode 100644
index 0000000000..26bfba7023
--- /dev/null
+++ b/board/mediatek/mt7621/hatlab,gateboard-one.h
@@ -0,0 +1,41 @@
+#pragma once
+
+#define F_CPU 500000000L
+
+#define MT7621_SYSCTL_BASE 0x1e000000
+#define MT7621_GPIO_BASE 0x1e000600
+
+#define MT7621_SYS_RSTCTL_REG 0x34
+#define ETH_RST_S 23
+#define ETH_RST_M 0x01
+#define PIO_RST_S 13
+#define PIO_RST_M 0x01
+#define MCM_RST_S 2
+#define MCM_RST_M 0x01
+
+#define MT7621_SYS_GPIO_MODE_REG 0x60
+#define RGMII2_MODE_S 15
+#define RGMII2_MODE_M 0x01
+#define MDIO_MODE_S 12
+#define MDIO_MODE_M 0x03
+#define WDT_MODE_S 8
+#define WDT_MODE_M 0x03
+
+#define MT7621_GPIO_CTRL_0_REG 0x00
+
+#define MT7621_GPIO_DATA_0_REG 0x20
+
+#define MDIO_READ 1
+#define MDIO_WRITE 0
+
+#define MDIO_DELAY 3
+#define MDIO_READ_DELAY 4
+
+#define REG_SET_VAL(_name, _val) \
+ (((_name##_M) & (_val)) << (_name##_S))
+
+#define REG_MASK(_name) \
+ ((_name##_M) << (_name##_S))
+
+#define REG_GET_VAL(_name, _val) \
+ (((_val) >> (_name##_S)) & (_name##_M))
diff --git a/configs/hatlab_gateboard_one_1000_defconfig b/configs/hatlab_gateboard_one_1000_defconfig
new file mode 100644
index 0000000000..6dc440b976
--- /dev/null
+++ b/configs/hatlab_gateboard_one_1000_defconfig
@@ -0,0 +1,125 @@
+CONFIG_MIPS=y
+CONFIG_BOARD_MT7621_HATLAB_GATEBOARD_ONE=y
+CONFIG_SPL_SERIAL=y
+CONFIG_SPL_SYS_MALLOC_F_LEN=0x100000
+CONFIG_SPL=y
+CONFIG_SYS_MALLOC_LEN=0x100000
+CONFIG_MIPS_RELOCATION_TABLE_SIZE=0x10000
+CONFIG_SPL_LIBCOMMON_SUPPORT=y
+CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_NR_DRAM_BANKS=1
+# CONFIG_ENV_IS_NOWHERE is not set
+CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_ENV_OFFSET=0x70000
+CONFIG_ENV_SIZE=0x8000
+CONFIG_ENV_SECT_SIZE=0x1000
+CONFIG_ENV_SOURCE_FILE="hatlab,gateboard-one"
+CONFIG_DEFAULT_DEVICE_TREE="hatlab,gateboard-one"
+CONFIG_DEBUG_UART_BASE=0xbe000c00
+CONFIG_DEBUG_UART_CLOCK=50000000
+CONFIG_SYS_LOAD_ADDR=0x83000000
+CONFIG_ARCH_MTMIPS=y
+CONFIG_SOC_MT7621=y
+CONFIG_MT7621_CPU_FREQ=1000
+CONFIG_MT7621_DRAM_FREQ_1200=y
+CONFIG_MT7621_DRAM_DDR3_4096M=y
+# CONFIG_MIPS_CACHE_SETUP is not set
+# CONFIG_MIPS_CACHE_DISABLE is not set
+CONFIG_RESTORE_EXCEPTION_VECTOR_BASE=y
+CONFIG_MIPS_BOOT_FDT=y
+CONFIG_DEBUG_UART=y
+CONFIG_TPL_SYS_MALLOC_F_LEN=0x1000
+CONFIG_FIT=y
+# CONFIG_ARCH_FIXUP_FDT_MEMORY is not set
+CONFIG_SYS_CONSOLE_INFO_QUIET=y
+CONFIG_SPL_MAX_SIZE=0x30000
+CONFIG_SPL_BSS_START_ADDR=0x80140000
+CONFIG_SPL_BSS_MAX_SIZE=0x80000
+CONFIG_SPL_SYS_MALLOC_SIMPLE=y
+CONFIG_SPL_NOR_SUPPORT=y
+CONFIG_TPL=y
+CONFIG_BOOTDELAY=0
+# CONFIG_TPL_FRAMEWORK is not set
+# CONFIG_BOOTM_NETBSD is not set
+# CONFIG_BOOTM_PLAN9 is not set
+# CONFIG_BOOTM_RTEMS is not set
+# CONFIG_BOOTM_VXWORKS is not set
+CONFIG_SYS_BOOTM_LEN=0x2000000
+CONFIG_HUSH_PARSER=y
+# CONFIG_CMD_BOOTFLOW is not set
+# CONFIG_CMD_ELF is not set
+# CONFIG_CMD_XIMG is not set
+# CONFIG_CMD_CRC32 is not set
+CONFIG_CMD_DM=y
+CONFIG_CMD_GPIO=y
+# CONFIG_CMD_LOADB is not set
+# CONFIG_CMD_LOADS is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_PART=y
+# CONFIG_CMD_PINMUX is not set
+CONFIG_CMD_SPI=y
+# CONFIG_CMD_NFS is not set
+CONFIG_DOS_PARTITION=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+CONFIG_CMD_EXT2=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_UBI=y
+CONFIG_CMD_MTD=y
+CONFIG_MTDIDS_DEFAULT="nor0=nor0,spi-nand0=nand0"
+CONFIG_MTDPARTS_DEFAULT="nor0:448k(u-boot),32k(u-boot-env),32k(factory);nand0:-(nand0-ubi)"
+# CONFIG_SPL_DOS_PARTITION is not set
+# CONFIG_ISO_PARTITION is not set
+CONFIG_EFI_PARTITION=y
+# CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_PARTITION_TYPE_GUID=y
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_I2C=y
+CONFIG_DM_I2C=y
+CONFIG_DM_I2C_GPIO=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_MDIO=y
+# CONFIG_INPUT is not set
+CONFIG_MMC=y
+# CONFIG_MMC_QUIRKS is not set
+# CONFIG_MMC_HW_PARTITIONING is not set
+CONFIG_MMC_MTK=y
+CONFIG_SF_DEFAULT_SPEED=20000000
+CONFIG_SPI_FLASH_BAR=y
+CONFIG_SPI_FLASH_EON=y
+CONFIG_SPI_FLASH_GIGADEVICE=y
+CONFIG_SPI_FLASH_ISSI=y
+CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_SPI_FLASH_WINBOND=y
+CONFIG_SPI_FLASH_XMC=y
+CONFIG_SPI_FLASH_XTX=y
+CONFIG_SPI_FLASH_MTD=y
+CONFIG_DM_MTD=y
+CONFIG_MTD_SPI_NAND=y
+CONFIG_MTD=y
+CONFIG_MTD_UBI=y
+CONFIG_CMD_MTDPARTS=y
+CONFIG_CMD_MTDPARTS_SPREAD=y
+CONFIG_CMD_MTDPARTS_SHOW_NET_SIZES=y
+CONFIG_MEDIATEK_ETH=y
+CONFIG_PHY=y
+CONFIG_PHY_MTK_TPHY=y
+CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_SPI=y
+CONFIG_MT7621_SPI=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_RESETCTL=y
+CONFIG_WDT=y
+CONFIG_WDT_MT7621=y
+# CONFIG_BINMAN_FDT is not set
+CONFIG_LZMA=y
+CONFIG_GZIP=y
+CONFIG_SPL_LZMA=y
+CONFIG_USB=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_MTK=y
+CONFIG_USB_STORAGE=y
diff --git a/configs/hatlab_gateboard_one_1200_defconfig b/configs/hatlab_gateboard_one_1200_defconfig
new file mode 100644
index 0000000000..0972cb3a7e
--- /dev/null
+++ b/configs/hatlab_gateboard_one_1200_defconfig
@@ -0,0 +1,125 @@
+CONFIG_MIPS=y
+CONFIG_BOARD_MT7621_HATLAB_GATEBOARD_ONE=y
+CONFIG_SPL_SERIAL=y
+CONFIG_SPL_SYS_MALLOC_F_LEN=0x100000
+CONFIG_SPL=y
+CONFIG_SYS_MALLOC_LEN=0x100000
+CONFIG_MIPS_RELOCATION_TABLE_SIZE=0x10000
+CONFIG_SPL_LIBCOMMON_SUPPORT=y
+CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_NR_DRAM_BANKS=1
+# CONFIG_ENV_IS_NOWHERE is not set
+CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_ENV_OFFSET=0x70000
+CONFIG_ENV_SIZE=0x8000
+CONFIG_ENV_SECT_SIZE=0x1000
+CONFIG_ENV_SOURCE_FILE="hatlab,gateboard-one"
+CONFIG_DEFAULT_DEVICE_TREE="hatlab,gateboard-one"
+CONFIG_DEBUG_UART_BASE=0xbe000c00
+CONFIG_DEBUG_UART_CLOCK=50000000
+CONFIG_SYS_LOAD_ADDR=0x83000000
+CONFIG_ARCH_MTMIPS=y
+CONFIG_SOC_MT7621=y
+CONFIG_MT7621_CPU_FREQ=1200
+CONFIG_MT7621_DRAM_FREQ_1200=y
+CONFIG_MT7621_DRAM_DDR3_4096M=y
+# CONFIG_MIPS_CACHE_SETUP is not set
+# CONFIG_MIPS_CACHE_DISABLE is not set
+CONFIG_RESTORE_EXCEPTION_VECTOR_BASE=y
+CONFIG_MIPS_BOOT_FDT=y
+CONFIG_DEBUG_UART=y
+CONFIG_TPL_SYS_MALLOC_F_LEN=0x1000
+CONFIG_FIT=y
+# CONFIG_ARCH_FIXUP_FDT_MEMORY is not set
+CONFIG_SYS_CONSOLE_INFO_QUIET=y
+CONFIG_SPL_MAX_SIZE=0x30000
+CONFIG_SPL_BSS_START_ADDR=0x80140000
+CONFIG_SPL_BSS_MAX_SIZE=0x80000
+CONFIG_SPL_SYS_MALLOC_SIMPLE=y
+CONFIG_SPL_NOR_SUPPORT=y
+CONFIG_TPL=y
+CONFIG_BOOTDELAY=0
+# CONFIG_TPL_FRAMEWORK is not set
+# CONFIG_BOOTM_NETBSD is not set
+# CONFIG_BOOTM_PLAN9 is not set
+# CONFIG_BOOTM_RTEMS is not set
+# CONFIG_BOOTM_VXWORKS is not set
+CONFIG_SYS_BOOTM_LEN=0x2000000
+CONFIG_HUSH_PARSER=y
+# CONFIG_CMD_BOOTFLOW is not set
+# CONFIG_CMD_ELF is not set
+# CONFIG_CMD_XIMG is not set
+# CONFIG_CMD_CRC32 is not set
+CONFIG_CMD_DM=y
+CONFIG_CMD_GPIO=y
+# CONFIG_CMD_LOADB is not set
+# CONFIG_CMD_LOADS is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_PART=y
+# CONFIG_CMD_PINMUX is not set
+CONFIG_CMD_SPI=y
+# CONFIG_CMD_NFS is not set
+CONFIG_DOS_PARTITION=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+CONFIG_CMD_EXT2=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_UBI=y
+CONFIG_CMD_MTD=y
+CONFIG_MTDIDS_DEFAULT="nor0=nor0,spi-nand0=nand0"
+CONFIG_MTDPARTS_DEFAULT="nor0:448k(u-boot),32k(u-boot-env),32k(factory);nand0:-(nand0-ubi)"
+# CONFIG_SPL_DOS_PARTITION is not set
+# CONFIG_ISO_PARTITION is not set
+CONFIG_EFI_PARTITION=y
+# CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_PARTITION_TYPE_GUID=y
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_I2C=y
+CONFIG_DM_I2C=y
+CONFIG_DM_I2C_GPIO=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_MDIO=y
+# CONFIG_INPUT is not set
+CONFIG_MMC=y
+# CONFIG_MMC_QUIRKS is not set
+# CONFIG_MMC_HW_PARTITIONING is not set
+CONFIG_MMC_MTK=y
+CONFIG_SF_DEFAULT_SPEED=20000000
+CONFIG_SPI_FLASH_BAR=y
+CONFIG_SPI_FLASH_EON=y
+CONFIG_SPI_FLASH_GIGADEVICE=y
+CONFIG_SPI_FLASH_ISSI=y
+CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_SPI_FLASH_WINBOND=y
+CONFIG_SPI_FLASH_XMC=y
+CONFIG_SPI_FLASH_XTX=y
+CONFIG_SPI_FLASH_MTD=y
+CONFIG_DM_MTD=y
+CONFIG_MTD_SPI_NAND=y
+CONFIG_MTD=y
+CONFIG_MTD_UBI=y
+CONFIG_CMD_MTDPARTS=y
+CONFIG_CMD_MTDPARTS_SPREAD=y
+CONFIG_CMD_MTDPARTS_SHOW_NET_SIZES=y
+CONFIG_MEDIATEK_ETH=y
+CONFIG_PHY=y
+CONFIG_PHY_MTK_TPHY=y
+CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_SPI=y
+CONFIG_MT7621_SPI=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_RESETCTL=y
+CONFIG_WDT=y
+CONFIG_WDT_MT7621=y
+# CONFIG_BINMAN_FDT is not set
+CONFIG_LZMA=y
+CONFIG_GZIP=y
+CONFIG_SPL_LZMA=y
+CONFIG_USB=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_MTK=y
+CONFIG_USB_STORAGE=y
diff --git a/configs/hatlab_gateboard_one_880_defconfig b/configs/hatlab_gateboard_one_880_defconfig
new file mode 100644
index 0000000000..0b584bc912
--- /dev/null
+++ b/configs/hatlab_gateboard_one_880_defconfig
@@ -0,0 +1,125 @@
+CONFIG_MIPS=y
+CONFIG_BOARD_MT7621_HATLAB_GATEBOARD_ONE=y
+CONFIG_SPL_SERIAL=y
+CONFIG_SPL_SYS_MALLOC_F_LEN=0x100000
+CONFIG_SPL=y
+CONFIG_SYS_MALLOC_LEN=0x100000
+CONFIG_MIPS_RELOCATION_TABLE_SIZE=0x10000
+CONFIG_SPL_LIBCOMMON_SUPPORT=y
+CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_NR_DRAM_BANKS=1
+# CONFIG_ENV_IS_NOWHERE is not set
+CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_ENV_OFFSET=0x70000
+CONFIG_ENV_SIZE=0x8000
+CONFIG_ENV_SECT_SIZE=0x1000
+CONFIG_ENV_SOURCE_FILE="hatlab,gateboard-one"
+CONFIG_DEFAULT_DEVICE_TREE="hatlab,gateboard-one"
+CONFIG_DEBUG_UART_BASE=0xbe000c00
+CONFIG_DEBUG_UART_CLOCK=50000000
+CONFIG_SYS_LOAD_ADDR=0x83000000
+CONFIG_ARCH_MTMIPS=y
+CONFIG_SOC_MT7621=y
+CONFIG_MT7621_CPU_FREQ=880
+CONFIG_MT7621_DRAM_FREQ_1200=y
+CONFIG_MT7621_DRAM_DDR3_4096M=y
+# CONFIG_MIPS_CACHE_SETUP is not set
+# CONFIG_MIPS_CACHE_DISABLE is not set
+CONFIG_RESTORE_EXCEPTION_VECTOR_BASE=y
+CONFIG_MIPS_BOOT_FDT=y
+CONFIG_DEBUG_UART=y
+CONFIG_TPL_SYS_MALLOC_F_LEN=0x1000
+CONFIG_FIT=y
+# CONFIG_ARCH_FIXUP_FDT_MEMORY is not set
+CONFIG_SYS_CONSOLE_INFO_QUIET=y
+CONFIG_SPL_MAX_SIZE=0x30000
+CONFIG_SPL_BSS_START_ADDR=0x80140000
+CONFIG_SPL_BSS_MAX_SIZE=0x80000
+CONFIG_SPL_SYS_MALLOC_SIMPLE=y
+CONFIG_SPL_NOR_SUPPORT=y
+CONFIG_TPL=y
+CONFIG_BOOTDELAY=0
+# CONFIG_TPL_FRAMEWORK is not set
+# CONFIG_BOOTM_NETBSD is not set
+# CONFIG_BOOTM_PLAN9 is not set
+# CONFIG_BOOTM_RTEMS is not set
+# CONFIG_BOOTM_VXWORKS is not set
+CONFIG_SYS_BOOTM_LEN=0x2000000
+CONFIG_HUSH_PARSER=y
+# CONFIG_CMD_BOOTFLOW is not set
+# CONFIG_CMD_ELF is not set
+# CONFIG_CMD_XIMG is not set
+# CONFIG_CMD_CRC32 is not set
+CONFIG_CMD_DM=y
+CONFIG_CMD_GPIO=y
+# CONFIG_CMD_LOADB is not set
+# CONFIG_CMD_LOADS is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_PART=y
+# CONFIG_CMD_PINMUX is not set
+CONFIG_CMD_SPI=y
+# CONFIG_CMD_NFS is not set
+CONFIG_DOS_PARTITION=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+CONFIG_CMD_EXT2=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_UBI=y
+CONFIG_CMD_MTD=y
+CONFIG_MTDIDS_DEFAULT="nor0=nor0,spi-nand0=nand0"
+CONFIG_MTDPARTS_DEFAULT="nor0:448k(u-boot),32k(u-boot-env),32k(factory);nand0:-(nand0-ubi)"
+# CONFIG_SPL_DOS_PARTITION is not set
+# CONFIG_ISO_PARTITION is not set
+CONFIG_EFI_PARTITION=y
+# CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_PARTITION_TYPE_GUID=y
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_I2C=y
+CONFIG_DM_I2C=y
+CONFIG_DM_I2C_GPIO=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_MDIO=y
+# CONFIG_INPUT is not set
+CONFIG_MMC=y
+# CONFIG_MMC_QUIRKS is not set
+# CONFIG_MMC_HW_PARTITIONING is not set
+CONFIG_MMC_MTK=y
+CONFIG_SF_DEFAULT_SPEED=20000000
+CONFIG_SPI_FLASH_BAR=y
+CONFIG_SPI_FLASH_EON=y
+CONFIG_SPI_FLASH_GIGADEVICE=y
+CONFIG_SPI_FLASH_ISSI=y
+CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_SPI_FLASH_WINBOND=y
+CONFIG_SPI_FLASH_XMC=y
+CONFIG_SPI_FLASH_XTX=y
+CONFIG_SPI_FLASH_MTD=y
+CONFIG_DM_MTD=y
+CONFIG_MTD_SPI_NAND=y
+CONFIG_MTD=y
+CONFIG_MTD_UBI=y
+CONFIG_CMD_MTDPARTS=y
+CONFIG_CMD_MTDPARTS_SPREAD=y
+CONFIG_CMD_MTDPARTS_SHOW_NET_SIZES=y
+CONFIG_MEDIATEK_ETH=y
+CONFIG_PHY=y
+CONFIG_PHY_MTK_TPHY=y
+CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_SPI=y
+CONFIG_MT7621_SPI=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_RESETCTL=y
+CONFIG_WDT=y
+CONFIG_WDT_MT7621=y
+# CONFIG_BINMAN_FDT is not set
+CONFIG_LZMA=y
+CONFIG_GZIP=y
+CONFIG_SPL_LZMA=y
+CONFIG_USB=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_MTK=y
+CONFIG_USB_STORAGE=y
diff --git a/drivers/mtd/spi/spi-nor-ids.c b/drivers/mtd/spi/spi-nor-ids.c
index 4fe8b0d92c..d94723338c 100644
--- a/drivers/mtd/spi/spi-nor-ids.c
+++ b/drivers/mtd/spi/spi-nor-ids.c
@@ -443,6 +443,7 @@ const struct flash_info spi_nor_ids[] = {
{ INFO("w25m512jv", 0xef7119, 0, 64 * 1024, 1024, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
{ INFO("w25h02jv", 0xef9022, 0, 64 * 1024, 4096, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
#endif
+ { INFO("p25d40h", 0x856013, 0, 64 * 1024, 8, SECT_4K | SPI_NOR_HAS_LOCK) },
#ifdef CONFIG_SPI_FLASH_XMC
/* XMC (Wuhan Xinxin Semiconductor Manufacturing Corp.) */
{ INFO("XM25QH64A", 0x207017, 0, 64 * 1024, 128, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
diff --git a/helper/build.sh b/helper/build.sh
new file mode 100755
index 0000000000..b31476e38c
--- /dev/null
+++ b/helper/build.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+# sudo apt install gcc-mipsel-linux-gnu
+