Add support for MT8516 SoCs
Subsystems (8)
cover Add support for MT8516 SoCs
This patch series adds basic boot support on eMMC for the MediaTek MT8516 SoC based boards. This series adds the clock, pinctrl drivers and the SoC initialization code.
Fabien Parent (6):
mmc: mtk-sd: add source_cg clock support
mmc: mtk-sd: add support for MT8516
clk: mediatek: add support for CLK_GATE_SETCLR_INV flag
clk: mediatek: add driver for MT8516
pinctrl: add driver for MT8516
ARM: MediaTek: Add support for MT8516 SoC
arch/arm/dts/mt8516.dtsi | 142 ++++ arch/arm/mach-mediatek/Kconfig | 10 + arch/arm/mach-mediatek/Makefile | 1 + arch/arm/mach-mediatek/mt8516/Makefile | 3 + arch/arm/mach-mediatek/mt8516/init.c | 112 +++ drivers/clk/mediatek/Makefile | 1 + drivers/clk/mediatek/clk-mt8516.c | 802 ++++++++++++++++++++++ drivers/clk/mediatek/clk-mtk.c | 3 + drivers/mmc/mtk-sd.c | 18 + drivers/pinctrl/mediatek/Kconfig | 4 + drivers/pinctrl/mediatek/Makefile | 1 + drivers/pinctrl/mediatek/pinctrl-mt8516.c | 391 +++++++++++ include/dt-bindings/clock/mt8516-clk.h | 251 +++++++ 13 files changed, 1739 insertions(+) create mode 100644 arch/arm/dts/mt8516.dtsi create mode 100644 arch/arm/mach-mediatek/mt8516/Makefile create mode 100644 arch/arm/mach-mediatek/mt8516/init.c create mode 100644 drivers/clk/mediatek/clk-mt8516.c create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8516.c create mode 100644 include/dt-bindings/clock/mt8516-clk.h
Signature · 1 line
2.20.1
PATCH 1/6 mmc: mtk-sd: add source_cg clock support
Some MediaTek SoC need an additional clock "source_cg". Enable this new clock. We reuse the same clock name as in the kernel.
--- drivers/mmc/mtk-sd.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/mmc/mtk-sd.c +8 -0
@@ -247,7 +247,9 @@ struct msdc_host {struct msdc_compatible *dev_comp;struct clk src_clk;/* for SD/MMC bus clock */ +struct clk src_clk_cg;/* optional, MSDC source clock control gate */ struct clk h_clk;/* MSDC core clock */ +bool has_src_clk_cg;u32 src_clk_freq;/* source clock */ u32 mclk;/* mmc framework required bus clock */
@@ -1269,6 +1271,8 @@ static void msdc_ungate_clock(struct msdc_host *host) {clk_enable (&host->src_clk);clk_enable (&host->h_clk); +if (host->has_src_clk_cg) +clk_enable (&host->src_clk_cg); }static int msdc_drv_probe (struct udevice *dev)
@@ -1332,6 +1336,10 @@ static int msdc_ofdata_to_platdata(struct udevice *dev)if (ret <0 )return ret; + ret =clk_get_by_name (dev,"source_cg" , &host->src_clk_cg);/* optional */ +if (!ret) + host->has_src_clk_cg = true; +#if IS_ENABLED (DM_GPIO )gpio_request_by_name (dev,"wp-gpios" ,0 , &host->gpio_wp,GPIOD_IS_IN );gpio_request_by_name (dev,"cd-gpios" ,0 , &host->gpio_cd,GPIOD_IS_IN );
Signature · 1 line
2.20.1
PATCH 1/6 mmc: mtk-sd: add source_cg clock support
Quoted 4 lines · Fabien Parent
Some MediaTek SoC need an additional clock "
source_cg". Enable this new clock. We reuse the same clock name as in the kernel.Signed-off-by Fabien Parent <[email protected]>
Quoted 9 lines
--- drivers/mmc/mtk-sd.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/mmc/mtk-sd.c +0
-0
drivers/mmc/mtk-sd.c struct msdc_host { · line 252
Quoted 6 lines
drivers/mmc/mtk-sd.c +2
-0@@ -247,7 +247,9 @@ struct msdc_host {struct msdc_compatible *dev_comp;struct clk src_clk;/* for SD/MMC bus clock */ +struct clk src_clk_cg;/* optional, MSDC source clock control gate */ struct clk h_clk;/* MSDC core clock */ +bool has_src_clk_cg;
<just_checking>
Could we have a chance to get rid of this flag?
</just_checking>
Quoted 22 lines
drivers/mmc/mtk-sd.c +6
-0u32 src_clk_freq;/* source clock */ u32 mclk;/* mmc framework required bus clock */ @@ -1269,6 +1271,8 @@ static void msdc_ungate_clock(struct msdc_host *host) {clk_enable (&host->src_clk);clk_enable (&host->h_clk); +if (host->has_src_clk_cg) +clk_enable (&host->src_clk_cg); }static int msdc_drv_probe (struct udevice *dev)@@ -1332,6 +1336,10 @@ static int msdc_ofdata_to_platdata(struct udevice *dev)if (ret <0 )return ret; + ret =clk_get_by_name (dev,"source_cg" , &host->src_clk_cg);/* optional */ +if (!ret) + host->has_src_clk_cg = true; +#if IS_ENABLED (DM_GPIO )gpio_request_by_name (dev,"wp-gpios" ,0 , &host->gpio_wp,GPIOD_IS_IN );gpio_request_by_name (dev,"cd-gpios" ,0 , &host->gpio_cd,GPIOD_IS_IN );
PATCH 2/6 mmc: mtk-sd: add support for MT8516
In reply to Fabien ParentAdd config for handling MT8516 SoC.
--- drivers/mmc/mtk-sd.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/mmc/mtk-sd.c +10 -0
@@ -1384,8 +1384,18 @@ static const struct msdc_compatible mt7623_compat = { .enhance_rx = false }; +static const struct msdc_compatible mt8516_compat = { + .clk_div_bits =12 , + .pad_tune0 = true, + .async_fifo = true, + .data_tune = true, + .busy_check = true, + .stop_clk_fix = true, +}; +static const struct udevice_id msdc_ids[] = { { .compatible ="mediatek,mt7623-mmc" , .data = (ulong)&mt7623_compat }, + { .compatible ="mediatek,mt8516-mmc" , .data = (ulong)&mt8516_compat }, {} };
Signature · 1 line
2.20.1
PATCH 2/6 mmc: mtk-sd: add support for MT8516
Quoted 3 lines · Fabien Parent
Add config for handling MT8516 SoC.
Signed-off-by Fabien Parent <[email protected]>
Quoted 27 lines
--- drivers/mmc/mtk-sd.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/mmc/mtk-sd.c +10
-0@@ -1384,8 +1384,18 @@ static const struct msdc_compatible mt7623_compat = { .enhance_rx = false }; +static const struct msdc_compatible mt8516_compat = { + .clk_div_bits =12 , + .pad_tune0 = true, + .async_fifo = true, + .data_tune = true, + .busy_check = true, + .stop_clk_fix = true, +}; +static const struct udevice_id msdc_ids[] = { { .compatible ="mediatek,mt7623-mmc" , .data = (ulong)&mt7623_compat }, + { .compatible ="mediatek,mt8516-mmc" , .data = (ulong)&mt8516_compat }, {} };
PATCH 3/6 clk: mediatek: add support for CLK_GATE_SETCLR_INV flag
In reply to Fabien ParentAdd the implementation for the CLK_GATE_SETCLR_INV flag.
--- drivers/clk/mediatek/clk-mtk.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/clk/mediatek/clk-mtk.c +3 -0
@@ -390,6 +390,9 @@ static int mtk_clk_gate_enable(struct clk *clk)case CLK_GATE_SETCLR :writel (bit, priv->base + gate->regs->clr_ofs);break ; +case CLK_GATE_SETCLR_INV : +writel (bit, priv->base + gate->regs->set_ofs); +break ;case CLK_GATE_NO_SETCLR_INV :clrsetbits_le32 (priv->base + gate->regs->sta_ofs, bit, bit);break ;
Signature · 1 line
2.20.1
PATCH 3/6 clk: mediatek: add support for CLK_GATE_SETCLR_INV flag
Quoted 3 lines · Fabien Parent
Add the implementation for the
CLK_GATE_SETCLR_INVflag.Signed-off-by Fabien Parent <[email protected]>
Quoted 18 lines
--- drivers/clk/mediatek/clk-mtk.c | 3 +++ 1 file changed, 3 insertions(+)drivers/clk/mediatek/clk-mtk.c +3
-0@@ -390,6 +390,9 @@ static int mtk_clk_gate_enable(struct clk *clk)case CLK_GATE_SETCLR :writel (bit, priv->base + gate->regs->clr_ofs);break ; +case CLK_GATE_SETCLR_INV : +writel (bit, priv->base + gate->regs->set_ofs); +break ;case CLK_GATE_NO_SETCLR_INV :clrsetbits_le32 (priv->base + gate->regs->sta_ofs, bit, bit);break ;
PATCH 4/6 clk: mediatek: add driver for MT8516
In reply to Fabien ParentAdd clock driver for MediaTek MT8516 SoC.
--- drivers/clk/mediatek/Makefile | 1 + drivers/clk/mediatek/clk-mt8516.c | 802 +++++++++++++++++++++++++ include/dt-bindings/clock/mt8516-clk.h | 251 ++++++++ 3 files changed, 1054 insertions(+) create mode 100644 drivers/clk/mediatek/clk-mt8516.c create mode 100644 include/dt-bindings/clock/mt8516-clk.h
drivers/clk/mediatek/Makefile +1 -0
@@ -5,3 +5,4 @@ obj-$(CONFIG_ARCH_MEDIATEK) += clk-mtk.o # SoC Drivers 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-mt8516.c new file +802 -0
802 lines not on this page · raw message
include/dt-bindings/clock/mt8516-clk.h new file +251 -0
251 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 4/6 clk: mediatek: add driver for MT8516
Quoted 33 lines · Fabien Parent
Add clock driver for MediaTek MT8516 SoC.
Signed-off-by Fabien Parent <[email protected]>--- drivers/clk/mediatek/Makefile | 1 + drivers/clk/mediatek/clk-mt8516.c | 802 +++++++++++++++++++++++++ include/dt-bindings/clock/mt8516-clk.h | 251 ++++++++ 3 files changed, 1054 insertions(+) create mode 100644 drivers/clk/mediatek/clk-mt8516.c create mode 100644 include/dt-bindings/clock/mt8516-clk.hdrivers/clk/mediatek/Makefile +1
-0@@ -5,3 +5,4 @@ obj-$(CONFIG_ARCH_MEDIATEK) += clk-mtk.o # SoC Drivers obj-$(CONFIG_TARGET_MT7623) += clk-mt7623.o obj-$(CONFIG_TARGET_MT7629) += clk-mt7629.o +obj-$(CONFIG_TARGET_MT8516) += clk-mt8516.odrivers/clk/mediatek/clk-mt8516.c new file +7
-0@@ -0,0 +1,802 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* MediaTek clock driver for MT8516 SoC +* +* Copyright (C) 2018 BayLibre, SAS +* Author: Fabien Parent <[email protected]> +*/
[snip]
include/dt-bindings/clock/mt8516-clk.h line 7
Quoted 13 lines
include/dt-bindings/clock/mt8516-clk.h new file +7
-0@@ -0,0 +1,251 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2018 BayLibre, SAS +* Copyright (c) 2018 MediaTek Inc. +* Author: Fabien Parent <[email protected]> +*/ +
[snip]
We are in 2019 now :)
PATCH 5/6 pinctrl: add driver for MT8516
In reply to Fabien ParentAdd Pinctrl driver for MediaTek MT8516 SoC.
--- drivers/pinctrl/mediatek/Kconfig | 4 + drivers/pinctrl/mediatek/Makefile | 1 + drivers/pinctrl/mediatek/pinctrl-mt8516.c | 391 ++++++++++++++++++++++ 3 files changed, 396 insertions(+) create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8516.c
drivers/pinctrl/mediatek/Kconfig +4 -0
@@ -12,4 +12,8 @@ config PINCTRL_MT7629 bool "MT7629 SoC pinctrl driver" select PINCTRL_MTK +config PINCTRL_MT8516 + bool "MT8516 SoC pinctrl driver" + select PINCTRL_MTK + endif
drivers/pinctrl/mediatek/Makefile +1 -0
@@ -5,3 +5,4 @@ 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_MT8516) += pinctrl-mt8516.o
drivers/pinctrl/mediatek/pinctrl-mt8516.c new file +391 -0
391 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 5/6 pinctrl: add driver for MT8516
Quoted 38 lines · Fabien Parent
Add Pinctrl driver for MediaTek MT8516 SoC.
Signed-off-by Fabien Parent <[email protected]>--- drivers/pinctrl/mediatek/Kconfig | 4 + drivers/pinctrl/mediatek/Makefile | 1 + drivers/pinctrl/mediatek/pinctrl-mt8516.c | 391 ++++++++++++++++++++++ 3 files changed, 396 insertions(+) create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8516.cdrivers/pinctrl/mediatek/Kconfig +4
-0@@ -12,4 +12,8 @@ config PINCTRL_MT7629 bool "MT7629 SoC pinctrl driver" select PINCTRL_MTK +config PINCTRL_MT8516 + bool "MT8516 SoC pinctrl driver" + select PINCTRL_MTK + endifdrivers/pinctrl/mediatek/Makefile +1
-0@@ -5,3 +5,4 @@ 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_MT8516) += pinctrl-mt8516.odrivers/pinctrl/mediatek/pinctrl-mt8516.c new file +0
-0
drivers/pinctrl/mediatek/pinctrl-mt8516.c line 5
Quoted 5 lines
drivers/pinctrl/mediatek/pinctrl-mt8516.c new file +5
-0@@ -0,0 +1,391 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2018 BayLibre, SAS +* Author: Fabien Parent <[email protected]> +*/
Looks good to me, but we are in 2019 now :)
PATCH 6/6 ARM: MediaTek: Add support for MT8516 SoC
In reply to Fabien ParentAdd support for MediaTek MT8516 SoC. This include the file that will initialize the SoC after boot and its device tree.
--- arch/arm/dts/mt8516.dtsi | 142 +++++++++++++++++++++++++ arch/arm/mach-mediatek/Kconfig | 10 ++ arch/arm/mach-mediatek/Makefile | 1 + arch/arm/mach-mediatek/mt8516/Makefile | 3 + arch/arm/mach-mediatek/mt8516/init.c | 112 +++++++++++++++++++ 5 files changed, 268 insertions(+) create mode 100644 arch/arm/dts/mt8516.dtsi create mode 100644 arch/arm/mach-mediatek/mt8516/Makefile create mode 100644 arch/arm/mach-mediatek/mt8516/init.c
arch/arm/dts/mt8516.dtsi new file +142 -0
@@ -0,0 +1,142 @@ +/* + * Copyright (C) 2018 BayLibre, SAS + * Author: Fabien Parent <[email protected]> + * + * SPDX-License-Identifier: (GPL-2.0 OR MIT) + */ + +#include <dt-bindings/clock/mt8516-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,mt8516"; + interrupt-parent = <&sysirq>; + #address-cells = <1>; + #size-cells = <1>; + + cpus { + #address-cells = <1>; + #size-cells = <0>; + enable-method = "mediatek,mt8516-smp"; + + cpu at 0 { + device_type = "cpu"; + compatible = "arm,cortex-a35"; + reg = <0x0>; + clock-frequency = <1300000000>; + }; + + cpu at 1 { + device_type = "cpu"; + compatible = "arm,cortex-a35"; + reg = <0x1>; + clock-frequency = <1300000000>; + }; + + cpu at 2 { + device_type = "cpu"; + compatible = "arm,cortex-a35"; + reg = <0x2>; + clock-frequency = <1300000000>; + }; + + cpu at 3 { + device_type = "cpu"; + compatible = "arm,cortex-a35"; + reg = <0x3>; + clock-frequency = <1300000000>; + }; + }; + + topckgen: clock-controller at 10000000 { + compatible = "mediatek,mt8516-topckgen"; + reg = <0x10000000 0x1000>; + #clock-cells = <1>; + u-boot,dm-pre-reloc; + }; + + topckgen_cg: clock-controller-cg at 10000000 { + compatible = "mediatek,mt8516-topckgen-cg"; + reg = <0x10000000 0x1000>; + #clock-cells = <1>; + u-boot,dm-pre-reloc; + }; + + infracfg: clock-controller at 10001000 { + compatible = "mediatek,mt8516-infracfg"; + reg = <0x10001000 0x1000>; + #clock-cells = <1>; + u-boot,dm-pre-reloc; + }; + + apmixedsys: clock-controller at 10018000 { + compatible = "mediatek,mt8516-apmixedsys"; + reg = <0x10018000 0x710>; + #clock-cells = <1>; + u-boot,dm-pre-reloc; + }; + + gic: interrupt-controller at 10310000 { + compatible = "arm,gic-400"; + interrupt-controller; + #interrupt-cells = <3>; + interrupt-parent = <&gic>; + reg = <0x10310000 0x1000>, + <0x10320000 0x1000>, + <0x10340000 0x2000>, + <0x10360000 0x2000>; + interrupts = <GIC_PPI 9 + (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>; + }; + + sysirq: interrupt-controller at 10200620 { + compatible = "mediatek,sysirq"; + interrupt-controller; + #interrupt-cells = <3>; + interrupt-parent = <&gic>; + reg = <0x10200620 0x20>; + }; + + watchdog: watchdog at 10007000 { + compatible = "mediatek,wdt"; + reg = <0x10007000 0x1000>; + interrupts = <GIC_SPI 198 IRQ_TYPE_EDGE_FALLING>; + #reset-cells = <1>; + status = "disabled"; + }; + + pinctrl: pinctrl at 10005000 { + compatible = "mediatek,mt8516-pinctrl"; + reg = <0x10005000 0x1000>; + + gpio: gpio-controller { + gpio-controller; + #gpio-cells = <2>; + }; + }; + + mmc0: mmc at 11120000 { + compatible = "mediatek,mt8516-mmc"; + reg = <0x11120000 0x1000>; + interrupts = <GIC_SPI 78 IRQ_TYPE_LEVEL_LOW>; + clocks = <&topckgen_cg CLK_TOP_MSDC0>, + <&topckgen CLK_TOP_AHB_INFRA_SEL>, + <&topckgen_cg CLK_TOP_MSDC0_INFRA>; + clock-names = "source", "hclk", "source_cg"; + status = "disabled"; + }; + + uart0: serial at 11005000 { + compatible = "mediatek,hsuart"; + reg = <0x11005000 0x1000>; + reg-shift = <2>; + interrupts = <GIC_SPI 84 IRQ_TYPE_LEVEL_LOW>; + clocks = <&topckgen CLK_TOP_UART0_SEL>, + <&topckgen_cg CLK_TOP_UART0>; + clock-names = "baud","bus"; + status = "disabled"; + u-boot,dm-pre-reloc; + }; +};
arch/arm/mach-mediatek/Kconfig +10 -0
@@ -31,6 +31,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_MT8516 + bool "MediaTek MT8516 SoC" + select ARM64 + select ARCH_MISC_INIT + help + The MediaTek MT8516 is a ARM64-based SoC with a quad-core Cortex-A35. + 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. + endchoice source "board/mediatek/mt7623/Kconfig"
arch/arm/mach-mediatek/Makefile +1 -0
@@ -5,3 +5,4 @@ obj-$(CONFIG_SPL_BUILD) += spl.o obj-$(CONFIG_TARGET_MT7623) += mt7623/ obj-$(CONFIG_TARGET_MT7629) += mt7629/ +obj-$(CONFIG_TARGET_MT8516) += mt8516/
arch/arm/mach-mediatek/mt8516/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-y += init.o
arch/arm/mach-mediatek/mt8516/init.c new file +112 -0
112 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 6/6 ARM: MediaTek: Add support for MT8516 SoC
Quoted 4 lines · Fabien Parent
Add support for MediaTek MT8516 SoC. This include the file that will initialize the SoC after boot and its device tree.
Signed-off-by Fabien Parent <[email protected]>
[snip]
arch/arm/dts/mt8516.dtsi line 58
Quoted 6 lines
arch/arm/dts/mt8516.dtsi new file +6
-0+ topckgen: clock-controller at 10000000 { + compatible = "mediatek,mt8516-topckgen"; + reg = <0x10000000 0x1000>; + #clock-cells = <1>; + u-boot,dm-pre-reloc; + };
The u-boot,xxx properties go in a -u-boot.dtsi file, see scripts/Makefile.lib for the logic on how we automatically find them. This makes future re-syncs with this file from the kernel less problematic (as seen on say am33xx where we broke some platforms when we removed these dm-pre-reloc properties by accident as they didn't get put into am33xx-u-boot.dtsi as the mechanism didn't exist then). Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190208/5e956b73/attachment.sig>