Skip to contentSkip to conversation

Add support for MediaTek MT7621 SoC

PATCH Superseded Weijie Gao 5 participants 29 messages Apr 28, 2022 – May 5, 2022

Subsystems (15)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Weijie Gao

author
#0 lore raw

v3 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

v3 changes:
- Rewrite clk driver to follow definitions from upstream kernel
- Implement noncached_alloc() for MIPS platform
- Update register remap for mtk-eth driver needed by mt7621

v2 changes:
- Add a kconfig for max supported ram size
- Remove network configs from default config file
- Add config file for mt7621-rfb boards

Weijie Gao (15):
mips: mtmips: add support for MediaTek MT7621 SoC
mips: mtmips: add two reference boards for mt7621
mips: add support for noncached_alloc()
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                     |  370 +++++
 arch/mips/include/asm/system.h                |   20 +
 arch/mips/lib/cache.c                         |   43 +
 arch/mips/mach-mtmips/Kconfig                 |   34 +-
 arch/mips/mach-mtmips/Makefile                |    5 +
 arch/mips/mach-mtmips/cpu.c                   |    2 +-
 arch/mips/mach-mtmips/mt7621/Kconfig          |   43 +
 arch/mips/mach-mtmips/mt7621/Makefile         |    4 +
 arch/mips/mach-mtmips/mt7621/init.c           |  153 +++
 arch/mips/mach-mtmips/mt7621/mt7621.h         |  204 +++
 arch/mips/mach-mtmips/mt7621/serial.c         |   23 +
 board/mediatek/mt7621/MAINTAINERS             |    9 +
 board/mediatek/mt7621/Makefile                |    3 +
 board/mediatek/mt7621/board.c                 |    6 +
 configs/mt7621_nand_rfb_ramboot_defconfig     |   72 +
 configs/mt7621_rfb_ramboot_defconfig          |   75 ++
 drivers/clk/mtmips/Makefile                   |    1 +
 drivers/clk/mtmips/clk-mt7621.c               |  313 +++++
 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                         |   45 +-
 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-rfb.h                  |   18 +
 include/configs/mt7621.h                      |   38 +
 include/dt-bindings/clock/mt7621-clk.h        |   46 +
 include/dt-bindings/reset/mt7621-reset.h      |   38 +
 41 files changed, 3219 insertions(+), 30 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/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-rfb.h
 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 v3 1/15 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

---
v3 changes:
Update clock name for mt7621.dtsi due to clk driver changed
v2 changes:
Add a kconfig for max supported ram size
Remove network configs from default config file

---
 arch/mips/dts/mt7621.dtsi             | 370 ++++++++++++++++++++++++++
 arch/mips/mach-mtmips/Kconfig         |  34 ++-
 arch/mips/mach-mtmips/Makefile        |   5 +
 arch/mips/mach-mtmips/cpu.c           |   2 +-
 arch/mips/mach-mtmips/mt7621/Kconfig  |  23 ++
 arch/mips/mach-mtmips/mt7621/Makefile |   4 +
 arch/mips/mach-mtmips/mt7621/init.c   | 153 +++++++++++
 arch/mips/mach-mtmips/mt7621/mt7621.h | 204 ++++++++++++++
 arch/mips/mach-mtmips/mt7621/serial.c |  23 ++
 include/configs/mt7621.h              |  38 +++
 10 files changed, 851 insertions(+), 5 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/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 +370 -0
new file mode 100644
index 0000000000..7fec87abe7
@@ -0,0 +1,370 @@
+// 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 MT7621_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 MT7621_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 MT7621_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 MT7621_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 MT7621_CLK_GDMA>,
+			 <&clkctrl MT7621_CLK_ETH>;
+		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 MT7621_CLK_SHXC>;
+		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";
+
+		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 +30 -4
index 151b004603..a73e9f8bd8 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,25 +19,36 @@ 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"
 
+config MAX_MEM_SIZE
+	int
+	default 256 if SOC_MT7620 || SOC_MT7628
+	default 512 if SOC_MT7621
+
 choice
 	prompt "MediaTek MIPS SoC select"
 
@@ -55,6 +67,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 +105,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 +1 -1
index a4b5cff61d..f1e9022738 100644
@@ -16,7 +16,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((void *)KSEG1, SZ_256M);
+	gd->ram_size = get_ram_size((void *)KSEG1, CONFIG_MAX_MEM_SIZE << 20);
 
 	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 +4 -0
new file mode 100644
index 0000000000..3906430077
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-y += init.o
+obj-y += serial.o
arch/mips/mach-mtmips/mt7621/init.c new file +153 -0

153 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 +38 -0
new file mode 100644
index 0000000000..74a81004d0
@@ -0,0 +1,38 @@
+/* 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	0x80000
+
+#define CONFIG_SYS_BOOTM_LEN		0x2000000
+
+#define CONFIG_SYS_MAXARGS		16
+#define CONFIG_SYS_CBSIZE		1024
+
+#define CONFIG_SYS_NONCACHED_MEMORY	0x100000
+
+/* MMC */
+#define MMC_SUPPORTS_TUNING
+
+/* NAND */
+#define CONFIG_SYS_MAX_NAND_DEVICE	1
+
+#endif /* __CONFIG_MT7621_H */
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH v3 2/15 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.

---
v3 changes: none
v2 changes:
Add config file for mt7621-rfb boards

---
 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          |  9 +++
 board/mediatek/mt7621/Makefile             |  3 +
 board/mediatek/mt7621/board.c              |  6 ++
 configs/mt7621_nand_rfb_ramboot_defconfig  | 72 +++++++++++++++++++++
 configs/mt7621_rfb_ramboot_defconfig       | 75 ++++++++++++++++++++++
 include/configs/mt7621-rfb.h               | 18 ++++++
 10 files changed, 325 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
 create mode 100644 include/configs/mt7621-rfb.h
arch/mips/dts/Makefile +2 -0
index 95144b24dc..1b179116c9 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 +9 -0
new file mode 100644
index 0000000000..add653b931
@@ -0,0 +1,9 @@
+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
+F:	include/configs/mt7621-rfb.h
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 +72 -0

72 lines not on this page · raw message

configs/mt7621_rfb_ramboot_defconfig new file +75 -0

75 lines not on this page · raw message

include/configs/mt7621-rfb.h new file +18 -0
new file mode 100644
index 0000000000..2287cb1103
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2021 MediaTek Inc. All Rights Reserved.
+ *
+ * Author: Weijie Gao <[email protected]>
+ */
+
+#ifndef __CONFIG_MT7621_RFB_H
+#define __CONFIG_MT7621_RFB_H
+
+#include "mt7621.h"
+
+/* Network */
+#define CONFIG_IPADDR			192.168.1.1
+#define CONFIG_SERVERIP			192.168.1.2
+#define CONFIG_NETMASK			255.255.255.0
+
+#endif /* __CONFIG_MT7621_RFB_H */
Signature · 1 line
2.17.1
Reviewed-by on v3 2/15
#3 lore raw

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

Quoted 417 lines · 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.

---
v3 changes: none
v2 changes:
Add config file for mt7621-rfb boards

---
  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          |  9 +++
  board/mediatek/mt7621/Makefile             |  3 +
  board/mediatek/mt7621/board.c              |  6 ++
  configs/mt7621_nand_rfb_ramboot_defconfig  | 72 +++++++++++++++++++++
  configs/mt7621_rfb_ramboot_defconfig       | 75 ++++++++++++++++++++++
  include/configs/mt7621-rfb.h               | 18 ++++++
  10 files changed, 325 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 create mode 100644 include/configs/mt7621-rfb.h

arch/mips/dts/Makefile +2 -0
index 95144b24dc..1b179116c9 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
new file mode 100644
index 0000000000..80870fe3f3
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 MediaTek Inc. All rights reserved.
+ *
+ * Author: Weijie Gao <[email protected]>
+ */
+
+/dts-v1/;
+
+#include "mt7621.dtsi"
+
+/ {
+	compatible = "mediatek,mt7621-nand-rfb", "mediatek,mt7621-soc";
+	model = "MediaTek MT7621 RFB (NAND)";
+
+	aliases {
+		serial0 = &uart0;
+	};
+
+	chosen {
+		stdout-path = &uart0;
+	};
+};
+
+&pinctrl {
+	state_default: pin_state {
+		nand {
+			groups = "spi", "sdxc";
+			function = "nand";
+		};
+	};
+};
+
+&uart0 {
+	status = "okay";
+};
+
+&gpio {
+	status = "okay";
+};
+
+&eth {
+	status = "okay";
+};
+
+&ssusb {
+	status = "okay";
+};
+
+&u3phy {
+	status = "okay";
+};
arch/mips/dts/mediatek,mt7621-rfb.dts new file +68 -0
new file mode 100644
index 0000000000..c8561548f5
@@ -0,0 +1,68 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 MediaTek Inc. All rights reserved.
+ *
+ * Author: Weijie Gao <[email protected]>
+ */
+
+/dts-v1/;
+
+#include "mt7621.dtsi"
+
+/ {
+	compatible = "mediatek,mt7621-rfb", "mediatek,mt7621-soc";
+	model = "MediaTek MT7621 RFB (SPI-NOR)";
+
+	aliases {
+		serial0 = &uart0;
+		spi0 = &spi;
+	};
+
+	chosen {
+		stdout-path = &uart0;
+	};
+};
+
+&pinctrl {
+	state_default: pin_state {
+	};
+};
+
+&uart0 {
+	status = "okay";
+};
+
+&gpio {
+	status = "okay";
+};
+
+&spi {
+	status = "okay";
+	num-cs = <2>;
+
+	spi-flash@0 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "jedec,spi-nor";
+		spi-max-frequency = <25000000>;
+		reg = <0>;
+	};
+};
+
+&eth {
+	status = "okay";
+};
+
+&mmc {
+	cap-sd-highspeed;
+
+	status = "okay";
+};
+
+&ssusb {
+	status = "okay";
+};
+
+&u3phy {
+	status = "okay";
+};
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 +9 -0
new file mode 100644
index 0000000000..add653b931
@@ -0,0 +1,9 @@
+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
+F:	include/configs/mt7621-rfb.h
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 +72 -0
new file mode 100644
index 0000000000..f5088ca629
@@ -0,0 +1,72 @@
+CONFIG_MIPS=y
+CONFIG_SYS_CONFIG_NAME="mt7621-rfb"
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_ENV_SIZE=0x1000
+CONFIG_SYS_MALLOC_LEN=0x100000
+CONFIG_DEFAULT_DEVICE_TREE="mediatek,mt7621-nand-rfb"
+CONFIG_DEBUG_UART_BASE=0xbe000c00
+CONFIG_DEBUG_UART_CLOCK=50000000
+CONFIG_ARCH_MTMIPS=y
+CONFIG_SOC_MT7621=y
+CONFIG_BOARD_MT7621_NAND_RFB=y
+# CONFIG_MIPS_CACHE_SETUP is not set
+# CONFIG_MIPS_CACHE_DISABLE is not set
+CONFIG_RESTORE_EXCEPTION_VECTOR_BASE=y
+CONFIG_SPL_INIT_STACK_WITHOUT_MALLOC_F=y
+CONFIG_MIPS_BOOT_FDT=y
+CONFIG_DEBUG_UART=y
+CONFIG_SYS_LOAD_ADDR=0x83000000
+CONFIG_FIT=y
+# CONFIG_ARCH_FIXUP_FDT_MEMORY is not set
+CONFIG_SYS_CONSOLE_INFO_QUIET=y
+# CONFIG_BOOTM_NETBSD is not set
+# CONFIG_BOOTM_PLAN9 is not set
+# CONFIG_BOOTM_RTEMS is not set
+# CONFIG_BOOTM_VXWORKS is not set
+# CONFIG_CMD_ELF is not set
+# CONFIG_CMD_XIMG is not set
+# CONFIG_CMD_CRC32 is not set
+# CONFIG_CMD_DM is not set
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_GPIO=y
+# CONFIG_CMD_LOADS is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_MTD=y
+CONFIG_CMD_PART=y
+# CONFIG_CMD_PINMUX is not set
+CONFIG_CMD_USB=y
+# CONFIG_CMD_NFS is not set
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+# CONFIG_ISO_PARTITION is not set
+CONFIG_EFI_PARTITION=y
+CONFIG_PARTITION_TYPE_GUID=y
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_NET_RANDOM_ETHADDR=y
+# CONFIG_I2C is not set
+# CONFIG_INPUT is not set
+CONFIG_MMC=y
+# CONFIG_MMC_QUIRKS is not set
+# CONFIG_MMC_HW_PARTITIONING is not set
+CONFIG_MMC_MTK=y
+CONFIG_MTD=y
+CONFIG_DM_MTD=y
+CONFIG_MTD_RAW_NAND=y
+CONFIG_NAND_MT7621=y
+CONFIG_SYS_NAND_ONFI_DETECTION=y
+CONFIG_MEDIATEK_ETH=y
+CONFIG_PHY=y
+CONFIG_PHY_MTK_TPHY=y
+CONFIG_SPECIFY_CONSOLE_INDEX=y
+CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_RESETCTL=y
+CONFIG_USB=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_MTK=y
+CONFIG_USB_STORAGE=y
+CONFIG_WDT=y
+CONFIG_WDT_MT7621=y
+CONFIG_FAT_WRITE=y
+CONFIG_LZMA=y
+CONFIG_SPL_LZMA=y
configs/mt7621_rfb_ramboot_defconfig new file +75 -0
new file mode 100644
index 0000000000..6f6bb52c9e
@@ -0,0 +1,75 @@
+CONFIG_MIPS=y
+CONFIG_SYS_CONFIG_NAME="mt7621-rfb"
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_ENV_SIZE=0x1000
+CONFIG_SYS_MALLOC_LEN=0x100000
+CONFIG_DEFAULT_DEVICE_TREE="mediatek,mt7621-rfb"
+CONFIG_DEBUG_UART_BASE=0xbe000c00
+CONFIG_DEBUG_UART_CLOCK=50000000
+CONFIG_ARCH_MTMIPS=y
+CONFIG_SOC_MT7621=y
+# CONFIG_MIPS_CACHE_SETUP is not set
+# CONFIG_MIPS_CACHE_DISABLE is not set
+CONFIG_RESTORE_EXCEPTION_VECTOR_BASE=y
+CONFIG_SPL_INIT_STACK_WITHOUT_MALLOC_F=y
+CONFIG_MIPS_BOOT_FDT=y
+CONFIG_DEBUG_UART=y
+CONFIG_SYS_LOAD_ADDR=0x83000000
+CONFIG_FIT=y
+# CONFIG_ARCH_FIXUP_FDT_MEMORY is not set
+CONFIG_SYS_CONSOLE_INFO_QUIET=y
+# CONFIG_BOOTM_NETBSD is not set
+# CONFIG_BOOTM_PLAN9 is not set
+# CONFIG_BOOTM_RTEMS is not set
+# CONFIG_BOOTM_VXWORKS is not set
+# CONFIG_CMD_ELF is not set
+# CONFIG_CMD_XIMG is not set
+# CONFIG_CMD_CRC32 is not set
+# CONFIG_CMD_DM is not set
+CONFIG_CMD_GPIO=y
+# CONFIG_CMD_LOADS is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_PART=y
+# CONFIG_CMD_PINMUX is not set
+CONFIG_CMD_SPI=y
+CONFIG_CMD_USB=y
+# CONFIG_CMD_NFS is not set
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+# CONFIG_ISO_PARTITION is not set
+CONFIG_EFI_PARTITION=y
+CONFIG_PARTITION_TYPE_GUID=y
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_NET_RANDOM_ETHADDR=y
+# CONFIG_I2C is not set
+# CONFIG_INPUT is not set
+CONFIG_MMC=y
+# CONFIG_MMC_QUIRKS is not set
+# CONFIG_MMC_HW_PARTITIONING is not set
+CONFIG_MMC_MTK=y
+CONFIG_SPI_FLASH_EON=y
+CONFIG_SPI_FLASH_GIGADEVICE=y
+CONFIG_SPI_FLASH_ISSI=y
+CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_SPI_FLASH_WINBOND=y
+CONFIG_SPI_FLASH_XMC=y
+CONFIG_MEDIATEK_ETH=y
+CONFIG_PHY=y
+CONFIG_PHY_MTK_TPHY=y
+CONFIG_SPECIFY_CONSOLE_INDEX=y
+CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_SPI=y
+CONFIG_MT7621_SPI=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_RESETCTL=y
+CONFIG_USB=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_MTK=y
+CONFIG_USB_STORAGE=y
+CONFIG_WDT=y
+CONFIG_WDT_MT7621=y
+CONFIG_FAT_WRITE=y
+CONFIG_LZMA=y
+CONFIG_SPL_LZMA=y
include/configs/mt7621-rfb.h new file +6 -0
new file mode 100644
index 0000000000..2287cb1103
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2021 MediaTek Inc. All Rights Reserved.
+ *
+ * Author: Weijie Gao <[email protected]>
+ */

include/configs/mt7621-rfb.h line 16

Quoted 10 lines
include/configs/mt7621-rfb.h new file +10 -0
+
+#ifndef __CONFIG_MT7621_RFB_H
+#define __CONFIG_MT7621_RFB_H
+
+#include "mt7621.h"
+
+/* Network */
+#define CONFIG_IPADDR			192.168.1.1
+#define CONFIG_SERVERIP			192.168.1.2
+#define CONFIG_NETMASK			255.255.255.0

Do you really need this? It's in general not recommended to add some hardcoded values here (anymore).

BTW: You might also want to update the copyright line to 2022.

Other than this:

Thanks,
Stefan

author
#4 lore raw

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

Quoted 453 lines · Stefan Roese
Quoted 452 lines · 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.

---
v3 changes: none
v2 changes:
Add config file for mt7621-rfb boards

---
  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          |  9 +++
  board/mediatek/mt7621/Makefile             |  3 +
  board/mediatek/mt7621/board.c              |  6 ++
  configs/mt7621_nand_rfb_ramboot_defconfig  | 72
+++++++++++++++++++++
  configs/mt7621_rfb_ramboot_defconfig       | 75
++++++++++++++++++++++
  include/configs/mt7621-rfb.h               | 18 ++++++
  10 files changed, 325 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 create mode 100644 include/configs/mt7621-rfb.h

arch/mips/dts/Makefile +0 -0
index 95144b24dc..1b179116c9 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

arch/mips/dts/Makefile +2 -0
+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 +13 -0
new file mode 100644
index 0000000000..80870fe3f3
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 MediaTek Inc. All rights reserved.
+ *
+ * Author: Weijie Gao <[email protected]>
+ */
+
+/dts-v1/;
+
+#include "mt7621.dtsi"
+
+/ {
+	compatible = "mediatek,mt7621-nand-rfb", "mediatek,mt7621-

soc";

arch/mips/dts/mediatek,mt7621-nand-rfb.dts new file +39 -0
+	model = "MediaTek MT7621 RFB (NAND)";
+
+	aliases {
+		serial0 = &uart0;
+	};
+
+	chosen {
+		stdout-path = &uart0;
+	};
+};
+
+&pinctrl {
+	state_default: pin_state {
+		nand {
+			groups = "spi", "sdxc";
+			function = "nand";
+		};
+	};
+};
+
+&uart0 {
+	status = "okay";
+};
+
+&gpio {
+	status = "okay";
+};
+
+&eth {
+	status = "okay";
+};
+
+&ssusb {
+	status = "okay";
+};
+
+&u3phy {
+	status = "okay";
+};
arch/mips/dts/mediatek,mt7621-rfb.dts new file +68 -0
new file mode 100644
index 0000000000..c8561548f5
@@ -0,0 +1,68 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 MediaTek Inc. All rights reserved.
+ *
+ * Author: Weijie Gao <[email protected]>
+ */
+
+/dts-v1/;
+
+#include "mt7621.dtsi"
+
+/ {
+	compatible = "mediatek,mt7621-rfb", "mediatek,mt7621-soc";
+	model = "MediaTek MT7621 RFB (SPI-NOR)";
+
+	aliases {
+		serial0 = &uart0;
+		spi0 = &spi;
+	};
+
+	chosen {
+		stdout-path = &uart0;
+	};
+};
+
+&pinctrl {
+	state_default: pin_state {
+	};
+};
+
+&uart0 {
+	status = "okay";
+};
+
+&gpio {
+	status = "okay";
+};
+
+&spi {
+	status = "okay";
+	num-cs = <2>;
+
+	spi-flash@0 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "jedec,spi-nor";
+		spi-max-frequency = <25000000>;
+		reg = <0>;
+	};
+};
+
+&eth {
+	status = "okay";
+};
+
+&mmc {
+	cap-sd-highspeed;
+
+	status = "okay";
+};
+
+&ssusb {
+	status = "okay";
+};
+
+&u3phy {
+	status = "okay";
+};
arch/mips/mach- renamed from arch/mips/mach-mtmips/mt7621/Kconfig +0 -0

mtmips/mt7621/Kconfig
index 6948bee31b..add1f4154b 100644

arch/mips/mach-mtmips/mt7621/Kconfig +4 -0
@@ -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.

arch/mips/mach-mtmips/mt7621/Kconfig +1 -0
+	  The board can be configured with DDR2 (64MiB~256MiB) or

DDR3

arch/mips/mach-mtmips/mt7621/Kconfig +1 -0
+	  (128MiB~512MiB). The board has 16 MiB SPI-NOR flash,

built-in MT7530

arch/mips/mach-mtmips/mt7621/Kconfig +1 -0
+	  GbE switch, 1 UART, 1 USB 2.0 host, 1 USB 3.0 host, 1

SDXC, 3 PCIe

arch/mips/mach-mtmips/mt7621/Kconfig +1 -0
+	  sockets, 1 RGMII to external GbE PHY, 2 audio jacks

(in/out),

arch/mips/mach-mtmips/mt7621/Kconfig +6 -0
+	  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.

arch/mips/mach-mtmips/mt7621/Kconfig +1 -0
+	  The board can be configured with DDR2 (64MiB~256MiB) or

DDR3

arch/mips/mach-mtmips/mt7621/Kconfig +1 -0
+	  (128MiB~512MiB). The board has 128 MiB parallel NAND

flash, built-in

arch/mips/mach-mtmips/mt7621/Kconfig +1 -0
+	  MT7530 GbE switch, 1 UART, 1 USB 2.0 host, 1 USB 3.0

host, 3 PCIe

arch/mips/mach-mtmips/mt7621/Kconfig +1 -0
+	  sockets, 1 RGMII to external GbE PHY, 2 audio jacks

(in/out),

arch/mips/mach-mtmips/mt7621/Kconfig +2 -0
+	  JTAG pins and expansion GPIO pins.
+
  endchoice
 
  config SYS_CONFIG_NAME
board/mediatek/mt7621/MAINTAINERS new file +9 -0
new file mode 100644
index 0000000000..add653b931
@@ -0,0 +1,9 @@
+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
+F:	include/configs/mt7621-rfb.h
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 +72 -0
new file mode 100644
index 0000000000..f5088ca629
@@ -0,0 +1,72 @@
+CONFIG_MIPS=y
+CONFIG_SYS_CONFIG_NAME="mt7621-rfb"
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_ENV_SIZE=0x1000
+CONFIG_SYS_MALLOC_LEN=0x100000
+CONFIG_DEFAULT_DEVICE_TREE="mediatek,mt7621-nand-rfb"
+CONFIG_DEBUG_UART_BASE=0xbe000c00
+CONFIG_DEBUG_UART_CLOCK=50000000
+CONFIG_ARCH_MTMIPS=y
+CONFIG_SOC_MT7621=y
+CONFIG_BOARD_MT7621_NAND_RFB=y
+# CONFIG_MIPS_CACHE_SETUP is not set
+# CONFIG_MIPS_CACHE_DISABLE is not set
+CONFIG_RESTORE_EXCEPTION_VECTOR_BASE=y
+CONFIG_SPL_INIT_STACK_WITHOUT_MALLOC_F=y
+CONFIG_MIPS_BOOT_FDT=y
+CONFIG_DEBUG_UART=y
+CONFIG_SYS_LOAD_ADDR=0x83000000
+CONFIG_FIT=y
+# CONFIG_ARCH_FIXUP_FDT_MEMORY is not set
+CONFIG_SYS_CONSOLE_INFO_QUIET=y
+# CONFIG_BOOTM_NETBSD is not set
+# CONFIG_BOOTM_PLAN9 is not set
+# CONFIG_BOOTM_RTEMS is not set
+# CONFIG_BOOTM_VXWORKS is not set
+# CONFIG_CMD_ELF is not set
+# CONFIG_CMD_XIMG is not set
+# CONFIG_CMD_CRC32 is not set
+# CONFIG_CMD_DM is not set
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_GPIO=y
+# CONFIG_CMD_LOADS is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_MTD=y
+CONFIG_CMD_PART=y
+# CONFIG_CMD_PINMUX is not set
+CONFIG_CMD_USB=y
+# CONFIG_CMD_NFS is not set
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+# CONFIG_ISO_PARTITION is not set
+CONFIG_EFI_PARTITION=y
+CONFIG_PARTITION_TYPE_GUID=y
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_NET_RANDOM_ETHADDR=y
+# CONFIG_I2C is not set
+# CONFIG_INPUT is not set
+CONFIG_MMC=y
+# CONFIG_MMC_QUIRKS is not set
+# CONFIG_MMC_HW_PARTITIONING is not set
+CONFIG_MMC_MTK=y
+CONFIG_MTD=y
+CONFIG_DM_MTD=y
+CONFIG_MTD_RAW_NAND=y
+CONFIG_NAND_MT7621=y
+CONFIG_SYS_NAND_ONFI_DETECTION=y
+CONFIG_MEDIATEK_ETH=y
+CONFIG_PHY=y
+CONFIG_PHY_MTK_TPHY=y
+CONFIG_SPECIFY_CONSOLE_INDEX=y
+CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_RESETCTL=y
+CONFIG_USB=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_MTK=y
+CONFIG_USB_STORAGE=y
+CONFIG_WDT=y
+CONFIG_WDT_MT7621=y
+CONFIG_FAT_WRITE=y
+CONFIG_LZMA=y
+CONFIG_SPL_LZMA=y
configs/mt7621_rfb_ramboot_defconfig new file +75 -0
new file mode 100644
index 0000000000..6f6bb52c9e
@@ -0,0 +1,75 @@
+CONFIG_MIPS=y
+CONFIG_SYS_CONFIG_NAME="mt7621-rfb"
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_ENV_SIZE=0x1000
+CONFIG_SYS_MALLOC_LEN=0x100000
+CONFIG_DEFAULT_DEVICE_TREE="mediatek,mt7621-rfb"
+CONFIG_DEBUG_UART_BASE=0xbe000c00
+CONFIG_DEBUG_UART_CLOCK=50000000
+CONFIG_ARCH_MTMIPS=y
+CONFIG_SOC_MT7621=y
+# CONFIG_MIPS_CACHE_SETUP is not set
+# CONFIG_MIPS_CACHE_DISABLE is not set
+CONFIG_RESTORE_EXCEPTION_VECTOR_BASE=y
+CONFIG_SPL_INIT_STACK_WITHOUT_MALLOC_F=y
+CONFIG_MIPS_BOOT_FDT=y
+CONFIG_DEBUG_UART=y
+CONFIG_SYS_LOAD_ADDR=0x83000000
+CONFIG_FIT=y
+# CONFIG_ARCH_FIXUP_FDT_MEMORY is not set
+CONFIG_SYS_CONSOLE_INFO_QUIET=y
+# CONFIG_BOOTM_NETBSD is not set
+# CONFIG_BOOTM_PLAN9 is not set
+# CONFIG_BOOTM_RTEMS is not set
+# CONFIG_BOOTM_VXWORKS is not set
+# CONFIG_CMD_ELF is not set
+# CONFIG_CMD_XIMG is not set
+# CONFIG_CMD_CRC32 is not set
+# CONFIG_CMD_DM is not set
+CONFIG_CMD_GPIO=y
+# CONFIG_CMD_LOADS is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_PART=y
+# CONFIG_CMD_PINMUX is not set
+CONFIG_CMD_SPI=y
+CONFIG_CMD_USB=y
+# CONFIG_CMD_NFS is not set
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+# CONFIG_ISO_PARTITION is not set
+CONFIG_EFI_PARTITION=y
+CONFIG_PARTITION_TYPE_GUID=y
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_NET_RANDOM_ETHADDR=y
+# CONFIG_I2C is not set
+# CONFIG_INPUT is not set
+CONFIG_MMC=y
+# CONFIG_MMC_QUIRKS is not set
+# CONFIG_MMC_HW_PARTITIONING is not set
+CONFIG_MMC_MTK=y
+CONFIG_SPI_FLASH_EON=y
+CONFIG_SPI_FLASH_GIGADEVICE=y
+CONFIG_SPI_FLASH_ISSI=y
+CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_SPI_FLASH_WINBOND=y
+CONFIG_SPI_FLASH_XMC=y
+CONFIG_MEDIATEK_ETH=y
+CONFIG_PHY=y
+CONFIG_PHY_MTK_TPHY=y
+CONFIG_SPECIFY_CONSOLE_INDEX=y
+CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_SPI=y
+CONFIG_MT7621_SPI=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_RESETCTL=y
+CONFIG_USB=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_MTK=y
+CONFIG_USB_STORAGE=y
+CONFIG_WDT=y
+CONFIG_WDT_MT7621=y
+CONFIG_FAT_WRITE=y
+CONFIG_LZMA=y
+CONFIG_SPL_LZMA=y
include/configs/mt7621- renamed from include/configs/mt7621-rfb.h +0 -0

rfb.h
new file mode 100644
index 0000000000..2287cb1103

include/configs/mt7621-rfb.h new file +11 -0
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2021 MediaTek Inc. All Rights Reserved.
+ *
+ * Author: Weijie Gao <[email protected]>
+ */
+
+#ifndef __CONFIG_MT7621_RFB_H
+#define __CONFIG_MT7621_RFB_H
+
+#include "mt7621.h"
Quoted 8 lines

include/configs/mt7621-rfb.h line 16

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

Do you really need this? It's in general not recommended to add some hardcoded values here (anymore).

OK. I'll remove this file and use mt7621.h instead.

Quoted 2 lines

BTW: You might also want to update the copyright line to 2022.

I'll update it for all new files.

Quoted 7 lines

Other than this:

Thanks,
Stefan

author
#5 lore raw

PATCH v3 3/15 mips: add support for noncached_alloc()

In reply to Weijie Gao

This patch adds support for noncached_alloc() which was only supported by ARM platform.

Unlike the ARM platform, MMU is not used in u-boot for MIPS. Instead, KSEG is provided to access uncached memory. So most code of this patch is copied from cache.c of ARM platform, with only two differences:
1. MMU is untouched in noncached_set_region()
2. Address returned by noncached_alloc() is converted using KSEG1ADDR()

---
v3 changes: new

---
 arch/mips/include/asm/system.h | 20 ++++++++++++++++
 arch/mips/lib/cache.c          | 43 ++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+)
arch/mips/include/asm/system.h +20 -0
index 79e638844b..89a2ac209f 100644
@@ -282,4 +282,24 @@ static inline void instruction_hazard_barrier(void)
 	: "=&r"(tmp));
 }
 
+#ifdef CONFIG_SYS_NONCACHED_MEMORY
+/* 1MB granularity */
+#define MMU_SECTION_SHIFT	20
+#define MMU_SECTION_SIZE	(1 << MMU_SECTION_SHIFT)
+
+/**
+ * noncached_init() - Initialize non-cached memory region
+ *
+ * Initialize non-cached memory area. This memory region will be typically
+ * located right below the malloc() area and be accessed from KSEG1.
+ *
+ * It is called during the generic post-relocation init sequence.
+ *
+ * Return: 0 if OK
+ */
+int noncached_init(void);
+
+phys_addr_t noncached_alloc(size_t size, size_t align);
+#endif /* CONFIG_SYS_NONCACHED_MEMORY */
+
 #endif /* _ASM_SYSTEM_H */
arch/mips/lib/cache.c +43 -0

52 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#6 lore raw

PATCH v3 4/15 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.

---
v3 changes: update clock definitions to match upstream kernel v2 changes: none

---
 drivers/clk/mtmips/Makefile            |   1 +
 drivers/clk/mtmips/clk-mt7621.c        | 313 +++++++++++++++++++++++++
 include/dt-bindings/clock/mt7621-clk.h |  46 ++++
 3 files changed, 360 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 +313 -0

313 lines not on this page · raw message

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

46 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#7 lore raw

PATCH v3 5/15 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

---
v3 changes: none
v2 changes: none

---
 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 v3 6/15 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.

---
v3 changes: none
v2 changes: none

---
 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 v3 7/15 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.

---
v3 changes: none
v2 changes: none

---
 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 d75f371c95..763e16976d 100644
@@ -521,6 +521,17 @@ config TEGRA_NAND
 	help
 	  Enables support for NAND Flash chips on Tegra SoCs platforms.
 
+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 v3 8/15 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

---
v3 changes: none
v2 changes: none

---
 drivers/usb/host/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/Kconfig +1 -1
index 8f77412cc7..8f7bfe1602 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 v3 9/15 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

---
v3 changes: none
v2 changes: none

---
 drivers/phy/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/Kconfig +1 -1
index c01d9e09b9..1708d4f533 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 v3 10/15 spi: add support for MediaTek MT7621 SoC

In reply to Weijie Gao

This patch makes mt7621_spi driver available for MediaTek MT7621 SoC

---
v3 changes: none
v2 changes: none

---
 drivers/spi/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/Kconfig +1 -1
index 8dba95ae4e..d88c43031f 100644
@@ -240,7 +240,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 v3 11/15 gpio: add support for MediaTek MT7621 SoC

In reply to Weijie Gao

This patch makes mt7621_gpio driver available for MediaTek MT7621 SoC

---
v3 changes: none
v2 changes: none

---
 drivers/gpio/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/Kconfig +1 -1
index 89068c7800..f4e41c765e 100644
@@ -534,7 +534,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
#14 lore raw

PATCH v3 12/15 watchdog: add support for MediaTek MT7621 SoC

In reply to Weijie Gao

This patch makes mt7621_wdt driver available for MediaTek MT7621 SoC

---
v3 changes: none
v2 changes: none

---
 drivers/watchdog/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/Kconfig +1 -1
index 03e8e72e6b..c63a40e2f9 100644
@@ -184,7 +184,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
#15 lore raw

PATCH v3 13/15 mmc: mediatek: add support for MediaTek MT7621 SoC

In reply to Weijie Gao

This patch adds SDXC support for MediaTek MT7621 SoC

---
v3 changes: none
v2 changes: none

---
 drivers/mmc/mtk-sd.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/mmc/mtk-sd.c +13 -0
index 97182ffd7f..e61e8cf4b9 100644
@@ -1761,6 +1761,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,
@@ -1809,6 +1821,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
#16 lore raw

PATCH v3 14/15 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.

---
v3 changes:
Add register remap needed by mt7621
Fix use of noncached_alloc
v2 changes: none

---
 drivers/net/mtk_eth.c | 45 ++++++++++++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 18 deletions(-)
drivers/net/mtk_eth.c +27 -18
index 666ddeb10d..4fe7ee0d36 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 {
@@ -159,9 +160,10 @@ struct mtk_eth_priv {
 
 	void __iomem *fe_base;
 	void __iomem *gmac_base;
-	void __iomem *ethsys_base;
 	void __iomem *sgmii_base;
 
+	struct regmap *ethsys_regmap;
+
 	struct mii_dev *mdio_bus;
 	int (*mii_read)(struct mtk_eth_priv *priv, u8 phy, u8 reg);
 	int (*mii_write)(struct mtk_eth_priv *priv, u8 phy, u8 reg, u16 val);
@@ -233,7 +235,12 @@ static void mtk_gmac_rmw(struct mtk_eth_priv *priv, u32 reg, u32 clr, u32 set)
 static void mtk_ethsys_rmw(struct mtk_eth_priv *priv, u32 reg, u32 clr,
 			   u32 set)
 {
-	clrsetbits_le32(priv->ethsys_base + reg, clr, set);
+	uint val;
+
+	regmap_read(priv->ethsys_regmap, reg, &val);
+	val &= ~clr;
+	val |= set;
+	regmap_write(priv->ethsys_regmap, reg, val);
 }
 
 /* Direct MDIO clause 22/45 access via SoC */
@@ -669,12 +676,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 +745,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);
@@ -1419,7 +1433,7 @@ static int mtk_eth_of_to_plat(struct udevice *dev)
 
 	priv->soc = dev_get_driver_data(dev);
 
-	pdata->iobase = dev_read_addr(dev);
+	pdata->iobase = (phys_addr_t)dev_remap_addr(dev);
 
 	/* get corresponding ethsys phandle */
 	ret = dev_read_phandle_with_args(dev, "mediatek,ethsys", NULL, 0, 0,
@@ -1427,15 +1441,9 @@ static int mtk_eth_of_to_plat(struct udevice *dev)
 	if (ret)
 		return ret;
 
-	regmap = syscon_node_to_regmap(args.node);
-	if (IS_ERR(regmap))
-		return PTR_ERR(regmap);
-
-	priv->ethsys_base = regmap_get_range(regmap, 0);
-	if (!priv->ethsys_base) {
-		dev_err(dev, "Unable to find ethsys\n");
-		return -ENODEV;
-	}
+	priv->ethsys_regmap = syscon_node_to_regmap(args.node);
+	if (IS_ERR(priv->ethsys_regmap))
+		return PTR_ERR(priv->ethsys_regmap);
 
 	/* Reset controllers */
 	ret = reset_get_by_name(dev, "fe", &priv->rst_fe);
@@ -1540,6 +1548,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 },
 	{}
 };
 
Signature · 1 line
2.17.1
#17 lore raw

Re: [PATCH v3 14/15] net: mediatek: add support for MediaTek MT7621 SoC

Quoted 42 lines · Weijie Gao

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

---
v3 changes:
Add register remap needed by mt7621
Fix use of noncached_alloc
v2 changes: none

---
 drivers/net/mtk_eth.c | 45 ++++++++++++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 18 deletions(-)
drivers/net/mtk_eth.c +4 -2
index 666ddeb10d..4fe7ee0d36 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 {
@@ -159,9 +160,10 @@ struct mtk_eth_priv {
 
        void __iomem *fe_base;
        void __iomem *gmac_base;
-       void __iomem *ethsys_base;
        void __iomem *sgmii_base;
 
+       struct regmap *ethsys_regmap;
+
        struct mii_dev *mdio_bus;
        int (*mii_read)(struct mtk_eth_priv *priv, u8 phy, u8 reg);
        int (*mii_write)(struct mtk_eth_priv *priv, u8 phy, u8 reg, u16 val);
@@ -233,7 +235,12 @@ static void mtk_gmac_rmw(struct mtk_eth_priv *priv, u32 reg, u32 clr, u32 set)
 static void mtk_ethsys_rmw(struct mtk_eth_priv *priv, u32 reg, u32 clr,

drivers/net/mtk_eth.c static void mtk_gmac_rmw(struct mtk_eth_priv *priv, u32 reg, u32 clr, u32 set) · line 244

Quoted 10 lines
drivers/net/mtk_eth.c +6 -1
                           u32 set)
 {
-       clrsetbits_le32(priv->ethsys_base + reg, clr, set);
+       uint val;
+
+       regmap_read(priv->ethsys_regmap, reg, &val);
+       val &= ~clr;
+       val |= set;
+       regmap_write(priv->ethsys_regmap, reg, val);
 }

Changing the registers to regmap is not part of the support for the MT7621. please separate into two patches.

Quoted 36 lines
drivers/net/mtk_eth.c +12 -5
 /* Direct MDIO clause 22/45 access via SoC */
@@ -669,12 +676,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 +745,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);

drivers/net/mtk_eth.c static int mtk_eth_of_to_plat(struct udevice *dev) · line 1436

Quoted 5 lines
drivers/net/mtk_eth.c +1 -1
@@ -1419,7 +1433,7 @@ static int mtk_eth_of_to_plat(struct udevice *dev)
 
        priv->soc = dev_get_driver_data(dev);
 
-       pdata->iobase = dev_read_addr(dev);
+       pdata->iobase = (phys_addr_t)dev_remap_addr(dev);

This also needs a patch of it's own.

Quoted 33 lines
drivers/net/mtk_eth.c +4 -10
        /* get corresponding ethsys phandle */
        ret = dev_read_phandle_with_args(dev, "mediatek,ethsys", NULL, 0, 0,
@@ -1427,15 +1441,9 @@ static int mtk_eth_of_to_plat(struct udevice *dev)
        if (ret)
                return ret;
 
-       regmap = syscon_node_to_regmap(args.node);
-       if (IS_ERR(regmap))
-               return PTR_ERR(regmap);
-
-       priv->ethsys_base = regmap_get_range(regmap, 0);
-       if (!priv->ethsys_base) {
-               dev_err(dev, "Unable to find ethsys\n");
-               return -ENODEV;
-       }
+       priv->ethsys_regmap = syscon_node_to_regmap(args.node);
+       if (IS_ERR(priv->ethsys_regmap))
+               return PTR_ERR(priv->ethsys_regmap);
 
        /* Reset controllers */
        ret = reset_get_by_name(dev, "fe", &priv->rst_fe);
@@ -1540,6 +1548,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 },
        {}
 };
 
--

2.17.1

author
#18 lore raw

Re: [PATCH v3 14/15] net: mediatek: add support for MediaTek MT7621 SoC

Quoted 53 lines · Ramon Fried
Quoted 51 lines · Weijie Gao

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

---
v3 changes:
Add register remap needed by mt7621
Fix use of noncached_alloc
v2 changes: none

---
 drivers/net/mtk_eth.c | 45 ++++++++++++++++++++++++++-------------
----
 1 file changed, 27 insertions(+), 18 deletions(-)
drivers/net/mtk_eth.c +4 -2
index 666ddeb10d..4fe7ee0d36 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 {
@@ -159,9 +160,10 @@ struct mtk_eth_priv {
 
        void __iomem *fe_base;
        void __iomem *gmac_base;
-       void __iomem *ethsys_base;
        void __iomem *sgmii_base;
 
+       struct regmap *ethsys_regmap;
+
        struct mii_dev *mdio_bus;
        int (*mii_read)(struct mtk_eth_priv *priv, u8 phy, u8 reg);
        int (*mii_write)(struct mtk_eth_priv *priv, u8 phy, u8 reg,

u16 val);

drivers/net/mtk_eth.c +2 -1
@@ -233,7 +235,12 @@ static void mtk_gmac_rmw(struct mtk_eth_priv
 *priv, u32 reg, u32 clr, u32 set)
 static void mtk_ethsys_rmw(struct mtk_eth_priv *priv, u32 reg, u32
 clr,
                           u32 set)
 {
-       clrsetbits_le32(priv->ethsys_base + reg, clr, set);
+       uint val;
+
Quoted 8 lines

drivers/net/mtk_eth.c static void mtk_gmac_rmw(struct mtk_eth_priv *priv, u32 reg, u32 clr, u32 set) · line 244

Quoted 5 lines
drivers/net/mtk_eth.c +4 -0
+       regmap_read(priv->ethsys_regmap, reg, &val);
+       val &= ~clr;
+       val |= set;
+       regmap_write(priv->ethsys_regmap, reg, val);
 }

Changing the registers to regmap is not part of the support for the MT7621. please separate into two patches.

OK. I'll split this into three patches.

Quoted 89 lines
Quoted 41 lines

/* Direct MDIO clause 22/45 access via SoC */

drivers/net/mtk_eth.c +10 -4
@@ -669,12 +676,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);
drivers/net/mtk_eth.c +2 -1
@@ -732,7 +745,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);

drivers/net/mtk_eth.c static int mtk_eth_of_to_plat(struct udevice · line 1437

Quoted 6 lines
drivers/net/mtk_eth.c +1 -1
@@ -1419,7 +1433,7 @@ static int mtk_eth_of_to_plat(struct udevice
 *dev)
 
        priv->soc = dev_get_driver_data(dev);
 
-       pdata->iobase = dev_read_addr(dev);
+       pdata->iobase = (phys_addr_t)dev_remap_addr(dev);

This also needs a patch of it's own.

Quoted 40 lines
drivers/net/mtk_eth.c +0 -0
        /* get corresponding ethsys phandle */
        ret = dev_read_phandle_with_args(dev, "mediatek,ethsys",

NULL, 0, 0,

drivers/net/mtk_eth.c +3 -9
@@ -1427,15 +1441,9 @@ static int mtk_eth_of_to_plat(struct udevice
 *dev)
        if (ret)
                return ret;
 
-       regmap = syscon_node_to_regmap(args.node);
-       if (IS_ERR(regmap))
-               return PTR_ERR(regmap);
-
-       priv->ethsys_base = regmap_get_range(regmap, 0);
-       if (!priv->ethsys_base) {
-               dev_err(dev, "Unable to find ethsys\n");
-               return -ENODEV;
-       }
+       priv->ethsys_regmap = syscon_node_to_regmap(args.node);
+       if (IS_ERR(priv->ethsys_regmap))
+               return PTR_ERR(priv->ethsys_regmap);
 
        /* Reset controllers */
        ret = reset_get_by_name(dev, "fe", &priv->rst_fe);
drivers/net/mtk_eth.c +0 -0
@@ -1540,6 +1548,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
},

        {}

};

--
2.17.1

author
#19 lore raw

PATCH v3 15/15 MAINTAINERS: update maintainer for MediaTek MIPS platform

In reply to Weijie Gao

Update maintainer for MediaTek MIPS platform

---
v3 changes: none
v2 changes: none

---
 MAINTAINERS | 5 +++++
 1 file changed, 5 insertions(+)
MAINTAINERS +5 -0
index 56be0bfad0..80250b41e8 100644
@@ -995,15 +995,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
#20 lore raw
In reply to Weijie Gao
Quoted 6 lines · On Thu, 28 Apr 2022 18:37:09 +0800 Weijie Gao <[email protected]> wrote:

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.

Hello Weijie,

doesn't MT7621 U-Boot need a proprietary binary for DDR training? I remember that it was required in 2016 for MqMaker WitiBoard.

Marek

author
#21 lore raw

Hi Marek,

Yes. MT7621 does need such a proprietary binary for DDR initialization and calibration. That's why I submit only the ram-bootable part here.

I'm considering to create a preloader to load and run DDR init&calib
binary and ram-bootable u-boot image. The ram-bootable u-boot image can be appended to the proloader to form the flash-bootable bootloader.

The source code of preloader will be uploaded to github.

Best Regards,
Weijie

Quoted 18 lines · Marek Behún
Quoted 8 lines · On Thu, 28 Apr 2022 18:37:09 +0800 Weijie Gao <[email protected]> wrote:

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.

Hello Weijie,

doesn't MT7621 U-Boot need a proprietary binary for DDR training? I remember that it was required in 2016 for MqMaker WitiBoard.

Marek

#22 lore raw

Hi Weijie

Quoted 9 lines · Weijie Gao

Hi Marek,

Yes. MT7621 does need such a proprietary binary for DDR initialization and calibration. That's why I submit only the ram-bootable part here.

I'm considering to create a preloader to load and run DDR init&calib
binary and ram-bootable u-boot image. The ram-bootable u-boot image can be appended to the proloader to form the flash-bootable bootloader.

The source code of preloader will be uploaded to github.

Just to be sure: You are not implementing this preloader as an U-Boot SPL loader, as this would conflict with U-Boot's GPL compatibility?

Thanks,
Stefan

Quoted 22 lines

Best Regards,
Weijie

Quoted 18 lines · Marek Behún
Quoted 8 lines · On Thu, 28 Apr 2022 18:37:09 +0800 Weijie Gao <[email protected]> wrote:

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.

Hello Weijie,

doesn't MT7621 U-Boot need a proprietary binary for DDR training? I remember that it was required in 2016 for MqMaker WitiBoard.

Marek

Viele Grüße,
Stefan Roese

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]
author
#23 lore raw
Quoted 16 lines · Stefan Roese

Hi Weijie

Quoted 13 lines · Weijie Gao

Hi Marek,

Yes. MT7621 does need such a proprietary binary for DDR initialization
and calibration. That's why I submit only the ram-bootable part here.

I'm considering to create a preloader to load and run DDR init&calib
binary and ram-bootable u-boot image. The ram-bootable u-boot image can be appended to the proloader to form the flash-bootable bootloader.

Quoted 4 lines
Quoted 1 line

The source code of preloader will be uploaded to github.

Just to be sure: You are not implementing this preloader as an U-Boot SPL loader, as this would conflict with U-Boot's GPL compatibility?

Yes. Submitting the source code of this binary also violates MTK's non- disclosure agreement.

Quoted 32 lines

Thanks,
Stefan

Quoted 24 lines

Best Regards,
Weijie

Quoted 20 lines · Marek Behún
Quoted 10 lines · On Thu, 28 Apr 2022 18:37:09 +0800 Weijie Gao <[email protected]> wrote:

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.

Hello Weijie,

doesn't MT7621 U-Boot need a proprietary binary for DDR training? I remember that it was required in 2016 for MqMaker WitiBoard.

Marek

Viele Grüße,
Stefan Roese

#24 lore raw
Quoted 17 lines · On Fri, 29 Apr 2022 15:59:44 +0800 Weijie Gao <[email protected]> wrote:
Quoted 16 lines · Stefan Roese

Hi Weijie

Quoted 13 lines · Weijie Gao

Hi Marek,

Yes. MT7621 does need such a proprietary binary for DDR initialization
and calibration. That's why I submit only the ram-bootable part here.

I'm considering to create a preloader to load and run DDR init&calib
binary and ram-bootable u-boot image. The ram-bootable u-boot image can be appended to the proloader to form the flash-bootable bootloader.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

The source code of preloader will be uploaded to github.

Just to be sure: You are not implementing this preloader as an U-Boot SPL loader, as this would conflict with U-Boot's GPL compatibility?

Yes. Submitting the source code of this binary also violates MTK's non- disclosure agreement.

Isn't it possible to submit the DDR training code in binary version, and somehow call into it from SPL?

Marek

author
#25 lore raw
Quoted 28 lines · Marek Behún
Quoted 25 lines · On Fri, 29 Apr 2022 15:59:44 +0800 Weijie Gao <[email protected]> wrote:
Quoted 23 lines · Stefan Roese

Hi Weijie

Quoted 7 lines · Weijie Gao

Hi Marek,

Yes. MT7621 does need such a proprietary binary for DDR initialization
and calibration. That's why I submit only the ram-bootable part here.

Quoted 8 lines

I'm considering to create a preloader to load and run DDR init&calib
binary and ram-bootable u-boot image. The ram-bootable u-boot image
can be appended to the proloader to form the flash-bootable bootloader.

The source code of preloader will be uploaded to github.

Just to be sure: You are not implementing this preloader as an U- Boot
SPL loader, as this would conflict with U-Boot's GPL compatibility?

Quoted 6 lines
Quoted 3 lines

Yes. Submitting the source code of this binary also violates MTK's non-
disclosure agreement.

Isn't it possible to submit the DDR training code in binary version, and somehow call into it from SPL?

It's possible and I've already implemented it. But will u-boot accept binary file?

Quoted 2 lines

Marek

#26 lore raw
Quoted 33 lines · On Sat, 30 Apr 2022 21:31:15 +0800 Weijie Gao <[email protected]> wrote:
Quoted 32 lines · Marek Behún
Quoted 28 lines · On Fri, 29 Apr 2022 15:59:44 +0800 Weijie Gao <[email protected]> wrote:
Quoted 17 lines · Stefan Roese

Hi Weijie

Quoted 14 lines · Weijie Gao

Hi Marek,

Yes. MT7621 does need such a proprietary binary for DDR initialization
and calibration. That's why I submit only the ram-bootable part here.

I'm considering to create a preloader to load and run DDR init&calib
binary and ram-bootable u-boot image. The ram-bootable u-boot image
can be appended to the proloader to form the flash-bootable bootloader.

Quoted 6 lines
Quoted 1 line

The source code of preloader will be uploaded to github.

Just to be sure: You are not implementing this preloader as an U- Boot
SPL loader, as this would conflict with U-Boot's GPL compatibility?

Yes. Submitting the source code of this binary also violates MTK's non-
disclosure agreement.

Quoted 5 lines
Quoted 2 lines

Isn't it possible to submit the DDR training code in binary version, and somehow call into it from SPL?

It's possible and I've already implemented it. But will u-boot accept binary file?

U-Boot at least accepts drivers that require proprietary firmware to load (bnxt driver, for example).

I don't know whether a binary firmware can be accepted into the U-Boot repository, whether in a separate file or as an u8 array in a .c file, but it should at least be possible to make it so that the user can compile it thsemsevles to be bundled, i.e. create a Kconfig option that configures a path to the firmware. If it is present, it will be compiled with DDR training bundled.

Stefan, Tom, can this be done?

BTW, Weijie, can I already test this on mt7621 board, also with DDR training? Can you send me the patch that adds calling the proprietary code?

Marek

#27 lore raw
Quoted 52 lines · Marek Behún
Quoted 33 lines · On Sat, 30 Apr 2022 21:31:15 +0800 Weijie Gao <[email protected]> wrote:
Quoted 32 lines · Marek Behún
Quoted 28 lines · On Fri, 29 Apr 2022 15:59:44 +0800 Weijie Gao <[email protected]> wrote:
Quoted 17 lines · Stefan Roese

Hi Weijie

Quoted 14 lines · Weijie Gao

Hi Marek,

Yes. MT7621 does need such a proprietary binary for DDR initialization
and calibration. That's why I submit only the ram-bootable part here.

I'm considering to create a preloader to load and run DDR init&calib
binary and ram-bootable u-boot image. The ram-bootable u-boot image
can be appended to the proloader to form the flash-bootable bootloader.

Quoted 6 lines
Quoted 1 line

The source code of preloader will be uploaded to github.

Just to be sure: You are not implementing this preloader as an U- Boot
SPL loader, as this would conflict with U-Boot's GPL compatibility?

Yes. Submitting the source code of this binary also violates MTK's non-
disclosure agreement.

Quoted 5 lines
Quoted 2 lines

Isn't it possible to submit the DDR training code in binary version, and somehow call into it from SPL?

It's possible and I've already implemented it. But will u-boot accept binary file?

U-Boot at least accepts drivers that require proprietary firmware to load (bnxt driver, for example).

I don't know whether a binary firmware can be accepted into the U-Boot repository, whether in a separate file or as an u8 array in a .c file, but it should at least be possible to make it so that the user can compile it thsemsevles to be bundled, i.e. create a Kconfig option that configures a path to the firmware. If it is present, it will be compiled with DDR training bundled.

Quoted 5 lines

Stefan, Tom, can this be done?

BTW, Weijie, can I already test this on mt7621 board, also with DDR training? Can you send me the patch that adds calling the proprietary code?

At the high level, I would make a further disappointed sigh and note the NXP ddr firmware blobs, the binary blobs we pull in for x86, and all of the other blobs we bring in today via binman. Please make use of one of these otherwise existing mechanics to bring in the required DDR blobs here.

Signature · 1 line
Tom
author
#28 lore raw
Quoted 72 lines · Tom Rini
Quoted 64 lines · Marek Behún
Quoted 39 lines · On Sat, 30 Apr 2022 21:31:15 +0800 Weijie Gao <[email protected]> wrote:
Quoted 38 lines · Marek Behún
Quoted 34 lines · On Fri, 29 Apr 2022 15:59:44 +0800 Weijie Gao <[email protected]> wrote:
Quoted 20 lines · Stefan Roese

Hi Weijie

Quoted 17 lines · Weijie Gao

Hi Marek,

Yes. MT7621 does need such a proprietary binary for DDR initialization
and calibration. That's why I submit only the ram- bootable part
here.

I'm considering to create a preloader to load and run DDR init&calib
binary and ram-bootable u-boot image. The ram-bootable u- boot
image
can be appended to the proloader to form the flash- bootable
bootloader.

Quoted 8 lines
Quoted 2 lines

The source code of preloader will be uploaded to
github.

Just to be sure: You are not implementing this preloader as an U-
Boot
SPL loader, as this would conflict with U-Boot's GPL compatibility?

Yes. Submitting the source code of this binary also violates MTK's
non-
disclosure agreement.

Quoted 7 lines
Quoted 3 lines

Isn't it possible to submit the DDR training code in binary version,
and somehow call into it from SPL?

It's possible and I've already implemented it. But will u-boot accept
binary file?

U-Boot at least accepts drivers that require proprietary firmware to
load (bnxt driver, for example).

I don't know whether a binary firmware can be accepted into the U- Boot
repository, whether in a separate file or as an u8 array in a .c file,
but it should at least be possible to make it so that the user can compile it thsemsevles to be bundled, i.e. create a Kconfig option that
configures a path to the firmware. If it is present, it will be compiled with DDR training bundled.

Quoted 6 lines

Stefan, Tom, can this be done?

BTW, Weijie, can I already test this on mt7621 board, also with DDR training? Can you send me the patch that adds calling the proprietary
code?

Quoted 9 lines

At the high level, I would make a further disappointed sigh and note the
NXP ddr firmware blobs, the binary blobs we pull in for x86, and all of
the other blobs we bring in today via binman. Please make use of one of
these otherwise existing mechanics to bring in the required DDR blobs here.

At lease there are ways to achieve this. Thanks for the note.