Skip to contentSkip to conversation

Add support for MediaTek MT7620 SoC - v4

PATCH New Weijie Gao 2 participants 30 messages Nov 12, 2020 – Jan 21, 2021

Subsystems (13)
lore
Share & tools
lore

Weijie Gao

author
#0 lore raw

v4 cover Add support for MediaTek MT7620 SoC - v4

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

The MediaTek MT7620 is a 2x2 802.11n WiSoC integrating a MIPS 24KEc processor running at a maximum frequency of 620MHz. This chip can be found in many wireless routers.

This series add all basic drivers which are useful in u-boot, like usb, sdhc, ethernet, spi and serial. Booting from NAND is currently unsupported.

Thanks,
Weijie

v4 changes:
- Remove unused code in drivers/serial/serial.c
- Fix plat->cfg.f_max of mtk-sd driver

v3 changes:
- Use bool instead of int in for mt7620_spi_set_cs() mt7620_spi.c
- Add detail comments for mt7620_wdt_expire_now() in mt7620_wdt.c
- Remove duplicated dev field in mt7620-usb-phy.c
- Add fixes for mtk-sd (fix sclk cycles shift value, assign plat->cfg.f_max)

v2 changes:
- Remove non-DM code from mt7620-serial driver, and use of-platdata instead
- Fix dev_err related compilation error
- Add expire_now for mt7620-wdt
- Remove use of common.h

Weijie Gao (23):
mips: dts: switch to board defines for dtb for mtmips
mips: mtmips: move mt7628 related Kconfig into mt7628 subdirectory
mips: mtmips: select SYSRESET for mt7628 only
mips: mtmips: fix dram size detection in dram_init
mips: enable _machine_restart for spl
mips: mtmips: add support to initialize SDRAM
mips: mtmips: add support for MediaTek MT7620 SoC
mips: mtmips: add two reference boards for mt7620
configs: mtmips: refresh for mt7628 based boards
serial: add uart driver for MediaTek MT7620 SoC
clk: add clock driver for MediaTek MT7620 SoC
reset: mtmips: add reset controller support for MediaTek MT7620 SoC
pinctrl: mtmips: add support for MediaTek MT7620 SoC
watchdog: add watchdog driver for MediaTek MT7620 SoC
gpio: add GPIO controller driver for MediaTek MT7620 SoC
spi: add spi controller support for MediaTek MT7620 SoC
phy: add USB PHY driver for MediaTek MT7620 SoC
net: add ethernet driver for MediaTek MT7620 SoC
mmc: mtk-sd: fix sclk cycles shift value
mmc: mtk-sd: add pad control settings for MediaTek MT7620/MT76x8 SoCs
mmc: mtk-sd: assign plat->cfg.f_max with a correct value
reset: reset-mtmips: add DM_FLAG_PRE_RELOC flag
MAINTAINERS: add maintainer for MediaTek MIPS platform

 MAINTAINERS                                   |   23 +
 arch/mips/Kconfig                             |    1 -
 arch/mips/cpu/cpu.c                           |    2 +-
 arch/mips/dts/Makefile                        |    7 +-
 arch/mips/dts/mediatek,mt7620-mt7530-rfb.dts  |  100 ++
 arch/mips/dts/mediatek,mt7620-rfb.dts         |   97 ++
 arch/mips/dts/mt7620-u-boot.dtsi              |   14 +
 arch/mips/dts/mt7620.dtsi                     |  296 ++++
 arch/mips/mach-mtmips/Kconfig                 |   72 +-
 arch/mips/mach-mtmips/Makefile                |    1 +
 arch/mips/mach-mtmips/cpu.c                   |    5 +-
 arch/mips/mach-mtmips/ddr_init.c              |   59 +
 arch/mips/mach-mtmips/include/mach/ddr.h      |    4 +
 .../mach-mtmips/include/mach/mt7620-sysc.h    |   54 +
 arch/mips/mach-mtmips/mt7620/Kconfig          |   71 +
 arch/mips/mach-mtmips/mt7620/Makefile         |   10 +
 arch/mips/mach-mtmips/mt7620/dram.c           |  113 ++
 arch/mips/mach-mtmips/mt7620/init.c           |  193 +++
 arch/mips/mach-mtmips/mt7620/lowlevel_init.S  |   53 +
 arch/mips/mach-mtmips/mt7620/mt7620.h         |  103 ++
 arch/mips/mach-mtmips/mt7620/serial.c         |   36 +
 arch/mips/mach-mtmips/mt7620/sysc.c           |  172 +++
 arch/mips/mach-mtmips/mt7628/Kconfig          |   53 +
 board/mediatek/mt7620/Kconfig                 |   12 +
 board/mediatek/mt7620/MAINTAINERS             |    9 +
 board/mediatek/mt7620/Makefile                |    3 +
 board/mediatek/mt7620/board.c                 |    6 +
 .../gardena-smart-gateway-mt7688_defconfig    |    1 +
 configs/linkit-smart-7688_defconfig           |    1 +
 configs/mt7620_mt7530_rfb_defconfig           |   58 +
 configs/mt7620_rfb_defconfig                  |   76 +
 configs/mt7628_rfb_defconfig                  |    1 +
 configs/vocore2_defconfig                     |    1 +
 drivers/clk/mtmips/Makefile                   |    1 +
 drivers/clk/mtmips/clk-mt7620.c               |  159 +++
 drivers/gpio/Kconfig                          |    8 +
 drivers/gpio/Makefile                         |    1 +
 drivers/gpio/mt7620_gpio.c                    |  146 ++
 drivers/mmc/mtk-sd.c                          |  136 +-
 drivers/net/Kconfig                           |   12 +
 drivers/net/Makefile                          |    1 +
 drivers/net/mt7620-eth.c                      | 1222 +++++++++++++++++
 drivers/phy/Kconfig                           |    7 +
 drivers/phy/Makefile                          |    1 +
 drivers/phy/mt7620-usb-phy.c                  |  110 ++
 drivers/pinctrl/mtmips/Kconfig                |    9 +
 drivers/pinctrl/mtmips/Makefile               |    1 +
 drivers/pinctrl/mtmips/pinctrl-mt7620.c       |  200 +++
 drivers/reset/reset-mtmips.c                  |    1 +
 drivers/serial/Kconfig                        |   20 +
 drivers/serial/Makefile                       |    1 +
 drivers/serial/serial_mt7620.c                |  246 ++++
 drivers/spi/Kconfig                           |    7 +
 drivers/spi/Makefile                          |    1 +
 drivers/spi/mt7620_spi.c                      |  281 ++++
 drivers/watchdog/Kconfig                      |    7 +
 drivers/watchdog/Makefile                     |    1 +
 drivers/watchdog/mt7620_wdt.c                 |  142 ++
 include/configs/mt7620.h                      |   46 +
 include/dt-bindings/clock/mt7620-clk.h        |   40 +
 include/dt-bindings/reset/mt7620-reset.h      |   35 +
 61 files changed, 4477 insertions(+), 72 deletions(-)
 create mode 100644 arch/mips/dts/mediatek,mt7620-mt7530-rfb.dts
 create mode 100644 arch/mips/dts/mediatek,mt7620-rfb.dts
 create mode 100644 arch/mips/dts/mt7620-u-boot.dtsi
 create mode 100644 arch/mips/dts/mt7620.dtsi
 create mode 100644 arch/mips/mach-mtmips/include/mach/mt7620-sysc.h
 create mode 100644 arch/mips/mach-mtmips/mt7620/Kconfig
 create mode 100644 arch/mips/mach-mtmips/mt7620/Makefile
 create mode 100644 arch/mips/mach-mtmips/mt7620/dram.c
 create mode 100644 arch/mips/mach-mtmips/mt7620/init.c
 create mode 100644 arch/mips/mach-mtmips/mt7620/lowlevel_init.S
 create mode 100644 arch/mips/mach-mtmips/mt7620/mt7620.h
 create mode 100644 arch/mips/mach-mtmips/mt7620/serial.c
 create mode 100644 arch/mips/mach-mtmips/mt7620/sysc.c
 create mode 100644 arch/mips/mach-mtmips/mt7628/Kconfig
 create mode 100644 board/mediatek/mt7620/Kconfig
 create mode 100644 board/mediatek/mt7620/MAINTAINERS
 create mode 100644 board/mediatek/mt7620/Makefile
 create mode 100644 board/mediatek/mt7620/board.c
 create mode 100644 configs/mt7620_mt7530_rfb_defconfig
 create mode 100644 configs/mt7620_rfb_defconfig
 create mode 100644 drivers/clk/mtmips/clk-mt7620.c
 create mode 100644 drivers/gpio/mt7620_gpio.c
 create mode 100644 drivers/net/mt7620-eth.c
 create mode 100644 drivers/phy/mt7620-usb-phy.c
 create mode 100644 drivers/pinctrl/mtmips/pinctrl-mt7620.c
 create mode 100644 drivers/serial/serial_mt7620.c
 create mode 100644 drivers/spi/mt7620_spi.c
 create mode 100644 drivers/watchdog/mt7620_wdt.c
 create mode 100644 include/configs/mt7620.h
 create mode 100644 include/dt-bindings/clock/mt7620-clk.h
 create mode 100644 include/dt-bindings/reset/mt7620-reset.h
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v4 1/23 mips: dts: switch to board defines for dtb for mtmips

Previous the dts files for gardena-smart-gateway-mt7688 and linkit-smart-7688 are set to be built when mtmips is selected.

This can lead to a compilation error if another soc is added to this arch with different dtsi files.

So it's better to build the dtb only if their board is selected.

---
v4 changes: none
v3 changes: none
v2 changes: none

---
 arch/mips/dts/Makefile | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/mips/dts/Makefile +2 -3
index dc85901dca..e82f96d4e4 100644
@@ -1,8 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0+
 
-dtb-$(CONFIG_ARCH_MTMIPS) += \
-	gardena-smart-gateway-mt7688.dtb \
-	linkit-smart-7688.dtb
 dtb-$(CONFIG_TARGET_AP121) += ap121.dtb
 dtb-$(CONFIG_TARGET_AP143) += ap143.dtb
 dtb-$(CONFIG_TARGET_AP152) += ap152.dtb
@@ -18,6 +15,8 @@ dtb-$(CONFIG_BOARD_COMTREND_VR3032U) += comtrend,vr-3032u.dtb
 dtb-$(CONFIG_BOARD_COMTREND_WAP5813N) += comtrend,wap-5813n.dtb
 dtb-$(CONFIG_BOARD_HUAWEI_HG556A) += huawei,hg556a.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
 dtb-$(CONFIG_TARGET_OCTEON_EBB7304) += mrvl,octeon-ebb7304.dtb
 dtb-$(CONFIG_BOARD_NETGEAR_CG3100D) += netgear,cg3100d.dtb
 dtb-$(CONFIG_BOARD_NETGEAR_DGND3700V2) += netgear,dgnd3700v2.dtb
Signature · 1 line
2.17.1
#2 lore raw

PATCH v4 1/23 mips: dts: switch to board defines for dtb for mtmips

Am Donnerstag, den 12.11.2020, 16:35 +0800 schrieb Weijie Gao:

Quoted 10 lines

Previous the dts files for gardena-smart-gateway-mt7688 and linkit-smart-7688 are set to be built when mtmips is selected.

This can lead to a compilation error if another soc is added to this arch with different dtsi files.

So it's better to build the dtb only if their board is selected.

Quoted 9 lines

---
v4 changes: none
v3 changes: none
v2 changes: none

---
 arch/mips/dts/Makefile | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

series applied to u-boot-mips/next, thanks.

Signature · 1 line
- Daniel
author
#3 lore raw

PATCH v4 1/23 mips: dts: switch to board defines for dtb for mtmips

Quoted 21 lines · Daniel Schwierzeck

Am Donnerstag, den 12.11.2020, 16:35 +0800 schrieb Weijie Gao:

Quoted 10 lines

Previous the dts files for gardena-smart-gateway-mt7688 and linkit-smart-7688 are set to be built when mtmips is selected.

This can lead to a compilation error if another soc is added to this arch with different dtsi files.

So it's better to build the dtb only if their board is selected.

Quoted 9 lines

---
v4 changes: none
v3 changes: none
v2 changes: none

---
 arch/mips/dts/Makefile | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
Quoted 2 lines

series applied to u-boot-mips/next, thanks.

Hi Daniel,

Gentle ping

I'm just curious when can the patch series be merged into u-boot/master?

Regards

#4 lore raw

PATCH v4 1/23 mips: dts: switch to board defines for dtb for mtmips

Am Montag, den 18.01.2021, 15:54 +0800 schrieb Weijie Gao:

Quoted 22 lines · Daniel Schwierzeck
Quoted 21 lines

Am Donnerstag, den 12.11.2020, 16:35 +0800 schrieb Weijie Gao:

Quoted 19 lines

Previous the dts files for gardena-smart-gateway-mt7688 and linkit-smart-7688 are set to be built when mtmips is selected.

This can lead to a compilation error if another soc is added to this arch with different dtsi files.

So it's better to build the dtb only if their board is selected.

---
v4 changes: none
v3 changes: none
v2 changes: none

---
 arch/mips/dts/Makefile | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
Quoted 9 lines
Quoted 2 lines

series applied to u-boot-mips/next, thanks.

Hi Daniel,

Gentle ping

I'm just curious when can the patch series be merged into u-boot/master?

Hi Weijie,

thanks for the reminder, I missed the opening of the merge window ;)

I rebased the MIPS next branch and triggered all CI builds. If all is ok, I'll prepare a pull request.

Signature · 1 line
- Daniel
author
#5 lore raw

PATCH v4 1/23 mips: dts: switch to board defines for dtb for mtmips

Quoted 33 lines · Daniel Schwierzeck

Am Montag, den 18.01.2021, 15:54 +0800 schrieb Weijie Gao:

Quoted 22 lines · Daniel Schwierzeck
Quoted 21 lines

Am Donnerstag, den 12.11.2020, 16:35 +0800 schrieb Weijie Gao:

Quoted 19 lines

Previous the dts files for gardena-smart-gateway-mt7688 and linkit-smart-7688 are set to be built when mtmips is selected.

This can lead to a compilation error if another soc is added to this arch with different dtsi files.

So it's better to build the dtb only if their board is selected.

---
v4 changes: none
v3 changes: none
v2 changes: none

---
 arch/mips/dts/Makefile | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
Quoted 9 lines
Quoted 2 lines

series applied to u-boot-mips/next, thanks.

Hi Daniel,

Gentle ping

I'm just curious when can the patch series be merged into u-boot/master?

Quoted 7 lines

Hi Weijie,

thanks for the reminder, I missed the opening of the merge window ;)

I rebased the MIPS next branch and triggered all CI builds. If all is ok, I'll prepare a pull request.

got it. thanks.

#6 lore raw

PATCH v4 1/23 mips: dts: switch to board defines for dtb for mtmips

Hi Weijie,

Am Dienstag, den 19.01.2021, 08:58 +0800 schrieb Weijie Gao:

Quoted 10 lines
Quoted 10 lines
Quoted 7 lines

Hi Daniel,

Gentle ping

I'm just curious when can the patch series be merged into u-boot/master?

Hi Weijie,

Quoted 7 lines
Quoted 5 lines

thanks for the reminder, I missed the opening of the merge window ;)

I rebased the MIPS next branch and triggered all CI builds. If all is ok, I'll prepare a pull request.

got it. thanks.

in mainline there was a lot of renaming in DM core. I created fixup commits in u-boot-mips/next to fix all build errors. Could you give it short look and test? Thanks.

Signature · 1 line
- Daniel
author
#7 lore raw

PATCH v4 1/23 mips: dts: switch to board defines for dtb for mtmips

Quoted 19 lines · Daniel Schwierzeck

Hi Weijie,

Am Dienstag, den 19.01.2021, 08:58 +0800 schrieb Weijie Gao:

Quoted 16 lines
Quoted 15 lines
Quoted 7 lines

Hi Daniel,

Gentle ping

I'm just curious when can the patch series be merged into u-boot/master?

Hi Weijie,

thanks for the reminder, I missed the opening of the merge window ;)

I rebased the MIPS next branch and triggered all CI builds. If all is ok, I'll prepare a pull request.

Quoted 6 lines
Quoted 1 line

got it. thanks.

in mainline there was a lot of renaming in DM core. I created fixup commits in u-boot-mips/next to fix all build errors. Could you give it short look and test? Thanks.

I have tested and all works fine.

Regards

author
#8 lore raw

PATCH v4 2/23 mips: mtmips: move mt7628 related Kconfig into mt7628 subdirectory

In reply to Weijie Gao

This patch is a preparation for add a new soc fot mtmips.

Move all mt7628 related Kconfig (boards and UART selection) into mt7628 subdirectory and make sure the top directory of mtmips contains only selection for SoCs.

---
v4 changes: none
v3 changes: none
v2 changes: none

---
 arch/mips/mach-mtmips/Kconfig        | 53 +---------------------------
 arch/mips/mach-mtmips/mt7628/Kconfig | 53 ++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 52 deletions(-)
 create mode 100644 arch/mips/mach-mtmips/mt7628/Kconfig
arch/mips/mach-mtmips/Kconfig +1 -52
index 737de2cb8e..7c07430a0c 100644
@@ -58,57 +58,6 @@ config SOC_MT7628
 
 endchoice
 
-choice
-	prompt "Board select"
-
-config BOARD_GARDENA_SMART_GATEWAY_MT7688
-	bool "GARDENA smart Gateway"
-	depends on SOC_MT7628
-	select BOARD_LATE_INIT
-	help
-	  GARDENA smart Gateway boards have a MT7688 SoC with 128 MiB of RAM
-	  and 8 MiB of flash (SPI NOR) and additional SPI NAND storage.
-
-config BOARD_LINKIT_SMART_7688
-	bool "LinkIt Smart 7688"
-	depends on SOC_MT7628
-	help
-	  Seeed LinkIt Smart 7688 boards have a MT7688 SoC with 128 MiB of RAM
-	  and 32 MiB of flash (SPI).
-	  Between its different peripherals there's an integrated switch with 4
-	  ethernet ports, 1 USB port, 1 UART, GPIO buttons and LEDs, and
-	  a MT7688 (PCIe).
-
-config BOARD_MT7628_RFB
-	bool "MediaTek MT7628 RFB"
-	depends on SOC_MT7628
-	help
-	  The reference design of MT7628. The board has 128 MiB DDR2, 8 MiB
-	  SPI-NOR flash, 1 built-in switch with 5 ports, 1 UART, 1 USB host,
-	  1 SDXC, 1 PCIe socket and JTAG pins.
-
-config BOARD_VOCORE2
-	bool "VoCore2"
-	depends on SOC_MT7628
-	select SPL_SERIAL_SUPPORT
-	select SPL_UART2_SPIS_PINMUX
-	help
-	  VoCore VoCore2 board has a MT7628 SoC with 128 MiB of RAM
-	  and 16 MiB of flash (SPI).
-
-endchoice
-
-config SPL_UART2_SPIS_PINMUX
-	bool "Use alternative pinmux for UART2 in SPL stage"
-	depends on SPL_SERIAL_SUPPORT
-	default n
-	help
-	  Select this if the UART2 of your board is connected to GPIO 16/17
-	  (shared with SPIS) rather than the usual GPIO 20/21.
-
-source "board/gardena/smart-gateway-mt7688/Kconfig"
-source "board/mediatek/mt7628/Kconfig"
-source "board/seeed/linkit-smart-7688/Kconfig"
-source "board/vocore/vocore2/Kconfig"
+source "arch/mips/mach-mtmips/mt7628/Kconfig"
 
 endmenu
arch/mips/mach-mtmips/mt7628/Kconfig new file +53 -0

53 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#9 lore raw

PATCH v4 3/23 mips: mtmips: select SYSRESET for mt7628 only

In reply to Weijie Gao

Currently only mt7628 needs the sysreset driver, do not select it for mt7620.

---
v4 changes: none
v3 changes: none
v2 changes: new

---
 arch/mips/Kconfig             | 1 -
 arch/mips/mach-mtmips/Kconfig | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)
arch/mips/Kconfig +0 -1
index e0f6b6c4b3..77f563e98e 100644
@@ -97,7 +97,6 @@ config ARCH_MTMIPS
 	select SUPPORTS_CPU_MIPS32_R1
 	select SUPPORTS_CPU_MIPS32_R2
 	select SUPPORTS_LITTLE_ENDIAN
-	select SYSRESET
 	select SUPPORT_SPL
 
 config ARCH_JZ47XX
arch/mips/mach-mtmips/Kconfig +1 -0
index 7c07430a0c..c383e82a6b 100644
@@ -43,6 +43,7 @@ config SOC_MT7628
 	select SYS_MIPS_CACHE_INIT_RAM_LOAD
 	select PINCTRL_MT7628
 	select MTK_SERIAL
+	select SYSRESET
 	select SYSRESET_RESETCTL
 	select SPL_SEPARATE_BSS if SPL
 	select SPL_INIT_STACK_WITHOUT_MALLOC_F if SPL
Signature · 1 line
2.17.1
author
#10 lore raw

PATCH v4 4/23 mips: mtmips: fix dram size detection in dram_init

In reply to Weijie Gao

CONFIG_SYS_SDRAM_BASE points to cached memory, i.e. KSEG0, which is not suitable for detecting memory size.

Replace CONFIG_SYS_SDRAM_BASE with KSEG1, and make dram_init() always do memory size detection in any stage.

---
v4 changes: none
v3 changes: none
v2 changes: none

---
 arch/mips/mach-mtmips/cpu.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/mips/mach-mtmips/cpu.c +2 -3
index 2ddf8cb096..ca1967055a 100644
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <init.h>
 #include <malloc.h>
+#include <asm/addrspace.h>
 #include <linux/bitops.h>
 #include <linux/io.h>
 #include <linux/sizes.h>
@@ -14,9 +15,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
 {
-#ifdef CONFIG_SKIP_LOWLEVEL_INIT
-	gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE, SZ_256M);
-#endif
+	gd->ram_size = get_ram_size((void *)KSEG1, SZ_256M);
 
 	return 0;
 }
Signature · 1 line
2.17.1
author
#11 lore raw

PATCH v4 5/23 mips: enable _machine_restart for spl

In reply to Weijie Gao

The sysreset driver has a config CONFIG_SPL_SYSRESET for the spl stage. Change CONFIG_SYSRESET to CONFIG_IS_ENABLED(SYSRESET) will give spl a chance to use _machine_restart instead of the sysreset driver.

---
v4 changes: none
v3 changes: none
v2 changes: new

---
 arch/mips/cpu/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/cpu/cpu.c +1 -1
index 7d5c9fd83a..b304026a67 100644
@@ -12,7 +12,7 @@
 #include <asm/mipsregs.h>
 #include <asm/reboot.h>
 
-#ifndef CONFIG_SYSRESET
+#if !CONFIG_IS_ENABLED(SYSRESET)
 void __weak _machine_restart(void)
 {
 	fprintf(stderr, "*** reset failed ***\n");
Signature · 1 line
2.17.1
author
#12 lore raw

PATCH v4 6/23 mips: mtmips: add support to initialize SDRAM

In reply to Weijie Gao

This patch adds support for mtmips SoCs to initialize the SDRAM.

---
v4 changes: none
v3 changes: none
v2 changes: none

---
 arch/mips/mach-mtmips/ddr_init.c         | 59 ++++++++++++++++++++++++
 arch/mips/mach-mtmips/include/mach/ddr.h |  4 ++
 2 files changed, 63 insertions(+)
arch/mips/mach-mtmips/ddr_init.c +59 -0
index 6c6d0933f2..9c986daea6 100644
@@ -15,6 +15,13 @@
 
 #define DDR_BW_TEST_PAT			0xaa5555aa
 
+static const u32 sdr_size_cfg1[] = {
+	[DRAM_8MB] = (1 << NUMROWS_S),
+	[DRAM_16MB] = (1 << NUMROWS_S) | (1 << NUMCOLS_S),
+	[DRAM_32MB] = (2 << NUMROWS_S) | (1 << NUMCOLS_S),
+	[DRAM_64MB] = (2 << NUMROWS_S) | (2 << NUMCOLS_S),
+};
+
 static const u32 dram_size[] = {
 	[DRAM_8MB] = SZ_8M,
 	[DRAM_16MB] = SZ_16M,
@@ -193,3 +200,55 @@ void ddr2_init(struct mc_ddr_init_param *param)
 	param->memsize = dram_size[sz];
 	param->bus_width = bw;
 }
+
+static void mc_sdr_init(void __iomem *memc, mc_reset_t mc_reset, u32 cfg0,
+			u32 cfg1)
+{
+	mc_reset(1);
+	__udelay(200);
+	mc_reset(0);
+
+	writel(cfg0, memc + MEMCTL_SDRAM_CFG0_REG);
+	writel(cfg1, memc + MEMCTL_SDRAM_CFG1_REG);
+
+	while (!(readl(memc + MEMCTL_SDRAM_CFG1_REG) & SDRAM_INIT_DONE))
+		;
+
+	clrsetbits_32(memc + MEMCTL_PWR_SAVE_CNT_REG, SR_TAR_CNT_M,
+		      1 << SR_TAR_CNT_S);
+
+	setbits_32(memc + MEMCTL_DDR_SELF_REFRESH_REG, SR_AUTO_EN);
+}
+
+void sdr_init(struct mc_ddr_init_param *param)
+{
+	enum mc_dram_size sz;
+	u32 cfg1;
+
+	cfg1 = param->sdr_cfg1 | SDRAM_INIT_START;
+	cfg1 &= ~(NUMCOLS_M | NUMROWS_M);
+
+	/* First initialization, determine SDR capacity */
+	mc_sdr_init(param->memc, param->mc_reset, param->sdr_cfg0,
+		    cfg1 | sdr_size_cfg1[DRAM_64MB]);
+
+	if (dram_addr_test_bit(9)) {
+		sz = DRAM_8MB;
+	} else {
+		if (dram_addr_test_bit(10)) {
+			if (dram_addr_test_bit(23))
+				sz = DRAM_16MB;
+			else
+				sz = DRAM_32MB;
+		} else {
+			sz = DRAM_64MB;
+		}
+	}
+
+	/* Final initialization */
+	mc_sdr_init(param->memc, param->mc_reset, param->sdr_cfg0,
+		    cfg1 | sdr_size_cfg1[sz]);
+
+	/* Return actual DDR configuration */
+	param->memsize = dram_size[sz];
+}
arch/mips/mach-mtmips/include/mach/ddr.h +4 -0
index f92198137b..15ff66ace6 100644
@@ -35,6 +35,9 @@ typedef void (*mc_reset_t)(int assert);
 struct mc_ddr_init_param {
 	void __iomem *memc;
 
+	u32 sdr_cfg0;
+	u32 sdr_cfg1;
+
 	u32 dq_dly;
 	u32 dqs_dly;
 
@@ -45,6 +48,7 @@ struct mc_ddr_init_param {
 	u32 bus_width;
 };
 
+void sdr_init(struct mc_ddr_init_param *param);
 void ddr1_init(struct mc_ddr_init_param *param);
 void ddr2_init(struct mc_ddr_init_param *param);
 void ddr_calibrate(void __iomem *memc, u32 memsize, u32 bw);
Signature · 1 line
2.17.1
author
#13 lore raw

PATCH v4 7/23 mips: mtmips: add support for MediaTek MT7620 SoC

In reply to Weijie Gao

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

---
v4 changes: none
v3 changes: none
v2 changes: remove use of common.h

---
 arch/mips/dts/mt7620-u-boot.dtsi              |  14 +
 arch/mips/dts/mt7620.dtsi                     | 296 ++++++++++++++++++
 arch/mips/mach-mtmips/Kconfig                 |  18 ++
 arch/mips/mach-mtmips/Makefile                |   1 +
 .../mach-mtmips/include/mach/mt7620-sysc.h    |  54 ++++
 arch/mips/mach-mtmips/mt7620/Kconfig          |  54 ++++
 arch/mips/mach-mtmips/mt7620/Makefile         |  10 +
 arch/mips/mach-mtmips/mt7620/dram.c           | 113 +++++++
 arch/mips/mach-mtmips/mt7620/init.c           | 193 ++++++++++++
 arch/mips/mach-mtmips/mt7620/lowlevel_init.S  |  53 ++++
 arch/mips/mach-mtmips/mt7620/mt7620.h         | 103 ++++++
 arch/mips/mach-mtmips/mt7620/serial.c         |  36 +++
 arch/mips/mach-mtmips/mt7620/sysc.c           | 172 ++++++++++
 include/configs/mt7620.h                      |  46 +++
 14 files changed, 1163 insertions(+)
 create mode 100644 arch/mips/dts/mt7620-u-boot.dtsi
 create mode 100644 arch/mips/dts/mt7620.dtsi
 create mode 100644 arch/mips/mach-mtmips/include/mach/mt7620-sysc.h
 create mode 100644 arch/mips/mach-mtmips/mt7620/Kconfig
 create mode 100644 arch/mips/mach-mtmips/mt7620/Makefile
 create mode 100644 arch/mips/mach-mtmips/mt7620/dram.c
 create mode 100644 arch/mips/mach-mtmips/mt7620/init.c
 create mode 100644 arch/mips/mach-mtmips/mt7620/lowlevel_init.S
 create mode 100644 arch/mips/mach-mtmips/mt7620/mt7620.h
 create mode 100644 arch/mips/mach-mtmips/mt7620/serial.c
 create mode 100644 arch/mips/mach-mtmips/mt7620/sysc.c
 create mode 100644 include/configs/mt7620.h
arch/mips/dts/mt7620-u-boot.dtsi new file +14 -0
new file mode 100644
index 0000000000..ed8425719b
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 MediaTek Inc.
+ *
+ * Author: Weijie Gao <[email protected]>
+ */
+
+&uartlite {
+	u-boot,dm-pre-reloc;
+};
+
+&uartfull {
+	u-boot,dm-pre-reloc;
+};
arch/mips/dts/mt7620.dtsi new file +296 -0

296 lines not on this page · raw message

arch/mips/mach-mtmips/Kconfig +18 -0
index c383e82a6b..8756cadb0b 100644
@@ -5,6 +5,7 @@ config SYS_MALLOC_F_LEN
 	default 0x1000
 
 config SYS_SOC
+	default "mt7620" if SOC_MT7620
 	default "mt7628" if SOC_MT7628
 
 config SYS_DCACHE_SIZE
@@ -31,10 +32,26 @@ config SPL_PAYLOAD
 
 config BUILD_TARGET
 	default "u-boot-with-spl.bin" if SPL
+	default "u-boot.bin"
 
 choice
 	prompt "MediaTek MIPS SoC select"
 
+config SOC_MT7620
+	bool "MT7620"
+	select MIPS_L1_CACHE_SHIFT_5
+	select SYS_MIPS_CACHE_INIT_RAM_LOAD
+	select PINCTRL_MT7620
+	select MT7620_SERIAL
+	select MISC
+	select SPL_SEPARATE_BSS if SPL
+	select SPL_LOADER_SUPPORT if SPL
+	select SPL_OF_CONTROL if SPL_DM
+	select SPL_OF_PLATDATA if SPL_DM
+	select SPL_DM_SERIAL if SPL_DM
+	help
+	  This supports MediaTek MT7620.
+
 config SOC_MT7628
 	bool "MT7628"
 	select MIPS_L1_CACHE_SHIFT_5
@@ -59,6 +76,7 @@ config SOC_MT7628
 
 endchoice
 
+source "arch/mips/mach-mtmips/mt7620/Kconfig"
 source "arch/mips/mach-mtmips/mt7628/Kconfig"
 
 endmenu
arch/mips/mach-mtmips/Makefile +1 -0
index a7e6a66304..4909b47ef2 100644
@@ -5,4 +5,5 @@ obj-y += ddr_init.o
 obj-y += ddr_cal.o
 obj-$(CONFIG_SPL_BUILD) += spl.o
 
+obj-$(CONFIG_SOC_MT7620) += mt7620/
 obj-$(CONFIG_SOC_MT7628) += mt7628/
arch/mips/mach-mtmips/include/mach/mt7620-sysc.h new file +54 -0

54 lines not on this page · raw message

arch/mips/mach-mtmips/mt7620/Kconfig new file +54 -0

54 lines not on this page · raw message

arch/mips/mach-mtmips/mt7620/Makefile new file +10 -0
new file mode 100644
index 0000000000..649f6c3798
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-y += lowlevel_init.o
+obj-y += init.o
+obj-y += dram.o
+obj-y += serial.o
+
+ifndef CONFIG_SPL_BUILD
+obj-y += sysc.o
+endif
arch/mips/mach-mtmips/mt7620/dram.c new file +113 -0

113 lines not on this page · raw message

arch/mips/mach-mtmips/mt7620/init.c new file +193 -0

193 lines not on this page · raw message

arch/mips/mach-mtmips/mt7620/lowlevel_init.S new file +53 -0

53 lines not on this page · raw message

arch/mips/mach-mtmips/mt7620/mt7620.h new file +103 -0

103 lines not on this page · raw message

arch/mips/mach-mtmips/mt7620/serial.c new file +36 -0
new file mode 100644
index 0000000000..44f061cd6c
@@ -0,0 +1,36 @@
+// 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 "mt7620.h"
+
+void board_debug_uart_init(void)
+{
+	void __iomem *base = ioremap_nocache(SYSCTL_BASE, SYSCTL_SIZE);
+
+#if CONFIG_DEBUG_UART_BASE == 0xb0000500 /* KSEG1ADDR(UARTFULL_BASE) */
+	clrsetbits_32(base + SYSCTL_GPIOMODE_REG, UARTF_SHARE_MODE_M,
+		      UARTF_MODE_UARTF_GPIO << UARTF_SHARE_MODE_S);
+#else
+	clrbits_32(base + SYSCTL_GPIOMODE_REG, UARTL_GPIO_MODE);
+#endif
+}
+
+void mtmips_spl_serial_init(void)
+{
+#ifdef CONFIG_SPL_SERIAL_SUPPORT
+	void __iomem *base = ioremap_nocache(SYSCTL_BASE, SYSCTL_SIZE);
+
+#if CONFIG_CONS_INDEX == 1
+	clrbits_32(base + SYSCTL_GPIOMODE_REG, UARTL_GPIO_MODE);
+#elif CONFIG_CONS_INDEX == 2
+	clrsetbits_32(base + SYSCTL_GPIOMODE_REG, UARTF_SHARE_MODE_M,
+		      UARTF_MODE_UARTF_GPIO << UARTF_SHARE_MODE_S);
+#endif
+#endif /* CONFIG_SPL_SERIAL_SUPPORT */
+}
arch/mips/mach-mtmips/mt7620/sysc.c new file +172 -0

172 lines not on this page · raw message

include/configs/mt7620.h new file +46 -0

46 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#14 lore raw

PATCH v4 8/23 mips: mtmips: add two reference boards for mt7620

In reply to Weijie Gao

The mt7620_rfb board supports integrated 10/100M PHYs plus two external giga PHYs. It also has 8MB SPI-NOR, mini PCI-e x1 slot, SDHC and USB.

The mt7620_mt7530_rfb boards supports an external MT7530 giga switch and a 16MB SPI-NOR flash.

---
v4 changes: none
v3 changes: none
v2 changes: remove use of common.h

---
 arch/mips/dts/Makefile                       |   2 +
 arch/mips/dts/mediatek,mt7620-mt7530-rfb.dts | 100 +++++++++++++++++++
 arch/mips/dts/mediatek,mt7620-rfb.dts        |  97 ++++++++++++++++++
 arch/mips/mach-mtmips/mt7620/Kconfig         |  17 ++++
 board/mediatek/mt7620/Kconfig                |  12 +++
 board/mediatek/mt7620/MAINTAINERS            |   9 ++
 board/mediatek/mt7620/Makefile               |   3 +
 board/mediatek/mt7620/board.c                |   6 ++
 configs/mt7620_mt7530_rfb_defconfig          |  58 +++++++++++
 configs/mt7620_rfb_defconfig                 |  76 ++++++++++++++
 10 files changed, 380 insertions(+)
 create mode 100644 arch/mips/dts/mediatek,mt7620-mt7530-rfb.dts
 create mode 100644 arch/mips/dts/mediatek,mt7620-rfb.dts
 create mode 100644 board/mediatek/mt7620/Kconfig
 create mode 100644 board/mediatek/mt7620/MAINTAINERS
 create mode 100644 board/mediatek/mt7620/Makefile
 create mode 100644 board/mediatek/mt7620/board.c
 create mode 100644 configs/mt7620_mt7530_rfb_defconfig
 create mode 100644 configs/mt7620_rfb_defconfig
arch/mips/dts/Makefile +2 -0
index e82f96d4e4..7c42923134 100644
@@ -14,6 +14,8 @@ dtb-$(CONFIG_BOARD_COMTREND_CT5361) += comtrend,ct-5361.dtb
 dtb-$(CONFIG_BOARD_COMTREND_VR3032U) += comtrend,vr-3032u.dtb
 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_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,mt7620-mt7530-rfb.dts new file +100 -0

100 lines not on this page · raw message

arch/mips/dts/mediatek,mt7620-rfb.dts new file +97 -0

97 lines not on this page · raw message

arch/mips/mach-mtmips/mt7620/Kconfig +17 -0
index aa7cf1d3c1..5db83eb9d9 100644
@@ -7,6 +7,21 @@ config DEBUG_UART_BOARD_INIT
 choice
 	prompt "Board select"
 
+config BOARD_MT7620_RFB
+	bool "MediaTek MT7620 RFB"
+	help
+	  The reference design of MT7620A (WS2120). The board has 64 MiB DDR2,
+	  8 MiB SPI-NOR flash, 1 built-in 6 port switch (two GE PHYs and five
+	  FE PHYs,one port can be configured to use either FE PHY or GE PHY),
+	  1 UART, 1 USB host, 1 SDXC, 1 PCIe socket and JTAG pins.
+
+config BOARD_MT7620_MT7530_RFB
+	bool "MediaTek MT7620-MT7530 RFB"
+	help
+	  The reference design of MT7620DA (MTKC712). The board has 64 MiB
+	  intergrated DDR2 KGD, 16 MiB SPI-NOR flash, an external 5-port giga
+	  switch MT7530 and 1 UART.
+
 endchoice
 
 choice
@@ -51,4 +66,6 @@ config CPU_FREQ_MULTI
 	default 6 if CPU_FREQ_600MHZ
 	default 7 if CPU_FREQ_620MHZ
 
+source "board/mediatek/mt7620/Kconfig"
+
 endif
board/mediatek/mt7620/Kconfig new file +12 -0
new file mode 100644
index 0000000000..b9137adcc9
@@ -0,0 +1,12 @@
+if BOARD_MT7620_RFB || BOARD_MT7620_MT7530_RFB
+
+config SYS_BOARD
+	default "mt7620"
+
+config SYS_VENDOR
+	default "mediatek"
+
+config SYS_CONFIG_NAME
+	default "mt7620"
+
+endif
board/mediatek/mt7620/MAINTAINERS new file +9 -0
new file mode 100644
index 0000000000..05db777ced
@@ -0,0 +1,9 @@
+MT7620_RFB BOARD
+M:	Weijie Gao <[email protected]>
+S:	Maintained
+F:	board/mediatek/mt7620
+F:	include/configs/mt7620.h
+F:	configs/mt7620_rfb_defconfig
+F:	configs/mt7620_mt7530_rfb_defconfig
+F:	arch/mips/dts/mediatek,mt7620-rfb.dts
+F:	arch/mips/dts/mediatek,mt7620-mt7530-rfb.dts
board/mediatek/mt7620/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/mt7620/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/mt7620_mt7530_rfb_defconfig new file +58 -0

58 lines not on this page · raw message

configs/mt7620_rfb_defconfig new file +76 -0

76 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#15 lore raw

PATCH v4 9/23 configs: mtmips: refresh for mt7628 based boards

In reply to Weijie Gao

Since mt7620 is added into Kconfig, the CONFIG_SOC_MT7628=y which is omitted by default must be added back, otherwise make xxx_defconfig for these boards will be configured for mt7620 platform.

---
v4 changes: none
v3 changes: none
v2 changes: none

---
 configs/gardena-smart-gateway-mt7688_defconfig | 1 +
 configs/linkit-smart-7688_defconfig            | 1 +
 configs/mt7628_rfb_defconfig                   | 1 +
 configs/vocore2_defconfig                      | 1 +
 4 files changed, 4 insertions(+)
configs/gardena-smart-gateway-mt7688_defconfig +1 -0
index 001a66d0f6..c03123f6e4 100644
@@ -12,6 +12,7 @@ CONFIG_SPL=y
 CONFIG_SYS_BOOTCOUNT_SINGLEWORD=y
 CONFIG_ENV_OFFSET_REDUND=0xB0000
 CONFIG_ARCH_MTMIPS=y
+CONFIG_SOC_MT7628=y
 CONFIG_DEFAULT_DEVICE_TREE="gardena-smart-gateway-mt7688"
 CONFIG_RESTORE_EXCEPTION_VECTOR_BASE=y
 # CONFIG_MIPS_BOOT_ENV_LEGACY is not set
configs/linkit-smart-7688_defconfig +1 -0
index 437000b4c7..dd2524e4ec 100644
@@ -9,6 +9,7 @@ CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL_SYS_MALLOC_F_LEN=0x40000
 CONFIG_SPL=y
 CONFIG_ARCH_MTMIPS=y
+CONFIG_SOC_MT7628=y
 CONFIG_BOARD_LINKIT_SMART_7688=y
 CONFIG_DEFAULT_DEVICE_TREE="linkit-smart-7688"
 CONFIG_RESTORE_EXCEPTION_VECTOR_BASE=y
configs/mt7628_rfb_defconfig +1 -0
index 69025728b2..831e54e9f3 100644
@@ -9,6 +9,7 @@ CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL_SYS_MALLOC_F_LEN=0x40000
 CONFIG_SPL=y
 CONFIG_ARCH_MTMIPS=y
+CONFIG_SOC_MT7628=y
 CONFIG_BOARD_MT7628_RFB=y
 CONFIG_DEFAULT_DEVICE_TREE="mediatek,mt7628-rfb"
 CONFIG_RESTORE_EXCEPTION_VECTOR_BASE=y
configs/vocore2_defconfig +1 -0
index acb9abf1be..e255829366 100644
@@ -10,6 +10,7 @@ CONFIG_SPL_SYS_MALLOC_F_LEN=0x40000
 CONFIG_SPL=y
 CONFIG_SYS_BOOTCOUNT_SINGLEWORD=y
 CONFIG_ARCH_MTMIPS=y
+CONFIG_SOC_MT7628=y
 CONFIG_BOARD_VOCORE2=y
 CONFIG_DEFAULT_DEVICE_TREE="vocore_vocore2"
 CONFIG_RESTORE_EXCEPTION_VECTOR_BASE=y
Signature · 1 line
2.17.1
author
#16 lore raw

PATCH v4 10/23 serial: add uart driver for MediaTek MT7620 SoC

In reply to Weijie Gao

This patch adds uart support for MediaTek MT7620 and earlier SoCs.

The UART used by MT7620 is incompatible with the ns16550a driver. All registers of this UART have different addresses. A special 16-bit register for Divisor Latch is used to set the baudrate instead of the original two 8-bit registers (DLL and DLM).

The driver supports of-platdata which is useful for tiny SPL.

---
v4 changes: remove unused non-DM code in drivers/serial/serial.c v3 changes: none
v2 changes: replace non-DM code with of-platdata

---
 drivers/serial/Kconfig         |  20 +++
 drivers/serial/Makefile        |   1 +
 drivers/serial/serial_mt7620.c | 246 +++++++++++++++++++++++++++++++++
 3 files changed, 267 insertions(+)
 create mode 100644 drivers/serial/serial_mt7620.c
drivers/serial/Kconfig +20 -0
index b4805a2e4e..44fff8a3cd 100644
@@ -401,6 +401,16 @@ config DEBUG_UART_MTK
 	  driver will be available until the real driver model serial is
 	  running.
 
+config DEBUG_UART_MT7620
+	bool "UART driver for MediaTek MT7620 and earlier SoCs"
+	depends on MT7620_SERIAL
+	help
+	  Select this to enable a debug UART using the UART driver for
+	  MediaTek MT7620 and earlier SoCs.
+	  You will need to provide parameters to make this work. The
+	  driver will be available until the real driver model serial is
+	  running.
+
 endchoice
 
 config DEBUG_UART_BASE
@@ -817,6 +827,16 @@ config MTK_SERIAL
 	  The High-speed UART is compatible with the ns16550a UART and have
 	  its own high-speed registers.
 
+config MT7620_SERIAL
+	bool "UART driver for MediaTek MT7620 and earlier SoCs"
+	depends on DM_SERIAL
+	help
+	  Select this to enable UART support for MediaTek MT7620 and earlier
+	  SoCs. This driver uses driver model and requires a device tree
+	  binding to operate.
+	  The UART driver for MediaTek MT7620 and earlier SoCs is *NOT*
+	  compatible with the ns16550a UART.
+
 config MPC8XX_CONS
 	bool "Console driver for MPC8XX"
 	depends on MPC8xx
drivers/serial/Makefile +1 -0
index 25f7f8d342..0c3810f5d5 100644
@@ -69,6 +69,7 @@ obj-$(CONFIG_NULLDEV_SERIAL) += serial_nulldev.o
 obj-$(CONFIG_OWL_SERIAL) += serial_owl.o
 obj-$(CONFIG_OMAP_SERIAL) += serial_omap.o
 obj-$(CONFIG_MTK_SERIAL) += serial_mtk.o
+obj-$(CONFIG_MT7620_SERIAL) += serial_mt7620.o
 obj-$(CONFIG_SIFIVE_SERIAL) += serial_sifive.o
 obj-$(CONFIG_XEN_SERIAL) += serial_xen.o
 
drivers/serial/serial_mt7620.c new file +246 -0

246 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#17 lore raw

PATCH v4 11/23 clk: add clock driver for MediaTek MT7620 SoC

In reply to Weijie Gao

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

---
v4 changes: none
v3 changes: none
v2 changes: none

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

159 lines not on this page · raw message

include/dt-bindings/clock/mt7620-clk.h new file +40 -0
new file mode 100644
index 0000000000..3bb91ebdf1
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2020 MediaTek Inc.
+ *
+ * Author:  Weijie Gao <[email protected]>
+ */
+
+#ifndef _DT_BINDINGS_MT7620_CLK_H_
+#define _DT_BINDINGS_MT7620_CLK_H_
+
+/* Base clocks */
+#define CLK_SYS				34
+#define CLK_CPU				33
+#define CLK_XTAL			32
+
+/* Peripheral clocks */
+#define CLK_SDHC			30
+#define CLK_MIPS_CNT			28
+#define CLK_PCIE			26
+#define CLK_UPHY_12M			25
+#define CLK_EPHY			24
+#define CLK_ESW				23
+#define CLK_UPHY_48M			22
+#define CLK_FE				21
+#define CLK_UARTL			19
+#define CLK_SPI				18
+#define CLK_I2S				17
+#define CLK_I2C				16
+#define CLK_NAND			15
+#define CLK_GDMA			14
+#define CLK_PIO				13
+#define CLK_UARTF			12
+#define CLK_PCM				11
+#define CLK_MC				10
+#define CLK_INTC			9
+#define CLK_TIMER			8
+#define CLK_GE2				7
+#define CLK_GE1				6
+
+#endif /* _DT_BINDINGS_MT7620_CLK_H_ */
Signature · 1 line
2.17.1
author
#18 lore raw

PATCH v4 12/23 reset: mtmips: add reset controller support for MediaTek MT7620 SoC

In reply to Weijie Gao

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

---
v4 changes: none
v3 changes: none
v2 changes: none

---
 include/dt-bindings/reset/mt7620-reset.h | 35 ++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 include/dt-bindings/reset/mt7620-reset.h
include/dt-bindings/reset/mt7620-reset.h new file +35 -0
new file mode 100644
index 0000000000..3096b29cdb
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2020 MediaTek Inc.
+ *
+ * Author:  Weijie Gao <[email protected]>
+ */
+
+#ifndef _DT_BINDINGS_MT7620_RESET_H_
+#define _DT_BINDINGS_MT7620_RESET_H_
+
+#define PPE_RST			31
+#define SDHC_RST		30
+#define MIPS_CNT_RST		28
+#define PCIE_RST		26
+#define UHST_RST		25
+#define EPHY_RST		24
+#define ESW_RST			23
+#define UDEV_RST		22
+#define FE_RST			21
+#define WLAN_RST		20
+#define UARTL_RST		19
+#define SPI_RST			18
+#define I2S_RST			17
+#define I2C_RST			16
+#define NAND_RST		15
+#define DMA_RST			14
+#define PIO_RST			13
+#define UARTF_RST		12
+#define PCM_RST			11
+#define MC_RST			10
+#define INTC_RST		9
+#define TIMER_RST		8
+#define SYS_RST			0
+
+#endif /* _DT_BINDINGS_MT7620_RESET_H_ */
Signature · 1 line
2.17.1
author
#19 lore raw

PATCH v4 13/23 pinctrl: mtmips: add support for MediaTek MT7620 SoC

In reply to Weijie Gao

This patch adds pinctrl support for MediaTek MT7620 SoC. The MT7620 SoC supports only pinmux.

---
v4 changes: none
v3 changes: none
v2 changes: none

---
 drivers/pinctrl/mtmips/Kconfig          |   9 ++
 drivers/pinctrl/mtmips/Makefile         |   1 +
 drivers/pinctrl/mtmips/pinctrl-mt7620.c | 200 ++++++++++++++++++++++++
 3 files changed, 210 insertions(+)
 create mode 100644 drivers/pinctrl/mtmips/pinctrl-mt7620.c
drivers/pinctrl/mtmips/Kconfig +9 -0
index 8482a38ebc..844d5b743f 100644
@@ -3,6 +3,15 @@ config PINCTRL_MTMIPS
 	depends on ARCH_MTMIPS
 	bool
 
+config PINCTRL_MT7620
+	bool "MediaTek MT7620 pin control driver"
+	select PINCTRL_MTMIPS
+	depends on SOC_MT7620 && PINCTRL_GENERIC
+	help
+	  Support pin multiplexing control on MediaTek MT7620.
+	  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 3ba5c0c66d..ba945a89a7 100644
@@ -4,4 +4,5 @@
 obj-$(CONFIG_PINCTRL_MTMIPS) += pinctrl-mtmips-common.o
 
 # SoC Drivers
+obj-$(CONFIG_PINCTRL_MT7620) += pinctrl-mt7620.o
 obj-$(CONFIG_PINCTRL_MT7628) += pinctrl-mt7628.o
drivers/pinctrl/mtmips/pinctrl-mt7620.c new file +200 -0

200 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#20 lore raw

PATCH v4 14/23 watchdog: add watchdog driver for MediaTek MT7620 SoC

In reply to Weijie Gao

This patch adds watchdog support for the Mediatek MT7620 SoC

---
v4 changes: none
v3 changes: add detail comments for mt7620_wdt_expire_now() v2 changes: add expire_now

---
 drivers/watchdog/Kconfig      |   7 ++
 drivers/watchdog/Makefile     |   1 +
 drivers/watchdog/mt7620_wdt.c | 142 ++++++++++++++++++++++++++++++++++
 3 files changed, 150 insertions(+)
 create mode 100644 drivers/watchdog/mt7620_wdt.c
drivers/watchdog/Kconfig +7 -0
index 4532a40e45..7d7bd4dcb7 100644
@@ -125,6 +125,13 @@ config WDT_MPC8xx
 	help
 	  Select this to enable mpc8xx watchdog timer
 
+config WDT_MT7620
+	bool "MediaTek MT7620 watchdog timer support"
+	depends on WDT && SOC_MT7620
+	help
+	  Select this to enable watchdog timer on MediaTek MT7620 and earlier
+	  SoC chips.
+
 config WDT_MT7621
 	bool "MediaTek MT7621 watchdog timer support"
 	depends on WDT && SOC_MT7628
drivers/watchdog/Makefile +1 -0
index 01b8231f2b..825b50e626 100644
@@ -24,6 +24,7 @@ obj-$(CONFIG_WDT_CORTINA) += cortina_wdt.o
 obj-$(CONFIG_WDT_ORION) += orion_wdt.o
 obj-$(CONFIG_WDT_CDNS) += cdns_wdt.o
 obj-$(CONFIG_WDT_MPC8xx) += mpc8xx_wdt.o
+obj-$(CONFIG_WDT_MT7620) += mt7620_wdt.o
 obj-$(CONFIG_WDT_MT7621) += mt7621_wdt.o
 obj-$(CONFIG_WDT_MTK) += mtk_wdt.o
 obj-$(CONFIG_WDT_OCTEONTX) += octeontx_wdt.o
drivers/watchdog/mt7620_wdt.c new file +142 -0

142 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#21 lore raw

PATCH v4 15/23 gpio: add GPIO controller driver for MediaTek MT7620 SoC

In reply to Weijie Gao

This patch adds GPIO controller driver for MediaTek MT7620 SoC

---
v4 changes: none
v3 changes: none
v2 changes: none

---
 drivers/gpio/Kconfig       |   8 ++
 drivers/gpio/Makefile      |   1 +
 drivers/gpio/mt7620_gpio.c | 146 +++++++++++++++++++++++++++++++++++++
 3 files changed, 155 insertions(+)
 create mode 100644 drivers/gpio/mt7620_gpio.c
drivers/gpio/Kconfig +8 -0
index 202fcc6f47..7e94759a79 100644
@@ -471,6 +471,14 @@ config MPC83XX_SPISEL_BOOT
 
 	  This pin is typically used as spi chip select to a spi nor flash.
 
+config MT7620_GPIO
+	bool "MediaTek MT7620 GPIO driver"
+	depends on DM_GPIO && SOC_MT7620
+	default y
+	help
+	  Device model driver for GPIO controller present in MediaTek MT7620
+	  and earlier SoCs.
+
 config MT7621_GPIO
 	bool "MediaTek MT7621 GPIO driver"
 	depends on DM_GPIO && SOC_MT7628
drivers/gpio/Makefile +1 -0
index d3d0d3cacf..8541ba0b0a 100644
@@ -64,6 +64,7 @@ obj-$(CONFIG_MVEBU_GPIO)	+= mvebu_gpio.o
 obj-$(CONFIG_MSM_GPIO)		+= msm_gpio.o
 obj-$(CONFIG_$(SPL_)PCF8575_GPIO)	+= pcf8575_gpio.o
 obj-$(CONFIG_PM8916_GPIO)	+= pm8916_gpio.o
+obj-$(CONFIG_MT7620_GPIO)	+= mt7620_gpio.o
 obj-$(CONFIG_MT7621_GPIO)	+= mt7621_gpio.o
 obj-$(CONFIG_MSCC_SGPIO)	+= mscc_sgpio.o
 obj-$(CONFIG_NX_GPIO)		+= nx_gpio.o
drivers/gpio/mt7620_gpio.c new file +146 -0

146 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#22 lore raw

PATCH v4 16/23 spi: add spi controller support for MediaTek MT7620 SoC

In reply to Weijie Gao

This patch adds spi controller support for MediaTek MT7620 SoC.

The SPI controller supports two chip selects. These two chip selects are implemented as two separate register groups, but they share the same bus (DI/DO/CLK), only CS pins are dedicated for each register group. Appearently these two register groups cannot operates simulataneously so they are implemented as one controller.

---
v4 changes: none
v3 changes: use bool instead of int in for mt7620_spi_set_cs() v2 changes: none

---
 drivers/spi/Kconfig      |   7 +
 drivers/spi/Makefile     |   1 +
 drivers/spi/mt7620_spi.c | 281 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 289 insertions(+)
 create mode 100644 drivers/spi/mt7620_spi.c
drivers/spi/Kconfig +7 -0
index f7a9852565..ec50d843ef 100644
@@ -202,6 +202,13 @@ config MSCC_BB_SPI
 	  Enable MSCC bitbang SPI driver. This driver can be used on
 	  MSCC SOCs.
 
+config MT7620_SPI
+	bool "MediaTek MT7620 SPI driver"
+	depends on SOC_MT7620
+	help
+	  Enable the MT7620 SPI driver. This driver can be used to access
+	  generic SPI devices on MediaTek MT7620 SoC.
+
 config MT7621_SPI
 	bool "MediaTek MT7621 SPI driver"
 	depends on SOC_MT7628
drivers/spi/Makefile +1 -0
index d9b5bd9b79..bfd142d153 100644
@@ -36,6 +36,7 @@ obj-$(CONFIG_MESON_SPIFC) += meson_spifc.o
 obj-$(CONFIG_MPC8XX_SPI) += mpc8xx_spi.o
 obj-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
 obj-$(CONFIG_MTK_SNFI_SPI) += mtk_snfi_spi.o
+obj-$(CONFIG_MT7620_SPI) += mt7620_spi.o
 obj-$(CONFIG_MT7621_SPI) += mt7621_spi.o
 obj-$(CONFIG_MSCC_BB_SPI) += mscc_bb_spi.o
 obj-$(CONFIG_MVEBU_A3700_SPI) += mvebu_a3700_spi.o
drivers/spi/mt7620_spi.c new file +281 -0

281 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#23 lore raw

PATCH v4 17/23 phy: add USB PHY driver for MediaTek MT7620 SoC

In reply to Weijie Gao

This patch adds USB PHY driver for MediaTek MT7620 SoC

---
v4 changes: none
v3 changes: remove duplicated dev field in mt7620_usb_phy v2 changes: none

---
 drivers/phy/Kconfig          |   7 +++
 drivers/phy/Makefile         |   1 +
 drivers/phy/mt7620-usb-phy.c | 110 +++++++++++++++++++++++++++++++++++
 3 files changed, 118 insertions(+)
 create mode 100644 drivers/phy/mt7620-usb-phy.c
drivers/phy/Kconfig +7 -0
index d12a6b02ad..ab638f0e7d 100644
@@ -218,6 +218,13 @@ config KEYSTONE_USB_PHY
 
 	  This PHY is found on some Keystone (K2) devices supporting USB.
 
+config MT7620_USB_PHY
+	bool "MediaTek MT7620 USB PHY support"
+	depends on PHY
+	depends on SOC_MT7620
+	help
+          Support the intergated USB PHY in MediaTek MT7620 SoC
+
 config MT76X8_USB_PHY
 	bool "MediaTek MT76x8 (7628/88) USB PHY support"
 	depends on PHY
drivers/phy/Makefile +1 -0
index 45a7fe5b56..6b3761b8c8 100644
@@ -24,6 +24,7 @@ obj-$(CONFIG_MESON_G12A_USB_PHY) += meson-g12a-usb2.o meson-g12a-usb3-pcie.o
 obj-$(CONFIG_MSM8916_USB_PHY) += msm8916-usbh-phy.o
 obj-$(CONFIG_OMAP_USB2_PHY) += omap-usb2-phy.o
 obj-$(CONFIG_KEYSTONE_USB_PHY) += keystone-usb-phy.o
+obj-$(CONFIG_MT7620_USB_PHY) += mt7620-usb-phy.o
 obj-$(CONFIG_MT76X8_USB_PHY) += mt76x8-usb-phy.o
 obj-$(CONFIG_PHY_DA8XX_USB) += phy-da8xx-usb.o
 obj-$(CONFIG_PHY_MTK_TPHY) += phy-mtk-tphy.o
drivers/phy/mt7620-usb-phy.c new file +110 -0

110 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#24 lore raw

PATCH v4 18/23 net: add ethernet driver for MediaTek MT7620 SoC

In reply to Weijie Gao

This patch adds ethernet driver for MediaTek MT7620 SoC.

The MT7620 SoC has a built-in ethernet (Frame Engine) and a built-in 7-port switch and two xMII interfaces (can be MII/RMII/RGMII).

The port 0-3 of the switch connects to intergrited FE PHYs. Port 4 can be configured to connect to either the intergrited FE PHY, or the xMII. Port 5 always connects to the xMII. Port 6 is the CPU port.

This driver supports MT7530 giga switch connects to port 5.

---
v4 changes: none
v3 changes: none
v2 changes: none

---
 drivers/net/Kconfig      |   12 +
 drivers/net/Makefile     |    1 +
 drivers/net/mt7620-eth.c | 1222 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 1235 insertions(+)
 create mode 100644 drivers/net/mt7620-eth.c
drivers/net/Kconfig +12 -0
index 3a5e036880..d1a52c7264 100644
@@ -399,6 +399,18 @@ config MACB_ZYNQ
 	  The Cadence MACB ethernet interface was used on Zynq platform.
 	  Say Y to enable support for the MACB/GEM in Zynq chip.
 
+config MT7620_ETH
+	bool "MediaTek MT7620 Ethernet Interface"
+	depends on SOC_MT7620
+	select PHYLIB
+	select DM_RESET
+	select DM_GPIO
+	select CLK
+	help
+	  The MediaTek MT7620 ethernet interface is used on MT7620 based
+	  boards. It has a built-in switch with two configurable ports which
+	  can connect to external PHY/MACs.
+
 config MT7628_ETH
 	bool "MediaTek MT7628 Ethernet Interface"
 	depends on SOC_MT7628
drivers/net/Makefile +1 -0
index e3bdda359d..f2a0df509d 100644
@@ -44,6 +44,7 @@ obj-$(CONFIG_MDIO_IPQ4019) += mdio-ipq4019.o
 obj-$(CONFIG_MDIO_MUX_I2CREG) += mdio_mux_i2creg.o
 obj-$(CONFIG_MDIO_MUX_SANDBOX) += mdio_mux_sandbox.o
 obj-$(CONFIG_MPC8XX_FEC) += mpc8xx_fec.o
+obj-$(CONFIG_MT7620_ETH) += mt7620-eth.o
 obj-$(CONFIG_MT7628_ETH) += mt7628-eth.o
 obj-$(CONFIG_MVGBE) += mvgbe.o
 obj-$(CONFIG_MVMDIO) += mvmdio.o
drivers/net/mt7620-eth.c new file +1222 -0

1,222 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#25 lore raw

PATCH v4 19/23 mmc: mtk-sd: fix sclk cycles shift value

In reply to Weijie Gao

It turns out that the sclk cycles used by mt7620/mt7628 is the same as other chips (20 bits, 1048576), not 65536.

This patch removes sclk_cycle_shift from dev_comp, and uses a macro with a value 20 instead.

---
v4 changes: none
v3 changes: new

---
 drivers/mmc/mtk-sd.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/mmc/mtk-sd.c +4 -9
index 4f9fa7d0ec..63ff68272c 100644
@@ -166,6 +166,8 @@
 
 #define DEFAULT_CD_DEBOUNCE		8
 
+#define SCLK_CYCLES_SHIFT		20
+
 #define CMD_INTS_MASK	\
 	(MSDC_INT_CMDRDY | MSDC_INT_RSPCRCERR | MSDC_INT_CMDTMO)
 
@@ -256,7 +258,6 @@ struct msdc_top_regs {
 
 struct msdc_compatible {
 	u8 clk_div_bits;
-	u8 sclk_cycle_shift;
 	bool pad_tune0;
 	bool async_fifo;
 	bool data_tune;
@@ -722,7 +723,7 @@ static int msdc_ops_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
 
 static void msdc_set_timeout(struct msdc_host *host, u32 ns, u32 clks)
 {
-	u32 timeout, clk_ns, shift;
+	u32 timeout, clk_ns, shift = SCLK_CYCLES_SHIFT;
 	u32 mode = 0;
 
 	host->timeout_ns = ns;
@@ -731,7 +732,6 @@ static void msdc_set_timeout(struct msdc_host *host, u32 ns, u32 clks)
 	if (host->sclk == 0) {
 		timeout = 0;
 	} else {
-		shift = host->dev_comp->sclk_cycle_shift;
 		clk_ns = 1000000000UL / host->sclk;
 		timeout = (ns + clk_ns - 1) / clk_ns + clks;
 		/* unit is 1048576 sclk cycles */
@@ -1531,7 +1531,7 @@ static int msdc_drv_probe(struct udevice *dev)
 
 	host->mmc = &plat->mmc;
 	host->timeout_ns = 100000000;
-	host->timeout_clks = 3 * (1 << host->dev_comp->sclk_cycle_shift);
+	host->timeout_clks = 3 * (1 << SCLK_CYCLES_SHIFT);
 
 #ifdef CONFIG_PINCTRL
 	pinctrl_select_state(dev, "default");
@@ -1615,7 +1615,6 @@ static const struct dm_mmc_ops msdc_ops = {
 
 static const struct msdc_compatible mt7620_compat = {
 	.clk_div_bits = 8,
-	.sclk_cycle_shift = 16,
 	.pad_tune0 = false,
 	.async_fifo = false,
 	.data_tune = false,
@@ -1635,7 +1634,6 @@ static const struct msdc_compatible mt7622_compat = {
 
 static const struct msdc_compatible mt7623_compat = {
 	.clk_div_bits = 12,
-	.sclk_cycle_shift = 20,
 	.pad_tune0 = true,
 	.async_fifo = true,
 	.data_tune = true,
@@ -1646,7 +1644,6 @@ static const struct msdc_compatible mt7623_compat = {
 
 static const struct msdc_compatible mt8512_compat = {
 	.clk_div_bits = 12,
-	.sclk_cycle_shift = 20,
 	.pad_tune0 = true,
 	.async_fifo = true,
 	.data_tune = true,
@@ -1656,7 +1653,6 @@ static const struct msdc_compatible mt8512_compat = {
 
 static const struct msdc_compatible mt8516_compat = {
 	.clk_div_bits = 12,
-	.sclk_cycle_shift = 20,
 	.pad_tune0 = true,
 	.async_fifo = true,
 	.data_tune = true,
@@ -1666,7 +1662,6 @@ static const struct msdc_compatible mt8516_compat = {
 
 static const struct msdc_compatible mt8183_compat = {
 	.clk_div_bits = 12,
-	.sclk_cycle_shift = 20,
 	.pad_tune0 = true,
 	.async_fifo = true,
 	.data_tune = true,
Signature · 1 line
2.17.1
author
#26 lore raw

PATCH v4 20/23 mmc: mtk-sd: add pad control settings for MediaTek MT7620/MT76x8 SoCs

In reply to Weijie Gao

The driver is missing pad control settings (pad delay and pad conf) for the mt7620 and mt76x8. Although mt76x8 still works well, mt7620 will encounter CRC error on data transfers.

This patch adds default pad control settings for mt7620_compat.

---
v4 changes: none
v3 changes: none
v2 changes: none

---
 drivers/mmc/mtk-sd.c | 121 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 118 insertions(+), 3 deletions(-)
drivers/mmc/mtk-sd.c +118 -3
index 63ff68272c..f4ff8822f2 100644
@@ -113,7 +113,51 @@
 #define MSDC_PB2_RESPWAIT_M		0x0c
 #define MSDC_PB2_RESPWAIT_S		2
 
+/* MSDC_PAD_CTRL0 */
+#define MSDC_PAD_CTRL0_CLKRDSEL_M	0xff000000
+#define MSDC_PAD_CTRL0_CLKRDSEL_S	24
+#define MSDC_PAD_CTRL0_CLKTDSEL		BIT(20)
+#define MSDC_PAD_CTRL0_CLKIES		BIT(19)
+#define MSDC_PAD_CTRL0_CLKSMT		BIT(18)
+#define MSDC_PAD_CTRL0_CLKPU		BIT(17)
+#define MSDC_PAD_CTRL0_CLKPD		BIT(16)
+#define MSDC_PAD_CTRL0_CLKSR		BIT(8)
+#define MSDC_PAD_CTRL0_CLKDRVP_M	0x70
+#define MSDC_PAD_CTRL0_CLKDRVP_S	4
+#define MSDC_PAD_CTRL0_CLKDRVN_M	0x7
+#define MSDC_PAD_CTRL0_CLKDRVN_S	0
+
+/* MSDC_PAD_CTRL1 */
+#define MSDC_PAD_CTRL1_CMDRDSEL_M	0xff000000
+#define MSDC_PAD_CTRL1_CMDRDSEL_S	24
+#define MSDC_PAD_CTRL1_CMDTDSEL		BIT(20)
+#define MSDC_PAD_CTRL1_CMDIES		BIT(19)
+#define MSDC_PAD_CTRL1_CMDSMT		BIT(18)
+#define MSDC_PAD_CTRL1_CMDPU		BIT(17)
+#define MSDC_PAD_CTRL1_CMDPD		BIT(16)
+#define MSDC_PAD_CTRL1_CMDSR		BIT(8)
+#define MSDC_PAD_CTRL1_CMDDRVP_M	0x70
+#define MSDC_PAD_CTRL1_CMDDRVP_S	4
+#define MSDC_PAD_CTRL1_CMDDRVN_M	0x7
+#define MSDC_PAD_CTRL1_CMDDRVN_S	0
+
+/* MSDC_PAD_CTRL2 */
+#define MSDC_PAD_CTRL2_DATRDSEL_M	0xff000000
+#define MSDC_PAD_CTRL2_DATRDSEL_S	24
+#define MSDC_PAD_CTRL2_DATTDSEL		BIT(20)
+#define MSDC_PAD_CTRL2_DATIES		BIT(19)
+#define MSDC_PAD_CTRL2_DATSMT		BIT(18)
+#define MSDC_PAD_CTRL2_DATPU		BIT(17)
+#define MSDC_PAD_CTRL2_DATPD		BIT(16)
+#define MSDC_PAD_CTRL2_DATSR		BIT(8)
+#define MSDC_PAD_CTRL2_DATDRVP_M	0x70
+#define MSDC_PAD_CTRL2_DATDRVP_S	4
+#define MSDC_PAD_CTRL2_DATDRVN_M	0x7
+#define MSDC_PAD_CTRL2_DATDRVN_S	0
+
 /* PAD_TUNE */
+#define MSDC_PAD_TUNE_CLKTDLY_M		0xf8000000
+#define MSDC_PAD_TUNE_CLKTDLY_S		27
 #define MSDC_PAD_TUNE_CMDRRDLY_M	0x7c00000
 #define MSDC_PAD_TUNE_CMDRRDLY_S	22
 #define MSDC_PAD_TUNE_CMD_SEL		BIT(21)
@@ -129,6 +173,26 @@
 #define PAD_CMD_TUNE_RX_DLY3		0x3E
 #define PAD_CMD_TUNE_RX_DLY3_S		1
 
+/* PAD_TUNE0 */
+#define MSDC_PAD_TUNE0_DAT0RDDLY_M	0x1f000000
+#define MSDC_PAD_TUNE0_DAT0RDDLY_S	24
+#define MSDC_PAD_TUNE0_DAT1RDDLY_M	0x1f0000
+#define MSDC_PAD_TUNE0_DAT1RDDLY_S	16
+#define MSDC_PAD_TUNE0_DAT2RDDLY_M	0x1f00
+#define MSDC_PAD_TUNE0_DAT2RDDLY_S	8
+#define MSDC_PAD_TUNE0_DAT3RDDLY_M	0x1f
+#define MSDC_PAD_TUNE0_DAT3RDDLY_S	0
+
+/* PAD_TUNE1 */
+#define MSDC_PAD_TUNE1_DAT4RDDLY_M	0x1f000000
+#define MSDC_PAD_TUNE1_DAT4RDDLY_S	24
+#define MSDC_PAD_TUNE1_DAT5RDDLY_M	0x1f0000
+#define MSDC_PAD_TUNE1_DAT5RDDLY_S	16
+#define MSDC_PAD_TUNE1_DAT6RDDLY_M	0x1f00
+#define MSDC_PAD_TUNE1_DAT6RDDLY_S	8
+#define MSDC_PAD_TUNE1_DAT7RDDLY_M	0x1f
+#define MSDC_PAD_TUNE1_DAT7RDDLY_S	0
+
 /* EMMC50_CFG0 */
 #define EMMC50_CFG_CFCSTS_SEL		BIT(4)
 
@@ -223,7 +287,10 @@ struct mtk_sd_regs {
 	u32 dat3_tune_crc;
 	u32 cmd_tune_crc;
 	u32 sdio_tune_wind;
-	u32 reserved4[5];
+	u32 reserved4[2];
+	u32 pad_ctrl0;
+	u32 pad_ctrl1;
+	u32 pad_ctrl2;
 	u32 pad_tune;
 	u32 pad_tune0;
 	u32 pad_tune1;
@@ -264,6 +331,8 @@ struct msdc_compatible {
 	bool busy_check;
 	bool stop_clk_fix;
 	bool enhance_rx;
+	bool builtin_pad_ctrl;
+	bool default_pad_dly;
 };
 
 struct msdc_delay_phase {
@@ -1391,9 +1460,14 @@ static void msdc_init_hw(struct msdc_host *host)
 {
 	u32 val;
 	void __iomem *tune_reg = &host->base->pad_tune;
+	void __iomem *rd_dly0_reg = &host->base->pad_tune0;
+	void __iomem *rd_dly1_reg = &host->base->pad_tune1;
 
-	if (host->dev_comp->pad_tune0)
+	if (host->dev_comp->pad_tune0) {
 		tune_reg = &host->base->pad_tune0;
+		rd_dly0_reg = &host->base->dat_rd_dly[0];
+		rd_dly1_reg = &host->base->dat_rd_dly[1];
+	}
 
 	/* Configure to MMC/SD mode, clock free running */
 	setbits_le32(&host->base->msdc_cfg, MSDC_CFG_MODE);
@@ -1479,6 +1553,45 @@ static void msdc_init_hw(struct msdc_host *host)
 		setbits_le32(tune_reg, MSDC_PAD_TUNE_RXDLYSEL);
 	}
 
+	if (host->dev_comp->builtin_pad_ctrl) {
+		/* Set pins driving strength */
+		writel(MSDC_PAD_CTRL0_CLKPD | MSDC_PAD_CTRL0_CLKSMT |
+		       MSDC_PAD_CTRL0_CLKIES | (4 << MSDC_PAD_CTRL0_CLKDRVN_S) |
+		       (4 << MSDC_PAD_CTRL0_CLKDRVP_S), &host->base->pad_ctrl0);
+		writel(MSDC_PAD_CTRL1_CMDPU | MSDC_PAD_CTRL1_CMDSMT |
+		       MSDC_PAD_CTRL1_CMDIES | (4 << MSDC_PAD_CTRL1_CMDDRVN_S) |
+		       (4 << MSDC_PAD_CTRL1_CMDDRVP_S), &host->base->pad_ctrl1);
+		writel(MSDC_PAD_CTRL2_DATPU | MSDC_PAD_CTRL2_DATSMT |
+		       MSDC_PAD_CTRL2_DATIES | (4 << MSDC_PAD_CTRL2_DATDRVN_S) |
+		       (4 << MSDC_PAD_CTRL2_DATDRVP_S), &host->base->pad_ctrl2);
+	}
+
+	if (host->dev_comp->default_pad_dly) {
+		/* Default pad delay may be needed if tuning not enabled */
+		clrsetbits_le32(tune_reg, MSDC_PAD_TUNE_CLKTDLY_M |
+				MSDC_PAD_TUNE_CMDRRDLY_M |
+				MSDC_PAD_TUNE_CMDRDLY_M |
+				MSDC_PAD_TUNE_DATRRDLY_M |
+				MSDC_PAD_TUNE_DATWRDLY_M,
+				(0x10 << MSDC_PAD_TUNE_CLKTDLY_S) |
+				(0x10 << MSDC_PAD_TUNE_CMDRRDLY_S) |
+				(0x10 << MSDC_PAD_TUNE_CMDRDLY_S) |
+				(0x10 << MSDC_PAD_TUNE_DATRRDLY_S) |
+				(0x10 << MSDC_PAD_TUNE_DATWRDLY_S));
+
+		writel((0x10 << MSDC_PAD_TUNE0_DAT0RDDLY_S) |
+		       (0x10 << MSDC_PAD_TUNE0_DAT1RDDLY_S) |
+		       (0x10 << MSDC_PAD_TUNE0_DAT2RDDLY_S) |
+		       (0x10 << MSDC_PAD_TUNE0_DAT3RDDLY_S),
+		       rd_dly0_reg);
+
+		writel((0x10 << MSDC_PAD_TUNE1_DAT4RDDLY_S) |
+		       (0x10 << MSDC_PAD_TUNE1_DAT5RDDLY_S) |
+		       (0x10 << MSDC_PAD_TUNE1_DAT6RDDLY_S) |
+		       (0x10 << MSDC_PAD_TUNE1_DAT7RDDLY_S),
+		       rd_dly1_reg);
+	}
+
 	/* Configure to enable SDIO mode otherwise sdio cmd5 won't work */
 	setbits_le32(&host->base->sdc_cfg, SDC_CFG_SDIO);
 
@@ -1620,7 +1733,9 @@ static const struct msdc_compatible mt7620_compat = {
 	.data_tune = false,
 	.busy_check = false,
 	.stop_clk_fix = false,
-	.enhance_rx = false
+	.enhance_rx = false,
+	.builtin_pad_ctrl = true,
+	.default_pad_dly = true,
 };
 
 static const struct msdc_compatible mt7622_compat = {
Signature · 1 line
2.17.1
author
#27 lore raw

PATCH v4 21/23 mmc: mtk-sd: assign plat->cfg.f_max with a correct value

In reply to Weijie Gao

Currently this driver does not set the value of plat->cfg.f_max, which results in that MMC framework will always run at the lowest frequency.

This patch sets plat->cfg.f_max to the maximum allowed frequency, which equals to the source clock frequency.

---
v4 changes: change plat->cfg.f_max to equal to host->src_clk_freq v3 changes: new

---
 drivers/mmc/mtk-sd.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mmc/mtk-sd.c +2 -0
index f4ff8822f2..77fda0eab0 100644
@@ -1639,6 +1639,8 @@ static int msdc_drv_probe(struct udevice *dev)
 	else
 		cfg->f_min = host->src_clk_freq / (4 * 4095);
 
+	cfg->f_max = host->src_clk_freq;
+
 	cfg->b_max = 1024;
 	cfg->voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
 
Signature · 1 line
2.17.1
author
#28 lore raw

PATCH v4 22/23 reset: reset-mtmips: add DM_FLAG_PRE_RELOC flag

In reply to Weijie Gao

Add DM_FLAG_PRE_RELOC flag for reset-mtmips to make sure this driver can be probed before relocation even if u-boot,dm-pre-reloc is not present in the dts.

---
v4 changes: none
v3 changes: none
v2 changes: new

---
 drivers/reset/reset-mtmips.c | 1 +
 1 file changed, 1 insertion(+)
drivers/reset/reset-mtmips.c +1 -0
index bc20e3335c..0d6a446465 100644
@@ -82,4 +82,5 @@ U_BOOT_DRIVER(mtmips_reset) = {
 	.probe = mtmips_reset_probe,
 	.priv_auto_alloc_size = sizeof(struct mtmips_reset_priv),
 	.ops = &mtmips_reset_ops,
+	.flags = DM_FLAG_PRE_RELOC,
 };
Signature · 1 line
2.17.1
author
#29 lore raw

PATCH v4 23/23 MAINTAINERS: add maintainer for MediaTek MIPS platform

In reply to Weijie Gao

Update maintainer for MediaTek MIPS platform

---
v4 changes: none
v3 changes: none
v2 changes: none

---
 MAINTAINERS | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
MAINTAINERS +23 -0
index 874cf2c0e5..0123afe7cf 100644
@@ -802,6 +802,29 @@ F:	drivers/mmc/ca_dw_mmc.c
 F:	drivers/i2c/i2c-cortina.c
 F:	drivers/i2c/i2c-cortina.h
 
+MIPS MEDIATEK
+M:	Weijie Gao <[email protected]>
+R:	GSS_MTK_Uboot_upstream <[email protected]>
+S:	Maintained
+F:	arch/mips/mach-mtmips/
+F:	arch/mips/dts/mt7620.dtsi
+F:	arch/mips/dts/mt7620-u-boot.dtsi
+F:	include/configs/mt7620.h
+F:	include/dt-bindings/clock/mt7620-clk.h
+F:	include/dt-bindings/clock/mt7628-clk.h
+F:	include/dt-bindings/reset/mt7620-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/net/mt7620-eth.c
+F:	drivers/phy/mt7620-usb-phy.c
+F:	drivers/reset/reset-mtmips.c
+F:	drivers/serial/serial_mt7620.c
+F:	drivers/spi/mt7620_spi.c
+F:	drivers/sysreset/sysreset_resetctl.c
+F:	drivers/watchdog/mt7620_wdt.c
+
 MIPS MSCC
 M:	Gregory CLEMENT <[email protected]>
 M:	Lars Povlsen <[email protected]>
Signature · 1 line
2.17.1