Skip to contentSkip to conversation

Add support for MediaTek MT7621 SoC

PATCH Superseded Weijie Gao 3 participants 20 messages Nov 4, 2021 – Nov 9, 2021

Subsystems (15)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Weijie Gao

author
#0 lore raw

cover Add support for MediaTek MT7621 SoC

This series will add support for MediaTek MT7621 SoC with two reference boards and related drivers.

The MediaTek MT7621 is a network processor integrating a dual-core dual-threaded MIPS 1004Kc processor running at a normal frequency of 880MHz. This chip can be found in many wireless routers.

This series add all basic drivers which are useful in u-boot, like usb, sdxc, ethernet, spi, nand and serial.

Currently this patch series only supports building the ram-bootable image as it needs the preloader from MediaTek SDK.

Thanks,
Weijie

Weijie Gao (14):
mips: mtmips: add support for MediaTek MT7621 SoC
mips: mtmips: add two reference boards for mt7621
clk: mtmips: add clock driver for MediaTek MT7621 SoC
reset: mtmips: add reset controller support for MediaTek MT7621 SoC
pinctrl: mtmips: add support for MediaTek MT7621 SoC
nand: raw: add support for MediaTek MT7621 SoC
usb: xhci-mtk: add support for MediaTek MT7621 SoC
phy: mtk-tphy: add support for MediaTek MT7621 SoC
spi: add support for MediaTek MT7621 SoC
gpio: add support for MediaTek MT7621 SoC
watchdog: add support for MediaTek MT7621 SoC
mmc: mediatek: add support for MediaTek MT7621 SoC
net: mediatek: add support for MediaTek MT7621 SoC
MAINTAINERS: update maintainer for MediaTek MIPS platform

 MAINTAINERS                                   |    5 +
 arch/mips/dts/Makefile                        |    2 +
 arch/mips/dts/mediatek,mt7621-nand-rfb.dts    |   52 +
 arch/mips/dts/mediatek,mt7621-rfb.dts         |   68 +
 arch/mips/dts/mt7621.dtsi                     |  372 ++++++
 arch/mips/mach-mtmips/Kconfig                 |   29 +-
 arch/mips/mach-mtmips/Makefile                |    5 +
 arch/mips/mach-mtmips/cpu.c                   |    4 +
 arch/mips/mach-mtmips/mt7621/Kconfig          |   43 +
 arch/mips/mach-mtmips/mt7621/Makefile         |    5 +
 arch/mips/mach-mtmips/mt7621/compat.c         |   21 +
 arch/mips/mach-mtmips/mt7621/init.c           |  156 +++
 arch/mips/mach-mtmips/mt7621/mt7621.h         |  204 +++
 arch/mips/mach-mtmips/mt7621/serial.c         |   23 +
 board/mediatek/mt7621/MAINTAINERS             |    8 +
 board/mediatek/mt7621/Makefile                |    3 +
 board/mediatek/mt7621/board.c                 |    6 +
 configs/mt7621_nand_rfb_ramboot_defconfig     |   71 +
 configs/mt7621_rfb_ramboot_defconfig          |   74 +
 drivers/clk/mtmips/Makefile                   |    1 +
 drivers/clk/mtmips/clk-mt7621.c               |  260 ++++
 drivers/gpio/Kconfig                          |    2 +-
 drivers/mmc/mtk-sd.c                          |   13 +
 drivers/mtd/nand/raw/Kconfig                  |   11 +
 drivers/mtd/nand/raw/Makefile                 |    1 +
 drivers/mtd/nand/raw/mt7621_nand.c            | 1189 +++++++++++++++++
 drivers/net/mtk_eth.c                         |   27 +-
 drivers/net/mtk_eth.h                         |    8 +
 drivers/phy/Kconfig                           |    2 +-
 drivers/pinctrl/mtmips/Kconfig                |    9 +
 drivers/pinctrl/mtmips/Makefile               |    1 +
 drivers/pinctrl/mtmips/pinctrl-mt7621.c       |  307 +++++
 .../pinctrl/mtmips/pinctrl-mtmips-common.c    |    4 +-
 .../pinctrl/mtmips/pinctrl-mtmips-common.h    |   12 +
 drivers/spi/Kconfig                           |    2 +-
 drivers/usb/host/Kconfig                      |    2 +-
 drivers/watchdog/Kconfig                      |    2 +-
 include/configs/mt7621.h                      |   41 +
 include/dt-bindings/clock/mt7621-clk.h        |   42 +
 include/dt-bindings/reset/mt7621-reset.h      |   38 +
 40 files changed, 3108 insertions(+), 17 deletions(-)
 create mode 100644 arch/mips/dts/mediatek,mt7621-nand-rfb.dts
 create mode 100644 arch/mips/dts/mediatek,mt7621-rfb.dts
 create mode 100644 arch/mips/dts/mt7621.dtsi
 create mode 100644 arch/mips/mach-mtmips/mt7621/Kconfig
 create mode 100644 arch/mips/mach-mtmips/mt7621/Makefile
 create mode 100644 arch/mips/mach-mtmips/mt7621/compat.c
 create mode 100644 arch/mips/mach-mtmips/mt7621/init.c
 create mode 100644 arch/mips/mach-mtmips/mt7621/mt7621.h
 create mode 100644 arch/mips/mach-mtmips/mt7621/serial.c
 create mode 100644 board/mediatek/mt7621/MAINTAINERS
 create mode 100644 board/mediatek/mt7621/Makefile
 create mode 100644 board/mediatek/mt7621/board.c
 create mode 100644 configs/mt7621_nand_rfb_ramboot_defconfig
 create mode 100644 configs/mt7621_rfb_ramboot_defconfig
 create mode 100644 drivers/clk/mtmips/clk-mt7621.c
 create mode 100644 drivers/mtd/nand/raw/mt7621_nand.c
 create mode 100644 drivers/pinctrl/mtmips/pinctrl-mt7621.c
 create mode 100644 include/configs/mt7621.h
 create mode 100644 include/dt-bindings/clock/mt7621-clk.h
 create mode 100644 include/dt-bindings/reset/mt7621-reset.h
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/14 mips: mtmips: add support for MediaTek MT7621 SoC

This patch adds support for MediaTek MT7621 SoC.
All files are dedicated for u-boot.

Currently only ramboot is supported.
The default build target is u-boot-lzma.img.
This file can be booted using bootm command, or be used as a payload of the SDK preloader of MT7621.

The specification of this chip:
https://www.mediatek.com/products/homenetworking/mt7621

---
 arch/mips/dts/mt7621.dtsi             | 372 ++++++++++++++++++++++++++
 arch/mips/mach-mtmips/Kconfig         |  29 +-
 arch/mips/mach-mtmips/Makefile        |   5 +
 arch/mips/mach-mtmips/cpu.c           |   4 +
 arch/mips/mach-mtmips/mt7621/Kconfig  |  23 ++
 arch/mips/mach-mtmips/mt7621/Makefile |   5 +
 arch/mips/mach-mtmips/mt7621/compat.c |  21 ++
 arch/mips/mach-mtmips/mt7621/init.c   | 156 +++++++++++
 arch/mips/mach-mtmips/mt7621/mt7621.h | 204 ++++++++++++++
 arch/mips/mach-mtmips/mt7621/serial.c |  23 ++
 include/configs/mt7621.h              |  41 +++
 11 files changed, 879 insertions(+), 4 deletions(-)
 create mode 100644 arch/mips/dts/mt7621.dtsi
 create mode 100644 arch/mips/mach-mtmips/mt7621/Kconfig
 create mode 100644 arch/mips/mach-mtmips/mt7621/Makefile
 create mode 100644 arch/mips/mach-mtmips/mt7621/compat.c
 create mode 100644 arch/mips/mach-mtmips/mt7621/init.c
 create mode 100644 arch/mips/mach-mtmips/mt7621/mt7621.h
 create mode 100644 arch/mips/mach-mtmips/mt7621/serial.c
 create mode 100644 include/configs/mt7621.h
arch/mips/dts/mt7621.dtsi new file +372 -0
new file mode 100644
index 0000000000..c09350b370
@@ -0,0 +1,372 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 MediaTek Inc. All rights reserved.
+ *
+ * Author: Weijie Gao <[email protected]>
+ */
+
+#include <dt-bindings/clock/mt7621-clk.h>
+#include <dt-bindings/reset/mt7621-reset.h>
+#include <dt-bindings/phy/phy.h>
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+	compatible = "mediatek,mt7621-soc";
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cpu@0 {
+			device_type = "cpu";
+			compatible = "mips,mips1004Kc";
+			reg = <0>;
+		};
+
+		cpu@1 {
+			device_type = "cpu";
+			compatible = "mips,mips1004Kc";
+			reg = <0>;
+		};
+	};
+
+	clk48m: clk48m@0 {
+		compatible = "fixed-clock";
+
+		clock-frequency = <48000000>;
+
+		#clock-cells = <0>;
+	};
+
+	clk50m: clk50m@0 {
+		compatible = "fixed-clock";
+
+		clock-frequency = <50000000>;
+
+		#clock-cells = <0>;
+	};
+
+	sysc: sysc@1e000000 {
+		compatible = "mediatek,mt7621-sysc", "syscon";
+		reg = <0x1e000000 0x100>;
+	};
+
+	clkctrl: clkctrl@1e000030 {
+		compatible = "mediatek,mt7621-clk";
+		mediatek,sysc = <&sysc>;
+		mediatek,memc = <&memc>;
+
+		#clock-cells = <1>;
+		u-boot,dm-pre-reloc;
+	};
+
+	rstctrl: rstctrl@1e000034 {
+		compatible = "mediatek,mtmips-reset";
+		reg = <0x1e000034 0x4>;
+		#reset-cells = <1>;
+	};
+
+	reboot: resetctl-reboot {
+		compatible = "resetctl-reboot";
+
+		resets = <&rstctrl RST_SYS>;
+		reset-names = "sysreset";
+	};
+
+	memc: memc@1e005000 {
+		compatible = "mediatek,mt7621-memc", "syscon";
+		reg = <0x1e005000 0x1000>;
+	};
+
+	pinctrl: pinctrl@1e000060 {
+		compatible = "mediatek,mt7621-pinctrl";
+		reg = <0x1e000048 0x30>;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&state_default>;
+
+		state_default: pin_state {
+			uart1 {
+				groups = "uart1";
+				function = "uart";
+			};
+
+			gpios {
+				groups = "i2c", "uart3", "pcie reset";
+				function = "gpio";
+			};
+
+			jtag {
+				groups = "jtag";
+				function = "jtag";
+			};
+
+			wdt {
+				groups = "wdt";
+				function = "wdt rst";
+			};
+		};
+
+		uart1_pins: uart1_pins {
+			groups = "uart1";
+			function = "uart";
+		};
+
+		uart2_pins: uart2_pins {
+			groups = "uart2";
+			function = "uart";
+		};
+
+		uart3_pins: uart3_pins {
+			groups = "uart3";
+			function = "uart";
+		};
+
+		sdxc_pins: sdxc_pins {
+			groups = "sdxc";
+			function = "sdxc";
+		};
+
+		spi_pins: spi_pins {
+			groups = "spi";
+			function = "spi";
+		};
+
+		eth_pins: eth_pins {
+			mdio_pins {
+				groups = "mdio";
+				function = "mdio";
+			};
+
+			rgmii1_pins {
+				groups = "rgmii1";
+				function = "rgmii";
+			};
+
+			esw_pins {
+				groups = "esw int";
+				function = "esw int";
+			};
+
+			mdio_pconf {
+				groups = "mdio";
+				drive-strength = <2>;
+			};
+		};
+	};
+
+	watchdog: watchdog@1e000100 {
+		compatible = "mediatek,mt7621-wdt";
+		reg = <0x1e000100 0x40>;
+
+		resets = <&rstctrl RST_TIMER>;
+		reset-names = "wdt";
+
+		status = "disabled";
+	};
+
+	gpio: gpio@1e000600 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		compatible = "mtk,mt7621-gpio";
+		reg = <0x1e000600 0x100>;
+
+		resets = <&rstctrl RST_PIO>;
+		reset-names = "pio";
+
+		gpio0: bank@0 {
+			reg = <0>;
+			compatible = "mtk,mt7621-gpio-bank";
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpio1: bank@1 {
+			reg = <1>;
+			compatible = "mtk,mt7621-gpio-bank";
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpio2: bank@2 {
+			reg = <2>;
+			compatible = "mtk,mt7621-gpio-bank";
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+	};
+
+	spi: spi@1e000b00 {
+		compatible = "ralink,mt7621-spi";
+		reg = <0x1e000b00 0x40>;
+
+		status = "disabled";
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&spi_pins>;
+
+		resets = <&rstctrl RST_SPI>;
+		reset-names = "spi";
+
+		clocks = <&clkctrl CLK_SPI>;
+
+		#address-cells = <1>;
+		#size-cells = <0>;
+	};
+
+	uart0: uart1@1e000c00 {
+		compatible = "mediatek,hsuart", "ns16550a";
+		reg = <0x1e000c00 0x100>;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&uart1_pins>;
+
+		clocks = <&clkctrl CLK_UART1>;
+
+		resets = <&rstctrl RST_UART1>;
+
+		reg-shift = <2>;
+	};
+
+	uart1: uart2@1e000d00 {
+		compatible = "mediatek,hsuart", "ns16550a";
+		reg = <0x1e000d00 0x100>;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&uart2_pins>;
+
+		clocks = <&clkctrl CLK_UART2>;
+
+		resets = <&rstctrl RST_UART2>;
+
+		reg-shift = <2>;
+
+		status = "disabled";
+	};
+
+	uart2: uart3@1e000e00 {
+		compatible = "mediatek,hsuart", "ns16550a";
+		reg = <0x1e000e00 0x100>;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&uart3_pins>;
+
+		clocks = <&clkctrl CLK_UART3>;
+
+		resets = <&rstctrl RST_UART3>;
+
+		reg-shift = <2>;
+
+		status = "disabled";
+	};
+
+	eth: eth@1e100000 {
+		compatible = "mediatek,mt7621-eth";
+		reg = <0x1e100000 0x20000>;
+		mediatek,ethsys = <&sysc>;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&eth_pins>;
+
+		resets = <&rstctrl RST_FE>, <&rstctrl RST_GMAC>, <&rstctrl RST_MCM>;
+		reset-names = "fe", "gmac", "mcm";
+
+		clocks = <&clkctrl CLK_GMAC>,
+			 <&clkctrl CLK_FE>;
+		clock-names = "gmac", "fe";
+
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		mediatek,gmac-id = <0>;
+		phy-mode = "rgmii";
+		mediatek,switch = "mt7530";
+		mediatek,mcm;
+
+		fixed-link {
+			speed = <1000>;
+			full-duplex;
+		};
+	};
+
+	mmc: mmc@1e130000 {
+		compatible = "mediatek,mt7621-mmc";
+		reg = <0x1e130000 0x4000>;
+
+		status = "disabled";
+
+		bus-width = <4>;
+		builtin-cd = <1>;
+		r_smpl = <1>;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&sdxc_pins>;
+
+		clocks = <&clk50m>, <&clkctrl CLK_SDXC>;
+		clock-names = "source", "hclk";
+
+		resets = <&rstctrl RST_SDXC>;
+	};
+
+	ssusb: usb@1e1c0000 {
+		compatible = "mediatek,mt7621-xhci", "mediatek,mtk-xhci";
+		reg = <0x1e1c0000 0x1000>, <0x1e1d0700 0x100>;
+		reg-names = "mac", "ippc";
+
+		/* power-domains = <&scpsys MT7629_POWER_DOMAIN_HIF1>; */
+
+		clocks = <&clk48m>, <&clk48m>;
+		clock-names = "sys_ck", "ref_ck";
+
+		phys = <&u2port0 PHY_TYPE_USB2>,
+		       <&u3port0 PHY_TYPE_USB3>,
+		       <&u2port1 PHY_TYPE_USB2>;
+
+		status = "disabled";
+	};
+
+	u3phy: usb-phy@1e1d0000 {
+		compatible = "mediatek,mt7621-u3phy",
+			     "mediatek,generic-tphy-v1";
+		reg = <0x1e1d0000 0x700>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+		status = "disabled";
+
+		u2port0: usb-phy@1e1d0800 {
+			reg = <0x1e1d0800 0x0100>;
+			#phy-cells = <1>;
+			clocks = <&clk48m>;
+			clock-names = "ref";
+		};
+
+		u3port0: usb-phy@1e1d0900 {
+			reg = <0x1e1d0900 0x0100>;
+			#phy-cells = <1>;
+		};
+
+		u2port1: usb-phy@1e1d1000 {
+			reg = <0x1e1d1000 0x0100>;
+			#phy-cells = <1>;
+			clocks = <&clk48m>;
+			clock-names = "ref";
+		};
+	};
+
+	i2c: i2c@1e000900 {
+		compatible = "i2c-gpio";
+
+		status = "disabled";
+
+		i2c-gpio,delay-us = <3>;
+
+		gpios = <&gpio0 3 1>, /* PIN3 as SDA */
+			<&gpio0 4 1>; /* PIN4 as CLK */
+
+		#address-cells = <1>;
+		#size-cells = <0>;
+	};
+};
arch/mips/mach-mtmips/Kconfig +25 -4
index 151b004603..9b30535411 100644
@@ -9,6 +9,7 @@ config SYS_MALLOC_F_LEN
 
 config SYS_SOC
 	default "mt7620" if SOC_MT7620
+	default "mt7621" if SOC_MT7621
 	default "mt7628" if SOC_MT7628
 
 config SYS_DCACHE_SIZE
@@ -18,22 +19,28 @@ config SYS_DCACHE_LINE_SIZE
 	default 32
 
 config SYS_ICACHE_SIZE
-	default 65536
+	default 65536 if SOC_MT7620 || SOC_MT7628
+	default 32768 if SOC_MT7621
 
 config SYS_ICACHE_LINE_SIZE
 	default 32
 
 config SYS_TEXT_BASE
-	default 0x9c000000 if !SPL
-	default 0x80200000 if SPL
+	default 0x9c000000 if !SPL && !SOC_MT7621
+	default 0x80200000 if SPL || SOC_MT7621
 
 config SPL_TEXT_BASE
-	default 0x9c000000
+	default 0x9c000000 if !SOC_MT7621
+	default 0x80100000 if SOC_MT7621
+
+config TPL_TEXT_BASE
+	default 0xbfc00000 if SOC_MT7621
 
 config SPL_PAYLOAD
 	default "u-boot-lzma.img" if SPL_LZMA
 
 config BUILD_TARGET
+	default "u-boot-lzma.img" if SOC_MT7621 # Only ramboot is supported now
 	default "u-boot-with-spl.bin" if SPL
 	default "u-boot.bin"
 
@@ -55,6 +62,19 @@ config SOC_MT7620
 	help
 	  This supports MediaTek MT7620.
 
+config SOC_MT7621
+	bool "MT7621"
+	select MIPS_CM
+	select MIPS_L2_CACHE
+	select SYS_CACHE_SHIFT_5
+	select SYS_MIPS_CACHE_INIT_RAM_LOAD
+	select PINCTRL_MT7621
+	select MTK_SERIAL
+	select REGMAP
+	select SYSCON
+	help
+	  This supports MediaTek MT7621.
+
 config SOC_MT7628
 	bool "MT7628"
 	select SYS_CACHE_SHIFT_5
@@ -80,6 +100,7 @@ config SOC_MT7628
 endchoice
 
 source "arch/mips/mach-mtmips/mt7620/Kconfig"
+source "arch/mips/mach-mtmips/mt7621/Kconfig"
 source "arch/mips/mach-mtmips/mt7628/Kconfig"
 
 endmenu
arch/mips/mach-mtmips/Makefile +5 -0
index 4909b47ef2..9ab882dee0 100644
@@ -1,9 +1,14 @@
 # SPDX-License-Identifier: GPL-2.0+
 
 obj-y += cpu.o
+
+ifneq ($(CONFIG_SOC_MT7621),y)
 obj-y += ddr_init.o
 obj-y += ddr_cal.o
+endif
+
 obj-$(CONFIG_SPL_BUILD) += spl.o
 
 obj-$(CONFIG_SOC_MT7620) += mt7620/
+obj-$(CONFIG_SOC_MT7621) += mt7621/
 obj-$(CONFIG_SOC_MT7628) += mt7628/
arch/mips/mach-mtmips/cpu.c +4 -0
index a4b5cff61d..6ca5655d46 100644
@@ -16,7 +16,11 @@ DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
 {
+#ifdef CONFIG_SOC_MT7621
+	gd->ram_size = get_ram_size((void *)KSEG1, SZ_512M);
+#else
 	gd->ram_size = get_ram_size((void *)KSEG1, SZ_256M);
+#endif
 
 	return 0;
 }
arch/mips/mach-mtmips/mt7621/Kconfig new file +23 -0
new file mode 100644
index 0000000000..6948bee31b
@@ -0,0 +1,23 @@
+
+if SOC_MT7621
+
+config DEBUG_UART_BOARD_INIT
+	default y
+
+choice
+	prompt "Board select"
+
+endchoice
+
+config SYS_CONFIG_NAME
+	string "Board configuration name"
+	default "mt7621" if  BOARD_MT7621_RFB || BOARD_MT7621_NAND_RFB
+
+config SYS_BOARD
+	string "Board name"
+	default "mt7621" if  BOARD_MT7621_RFB || BOARD_MT7621_NAND_RFB
+
+config SYS_VENDOR
+	default "mediatek" if BOARD_MT7621_RFB || BOARD_MT7621_NAND_RFB
+
+endif
arch/mips/mach-mtmips/mt7621/Makefile new file +5 -0
new file mode 100644
index 0000000000..adb48ffe37
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-y += init.o
+obj-y += serial.o
+obj-y += compat.o
arch/mips/mach-mtmips/mt7621/compat.c new file +21 -0
new file mode 100644
index 0000000000..ae2dd263f7
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 MediaTek Inc. All rights reserved.
+ *
+ * Author:  Weijie Gao <[email protected]>
+ */
+
+#include <malloc.h>
+#include <asm/io.h>
+#include <asm/addrspace.h>
+
+/* This is used for the mtk-eth driver */
+phys_addr_t noncached_alloc(size_t size, size_t align)
+{
+	void *ptr = memalign(align, ALIGN(size, align));
+
+	if (!ptr)
+		return 0;
+
+	return KSEG1ADDR((ulong)ptr);
+}
arch/mips/mach-mtmips/mt7621/init.c new file +156 -0

156 lines not on this page · raw message

arch/mips/mach-mtmips/mt7621/mt7621.h new file +204 -0

204 lines not on this page · raw message

arch/mips/mach-mtmips/mt7621/serial.c new file +23 -0
new file mode 100644
index 0000000000..393188abce
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 MediaTek Inc.
+ *
+ * Author:  Weijie Gao <[email protected]>
+ */
+
+#include <asm/io.h>
+#include <asm/addrspace.h>
+#include "mt7621.h"
+
+void board_debug_uart_init(void)
+{
+	void __iomem *base = ioremap_nocache(SYSCTL_BASE, SYSCTL_SIZE);
+
+#if CONFIG_DEBUG_UART_BASE == 0xbe000c00 /* KSEG1ADDR(UART1_BASE) */
+	clrbits_32(base + SYSCTL_GPIOMODE_REG, UART1_MODE);
+#elif CONFIG_DEBUG_UART_BASE == 0xbe000d00 /* KSEG1ADDR(UART2_BASE) */
+	clrbits_32(base + SYSCTL_GPIOMODE_REG, UART2_MODE_M);
+#elif CONFIG_DEBUG_UART_BASE == 0xbe000e00 /* KSEG1ADDR(UART3_BASE) */
+	clrbits_32(base + SYSCTL_GPIOMODE_REG, UART3_MODE_M);
+#endif
+}
include/configs/mt7621.h new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#4 lore raw

PATCH 2/14 mips: mtmips: add two reference boards for mt7621

In reply to Weijie Gao

The mt7621_rfb board supports integrated giga PHYs plus one external giga PHYs. It also has up to 512MiB DDR3, 16MB SPI-NOR, 3 mini PCI-e x1 slots, SDXC and USB.

The mt7621_nand_rfb board is almost the same as mt7621_rfb board, but it uses NAND flash and SDXC is not available.

---
 arch/mips/dts/Makefile                     |  2 +
 arch/mips/dts/mediatek,mt7621-nand-rfb.dts | 52 +++++++++++++++
 arch/mips/dts/mediatek,mt7621-rfb.dts      | 68 ++++++++++++++++++++
 arch/mips/mach-mtmips/mt7621/Kconfig       | 20 ++++++
 board/mediatek/mt7621/MAINTAINERS          |  8 +++
 board/mediatek/mt7621/Makefile             |  3 +
 board/mediatek/mt7621/board.c              |  6 ++
 configs/mt7621_nand_rfb_ramboot_defconfig  | 71 +++++++++++++++++++++
 configs/mt7621_rfb_ramboot_defconfig       | 74 ++++++++++++++++++++++
 9 files changed, 304 insertions(+)
 create mode 100644 arch/mips/dts/mediatek,mt7621-nand-rfb.dts
 create mode 100644 arch/mips/dts/mediatek,mt7621-rfb.dts
 create mode 100644 board/mediatek/mt7621/MAINTAINERS
 create mode 100644 board/mediatek/mt7621/Makefile
 create mode 100644 board/mediatek/mt7621/board.c
 create mode 100644 configs/mt7621_nand_rfb_ramboot_defconfig
 create mode 100644 configs/mt7621_rfb_ramboot_defconfig
arch/mips/dts/Makefile +2 -0
index 215283cfa0..1ef5a28e93 100644
@@ -16,6 +16,8 @@ dtb-$(CONFIG_BOARD_COMTREND_WAP5813N) += comtrend,wap-5813n.dtb
 dtb-$(CONFIG_BOARD_HUAWEI_HG556A) += huawei,hg556a.dtb
 dtb-$(CONFIG_BOARD_MT7620_RFB) += mediatek,mt7620-rfb.dtb
 dtb-$(CONFIG_BOARD_MT7620_MT7530_RFB) += mediatek,mt7620-mt7530-rfb.dtb
+dtb-$(CONFIG_BOARD_MT7621_RFB) += mediatek,mt7621-rfb.dtb
+dtb-$(CONFIG_BOARD_MT7621_NAND_RFB) += mediatek,mt7621-nand-rfb.dtb
 dtb-$(CONFIG_BOARD_MT7628_RFB) += mediatek,mt7628-rfb.dtb
 dtb-$(CONFIG_BOARD_GARDENA_SMART_GATEWAY_MT7688) += gardena-smart-gateway-mt7688.dtb
 dtb-$(CONFIG_BOARD_LINKIT_SMART_7688) += linkit-smart-7688.dtb
arch/mips/dts/mediatek,mt7621-nand-rfb.dts new file +52 -0

52 lines not on this page · raw message

arch/mips/dts/mediatek,mt7621-rfb.dts new file +68 -0

68 lines not on this page · raw message

arch/mips/mach-mtmips/mt7621/Kconfig +20 -0
index 6948bee31b..add1f4154b 100644
@@ -7,6 +7,26 @@ config DEBUG_UART_BOARD_INIT
 choice
 	prompt "Board select"
 
+config BOARD_MT7621_RFB
+	bool "MediaTek MT7621 RFB (SPI-NOR)"
+	help
+	  The reference design of MT7621A (WS3010) booting from SPI-NOR flash.
+	  The board can be configured with DDR2 (64MiB~256MiB) or DDR3
+	  (128MiB~512MiB). The board has 16 MiB SPI-NOR flash, built-in MT7530
+	  GbE switch, 1 UART, 1 USB 2.0 host, 1 USB 3.0 host, 1 SDXC, 3 PCIe
+	  sockets, 1 RGMII to external GbE PHY, 2 audio jacks (in/out),
+	  JTAG pins and expansion GPIO pins.
+
+config BOARD_MT7621_NAND_RFB
+	bool "MediaTek MT7621 RFB (NAND)"
+	help
+	  The reference design of MT7621A (WS3010) booting from NAND flash.
+	  The board can be configured with DDR2 (64MiB~256MiB) or DDR3
+	  (128MiB~512MiB). The board has 128 MiB parallel NAND flash, built-in
+	  MT7530 GbE switch, 1 UART, 1 USB 2.0 host, 1 USB 3.0 host, 3 PCIe
+	  sockets, 1 RGMII to external GbE PHY, 2 audio jacks (in/out),
+	  JTAG pins and expansion GPIO pins.
+
 endchoice
 
 config SYS_CONFIG_NAME
board/mediatek/mt7621/MAINTAINERS new file +8 -0
new file mode 100644
index 0000000000..7324353e0b
@@ -0,0 +1,8 @@
+MT7621_RFB BOARD
+M:	Weijie Gao <[email protected]>
+S:	Maintained
+F:	board/mediatek/mt7621
+F:	configs/mt7621_rfb_ramboot_defconfig
+F:	configs/mt7621_nand_rfb_ramboot_defconfig
+F:	arch/mips/dts/mediatek,mt7621-rfb.dts
+F:	arch/mips/dts/mediatek,mt7621-nand-rfb.dts
board/mediatek/mt7621/Makefile new file +3 -0
new file mode 100644
index 0000000000..db129c5aba
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-y += board.o
board/mediatek/mt7621/board.c new file +6 -0
new file mode 100644
index 0000000000..119b8fc9e5
@@ -0,0 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 MediaTek Inc. All Rights Reserved.
+ *
+ * Author: Weijie Gao <[email protected]>
+ */
configs/mt7621_nand_rfb_ramboot_defconfig new file +71 -0

71 lines not on this page · raw message

configs/mt7621_rfb_ramboot_defconfig new file +74 -0

74 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#6 lore raw

PATCH 3/14 clk: mtmips: add clock driver for MediaTek MT7621 SoC

In reply to Weijie Gao

This patch adds a clock driver for MediaTek MT7621 SoC.
This driver provides clock gate control as well as getting clock frequency for CPU/SYS/XTAL and some peripherals.

---
 drivers/clk/mtmips/Makefile            |   1 +
 drivers/clk/mtmips/clk-mt7621.c        | 260 +++++++++++++++++++++++++
 include/dt-bindings/clock/mt7621-clk.h |  42 ++++
 3 files changed, 303 insertions(+)
 create mode 100644 drivers/clk/mtmips/clk-mt7621.c
 create mode 100644 include/dt-bindings/clock/mt7621-clk.h
drivers/clk/mtmips/Makefile +1 -0
index 732e7f2545..ee8b5afe87 100644
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
 
 obj-$(CONFIG_SOC_MT7620) += clk-mt7620.o
+obj-$(CONFIG_SOC_MT7621) += clk-mt7621.o
 obj-$(CONFIG_SOC_MT7628) += clk-mt7628.o
drivers/clk/mtmips/clk-mt7621.c new file +260 -0

260 lines not on this page · raw message

include/dt-bindings/clock/mt7621-clk.h new file +42 -0

42 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#7 lore raw

PATCH 4/14 reset: mtmips: add reset controller support for MediaTek MT7621 SoC

In reply to Weijie Gao

This patch adds reset controller bits definition header file for MediaTek MT7621 SoC

---
 include/dt-bindings/reset/mt7621-reset.h | 38 ++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 include/dt-bindings/reset/mt7621-reset.h
include/dt-bindings/reset/mt7621-reset.h new file +38 -0
new file mode 100644
index 0000000000..e129c531fc
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2021 MediaTek Inc. All rights reserved.
+ *
+ * Author:  Weijie Gao <[email protected]>
+ */
+
+#ifndef _DT_BINDINGS_MT7621_RESET_H_
+#define _DT_BINDINGS_MT7621_RESET_H_
+
+#define RST_PPE			31
+#define RST_SDXC		30
+#define RST_CRYPTO		29
+#define RST_AUX_STCK		28
+#define RST_PCIE2		26
+#define RST_PCIE1		25
+#define RST_PCIE0		24
+#define RST_GMAC		23
+#define RST_UART3		21
+#define RST_UART2		20
+#define RST_UART1		19
+#define RST_SPI			18
+#define RST_I2S			17
+#define RST_I2C			16
+#define RST_NFI			15
+#define RST_GDMA		14
+#define RST_PIO			13
+#define RST_PCM			11
+#define RST_MC			10
+#define RST_INTC		9
+#define RST_TIMER		8
+#define RST_SPDIFTX		7
+#define RST_FE			6
+#define RST_HSDMA		5
+#define RST_MCM			2
+#define RST_SYS			0
+
+#endif /* _DT_BINDINGS_MT7621_RESET_H_ */
Signature · 1 line
2.17.1
author
#8 lore raw

PATCH 5/14 pinctrl: mtmips: add support for MediaTek MT7621 SoC

In reply to Weijie Gao

This patch adds pinctrl support for MediaTek MT7621 SoC. The MT7621 SoC supports pinconf, but it is not the same as mt7628.

---
 drivers/pinctrl/mtmips/Kconfig                |   9 +
 drivers/pinctrl/mtmips/Makefile               |   1 +
 drivers/pinctrl/mtmips/pinctrl-mt7621.c       | 307 ++++++++++++++++++
 .../pinctrl/mtmips/pinctrl-mtmips-common.c    |   4 +-
 .../pinctrl/mtmips/pinctrl-mtmips-common.h    |  12 +
 5 files changed, 331 insertions(+), 2 deletions(-)
 create mode 100644 drivers/pinctrl/mtmips/pinctrl-mt7621.c
drivers/pinctrl/mtmips/Kconfig +9 -0
index 844d5b743f..456f3ea25d 100644
@@ -12,6 +12,15 @@ config PINCTRL_MT7620
 	  The driver is controlled by a device tree node which contains
 	  the pin mux functions for each available pin groups.
 
+config PINCTRL_MT7621
+	bool "MediaTek MT7621 pin control driver"
+	select PINCTRL_MTMIPS
+	depends on SOC_MT7621 && PINCTRL_GENERIC
+	help
+	  Support pin multiplexing control on MediaTek MT7621.
+	  The driver is controlled by a device tree node which contains
+	  the pin mux functions for each available pin groups.
+
 config PINCTRL_MT7628
 	bool "MediaTek MT7628 pin control driver"
 	select PINCTRL_MTMIPS
drivers/pinctrl/mtmips/Makefile +1 -0
index ba945a89a7..8fece4f5fa 100644
@@ -5,4 +5,5 @@ obj-$(CONFIG_PINCTRL_MTMIPS) += pinctrl-mtmips-common.o
 
 # SoC Drivers
 obj-$(CONFIG_PINCTRL_MT7620) += pinctrl-mt7620.o
+obj-$(CONFIG_PINCTRL_MT7621) += pinctrl-mt7621.o
 obj-$(CONFIG_PINCTRL_MT7628) += pinctrl-mt7628.o
drivers/pinctrl/mtmips/pinctrl-mt7621.c new file +307 -0

307 lines not on this page · raw message

drivers/pinctrl/mtmips/pinctrl-mtmips-common.c +2 -2
index e361916eb2..869b781068 100644
@@ -13,8 +13,8 @@
 
 #include "pinctrl-mtmips-common.h"
 
-static void mtmips_pinctrl_reg_set(struct mtmips_pinctrl_priv *priv,
-				   u32 reg, u32 shift, u32 mask, u32 value)
+void mtmips_pinctrl_reg_set(struct mtmips_pinctrl_priv *priv,
+			    u32 reg, u32 shift, u32 mask, u32 value)
 {
 	u32 val;
 
drivers/pinctrl/mtmips/pinctrl-mtmips-common.h +12 -0
index b51d8f009c..1f1023ef42 100644
@@ -22,6 +22,10 @@ struct mtmips_pmx_group {
 	u32 shift;
 	char mask;
 
+	int pconf_avail;
+	u32 pconf_reg;
+	u32 pconf_shift;
+
 	int nfuncs;
 	const struct mtmips_pmx_func *funcs;
 };
@@ -42,6 +46,14 @@ struct mtmips_pinctrl_priv {
 	{ .name = (_name), .reg = (_reg), .shift = (_shift), .mask = (_mask), \
 	  .funcs = (_funcs), .nfuncs = ARRAY_SIZE(_funcs) }
 
+#define GRP_PCONF(_name, _funcs, _reg, _shift, _mask, _pconf_reg, _pconf_shift) \
+	{ .name = (_name), .reg = (_reg), .shift = (_shift), .mask = (_mask), \
+	  .funcs = (_funcs), .nfuncs = ARRAY_SIZE(_funcs), .pconf_avail = 1, \
+	  .pconf_reg = (_pconf_reg), .pconf_shift = (_pconf_shift) }
+
+void mtmips_pinctrl_reg_set(struct mtmips_pinctrl_priv *priv,
+			    u32 reg, u32 shift, u32 mask, u32 value);
+
 int mtmips_get_functions_count(struct udevice *dev);
 const char *mtmips_get_function_name(struct udevice *dev,
 				     unsigned int selector);
Signature · 1 line
2.17.1
author
#9 lore raw

PATCH 6/14 nand: raw: add support for MediaTek MT7621 SoC

In reply to Weijie Gao

This patch adds NAND flash controller driver for MediaTek MT7621 SoC. The NAND flash controller of MT7621 supports only SLC NAND flashes. It supports 4~12 bits correction with maximum 4KB page size.

---
 drivers/mtd/nand/raw/Kconfig       |   11 +
 drivers/mtd/nand/raw/Makefile      |    1 +
 drivers/mtd/nand/raw/mt7621_nand.c | 1189 ++++++++++++++++++++++++++++
 3 files changed, 1201 insertions(+)
 create mode 100644 drivers/mtd/nand/raw/mt7621_nand.c
drivers/mtd/nand/raw/Kconfig +11 -0
index cb0c0a1581..fe87c521d7 100644
@@ -475,6 +475,17 @@ config ROCKCHIP_NAND
 	    NFC v800: RK3308, RV1108
 	    NFC v900: PX30, RK3326
 
+config NAND_MT7621
+	bool "Support for MediaTek MT7621 NAND flash controller"
+	depends on SOC_MT7621
+	select SYS_NAND_SELF_INIT
+	imply CMD_NAND
+	help
+	  This enables NAND driver for the NAND flash controller on MediaTek
+	  MT7621 platform.
+	  The controller supports 4~12 bits correction per 512 bytes with a
+	  maximum 4KB page size.
+
 comment "Generic NAND options"
 
 config SYS_NAND_BLOCK_SIZE
drivers/mtd/nand/raw/Makefile +1 -0
index 6ec3581d20..6d6721a3be 100644
@@ -72,6 +72,7 @@ obj-$(CONFIG_NAND_ZYNQ) += zynq_nand.o
 obj-$(CONFIG_NAND_STM32_FMC2) += stm32_fmc2_nand.o
 obj-$(CONFIG_CORTINA_NAND) += cortina_nand.o
 obj-$(CONFIG_ROCKCHIP_NAND) += rockchip_nfc.o
+obj-$(CONFIG_NAND_MT7621) += mt7621_nand.o
 
 else  # minimal SPL drivers
 
drivers/mtd/nand/raw/mt7621_nand.c new file +1189 -0

1,189 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#10 lore raw

PATCH 7/14 usb: xhci-mtk: add support for MediaTek MT7621 SoC

In reply to Weijie Gao

This patch makes xhci-mtk driver available for MediaTek MT7621 SoC

---
 drivers/usb/host/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/Kconfig +1 -1
index ccecb5a3b0..f2c060e692 100644
@@ -34,7 +34,7 @@ config USB_XHCI_DWC3_OF_SIMPLE
 
 config USB_XHCI_MTK
 	bool "Support for MediaTek on-chip xHCI USB controller"
-	depends on ARCH_MEDIATEK
+	depends on ARCH_MEDIATEK || SOC_MT7621
 	help
 	  Enables support for the on-chip xHCI controller on MediaTek SoCs.
 
Signature · 1 line
2.17.1
author
#11 lore raw

PATCH 8/14 phy: mtk-tphy: add support for MediaTek MT7621 SoC

In reply to Weijie Gao

This patch makes mtk-tphy driver available for MediaTek MT7621 SoC

---
 drivers/phy/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/Kconfig +1 -1
index 4767d215f3..6ab99d2643 100644
@@ -266,7 +266,7 @@ config MT76X8_USB_PHY
 config PHY_MTK_TPHY
 	bool "MediaTek T-PHY Driver"
 	depends on PHY
-	depends on ARCH_MEDIATEK
+	depends on ARCH_MEDIATEK || SOC_MT7621
 	help
 	  MediaTek T-PHY driver supports usb2.0, usb3.0 ports, PCIe and
 	  SATA, and meanwhile supports two version T-PHY which have
Signature · 1 line
2.17.1
author
#12 lore raw

PATCH 9/14 spi: add support for MediaTek MT7621 SoC

In reply to Weijie Gao

This patch makes mt7621_spi driver available for MediaTek MT7621 SoC

---
 drivers/spi/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/Kconfig +1 -1
index d07e9a28af..a43e652231 100644
@@ -219,7 +219,7 @@ config MT7620_SPI
 
 config MT7621_SPI
 	bool "MediaTek MT7621 SPI driver"
-	depends on SOC_MT7628
+	depends on SOC_MT7621 || SOC_MT7628
 	help
 	  Enable the MT7621 SPI driver. This driver can be used to access
 	  the SPI NOR flash on platforms embedding this Ralink / MediaTek
Signature · 1 line
2.17.1
author
#13 lore raw

PATCH 10/14 gpio: add support for MediaTek MT7621 SoC

In reply to Weijie Gao

This patch makes mt7621_gpio driver available for MediaTek MT7621 SoC

---
 drivers/gpio/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/Kconfig +1 -1
index 40abc33772..8c49ca3f50 100644
@@ -501,7 +501,7 @@ config MT7620_GPIO
 
 config MT7621_GPIO
 	bool "MediaTek MT7621 GPIO driver"
-	depends on DM_GPIO && SOC_MT7628
+	depends on DM_GPIO && (SOC_MT7621 || SOC_MT7628)
 	default y
 	help
 	  Say yes here to support MediaTek MT7621 compatible GPIOs.
Signature · 1 line
2.17.1
author
#15 lore raw

PATCH 11/14 watchdog: add support for MediaTek MT7621 SoC

In reply to Weijie Gao

This patch makes mt7621_wdt driver available for MediaTek MT7621 SoC

---
 drivers/watchdog/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/Kconfig +1 -1
index d306054a8c..cf383de973 100644
@@ -173,7 +173,7 @@ config WDT_MT7620
 
 config WDT_MT7621
 	bool "MediaTek MT7621 watchdog timer support"
-	depends on WDT && SOC_MT7628
+	depends on WDT && (SOC_MT7621 || SOC_MT7628)
 	help
 	  Select this to enable Ralink / Mediatek watchdog timer,
 	  which can be found on some MediaTek chips.
Signature · 1 line
2.17.1
author
#17 lore raw

PATCH 12/14 mmc: mediatek: add support for MediaTek MT7621 SoC

In reply to Weijie Gao

This patch adds SDXC support for MediaTek MT7621 SoC

---
 drivers/mmc/mtk-sd.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/mmc/mtk-sd.c +13 -0
index 8599f095bc..1199052a89 100644
@@ -1746,6 +1746,18 @@ static const struct msdc_compatible mt7620_compat = {
 	.default_pad_dly = true,
 };
 
+static const struct msdc_compatible mt7621_compat = {
+	.clk_div_bits = 8,
+	.pad_tune0 = false,
+	.async_fifo = true,
+	.data_tune = true,
+	.busy_check = false,
+	.stop_clk_fix = false,
+	.enhance_rx = false,
+	.builtin_pad_ctrl = true,
+	.default_pad_dly = true,
+};
+
 static const struct msdc_compatible mt7622_compat = {
 	.clk_div_bits = 12,
 	.pad_tune0 = true,
@@ -1794,6 +1806,7 @@ static const struct msdc_compatible mt8183_compat = {
 
 static const struct udevice_id msdc_ids[] = {
 	{ .compatible = "mediatek,mt7620-mmc", .data = (ulong)&mt7620_compat },
+	{ .compatible = "mediatek,mt7621-mmc", .data = (ulong)&mt7621_compat },
 	{ .compatible = "mediatek,mt7622-mmc", .data = (ulong)&mt7622_compat },
 	{ .compatible = "mediatek,mt7623-mmc", .data = (ulong)&mt7623_compat },
 	{ .compatible = "mediatek,mt8512-mmc", .data = (ulong)&mt8512_compat },
Signature · 1 line
2.17.1
author
#18 lore raw

PATCH 13/14 net: mediatek: add support for MediaTek MT7621 SoC

In reply to Weijie Gao

This patch adds GMAC support for MediaTek MT7621 SoC. MT7621 has the same GMAC/Switch configuration as MT7623.

---
 drivers/net/mtk_eth.c | 27 +++++++++++++++++++++------
 drivers/net/mtk_eth.h |  8 ++++++++
 2 files changed, 29 insertions(+), 6 deletions(-)
drivers/net/mtk_eth.c +21 -6
index 26f02847a2..3b42c99c2a 100644
@@ -145,7 +145,8 @@ enum mtk_switch {
 enum mtk_soc {
 	SOC_MT7623,
 	SOC_MT7629,
-	SOC_MT7622
+	SOC_MT7622,
+	SOC_MT7621
 };
 
 struct mtk_eth_priv {
@@ -669,12 +670,18 @@ static int mt7530_pad_clk_setup(struct mtk_eth_priv *priv, int mode)
 static int mt7530_setup(struct mtk_eth_priv *priv)
 {
 	u16 phy_addr, phy_val;
-	u32 val;
+	u32 val, txdrv;
 	int i;
 
-	/* Select 250MHz clk for RGMII mode */
-	mtk_ethsys_rmw(priv, ETHSYS_CLKCFG0_REG,
-		       ETHSYS_TRGMII_CLK_SEL362_5, 0);
+	if (priv->soc != SOC_MT7621) {
+		/* Select 250MHz clk for RGMII mode */
+		mtk_ethsys_rmw(priv, ETHSYS_CLKCFG0_REG,
+			       ETHSYS_TRGMII_CLK_SEL362_5, 0);
+
+		txdrv = 8;
+	} else {
+		txdrv = 4;
+	}
 
 	/* Modify HWTRAP first to allow direct access to internal PHYs */
 	mt753x_reg_read(priv, HWTRAP_REG, &val);
@@ -732,7 +739,8 @@ static int mt7530_setup(struct mtk_eth_priv *priv)
 	/* Lower Tx Driving for TRGMII path */
 	for (i = 0 ; i < NUM_TRGMII_CTRL ; i++)
 		mt753x_reg_write(priv, MT7530_TRGMII_TD_ODT(i),
-				 (8 << TD_DM_DRVP_S) | (8 << TD_DM_DRVN_S));
+				 (txdrv << TD_DM_DRVP_S) |
+				 (txdrv << TD_DM_DRVN_S));
 
 	for (i = 0 ; i < NUM_TRGMII_CTRL; i++)
 		mt753x_reg_rmw(priv, MT7530_TRGMII_RD(i), RD_TAP_M, 16);
@@ -1437,6 +1445,12 @@ static int mtk_eth_of_to_plat(struct udevice *dev)
 		return -ENODEV;
 	}
 
+	if (priv->soc == SOC_MT7621) {
+		/* ioremap is needed for MIPS platform */
+		priv->ethsys_base =
+			ioremap_nocache((phys_addr_t)priv->ethsys_base, 0x100);
+	}
+
 	/* Reset controllers */
 	ret = reset_get_by_name(dev, "fe", &priv->rst_fe);
 	if (ret) {
@@ -1542,6 +1556,7 @@ static const struct udevice_id mtk_eth_ids[] = {
 	{ .compatible = "mediatek,mt7629-eth", .data = SOC_MT7629 },
 	{ .compatible = "mediatek,mt7623-eth", .data = SOC_MT7623 },
 	{ .compatible = "mediatek,mt7622-eth", .data = SOC_MT7622 },
+	{ .compatible = "mediatek,mt7621-eth", .data = SOC_MT7621 },
 	{}
 };
 
drivers/net/mtk_eth.h +8 -0
index 057ecfaabf..4a8c66c671 100644
@@ -412,4 +412,12 @@
 #define PHY_POWER_SAVING_M		0x300
 #define PHY_POWER_SAVING_TX		0x0
 
+#ifndef CONFIG_SYS_NONCACHED_MEMORY
+/*
+ * noncached_alloc is provided only for ARM. Add a prototype here for other
+ * platforms to suppress compilation warning.
+ */
+phys_addr_t noncached_alloc(size_t size, size_t align);
+#endif
+
 #endif /* _MTK_ETH_H_ */
Signature · 1 line
2.17.1
author
#19 lore raw

PATCH 14/14 MAINTAINERS: update maintainer for MediaTek MIPS platform

In reply to Weijie Gao

Update maintainer for MediaTek MIPS platform

---
 MAINTAINERS | 5 +++++
 1 file changed, 5 insertions(+)
MAINTAINERS +5 -0
index 5069f18806..7d65856743 100644
@@ -855,15 +855,20 @@ R:	GSS_MTK_Uboot_upstream <[email protected]>
 S:	Maintained
 F:	arch/mips/mach-mtmips/
 F:	arch/mips/dts/mt7620.dtsi
+F:	arch/mips/dts/mt7621.dtsi
 F:	arch/mips/dts/mt7620-u-boot.dtsi
 F:	include/configs/mt7620.h
+F:	include/configs/mt7621.h
 F:	include/dt-bindings/clock/mt7620-clk.h
+F:	include/dt-bindings/clock/mt7621-clk.h
 F:	include/dt-bindings/clock/mt7628-clk.h
 F:	include/dt-bindings/reset/mt7620-reset.h
+F:	include/dt-bindings/reset/mt7621-reset.h
 F:	include/dt-bindings/reset/mt7628-reset.h
 F:	drivers/clk/mtmips/
 F:	drivers/pinctrl/mtmips/
 F:	drivers/gpio/mt7620_gpio.c
+F:	drivers/mtd/nand/raw/mt7621_nand.c
 F:	drivers/net/mt7620-eth.c
 F:	drivers/phy/mt7620-usb-phy.c
 F:	drivers/reset/reset-mtmips.c
Signature · 1 line
2.17.1
Reviewed-by on v1 10/14
#14 lore raw

Re: [PATCH 10/14] gpio: add support for MediaTek MT7621 SoC

In reply to Weijie Gao
Quoted 3 lines · Weijie Gao

This patch makes mt7621_gpio driver available for MediaTek MT7621 SoC

Thanks,
Stefan

Quoted 10 lines
---
  drivers/gpio/Kconfig | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/Kconfig +0 -0
index 40abc33772..8c49ca3f50 100644

drivers/gpio/Kconfig config MT7620_GPIO · line 507

Quoted 8 lines
drivers/gpio/Kconfig +1 -1
@@ -501,7 +501,7 @@ config MT7620_GPIO
 
  config MT7621_GPIO
  	bool "MediaTek MT7621 GPIO driver"
-	depends on DM_GPIO && SOC_MT7628
+	depends on DM_GPIO && (SOC_MT7621 || SOC_MT7628)
  	default y
  	help
  	  Say yes here to support MediaTek MT7621 compatible GPIOs.

Viele Grüße,
Stefan

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
Reviewed-by on v1 11/14
#16 lore raw

Re: [PATCH 11/14] watchdog: add support for MediaTek MT7621 SoC

In reply to Weijie Gao
Quoted 3 lines · Weijie Gao

This patch makes mt7621_wdt driver available for MediaTek MT7621 SoC

Thanks,
Stefan

Quoted 10 lines
---
  drivers/watchdog/Kconfig | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/Kconfig +0 -0
index d306054a8c..cf383de973 100644

drivers/watchdog/Kconfig config WDT_MT7620 · line 179

Quoted 8 lines
drivers/watchdog/Kconfig +1 -1
@@ -173,7 +173,7 @@ config WDT_MT7620
 
  config WDT_MT7621
  	bool "MediaTek MT7621 watchdog timer support"
-	depends on WDT && SOC_MT7628
+	depends on WDT && (SOC_MT7621 || SOC_MT7628)
  	help
  	  Select this to enable Ralink / Mediatek watchdog timer,
  	  which can be found on some MediaTek chips.

Viele Grüße,
Stefan

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
#2 lore raw

Re: [PATCH 01/14] mips: mtmips: add support for MediaTek MT7621 SoC

In reply to Weijie Gao

Am Donnerstag, dem 04.11.2021 um 17:48 +0800 schrieb Weijie Gao:

Quoted 518 lines

This patch adds support for MediaTek MT7621 SoC.
All files are dedicated for u-boot.

Currently only ramboot is supported.
The default build target is u-boot-lzma.img.
This file can be booted using bootm command, or be used as a payload of the
SDK preloader of MT7621.

The specification of this chip:
https://www.mediatek.com/products/homenetworking/mt7621

---
 arch/mips/dts/mt7621.dtsi             | 372
++++++++++++++++++++++++++
 arch/mips/mach-mtmips/Kconfig         |  29 +-
 arch/mips/mach-mtmips/Makefile        |   5 +
 arch/mips/mach-mtmips/cpu.c           |   4 +
 arch/mips/mach-mtmips/mt7621/Kconfig  |  23 ++
 arch/mips/mach-mtmips/mt7621/Makefile |   5 +
 arch/mips/mach-mtmips/mt7621/compat.c |  21 ++
 arch/mips/mach-mtmips/mt7621/init.c   | 156 +++++++++++
 arch/mips/mach-mtmips/mt7621/mt7621.h | 204 ++++++++++++++
 arch/mips/mach-mtmips/mt7621/serial.c |  23 ++
 include/configs/mt7621.h              |  41 +++
 11 files changed, 879 insertions(+), 4 deletions(-)
 create mode 100644 arch/mips/dts/mt7621.dtsi
 create mode 100644 arch/mips/mach-mtmips/mt7621/Kconfig
 create mode 100644 arch/mips/mach-mtmips/mt7621/Makefile
 create mode 100644 arch/mips/mach-mtmips/mt7621/compat.c
 create mode 100644 arch/mips/mach-mtmips/mt7621/init.c
 create mode 100644 arch/mips/mach-mtmips/mt7621/mt7621.h
 create mode 100644 arch/mips/mach-mtmips/mt7621/serial.c
 create mode 100644 include/configs/mt7621.h
arch/mips/dts/mt7621.dtsi new file +273 -0
new file mode 100644
index 0000000000..c09350b370
@@ -0,0 +1,372 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 MediaTek Inc. All rights reserved.
+ *
+ * Author: Weijie Gao <[email protected]>
+ */
+
+#include <dt-bindings/clock/mt7621-clk.h>
+#include <dt-bindings/reset/mt7621-reset.h>
+#include <dt-bindings/phy/phy.h>
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+	compatible = "mediatek,mt7621-soc";
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cpu@0 {
+			device_type = "cpu";
+			compatible = "mips,mips1004Kc";
+			reg = <0>;
+		};
+
+		cpu@1 {
+			device_type = "cpu";
+			compatible = "mips,mips1004Kc";
+			reg = <0>;
+		};
+	};
+
+	clk48m: clk48m@0 {
+		compatible = "fixed-clock";
+
+		clock-frequency = <48000000>;
+
+		#clock-cells = <0>;
+	};
+
+	clk50m: clk50m@0 {
+		compatible = "fixed-clock";
+
+		clock-frequency = <50000000>;
+
+		#clock-cells = <0>;
+	};
+
+	sysc: sysc@1e000000 {
+		compatible = "mediatek,mt7621-sysc", "syscon";
+		reg = <0x1e000000 0x100>;
+	};
+
+	clkctrl: clkctrl@1e000030 {
+		compatible = "mediatek,mt7621-clk";
+		mediatek,sysc = <&sysc>;
+		mediatek,memc = <&memc>;
+
+		#clock-cells = <1>;
+		u-boot,dm-pre-reloc;
+	};
+
+	rstctrl: rstctrl@1e000034 {
+		compatible = "mediatek,mtmips-reset";
+		reg = <0x1e000034 0x4>;
+		#reset-cells = <1>;
+	};
+
+	reboot: resetctl-reboot {
+		compatible = "resetctl-reboot";
+
+		resets = <&rstctrl RST_SYS>;
+		reset-names = "sysreset";
+	};
+
+	memc: memc@1e005000 {
+		compatible = "mediatek,mt7621-memc", "syscon";
+		reg = <0x1e005000 0x1000>;
+	};
+
+	pinctrl: pinctrl@1e000060 {
+		compatible = "mediatek,mt7621-pinctrl";
+		reg = <0x1e000048 0x30>;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&state_default>;
+
+		state_default: pin_state {
+			uart1 {
+				groups = "uart1";
+				function = "uart";
+			};
+
+			gpios {
+				groups = "i2c", "uart3", "pcie reset";
+				function = "gpio";
+			};
+
+			jtag {
+				groups = "jtag";
+				function = "jtag";
+			};
+
+			wdt {
+				groups = "wdt";
+				function = "wdt rst";
+			};
+		};
+
+		uart1_pins: uart1_pins {
+			groups = "uart1";
+			function = "uart";
+		};
+
+		uart2_pins: uart2_pins {
+			groups = "uart2";
+			function = "uart";
+		};
+
+		uart3_pins: uart3_pins {
+			groups = "uart3";
+			function = "uart";
+		};
+
+		sdxc_pins: sdxc_pins {
+			groups = "sdxc";
+			function = "sdxc";
+		};
+
+		spi_pins: spi_pins {
+			groups = "spi";
+			function = "spi";
+		};
+
+		eth_pins: eth_pins {
+			mdio_pins {
+				groups = "mdio";
+				function = "mdio";
+			};
+
+			rgmii1_pins {
+				groups = "rgmii1";
+				function = "rgmii";
+			};
+
+			esw_pins {
+				groups = "esw int";
+				function = "esw int";
+			};
+
+			mdio_pconf {
+				groups = "mdio";
+				drive-strength = <2>;
+			};
+		};
+	};
+
+	watchdog: watchdog@1e000100 {
+		compatible = "mediatek,mt7621-wdt";
+		reg = <0x1e000100 0x40>;
+
+		resets = <&rstctrl RST_TIMER>;
+		reset-names = "wdt";
+
+		status = "disabled";
+	};
+
+	gpio: gpio@1e000600 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		compatible = "mtk,mt7621-gpio";
+		reg = <0x1e000600 0x100>;
+
+		resets = <&rstctrl RST_PIO>;
+		reset-names = "pio";
+
+		gpio0: bank@0 {
+			reg = <0>;
+			compatible = "mtk,mt7621-gpio-bank";
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpio1: bank@1 {
+			reg = <1>;
+			compatible = "mtk,mt7621-gpio-bank";
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpio2: bank@2 {
+			reg = <2>;
+			compatible = "mtk,mt7621-gpio-bank";
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+	};
+
+	spi: spi@1e000b00 {
+		compatible = "ralink,mt7621-spi";
+		reg = <0x1e000b00 0x40>;
+
+		status = "disabled";
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&spi_pins>;
+
+		resets = <&rstctrl RST_SPI>;
+		reset-names = "spi";
+
+		clocks = <&clkctrl CLK_SPI>;
+
+		#address-cells = <1>;
+		#size-cells = <0>;
+	};
+
+	uart0: uart1@1e000c00 {
+		compatible = "mediatek,hsuart", "ns16550a";
+		reg = <0x1e000c00 0x100>;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&uart1_pins>;
+
+		clocks = <&clkctrl CLK_UART1>;
+
+		resets = <&rstctrl RST_UART1>;
+
+		reg-shift = <2>;
+	};
+
+	uart1: uart2@1e000d00 {
+		compatible = "mediatek,hsuart", "ns16550a";
+		reg = <0x1e000d00 0x100>;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&uart2_pins>;
+
+		clocks = <&clkctrl CLK_UART2>;
+
+		resets = <&rstctrl RST_UART2>;
+
+		reg-shift = <2>;
+
+		status = "disabled";
+	};
+
+	uart2: uart3@1e000e00 {
+		compatible = "mediatek,hsuart", "ns16550a";
+		reg = <0x1e000e00 0x100>;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&uart3_pins>;
+
+		clocks = <&clkctrl CLK_UART3>;
+
+		resets = <&rstctrl RST_UART3>;
+
+		reg-shift = <2>;
+
+		status = "disabled";
+	};
+
+	eth: eth@1e100000 {
+		compatible = "mediatek,mt7621-eth";
+		reg = <0x1e100000 0x20000>;
+		mediatek,ethsys = <&sysc>;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&eth_pins>;
+
+		resets = <&rstctrl RST_FE>, <&rstctrl RST_GMAC>,

<&rstctrl RST_MCM>;

arch/mips/dts/mt7621.dtsi new file +41 -0
+		reset-names = "fe", "gmac", "mcm";
+
+		clocks = <&clkctrl CLK_GMAC>,
+			 <&clkctrl CLK_FE>;
+		clock-names = "gmac", "fe";
+
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		mediatek,gmac-id = <0>;
+		phy-mode = "rgmii";
+		mediatek,switch = "mt7530";
+		mediatek,mcm;
+
+		fixed-link {
+			speed = <1000>;
+			full-duplex;
+		};
+	};
+
+	mmc: mmc@1e130000 {
+		compatible = "mediatek,mt7621-mmc";
+		reg = <0x1e130000 0x4000>;
+
+		status = "disabled";
+
+		bus-width = <4>;
+		builtin-cd = <1>;
+		r_smpl = <1>;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&sdxc_pins>;
+
+		clocks = <&clk50m>, <&clkctrl CLK_SDXC>;
+		clock-names = "source", "hclk";
+
+		resets = <&rstctrl RST_SDXC>;
+	};
+
+	ssusb: usb@1e1c0000 {
+		compatible = "mediatek,mt7621-xhci", "mediatek,mtk-

xhci";

arch/mips/dts/mt7621.dtsi new file +4 -0
+		reg = <0x1e1c0000 0x1000>, <0x1e1d0700 0x100>;
+		reg-names = "mac", "ippc";
+
+		/* power-domains = <&scpsys MT7629_POWER_DOMAIN_HIF1>;

*/

arch/mips/dts/mt7621.dtsi new file +54 -0
+
+		clocks = <&clk48m>, <&clk48m>;
+		clock-names = "sys_ck", "ref_ck";
+
+		phys = <&u2port0 PHY_TYPE_USB2>,
+		       <&u3port0 PHY_TYPE_USB3>,
+		       <&u2port1 PHY_TYPE_USB2>;
+
+		status = "disabled";
+	};
+
+	u3phy: usb-phy@1e1d0000 {
+		compatible = "mediatek,mt7621-u3phy",
+			     "mediatek,generic-tphy-v1";
+		reg = <0x1e1d0000 0x700>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+		status = "disabled";
+
+		u2port0: usb-phy@1e1d0800 {
+			reg = <0x1e1d0800 0x0100>;
+			#phy-cells = <1>;
+			clocks = <&clk48m>;
+			clock-names = "ref";
+		};
+
+		u3port0: usb-phy@1e1d0900 {
+			reg = <0x1e1d0900 0x0100>;
+			#phy-cells = <1>;
+		};
+
+		u2port1: usb-phy@1e1d1000 {
+			reg = <0x1e1d1000 0x0100>;
+			#phy-cells = <1>;
+			clocks = <&clk48m>;
+			clock-names = "ref";
+		};
+	};
+
+	i2c: i2c@1e000900 {
+		compatible = "i2c-gpio";
+
+		status = "disabled";
+
+		i2c-gpio,delay-us = <3>;
+
+		gpios = <&gpio0 3 1>, /* PIN3 as SDA */
+			<&gpio0 4 1>; /* PIN4 as CLK */
+
+		#address-cells = <1>;
+		#size-cells = <0>;
+	};
+};
arch/mips/mach- renamed from arch/mips/mach-mtmips/Kconfig +0 -0

mtmips/Kconfig
index 151b004603..9b30535411 100644

arch/mips/mach-mtmips/Kconfig +11 -4
@@ -9,6 +9,7 @@ config SYS_MALLOC_F_LEN
 
 config SYS_SOC
 	default "mt7620" if SOC_MT7620
+	default "mt7621" if SOC_MT7621
 	default "mt7628" if SOC_MT7628
 
 config SYS_DCACHE_SIZE
@@ -18,22 +19,28 @@ config SYS_DCACHE_LINE_SIZE
 	default 32
 
 config SYS_ICACHE_SIZE
-	default 65536
+	default 65536 if SOC_MT7620 || SOC_MT7628
+	default 32768 if SOC_MT7621
 
 config SYS_ICACHE_LINE_SIZE
 	default 32
 
 config SYS_TEXT_BASE
-	default 0x9c000000 if !SPL
-	default 0x80200000 if SPL
+	default 0x9c000000 if !SPL && !SOC_MT7621
+	default 0x80200000 if SPL || SOC_MT7621
 
 config SPL_TEXT_BASE
-	default 0x9c000000
+	default 0x9c000000 if !SOC_MT7621
+	default 0x80100000 if SOC_MT7621
+
+config TPL_TEXT_BASE
+	default 0xbfc00000 if SOC_MT7621
 
 config SPL_PAYLOAD
 	default "u-boot-lzma.img" if SPL_LZMA
 
 config BUILD_TARGET
+	default "u-boot-lzma.img" if SOC_MT7621 # Only ramboot is

supported now

arch/mips/mach-mtmips/Kconfig +14 -0
 	default "u-boot-with-spl.bin" if SPL
 	default "u-boot.bin"
@@ -55,6 +62,19 @@ config SOC_MT7620
 	help
 	  This supports MediaTek MT7620.
 
+config SOC_MT7621
+	bool "MT7621"
+	select MIPS_CM
+	select MIPS_L2_CACHE
+	select SYS_CACHE_SHIFT_5
+	select SYS_MIPS_CACHE_INIT_RAM_LOAD
+	select PINCTRL_MT7621
+	select MTK_SERIAL
+	select REGMAP
+	select SYSCON
+	help
+	  This supports MediaTek MT7621.
+
 config SOC_MT7628
 	bool "MT7628"
 	select SYS_CACHE_SHIFT_5
@@ -80,6 +100,7 @@ config SOC_MT7628
 endchoice
 
 source "arch/mips/mach-mtmips/mt7620/Kconfig"
+source "arch/mips/mach-mtmips/mt7621/Kconfig"
 source "arch/mips/mach-mtmips/mt7628/Kconfig"
 
 endmenu
arch/mips/mach- renamed from arch/mips/mach-mtmips/Makefile +0 -0

mtmips/Makefile
index 4909b47ef2..9ab882dee0 100644

arch/mips/mach-mtmips/Makefile +5 -0
@@ -1,9 +1,14 @@
 # SPDX-License-Identifier: GPL-2.0+
 
 obj-y += cpu.o
+
+ifneq ($(CONFIG_SOC_MT7621),y)
 obj-y += ddr_init.o
 obj-y += ddr_cal.o
+endif
+
 obj-$(CONFIG_SPL_BUILD) += spl.o
 
 obj-$(CONFIG_SOC_MT7620) += mt7620/
+obj-$(CONFIG_SOC_MT7621) += mt7621/
 obj-$(CONFIG_SOC_MT7628) += mt7628/
arch/mips/mach- renamed from arch/mips/mach-mtmips/cpu.c +0 -0

mtmips/cpu.c
index a4b5cff61d..6ca5655d46 100644

arch/mips/mach-mtmips/cpu.c DECLARE_GLOBAL_DATA_PTR; · line 23

Quoted 8 lines
arch/mips/mach-mtmips/cpu.c +4 -0
@@ -16,7 +16,11 @@ DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
 {
+#ifdef CONFIG_SOC_MT7621
+	gd->ram_size = get_ram_size((void *)KSEG1, SZ_512M);
+#else
 	gd->ram_size = get_ram_size((void *)KSEG1, SZ_256M);
+#endif

to avoid cluttering the code with new ifdefs the RAM size should be a Kconfig option which default value depends on CONFIG_SOC_MTxxxx

Quoted 527 lines
arch/mips/mach-mtmips/cpu.c +0 -0
 	return 0;
 }
arch/mips/mach- renamed from arch/mips/mach-mtmips/mt7621/Kconfig +0 -0

mtmips/mt7621/Kconfig
new file mode 100644
index 0000000000..6948bee31b

arch/mips/mach-mtmips/mt7621/Kconfig new file +23 -0
@@ -0,0 +1,23 @@
+
+if SOC_MT7621
+
+config DEBUG_UART_BOARD_INIT
+	default y
+
+choice
+	prompt "Board select"
+
+endchoice
+
+config SYS_CONFIG_NAME
+	string "Board configuration name"
+	default "mt7621" if  BOARD_MT7621_RFB || BOARD_MT7621_NAND_RFB
+
+config SYS_BOARD
+	string "Board name"
+	default "mt7621" if  BOARD_MT7621_RFB || BOARD_MT7621_NAND_RFB
+
+config SYS_VENDOR
+	default "mediatek" if BOARD_MT7621_RFB || BOARD_MT7621_NAND_RFB
+
+endif
arch/mips/mach- renamed from arch/mips/mach-mtmips/mt7621/Makefile +0 -0

mtmips/mt7621/Makefile
new file mode 100644
index 0000000000..adb48ffe37

arch/mips/mach-mtmips/mt7621/Makefile new file +5 -0
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-y += init.o
+obj-y += serial.o
+obj-y += compat.o
arch/mips/mach- renamed from arch/mips/mach-mtmips/mt7621/compat.c +0 -0

mtmips/mt7621/compat.c
new file mode 100644
index 0000000000..ae2dd263f7

arch/mips/mach-mtmips/mt7621/compat.c new file +21 -0
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 MediaTek Inc. All rights reserved.
+ *
+ * Author:  Weijie Gao <[email protected]>
+ */
+
+#include <malloc.h>
+#include <asm/io.h>
+#include <asm/addrspace.h>
+
+/* This is used for the mtk-eth driver */
+phys_addr_t noncached_alloc(size_t size, size_t align)
+{
+	void *ptr = memalign(align, ALIGN(size, align));
+
+	if (!ptr)
+		return 0;
+
+	return KSEG1ADDR((ulong)ptr);
+}
arch/mips/mach- renamed from arch/mips/mach-mtmips/mt7621/init.c +0 -0

mtmips/mt7621/init.c
new file mode 100644
index 0000000000..ca72d37980

arch/mips/mach-mtmips/mt7621/init.c new file +18 -0
@@ -0,0 +1,156 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 MediaTek Inc. All Rights Reserved.
+ *
+ * Author:  Weijie Gao <[email protected]>
+ */
+
+#include <clk.h>
+#include <dm.h>
+#include <dm/uclass.h>
+#include <dt-bindings/clock/mt7621-clk.h>
+#include <asm/global_data.h>
+#include <linux/io.h>
+#include "mt7621.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static const char *const boot_mode[(CHIP_MODE_M >> CHIP_MODE_S) + 1]

= {

arch/mips/mach-mtmips/mt7621/init.c new file +38 -0
+	[1] = "NAND 2K+64",
+	[2] = "SPI-NOR 3-Byte Addr",
+	[3] = "SPI-NOR 4-Byte Addr",
+	[10] = "NAND 2K+128",
+	[11] = "NAND 4K+128",
+	[12] = "NAND 4K+256",
+};
+
+int print_cpuinfo(void)
+{
+	void __iomem *sysc = ioremap_nocache(SYSCTL_BASE, SYSCTL_SIZE);
+	u32 cpu_clk, ddr_clk, bus_clk, xtal_clk, timer_freq;
+	u32 val, ver, eco, pkg, core, dram, chipmode;
+	struct udevice *clkdev;
+	const char *bootdev;
+	struct clk clk;
+	int ret;
+
+	val = readl(sysc + SYSCTL_CHIP_REV_ID_REG);
+	ver = (val & VER_ID_M) >> VER_ID_S;
+	eco = (val & ECO_ID_M) >> ECO_ID_S;
+	pkg = !!(val & PKG_ID);
+	core = !!(val & CPU_ID);
+
+	val = readl(sysc + SYSCTL_SYSCFG0_REG);
+	dram = val & DRAM_TYPE;
+	chipmode = (val & CHIP_MODE_M) >> CHIP_MODE_S;
+
+	bootdev = boot_mode[chipmode];
+	if (!bootdev)
+		bootdev = "Unsupported boot mode";
+
+	printf("CPU:   MediaTek MT7621%c ver %u, eco %u\n",
+	       core ? (pkg ? 'A' : 'N') : 'S', ver, eco);
+
+	printf("Boot:  DDR%u, %s\n", dram ? 2 : 3, bootdev);
+
+	ret = uclass_get_device_by_driver(UCLASS_CLK,

DM_DRIVER_GET(mt7621_clk),

arch/mips/mach-mtmips/mt7621/init.c new file +26 -0
+					  &clkdev);
+	if (ret)
+		return ret;
+
+	clk.dev = clkdev;
+
+	clk.id = CLK_CPU;
+	cpu_clk = clk_get_rate(&clk);
+
+	clk.id = CLK_SYS;
+	bus_clk = clk_get_rate(&clk);
+
+	clk.id = CLK_DDR;
+	ddr_clk = clk_get_rate(&clk);
+
+	clk.id = CLK_XTAL;
+	xtal_clk = clk_get_rate(&clk);
+
+	clk.id = CLK_MIPS_CNT;
+	timer_freq = clk_get_rate(&clk);
+
+	/* Set final timer frequency */
+	if (timer_freq)
+		gd->arch.timer_freq = timer_freq;
+
+	printf("Clock: CPU: %uMHz, DDR: %uMT/s, Bus: %uMHz, XTAL:

%uMHz\n",

arch/mips/mach-mtmips/mt7621/init.c new file +19 -0
+	       cpu_clk / 1000000, ddr_clk / 500000, bus_clk / 1000000,
+	       xtal_clk / 1000000);
+
+	return 0;
+}
+
+void lowlevel_init(void)
+{
+	void __iomem *usbh = ioremap_nocache(SSUSB_BASE, SSUSB_SIZE);
+
+	/* Setup USB xHCI */
+
+	writel((0x20 << SSUSB_MAC3_SYS_CK_GATE_MASK_TIME_S) |
+	       (0x20 << SSUSB_MAC2_SYS_CK_GATE_MASK_TIME_S) |
+	       (2 << SSUSB_MAC3_SYS_CK_GATE_MODE_S) |
+	       (2 << SSUSB_MAC2_SYS_CK_GATE_MODE_S) | 0x10,
+	       usbh + SSUSB_MAC_CK_CTRL_REG);
+
+	writel((2 << SSUSB_PLL_PREDIV_PE1D_S) | (1 <<

SSUSB_PLL_PREDIV_U3_S) |

arch/mips/mach-mtmips/mt7621/init.c new file +1 -0
+	       (4 << SSUSB_PLL_FBKDI_S), usbh +

DA_SSUSB_U3PHYA_10_REG);

arch/mips/mach-mtmips/mt7621/init.c new file +19 -0
+
+	writel((0x18 << SSUSB_PLL_FBKDIV_PE2H_S) |
+	       (0x18 << SSUSB_PLL_FBKDIV_PE1D_S) |
+	       (0x18 << SSUSB_PLL_FBKDIV_PE1H_S) |
+	       (0x1e << SSUSB_PLL_FBKDIV_U3_S),
+	       usbh + DA_SSUSB_PLL_FBKDIV_REG);
+
+	writel((0x1e400000 << SSUSB_PLL_PCW_NCPO_U3_S),
+	       usbh + DA_SSUSB_PLL_PCW_NCPO_REG);
+
+	writel((0x25 << SSUSB_PLL_SSC_DELTA1_PE1H_S) |
+	       (0x73 << SSUSB_PLL_SSC_DELTA1_U3_S),
+	       usbh + DA_SSUSB_PLL_SSC_DELTA1_REG);
+
+	writel((0x71 << SSUSB_PLL_SSC_DELTA_U3_S) |
+	       (0x4a << SSUSB_PLL_SSC_DELTA1_PE2D_S),
+	       usbh + DA_SSUSB_U3PHYA_21_REG);
+
+	writel((0x140 << SSUSB_PLL_SSC_PRD_S), usbh +

SSUSB_U3PHYA_9_REG);

arch/mips/mach-mtmips/mt7621/init.c new file +5 -0
+
+	writel((0x11c00000 << SSUSB_SYSPLL_PCW_NCPO_S),
+	       usbh + SSUSB_U3PHYA_3_REG);
+
+	writel((4 << SSUSB_PCIE_CLKDRV_AMP_S) | (1 <<

SSUSB_SYSPLL_FBSEL_S) |

arch/mips/mach-mtmips/mt7621/init.c new file +1 -0
+	       (1 << SSUSB_SYSPLL_PREDIV_S), usbh +

SSUSB_U3PHYA_1_REG);

arch/mips/mach-mtmips/mt7621/init.c new file +2 -0
+
+	writel((0x12 << SSUSB_SYSPLL_FBDIV_S) |

SSUSB_SYSPLL_VCO_DIV_SEL |

arch/mips/mach-mtmips/mt7621/init.c new file +1 -0
+	       SSUSB_SYSPLL_FPEN | SSUSB_SYSPLL_MONCK_EN |

SSUSB_SYSPLL_VOD_EN,

arch/mips/mach-mtmips/mt7621/init.c new file +4 -0
+	       usbh + SSUSB_U3PHYA_2_REG);
+
+	writel(SSUSB_EQ_CURSEL | (8 << SSUSB_RX_DAC_MUX_S) |
+	       (1 << SSUSB_PCIE_SIGDET_VTH_S) | (1 <<

SSUSB_PCIE_SIGDET_LPF_S),

arch/mips/mach-mtmips/mt7621/init.c new file +4 -0
+	       usbh + SSUSB_U3PHYA_11_REG);
+
+	writel((0x1ff << SSUSB_RING_OSC_CNTEND_S) |
+	       (0x7f << SSUSB_XTAL_OSC_CNTEND_S) |

SSUSB_RING_BYPASS_DET,

arch/mips/mach-mtmips/mt7621/init.c new file +3 -0
+	       usbh + SSUSB_B2_ROSC_0_REG);
+
+	writel((3 << SSUSB_RING_OSC_FRC_RECAL_S) |

SSUSB_RING_OSC_FRC_SEL,

arch/mips/mach-mtmips/mt7621/init.c new file +15 -0
+	       usbh + SSUSB_B2_ROSC_1_REG);
+}
+
+ulong notrace get_tbclk(void)
+{
+	return gd->arch.timer_freq;
+}
+
+void _machine_restart(void)
+{
+	void __iomem *sysc = ioremap_nocache(SYSCTL_BASE, SYSCTL_SIZE);
+
+	while (1)
+		writel(SYS_RST, sysc + SYSCTL_RSTCTL_REG);
+}
arch/mips/mach- renamed from arch/mips/mach-mtmips/mt7621/mt7621.h +0 -0

mtmips/mt7621/mt7621.h
new file mode 100644
index 0000000000..012f5a3557

arch/mips/mach-mtmips/mt7621/mt7621.h new file +204 -0
@@ -0,0 +1,204 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2021 MediaTek Inc. All Rights Reserved.
+ *
+ * Author: Weijie Gao <[email protected]>
+ */
+
+#ifndef _MT7621_H_
+#define _MT7621_H_
+
+#define SYSCTL_BASE				0x1e000000
+#define SYSCTL_SIZE				0x100
+#define TIMER_BASE				0x1e000100
+#define TIMER_SIZE				0x100
+#define RBUS_BASE				0x1e000400
+#define RBUS_SIZE				0x100
+#define GPIO_BASE				0x1e000600
+#define GPIO_SIZE				0x100
+#define DMA_CFG_ARB_BASE			0x1e000800
+#define DMA_CFG_ARB_SIZE			0x100
+#define SPI_BASE				0x1e000b00
+#define SPI_SIZE				0x100
+#define UART1_BASE				0x1e000c00
+#define UART1_SIZE				0x100
+#define NFI_BASE				0x1e003000
+#define NFI_SIZE				0x800
+#define NFI_ECC_BASE				0x1e003800
+#define NFI_ECC_SIZE				0x800
+#define DRAMC_BASE				0x1e005000
+#define DRAMC_SIZE				0x1000
+#define FE_BASE					0x1e100000
+#define FE_SIZE					0xe000
+#define GMAC_BASE				0x1e110000
+#define GMAC_SIZE				0x8000
+#define SSUSB_BASE				0x1e1c0000
+#define SSUSB_SIZE				0x40000
+
+ /* GIC Base Address */
+#define MIPS_GIC_BASE				0x1fbc0000
+
+ /* CPC Base Address */
+#define MIPS_CPC_BASE				0x1fbf0000
+
+ /* Flash Memory-mapped Base Address */
+#define FLASH_MMAP_BASE				0x1fc00000
+
+/* SRAM */
+#define FE_SRAM_BASE1				0x8000
+#define FE_SRAM_BASE2				0xa000
+
+/* SYSCTL_BASE */
+#define SYSCTL_CHIP_REV_ID_REG			0x0c
+#define CPU_ID					0x20000
+#define PKG_ID					0x10000
+#define VER_ID_S				8
+#define VER_ID_M				0xf00
+#define ECO_ID_S				0
+#define ECO_ID_M				0x0f
+
+#define SYSCTL_SYSCFG0_REG			0x10
+#define XTAL_MODE_SEL_S				6
+#define XTAL_MODE_SEL_M				0x1c0
+#define DRAM_TYPE				0x10
+#define CHIP_MODE_S				0
+#define CHIP_MODE_M				0x0f
+
+#define BOOT_SRAM_BASE_REG			0x20
+
+#define SYSCTL_CLKCFG0_REG			0x2c
+#define CPU_CLK_SEL_S				30
+#define CPU_CLK_SEL_M				0xc0000000
+#define MPLL_CFG_SEL_S				23
+#define MPLL_CFG_SEL_M				0x800000
+
+#define SYSCTL_RSTCTL_REG			0x34
+#define SYS_RST					0x01
+
+#define SYSCTL_CUR_CLK_STS_REG			0x44
+#define CUR_CPU_FDIV_S				8
+#define CUR_CPU_FDIV_M				0x1f00
+#define CUR_CPU_FFRAC_S				0
+#define CUR_CPU_FFRAC_M				0x1f
+
+#define SYSCTL_GPIOMODE_REG			0x60
+#define UART2_MODE_S				5
+#define UART2_MODE_M				0x60
+#define UART3_MODE_S				3
+#define UART3_MODE_M				0x18
+#define UART1_MODE				0x02
+
+/* RBUS_BASE */
+#define RBUS_DYN_CFG0_REG			0x0010
+#define CPU_FDIV_S				8
+#define CPU_FDIV_M				0x1f00
+#define CPU_FFRAC_S				0
+#define CPU_FFRAC_M				0x1f
+
+/* DMA_CFG_ARB_BASE */
+#define DMA_ROUTE_REG				0x000c
+
+/* SPI_BASE */
+#define SPI_SPACE_REG				0x003c
+#define FS_SLAVE_SEL_S				12
+#define FS_SLAVE_SEL_M				0x70000
+#define FS_CLK_SEL_S				0
+#define FS_CLK_SEL_M				0xfff
+
+/* FE_BASE */
+#define FE_RST_GLO_REG				0x0004
+#define FE_PSE_RAM				0x04
+#define FE_PSE_MEM_EN				0x02
+#define FE_PSE_RESET				0x01
+
+/* SSUSB_BASE */
+#define SSUSB_MAC_CK_CTRL_REG			0x10784
+#define SSUSB_MAC3_SYS_CK_GATE_MASK_TIME_S	16
+#define SSUSB_MAC3_SYS_CK_GATE_MASK_TIME_M	0xff0000
+#define SSUSB_MAC2_SYS_CK_GATE_MASK_TIME_S	8
+#define SSUSB_MAC2_SYS_CK_GATE_MASK_TIME_M	0xff00
+#define SSUSB_MAC3_SYS_CK_GATE_MODE_S		2
+#define SSUSB_MAC3_SYS_CK_GATE_MODE_M		0x0c
+#define SSUSB_MAC2_SYS_CK_GATE_MODE_S		0
+#define SSUSB_MAC2_SYS_CK_GATE_MODE_M		0x03
+
+#define SSUSB_B2_ROSC_0_REG			0x10a40
+#define SSUSB_RING_OSC_CNTEND_S			23
+#define SSUSB_RING_OSC_CNTEND_M			0xff800000
+#define SSUSB_XTAL_OSC_CNTEND_S			16
+#define SSUSB_XTAL_OSC_CNTEND_M			0x7f0000
+#define SSUSB_RING_BYPASS_DET			0x01
+
+#define SSUSB_B2_ROSC_1_REG			0x10a44
+#define SSUSB_RING_OSC_FRC_RECAL_S		17
+#define SSUSB_RING_OSC_FRC_RECAL_M		0x60000
+#define SSUSB_RING_OSC_FRC_SEL			0x01
+
+#define SSUSB_U3PHYA_1_REG			0x10b04
+#define SSUSB_PCIE_CLKDRV_AMP_S			27
+#define SSUSB_PCIE_CLKDRV_AMP_M			0x38000000
+#define SSUSB_SYSPLL_FBSEL_S			2
+#define SSUSB_SYSPLL_FBSEL_M			0x0c
+#define SSUSB_SYSPLL_PREDIV_S			0
+#define SSUSB_SYSPLL_PREDIV_M			0x03
+
+#define SSUSB_U3PHYA_2_REG			0x10b08
+#define SSUSB_SYSPLL_FBDIV_S			24
+#define SSUSB_SYSPLL_FBDIV_M			0x7f000000
+#define SSUSB_SYSPLL_VCO_DIV_SEL		0x200000
+#define SSUSB_SYSPLL_FPEN			0x2000
+#define SSUSB_SYSPLL_MONCK_EN			0x1000
+#define SSUSB_SYSPLL_VOD_EN			0x200
+
+#define SSUSB_U3PHYA_3_REG			0x10b10
+#define SSUSB_SYSPLL_PCW_NCPO_S			1
+#define SSUSB_SYSPLL_PCW_NCPO_M			0xfffffffe
+
+#define SSUSB_U3PHYA_9_REG			0x10b24
+#define SSUSB_PLL_SSC_PRD_S			0
+#define SSUSB_PLL_SSC_PRD_M			0xffff
+
+#define SSUSB_U3PHYA_11_REG			0x10b2c
+#define SSUSB_EQ_CURSEL				0x1000000
+#define SSUSB_RX_DAC_MUX_S			19
+#define SSUSB_RX_DAC_MUX_M			0xf80000
+#define SSUSB_PCIE_SIGDET_VTH_S			5
+#define SSUSB_PCIE_SIGDET_VTH_M			0x60
+#define SSUSB_PCIE_SIGDET_LPF_S			3
+#define SSUSB_PCIE_SIGDET_LPF_M			0x18
+
+#define DA_SSUSB_PLL_FBKDIV_REG			0x10c1c
+#define SSUSB_PLL_FBKDIV_PE2H_S			24
+#define SSUSB_PLL_FBKDIV_PE2H_M			0x7f000000
+#define SSUSB_PLL_FBKDIV_PE1D_S			16
+#define SSUSB_PLL_FBKDIV_PE1D_M			0x7f0000
+#define SSUSB_PLL_FBKDIV_PE1H_S			8
+#define SSUSB_PLL_FBKDIV_PE1H_M			0x7f00
+#define SSUSB_PLL_FBKDIV_U3_S			0
+#define SSUSB_PLL_FBKDIV_U3_M			0x7f
+
+#define DA_SSUSB_U3PHYA_10_REG			0x10c20
+#define SSUSB_PLL_PREDIV_PE1D_S			18
+#define SSUSB_PLL_PREDIV_PE1D_M			0xc0000
+#define SSUSB_PLL_PREDIV_U3_S			8
+#define SSUSB_PLL_PREDIV_U3_M			0x300
+#define SSUSB_PLL_FBKDI_S			0
+#define SSUSB_PLL_FBKDI_M			0x07
+
+#define DA_SSUSB_PLL_PCW_NCPO_REG		0x10c24
+#define SSUSB_PLL_PCW_NCPO_U3_S			0
+#define SSUSB_PLL_PCW_NCPO_U3_M			0x7fffffff
+
+#define DA_SSUSB_PLL_SSC_DELTA1_REG		0x10c38
+#define SSUSB_PLL_SSC_DELTA1_PE1H_S		16
+#define SSUSB_PLL_SSC_DELTA1_PE1H_M		0xffff0000
+#define SSUSB_PLL_SSC_DELTA1_U3_S		0
+#define SSUSB_PLL_SSC_DELTA1_U3_M		0xffff
+
+#define DA_SSUSB_U3PHYA_21_REG			0x10c40
+#define SSUSB_PLL_SSC_DELTA_U3_S		16
+#define SSUSB_PLL_SSC_DELTA_U3_M		0xffff0000
+#define SSUSB_PLL_SSC_DELTA1_PE2D_S		0
+#define SSUSB_PLL_SSC_DELTA1_PE2D_M		0xffff
+
+#endif /* _MT7621_H_ */
arch/mips/mach- renamed from arch/mips/mach-mtmips/mt7621/serial.c +0 -0

mtmips/mt7621/serial.c
new file mode 100644
index 0000000000..393188abce

arch/mips/mach-mtmips/mt7621/serial.c new file +18 -0
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 MediaTek Inc.
+ *
+ * Author:  Weijie Gao <[email protected]>
+ */
+
+#include <asm/io.h>
+#include <asm/addrspace.h>
+#include "mt7621.h"
+
+void board_debug_uart_init(void)
+{
+	void __iomem *base = ioremap_nocache(SYSCTL_BASE, SYSCTL_SIZE);
+
+#if CONFIG_DEBUG_UART_BASE == 0xbe000c00 /* KSEG1ADDR(UART1_BASE) */
+	clrbits_32(base + SYSCTL_GPIOMODE_REG, UART1_MODE);
+#elif CONFIG_DEBUG_UART_BASE == 0xbe000d00 /* KSEG1ADDR(UART2_BASE)

*/

arch/mips/mach-mtmips/mt7621/serial.c new file +2 -0
+	clrbits_32(base + SYSCTL_GPIOMODE_REG, UART2_MODE_M);
+#elif CONFIG_DEBUG_UART_BASE == 0xbe000e00 /* KSEG1ADDR(UART3_BASE)

*/

arch/mips/mach-mtmips/mt7621/serial.c new file +3 -0
+	clrbits_32(base + SYSCTL_GPIOMODE_REG, UART3_MODE_M);
+#endif
+}
include/configs/mt7621.h new file +29 -0
new file mode 100644
index 0000000000..47f7e51a1a
@@ -0,0 +1,41 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2021 MediaTek Inc. All Rights Reserved.
+ *
+ * Author: Weijie Gao <[email protected]>
+ */
+
+#ifndef __CONFIG_MT7621_H
+#define __CONFIG_MT7621_H
+
+#define CONFIG_SYS_HZ			1000
+#define CONFIG_SYS_MIPS_TIMER_FREQ	440000000
+
+#define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_TEXT_BASE
+
+#define CONFIG_SYS_BOOTPARAMS_LEN	0x20000
+
+#define CONFIG_SYS_SDRAM_BASE		0x80000000
+
+#define CONFIG_VERY_BIG_RAM
+#define CONFIG_MAX_MEM_MAPPED		0x1c000000
+
+#define CONFIG_SYS_INIT_SP_OFFSET	0x10000
+
+#define CONFIG_SYS_BOOTM_LEN		0x2000000
+
+#define CONFIG_SYS_MAXARGS		16
+#define CONFIG_SYS_CBSIZE		1024
+

include/configs/mt7621.h line 39

Quoted 10 lines
include/configs/mt7621.h new file +10 -0
+/* MMC */
+#define MMC_SUPPORTS_TUNING
+
+/* NAND */
+#define CONFIG_SYS_MAX_NAND_DEVICE	1
+
+/* Network */
+#define CONFIG_IPADDR			192.168.1.1
+#define CONFIG_SERVERIP			192.168.1.2
+#define CONFIG_NETMASK			255.255.255.0

the default config shouldn't have any network config

Quoted 2 lines
include/configs/mt7621.h new file +2 -0
+
+#endif /* __CONFIG_MT7621_H */
Signature · 1 line
- Daniel
Reviewed-by on v1 2/14
#5 lore raw

Re: [PATCH 02/14] mips: mtmips: add two reference boards for mt7621

In reply to Weijie Gao

Am Donnerstag, dem 04.11.2021 um 17:48 +0800 schrieb Weijie Gao:

Quoted 22 lines

The mt7621_rfb board supports integrated giga PHYs plus one external giga PHYs. It also has up to 512MiB DDR3, 16MB SPI-NOR, 3 mini PCI-e x1
slots, SDXC and USB.

The mt7621_nand_rfb board is almost the same as mt7621_rfb board, but it
uses NAND flash and SDXC is not available.

---
 arch/mips/dts/Makefile                     |  2 +
 arch/mips/dts/mediatek,mt7621-nand-rfb.dts | 52 +++++++++++++++
 arch/mips/dts/mediatek,mt7621-rfb.dts      | 68 ++++++++++++++++++++
 arch/mips/mach-mtmips/mt7621/Kconfig       | 20 ++++++
 board/mediatek/mt7621/MAINTAINERS          |  8 +++
 board/mediatek/mt7621/Makefile             |  3 +
 board/mediatek/mt7621/board.c              |  6 ++
 configs/mt7621_nand_rfb_ramboot_defconfig  | 71
+++++++++++++++++++++
 configs/mt7621_rfb_ramboot_defconfig       | 74

++++++++++++++++++++++

Quoted 10 lines
 9 files changed, 304 insertions(+)
 create mode 100644 arch/mips/dts/mediatek,mt7621-nand-rfb.dts
 create mode 100644 arch/mips/dts/mediatek,mt7621-rfb.dts
 create mode 100644 board/mediatek/mt7621/MAINTAINERS
 create mode 100644 board/mediatek/mt7621/Makefile
 create mode 100644 board/mediatek/mt7621/board.c
 create mode 100644 configs/mt7621_nand_rfb_ramboot_defconfig
 create mode 100644 configs/mt7621_rfb_ramboot_defconfig
Signature · 1 line
- Daniel
author
#3 lore raw

Re: [PATCH 01/14] mips: mtmips: add support for MediaTek MT7621 SoC

In reply to Daniel Schwierzeck
Quoted 524 lines · Daniel Schwierzeck

Am Donnerstag, dem 04.11.2021 um 17:48 +0800 schrieb Weijie Gao:

Quoted 523 lines

This patch adds support for MediaTek MT7621 SoC.
All files are dedicated for u-boot.

Currently only ramboot is supported.
The default build target is u-boot-lzma.img.
This file can be booted using bootm command, or be used as a payload
of the
SDK preloader of MT7621.

The specification of this chip:
https://www.mediatek.com/products/homenetworking/mt7621

---
 arch/mips/dts/mt7621.dtsi             | 372
++++++++++++++++++++++++++
 arch/mips/mach-mtmips/Kconfig         |  29 +-
 arch/mips/mach-mtmips/Makefile        |   5 +
 arch/mips/mach-mtmips/cpu.c           |   4 +
 arch/mips/mach-mtmips/mt7621/Kconfig  |  23 ++
 arch/mips/mach-mtmips/mt7621/Makefile |   5 +
 arch/mips/mach-mtmips/mt7621/compat.c |  21 ++
 arch/mips/mach-mtmips/mt7621/init.c   | 156 +++++++++++
 arch/mips/mach-mtmips/mt7621/mt7621.h | 204 ++++++++++++++
 arch/mips/mach-mtmips/mt7621/serial.c |  23 ++
 include/configs/mt7621.h              |  41 +++
 11 files changed, 879 insertions(+), 4 deletions(-)
 create mode 100644 arch/mips/dts/mt7621.dtsi
 create mode 100644 arch/mips/mach-mtmips/mt7621/Kconfig
 create mode 100644 arch/mips/mach-mtmips/mt7621/Makefile
 create mode 100644 arch/mips/mach-mtmips/mt7621/compat.c
 create mode 100644 arch/mips/mach-mtmips/mt7621/init.c
 create mode 100644 arch/mips/mach-mtmips/mt7621/mt7621.h
 create mode 100644 arch/mips/mach-mtmips/mt7621/serial.c
 create mode 100644 include/configs/mt7621.h
arch/mips/dts/mt7621.dtsi new file +96 -0
new file mode 100644
index 0000000000..c09350b370
@@ -0,0 +1,372 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 MediaTek Inc. All rights reserved.
+ *
+ * Author: Weijie Gao <[email protected]>
+ */
+
+#include <dt-bindings/clock/mt7621-clk.h>
+#include <dt-bindings/reset/mt7621-reset.h>
+#include <dt-bindings/phy/phy.h>
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+	compatible = "mediatek,mt7621-soc";
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cpu@0 {
+			device_type = "cpu";
+			compatible = "mips,mips1004Kc";
+			reg = <0>;
+		};
+
+		cpu@1 {
+			device_type = "cpu";
+			compatible = "mips,mips1004Kc";
+			reg = <0>;
+		};
+	};
+
+	clk48m: clk48m@0 {
+		compatible = "fixed-clock";
+
+		clock-frequency = <48000000>;
+
+		#clock-cells = <0>;
+	};
+
+	clk50m: clk50m@0 {
+		compatible = "fixed-clock";
+
+		clock-frequency = <50000000>;
+
+		#clock-cells = <0>;
+	};
+
+	sysc: sysc@1e000000 {
+		compatible = "mediatek,mt7621-sysc", "syscon";
+		reg = <0x1e000000 0x100>;
+	};
+
+	clkctrl: clkctrl@1e000030 {
+		compatible = "mediatek,mt7621-clk";
+		mediatek,sysc = <&sysc>;
+		mediatek,memc = <&memc>;
+
+		#clock-cells = <1>;
+		u-boot,dm-pre-reloc;
+	};
+
+	rstctrl: rstctrl@1e000034 {
+		compatible = "mediatek,mtmips-reset";
+		reg = <0x1e000034 0x4>;
+		#reset-cells = <1>;
+	};
+
+	reboot: resetctl-reboot {
+		compatible = "resetctl-reboot";
+
+		resets = <&rstctrl RST_SYS>;
+		reset-names = "sysreset";
+	};
+
+	memc: memc@1e005000 {
+		compatible = "mediatek,mt7621-memc", "syscon";
+		reg = <0x1e005000 0x1000>;
+	};
+
+	pinctrl: pinctrl@1e000060 {
+		compatible = "mediatek,mt7621-pinctrl";
+		reg = <0x1e000048 0x30>;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&state_default>;
+
+		state_default: pin_state {
+			uart1 {
+				groups = "uart1";
+				function = "uart";
+			};
+
+			gpios {
+				groups = "i2c", "uart3", "pcie

reset";

arch/mips/dts/mt7621.dtsi new file +177 -0
+				function = "gpio";
+			};
+
+			jtag {
+				groups = "jtag";
+				function = "jtag";
+			};
+
+			wdt {
+				groups = "wdt";
+				function = "wdt rst";
+			};
+		};
+
+		uart1_pins: uart1_pins {
+			groups = "uart1";
+			function = "uart";
+		};
+
+		uart2_pins: uart2_pins {
+			groups = "uart2";
+			function = "uart";
+		};
+
+		uart3_pins: uart3_pins {
+			groups = "uart3";
+			function = "uart";
+		};
+
+		sdxc_pins: sdxc_pins {
+			groups = "sdxc";
+			function = "sdxc";
+		};
+
+		spi_pins: spi_pins {
+			groups = "spi";
+			function = "spi";
+		};
+
+		eth_pins: eth_pins {
+			mdio_pins {
+				groups = "mdio";
+				function = "mdio";
+			};
+
+			rgmii1_pins {
+				groups = "rgmii1";
+				function = "rgmii";
+			};
+
+			esw_pins {
+				groups = "esw int";
+				function = "esw int";
+			};
+
+			mdio_pconf {
+				groups = "mdio";
+				drive-strength = <2>;
+			};
+		};
+	};
+
+	watchdog: watchdog@1e000100 {
+		compatible = "mediatek,mt7621-wdt";
+		reg = <0x1e000100 0x40>;
+
+		resets = <&rstctrl RST_TIMER>;
+		reset-names = "wdt";
+
+		status = "disabled";
+	};
+
+	gpio: gpio@1e000600 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		compatible = "mtk,mt7621-gpio";
+		reg = <0x1e000600 0x100>;
+
+		resets = <&rstctrl RST_PIO>;
+		reset-names = "pio";
+
+		gpio0: bank@0 {
+			reg = <0>;
+			compatible = "mtk,mt7621-gpio-bank";
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpio1: bank@1 {
+			reg = <1>;
+			compatible = "mtk,mt7621-gpio-bank";
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpio2: bank@2 {
+			reg = <2>;
+			compatible = "mtk,mt7621-gpio-bank";
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+	};
+
+	spi: spi@1e000b00 {
+		compatible = "ralink,mt7621-spi";
+		reg = <0x1e000b00 0x40>;
+
+		status = "disabled";
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&spi_pins>;
+
+		resets = <&rstctrl RST_SPI>;
+		reset-names = "spi";
+
+		clocks = <&clkctrl CLK_SPI>;
+
+		#address-cells = <1>;
+		#size-cells = <0>;
+	};
+
+	uart0: uart1@1e000c00 {
+		compatible = "mediatek,hsuart", "ns16550a";
+		reg = <0x1e000c00 0x100>;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&uart1_pins>;
+
+		clocks = <&clkctrl CLK_UART1>;
+
+		resets = <&rstctrl RST_UART1>;
+
+		reg-shift = <2>;
+	};
+
+	uart1: uart2@1e000d00 {
+		compatible = "mediatek,hsuart", "ns16550a";
+		reg = <0x1e000d00 0x100>;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&uart2_pins>;
+
+		clocks = <&clkctrl CLK_UART2>;
+
+		resets = <&rstctrl RST_UART2>;
+
+		reg-shift = <2>;
+
+		status = "disabled";
+	};
+
+	uart2: uart3@1e000e00 {
+		compatible = "mediatek,hsuart", "ns16550a";
+		reg = <0x1e000e00 0x100>;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&uart3_pins>;
+
+		clocks = <&clkctrl CLK_UART3>;
+
+		resets = <&rstctrl RST_UART3>;
+
+		reg-shift = <2>;
+
+		status = "disabled";
+	};
+
+	eth: eth@1e100000 {
+		compatible = "mediatek,mt7621-eth";
+		reg = <0x1e100000 0x20000>;
+		mediatek,ethsys = <&sysc>;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&eth_pins>;
+
+		resets = <&rstctrl RST_FE>, <&rstctrl RST_GMAC>,

<&rstctrl RST_MCM>;

arch/mips/dts/mt7621.dtsi new file +41 -0
+		reset-names = "fe", "gmac", "mcm";
+
+		clocks = <&clkctrl CLK_GMAC>,
+			 <&clkctrl CLK_FE>;
+		clock-names = "gmac", "fe";
+
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		mediatek,gmac-id = <0>;
+		phy-mode = "rgmii";
+		mediatek,switch = "mt7530";
+		mediatek,mcm;
+
+		fixed-link {
+			speed = <1000>;
+			full-duplex;
+		};
+	};
+
+	mmc: mmc@1e130000 {
+		compatible = "mediatek,mt7621-mmc";
+		reg = <0x1e130000 0x4000>;
+
+		status = "disabled";
+
+		bus-width = <4>;
+		builtin-cd = <1>;
+		r_smpl = <1>;
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&sdxc_pins>;
+
+		clocks = <&clk50m>, <&clkctrl CLK_SDXC>;
+		clock-names = "source", "hclk";
+
+		resets = <&rstctrl RST_SDXC>;
+	};
+
+	ssusb: usb@1e1c0000 {
+		compatible = "mediatek,mt7621-xhci",

"mediatek,mtk-
xhci";

arch/mips/dts/mt7621.dtsi new file +4 -0
+		reg = <0x1e1c0000 0x1000>, <0x1e1d0700 0x100>;
+		reg-names = "mac", "ippc";
+
+		/* power-domains = <&scpsys

MT7629_POWER_DOMAIN_HIF1>;
*/

arch/mips/dts/mt7621.dtsi new file +54 -0
+
+		clocks = <&clk48m>, <&clk48m>;
+		clock-names = "sys_ck", "ref_ck";
+
+		phys = <&u2port0 PHY_TYPE_USB2>,
+		       <&u3port0 PHY_TYPE_USB3>,
+		       <&u2port1 PHY_TYPE_USB2>;
+
+		status = "disabled";
+	};
+
+	u3phy: usb-phy@1e1d0000 {
+		compatible = "mediatek,mt7621-u3phy",
+			     "mediatek,generic-tphy-v1";
+		reg = <0x1e1d0000 0x700>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+		status = "disabled";
+
+		u2port0: usb-phy@1e1d0800 {
+			reg = <0x1e1d0800 0x0100>;
+			#phy-cells = <1>;
+			clocks = <&clk48m>;
+			clock-names = "ref";
+		};
+
+		u3port0: usb-phy@1e1d0900 {
+			reg = <0x1e1d0900 0x0100>;
+			#phy-cells = <1>;
+		};
+
+		u2port1: usb-phy@1e1d1000 {
+			reg = <0x1e1d1000 0x0100>;
+			#phy-cells = <1>;
+			clocks = <&clk48m>;
+			clock-names = "ref";
+		};
+	};
+
+	i2c: i2c@1e000900 {
+		compatible = "i2c-gpio";
+
+		status = "disabled";
+
+		i2c-gpio,delay-us = <3>;
+
+		gpios = <&gpio0 3 1>, /* PIN3 as SDA */
+			<&gpio0 4 1>; /* PIN4 as CLK */
+
+		#address-cells = <1>;
+		#size-cells = <0>;
+	};
+};
arch/mips/mach- renamed from arch/mips/mach-mtmips/Kconfig +0 -0

mtmips/Kconfig
index 151b004603..9b30535411 100644

arch/mips/mach-mtmips/Kconfig +11 -4
@@ -9,6 +9,7 @@ config SYS_MALLOC_F_LEN
 
 config SYS_SOC
 	default "mt7620" if SOC_MT7620
+	default "mt7621" if SOC_MT7621
 	default "mt7628" if SOC_MT7628
 
 config SYS_DCACHE_SIZE
@@ -18,22 +19,28 @@ config SYS_DCACHE_LINE_SIZE
 	default 32
 
 config SYS_ICACHE_SIZE
-	default 65536
+	default 65536 if SOC_MT7620 || SOC_MT7628
+	default 32768 if SOC_MT7621
 
 config SYS_ICACHE_LINE_SIZE
 	default 32
 
 config SYS_TEXT_BASE
-	default 0x9c000000 if !SPL
-	default 0x80200000 if SPL
+	default 0x9c000000 if !SPL && !SOC_MT7621
+	default 0x80200000 if SPL || SOC_MT7621
 
 config SPL_TEXT_BASE
-	default 0x9c000000
+	default 0x9c000000 if !SOC_MT7621
+	default 0x80100000 if SOC_MT7621
+
+config TPL_TEXT_BASE
+	default 0xbfc00000 if SOC_MT7621
 
 config SPL_PAYLOAD
 	default "u-boot-lzma.img" if SPL_LZMA
 
 config BUILD_TARGET
+	default "u-boot-lzma.img" if SOC_MT7621 # Only ramboot is

supported now

arch/mips/mach-mtmips/Kconfig +14 -0
 	default "u-boot-with-spl.bin" if SPL
 	default "u-boot.bin"
@@ -55,6 +62,19 @@ config SOC_MT7620
 	help
 	  This supports MediaTek MT7620.
 
+config SOC_MT7621
+	bool "MT7621"
+	select MIPS_CM
+	select MIPS_L2_CACHE
+	select SYS_CACHE_SHIFT_5
+	select SYS_MIPS_CACHE_INIT_RAM_LOAD
+	select PINCTRL_MT7621
+	select MTK_SERIAL
+	select REGMAP
+	select SYSCON
+	help
+	  This supports MediaTek MT7621.
+
 config SOC_MT7628
 	bool "MT7628"
 	select SYS_CACHE_SHIFT_5
@@ -80,6 +100,7 @@ config SOC_MT7628
 endchoice
 
 source "arch/mips/mach-mtmips/mt7620/Kconfig"
+source "arch/mips/mach-mtmips/mt7621/Kconfig"
 source "arch/mips/mach-mtmips/mt7628/Kconfig"
 
 endmenu
arch/mips/mach- renamed from arch/mips/mach-mtmips/Makefile +0 -0

mtmips/Makefile
index 4909b47ef2..9ab882dee0 100644

arch/mips/mach-mtmips/Makefile +5 -0
@@ -1,9 +1,14 @@
 # SPDX-License-Identifier: GPL-2.0+
 
 obj-y += cpu.o
+
+ifneq ($(CONFIG_SOC_MT7621),y)
 obj-y += ddr_init.o
 obj-y += ddr_cal.o
+endif
+
 obj-$(CONFIG_SPL_BUILD) += spl.o
 
 obj-$(CONFIG_SOC_MT7620) += mt7620/
+obj-$(CONFIG_SOC_MT7621) += mt7621/
 obj-$(CONFIG_SOC_MT7628) += mt7628/
arch/mips/mach- renamed from arch/mips/mach-mtmips/cpu.c +0 -0

mtmips/cpu.c
index a4b5cff61d..6ca5655d46 100644

arch/mips/mach-mtmips/cpu.c +0 -0
@@ -16,7 +16,11 @@ DECLARE_GLOBAL_DATA_PTR;
 
Quoted 11 lines

arch/mips/mach-mtmips/cpu.c DECLARE_GLOBAL_DATA_PTR; · line 23

Quoted 7 lines
arch/mips/mach-mtmips/cpu.c +4 -0
 int dram_init(void)
 {
+#ifdef CONFIG_SOC_MT7621
+	gd->ram_size = get_ram_size((void *)KSEG1, SZ_512M);
+#else
 	gd->ram_size = get_ram_size((void *)KSEG1, SZ_256M);
+#endif

to avoid cluttering the code with new ifdefs the RAM size should be a Kconfig option which default value depends on CONFIG_SOC_MTxxxx

OK. I'll create a config to do this.

Quoted 548 lines
Quoted 548 lines
arch/mips/mach-mtmips/cpu.c +0 -0
 	return 0;
 }
arch/mips/mach- renamed from arch/mips/mach-mtmips/mt7621/Kconfig +0 -0

mtmips/mt7621/Kconfig
new file mode 100644
index 0000000000..6948bee31b

arch/mips/mach-mtmips/mt7621/Kconfig new file +14 -0
@@ -0,0 +1,23 @@
+
+if SOC_MT7621
+
+config DEBUG_UART_BOARD_INIT
+	default y
+
+choice
+	prompt "Board select"
+
+endchoice
+
+config SYS_CONFIG_NAME
+	string "Board configuration name"
+	default "mt7621" if  BOARD_MT7621_RFB ||

BOARD_MT7621_NAND_RFB

arch/mips/mach-mtmips/mt7621/Kconfig new file +4 -0
+
+config SYS_BOARD
+	string "Board name"
+	default "mt7621" if  BOARD_MT7621_RFB ||

BOARD_MT7621_NAND_RFB

arch/mips/mach-mtmips/mt7621/Kconfig new file +3 -0
+
+config SYS_VENDOR
+	default "mediatek" if BOARD_MT7621_RFB ||

BOARD_MT7621_NAND_RFB

arch/mips/mach-mtmips/mt7621/Kconfig new file +2 -0
+
+endif
arch/mips/mach- renamed from arch/mips/mach-mtmips/mt7621/Makefile +0 -0

mtmips/mt7621/Makefile
new file mode 100644
index 0000000000..adb48ffe37

arch/mips/mach-mtmips/mt7621/Makefile new file +5 -0
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-y += init.o
+obj-y += serial.o
+obj-y += compat.o
arch/mips/mach- renamed from arch/mips/mach-mtmips/mt7621/compat.c +0 -0

mtmips/mt7621/compat.c
new file mode 100644
index 0000000000..ae2dd263f7

arch/mips/mach-mtmips/mt7621/compat.c new file +21 -0
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 MediaTek Inc. All rights reserved.
+ *
+ * Author:  Weijie Gao <[email protected]>
+ */
+
+#include <malloc.h>
+#include <asm/io.h>
+#include <asm/addrspace.h>
+
+/* This is used for the mtk-eth driver */
+phys_addr_t noncached_alloc(size_t size, size_t align)
+{
+	void *ptr = memalign(align, ALIGN(size, align));
+
+	if (!ptr)
+		return 0;
+
+	return KSEG1ADDR((ulong)ptr);
+}
arch/mips/mach- renamed from arch/mips/mach-mtmips/mt7621/init.c +0 -0

mtmips/mt7621/init.c
new file mode 100644
index 0000000000..ca72d37980

arch/mips/mach-mtmips/mt7621/init.c new file +18 -0
@@ -0,0 +1,156 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 MediaTek Inc. All Rights Reserved.
+ *
+ * Author:  Weijie Gao <[email protected]>
+ */
+
+#include <clk.h>
+#include <dm.h>
+#include <dm/uclass.h>
+#include <dt-bindings/clock/mt7621-clk.h>
+#include <asm/global_data.h>
+#include <linux/io.h>
+#include "mt7621.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static const char *const boot_mode[(CHIP_MODE_M >> CHIP_MODE_S) +

1]
= {

arch/mips/mach-mtmips/mt7621/init.c new file +11 -0
+	[1] = "NAND 2K+64",
+	[2] = "SPI-NOR 3-Byte Addr",
+	[3] = "SPI-NOR 4-Byte Addr",
+	[10] = "NAND 2K+128",
+	[11] = "NAND 4K+128",
+	[12] = "NAND 4K+256",
+};
+
+int print_cpuinfo(void)
+{
+	void __iomem *sysc = ioremap_nocache(SYSCTL_BASE,

SYSCTL_SIZE);

arch/mips/mach-mtmips/mt7621/init.c new file +27 -0
+	u32 cpu_clk, ddr_clk, bus_clk, xtal_clk, timer_freq;
+	u32 val, ver, eco, pkg, core, dram, chipmode;
+	struct udevice *clkdev;
+	const char *bootdev;
+	struct clk clk;
+	int ret;
+
+	val = readl(sysc + SYSCTL_CHIP_REV_ID_REG);
+	ver = (val & VER_ID_M) >> VER_ID_S;
+	eco = (val & ECO_ID_M) >> ECO_ID_S;
+	pkg = !!(val & PKG_ID);
+	core = !!(val & CPU_ID);
+
+	val = readl(sysc + SYSCTL_SYSCFG0_REG);
+	dram = val & DRAM_TYPE;
+	chipmode = (val & CHIP_MODE_M) >> CHIP_MODE_S;
+
+	bootdev = boot_mode[chipmode];
+	if (!bootdev)
+		bootdev = "Unsupported boot mode";
+
+	printf("CPU:   MediaTek MT7621%c ver %u, eco %u\n",
+	       core ? (pkg ? 'A' : 'N') : 'S', ver, eco);
+
+	printf("Boot:  DDR%u, %s\n", dram ? 2 : 3, bootdev);
+
+	ret = uclass_get_device_by_driver(UCLASS_CLK,

DM_DRIVER_GET(mt7621_clk),

arch/mips/mach-mtmips/mt7621/init.c new file +26 -0
+					  &clkdev);
+	if (ret)
+		return ret;
+
+	clk.dev = clkdev;
+
+	clk.id = CLK_CPU;
+	cpu_clk = clk_get_rate(&clk);
+
+	clk.id = CLK_SYS;
+	bus_clk = clk_get_rate(&clk);
+
+	clk.id = CLK_DDR;
+	ddr_clk = clk_get_rate(&clk);
+
+	clk.id = CLK_XTAL;
+	xtal_clk = clk_get_rate(&clk);
+
+	clk.id = CLK_MIPS_CNT;
+	timer_freq = clk_get_rate(&clk);
+
+	/* Set final timer frequency */
+	if (timer_freq)
+		gd->arch.timer_freq = timer_freq;
+
+	printf("Clock: CPU: %uMHz, DDR: %uMT/s, Bus: %uMHz, XTAL:

%uMHz\n",

arch/mips/mach-mtmips/mt7621/init.c new file +1 -0
+	       cpu_clk / 1000000, ddr_clk / 500000, bus_clk /

1000000,

arch/mips/mach-mtmips/mt7621/init.c new file +8 -0
+	       xtal_clk / 1000000);
+
+	return 0;
+}
+
+void lowlevel_init(void)
+{
+	void __iomem *usbh = ioremap_nocache(SSUSB_BASE,

SSUSB_SIZE);

arch/mips/mach-mtmips/mt7621/init.c new file +10 -0
+
+	/* Setup USB xHCI */
+
+	writel((0x20 << SSUSB_MAC3_SYS_CK_GATE_MASK_TIME_S) |
+	       (0x20 << SSUSB_MAC2_SYS_CK_GATE_MASK_TIME_S) |
+	       (2 << SSUSB_MAC3_SYS_CK_GATE_MODE_S) |
+	       (2 << SSUSB_MAC2_SYS_CK_GATE_MODE_S) | 0x10,
+	       usbh + SSUSB_MAC_CK_CTRL_REG);
+
+	writel((2 << SSUSB_PLL_PREDIV_PE1D_S) | (1 <<

SSUSB_PLL_PREDIV_U3_S) |

arch/mips/mach-mtmips/mt7621/init.c new file +1 -0
+	       (4 << SSUSB_PLL_FBKDI_S), usbh +

DA_SSUSB_U3PHYA_10_REG);

arch/mips/mach-mtmips/mt7621/init.c new file +19 -0
+
+	writel((0x18 << SSUSB_PLL_FBKDIV_PE2H_S) |
+	       (0x18 << SSUSB_PLL_FBKDIV_PE1D_S) |
+	       (0x18 << SSUSB_PLL_FBKDIV_PE1H_S) |
+	       (0x1e << SSUSB_PLL_FBKDIV_U3_S),
+	       usbh + DA_SSUSB_PLL_FBKDIV_REG);
+
+	writel((0x1e400000 << SSUSB_PLL_PCW_NCPO_U3_S),
+	       usbh + DA_SSUSB_PLL_PCW_NCPO_REG);
+
+	writel((0x25 << SSUSB_PLL_SSC_DELTA1_PE1H_S) |
+	       (0x73 << SSUSB_PLL_SSC_DELTA1_U3_S),
+	       usbh + DA_SSUSB_PLL_SSC_DELTA1_REG);
+
+	writel((0x71 << SSUSB_PLL_SSC_DELTA_U3_S) |
+	       (0x4a << SSUSB_PLL_SSC_DELTA1_PE2D_S),
+	       usbh + DA_SSUSB_U3PHYA_21_REG);
+
+	writel((0x140 << SSUSB_PLL_SSC_PRD_S), usbh +

SSUSB_U3PHYA_9_REG);

arch/mips/mach-mtmips/mt7621/init.c new file +5 -0
+
+	writel((0x11c00000 << SSUSB_SYSPLL_PCW_NCPO_S),
+	       usbh + SSUSB_U3PHYA_3_REG);
+
+	writel((4 << SSUSB_PCIE_CLKDRV_AMP_S) | (1 <<

SSUSB_SYSPLL_FBSEL_S) |

arch/mips/mach-mtmips/mt7621/init.c new file +1 -0
+	       (1 << SSUSB_SYSPLL_PREDIV_S), usbh +

SSUSB_U3PHYA_1_REG);

arch/mips/mach-mtmips/mt7621/init.c new file +2 -0
+
+	writel((0x12 << SSUSB_SYSPLL_FBDIV_S) |

SSUSB_SYSPLL_VCO_DIV_SEL |

arch/mips/mach-mtmips/mt7621/init.c new file +1 -0
+	       SSUSB_SYSPLL_FPEN | SSUSB_SYSPLL_MONCK_EN |

SSUSB_SYSPLL_VOD_EN,

arch/mips/mach-mtmips/mt7621/init.c new file +4 -0
+	       usbh + SSUSB_U3PHYA_2_REG);
+
+	writel(SSUSB_EQ_CURSEL | (8 << SSUSB_RX_DAC_MUX_S) |
+	       (1 << SSUSB_PCIE_SIGDET_VTH_S) | (1 <<

SSUSB_PCIE_SIGDET_LPF_S),

arch/mips/mach-mtmips/mt7621/init.c new file +4 -0
+	       usbh + SSUSB_U3PHYA_11_REG);
+
+	writel((0x1ff << SSUSB_RING_OSC_CNTEND_S) |
+	       (0x7f << SSUSB_XTAL_OSC_CNTEND_S) |

SSUSB_RING_BYPASS_DET,

arch/mips/mach-mtmips/mt7621/init.c new file +3 -0
+	       usbh + SSUSB_B2_ROSC_0_REG);
+
+	writel((3 << SSUSB_RING_OSC_FRC_RECAL_S) |

SSUSB_RING_OSC_FRC_SEL,

arch/mips/mach-mtmips/mt7621/init.c new file +11 -0
+	       usbh + SSUSB_B2_ROSC_1_REG);
+}
+
+ulong notrace get_tbclk(void)
+{
+	return gd->arch.timer_freq;
+}
+
+void _machine_restart(void)
+{
+	void __iomem *sysc = ioremap_nocache(SYSCTL_BASE,

SYSCTL_SIZE);

arch/mips/mach-mtmips/mt7621/init.c new file +4 -0
+
+	while (1)
+		writel(SYS_RST, sysc + SYSCTL_RSTCTL_REG);
+}
arch/mips/mach- renamed from arch/mips/mach-mtmips/mt7621/mt7621.h +0 -0

mtmips/mt7621/mt7621.h
new file mode 100644
index 0000000000..012f5a3557

arch/mips/mach-mtmips/mt7621/mt7621.h new file +204 -0
@@ -0,0 +1,204 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2021 MediaTek Inc. All Rights Reserved.
+ *
+ * Author: Weijie Gao <[email protected]>
+ */
+
+#ifndef _MT7621_H_
+#define _MT7621_H_
+
+#define SYSCTL_BASE				0x1e000000
+#define SYSCTL_SIZE				0x100
+#define TIMER_BASE				0x1e000100
+#define TIMER_SIZE				0x100
+#define RBUS_BASE				0x1e000400
+#define RBUS_SIZE				0x100
+#define GPIO_BASE				0x1e000600
+#define GPIO_SIZE				0x100
+#define DMA_CFG_ARB_BASE			0x1e000800
+#define DMA_CFG_ARB_SIZE			0x100
+#define SPI_BASE				0x1e000b00
+#define SPI_SIZE				0x100
+#define UART1_BASE				0x1e000c00
+#define UART1_SIZE				0x100
+#define NFI_BASE				0x1e003000
+#define NFI_SIZE				0x800
+#define NFI_ECC_BASE				0x1e003800
+#define NFI_ECC_SIZE				0x800
+#define DRAMC_BASE				0x1e005000
+#define DRAMC_SIZE				0x1000
+#define FE_BASE					0x1e100000
+#define FE_SIZE					0xe000
+#define GMAC_BASE				0x1e110000
+#define GMAC_SIZE				0x8000
+#define SSUSB_BASE				0x1e1c0000
+#define SSUSB_SIZE				0x40000
+
+ /* GIC Base Address */
+#define MIPS_GIC_BASE				0x1fbc0000
+
+ /* CPC Base Address */
+#define MIPS_CPC_BASE				0x1fbf0000
+
+ /* Flash Memory-mapped Base Address */
+#define FLASH_MMAP_BASE				0x1fc00000
+
+/* SRAM */
+#define FE_SRAM_BASE1				0x8000
+#define FE_SRAM_BASE2				0xa000
+
+/* SYSCTL_BASE */
+#define SYSCTL_CHIP_REV_ID_REG			0x0c
+#define CPU_ID					0x20000
+#define PKG_ID					0x10000
+#define VER_ID_S				8
+#define VER_ID_M				0xf00
+#define ECO_ID_S				0
+#define ECO_ID_M				0x0f
+
+#define SYSCTL_SYSCFG0_REG			0x10
+#define XTAL_MODE_SEL_S				6
+#define XTAL_MODE_SEL_M				0x1c0
+#define DRAM_TYPE				0x10
+#define CHIP_MODE_S				0
+#define CHIP_MODE_M				0x0f
+
+#define BOOT_SRAM_BASE_REG			0x20
+
+#define SYSCTL_CLKCFG0_REG			0x2c
+#define CPU_CLK_SEL_S				30
+#define CPU_CLK_SEL_M				0xc0000000
+#define MPLL_CFG_SEL_S				23
+#define MPLL_CFG_SEL_M				0x800000
+
+#define SYSCTL_RSTCTL_REG			0x34
+#define SYS_RST					0x01
+
+#define SYSCTL_CUR_CLK_STS_REG			0x44
+#define CUR_CPU_FDIV_S				8
+#define CUR_CPU_FDIV_M				0x1f00
+#define CUR_CPU_FFRAC_S				0
+#define CUR_CPU_FFRAC_M				0x1f
+
+#define SYSCTL_GPIOMODE_REG			0x60
+#define UART2_MODE_S				5
+#define UART2_MODE_M				0x60
+#define UART3_MODE_S				3
+#define UART3_MODE_M				0x18
+#define UART1_MODE				0x02
+
+/* RBUS_BASE */
+#define RBUS_DYN_CFG0_REG			0x0010
+#define CPU_FDIV_S				8
+#define CPU_FDIV_M				0x1f00
+#define CPU_FFRAC_S				0
+#define CPU_FFRAC_M				0x1f
+
+/* DMA_CFG_ARB_BASE */
+#define DMA_ROUTE_REG				0x000c
+
+/* SPI_BASE */
+#define SPI_SPACE_REG				0x003c
+#define FS_SLAVE_SEL_S				12
+#define FS_SLAVE_SEL_M				0x70000
+#define FS_CLK_SEL_S				0
+#define FS_CLK_SEL_M				0xfff
+
+/* FE_BASE */
+#define FE_RST_GLO_REG				0x0004
+#define FE_PSE_RAM				0x04
+#define FE_PSE_MEM_EN				0x02
+#define FE_PSE_RESET				0x01
+
+/* SSUSB_BASE */
+#define SSUSB_MAC_CK_CTRL_REG			0x10784
+#define SSUSB_MAC3_SYS_CK_GATE_MASK_TIME_S	16
+#define SSUSB_MAC3_SYS_CK_GATE_MASK_TIME_M	0xff0000
+#define SSUSB_MAC2_SYS_CK_GATE_MASK_TIME_S	8
+#define SSUSB_MAC2_SYS_CK_GATE_MASK_TIME_M	0xff00
+#define SSUSB_MAC3_SYS_CK_GATE_MODE_S		2
+#define SSUSB_MAC3_SYS_CK_GATE_MODE_M		0x0c
+#define SSUSB_MAC2_SYS_CK_GATE_MODE_S		0
+#define SSUSB_MAC2_SYS_CK_GATE_MODE_M		0x03
+
+#define SSUSB_B2_ROSC_0_REG			0x10a40
+#define SSUSB_RING_OSC_CNTEND_S			23
+#define SSUSB_RING_OSC_CNTEND_M			0xff800000
+#define SSUSB_XTAL_OSC_CNTEND_S			16
+#define SSUSB_XTAL_OSC_CNTEND_M			0x7f0000
+#define SSUSB_RING_BYPASS_DET			0x01
+
+#define SSUSB_B2_ROSC_1_REG			0x10a44
+#define SSUSB_RING_OSC_FRC_RECAL_S		17
+#define SSUSB_RING_OSC_FRC_RECAL_M		0x60000
+#define SSUSB_RING_OSC_FRC_SEL			0x01
+
+#define SSUSB_U3PHYA_1_REG			0x10b04
+#define SSUSB_PCIE_CLKDRV_AMP_S			27
+#define SSUSB_PCIE_CLKDRV_AMP_M			0x38000000
+#define SSUSB_SYSPLL_FBSEL_S			2
+#define SSUSB_SYSPLL_FBSEL_M			0x0c
+#define SSUSB_SYSPLL_PREDIV_S			0
+#define SSUSB_SYSPLL_PREDIV_M			0x03
+
+#define SSUSB_U3PHYA_2_REG			0x10b08
+#define SSUSB_SYSPLL_FBDIV_S			24
+#define SSUSB_SYSPLL_FBDIV_M			0x7f000000
+#define SSUSB_SYSPLL_VCO_DIV_SEL		0x200000
+#define SSUSB_SYSPLL_FPEN			0x2000
+#define SSUSB_SYSPLL_MONCK_EN			0x1000
+#define SSUSB_SYSPLL_VOD_EN			0x200
+
+#define SSUSB_U3PHYA_3_REG			0x10b10
+#define SSUSB_SYSPLL_PCW_NCPO_S			1
+#define SSUSB_SYSPLL_PCW_NCPO_M			0xfffffffe
+
+#define SSUSB_U3PHYA_9_REG			0x10b24
+#define SSUSB_PLL_SSC_PRD_S			0
+#define SSUSB_PLL_SSC_PRD_M			0xffff
+
+#define SSUSB_U3PHYA_11_REG			0x10b2c
+#define SSUSB_EQ_CURSEL				0x1000000
+#define SSUSB_RX_DAC_MUX_S			19
+#define SSUSB_RX_DAC_MUX_M			0xf80000
+#define SSUSB_PCIE_SIGDET_VTH_S			5
+#define SSUSB_PCIE_SIGDET_VTH_M			0x60
+#define SSUSB_PCIE_SIGDET_LPF_S			3
+#define SSUSB_PCIE_SIGDET_LPF_M			0x18
+
+#define DA_SSUSB_PLL_FBKDIV_REG			0x10c1c
+#define SSUSB_PLL_FBKDIV_PE2H_S			24
+#define SSUSB_PLL_FBKDIV_PE2H_M			0x7f000000
+#define SSUSB_PLL_FBKDIV_PE1D_S			16
+#define SSUSB_PLL_FBKDIV_PE1D_M			0x7f0000
+#define SSUSB_PLL_FBKDIV_PE1H_S			8
+#define SSUSB_PLL_FBKDIV_PE1H_M			0x7f00
+#define SSUSB_PLL_FBKDIV_U3_S			0
+#define SSUSB_PLL_FBKDIV_U3_M			0x7f
+
+#define DA_SSUSB_U3PHYA_10_REG			0x10c20
+#define SSUSB_PLL_PREDIV_PE1D_S			18
+#define SSUSB_PLL_PREDIV_PE1D_M			0xc0000
+#define SSUSB_PLL_PREDIV_U3_S			8
+#define SSUSB_PLL_PREDIV_U3_M			0x300
+#define SSUSB_PLL_FBKDI_S			0
+#define SSUSB_PLL_FBKDI_M			0x07
+
+#define DA_SSUSB_PLL_PCW_NCPO_REG		0x10c24
+#define SSUSB_PLL_PCW_NCPO_U3_S			0
+#define SSUSB_PLL_PCW_NCPO_U3_M			0x7fffffff
+
+#define DA_SSUSB_PLL_SSC_DELTA1_REG		0x10c38
+#define SSUSB_PLL_SSC_DELTA1_PE1H_S		16
+#define SSUSB_PLL_SSC_DELTA1_PE1H_M		0xffff0000
+#define SSUSB_PLL_SSC_DELTA1_U3_S		0
+#define SSUSB_PLL_SSC_DELTA1_U3_M		0xffff
+
+#define DA_SSUSB_U3PHYA_21_REG			0x10c40
+#define SSUSB_PLL_SSC_DELTA_U3_S		16
+#define SSUSB_PLL_SSC_DELTA_U3_M		0xffff0000
+#define SSUSB_PLL_SSC_DELTA1_PE2D_S		0
+#define SSUSB_PLL_SSC_DELTA1_PE2D_M		0xffff
+
+#endif /* _MT7621_H_ */
arch/mips/mach- renamed from arch/mips/mach-mtmips/mt7621/serial.c +0 -0

mtmips/mt7621/serial.c
new file mode 100644
index 0000000000..393188abce

arch/mips/mach-mtmips/mt7621/serial.c new file +14 -0
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 MediaTek Inc.
+ *
+ * Author:  Weijie Gao <[email protected]>
+ */
+
+#include <asm/io.h>
+#include <asm/addrspace.h>
+#include "mt7621.h"
+
+void board_debug_uart_init(void)
+{
+	void __iomem *base = ioremap_nocache(SYSCTL_BASE,

SYSCTL_SIZE);

arch/mips/mach-mtmips/mt7621/serial.c new file +2 -0
+
+#if CONFIG_DEBUG_UART_BASE == 0xbe000c00 /* KSEG1ADDR(UART1_BASE)

*/

arch/mips/mach-mtmips/mt7621/serial.c new file +2 -0
+	clrbits_32(base + SYSCTL_GPIOMODE_REG, UART1_MODE);
+#elif CONFIG_DEBUG_UART_BASE == 0xbe000d00 /*

KSEG1ADDR(UART2_BASE)
*/

arch/mips/mach-mtmips/mt7621/serial.c new file +2 -0
+	clrbits_32(base + SYSCTL_GPIOMODE_REG, UART2_MODE_M);
+#elif CONFIG_DEBUG_UART_BASE == 0xbe000e00 /*

KSEG1ADDR(UART3_BASE)
*/

arch/mips/mach-mtmips/mt7621/serial.c new file +3 -0
+	clrbits_32(base + SYSCTL_GPIOMODE_REG, UART3_MODE_M);
+#endif
+}
include/configs/mt7621.h new file +14 -0
new file mode 100644
index 0000000000..47f7e51a1a
@@ -0,0 +1,41 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2021 MediaTek Inc. All Rights Reserved.
+ *
+ * Author: Weijie Gao <[email protected]>
+ */
+
+#ifndef __CONFIG_MT7621_H
+#define __CONFIG_MT7621_H
+
+#define CONFIG_SYS_HZ			1000
+#define CONFIG_SYS_MIPS_TIMER_FREQ	440000000
+
+#define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_TEXT_BAS

E

include/configs/mt7621.h new file +19 -0
+
+#define CONFIG_SYS_BOOTPARAMS_LEN	0x20000
+
+#define CONFIG_SYS_SDRAM_BASE		0x80000000
+
+#define CONFIG_VERY_BIG_RAM
+#define CONFIG_MAX_MEM_MAPPED		0x1c000000
+
+#define CONFIG_SYS_INIT_SP_OFFSET	0x10000
+
+#define CONFIG_SYS_BOOTM_LEN		0x2000000
+
+#define CONFIG_SYS_MAXARGS		16
+#define CONFIG_SYS_CBSIZE		1024
+
+/* MMC */
+#define MMC_SUPPORTS_TUNING
+
+/* NAND */
Quoted 9 lines

include/configs/mt7621.h line 39

Quoted 6 lines
include/configs/mt7621.h new file +6 -0
+#define CONFIG_SYS_MAX_NAND_DEVICE	1
+
+/* Network */
+#define CONFIG_IPADDR			192.168.1.1
+#define CONFIG_SERVERIP			192.168.1.2
+#define CONFIG_NETMASK			255.255.255.0

the default config shouldn't have any network config

I'll create another config file to hold these configs.

Quoted 2 lines
Quoted 2 lines
include/configs/mt7621.h new file +2 -0
+
+#endif /* __CONFIG_MT7621_H */