[PATCH v5 2/2] board: mediatek: add mt8195 demo board

Macpaul Lin macpaul.lin at mediatek.com
Fri Aug 4 13:04:48 CEST 2023


From: Fabien Parent <fparent at baylibre.com>

Add mt8195-demo board support.
This demo purpose board uses MediaTek's MT8195 SoC.

Signed-off-by: Fabien Parent <fparent at baylibre.com>
Signed-off-by: Amjad Ouled-Ameur <aouledameur at baylibre.com>
Signed-off-by: Macpaul Lin <macpaul.lin at mediatek.com>
---
 MAINTAINERS                         |   1 +
 arch/arm/dts/Makefile               |   1 +
 arch/arm/dts/mt8195-demo.dts        | 122 ++++++++++++++++++++++++++++
 board/mediatek/mt8195/MAINTAINERS   |   6 ++
 board/mediatek/mt8195/Makefile      |   3 +
 board/mediatek/mt8195/README        |  65 +++++++++++++++
 board/mediatek/mt8195/mt8195_demo.c |  38 +++++++++
 configs/mt8195_demo_defconfig       |  99 ++++++++++++++++++++++
 include/configs/mt8195.h            |  46 +++++++++++
 9 files changed, 381 insertions(+)
 create mode 100644 arch/arm/dts/mt8195-demo.dts
 create mode 100644 board/mediatek/mt8195/MAINTAINERS
 create mode 100644 board/mediatek/mt8195/Makefile
 create mode 100644 board/mediatek/mt8195/README
 create mode 100644 board/mediatek/mt8195/mt8195_demo.c
 create mode 100644 configs/mt8195_demo_defconfig
 create mode 100644 include/configs/mt8195.h

Changes for v2 and v3:
 - no change.

Changes for v4:
 - Remove CONFIG_SYS_NS16550 related settings in mt8195.h.

Changes for v5:
 - Fix Copyright year to 2023.
 - Fix build error by adding 'CONFIG_TEXT_BASE' in defconfig.
 - Add README for mt8195-demo board includes toolchain setting
   'CROSS_COMPILE=aarch64-linux-gnu-' 
 - Fix 'CONFIG_EXTRA_ENV_SETTINGS' with 'CFG_EXTRA_ENV_SETTINGS'
   according to checkpatch error.
 - Update dram to 8GB size.
 - dts
  - Add optee and pcsi support in firmware section.
 - mt8195_demo_defconfig
  - enable I2C, DFU, GPT, MBR support
  - enable some USB ethernet adaptors
 - rebase patchset to v2023-10.rc1

diff --git a/MAINTAINERS b/MAINTAINERS
index 4d0f017e7e..454d3615f4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -396,6 +396,7 @@ F:	drivers/watchdog/mtk_wdt.c
 F:	drivers/net/mtk_eth.c
 F:	drivers/net/mtk_eth.h
 F:	drivers/reset/reset-mediatek.c
+F:	include/configs/mt8195.h
 F:	tools/mtk_image.c
 F:	tools/mtk_image.h
 F:	tools/mtk_nand_headers.c
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index e66c32e268..d7104b77bf 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1342,6 +1342,7 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \
 	mt7986a-emmc-rfb.dtb \
 	mt7986b-emmc-rfb.dtb \
 	mt8183-pumpkin.dtb \
+	mt8195-demo.dtb \
 	mt8512-bm1-emmc.dtb \
 	mt8516-pumpkin.dtb \
 	mt8518-ap1-emmc.dtb
diff --git a/arch/arm/dts/mt8195-demo.dts b/arch/arm/dts/mt8195-demo.dts
new file mode 100644
index 0000000000..e4063cd143
--- /dev/null
+++ b/arch/arm/dts/mt8195-demo.dts
@@ -0,0 +1,122 @@
+// SPDX-License-Identifier: GPL-2.0 OR MIT
+/*
+ * Copyright (C) 2023 MediaTek Inc.
+ * Copyright (C) 2023 BayLibre SAS.
+ * Author: Macpaul Lin <macpaul.lin at mediatek.com>
+ * Author: Fabien Parent <fparent at baylibre.com>
+ */
+
+/dts-v1/;
+
+#include <config.h>
+#include "mt8195.dtsi"
+
+/ {
+	model = "MediaTek MT8195 demo board";
+	compatible = "mediatek,mt8195-demo", "mediatek,mt8195";
+
+	memory at 40000000 {
+		/* 8GB */
+		device_type = "memory";
+		reg = <0 0x40000000 2 0x00000000>;
+	};
+
+	firmware: firmware {
+		optee {
+			compatible = "linaro,optee-tz";
+			method = "smc";
+		};
+
+		psci: psci {
+			compatible = "arm,psci-1.0";
+			method = "smc";
+		};
+	};
+
+	reserved-memory {
+		#address-cells = <2>;
+		#size-cells = <2>;
+		ranges;
+
+		/* 2 MiB reserved for ARM Trusted Firmware (BL31) */
+		bl31_secmon_reserved: secmon at 54600000 {
+			no-map;
+			reg = <0 0x54600000 0x0 0x200000>;
+		};
+
+		/* 12 MiB reserved for OP-TEE (BL32)
+		 * +-----------------------+ 0x43e0_0000
+		 * |      SHMEM 2MiB       |
+		 * +-----------------------+ 0x43c0_0000
+		 * |        | TA_RAM  8MiB |
+		 * + TZDRAM +--------------+ 0x4340_0000
+		 * |        | TEE_RAM 2MiB |
+		 * +-----------------------+ 0x4320_0000
+		 */
+		optee_reserved: optee at 43200000 {
+			no-map;
+			reg = <0 0x43200000 0 0x00c00000>;
+		};
+	};
+
+	chosen {
+		stdout-path = &uart0;
+	};
+
+	reg_1p8v: regulator-1p8v {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-1.8V";
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <1800000>;
+		regulator-boot-on;
+		regulator-always-on;
+	};
+
+	reg_3p3v: regulator-3p3v {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-3.3V";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		regulator-boot-on;
+		regulator-always-on;
+	};
+};
+
+&watchdog {
+	status = "okay";
+};
+
+&uart0 {
+	status = "okay";
+};
+
+&mmc0 {
+	bus-width = <4>;
+	max-frequency = <200000000>;
+	cap-mmc-highspeed;
+	mmc-hs200-1_8v;
+	cap-mmc-hw-reset;
+	vmmc-supply = <&reg_3p3v>;
+	vqmmc-supply = <&reg_1p8v>;
+	non-removable;
+	status = "okay";
+};
+
+&usb {
+	status = "okay";
+};
+
+&ssusb {
+	mediatek,force-vbus;
+	maximum-speed = "high-speed";
+	dr_mode = "peripheral";
+	status = "okay";
+};
+
+&xhci0 {
+	status = "okay";
+};
+
+&xhci3 {
+	status = "okay";
+};
diff --git a/board/mediatek/mt8195/MAINTAINERS b/board/mediatek/mt8195/MAINTAINERS
new file mode 100644
index 0000000000..01fa25115d
--- /dev/null
+++ b/board/mediatek/mt8195/MAINTAINERS
@@ -0,0 +1,6 @@
+MT8195 Demo
+M:	Macpaul Lin <macpaul.lin at mediatek.com>
+S:	Maintained
+F:	board/mediatek/mt8195
+F:	include/configs/mt8195.h
+F:	configs/mt8195_demo_defconfig
diff --git a/board/mediatek/mt8195/Makefile b/board/mediatek/mt8195/Makefile
new file mode 100644
index 0000000000..7e94a87aea
--- /dev/null
+++ b/board/mediatek/mt8195/Makefile
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier:	GPL-2.0
+
+obj-y += mt8195_demo.o
diff --git a/board/mediatek/mt8195/README b/board/mediatek/mt8195/README
new file mode 100644
index 0000000000..27ac56e077
--- /dev/null
+++ b/board/mediatek/mt8195/README
@@ -0,0 +1,65 @@
+Introduction
+============
+
+The Genio 1200-Demo (mt8195-demo) board is featuring the MediaTek
+MT8195/MT8395 Family SoC.
+
+Genio 1200-Demo board features:
+	* CPU: ARMv8 64bit Big-Little architecture,
+		* Big: quad-core Cortex-A73
+		* Little: quad-core Cortex-A53
+	* DRAM: 2x 4GB dual-channel
+	* eMMC: onboard eMMC
+	* SD/MMC
+	* GbE (onboard RTL8211F) Gigabit ethernet PHY
+	* PCIE: 2-lane M.2 E-Key
+	* USB:
+		* USB3.0 dual role port
+		* 1x USB3.0 host, 2x USB2.0 host
+	* Display: HDMI/eDP/MIPI
+	* Camera: 3x 4-lane CSI
+	* APU
+
+Here is the step-by-step to boot to U-Boot on Genio 1200-Demo (mt8195-demo)
+board.
+
+Get the Source from Genio IOT Yocto
+===================================
+
+To download the Genio IOT Yocto source code, please follow the instructions
+in [1]. With the full source code, developers can easily build the boot chain,
+which includes components such as TF-A, u-boot, kernel, and the complete
+Genio IOT Yocto image.
+
+Compile the U-Boot
+==================
+
+Linux native build with latest U-Boot.
+
+  > cd u-boot
+  > make CROSS_COMPILE=aarch64-linux-gnu- mt8195_demo_defconfig all
+
+Genio IOT Yocto build with latest U-boot or Genio IOT Yocto's U-boot.
+
+  > DISTRO=rity-demo MACHINE=i1200-demo bitbake u-boot
+
+Genio IOT Yocto build TF-A and package U-boot into bl31 together.
+
+  > DISTRO=rity-demo MACHINE=i1200-demo bitbake trusted-firmware-a
+
+Flash the image
+===============
+
+MediaTek currently support the use of the Genio IOT Yocto toolset with the
+'genio-flash' USB download tool for flashing images. To install 'genio-flash',
+use Python's 'pip' package manager. Then, follow the instructions provided
+in [2] to flash u-boot with the IOT Yocto image.
+
+   > pip install genio-flash
+
+cd into the folder contains Genio IOT Yocto image, then run 'genio-flash'.
+
+   > genio-flash
+
+[1] https://mediatek.gitlab.io/aiot/doc/aiot-dev-guide/release/v22.2/sw/yocto/get-started/build-code.html#genio-1200-demo-board
+[2] https://mediatek.gitlab.io/aiot/doc/aiot-dev-guide/master/sw/yocto/get-started/flash/flash-i1200-demo.html
diff --git a/board/mediatek/mt8195/mt8195_demo.c b/board/mediatek/mt8195/mt8195_demo.c
new file mode 100644
index 0000000000..27e16ad2fe
--- /dev/null
+++ b/board/mediatek/mt8195/mt8195_demo.c
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2023 BayLibre SAS
+ * Author: Fabien Parent <fparent at baylibre.com>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <net.h>
+#include <asm/io.h>
+
+int board_init(void)
+{
+	struct udevice *dev;
+	int ret;
+
+	if (CONFIG_IS_ENABLED(USB_GADGET)) {
+		ret = uclass_get_device(UCLASS_USB_GADGET_GENERIC, 0, &dev);
+		if (ret) {
+			pr_err("%s: Cannot find USB device\n", __func__);
+			return ret;
+		}
+	}
+
+	if (CONFIG_IS_ENABLED(USB_ETHER))
+		usb_ether_init();
+
+	printf("Disabling WDT\n");
+	writel(0, 0x10007000);
+
+	printf("Enabling SCP SRAM\n");
+	for (unsigned int val = 0xFFFFFFFF; val != 0U;) {
+		val = val >> 1;
+		writel(val, 0x1072102C);
+	}
+
+	return 0;
+}
diff --git a/configs/mt8195_demo_defconfig b/configs/mt8195_demo_defconfig
new file mode 100644
index 0000000000..7e6c02a742
--- /dev/null
+++ b/configs/mt8195_demo_defconfig
@@ -0,0 +1,99 @@
+CONFIG_ARM=y
+CONFIG_COUNTER_FREQUENCY=13000000
+CONFIG_POSITION_INDEPENDENT=y
+CONFIG_ARCH_MEDIATEK=y
+CONFIG_TEXT_BASE=0x4c000000
+CONFIG_SYS_MALLOC_LEN=0x500000
+CONFIG_SYS_MALLOC_F_LEN=0x4000
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_ENV_SIZE=0x1000
+CONFIG_ENV_OFFSET=0x0
+CONFIG_DM_GPIO=y
+CONFIG_DEFAULT_DEVICE_TREE="mt8195-demo"
+CONFIG_OF_LIBFDT_OVERLAY=y
+CONFIG_TARGET_MT8195=y
+CONFIG_DEBUG_UART_BASE=0x11001100
+CONFIG_DEBUG_UART_CLOCK=26000000
+CONFIG_ARMV8_CRYPTO=y
+CONFIG_SYS_LOAD_ADDR=0x4c000000
+CONFIG_DEBUG_UART=y
+CONFIG_FIT=y
+CONFIG_FIT_SIGNATURE=y
+# CONFIG_ARCH_FIXUP_FDT_MEMORY is not set
+CONFIG_DISTRO_DEFAULTS=y
+CONFIG_DEFAULT_FDT_FILE="mt8195-demo"
+# CONFIG_DISPLAY_BOARDINFO is not set
+# CONFIG_CMD_CONSOLE is not set
+# CONFIG_CMD_BOOTD is not set
+CONFIG_CMD_BOOTEFI_SELFTEST=y
+# CONFIG_CMD_ELF is not set
+# CONFIG_CMD_GO is not set
+# CONFIG_CMD_IMI is not set
+# CONFIG_CMD_XIMG is not set
+CONFIG_CMD_NVEDIT_EFI=y
+CONFIG_CMD_NVEDIT_INFO=y
+# CONFIG_CMD_CRC32 is not set
+CONFIG_CMD_CLK=y
+CONFIG_CMD_DFU=y
+CONFIG_CMD_DM=y
+CONFIG_CMD_GPT=y
+CONFIG_CMD_GPT_RENAME=y
+CONFIG_CMD_I2C=y
+# CONFIG_CMD_LOADB is not set
+# CONFIG_CMD_LOADS is not set
+CONFIG_CMD_MBR=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_USB_MASS_STORAGE=y
+# CONFIG_CMD_ITEST is not set
+# CONFIG_CMD_BLOCK_CACHE is not set
+CONFIG_CMD_EFIDEBUG=y
+CONFIG_PARTITION_TYPE_GUID=y
+CONFIG_ENV_IS_IN_MMC=y
+CONFIG_SYS_MMC_ENV_PART=2
+CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
+CONFIG_ENV_IMPORT_FDT=y
+CONFIG_DEVRES=y
+CONFIG_CLK=y
+CONFIG_DFU_MMC=y
+CONFIG_SYS_DFU_DATA_BUF_SIZE=0x100000
+CONFIG_SYS_DFU_MAX_FILE_SIZE=0x200000
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_FASTBOOT_BUF_ADDR=0x4d000000
+CONFIG_FASTBOOT_BUF_SIZE=0x8000000
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_MMC_BOOT_SUPPORT=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_MTK=y
+# CONFIG_INPUT is not set
+# CONFIG_MMC_QUIRKS is not set
+CONFIG_MMC_MTK=y
+CONFIG_PHY=y
+CONFIG_PHY_MTK_TPHY=y
+CONFIG_DM_RTC=y
+CONFIG_RTC_EMULATION=y
+CONFIG_BAUDRATE=921600
+CONFIG_DM_SERIAL=y
+CONFIG_DEBUG_UART_ANNOUNCE=y
+CONFIG_MTK_SERIAL=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_PSCI=y
+CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_MTK=y
+CONFIG_USB_MTU3=y
+CONFIG_USB_KEYBOARD=y
+CONFIG_USB_HOST_ETHER=y
+CONFIG_USB_ETHER_ASIX=y
+CONFIG_USB_ETHER_ASIX88179=y
+CONFIG_USB_ETHER_MCS7830=y
+CONFIG_USB_ETHER_RTL8152=y
+CONFIG_USB_ETHER_SMSC95XX=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_VENDOR_NUM=0x0e8d
+CONFIG_USB_GADGET_PRODUCT_NUM=0x201c
+CONFIG_USB_ETHER=y
+CONFIG_WDT=y
+CONFIG_EFI_SET_TIME=y
diff --git a/include/configs/mt8195.h b/include/configs/mt8195.h
new file mode 100644
index 0000000000..7af06da6ea
--- /dev/null
+++ b/include/configs/mt8195.h
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Configuration for MT8195 based boards
+ *
+ * Copyright (C) 2023 MediaTek Inc.
+ * Copyright (C) 2023 BayLibre, SAS
+ * Author: Macpaul Lin <macpaul.lin at mediatek.com>
+ * Author: Fabien Parent <fparent at baylibre.com>
+ */
+
+#ifndef __MT8195_H
+#define __MT8195_H
+
+#include <linux/sizes.h>
+
+/* Environment settings */
+#include <config_distro_bootcmd.h>
+
+#if IS_ENABLED(CONFIG_CMD_MMC)
+#define BOOT_TARGET_MMC(func) func(MMC, mmc, 0)
+#else
+#define BOOT_TARGET_MMC(func)
+#endif
+
+#if IS_ENABLED(CONFIG_CMD_USB)
+#define BOOT_TARGET_USB(func) func(USB, usb, 0)
+#else
+#define BOOT_TARGET_USB(func)
+#endif
+
+#define BOOT_TARGET_DEVICES(func) \
+	BOOT_TARGET_MMC(func) \
+	BOOT_TARGET_USB(func)
+
+#if !defined(CFG_EXTRA_ENV_SETTINGS)
+#define CFG_EXTRA_ENV_SETTINGS \
+	"scriptaddr=0x40000000\0" \
+	"fdt_addr_r=0x44000000\0" \
+	"fdtoverlay_addr_r=0x44c00000\0" \
+	"kernel_addr_r=0x45000000\0" \
+	"ramdisk_addr_r=0x46000000\0" \
+	"fdtfile=" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \
+	BOOTENV
+#endif
+
+#endif
-- 
2.18.0



More information about the U-Boot mailing list