1 From 37bcf4d1acb5f7ce93fa0bd59dc313a79004ae34 Mon Sep 17 00:00:00 2001
2 From: Weijie Gao <weijie.gao@mediatek.com>
3 Date: Wed, 31 Aug 2022 19:00:25 +0800
4 Subject: [PATCH 04/32] board: mediatek: add MT7981 reference boards
6 This patch adds general board files based on MT7981 SoCs.
8 MT7981 uses one mmc controller for booting from both SD and eMMC, and the
9 pins of mmc controller are also shared with spi controller.
10 So three configs are need for these boot types:
12 1. mt7981_rfb_defconfig - SPI-NOR and SPI-NAND
13 2. mt7981_emmc_rfb_defconfig - eMMC only
14 3. mt7981_sd_rfb_defconfig - SD only
16 Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
18 arch/arm/dts/Makefile | 3 +
19 arch/arm/dts/mt7981-emmc-rfb.dts | 139 +++++++++++++++++++++++
20 arch/arm/dts/mt7981-rfb.dts | 173 +++++++++++++++++++++++++++++
21 arch/arm/dts/mt7981-sd-rfb.dts | 139 +++++++++++++++++++++++
22 board/mediatek/mt7981/MAINTAINERS | 10 ++
23 board/mediatek/mt7981/Makefile | 3 +
24 board/mediatek/mt7981/mt7981_rfb.c | 10 ++
25 configs/mt7981_emmc_rfb_defconfig | 64 +++++++++++
26 configs/mt7981_rfb_defconfig | 69 ++++++++++++
27 configs/mt7981_sd_rfb_defconfig | 64 +++++++++++
28 include/configs/mt7981.h | 26 +++++
29 11 files changed, 700 insertions(+)
30 create mode 100644 arch/arm/dts/mt7981-emmc-rfb.dts
31 create mode 100644 arch/arm/dts/mt7981-rfb.dts
32 create mode 100644 arch/arm/dts/mt7981-sd-rfb.dts
33 create mode 100644 board/mediatek/mt7981/MAINTAINERS
34 create mode 100644 board/mediatek/mt7981/Makefile
35 create mode 100644 board/mediatek/mt7981/mt7981_rfb.c
36 create mode 100644 configs/mt7981_emmc_rfb_defconfig
37 create mode 100644 configs/mt7981_rfb_defconfig
38 create mode 100644 configs/mt7981_sd_rfb_defconfig
39 create mode 100644 include/configs/mt7981.h
41 --- a/arch/arm/dts/Makefile
42 +++ b/arch/arm/dts/Makefile
43 @@ -1233,6 +1233,9 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \
44 mt7622-bananapi-bpi-r64.dtb \
45 mt7623n-bananapi-bpi-r2.dtb \
48 + mt7981-emmc-rfb.dtb \
54 +++ b/arch/arm/dts/mt7981-emmc-rfb.dts
56 +// SPDX-License-Identifier: GPL-2.0
58 + * Copyright (c) 2022 MediaTek Inc.
59 + * Author: Sam Shih <sam.shih@mediatek.com>
63 +#include "mt7981.dtsi"
64 +#include <dt-bindings/gpio/gpio.h>
67 + #address-cells = <1>;
69 + model = "mt7981-rfb";
70 + compatible = "mediatek,mt7981", "mediatek,mt7981-rfb";
72 + stdout-path = &uart0;
73 + tick-timer = &timer0;
76 + reg_3p3v: regulator-3p3v {
77 + compatible = "regulator-fixed";
78 + regulator-name = "fixed-3.3V";
79 + regulator-min-microvolt = <3300000>;
80 + regulator-max-microvolt = <3300000>;
82 + regulator-always-on;
91 + pinctrl-names = "default";
92 + pinctrl-0 = <&uart1_pins>;
93 + status = "disabled";
98 + mediatek,gmac-id = <0>;
100 + mediatek,switch = "mt7531";
101 + reset-gpios = <&gpio 39 GPIO_ACTIVE_HIGH>;
110 + spic_pins: spi1-pins-func-1 {
117 + uart1_pins: spi1-pins-func-3 {
120 + groups = "uart1_2";
124 + /* pin15 as pwm0 */
125 + one_pwm_pins: one-pwm-pins {
132 + /* pin15 as pwm0 and pin14 as pwm1 */
133 + two_pwm_pins: two-pwm-pins {
136 + groups = "pwm0_1", "pwm1_0";
140 + /* pin15 as pwm0, pin14 as pwm1, pin7 as pwm2 */
141 + three_pwm_pins: three-pwm-pins {
144 + groups = "pwm0_1", "pwm1_0", "pwm2";
148 + mmc0_pins_default: mmc0default {
150 + function = "flash";
151 + groups = "emmc_45";
154 + pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO",
155 + "SPI0_CS", "SPI0_HOLD", "SPI0_WP",
156 + "SPI1_CLK", "SPI1_MOSI", "SPI1_MISO";
158 + drive-strength = <MTK_DRIVE_4mA>;
159 + bias-pull-up = <MTK_PUPD_SET_R1R0_01>;
163 + drive-strength = <MTK_DRIVE_6mA>;
164 + bias-pull-down = <MTK_PUPD_SET_R1R0_10>;
168 + drive-strength = <MTK_DRIVE_4mA>;
169 + bias-pull-up = <MTK_PUPD_SET_R1R0_01>;
175 + pinctrl-names = "default";
176 + pinctrl-0 = <&two_pwm_pins>;
181 + status = "disabled";
185 + pinctrl-names = "default";
186 + pinctrl-0 = <&mmc0_pins_default>;
188 + max-frequency = <52000000>;
191 + vmmc-supply = <®_3p3v>;
196 +++ b/arch/arm/dts/mt7981-rfb.dts
198 +// SPDX-License-Identifier: GPL-2.0
200 + * Copyright (c) 2022 MediaTek Inc.
201 + * Author: Sam Shih <sam.shih@mediatek.com>
205 +#include "mt7981.dtsi"
206 +#include <dt-bindings/gpio/gpio.h>
209 + #address-cells = <1>;
211 + model = "mt7981-rfb";
212 + compatible = "mediatek,mt7981", "mediatek,mt7981-rfb";
214 + stdout-path = &uart0;
215 + tick-timer = &timer0;
224 + pinctrl-names = "default";
225 + pinctrl-0 = <&uart1_pins>;
226 + status = "disabled";
231 + mediatek,gmac-id = <0>;
232 + phy-mode = "sgmii";
233 + mediatek,switch = "mt7531";
234 + reset-gpios = <&gpio 39 GPIO_ACTIVE_HIGH>;
243 + spi_flash_pins: spi0-pins-func-1 {
245 + function = "flash";
246 + groups = "spi0", "spi0_wp_hold";
250 + pins = "SPI0_CS", "SPI0_HOLD", "SPI0_WP";
251 + drive-strength = <MTK_DRIVE_8mA>;
252 + bias-pull-up = <MTK_PUPD_SET_R1R0_11>;
256 + pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO";
257 + drive-strength = <MTK_DRIVE_8mA>;
258 + bias-pull-down = <MTK_PUPD_SET_R1R0_11>;
262 + spi2_flash_pins: spi2-spi2-pins {
265 + groups = "spi2", "spi2_wp_hold";
269 + pins = "SPI2_CS", "SPI2_HOLD", "SPI2_WP";
270 + drive-strength = <MTK_DRIVE_8mA>;
271 + bias-pull-down = <MTK_PUPD_SET_R1R0_00>;
275 + pins = "SPI2_CLK", "SPI2_MOSI", "SPI2_MISO";
276 + drive-strength = <MTK_DRIVE_8mA>;
277 + bias-pull-down = <MTK_PUPD_SET_R1R0_00>;
281 + spic_pins: spi1-pins-func-1 {
288 + uart1_pins: spi1-pins-func-3 {
291 + groups = "uart1_2";
295 + /* pin15 as pwm0 */
296 + one_pwm_pins: one-pwm-pins {
303 + /* pin15 as pwm0 and pin14 as pwm1 */
304 + two_pwm_pins: two-pwm-pins {
307 + groups = "pwm0_1", "pwm1_0";
311 + /* pin15 as pwm0, pin14 as pwm1, pin7 as pwm2 */
312 + three_pwm_pins: three-pwm-pins {
315 + groups = "pwm0_1", "pwm1_0", "pwm2";
321 + #address-cells = <1>;
323 + pinctrl-names = "default";
324 + pinctrl-0 = <&spi_flash_pins>;
335 + compatible = "spi-nand";
337 + spi-max-frequency = <52000000>;
342 + #address-cells = <1>;
344 + pinctrl-names = "default";
345 + pinctrl-0 = <&spi2_flash_pins>;
356 + compatible = "jedec,spi-nor";
358 + spi-max-frequency = <52000000>;
363 + pinctrl-names = "default";
364 + pinctrl-0 = <&two_pwm_pins>;
369 + status = "disabled";
372 +++ b/arch/arm/dts/mt7981-sd-rfb.dts
374 +// SPDX-License-Identifier: GPL-2.0
376 + * Copyright (c) 2022 MediaTek Inc.
377 + * Author: Sam Shih <sam.shih@mediatek.com>
381 +#include "mt7981.dtsi"
382 +#include <dt-bindings/gpio/gpio.h>
385 + #address-cells = <1>;
387 + model = "mt7981-rfb";
388 + compatible = "mediatek,mt7981", "mediatek,mt7981-sd-rfb";
390 + stdout-path = &uart0;
391 + tick-timer = &timer0;
394 + reg_3p3v: regulator-3p3v {
395 + compatible = "regulator-fixed";
396 + regulator-name = "fixed-3.3V";
397 + regulator-min-microvolt = <3300000>;
398 + regulator-max-microvolt = <3300000>;
400 + regulator-always-on;
409 + pinctrl-names = "default";
410 + pinctrl-0 = <&uart1_pins>;
411 + status = "disabled";
416 + mediatek,gmac-id = <0>;
417 + phy-mode = "sgmii";
418 + mediatek,switch = "mt7531";
419 + reset-gpios = <&gpio 39 GPIO_ACTIVE_HIGH>;
428 + spic_pins: spi1-pins-func-1 {
435 + uart1_pins: spi1-pins-func-3 {
438 + groups = "uart1_2";
442 + /* pin15 as pwm0 */
443 + one_pwm_pins: one-pwm-pins {
450 + /* pin15 as pwm0 and pin14 as pwm1 */
451 + two_pwm_pins: two-pwm-pins {
454 + groups = "pwm0_1", "pwm1_0";
458 + /* pin15 as pwm0, pin14 as pwm1, pin7 as pwm2 */
459 + three_pwm_pins: three-pwm-pins {
462 + groups = "pwm0_1", "pwm1_0", "pwm2";
466 + mmc0_pins_default: mmc0default {
468 + function = "flash";
469 + groups = "emmc_45";
472 + pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO",
473 + "SPI0_CS", "SPI0_HOLD", "SPI0_WP",
474 + "SPI1_CLK", "SPI1_MOSI", "SPI1_MISO";
476 + drive-strength = <MTK_DRIVE_4mA>;
477 + bias-pull-up = <MTK_PUPD_SET_R1R0_01>;
481 + drive-strength = <MTK_DRIVE_6mA>;
482 + bias-pull-down = <MTK_PUPD_SET_R1R0_10>;
486 + drive-strength = <MTK_DRIVE_4mA>;
487 + bias-pull-up = <MTK_PUPD_SET_R1R0_01>;
493 + pinctrl-names = "default";
494 + pinctrl-0 = <&two_pwm_pins>;
499 + status = "disabled";
503 + pinctrl-names = "default";
504 + pinctrl-0 = <&mmc0_pins_default>;
506 + max-frequency = <52000000>;
509 + vmmc-supply = <®_3p3v>;
510 + vqmmc-supply = <®_3p3v>;
514 +++ b/board/mediatek/mt7981/MAINTAINERS
517 +M: Sam Shih <sam.shih@mediatek.com>
519 +F: board/mediatek/mt7981
520 +F: include/configs/mt7981.h
521 +F: configs/mt7981_emmc_rfb_defconfig
522 +F: configs/mt7981_rfb_defconfig
523 +F: configs/mt7981_sd_rfb_defconfig
524 +F: configs/mt7981_spim_nand_rfb_defconfig
525 +F: configs/mt7981_spim_nor_rfb_defconfig
527 +++ b/board/mediatek/mt7981/Makefile
529 +# SPDX-License-Identifier: GPL-2.0
531 +obj-y += mt7981_rfb.o
533 +++ b/board/mediatek/mt7981/mt7981_rfb.c
535 +// SPDX-License-Identifier: GPL-2.0
537 + * Copyright (C) 2022 MediaTek Inc.
538 + * Author: Sam Shih <sam.shih@mediatek.com>
541 +int board_init(void)
546 +++ b/configs/mt7981_emmc_rfb_defconfig
549 +CONFIG_POSITION_INDEPENDENT=y
550 +CONFIG_ARCH_MEDIATEK=y
551 +CONFIG_SYS_TEXT_BASE=0x41e00000
552 +CONFIG_SYS_MALLOC_F_LEN=0x4000
553 +CONFIG_NR_DRAM_BANKS=1
554 +CONFIG_ENV_SIZE=0x80000
555 +CONFIG_ENV_OFFSET=0x300000
556 +CONFIG_DEFAULT_DEVICE_TREE="mt7981-emmc-rfb"
557 +CONFIG_TARGET_MT7981=y
558 +CONFIG_DEBUG_UART_BASE=0x11002000
559 +CONFIG_DEBUG_UART_CLOCK=40000000
560 +CONFIG_SYS_LOAD_ADDR=0x46000000
562 +# CONFIG_AUTOBOOT is not set
563 +CONFIG_DEFAULT_FDT_FILE="mt7981-emmc-rfb"
566 +CONFIG_SYS_PROMPT="MT7981> "
567 +CONFIG_SYS_CBSIZE=512
568 +CONFIG_SYS_PBSIZE=1049
569 +# CONFIG_BOOTM_NETBSD is not set
570 +# CONFIG_BOOTM_PLAN9 is not set
571 +# CONFIG_BOOTM_RTEMS is not set
572 +# CONFIG_BOOTM_VXWORKS is not set
573 +# CONFIG_CMD_ELF is not set
574 +# CONFIG_CMD_UNLZ4 is not set
575 +# CONFIG_CMD_UNZIP is not set
578 +CONFIG_CMD_GPT_RENAME=y
586 +CONFIG_CMD_FS_GENERIC=y
587 +CONFIG_PARTITION_TYPE_GUID=y
588 +CONFIG_ENV_OVERWRITE=y
589 +CONFIG_ENV_IS_IN_MMC=y
590 +CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
591 +CONFIG_NET_RANDOM_ETHADDR=y
595 +CONFIG_MMC_HS200_SUPPORT=y
599 +CONFIG_MEDIATEK_ETH=y
602 +CONFIG_PINCTRL_MT7981=y
603 +CONFIG_POWER_DOMAIN=y
604 +CONFIG_MTK_POWER_DOMAIN=y
605 +CONFIG_DM_REGULATOR=y
606 +CONFIG_DM_REGULATOR_FIXED=y
611 +# CONFIG_EFI_LOADER is not set
613 +++ b/configs/mt7981_rfb_defconfig
616 +CONFIG_POSITION_INDEPENDENT=y
617 +CONFIG_ARCH_MEDIATEK=y
618 +CONFIG_SYS_TEXT_BASE=0x41e00000
619 +CONFIG_SYS_MALLOC_F_LEN=0x4000
620 +CONFIG_NR_DRAM_BANKS=1
621 +CONFIG_DEFAULT_DEVICE_TREE="mt7981-rfb"
622 +CONFIG_TARGET_MT7981=y
623 +CONFIG_DEBUG_UART_BASE=0x11002000
624 +CONFIG_DEBUG_UART_CLOCK=40000000
625 +CONFIG_SYS_LOAD_ADDR=0x46000000
627 +# CONFIG_AUTOBOOT is not set
628 +CONFIG_DEFAULT_FDT_FILE="mt7981-rfb"
631 +CONFIG_SYS_PROMPT="MT7981> "
632 +CONFIG_SYS_CBSIZE=512
633 +CONFIG_SYS_PBSIZE=1049
634 +# CONFIG_BOOTM_NETBSD is not set
635 +# CONFIG_BOOTM_PLAN9 is not set
636 +# CONFIG_BOOTM_RTEMS is not set
637 +# CONFIG_BOOTM_VXWORKS is not set
638 +# CONFIG_CMD_ELF is not set
639 +# CONFIG_CMD_UNLZ4 is not set
640 +# CONFIG_CMD_UNZIP is not set
643 +CONFIG_CMD_SF_TEST=y
646 +CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
647 +CONFIG_NET_RANDOM_ETHADDR=y
651 +CONFIG_HAVE_BLOCK_DEVICE=y
653 +# CONFIG_MMC is not set
656 +CONFIG_MTD_SPI_NAND=y
657 +CONFIG_DM_SPI_FLASH=y
658 +CONFIG_SPI_FLASH_SFDP_SUPPORT=y
659 +CONFIG_SPI_FLASH_EON=y
660 +CONFIG_SPI_FLASH_GIGADEVICE=y
661 +CONFIG_SPI_FLASH_ISSI=y
662 +CONFIG_SPI_FLASH_MACRONIX=y
663 +CONFIG_SPI_FLASH_SPANSION=y
664 +CONFIG_SPI_FLASH_STMICRO=y
665 +CONFIG_SPI_FLASH_WINBOND=y
666 +CONFIG_SPI_FLASH_XMC=y
667 +CONFIG_SPI_FLASH_XTX=y
668 +CONFIG_SPI_FLASH_MTD=y
671 +CONFIG_MEDIATEK_ETH=y
674 +CONFIG_PINCTRL_MT7981=y
675 +CONFIG_POWER_DOMAIN=y
676 +CONFIG_MTK_POWER_DOMAIN=y
683 +# CONFIG_EFI_LOADER is not set
685 +++ b/configs/mt7981_sd_rfb_defconfig
688 +CONFIG_POSITION_INDEPENDENT=y
689 +CONFIG_ARCH_MEDIATEK=y
690 +CONFIG_SYS_TEXT_BASE=0x41e00000
691 +CONFIG_SYS_MALLOC_F_LEN=0x4000
692 +CONFIG_NR_DRAM_BANKS=1
693 +CONFIG_ENV_SIZE=0x80000
694 +CONFIG_ENV_OFFSET=0x300000
695 +CONFIG_DEFAULT_DEVICE_TREE="mt7981-sd-rfb"
696 +CONFIG_TARGET_MT7981=y
697 +CONFIG_DEBUG_UART_BASE=0x11002000
698 +CONFIG_DEBUG_UART_CLOCK=40000000
699 +CONFIG_SYS_LOAD_ADDR=0x46000000
701 +# CONFIG_AUTOBOOT is not set
702 +CONFIG_DEFAULT_FDT_FILE="mt7981-sd-rfb"
705 +CONFIG_SYS_PROMPT="MT7981> "
706 +CONFIG_SYS_CBSIZE=512
707 +CONFIG_SYS_PBSIZE=1049
708 +# CONFIG_BOOTM_NETBSD is not set
709 +# CONFIG_BOOTM_PLAN9 is not set
710 +# CONFIG_BOOTM_RTEMS is not set
711 +# CONFIG_BOOTM_VXWORKS is not set
712 +# CONFIG_CMD_ELF is not set
713 +# CONFIG_CMD_UNLZ4 is not set
714 +# CONFIG_CMD_UNZIP is not set
717 +CONFIG_CMD_GPT_RENAME=y
725 +CONFIG_CMD_FS_GENERIC=y
726 +CONFIG_PARTITION_TYPE_GUID=y
727 +CONFIG_ENV_OVERWRITE=y
728 +CONFIG_ENV_IS_IN_MMC=y
729 +CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
730 +CONFIG_NET_RANDOM_ETHADDR=y
734 +CONFIG_MMC_HS200_SUPPORT=y
738 +CONFIG_MEDIATEK_ETH=y
741 +CONFIG_PINCTRL_MT7981=y
742 +CONFIG_POWER_DOMAIN=y
743 +CONFIG_MTK_POWER_DOMAIN=y
744 +CONFIG_DM_REGULATOR=y
745 +CONFIG_DM_REGULATOR_FIXED=y
750 +# CONFIG_EFI_LOADER is not set
752 +++ b/include/configs/mt7981.h
754 +/* SPDX-License-Identifier: GPL-2.0 */
756 + * Configuration for MediaTek MT7981 SoC
758 + * Copyright (C) 2022 MediaTek Inc.
759 + * Author: Sam Shih <sam.shih@mediatek.com>
765 +#include <linux/sizes.h>
767 +#define CONFIG_SYS_NONCACHED_MEMORY SZ_1M
768 +#define CONFIG_SYS_MMC_ENV_DEV 0
770 +/* Uboot definition */
771 +#define CONFIG_SYS_UBOOT_BASE CONFIG_SYS_TEXT_BASE
774 +#define CONFIG_SYS_UBOOT_START CONFIG_SYS_TEXT_BASE
777 +#define CONFIG_SYS_SDRAM_BASE 0x40000000