Add support for MediaTek MT8512 Soc
Subsystems (9)
cover Add support for MediaTek MT8512 Soc
This patch series adds basic boot support on eMMC for the MediaTek MT8512 SoC based boards. This series add the clock, pinctrl drivers and the SoC initializaton code.
mingming lee (7):
ARM: MediaTek: Add support for MediaTek MT8512 SoC
clk: mediatek: adjust common driver for mt8512
clk: mediatek: add driver support for MT8512
pinctrl: mediatek: add driver for MT8512
mmc: mtk-sd: add support for MediaTek MT8512/MT8110 SoCs
mmc: mtk-sd: fix hang when data read quickly
ARM: MediaTek: add basic support for MT8512 boards
arch/arm/dts/Makefile | 1 + arch/arm/dts/mt8512-bm1-emmc.dts | 106 +++ arch/arm/dts/mt8512.dtsi | 115 +++ arch/arm/mach-mediatek/Kconfig | 15 + arch/arm/mach-mediatek/Makefile | 1 + arch/arm/mach-mediatek/mt8512/Makefile | 4 + arch/arm/mach-mediatek/mt8512/init.c | 78 ++ arch/arm/mach-mediatek/mt8512/lowlevel_init.S | 32 + board/mediatek/mt8512/Kconfig | 14 + board/mediatek/mt8512/MAINTAINERS | 6 + board/mediatek/mt8512/Makefile | 3 + board/mediatek/mt8512/mt8512.c | 19 + configs/mt8512_bm1_emmc_defconfig | 44 + drivers/clk/mediatek/Makefile | 1 + drivers/clk/mediatek/clk-mt8512.c | 873 ++++++++++++++++++ drivers/clk/mediatek/clk-mtk.c | 72 +- drivers/clk/mediatek/clk-mtk.h | 26 + drivers/mmc/mtk-sd.c | 140 ++- drivers/pinctrl/mediatek/Kconfig | 4 + drivers/pinctrl/mediatek/Makefile | 1 + drivers/pinctrl/mediatek/pinctrl-mt8512.c | 387 ++++++++ include/configs/mt8512.h | 60 ++ include/dt-bindings/clock/mt8512-clk.h | 197 ++++ 23 files changed, 2140 insertions(+), 59 deletions(-) create mode 100644 arch/arm/dts/mt8512-bm1-emmc.dts create mode 100644 arch/arm/dts/mt8512.dtsi create mode 100644 arch/arm/mach-mediatek/mt8512/Makefile create mode 100644 arch/arm/mach-mediatek/mt8512/init.c create mode 100644 arch/arm/mach-mediatek/mt8512/lowlevel_init.S create mode 100644 board/mediatek/mt8512/Kconfig create mode 100644 board/mediatek/mt8512/MAINTAINERS create mode 100644 board/mediatek/mt8512/Makefile create mode 100644 board/mediatek/mt8512/mt8512.c create mode 100644 configs/mt8512_bm1_emmc_defconfig create mode 100644 drivers/clk/mediatek/clk-mt8512.c create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8512.c create mode 100644 include/configs/mt8512.h create mode 100644 include/dt-bindings/clock/mt8512-clk.h
Signature · 1 line
2.18.0
PATCH 1/7 ARM: MediaTek: Add support for MediaTek MT8512 SoC
Add support for MediaTek MT8512 SoC. This include the file that will initialize the SoC after boot and its device tree.
--- arch/arm/dts/mt8512.dtsi | 115 ++++++++++++++++++ arch/arm/mach-mediatek/Kconfig | 15 +++ arch/arm/mach-mediatek/Makefile | 1 + arch/arm/mach-mediatek/mt8512/Makefile | 4 + arch/arm/mach-mediatek/mt8512/init.c | 78 ++++++++++++ arch/arm/mach-mediatek/mt8512/lowlevel_init.S | 32 +++++ 6 files changed, 245 insertions(+) create mode 100644 arch/arm/dts/mt8512.dtsi create mode 100644 arch/arm/mach-mediatek/mt8512/Makefile create mode 100644 arch/arm/mach-mediatek/mt8512/init.c create mode 100644 arch/arm/mach-mediatek/mt8512/lowlevel_init.S
arch/arm/dts/mt8512.dtsi new file +115 -0
@@ -0,0 +1,115 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/* + * Copyright (C) 2019 MediaTek Inc. + * Author: Mingming Lee <[email protected]> + * + */ + +#include <dt-bindings/clock/mt8512-clk.h> +#include <dt-bindings/gpio/gpio.h> +#include <dt-bindings/interrupt-controller/irq.h> +#include <dt-bindings/interrupt-controller/arm-gic.h> + +/ { + compatible = "mediatek,mt8512"; + interrupt-parent = <&sysirq>; + #address-cells = <1>; + #size-cells = <1>; + + topckgen: clock-controller at 10000000 { + compatible = "mediatek,mt8512-topckgen"; + reg = <0x10000000 0x1000>; + #clock-cells = <1>; + }; + + topckgen_cg: clock-controller-cg at 10000000 { + compatible = "mediatek,mt8512-topckgen-cg"; + reg = <0x10000000 0x1000>; + #clock-cells = <1>; + }; + + infracfg: clock-controller at 10001000 { + compatible = "mediatek,mt8512-infracfg"; + reg = <0x10001000 0x1000>; + #clock-cells = <1>; + }; + + gic: interrupt-controller at 0c000000 { + compatible = "arm,gic-v3"; + #interrupt-cells = <3>; + interrupt-parent = <&gic>; + interrupt-controller; + reg = <0xc000000 0x40000>, /* GICD */ + <0xc080000 0x200000>; /* GICR */ + interrupts = <GIC_PPI 9 + (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>; + }; + + sysirq: interrupt-controller at 10200a80 { + compatible = "mediatek,sysirq"; + interrupt-controller; + #interrupt-cells = <3>; + interrupt-parent = <&gic>; + reg = <0x10200a80 0x50>; + }; + + timer0: apxgpt at 10008000 { + compatible = "mediatek,timer"; + reg = <0x10008000 0x1000>; + interrupts = <GIC_SPI 138 IRQ_TYPE_LEVEL_LOW>; + clocks = <&topckgen CLK_TOP_SYS_26M_D2>, + <&topckgen CLK_TOP_CLK32K>, + <&infracfg CLK_INFRA_APXGPT>; + clock-names = "clk13m", + "clk32k", + "bus"; + }; + + watchdog0: watchdog at 10007000 { + compatible = "mediatek,wdt"; + reg = <0x10007000 0x1000>; + interrupts = <GIC_SPI 190 IRQ_TYPE_EDGE_FALLING>; + #reset-cells = <1>; + status = "disabled"; + timeout-sec = <60>; + reset-on-timeout; + }; + + pinctrl: pinctrl at 10005000 { + compatible = "mediatek,mt8512-pinctrl"; + reg = <0x10005000 0x1000>; + gpio: gpio-controller { + gpio-controller; + #gpio-cells = <2>; + }; + }; + + apmixedsys: clock-controller at 1000c000 { + compatible = "mediatek,mt8512-apmixedsys"; + reg = <0x1000c000 0x1000>; + #clock-cells = <1>; + }; + + mmc0: mmc at 11230000 { + compatible = "mediatek,mt8512-mmc"; + reg = <0x11230000 0x1000>, + <0x11cd0000 0x1000>; + interrupts = <GIC_SPI 78 IRQ_TYPE_LEVEL_LOW>; + clocks = <&topckgen CLK_TOP_MSDC50_0_SEL>, + <&infracfg CLK_INFRA_MSDC0>, + <&infracfg CLK_INFRA_MSDC0_SRC>; + clock-names = "source", "hclk", "source_cg"; + status = "disabled"; + }; + + uart0: serial at 11002000 { + compatible = "mediatek,hsuart"; + reg = <0x11002000 0x1000>; + interrupts = <GIC_SPI 24 IRQ_TYPE_LEVEL_LOW>; + clocks = <&topckgen CLK_TOP_CLK26M>, + <&infracfg CLK_INFRA_UART0>; + clock-names = "baud", "bus"; + status = "disabled"; + }; + +};
arch/arm/mach-mediatek/Kconfig +15 -0
@@ -6,6 +6,10 @@ config SYS_SOC config SYS_VENDOR default "mediatek" +config MT8512 + bool "MediaTek MT8512 SoC" + default n + choice prompt "MediaTek board select"
@@ -29,6 +33,16 @@ config TARGET_MT7629 including DDR3, crypto engine, 3x3 11n/ac Wi-Fi, Gigabit Ethernet, switch, USB3.0, PCIe, UART, SPI, I2C and PWM. +config TARGET_MT8512 + bool "MediaTek MT8512 M1 Board" + select ARM64 + select MT8512 + help + The MediaTek MT8512 is a ARM64-based SoC with a quad-core Cortex-A53. + including UART, SPI, USB2.0 and OTG, SD and MMC cards, NAND, PWM, + Ethernet, IR TX/RX, I2C, I2S, S/PDIF, and built-in Wi-Fi / Bluetooth combo + chip and several DDR3 and DDR4 options. + config TARGET_MT8516 bool "MediaTek MT8516 SoC" select ARM64
@@ -51,6 +65,7 @@ endchoice source "board/mediatek/mt7623/Kconfig" source "board/mediatek/mt7629/Kconfig" +source "board/mediatek/mt8512/Kconfig" source "board/mediatek/mt8518/Kconfig" source "board/mediatek/pumpkin/Kconfig"
arch/arm/mach-mediatek/Makefile +1 -0
@@ -3,6 +3,7 @@ obj-y += cpu.o obj-$(CONFIG_SPL_BUILD) += spl.o +obj-$(CONFIG_MT8512) += mt8512/ obj-$(CONFIG_TARGET_MT7623) += mt7623/ obj-$(CONFIG_TARGET_MT7629) += mt7629/ obj-$(CONFIG_TARGET_MT8516) += mt8516/
arch/arm/mach-mediatek/mt8512/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-y += init.o +obj-y += lowlevel_init.o
arch/arm/mach-mediatek/mt8512/init.c new file +78 -0
78 lines not on this page · raw message
arch/arm/mach-mediatek/mt8512/lowlevel_init.S new file +32 -0
@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2019 MediaTek Inc. + * Author: Mingming Lee <[email protected]> + */ + +/* + * Switch from AArch64 EL2 to AArch32 EL2 + * @param inputs: + * x0: argument, zero + * x1: machine nr + * x2: fdt address + * x3: input argument + * x4: kernel entry point + * @param outputs for secure firmware: + * x0: function id + * x1: kernel entry point + * x2: machine nr + * x3: fdt address +*/ +.global armv8_el2_to_aarch32 +armv8_el2_to_aarch32: + mov x3, x2 + mov x2, x1 + mov x1, x4 + mov x4, #0 + /* Define in src\bsp\trustzone\atf\v1.2\ */ + /* mt8xxx\plat\mediatek\common\sip_svc.h */ + /* MTK_SIP_KERNEL_BOOT_AARCH64 for U-BOOT-64 to KERNEL*/ + ldr x0, =0xC2000200 + SMC #0 + ret
Signature · 1 line
2.18.0
PATCH 1/7 ARM: MediaTek: Add support for MediaTek MT8512 SoC
Quoted 30 lines · mingming lee
Add support for MediaTek MT8512 SoC. This include the file that will initialize the SoC after boot and its device tree.
Signed-off-by mingming lee <[email protected]>--- arch/arm/dts/mt8512.dtsi | 115 ++++++++++++++++++ arch/arm/mach-mediatek/Kconfig | 15 +++ arch/arm/mach-mediatek/Makefile | 1 + arch/arm/mach-mediatek/mt8512/Makefile | 4 + arch/arm/mach-mediatek/mt8512/init.c | 78 ++++++++++++ arch/arm/mach-mediatek/mt8512/lowlevel_init.S | 32 +++++ 6 files changed, 245 insertions(+) create mode 100644 arch/arm/dts/mt8512.dtsi create mode 100644 arch/arm/mach-mediatek/mt8512/Makefile create mode 100644 arch/arm/mach-mediatek/mt8512/init.c create mode 100644 arch/arm/mach-mediatek/mt8512/lowlevel_init.Sarch/arm/dts/mt8512.dtsi new file +7
-0@@ -0,0 +1,115 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/* + * Copyright (C) 2019 MediaTek Inc. + * Author: Mingming Lee <[email protected]> + * + */ +
arch/arm/dts/mt8512.dtsi line 17
Quoted 10 lines
arch/arm/dts/mt8512.dtsi new file +10
-0+#include <dt-bindings/clock/mt8512-clk.h> +#include <dt-bindings/gpio/gpio.h> +#include <dt-bindings/interrupt-controller/irq.h> +#include <dt-bindings/interrupt-controller/arm-gic.h> + +/ { + compatible = "mediatek,mt8512"; + interrupt-parent = <&sysirq>; + #address-cells = <1>; + #size-cells = <1>;
Sort device nodes alphabetically.
Quoted 281 lines
arch/arm/dts/mt8512.dtsi new file +97
-0+ topckgen: clock-controller at 10000000 { + compatible = "mediatek,mt8512-topckgen"; + reg = <0x10000000 0x1000>; + #clock-cells = <1>; + }; + + topckgen_cg: clock-controller-cg at 10000000 { + compatible = "mediatek,mt8512-topckgen-cg"; + reg = <0x10000000 0x1000>; + #clock-cells = <1>; + }; + + infracfg: clock-controller at 10001000 { + compatible = "mediatek,mt8512-infracfg"; + reg = <0x10001000 0x1000>; + #clock-cells = <1>; + }; + + gic: interrupt-controller at 0c000000 { + compatible = "arm,gic-v3"; + #interrupt-cells = <3>; + interrupt-parent = <&gic>; + interrupt-controller; + reg = <0xc000000 0x40000>, /* GICD */ + <0xc080000 0x200000>; /* GICR */ + interrupts = <GIC_PPI 9 + (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>; + }; + + sysirq: interrupt-controller at 10200a80 { + compatible = "mediatek,sysirq"; + interrupt-controller; + #interrupt-cells = <3>; + interrupt-parent = <&gic>; + reg = <0x10200a80 0x50>; + }; + + timer0: apxgpt at 10008000 { + compatible = "mediatek,timer"; + reg = <0x10008000 0x1000>; + interrupts = <GIC_SPI 138 IRQ_TYPE_LEVEL_LOW>; + clocks = <&topckgen CLK_TOP_SYS_26M_D2>, + <&topckgen CLK_TOP_CLK32K>, + <&infracfg CLK_INFRA_APXGPT>; + clock-names = "clk13m", + "clk32k", + "bus"; + }; + + watchdog0: watchdog at 10007000 { + compatible = "mediatek,wdt"; + reg = <0x10007000 0x1000>; + interrupts = <GIC_SPI 190 IRQ_TYPE_EDGE_FALLING>; + #reset-cells = <1>; + status = "disabled"; + timeout-sec = <60>; + reset-on-timeout; + }; + + pinctrl: pinctrl at 10005000 { + compatible = "mediatek,mt8512-pinctrl"; + reg = <0x10005000 0x1000>; + gpio: gpio-controller { + gpio-controller; + #gpio-cells = <2>; + }; + }; + + apmixedsys: clock-controller at 1000c000 { + compatible = "mediatek,mt8512-apmixedsys"; + reg = <0x1000c000 0x1000>; + #clock-cells = <1>; + }; + + mmc0: mmc at 11230000 { + compatible = "mediatek,mt8512-mmc"; + reg = <0x11230000 0x1000>, + <0x11cd0000 0x1000>; + interrupts = <GIC_SPI 78 IRQ_TYPE_LEVEL_LOW>; + clocks = <&topckgen CLK_TOP_MSDC50_0_SEL>, + <&infracfg CLK_INFRA_MSDC0>, + <&infracfg CLK_INFRA_MSDC0_SRC>; + clock-names = "source", "hclk", "source_cg"; + status = "disabled"; + }; + + uart0: serial at 11002000 { + compatible = "mediatek,hsuart"; + reg = <0x11002000 0x1000>; + interrupts = <GIC_SPI 24 IRQ_TYPE_LEVEL_LOW>; + clocks = <&topckgen CLK_TOP_CLK26M>, + <&infracfg CLK_INFRA_UART0>; + clock-names = "baud", "bus"; + status = "disabled"; + }; + +};arch/arm/mach-mediatek/Kconfig +15
-0@@ -6,6 +6,10 @@ config SYS_SOC config SYS_VENDOR default "mediatek" +config MT8512 + bool "MediaTek MT8512 SoC" + default n + choice prompt "MediaTek board select"@@ -29,6 +33,16 @@ config TARGET_MT7629 including DDR3, crypto engine, 3x3 11n/ac Wi-Fi, Gigabit Ethernet, switch, USB3.0, PCIe, UART, SPI, I2C and PWM. +config TARGET_MT8512 + bool "MediaTek MT8512 M1 Board" + select ARM64 + select MT8512 + help + The MediaTek MT8512 is a ARM64-based SoC with a quad-core Cortex-A53. + including UART, SPI, USB2.0 and OTG, SD and MMC cards, NAND, PWM, + Ethernet, IR TX/RX, I2C, I2S, S/PDIF, and built-in Wi-Fi / Bluetooth combo + chip and several DDR3 and DDR4 options. + config TARGET_MT8516 bool "MediaTek MT8516 SoC" select ARM64@@ -51,6 +65,7 @@ endchoice source "board/mediatek/mt7623/Kconfig" source "board/mediatek/mt7629/Kconfig" +source "board/mediatek/mt8512/Kconfig" source "board/mediatek/mt8518/Kconfig" source "board/mediatek/pumpkin/Kconfig"arch/arm/mach-mediatek/Makefile +1
-0@@ -3,6 +3,7 @@ obj-y += cpu.o obj-$(CONFIG_SPL_BUILD) += spl.o +obj-$(CONFIG_MT8512) += mt8512/ obj-$(CONFIG_TARGET_MT7623) += mt7623/ obj-$(CONFIG_TARGET_MT7629) += mt7629/ obj-$(CONFIG_TARGET_MT8516) += mt8516/arch/arm/mach-mediatek/mt8512/Makefile new file +4
-0@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-y += init.o +obj-y += lowlevel_init.oarch/arm/mach-mediatek/mt8512/init.c new file +78
-0@@ -0,0 +1,78 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Configuration for MediaTek MT8512 SoC +* +* Copyright (C) 2019 MediaTek Inc. +* Author: Mingming Lee <[email protected]> +*/ + +#include <clk.h> +#include <common.h> +#include <dm.h> +#include <fdtdec.h> +#include <ram.h> +#include <wdt.h> +#include <asm/arch/misc.h> +#include <asm/armv8/mmu.h> +#include <asm/sections.h> +#include <dm/uclass.h> +#include <dt-bindings/clock/mt8512-clk.h> + +DECLARE_GLOBAL_DATA_PTR ; + +int dram_init (void ) +{ +return fdtdec_setup_mem_size_base (); +} + +phys_size_t get_effective_memsize (void ) +{ +/* limit stack below tee reserve memory */ +return gd->ram_size -6 *SZ_1M ; +} + +int dram_init_banksize (void ) +{ + gd->bd->bi_dram[0 ].start = gd->ram_base; + gd->bd->bi_dram[0 ].size =get_effective_memsize (); + +return 0 ; +} + +void reset_cpu (ulong addr) +{ +struct udevice *watchdog_dev =NULL ; + +if (uclass_get_device_by_seq (UCLASS_WDT ,0 , &watchdog_dev)) +if (uclass_get_device (UCLASS_WDT ,0 , &watchdog_dev)) +psci_system_reset (); + +wdt_expire_now (watchdog_dev,0 ); +} + +int print_cpuinfo (void ) +{ +debug ("CPU: MediaTek MT8512\n" ); +return 0 ; +} + +static struct mm_region mt8512_mem_map[] = { + { +/* DDR */ + .virt =0x40000000UL , + .phys =0x40000000UL , + .size =0x40000000UL , + .attrs =PTE_BLOCK_MEMTYPE (MT_NORMAL ) |PTE_BLOCK_OUTER_SHARE , + }, { + .virt =0x00000000UL , + .phys =0x00000000UL , + .size =0x40000000UL , + .attrs =PTE_BLOCK_MEMTYPE (MT_DEVICE_NGNRNE ) | +PTE_BLOCK_NON_SHARE | +PTE_BLOCK_PXN |PTE_BLOCK_UXN + }, { +0 , + } +}; + +struct mm_region *mem_map = mt8512_mem_map;arch/arm/mach-mediatek/mt8512/lowlevel_init.S new file +32
-0@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2019 MediaTek Inc. + * Author: Mingming Lee <[email protected]> + */ + +/* + * Switch from AArch64 EL2 to AArch32 EL2 + * @param inputs: + * x0: argument, zero + * x1: machine nr + * x2: fdt address + * x3: input argument + * x4: kernel entry point + * @param outputs for secure firmware: + * x0: function id + * x1: kernel entry point + * x2: machine nr + * x3: fdt address +*/ +.global armv8_el2_to_aarch32 +armv8_el2_to_aarch32: + mov x3, x2 + mov x2, x1 + mov x1, x4 + mov x4, #0 + /* Define in src\bsp\trustzone\atf\v1.2\ */ + /* mt8xxx\plat\mediatek\common\sip_svc.h */ + /* MTK_SIP_KERNEL_BOOT_AARCH64 for U-BOOT-64 to KERNEL*/ + ldr x0, =0xC2000200 + SMC #0 + ret
PATCH 1/7 ARM: MediaTek: Add support for MediaTek MT8512 SoC
пн, 23 груд. 2019 о 22:12 Ryder Lee <[email protected]> пише:
Quoted 35 lines · mingming lee
Quoted 34 lines
Add support for MediaTek MT8512 SoC. This include the file that will initialize the SoC after boot and its device tree.
Signed-off-by mingming lee <[email protected]>--- arch/arm/dts/mt8512.dtsi | 115 ++++++++++++++++++ arch/arm/mach-mediatek/Kconfig | 15 +++ arch/arm/mach-mediatek/Makefile | 1 + arch/arm/mach-mediatek/mt8512/Makefile | 4 + arch/arm/mach-mediatek/mt8512/init.c | 78 ++++++++++++ arch/arm/mach-mediatek/mt8512/lowlevel_init.S | 32 +++++ 6 files changed, 245 insertions(+) create mode 100644 arch/arm/dts/mt8512.dtsi create mode 100644 arch/arm/mach-mediatek/mt8512/Makefile create mode 100644 arch/arm/mach-mediatek/mt8512/init.c create mode 100644 arch/arm/mach-mediatek/mt8512/lowlevel_init.Sarch/arm/dts/mt8512.dtsi new file +11
-0@@ -0,0 +1,115 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/* + * Copyright (C) 2019 MediaTek Inc. + * Author: Mingming Lee <[email protected]> + * + */ + +#include <dt-bindings/clock/mt8512-clk.h> +#include <dt-bindings/gpio/gpio.h> +#include <dt-bindings/interrupt-controller/irq.h> +#include <dt-bindings/interrupt-controller/arm-gic.h>
Quoted 9 lines
arch/arm/dts/mt8512.dtsi line 17
Quoted 6 lines
arch/arm/dts/mt8512.dtsi new file +6
-0+ +/ { + compatible = "mediatek,mt8512"; + interrupt-parent = <&sysirq>; + #address-cells = <1>; + #size-cells = <1>;Sort device nodes alphabetically.
Why alphabetically?
Quoted 294 lines
Review
Quoted 99 lines
arch/arm/dts/mt8512.dtsi new file +97
-0+ topckgen: clock-controller at 10000000 { + compatible = "mediatek,mt8512-topckgen"; + reg = <0x10000000 0x1000>; + #clock-cells = <1>; + }; + + topckgen_cg: clock-controller-cg at 10000000 { + compatible = "mediatek,mt8512-topckgen-cg"; + reg = <0x10000000 0x1000>; + #clock-cells = <1>; + }; + + infracfg: clock-controller at 10001000 { + compatible = "mediatek,mt8512-infracfg"; + reg = <0x10001000 0x1000>; + #clock-cells = <1>; + }; + + gic: interrupt-controller at 0c000000 { + compatible = "arm,gic-v3"; + #interrupt-cells = <3>; + interrupt-parent = <&gic>; + interrupt-controller; + reg = <0xc000000 0x40000>, /* GICD */ + <0xc080000 0x200000>; /* GICR */ + interrupts = <GIC_PPI 9 + (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>; + }; + + sysirq: interrupt-controller at 10200a80 { + compatible = "mediatek,sysirq"; + interrupt-controller; + #interrupt-cells = <3>; + interrupt-parent = <&gic>; + reg = <0x10200a80 0x50>; + }; + + timer0: apxgpt at 10008000 { + compatible = "mediatek,timer"; + reg = <0x10008000 0x1000>; + interrupts = <GIC_SPI 138 IRQ_TYPE_LEVEL_LOW>; + clocks = <&topckgen CLK_TOP_SYS_26M_D2>, + <&topckgen CLK_TOP_CLK32K>, + <&infracfg CLK_INFRA_APXGPT>; + clock-names = "clk13m", + "clk32k", + "bus"; + }; + + watchdog0: watchdog at 10007000 { + compatible = "mediatek,wdt"; + reg = <0x10007000 0x1000>; + interrupts = <GIC_SPI 190 IRQ_TYPE_EDGE_FALLING>; + #reset-cells = <1>; + status = "disabled"; + timeout-sec = <60>; + reset-on-timeout; + }; + + pinctrl: pinctrl at 10005000 { + compatible = "mediatek,mt8512-pinctrl"; + reg = <0x10005000 0x1000>; + gpio: gpio-controller { + gpio-controller; + #gpio-cells = <2>; + }; + }; + + apmixedsys: clock-controller at 1000c000 { + compatible = "mediatek,mt8512-apmixedsys"; + reg = <0x1000c000 0x1000>; + #clock-cells = <1>; + }; + + mmc0: mmc at 11230000 { + compatible = "mediatek,mt8512-mmc"; + reg = <0x11230000 0x1000>, + <0x11cd0000 0x1000>; + interrupts = <GIC_SPI 78 IRQ_TYPE_LEVEL_LOW>; + clocks = <&topckgen CLK_TOP_MSDC50_0_SEL>, + <&infracfg CLK_INFRA_MSDC0>, + <&infracfg CLK_INFRA_MSDC0_SRC>; + clock-names = "source", "hclk", "source_cg"; + status = "disabled"; + }; + + uart0: serial at 11002000 { + compatible = "mediatek,hsuart"; + reg = <0x11002000 0x1000>; + interrupts = <GIC_SPI 24 IRQ_TYPE_LEVEL_LOW>; + clocks = <&topckgen CLK_TOP_CLK26M>, + <&infracfg CLK_INFRA_UART0>; + clock-names = "baud", "bus"; + status = "disabled"; + }; + +};(quoted diff) +0
-0b/arch/arm/mach-mediatek/Kconfig
Quoted 15 lines
index
ad453a60c1..bca88b8db8100644arch/arm/mach-mediatek/Kconfig +4
-0@@ -6,6 +6,10 @@ config SYS_SOC config SYS_VENDOR default "mediatek" +config MT8512 + bool "MediaTek MT8512 SoC" + default n + choice prompt "MediaTek board select"arch/arm/mach-mediatek/Kconfig config TARGET_MT7629 · line 33
Quoted 1 line
arch/arm/mach-mediatek/Kconfig +0
-0@@ -29,6 +33,16 @@ config TARGET_MT7629 including DDR3, crypto engine, 3x3 11n/ac Wi-Fi, GigabitEthernet,
arch/arm/mach-mediatek/Kconfig config TARGET_MT7629
Quoted 8 lines
arch/arm/mach-mediatek/Kconfig +6
-0switch, USB3.0, PCIe, UART, SPI, I2C and PWM. +config TARGET_MT8512 + bool "MediaTek MT8512 M1 Board" + select ARM64 + select MT8512 + help + The MediaTek MT8512 is a ARM64-based SoC with a quad-coreCortex-A53.
arch/arm/mach-mediatek/Kconfig config TARGET_MT7629 · line 42
Quoted 1 line
arch/arm/mach-mediatek/Kconfig +1
-0+ including UART, SPI, USB2.0 and OTG, SD and MMC cards, NAND,PWM,
arch/arm/mach-mediatek/Kconfig config TARGET_MT7629 · line 43
Quoted 1 line
arch/arm/mach-mediatek/Kconfig +1
-0+ Ethernet, IR TX/RX, I2C, I2S, S/PDIF, and built-in Wi-Fi /Bluetooth combo
Review
Quoted 14 lines
arch/arm/mach-mediatek/Kconfig +3
-0+ chip and several DDR3 and DDR4 options. + config TARGET_MT8516 bool "MediaTek MT8516 SoC" select ARM64@@ -51,6 +65,7 @@ endchoice source "board/mediatek/mt7623/Kconfig" source "board/mediatek/mt7629/Kconfig" +source "board/mediatek/mt8512/Kconfig" source "board/mediatek/mt8518/Kconfig" source "board/mediatek/pumpkin/Kconfig"(quoted diff) +0
-0b/arch/arm/mach-mediatek/Makefile
Review
Quoted 12 lines
index
b9b2355e03..6129ac88ab100644arch/arm/mach-mediatek/Makefile +1
-0@@ -3,6 +3,7 @@ obj-y += cpu.o obj-$(CONFIG_SPL_BUILD) += spl.o +obj-$(CONFIG_MT8512) += mt8512/ obj-$(CONFIG_TARGET_MT7623) += mt7623/ obj-$(CONFIG_TARGET_MT7629) += mt7629/ obj-$(CONFIG_TARGET_MT8516) += mt8516/(quoted diff) +0
-0b/arch/arm/mach-mediatek/mt8512/Makefile
Review
Quoted 10 lines
new file mode 100644
index 0000000000..007eb4a367arch/arm/mach-mediatek/mt8512/Makefile new file +4
-0@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-y += init.o +obj-y += lowlevel_init.o(quoted diff) +0
-0
b/arch/arm/mach-mediatek/mt8512/init.cQuoted 60 lines
new file mode 100644
index 0000000000..a38b5d12d9arch/arm/mach-mediatek/mt8512/init.c new file +55
-0@@ -0,0 +1,78 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Configuration for MediaTek MT8512 SoC +* +* Copyright (C) 2019 MediaTek Inc. +* Author: Mingming Lee <[email protected]> +*/ + +#include <clk.h> +#include <common.h> +#include <dm.h> +#include <fdtdec.h> +#include <ram.h> +#include <wdt.h> +#include <asm/arch/misc.h> +#include <asm/armv8/mmu.h> +#include <asm/sections.h> +#include <dm/uclass.h> +#include <dt-bindings/clock/mt8512-clk.h> + +DECLARE_GLOBAL_DATA_PTR ; + +int dram_init (void ) +{ +return fdtdec_setup_mem_size_base (); +} + +phys_size_t get_effective_memsize (void ) +{ +/* limit stack below tee reserve memory */ +return gd->ram_size -6 *SZ_1M ; +} + +int dram_init_banksize (void ) +{ + gd->bd->bi_dram[0 ].start = gd->ram_base; + gd->bd->bi_dram[0 ].size =get_effective_memsize (); + +return 0 ; +} + +void reset_cpu (ulong addr) +{ +struct udevice *watchdog_dev =NULL ; + +if (uclass_get_device_by_seq (UCLASS_WDT ,0 , &watchdog_dev)) +if (uclass_get_device (UCLASS_WDT ,0 , &watchdog_dev)) +psci_system_reset (); + +wdt_expire_now (watchdog_dev,0 ); +} + +int print_cpuinfo (void ) +{ +debug ("CPU: MediaTek MT8512\n" );arch/arm/mach-mediatek/mt8512/init.c line 65
Quoted 10 lines
arch/arm/mach-mediatek/mt8512/init.c new file +10
-0+return 0 ; +} + +static struct mm_region mt8512_mem_map[] = { + { +/* DDR */ + .virt =0x40000000UL , + .phys =0x40000000UL , + .size =0x40000000UL , + .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
PTE_BLOCK_OUTER_SHARE,Review
Quoted 14 lines
arch/arm/mach-mediatek/mt8512/init.c new file +13
-0+ }, { + .virt = 0x00000000UL, + .phys = 0x00000000UL, + .size = 0x40000000UL, + .attrs =PTE_BLOCK_MEMTYPE (MT_DEVICE_NGNRNE ) | +PTE_BLOCK_NON_SHARE | +PTE_BLOCK_PXN |PTE_BLOCK_UXN + }, { + 0, + } +}; + +struct mm_region *mem_map = mt8512_mem_map;(quoted diff) +0
-0
b/arch/arm/mach-mediatek/mt8512/lowlevel_init.SQuoted 37 lines
new file mode 100644
index 0000000000..ad392120f4arch/arm/mach-mediatek/mt8512/lowlevel_init.S new file +32
-0@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2019 MediaTek Inc. + * Author: Mingming Lee <[email protected]> + */ + +/* + * Switch from AArch64 EL2 to AArch32 EL2 + * @param inputs: + * x0: argument, zero + * x1: machine nr + * x2: fdt address + * x3: input argument + * x4: kernel entry point + * @param outputs for secure firmware: + * x0: function id + * x1: kernel entry point + * x2: machine nr + * x3: fdt address +*/ +.global armv8_el2_to_aarch32 +armv8_el2_to_aarch32: + mov x3, x2 + mov x2, x1 + mov x1, x4 + mov x4, #0 + /* Define in src\bsp\trustzone\atf\v1.2\ */ + /* mt8xxx\plat\mediatek\common\sip_svc.h */ + /* MTK_SIP_KERNEL_BOOT_AARCH64 for U-BOOT-64 to KERNEL*/ + ldr x0, =0xC2000200 + SMC #0 + ret
Signature · 3 lines
WBW ------- Rybalko Oleksandr <[email protected]>
PATCH 2/7 clk: mediatek: adjust common driver for mt8512
In reply to mingming leeUpdate mtk common clock driver to support mt8512
1. add new set_clr_upd mux type and related operation
2. add configurable pcw_chg_reg/ibits/fmin to mtk_pll
3. fix mtk_clk_find_parent_rate data overflow
--- drivers/clk/mediatek/clk-mtk.c | 72 ++++++++++++++++++++++++---------- drivers/clk/mediatek/clk-mtk.h | 26 ++++++++++++ 2 files changed, 77 insertions(+), 21 deletions(-)
drivers/clk/mediatek/clk-mtk.c +51 -21
@@ -39,8 +39,8 @@* this function is recursively called to find the parent to calculate * the accurate frequency. */ -static int mtk_clk_find_parent_rate (struct clk *clk,int id, -const struct driver *drv) +static ulong mtk_clk_find_parent_rate (struct clk *clk,int id, +const struct driver *drv) {struct clk parent = { .id = id, };
@@ -67,12 +67,23 @@ static int mtk_clk_mux_set_parent(void __iomem *base, u32 parent,if (++index == mux->num_parents)return -EINVAL ; -/* switch mux to a select parent */ - val =readl (base + mux->mux_reg); - val &= ~(mux->mux_mask << mux->mux_shift); +if (mux->flags &CLK_MUX_SETCLR_UPD ) { + val = (mux->mux_mask << mux->mux_shift); +writel (val, base + mux->mux_clr_reg); - val |= index << mux->mux_shift; -writel (val, base + mux->mux_reg); + val = (index << mux->mux_shift); +writel (val, base + mux->mux_set_reg); + +if (mux->upd_shift >=0 ) +writel (BIT (mux->upd_shift), base + mux->upd_reg); + }else { +/* switch mux to a select parent */ + val =readl (base + mux->mux_reg); + val &= ~(mux->mux_mask << mux->mux_shift); + + val |= index << mux->mux_shift; +writel (val, base + mux->mux_reg); + }return 0 ; }
@@ -84,11 +95,13 @@ static unsigned long __mtk_pll_recalc_rate(const struct mtk_pll_data *pll, {int pcwbits = pll->pcwbits;int pcwfbits; +int ibits;u64 vco;u8 c =0 ;/* The fractional part of the PLL divider. */ - pcwfbits = pcwbits >INTEGER_BITS ? pcwbits -INTEGER_BITS :0 ; + ibits = pll->pcwibits ? pll->pcwibits :INTEGER_BITS ; + pcwfbits = pcwbits > ibits ? pcwbits - ibits :0 ; vco = (u64 )fin * pcw;
@@ -113,7 +126,7 @@ static void mtk_pll_set_rate_regs(struct clk *clk, u32 pcw, int postdiv) {struct mtk_clk_priv *priv =dev_get_priv (clk->dev);const struct mtk_pll_data *pll = &priv->tree->plls[clk->id]; -u32 val; +u32 val, chg;/* set postdiv */ val =readl (priv->base + pll->pd_reg);
@@ -129,11 +142,16 @@ static void mtk_pll_set_rate_regs(struct clk *clk, u32 pcw, int postdiv)/* set pcw */ val &= ~GENMASK (pll->pcw_shift + pll->pcwbits -1 , pll->pcw_shift); val |= pcw << pll->pcw_shift; - val &= ~CON1_PCW_CHG ; -writel (val, priv->base + pll->pcw_reg); - val |=CON1_PCW_CHG ; -writel (val, priv->base + pll->pcw_reg); +if (pll->pcw_chg_reg) { + chg =readl (priv->base + pll->pcw_chg_reg); + chg |=CON1_PCW_CHG ; +writel (val, priv->base + pll->pcw_reg); +writel (chg, priv->base + pll->pcw_chg_reg); + }else { + val |=CON1_PCW_CHG ; +writel (val, priv->base + pll->pcw_reg); + }udelay (20 ); }
@@ -150,8 +168,9 @@ static void mtk_pll_calc_values(struct clk *clk, u32 *pcw, u32 *postdiv, {struct mtk_clk_priv *priv =dev_get_priv (clk->dev);const struct mtk_pll_data *pll = &priv->tree->plls[clk->id]; -unsigned long fmin =1000 *MHZ ; +unsigned long fmin = pll->fmin ? pll->fmin :1000 *MHZ ;u64 _pcw; +int ibits;u32 val;if (freq > pll->fmax)
@@ -164,7 +183,8 @@ static void mtk_pll_calc_values(struct clk *clk, u32 *pcw, u32 *postdiv, }/* _pcw = freq * postdiv / xtal_rate * 2^pcwfbits */ - _pcw = ((u64 )freq << val) << (pll->pcwbits -INTEGER_BITS ); + ibits = pll->pcwibits ? pll->pcwibits :INTEGER_BITS ; + _pcw = ((u64 )freq << val) << (pll->pcwbits - ibits);do_div (_pcw, priv->tree->xtal2_rate); *pcw = (u32 )_pcw;
@@ -332,9 +352,14 @@ static int mtk_topckgen_enable(struct clk *clk)return 0 ;/* enable clock gate */ - val =readl (priv->base + mux->gate_reg); - val &= ~BIT (mux->gate_shift); -writel (val, priv->base + mux->gate_reg); +if (mux->flags &CLK_MUX_SETCLR_UPD ) { + val =BIT (mux->gate_shift); +writel (val, priv->base + mux->mux_clr_reg); + }else { + val =readl (priv->base + mux->gate_reg); + val &= ~BIT (mux->gate_shift); +writel (val, priv->base + mux->gate_reg); + }if (mux->flags &CLK_DOMAIN_SCPSYS ) {/* enable scpsys clock off control */
@@ -360,9 +385,14 @@ static int mtk_topckgen_disable(struct clk *clk)return 0 ;/* disable clock gate */ - val =readl (priv->base + mux->gate_reg); - val |=BIT (mux->gate_shift); -writel (val, priv->base + mux->gate_reg); +if (mux->flags &CLK_MUX_SETCLR_UPD ) { + val =BIT (mux->gate_shift); +writel (val, priv->base + mux->mux_set_reg); + }else { + val =readl (priv->base + mux->gate_reg); + val |=BIT (mux->gate_shift); +writel (val, priv->base + mux->gate_reg); + }return 0 ; }
drivers/clk/mediatek/clk-mtk.h +26 -0
@@ -12,6 +12,7 @@#define HAVE_RST_BAR BIT(0)#define CLK_DOMAIN_SCPSYS BIT(0) +#define CLK_MUX_SETCLR_UPD BIT(1)#define CLK_GATE_SETCLR BIT(0)#define CLK_GATE_SETCLR_INV BIT(1)
@@ -36,9 +37,12 @@ struct mtk_pll_data {u32 flags;u32 rst_bar_mask;u64 fmax; +u64 fmin;int pcwbits; +int pcwibits;u32 pcw_reg;int pcw_shift; +u32 pcw_chg_reg; };/**
@@ -102,9 +106,13 @@ struct mtk_composite {const int id;const int *parent;u32 mux_reg; +u32 mux_set_reg; +u32 mux_clr_reg; +u32 upd_reg;u32 gate_reg;u32 mux_mask;signed char mux_shift; +signed char upd_shift;signed char gate_shift;signed char num_parents;u16 flags;
@@ -137,6 +145,24 @@ struct mtk_composite { .flags = 0, \ } +#define MUX_CLR_SET_UPD_FLAGS (_id, _parents, _mux_ofs, _mux_set_ofs,\ + _mux_clr_ofs, _shift, _width, _gate, \ + _upd_ofs, _upd, _flags) { \ + .id = _id, \ + .mux_reg = _mux_ofs, \ + .mux_set_reg = _mux_set_ofs, \ + .mux_clr_reg = _mux_clr_ofs, \ + .upd_reg = _upd_ofs, \ + .upd_shift = _upd, \ + .mux_shift = _shift, \ + .mux_mask = BIT(_width) - 1, \ + .gate_reg = _mux_ofs, \ + .gate_shift = _gate, \ + .parent = _parents, \ + .num_parents = ARRAY_SIZE(_parents), \ + .flags = _flags, \ + } +struct mtk_gate_regs {u32 sta_ofs;u32 clr_ofs;
Signature · 1 line
2.18.0
PATCH 2/7 clk: mediatek: adjust common driver for mt8512
Quoted 4 lines · mingming lee
Update mtk common clock driver to support mt8512
1. add newset_clr_updmux type and related operation
2. add configurable pcw_chg_reg/ibits/fmin tomtk_pll
3. fixmtk_clk_find_parent_ratedata overflow.
I think these should be split into different patches. Also, Sam has sent a fixup for overflow problem
Quoted 216 lines
Signed-off-by mingming lee <[email protected]>--- drivers/clk/mediatek/clk-mtk.c | 72 ++++++++++++++++++++++++---------- drivers/clk/mediatek/clk-mtk.h | 26 ++++++++++++ 2 files changed, 77 insertions(+), 21 deletions(-)drivers/clk/mediatek/clk-mtk.c +51
-21@@ -39,8 +39,8 @@* this function is recursively called to find the parent to calculate * the accurate frequency. */ -static int mtk_clk_find_parent_rate (struct clk *clk,int id, -const struct driver *drv) +static ulong mtk_clk_find_parent_rate (struct clk *clk,int id, +const struct driver *drv) {struct clk parent = { .id = id, };@@ -67,12 +67,23 @@ static int mtk_clk_mux_set_parent(void __iomem *base, u32 parent,if (++index == mux->num_parents)return -EINVAL ; -/* switch mux to a select parent */ - val =readl (base + mux->mux_reg); - val &= ~(mux->mux_mask << mux->mux_shift); +if (mux->flags &CLK_MUX_SETCLR_UPD ) { + val = (mux->mux_mask << mux->mux_shift); +writel (val, base + mux->mux_clr_reg); - val |= index << mux->mux_shift; -writel (val, base + mux->mux_reg); + val = (index << mux->mux_shift); +writel (val, base + mux->mux_set_reg); + +if (mux->upd_shift >=0 ) +writel (BIT (mux->upd_shift), base + mux->upd_reg); + }else { +/* switch mux to a select parent */ + val =readl (base + mux->mux_reg); + val &= ~(mux->mux_mask << mux->mux_shift); + + val |= index << mux->mux_shift; +writel (val, base + mux->mux_reg); + }return 0 ; }@@ -84,11 +95,13 @@ static unsigned long __mtk_pll_recalc_rate(const struct mtk_pll_data *pll, {int pcwbits = pll->pcwbits;int pcwfbits; +int ibits;u64 vco;u8 c =0 ;/* The fractional part of the PLL divider. */ - pcwfbits = pcwbits >INTEGER_BITS ? pcwbits -INTEGER_BITS :0 ; + ibits = pll->pcwibits ? pll->pcwibits :INTEGER_BITS ; + pcwfbits = pcwbits > ibits ? pcwbits - ibits :0 ; vco = (u64 )fin * pcw;@@ -113,7 +126,7 @@ static void mtk_pll_set_rate_regs(struct clk *clk, u32 pcw, int postdiv) {struct mtk_clk_priv *priv =dev_get_priv (clk->dev);const struct mtk_pll_data *pll = &priv->tree->plls[clk->id]; -u32 val; +u32 val, chg;/* set postdiv */ val =readl (priv->base + pll->pd_reg);@@ -129,11 +142,16 @@ static void mtk_pll_set_rate_regs(struct clk *clk, u32 pcw, int postdiv)/* set pcw */ val &= ~GENMASK (pll->pcw_shift + pll->pcwbits -1 , pll->pcw_shift); val |= pcw << pll->pcw_shift; - val &= ~CON1_PCW_CHG ; -writel (val, priv->base + pll->pcw_reg); - val |=CON1_PCW_CHG ; -writel (val, priv->base + pll->pcw_reg); +if (pll->pcw_chg_reg) { + chg =readl (priv->base + pll->pcw_chg_reg); + chg |=CON1_PCW_CHG ; +writel (val, priv->base + pll->pcw_reg); +writel (chg, priv->base + pll->pcw_chg_reg); + }else { + val |=CON1_PCW_CHG ; +writel (val, priv->base + pll->pcw_reg); + }udelay (20 ); }@@ -150,8 +168,9 @@ static void mtk_pll_calc_values(struct clk *clk, u32 *pcw, u32 *postdiv, {struct mtk_clk_priv *priv =dev_get_priv (clk->dev);const struct mtk_pll_data *pll = &priv->tree->plls[clk->id]; -unsigned long fmin =1000 *MHZ ; +unsigned long fmin = pll->fmin ? pll->fmin :1000 *MHZ ;u64 _pcw; +int ibits;u32 val;if (freq > pll->fmax)@@ -164,7 +183,8 @@ static void mtk_pll_calc_values(struct clk *clk, u32 *pcw, u32 *postdiv, }/* _pcw = freq * postdiv / xtal_rate * 2^pcwfbits */ - _pcw = ((u64 )freq << val) << (pll->pcwbits -INTEGER_BITS ); + ibits = pll->pcwibits ? pll->pcwibits :INTEGER_BITS ; + _pcw = ((u64 )freq << val) << (pll->pcwbits - ibits);do_div (_pcw, priv->tree->xtal2_rate); *pcw = (u32 )_pcw;@@ -332,9 +352,14 @@ static int mtk_topckgen_enable(struct clk *clk)return 0 ;/* enable clock gate */ - val =readl (priv->base + mux->gate_reg); - val &= ~BIT (mux->gate_shift); -writel (val, priv->base + mux->gate_reg); +if (mux->flags &CLK_MUX_SETCLR_UPD ) { + val =BIT (mux->gate_shift); +writel (val, priv->base + mux->mux_clr_reg); + }else { + val =readl (priv->base + mux->gate_reg); + val &= ~BIT (mux->gate_shift); +writel (val, priv->base + mux->gate_reg); + }if (mux->flags &CLK_DOMAIN_SCPSYS ) {/* enable scpsys clock off control */ @@ -360,9 +385,14 @@ static int mtk_topckgen_disable(struct clk *clk)return 0 ;/* disable clock gate */ - val =readl (priv->base + mux->gate_reg); - val |=BIT (mux->gate_shift); -writel (val, priv->base + mux->gate_reg); +if (mux->flags &CLK_MUX_SETCLR_UPD ) { + val =BIT (mux->gate_shift); +writel (val, priv->base + mux->mux_set_reg); + }else { + val =readl (priv->base + mux->gate_reg); + val |=BIT (mux->gate_shift); +writel (val, priv->base + mux->gate_reg); + }return 0 ; }drivers/clk/mediatek/clk-mtk.h +26
-0@@ -12,6 +12,7 @@#define HAVE_RST_BAR BIT(0)#define CLK_DOMAIN_SCPSYS BIT(0) +#define CLK_MUX_SETCLR_UPD BIT(1)#define CLK_GATE_SETCLR BIT(0)#define CLK_GATE_SETCLR_INV BIT(1)@@ -36,9 +37,12 @@ struct mtk_pll_data {u32 flags;u32 rst_bar_mask;u64 fmax; +u64 fmin;int pcwbits; +int pcwibits;u32 pcw_reg;int pcw_shift; +u32 pcw_chg_reg; };/** @@ -102,9 +106,13 @@ struct mtk_composite {const int id;const int *parent;u32 mux_reg; +u32 mux_set_reg; +u32 mux_clr_reg; +u32 upd_reg;u32 gate_reg;u32 mux_mask;signed char mux_shift; +signed char upd_shift;signed char gate_shift;signed char num_parents;u16 flags;@@ -137,6 +145,24 @@ struct mtk_composite { .flags = 0, \ } +#define MUX_CLR_SET_UPD_FLAGS (_id, _parents, _mux_ofs, _mux_set_ofs,\ + _mux_clr_ofs, _shift, _width, _gate, \ + _upd_ofs, _upd, _flags) { \ + .id = _id, \ + .mux_reg = _mux_ofs, \ + .mux_set_reg = _mux_set_ofs, \ + .mux_clr_reg = _mux_clr_ofs, \ + .upd_reg = _upd_ofs, \ + .upd_shift = _upd, \ + .mux_shift = _shift, \ + .mux_mask = BIT(_width) - 1, \ + .gate_reg = _mux_ofs, \ + .gate_shift = _gate, \ + .parent = _parents, \ + .num_parents = ARRAY_SIZE(_parents), \ + .flags = _flags, \ + } +struct mtk_gate_regs {u32 sta_ofs;u32 clr_ofs;
PATCH 2/7 clk: mediatek: adjust common driver for mt8512
Quoted 216 lines · Ryder Lee
Quoted 4 lines · mingming lee
Update mtk common clock driver to support mt8512
1. add newset_clr_updmux type and related operation
2. add configurable pcw_chg_reg/ibits/fmin tomtk_pll
3. fixmtk_clk_find_parent_ratedata overflow.I think these should be split into different patches. Also, Sam has sent a fixup for overflow problem
Quoted 208 lines
Signed-off-by mingming lee <[email protected]>--- drivers/clk/mediatek/clk-mtk.c | 72 ++++++++++++++++++++++++---------- drivers/clk/mediatek/clk-mtk.h | 26 ++++++++++++ 2 files changed, 77 insertions(+), 21 deletions(-)drivers/clk/mediatek/clk-mtk.c +51
-21@@ -39,8 +39,8 @@* this function is recursively called to find the parent to calculate * the accurate frequency. */ -static int mtk_clk_find_parent_rate (struct clk *clk,int id, -const struct driver *drv) +static ulong mtk_clk_find_parent_rate (struct clk *clk,int id, +const struct driver *drv) {struct clk parent = { .id = id, };@@ -67,12 +67,23 @@ static int mtk_clk_mux_set_parent(void __iomem *base, u32 parent,if (++index == mux->num_parents)return -EINVAL ; -/* switch mux to a select parent */ - val =readl (base + mux->mux_reg); - val &= ~(mux->mux_mask << mux->mux_shift); +if (mux->flags &CLK_MUX_SETCLR_UPD ) { + val = (mux->mux_mask << mux->mux_shift); +writel (val, base + mux->mux_clr_reg); - val |= index << mux->mux_shift; -writel (val, base + mux->mux_reg); + val = (index << mux->mux_shift); +writel (val, base + mux->mux_set_reg); + +if (mux->upd_shift >=0 ) +writel (BIT (mux->upd_shift), base + mux->upd_reg); + }else { +/* switch mux to a select parent */ + val =readl (base + mux->mux_reg); + val &= ~(mux->mux_mask << mux->mux_shift); + + val |= index << mux->mux_shift; +writel (val, base + mux->mux_reg); + }return 0 ; }@@ -84,11 +95,13 @@ static unsigned long __mtk_pll_recalc_rate(const struct mtk_pll_data *pll, {int pcwbits = pll->pcwbits;int pcwfbits; +int ibits;u64 vco;u8 c =0 ;/* The fractional part of the PLL divider. */ - pcwfbits = pcwbits >INTEGER_BITS ? pcwbits -INTEGER_BITS :0 ; + ibits = pll->pcwibits ? pll->pcwibits :INTEGER_BITS ; + pcwfbits = pcwbits > ibits ? pcwbits - ibits :0 ; vco = (u64 )fin * pcw;@@ -113,7 +126,7 @@ static void mtk_pll_set_rate_regs(struct clk *clk, u32 pcw, int postdiv) {struct mtk_clk_priv *priv =dev_get_priv (clk->dev);const struct mtk_pll_data *pll = &priv->tree->plls[clk->id]; -u32 val; +u32 val, chg;/* set postdiv */ val =readl (priv->base + pll->pd_reg);@@ -129,11 +142,16 @@ static void mtk_pll_set_rate_regs(struct clk *clk, u32 pcw, int postdiv)/* set pcw */ val &= ~GENMASK (pll->pcw_shift + pll->pcwbits -1 , pll->pcw_shift); val |= pcw << pll->pcw_shift; - val &= ~CON1_PCW_CHG ; -writel (val, priv->base + pll->pcw_reg); - val |=CON1_PCW_CHG ; -writel (val, priv->base + pll->pcw_reg); +if (pll->pcw_chg_reg) { + chg =readl (priv->base + pll->pcw_chg_reg); + chg |=CON1_PCW_CHG ; +writel (val, priv->base + pll->pcw_reg); +writel (chg, priv->base + pll->pcw_chg_reg); + }else { + val |=CON1_PCW_CHG ; +writel (val, priv->base + pll->pcw_reg); + }udelay (20 ); }@@ -150,8 +168,9 @@ static void mtk_pll_calc_values(struct clk *clk, u32 *pcw, u32 *postdiv, {struct mtk_clk_priv *priv =dev_get_priv (clk->dev);const struct mtk_pll_data *pll = &priv->tree->plls[clk->id]; -unsigned long fmin =1000 *MHZ ; +unsigned long fmin = pll->fmin ? pll->fmin :1000 *MHZ ;u64 _pcw; +int ibits;u32 val;if (freq > pll->fmax)@@ -164,7 +183,8 @@ static void mtk_pll_calc_values(struct clk *clk, u32 *pcw, u32 *postdiv, }/* _pcw = freq * postdiv / xtal_rate * 2^pcwfbits */ - _pcw = ((u64 )freq << val) << (pll->pcwbits -INTEGER_BITS ); + ibits = pll->pcwibits ? pll->pcwibits :INTEGER_BITS ; + _pcw = ((u64 )freq << val) << (pll->pcwbits - ibits);do_div (_pcw, priv->tree->xtal2_rate); *pcw = (u32 )_pcw;@@ -332,9 +352,14 @@ static int mtk_topckgen_enable(struct clk *clk)return 0 ;/* enable clock gate */ - val =readl (priv->base + mux->gate_reg); - val &= ~BIT (mux->gate_shift); -writel (val, priv->base + mux->gate_reg); +if (mux->flags &CLK_MUX_SETCLR_UPD ) { + val =BIT (mux->gate_shift); +writel (val, priv->base + mux->mux_clr_reg); + }else { + val =readl (priv->base + mux->gate_reg); + val &= ~BIT (mux->gate_shift); +writel (val, priv->base + mux->gate_reg); + }if (mux->flags &CLK_DOMAIN_SCPSYS ) {/* enable scpsys clock off control */ @@ -360,9 +385,14 @@ static int mtk_topckgen_disable(struct clk *clk)return 0 ;/* disable clock gate */ - val =readl (priv->base + mux->gate_reg); - val |=BIT (mux->gate_shift); -writel (val, priv->base + mux->gate_reg); +if (mux->flags &CLK_MUX_SETCLR_UPD ) { + val =BIT (mux->gate_shift); +writel (val, priv->base + mux->mux_set_reg); + }else { + val =readl (priv->base + mux->gate_reg); + val |=BIT (mux->gate_shift); +writel (val, priv->base + mux->gate_reg); + }return 0 ; }drivers/clk/mediatek/clk-mtk.h +21
-0@@ -12,6 +12,7 @@#define HAVE_RST_BAR BIT(0)#define CLK_DOMAIN_SCPSYS BIT(0) +#define CLK_MUX_SETCLR_UPD BIT(1)#define CLK_GATE_SETCLR BIT(0)#define CLK_GATE_SETCLR_INV BIT(1)@@ -36,9 +37,12 @@ struct mtk_pll_data {u32 flags;u32 rst_bar_mask;u64 fmax; +u64 fmin;int pcwbits; +int pcwibits;u32 pcw_reg;int pcw_shift; +u32 pcw_chg_reg; };/** @@ -102,9 +106,13 @@ struct mtk_composite {const int id;const int *parent;u32 mux_reg; +u32 mux_set_reg; +u32 mux_clr_reg; +u32 upd_reg;u32 gate_reg;u32 mux_mask;signed char mux_shift; +signed char upd_shift;signed char gate_shift;signed char num_parents;u16 flags;@@ -137,6 +145,24 @@ struct mtk_composite { .flags = 0, \ } +#define MUX_CLR_SET_UPD_FLAGS (_id, _parents, _mux_ofs, _mux_set_ofs,\ + _mux_clr_ofs, _shift, _width, _gate, \ + _upd_ofs, _upd, _flags) { \ + .id = _id, \ + .mux_reg = _mux_ofs, \ + .mux_set_reg = _mux_set_ofs, \ + .mux_clr_reg = _mux_clr_ofs, \ + .upd_reg = _upd_ofs, \ + .upd_shift = _upd, \ + .mux_shift = _shift, \ + .mux_mask = BIT(_width) - 1, \ + .gate_reg = _mux_ofs, \ + .gate_shift = _gate, \
Quoted 10 lines
drivers/clk/mediatek/clk-mtk.h struct mtk_composite { · line 168
Quoted 8 lines
drivers/clk/mediatek/clk-mtk.h +5
-0+ .parent = _parents, \ + .num_parents = ARRAY_SIZE(_parents), \ + .flags = _flags, \ + } +struct mtk_gate_regs {u32 sta_ofs;u32 clr_ofs;
OK,I will split it.
Also, Sam has sent a fixup for overflow problem ------->And do you mean I could not care this in my patch.
PATCH 3/7 clk: mediatek: add driver support for MT8512
In reply to mingming leeAdd clock driver for MediaTek MT8512 SoC, include topckgen, apmixedsys and infracfg support.
--- drivers/clk/mediatek/Makefile | 1 + drivers/clk/mediatek/clk-mt8512.c | 873 +++++++++++++++++++++++++ include/dt-bindings/clock/mt8512-clk.h | 197 ++++++ 3 files changed, 1071 insertions(+) create mode 100644 drivers/clk/mediatek/clk-mt8512.c create mode 100644 include/dt-bindings/clock/mt8512-clk.h
drivers/clk/mediatek/Makefile +1 -0
@@ -3,6 +3,7 @@ obj-$(CONFIG_ARCH_MEDIATEK) += clk-mtk.o # SoC Drivers +obj-$(CONFIG_MT8512) += clk-mt8512.o obj-$(CONFIG_TARGET_MT7623) += clk-mt7623.o obj-$(CONFIG_TARGET_MT7629) += clk-mt7629.o obj-$(CONFIG_TARGET_MT8516) += clk-mt8516.o
drivers/clk/mediatek/clk-mt8512.c new file +873 -0
873 lines not on this page · raw message
include/dt-bindings/clock/mt8512-clk.h new file +197 -0
197 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH 4/7 pinctrl: mediatek: add driver for MT8512
In reply to mingming leeAdd Pinctrl driver for MediaTek MT8512 SoC.
--- drivers/pinctrl/mediatek/Kconfig | 4 + drivers/pinctrl/mediatek/Makefile | 1 + drivers/pinctrl/mediatek/pinctrl-mt8512.c | 387 ++++++++++++++++++++++ 3 files changed, 392 insertions(+) create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8512.c
drivers/pinctrl/mediatek/Kconfig +4 -0
@@ -12,6 +12,10 @@ config PINCTRL_MT7629 bool "MT7629 SoC pinctrl driver" select PINCTRL_MTK +config PINCTRL_MT8512 + bool "MT8512 SoC pinctrl driver" + select PINCTRL_MTK + config PINCTRL_MT8516 bool "MT8516 SoC pinctrl driver" select PINCTRL_MTK
drivers/pinctrl/mediatek/Makefile +1 -0
@@ -5,5 +5,6 @@ obj-$(CONFIG_PINCTRL_MTK) += pinctrl-mtk-common.o # SoC Drivers obj-$(CONFIG_PINCTRL_MT7623) += pinctrl-mt7623.o obj-$(CONFIG_PINCTRL_MT7629) += pinctrl-mt7629.o +obj-$(CONFIG_PINCTRL_MT8512) += pinctrl-mt8512.o obj-$(CONFIG_PINCTRL_MT8516) += pinctrl-mt8516.o obj-$(CONFIG_PINCTRL_MT8518) += pinctrl-mt8518.o
drivers/pinctrl/mediatek/pinctrl-mt8512.c new file +387 -0
387 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH 5/7 mmc: mtk-sd: add support for MediaTek MT8512/MT8110 SoCs
In reply to mingming leeThis patch adds mmc support for MediaTek MT8512/MT8110 SoCs. MT8512/MT8110 SoCs puts the tune register at top layer, so need add new code to support it.
--- drivers/mmc/mtk-sd.c | 134 ++++++++++++++++++++++++++++++++----------- 1 file changed, 101 insertions(+), 33 deletions(-)
drivers/mmc/mtk-sd.c +101 -33
@@ -12,6 +12,7 @@#include <mmc.h> #include <errno.h> #include <malloc.h> +#include <mapmem.h> #include <stdbool.h> #include <watchdog.h> #include <asm/gpio.h>
@@ -135,6 +136,25 @@#define SDC_FIFO_CFG_WRVALIDSEL BIT(24)#define SDC_FIFO_CFG_RDVALIDSEL BIT(25) +/* EMMC_TOP_CONTROL mask */ +#define PAD_RXDLY_SEL BIT(0) +#define DELAY_EN BIT(1) +#define PAD_DAT_RD_RXDLY2 (0x1f << 2) +#define PAD_DAT_RD_RXDLY (0x1f << 7) +#define PAD_DAT_RD_RXDLY_S 7 +#define PAD_DAT_RD_RXDLY2_SEL BIT(12) +#define PAD_DAT_RD_RXDLY_SEL BIT(13) +#define DATA_K_VALUE_SEL BIT(14) +#define SDC_RX_ENH_EN BIT(15) + +/* EMMC_TOP_CMD mask */ +#define PAD_CMD_RXDLY2 (0x1f << 0) +#define PAD_CMD_RXDLY (0x1f << 5) +#define PAD_CMD_RXDLY_S 5 +#define PAD_CMD_RD_RXDLY2_SEL BIT(10) +#define PAD_CMD_RD_RXDLY_SEL BIT(11) +#define PAD_CMD_TX_DLY (0x1f << 12) +/* SDC_CFG_BUSWIDTH */ #define MSDC_BUS_1BITS 0x0#define MSDC_BUS_4BITS 0x1
@@ -219,6 +239,21 @@ struct mtk_sd_regs {u32 sdc_fifo_cfg; }; +struct msdc_top_regs { +u32 emmc_top_control; +u32 emmc_top_cmd; +u32 emmc50_pad_ctl0; +u32 emmc50_pad_ds_tune; +u32 emmc50_pad_dat0_tune; +u32 emmc50_pad_dat1_tune; +u32 emmc50_pad_dat2_tune; +u32 emmc50_pad_dat3_tune; +u32 emmc50_pad_dat4_tune; +u32 emmc50_pad_dat5_tune; +u32 emmc50_pad_dat6_tune; +u32 emmc50_pad_dat7_tune; +}; +struct msdc_compatible {u8 clk_div_bits;u8 sclk_cycle_shift;
@@ -249,6 +284,7 @@ struct msdc_tune_para {struct msdc_host {struct mtk_sd_regs *base; +struct msdc_top_regs *top_base;struct mmc *mmc;struct msdc_compatible *dev_comp;
@@ -964,6 +1000,36 @@ static struct msdc_delay_phase get_best_delay(struct msdc_host *host, u32 delay)return delay_phase; } +static inline void msdc_set_cmd_delay (struct msdc_host *host,u32 value) +{ +void __iomem *tune_reg = &host->base->pad_tune; + +if (host->dev_comp->pad_tune0) + tune_reg = &host->base->pad_tune0; + +if (host->top_base) +clrsetbits_le32 (&host->top_base->emmc_top_cmd,PAD_CMD_RXDLY , + value <<PAD_CMD_RXDLY_S ); +else +clrsetbits_le32 (tune_reg,MSDC_PAD_TUNE_CMDRDLY_M , + value <<MSDC_PAD_TUNE_CMDRDLY_S ); +} + +static inline void msdc_set_data_delay (struct msdc_host *host,u32 value) +{ +void __iomem *tune_reg = &host->base->pad_tune; + +if (host->dev_comp->pad_tune0) + tune_reg = &host->base->pad_tune0; + +if (host->top_base) +clrsetbits_le32 (&host->top_base->emmc_top_control, +PAD_DAT_RD_RXDLY , value <<PAD_DAT_RD_RXDLY_S ); +else +clrsetbits_le32 (tune_reg,MSDC_PAD_TUNE_DATRRDLY_M , + value <<MSDC_PAD_TUNE_DATRRDLY_S ); +} +static int hs400_tune_response (struct udevice *dev,u32 opcode) {struct msdc_plat *plat =dev_get_platdata (dev);
@@ -1010,7 +1076,7 @@ static int hs400_tune_response(struct udevice *dev, u32 opcode) PAD_CMD_TUNE_RX_DLY3_S); final_delay = final_cmd_delay.final_phase; -dev_err (dev,"Final cmd pad delay: %x\n" , final_delay); +dev_info (dev,"Final cmd pad delay: %x\n" , final_delay);return final_delay ==0xff ? -EIO :0 ; }
@@ -1217,21 +1283,14 @@ static int msdc_tune_together(struct udevice *dev, u32 opcode)u32 rise_delay =0 , fall_delay =0 ;struct msdc_delay_phase final_rise_delay, final_fall_delay = {0 , };u8 final_delay, final_maxlen; -void __iomem *tune_reg = &host->base->pad_tune;int i, ret; -if (host->dev_comp->pad_tune0) - tune_reg = &host->base->pad_tune0; -clrbits_le32 (&host->base->msdc_iocon,MSDC_IOCON_DSPL );clrbits_le32 (&host->base->msdc_iocon,MSDC_IOCON_W_DSPL );for (i =0 ; i <PAD_DELAY_MAX ; i++) { -clrsetbits_le32 (tune_reg,MSDC_PAD_TUNE_CMDRDLY_M , - i <<MSDC_PAD_TUNE_CMDRDLY_S ); -clrsetbits_le32 (tune_reg,MSDC_PAD_TUNE_DATRRDLY_M , - i <<MSDC_PAD_TUNE_DATRRDLY_S ); - +msdc_set_cmd_delay (host, i); +msdc_set_data_delay (host, i); ret =mmc_send_tuning (mmc, opcode,NULL );if (!ret) rise_delay |= (1 << i);
@@ -1246,11 +1305,8 @@ static int msdc_tune_together(struct udevice *dev, u32 opcode)setbits_le32 (&host->base->msdc_iocon,MSDC_IOCON_W_DSPL );for (i =0 ; i <PAD_DELAY_MAX ; i++) { -clrsetbits_le32 (tune_reg,MSDC_PAD_TUNE_CMDRDLY_M , - i <<MSDC_PAD_TUNE_CMDRDLY_S ); -clrsetbits_le32 (tune_reg,MSDC_PAD_TUNE_DATRRDLY_M , - i <<MSDC_PAD_TUNE_DATRRDLY_S ); - +msdc_set_cmd_delay (host, i); +msdc_set_data_delay (host, i); ret =mmc_send_tuning (mmc, opcode,NULL );if (!ret) fall_delay |= (1 << i);
@@ -1263,27 +1319,17 @@ skip_fall:if (final_maxlen == final_rise_delay.maxlen) {clrbits_le32 (&host->base->msdc_iocon,MSDC_IOCON_DSPL );clrbits_le32 (&host->base->msdc_iocon,MSDC_IOCON_W_DSPL ); -clrsetbits_le32 (tune_reg,MSDC_PAD_TUNE_CMDRDLY_M , - final_rise_delay.final_phase << -MSDC_PAD_TUNE_CMDRDLY_S ); -clrsetbits_le32 (tune_reg,MSDC_PAD_TUNE_DATRRDLY_M , - final_rise_delay.final_phase << -MSDC_PAD_TUNE_DATRRDLY_S ); final_delay = final_rise_delay.final_phase; }else {setbits_le32 (&host->base->msdc_iocon,MSDC_IOCON_DSPL );setbits_le32 (&host->base->msdc_iocon,MSDC_IOCON_W_DSPL ); -clrsetbits_le32 (tune_reg,MSDC_PAD_TUNE_CMDRDLY_M , - final_fall_delay.final_phase << -MSDC_PAD_TUNE_CMDRDLY_S ); -clrsetbits_le32 (tune_reg,MSDC_PAD_TUNE_DATRRDLY_M , - final_fall_delay.final_phase << -MSDC_PAD_TUNE_DATRRDLY_S ); final_delay = final_fall_delay.final_phase; } -dev_err (dev,"Final pad delay: %x\n" , final_delay); +msdc_set_cmd_delay (host, final_delay); +msdc_set_data_delay (host, final_delay); +dev_info (dev,"Final pad delay: %x\n" , final_delay);return final_delay ==0xff ? -EIO :0 ; }
@@ -1400,8 +1446,12 @@ static void msdc_init_hw(struct msdc_host *host) 3 << MSDC_PB2_RESPWAIT_S);if (host->dev_comp->enhance_rx) { -setbits_le32 (&host->base->sdc_adv_cfg0, -SDC_RX_ENHANCE_EN ); +if (host->top_base) +setbits_le32 (&host->top_base->emmc_top_control, +SDC_RX_ENH_EN ); +else +setbits_le32 (&host->base->sdc_adv_cfg0, +SDC_RX_ENHANCE_EN ); }else { clrsetbits_le32(&host->base->patch_bit2, MSDC_PB2_RESPSTSENSEL_M,
@@ -1476,7 +1526,6 @@ static int msdc_drv_probe(struct udevice *dev) cfg->f_min = host->src_clk_freq / (4 *255 ); else cfg->f_min = host->src_clk_freq / (4 * 4095); - cfg->f_max = host->src_clk_freq /2 ; cfg->b_max =1024 ; cfg->voltages =MMC_VDD_32_33 |MMC_VDD_33_34 ;
@@ -1502,11 +1551,19 @@ static int msdc_ofdata_to_platdata(struct udevice *dev)struct msdc_plat *plat =dev_get_platdata (dev);struct msdc_host *host =dev_get_priv (dev);struct mmc_config *cfg = &plat->cfg; +fdt_addr_t base, top_base;int ret; - host->base = (void *)dev_read_addr (dev); -if (!host->base) + base =dev_read_addr (dev); +if (base ==FDT_ADDR_T_NONE )return -EINVAL ; + host->base =map_sysmem (base,0 ); + + top_base =dev_read_addr_index (dev,1 ); +if (top_base ==FDT_ADDR_T_NONE ) + host->top_base =NULL ; +else + host->top_base =map_sysmem (top_base,0 ); ret =mmc_of_parse (dev, cfg);if (ret)
@@ -1579,6 +1636,16 @@ static const struct msdc_compatible mt7623_compat = { .enhance_rx = false }; +static const struct msdc_compatible mt8512_compat = { + .clk_div_bits =12 , + .sclk_cycle_shift =20 , + .pad_tune0 = true, + .async_fifo = true, + .data_tune = true, + .busy_check = true, + .stop_clk_fix = true, +}; +static const struct msdc_compatible mt8516_compat = { .clk_div_bits =12 , .sclk_cycle_shift =20 ,
@@ -1602,6 +1669,7 @@ static const struct msdc_compatible mt8183_compat = {static const struct udevice_id msdc_ids[] = { { .compatible ="mediatek,mt7620-mmc" , .data = (ulong)&mt7620_compat }, { .compatible ="mediatek,mt7623-mmc" , .data = (ulong)&mt7623_compat }, + { .compatible ="mediatek,mt8512-mmc" , .data = (ulong)&mt8512_compat }, { .compatible ="mediatek,mt8516-mmc" , .data = (ulong)&mt8516_compat }, { .compatible ="mediatek,mt8183-mmc" , .data = (ulong)&mt8183_compat }, {}
Signature · 1 line
2.18.0
PATCH 6/7 mmc: mtk-sd: fix hang when data read quickly
In reply to mingming leeFor CMD21 tuning data, the 128/64 bytes data may coming in very short time, before msdc_start_data(), the read data has already come, in this case, clear MSDC_INT will cause the interrupt disappear and lead to the thread hang.
the solution is just clear all interrupts before command was sent.
--- drivers/mmc/mtk-sd.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/mmc/mtk-sd.c +1 -5
@@ -14,7 +14,6 @@#include <malloc.h> #include <mapmem.h> #include <stdbool.h> -#include <watchdog.h> #include <asm/gpio.h> #include <dm/pinctrl.h> #include <linux/bitops.h>
@@ -531,6 +530,7 @@ static int msdc_start_command(struct msdc_host *host, struct mmc_cmd *cmd, blocks = data->blocks;writel (CMD_INTS_MASK , &host->base->msdc_int); +writel (DATA_INTS_MASK , &host->base->msdc_int);writel (blocks, &host->base->sdc_blk_num);writel (cmd->cmdarg, &host->base->sdc_arg);writel (rawcmd, &host->base->sdc_cmd);
@@ -677,13 +677,9 @@ static int msdc_start_data(struct msdc_host *host, struct mmc_data *data)u32 size;int ret; -WATCHDOG_RESET (); -if (data->flags ==MMC_DATA_WRITE ) host->last_data_write =1 ; -writel (DATA_INTS_MASK , &host->base->msdc_int); - size = data->blocks * data->blocksize;if (data->flags ==MMC_DATA_WRITE )
Signature · 1 line
2.18.0
PATCH 7/7 ARM: MediaTek: add basic support for MT8512 boards
In reply to mingming leeThis adds a general board file based on MT8512 SoCs from MediaTek.
Apart from the generic parts (cpu) we add some low level init codes and initialize the early clocks.
This commit is adding the basic boot support for the MT8512 eMMC board.
--- arch/arm/dts/Makefile | 1 + arch/arm/dts/mt8512-bm1-emmc.dts | 106 ++++++++++++++++++++++++++++++ board/mediatek/mt8512/Kconfig | 14 ++++ board/mediatek/mt8512/MAINTAINERS | 6 ++ board/mediatek/mt8512/Makefile | 3 + board/mediatek/mt8512/mt8512.c | 19 ++++++ configs/mt8512_bm1_emmc_defconfig | 44 +++++++++++++ include/configs/mt8512.h | 60 +++++++++++++++++ 8 files changed, 253 insertions(+) create mode 100644 arch/arm/dts/mt8512-bm1-emmc.dts create mode 100644 board/mediatek/mt8512/Kconfig create mode 100644 board/mediatek/mt8512/MAINTAINERS create mode 100644 board/mediatek/mt8512/Makefile create mode 100644 board/mediatek/mt8512/mt8512.c create mode 100644 configs/mt8512_bm1_emmc_defconfig create mode 100644 include/configs/mt8512.h
arch/arm/dts/Makefile +1 -0
@@ -835,6 +835,7 @@ dtb-$(CONFIG_SOC_K3_J721E) += k3-j721e-common-proc-board.dtb \ dtb-$(CONFIG_ARCH_MEDIATEK) += \ mt7623n-bananapi-bpi-r2.dtb \ mt7629-rfb.dtb \ + mt8512-bm1-emmc.dtb \ mt8516-pumpkin.dtb \ mt8518-ap1-emmc.dtb
arch/arm/dts/mt8512-bm1-emmc.dts new file +106 -0
106 lines not on this page · raw message
board/mediatek/mt8512/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +if TARGET_MT8512 + +config SYS_BOARD + default "mt8512" + +config SYS_CONFIG_NAME + default "mt8512" + + +config MTK_BROM_HEADER_INFO + string + default "media=nor" + +endif
board/mediatek/mt8512/MAINTAINERS new file +6 -0
@@ -0,0 +1,6 @@ +MT8512 +M: Mingming lee <[email protected]> +S: Maintained +F: board/mediatek/mt8512 +F: include/configs/mt8512.h +F: configs/mt8512_bm1_emmc_defconfig
board/mediatek/mt8512/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-y += mt8512.o
board/mediatek/mt8512/mt8512.c new file +19 -0
@@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2019 MediaTek Inc. +*/ + +#include <common.h> +#include <dm.h> +#include <wdt.h> + +DECLARE_GLOBAL_DATA_PTR ; + +int board_init (void ) +{ +/* address of boot parameters */ + gd->bd->bi_boot_params = gd->ram_base +0x100 ; + +debug ("gd->fdt_blob is %p\n" , gd->fdt_blob); +return 0 ; +}
configs/mt8512_bm1_emmc_defconfig new file +44 -0
44 lines not on this page · raw message
include/configs/mt8512.h new file +60 -0
60 lines not on this page · raw message
Signature · 1 line
2.18.0