Add support for MediaTek MT7620 SoC
Subsystems (13)
v2 cover Add support for MediaTek MT7620 SoC
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
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 (21):
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: add pad control settings for MediaTek MT7620/MT76x8 SoCs
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 | 122 +- 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 | 113 ++ 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.c | 2 + drivers/serial/serial_mt7620.c | 246 ++++ drivers/spi/Kconfig | 7 + drivers/spi/Makefile | 1 + drivers/spi/mt7620_spi.c | 277 ++++ drivers/watchdog/Kconfig | 7 + drivers/watchdog/Makefile | 1 + drivers/watchdog/mt7620_wdt.c | 132 ++ include/configs/mt7620.h | 46 + include/dt-bindings/clock/mt7620-clk.h | 40 + include/dt-bindings/reset/mt7620-reset.h | 35 + 62 files changed, 4463 insertions(+), 63 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
PATCH v2 1/21 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.
---
v2 changes: none
--- arch/mips/dts/Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/mips/dts/Makefile +2 -3
@@ -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
PATCH v2 2/21 mips: mtmips: move mt7628 related Kconfig into mt7628 subdirectory
In reply to Weijie GaoThis 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.
---
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
@@ -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
PATCH v2 3/21 mips: mtmips: select SYSRESET for mt7628 only
In reply to Weijie GaoCurrently only mt7628 needs the sysreset driver, do not select it for mt7620.
---
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
@@ -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
@@ -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
PATCH v2 4/21 mips: mtmips: fix dram size detection in dram_init
In reply to Weijie GaoCONFIG_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.
---
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
@@ -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
PATCH v2 5/21 mips: enable _machine_restart for spl
In reply to Weijie GaoThe 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.
---
v2 changes: new
--- arch/mips/cpu/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/cpu/cpu.c +1 -1
@@ -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
PATCH v2 6/21 mips: mtmips: add support to initialize SDRAM
In reply to Weijie GaoThis patch adds support for mtmips SoCs to initialize the SDRAM.
---
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
@@ -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
@@ -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
PATCH v2 7/21 mips: mtmips: add support for MediaTek MT7620 SoC
In reply to Weijie GaoThis patch adds support for MediaTek MT7620 SoC.
All files are dedicated for u-boot.
---
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v2 8/21 mips: mtmips: add two reference boards for mt7620
In reply to Weijie GaoThe 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.
---
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-y += board.o
board/mediatek/mt7620/board.c new file +6 -0
@@ -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
PATCH v2 9/21 configs: mtmips: refresh for mt7628 based boards
In reply to Weijie GaoSince 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.
---
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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v2 10/21 serial: add uart driver for MediaTek MT7620 SoC
In reply to Weijie GaoThis 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.
---
v2 changes: replace non-DM code with of-platdata
--- drivers/serial/Kconfig | 20 +++ drivers/serial/Makefile | 1 + drivers/serial/serial.c | 2 + drivers/serial/serial_mt7620.c | 246 +++++++++++++++++++++++++++++++++ 4 files changed, 269 insertions(+) create mode 100644 drivers/serial/serial_mt7620.c
drivers/serial/Kconfig +20 -0
@@ -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
@@ -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.c +2 -0
@@ -127,6 +127,7 @@ serial_initfunc(pl01x_serial_initialize);serial_initfunc (pxa_serial_initialize);serial_initfunc (sh_serial_initialize);serial_initfunc (mtk_serial_initialize); +serial_initfunc (mt7620_serial_initialize);/** * serial_register() - Register serial driver with serial driver core
@@ -181,6 +182,7 @@ int serial_initialize(void)pxa_serial_initialize ();sh_serial_initialize ();mtk_serial_initialize (); +mt7620_serial_initialize ();serial_assign (default_serial_console ()->name);
drivers/serial/serial_mt7620.c new file +246 -0
246 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 11/21 clk: add clock driver for MediaTek MT7620 SoC
In reply to Weijie GaoThis 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.
---
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
@@ -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
@@ -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
PATCH v2 12/21 reset: mtmips: add reset controller support for MediaTek MT7620 SoC
In reply to Weijie GaoThis patch adds reset controller bits definition header file for MediaTek MT7620 SoC
---
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
@@ -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
PATCH v2 13/21 pinctrl: mtmips: add support for MediaTek MT7620 SoC
In reply to Weijie GaoThis patch adds pinctrl support for MediaTek MT7620 SoC. The MT7620 SoC supports only pinmux.
---
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
@@ -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
@@ -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
PATCH v2 14/21 watchdog: add watchdog driver for MediaTek MT7620 SoC
In reply to Weijie GaoThis patch adds watchdog support for the Mediatek MT7620 SoC
---
v2 changes: add expire_now
--- drivers/watchdog/Kconfig | 7 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/mt7620_wdt.c | 132 ++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+) create mode 100644 drivers/watchdog/mt7620_wdt.c
drivers/watchdog/Kconfig +7 -0
@@ -124,6 +124,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
@@ -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 +132 -0
132 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 15/21 gpio: add GPIO controller driver for MediaTek MT7620 SoC
In reply to Weijie GaoThis patch adds GPIO controller driver for MediaTek MT7620 SoC
---
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
@@ -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
@@ -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
PATCH v2 16/21 spi: add spi controller support for MediaTek MT7620 SoC
In reply to Weijie GaoThis 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.
---
v2 changes: none
--- drivers/spi/Kconfig | 7 + drivers/spi/Makefile | 1 + drivers/spi/mt7620_spi.c | 277 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 285 insertions(+) create mode 100644 drivers/spi/mt7620_spi.c
drivers/spi/Kconfig +7 -0
@@ -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
@@ -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 +277 -0
277 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 17/21 phy: add USB PHY driver for MediaTek MT7620 SoC
In reply to Weijie GaoThis patch adds USB PHY driver for MediaTek MT7620 SoC
---
v2 changes: none
--- drivers/phy/Kconfig | 7 +++ drivers/phy/Makefile | 1 + drivers/phy/mt7620-usb-phy.c | 113 +++++++++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 drivers/phy/mt7620-usb-phy.c
drivers/phy/Kconfig +7 -0
@@ -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
@@ -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 +113 -0
113 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 18/21 net: add ethernet driver for MediaTek MT7620 SoC
In reply to Weijie GaoThis 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.
---
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
@@ -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
@@ -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
PATCH v2 19/21 mmc: mtk-sd: add pad control settings for MediaTek MT7620/MT76x8 SoCs
In reply to Weijie GaoThe 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.
Also a missing field .sclk_cycle_shift = 20 for mt7622 is added.
---
v2 changes: none
--- drivers/mmc/mtk-sd.c | 122 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 119 insertions(+), 3 deletions(-)
drivers/mmc/mtk-sd.c +119 -3
@@ -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)
@@ -221,7 +285,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;
@@ -263,6 +330,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 );
@@ -1621,11 +1734,14 @@ 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 = { .clk_div_bits =12 , + .sclk_cycle_shift =20 , .pad_tune0 = true, .async_fifo = true, .data_tune = true,
Signature · 1 line
2.17.1
PATCH v2 20/21 reset: reset-mtmips: add DM_FLAG_PRE_RELOC flag
In reply to Weijie GaoAdd 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.
---
v2 changes: new
--- drivers/reset/reset-mtmips.c | 1 + 1 file changed, 1 insertion(+)
drivers/reset/reset-mtmips.c +1 -0
@@ -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
PATCH v2 21/21 MAINTAINERS: add maintainer for MediaTek MIPS platform
In reply to Weijie GaoUpdate maintainer for MediaTek MIPS platform
---
v2 changes: none
--- MAINTAINERS | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
MAINTAINERS +23 -0
@@ -800,6 +800,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
PATCH v2 16/21 spi: add spi controller support for MediaTek MT7620 SoC
In reply to Weijie GaoQuoted 121 lines · 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.
Signed-off-by Weijie Gao <[email protected]>---
v2 changes: none--- drivers/spi/Kconfig | 7 + drivers/spi/Makefile | 1 + drivers/spi/mt7620_spi.c | 277 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 285 insertions(+) create mode 100644 drivers/spi/mt7620_spi.cdrivers/spi/Kconfig +7
-0@@ -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_MT7628drivers/spi/Makefile +1
-0@@ -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.odrivers/spi/mt7620_spi.c new file +66
-0@@ -0,0 +1,277 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2020 MediaTek Inc. +* +* Author: Weijie Gao <[email protected]> +* +* Generic SPI driver for MediaTek MT7620 SoC +*/ + +#include <clk.h> +#include <dm.h> +#include <spi.h> +#include <linux/bitops.h> +#include <linux/iopoll.h> +#include <linux/io.h> +#include <linux/log2.h> + +#define MT7620_SPI_NUM_CS 2 +#define MT7620_SPI_MASTER1_OFF 0x00 +#define MT7620_SPI_MASTER2_OFF 0x40 + +/* SPI_STAT */ +#define SPI_BUSY BIT(0) + +/* SPI_CFG */ +#define MSB_FIRST BIT(8) +#define SPI_CLK_POL BIT(6) +#define RX_CLK_EDGE BIT(5) +#define TX_CLK_EDGE BIT(4) +#define SPI_CLK_S 0 +#define SPI_CLK_M GENMASK(2, 0) + +/* SPI_CTL */ +#define START_WR BIT(2) +#define START_RD BIT(1) +#define SPI_HIGH BIT(0) + +#define SPI_ARB 0xf0 +#define ARB_EN BIT(31) + +struct mt7620_spi_master_regs { +u32 stat; +u32 reserved0[3 ]; +u32 cfg; +u32 ctl; +u32 reserved1[2 ]; +u32 data; +}; + +struct mt7620_spi { +void __iomem *regs; +struct mt7620_spi_master_regs *m[MT7620_SPI_NUM_CS ]; +unsigned int sys_freq; +u32 wait_us; +uint mode; +uint speed; +}; + +static void mt7620_spi_master_setup (struct mt7620_spi *ms,int cs) +{ +u32 rate, prescale, freq, tmo, cfg; + +/* Calculate the clock divsior */ + rate =DIV_ROUND_UP (ms->sys_freq, ms->speed); + rate =roundup_pow_of_two (rate); +
drivers/spi/mt7620_spi.c line 76
Quoted 10 lines
drivers/spi/mt7620_spi.c new file +10
-0+ prescale =ilog2 (rate /2 ); +if (prescale >6 ) + prescale =6 ; + +/* Calculate the real clock, and usecs for one byte transaction */ + freq = ms->sys_freq >> (prescale +1 ); + tmo =DIV_ROUND_UP (8 *1000000 , freq); + +/* 10 times tolerance plus 100us */ + ms->wait_us =10 * tmo +100 ;
Replace the above magic numbers with meaningful macros.
Quoted 128 lines
drivers/spi/mt7620_spi.c new file +128
-0+ +/* set SPI_CFG */ + cfg = prescale <<SPI_CLK_S ; + +switch (ms->mode & (SPI_CPOL |SPI_CPHA )) { +case SPI_MODE_0 : + cfg |=TX_CLK_EDGE ; +break ; +case SPI_MODE_1 : + cfg |=RX_CLK_EDGE ; +break ; +case SPI_MODE_2 : + cfg |=SPI_CLK_POL |RX_CLK_EDGE ; +break ; +case SPI_MODE_3 : + cfg |=SPI_CLK_POL |TX_CLK_EDGE ; +break ; + } + +if (!(ms->mode &SPI_LSB_FIRST )) + cfg |=MSB_FIRST ; + +writel (cfg, &ms->m[cs]->cfg); + +writel (SPI_HIGH , &ms->m[cs]->ctl); +} + +static void mt7620_spi_set_cs (struct mt7620_spi *ms,int cs,int enable) +{ +if (enable) +mt7620_spi_master_setup (ms, cs); + +if (ms->mode &SPI_CS_HIGH ) + enable = !enable; + +if (enable) +clrbits_32 (&ms->m[cs]->ctl,SPI_HIGH ); +else +setbits_32 (&ms->m[cs]->ctl,SPI_HIGH ); +} + +static int mt7620_spi_set_mode (struct udevice *bus,uint mode) +{ +struct mt7620_spi *ms =dev_get_priv (bus); + + ms->mode = mode; + +/* Mode 0 is buggy. Force to use mode 3 */ +if ((mode &SPI_MODE_3 ) ==SPI_MODE_0 ) + ms->mode |=SPI_MODE_3 ; + +return 0 ; +} + +static int mt7620_spi_set_speed (struct udevice *bus,uint speed) +{ +struct mt7620_spi *ms =dev_get_priv (bus); + + ms->speed = speed; + +return 0 ; +} + +static inline int mt7620_spi_busy_poll (struct mt7620_spi *ms,int cs) +{ +u32 val; + +return readl_poll_timeout (&ms->m[cs]->stat, val, !(val &SPI_BUSY ), + ms->wait_us); +} + +static int mt7620_spi_read (struct mt7620_spi *ms,int cs,u8 *buf,size_t len) +{ +int ret; + +while (len) { +setbits_32 (&ms->m[cs]->ctl,START_RD ); + + ret =mt7620_spi_busy_poll (ms, cs); +if (ret) { +pr_err ("SPI read transaction timeout\n" ); +return ret; + } + + *buf++ = (u8 )readl (&ms->m[cs]->data); + + len--; + } + +return 0 ; +} + +static int mt7620_spi_write (struct mt7620_spi *ms,int cs,const u8 *buf, +size_t len) +{ +int ret; + +while (len) { +writel (*buf++, &ms->m[cs]->data); +setbits_32 (&ms->m[cs]->ctl,START_WR ); + + ret =mt7620_spi_busy_poll (ms, cs); +if (ret) { +pr_err ("SPI write transaction timeout\n" ); +return ret; + } + + len--; + } + +return 0 ; +} + +static int mt7620_spi_xfer (struct udevice *dev,unsigned int bitlen, +const void *dout,void *din,unsigned long flags) +{ +struct udevice *bus = dev->parent; +struct mt7620_spi *ms =dev_get_priv (bus); +int total_size = bitlen >>3 ; +int cs, ret =0 ; + +/* +* This driver only supports half-duplex, so complain and bail out +* upon full-duplex messages +*/ +if (dout && din) { +pr_err ("Only half-duplex SPI transfer supported\n" ); +return -EIO ;
drivers/spi/mt7620_spi.c line 214
Quoted 10 lines
drivers/spi/mt7620_spi.c new file +10
-0+ } + + cs =spi_chip_select (dev); +if (cs <0 || cs >=MT7620_SPI_NUM_CS ) { +pr_err ("Invalid chip select %d\n" , cs); +return -EINVAL ; + } + +if (flags &SPI_XFER_BEGIN ) +mt7620_spi_set_cs (ms, cs,1 );
use boolean type for last argument.
drivers/spi/mt7620_spi.c line 222
Quoted 8 lines
drivers/spi/mt7620_spi.c new file +8
-0+ +if (din) + ret =mt7620_spi_read (ms, cs, din, total_size); +else if (dout) + ret =mt7620_spi_write (ms, cs, dout, total_size); + +if (flags &SPI_XFER_END ) +mt7620_spi_set_cs (ms, cs,0 );
same as above.
PATCH v2 14/21 watchdog: add watchdog driver for MediaTek MT7620 SoC
In reply to Weijie GaoQuoted 128 lines · Weijie Gao
This patch adds watchdog support for the Mediatek MT7620 SoC
Signed-off-by Weijie Gao <[email protected]>---
v2 changes: addexpire_now--- drivers/watchdog/Kconfig | 7 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/mt7620_wdt.c | 132 ++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+) create mode 100644 drivers/watchdog/mt7620_wdt.cdrivers/watchdog/Kconfig +7
-0@@ -124,6 +124,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_MT7628drivers/watchdog/Makefile +1
-0@@ -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.odrivers/watchdog/mt7620_wdt.c new file +79
-0@@ -0,0 +1,132 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2020 MediaTek Inc. +* +* Author: Weijie Gao <[email protected]> +* +* Watchdog timer for MT7620 and earlier SoCs +*/ + +#include <div64.h> +#include <dm.h> +#include <reset.h> +#include <wdt.h> +#include <linux/bitops.h> +#include <linux/io.h> + +struct mt7620_wdt { +void __iomem *regs; +u64 timeout; +}; + +#define TIMER_FREQ 40000000 +#define TIMER_MASK 0xffff +#define TIMER_PRESCALE 65536 + +#define TIMER_LOAD 0x00 +#define TIMER_CTL 0x08 + +#define TIMER_ENABLE BIT(7) +#define TIMER_MODE_SHIFT 4 +#define TIMER_MODE_WDT 3 +#define TIMER_PRESCALE_SHIFT 0 +#define TIMER_PRESCALE_65536 15 + +static void mt7620_wdt_ping (struct mt7620_wdt *priv) +{ +u64 val; + + val = (TIMER_FREQ /TIMER_PRESCALE ) * priv->timeout; +do_div (val,1000 ); + +if (val >TIMER_MASK ) + val =TIMER_MASK ; + +writel (val, priv->regs +TIMER_LOAD ); +} + +static int mt7620_wdt_start (struct udevice *dev,u64 ms,ulong flags) +{ +struct mt7620_wdt *priv =dev_get_priv (dev); + + priv->timeout = ms; +mt7620_wdt_ping (priv); + +writel (TIMER_ENABLE | (TIMER_MODE_WDT <<TIMER_MODE_SHIFT ) | + (TIMER_PRESCALE_65536 <<TIMER_PRESCALE_SHIFT ), + priv->regs +TIMER_CTL ); + +return 0 ; +} + +static int mt7620_wdt_stop (struct udevice *dev) +{ +struct mt7620_wdt *priv =dev_get_priv (dev); + +mt7620_wdt_ping (priv); + +clrbits_32 (priv->regs +TIMER_CTL ,TIMER_ENABLE ); + +return 0 ; +} + +static int mt7620_wdt_reset (struct udevice *dev) +{ +struct mt7620_wdt *priv =dev_get_priv (dev); + +mt7620_wdt_ping (priv); + +return 0 ;
drivers/watchdog/mt7620_wdt.c line 89
Quoted 10 lines
drivers/watchdog/mt7620_wdt.c new file +10
-0+} + +static int mt7620_wdt_expire_now (struct udevice *dev,ulong flags) +{ +struct mt7620_wdt *priv =dev_get_priv (dev); + +mt7620_wdt_start (dev,1 , flags); + +/* 0 will disable the timer, so use 1 instead */ +writel (1 , priv->regs +TIMER_LOAD );
Better replace the magic number with macro.
Otherwise,
PATCH v2 17/21 phy: add USB PHY driver for MediaTek MT7620 SoC
In reply to Weijie GaoQuoted 57 lines · Weijie Gao
This patch adds USB PHY driver for MediaTek MT7620 SoC
Signed-off-by Weijie Gao <[email protected]>---
v2 changes: none--- drivers/phy/Kconfig | 7 +++ drivers/phy/Makefile | 1 + drivers/phy/mt7620-usb-phy.c | 113 +++++++++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 drivers/phy/mt7620-usb-phy.cdrivers/phy/Kconfig +7
-0@@ -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 PHYdrivers/phy/Makefile +1
-0@@ -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.odrivers/phy/mt7620-usb-phy.c new file +8
-0@@ -0,0 +1,113 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2020 MediaTek Inc. All Rights Reserved. +* +* Author: Weijie Gao <[email protected]> +*/ + +#include <clk.h>
drivers/phy/mt7620-usb-phy.c line 18
Quoted 10 lines
drivers/phy/mt7620-usb-phy.c new file +10
-0+#include <dm.h> +#include <generic-phy.h> +#include <misc.h> +#include <reset.h> +#include <dm/device_compat.h> +#include <linux/delay.h> +#include <mach/mt7620-sysc.h> + +struct mt7620_usb_phy { +struct udevice *dev;
Why this explicit dev required here? generic_phy_get_ calls will assign phy->dev
PATCH v2 5/21 mips: enable _machine_restart for spl
In reply to Weijie GaoQuoted 11 lines · Weijie Gao
The sysreset driver has a config
CONFIG_SPL_SYSRESETfor the spl stage. ChangeCONFIG_SYSRESETtoCONFIG_IS_ENABLED(SYSRESET)will give spl a chance to use_machine_restartinstead of the sysreset driver.Signed-off-by Weijie Gao <[email protected]>---
v2 changes: new--- arch/mips/cpu/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
PATCH v2 10/21 serial: add uart driver for MediaTek MT7620 SoC
In reply to Weijie GaoQuoted 13 lines · 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.
Signed-off-by Weijie Gao <[email protected]>---
v2 changes: replace non-DM code with of-platdata
Quoted 8 lines
--- drivers/serial/Kconfig | 20 +++ drivers/serial/Makefile | 1 + drivers/serial/serial.c | 2 + drivers/serial/serial_mt7620.c | 246 +++++++++++++++++++++++++++++++++ 4 files changed, 269 insertions(+) create mode 100644 drivers/serial/serial_mt7620.c
PATCH v2 16/21 spi: add spi controller support for MediaTek MT7620 SoC
In reply to Jagan TekiQuoted 126 lines · Jagan Teki
Quoted 125 lines · 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.
Signed-off-by Weijie Gao <[email protected]>---
v2 changes: none--- drivers/spi/Kconfig | 7 + drivers/spi/Makefile | 1 + drivers/spi/mt7620_spi.c | 277 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 285 insertions(+) create mode 100644 drivers/spi/mt7620_spi.cdrivers/spi/Kconfig +7
-0@@ -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_MT7628drivers/spi/Makefile +1
-0@@ -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.odrivers/spi/mt7620_spi.c new file +70
-0@@ -0,0 +1,277 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2020 MediaTek Inc. +* +* Author: Weijie Gao <[email protected]> +* +* Generic SPI driver for MediaTek MT7620 SoC +*/ + +#include <clk.h> +#include <dm.h> +#include <spi.h> +#include <linux/bitops.h> +#include <linux/iopoll.h> +#include <linux/io.h> +#include <linux/log2.h> + +#define MT7620_SPI_NUM_CS 2 +#define MT7620_SPI_MASTER1_OFF 0x00 +#define MT7620_SPI_MASTER2_OFF 0x40 + +/* SPI_STAT */ +#define SPI_BUSY BIT(0) + +/* SPI_CFG */ +#define MSB_FIRST BIT(8) +#define SPI_CLK_POL BIT(6) +#define RX_CLK_EDGE BIT(5) +#define TX_CLK_EDGE BIT(4) +#define SPI_CLK_S 0 +#define SPI_CLK_M GENMASK(2, 0) + +/* SPI_CTL */ +#define START_WR BIT(2) +#define START_RD BIT(1) +#define SPI_HIGH BIT(0) + +#define SPI_ARB 0xf0 +#define ARB_EN BIT(31) + +struct mt7620_spi_master_regs { +u32 stat; +u32 reserved0[3 ]; +u32 cfg; +u32 ctl; +u32 reserved1[2 ]; +u32 data; +}; + +struct mt7620_spi { +void __iomem *regs; +struct mt7620_spi_master_regs *m[MT7620_SPI_NUM_CS ]; +unsigned int sys_freq; +u32 wait_us; +uint mode; +uint speed; +}; + +static void mt7620_spi_master_setup (struct mt7620_spi *ms,int cs) +{ +u32 rate, prescale, freq, tmo, cfg; + +/* Calculate the clock divsior */ + rate =DIV_ROUND_UP (ms->sys_freq, ms->speed); + rate =roundup_pow_of_two (rate); + + prescale =ilog2 (rate /2 ); +if (prescale >6 ) + prescale =6 ; +
Quoted 8 lines
drivers/spi/mt7620_spi.c line 76
Quoted 6 lines
drivers/spi/mt7620_spi.c new file +6
-0+/* Calculate the real clock, and usecs for one byte transaction */ + freq = ms->sys_freq >> (prescale +1 ); + tmo =DIV_ROUND_UP (8 *1000000 , freq); + +/* 10 times tolerance plus 100us */ + ms->wait_us =10 * tmo +100 ;Replace the above magic numbers with meaningful macros.
ok.
Quoted 133 lines
Quoted 133 lines
drivers/spi/mt7620_spi.c new file +132
-0+ +/* set SPI_CFG */ + cfg = prescale <<SPI_CLK_S ; + +switch (ms->mode & (SPI_CPOL |SPI_CPHA )) { +case SPI_MODE_0 : + cfg |=TX_CLK_EDGE ; +break ; +case SPI_MODE_1 : + cfg |=RX_CLK_EDGE ; +break ; +case SPI_MODE_2 : + cfg |=SPI_CLK_POL |RX_CLK_EDGE ; +break ; +case SPI_MODE_3 : + cfg |=SPI_CLK_POL |TX_CLK_EDGE ; +break ; + } + +if (!(ms->mode &SPI_LSB_FIRST )) + cfg |=MSB_FIRST ; + +writel (cfg, &ms->m[cs]->cfg); + +writel (SPI_HIGH , &ms->m[cs]->ctl); +} + +static void mt7620_spi_set_cs (struct mt7620_spi *ms,int cs,int enable) +{ +if (enable) +mt7620_spi_master_setup (ms, cs); + +if (ms->mode &SPI_CS_HIGH ) + enable = !enable; + +if (enable) +clrbits_32 (&ms->m[cs]->ctl,SPI_HIGH ); +else +setbits_32 (&ms->m[cs]->ctl,SPI_HIGH ); +} + +static int mt7620_spi_set_mode (struct udevice *bus,uint mode) +{ +struct mt7620_spi *ms =dev_get_priv (bus); + + ms->mode = mode; + +/* Mode 0 is buggy. Force to use mode 3 */ +if ((mode &SPI_MODE_3 ) ==SPI_MODE_0 ) + ms->mode |=SPI_MODE_3 ; + +return 0 ; +} + +static int mt7620_spi_set_speed (struct udevice *bus,uint speed) +{ +struct mt7620_spi *ms =dev_get_priv (bus); + + ms->speed = speed; + +return 0 ; +} + +static inline int mt7620_spi_busy_poll (struct mt7620_spi *ms,int cs) +{ +u32 val; + +return readl_poll_timeout (&ms->m[cs]->stat, val, !(val &SPI_BUSY ), + ms->wait_us); +} + +static int mt7620_spi_read (struct mt7620_spi *ms,int cs,u8 *buf,size_t len) +{ +int ret; + +while (len) { +setbits_32 (&ms->m[cs]->ctl,START_RD ); + + ret =mt7620_spi_busy_poll (ms, cs); +if (ret) { +pr_err ("SPI read transaction timeout\n" ); +return ret; + } + + *buf++ = (u8 )readl (&ms->m[cs]->data); + + len--; + } + +return 0 ; +} + +static int mt7620_spi_write (struct mt7620_spi *ms,int cs,const u8 *buf, +size_t len) +{ +int ret; + +while (len) { +writel (*buf++, &ms->m[cs]->data); +setbits_32 (&ms->m[cs]->ctl,START_WR ); + + ret =mt7620_spi_busy_poll (ms, cs); +if (ret) { +pr_err ("SPI write transaction timeout\n" ); +return ret; + } + + len--; + } + +return 0 ; +} + +static int mt7620_spi_xfer (struct udevice *dev,unsigned int bitlen, +const void *dout,void *din,unsigned long flags) +{ +struct udevice *bus = dev->parent; +struct mt7620_spi *ms =dev_get_priv (bus); +int total_size = bitlen >>3 ; +int cs, ret =0 ; + +/* +* This driver only supports half-duplex, so complain and bail out +* upon full-duplex messages +*/ +if (dout && din) { +pr_err ("Only half-duplex SPI transfer supported\n" ); +return -EIO ; + } + + cs =spi_chip_select (dev); +if (cs <0 || cs >=MT7620_SPI_NUM_CS ) {
Quoted 8 lines
drivers/spi/mt7620_spi.c line 214
Quoted 6 lines
drivers/spi/mt7620_spi.c new file +6
-0+pr_err ("Invalid chip select %d\n" , cs); +return -EINVAL ; + } + +if (flags &SPI_XFER_BEGIN ) +mt7620_spi_set_cs (ms, cs,1 );use boolean type for last argument.
ok.
Quoted 11 lines
drivers/spi/mt7620_spi.c line 222
Quoted 9 lines
drivers/spi/mt7620_spi.c new file +8
-0+ +if (din) + ret =mt7620_spi_read (ms, cs, din, total_size); +else if (dout) + ret =mt7620_spi_write (ms, cs, dout, total_size); + +if (flags &SPI_XFER_END ) +mt7620_spi_set_cs (ms, cs,0 );same as above.
PATCH v2 14/21 watchdog: add watchdog driver for MediaTek MT7620 SoC
In reply to Jagan TekiQuoted 134 lines · Jagan Teki
Quoted 133 lines · Weijie Gao
This patch adds watchdog support for the Mediatek MT7620 SoC
Signed-off-by Weijie Gao <[email protected]>---
v2 changes: addexpire_now--- drivers/watchdog/Kconfig | 7 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/mt7620_wdt.c | 132 ++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+) create mode 100644 drivers/watchdog/mt7620_wdt.cdrivers/watchdog/Kconfig +7
-0@@ -124,6 +124,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_MT7628drivers/watchdog/Makefile +1
-0@@ -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.odrivers/watchdog/mt7620_wdt.c new file +84
-0@@ -0,0 +1,132 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2020 MediaTek Inc. +* +* Author: Weijie Gao <[email protected]> +* +* Watchdog timer for MT7620 and earlier SoCs +*/ + +#include <div64.h> +#include <dm.h> +#include <reset.h> +#include <wdt.h> +#include <linux/bitops.h> +#include <linux/io.h> + +struct mt7620_wdt { +void __iomem *regs; +u64 timeout; +}; + +#define TIMER_FREQ 40000000 +#define TIMER_MASK 0xffff +#define TIMER_PRESCALE 65536 + +#define TIMER_LOAD 0x00 +#define TIMER_CTL 0x08 + +#define TIMER_ENABLE BIT(7) +#define TIMER_MODE_SHIFT 4 +#define TIMER_MODE_WDT 3 +#define TIMER_PRESCALE_SHIFT 0 +#define TIMER_PRESCALE_65536 15 + +static void mt7620_wdt_ping (struct mt7620_wdt *priv) +{ +u64 val; + + val = (TIMER_FREQ /TIMER_PRESCALE ) * priv->timeout; +do_div (val,1000 ); + +if (val >TIMER_MASK ) + val =TIMER_MASK ; + +writel (val, priv->regs +TIMER_LOAD ); +} + +static int mt7620_wdt_start (struct udevice *dev,u64 ms,ulong flags) +{ +struct mt7620_wdt *priv =dev_get_priv (dev); + + priv->timeout = ms; +mt7620_wdt_ping (priv); + +writel (TIMER_ENABLE | (TIMER_MODE_WDT <<TIMER_MODE_SHIFT ) | + (TIMER_PRESCALE_65536 <<TIMER_PRESCALE_SHIFT ), + priv->regs +TIMER_CTL ); + +return 0 ; +} + +static int mt7620_wdt_stop (struct udevice *dev) +{ +struct mt7620_wdt *priv =dev_get_priv (dev); + +mt7620_wdt_ping (priv); + +clrbits_32 (priv->regs +TIMER_CTL ,TIMER_ENABLE ); + +return 0 ; +} + +static int mt7620_wdt_reset (struct udevice *dev) +{ +struct mt7620_wdt *priv =dev_get_priv (dev); + +mt7620_wdt_ping (priv); + +return 0 ; +} + +static int mt7620_wdt_expire_now (struct udevice *dev,ulong flags) +{ +struct mt7620_wdt *priv =dev_get_priv (dev);
Quoted 8 lines
drivers/watchdog/mt7620_wdt.c line 89
Quoted 5 lines
drivers/watchdog/mt7620_wdt.c new file +5
-0+ +mt7620_wdt_start (dev,1 , flags); + +/* 0 will disable the timer, so use 1 instead */ +writel (1 , priv->regs +TIMER_LOAD );Better replace the magic number with macro.
Otherwise,
this line means load timer with value 1. Since the timer is a countdown, 1 is the smallest value to cause a wdt timeout.
Quoted 2 lines
Reviewed-by Jagan Teki <[email protected]>
PATCH v2 17/21 phy: add USB PHY driver for MediaTek MT7620 SoC
In reply to Jagan TekiQuoted 62 lines · Jagan Teki
Quoted 61 lines · Weijie Gao
This patch adds USB PHY driver for MediaTek MT7620 SoC
Signed-off-by Weijie Gao <[email protected]>---
v2 changes: none--- drivers/phy/Kconfig | 7 +++ drivers/phy/Makefile | 1 + drivers/phy/mt7620-usb-phy.c | 113 +++++++++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 drivers/phy/mt7620-usb-phy.cdrivers/phy/Kconfig +7
-0@@ -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 PHYdrivers/phy/Makefile +1
-0@@ -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.odrivers/phy/mt7620-usb-phy.c new file +12
-0@@ -0,0 +1,113 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2020 MediaTek Inc. All Rights Reserved. +* +* Author: Weijie Gao <[email protected]> +*/ + +#include <clk.h> +#include <dm.h> +#include <generic-phy.h> +#include <misc.h> +#include <reset.h>
Quoted 8 lines
drivers/phy/mt7620-usb-phy.c line 18
Quoted 6 lines
drivers/phy/mt7620-usb-phy.c new file +6
-0+#include <dm/device_compat.h> +#include <linux/delay.h> +#include <mach/mt7620-sysc.h> + +struct mt7620_usb_phy { +struct udevice *dev;Why this explicit dev required here?
generic_phy_get_calls will assignphy->dev
I didn't notice that. This will be modified in next series.