Skip to contentSkip to conversation

Add support for MT8516 SoCs

PATCH Superseded Fabien Parent 2 participants 8 messages Feb 23, 2019 – Feb 26, 2019

Subsystems (8)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 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 SETCLR_INV and NO_SETCLR flags
clk: mediatek: add driver for MT8516
pinctrl: add driver for MT8516
ARM: MediaTek: Add support for MT8516 SoC

 arch/arm/dts/mt8516-u-boot.dtsi           |  25 +
 arch/arm/dts/mt8516.dtsi                  | 136 ++++
 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      | 120 ++++
 drivers/clk/mediatek/Makefile             |   1 +
 drivers/clk/mediatek/clk-mt8516.c         | 802 ++++++++++++++++++++++
 drivers/clk/mediatek/clk-mtk.c            |  12 +
 drivers/mmc/mtk-sd.c                      |  15 +
 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 +++++++
 14 files changed, 1772 insertions(+)
 create mode 100644 arch/arm/dts/mt8516-u-boot.dtsi
 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
#1 lore raw

PATCH v2 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.

---

v2:
* Get rid of variable has_src_clk_cg

---
 drivers/mmc/mtk-sd.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/mmc/mtk-sd.c +5 -0
index d3f0778368..eed98b769c 100644
@@ -247,6 +247,7 @@ 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 */
 
 	u32 src_clk_freq;	/* source clock */
@@ -1269,6 +1270,8 @@ static void msdc_ungate_clock(struct msdc_host *host)
 {
 	clk_enable(&host->src_clk);
 	clk_enable(&host->h_clk);
+	if (host->src_clk_cg.dev)
+		clk_enable(&host->src_clk_cg);
 }
 
 static int msdc_drv_probe(struct udevice *dev)
@@ -1332,6 +1335,8 @@ static int msdc_ofdata_to_platdata(struct udevice *dev)
 	if (ret < 0)
 		return ret;
 
+	clk_get_by_name(dev, "source_cg", &host->src_clk_cg); /* optional */
+
 #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
#2 lore raw

PATCH v2 2/6 mmc: mtk-sd: add support for MT8516

In reply to Fabien Parent

Add config for handling MT8516 SoC.

---

v2:
* No change

---
 drivers/mmc/mtk-sd.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/mmc/mtk-sd.c +10 -0
index eed98b769c..b44686fbc9 100644
@@ -1381,8 +1381,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
#3 lore raw

PATCH v2 3/6 clk: mediatek: add support for SETCLR_INV and NO_SETCLR flags

In reply to Fabien Parent

Add the implementation for the CLK_GATE_SETCLR_INV and CLK_GATE_NO_SETCLR flags.

---

v2:
* Add missing support for SETCLR_INV in the mtk_clk_gate_disable func
* Add support for CLK_GATE_NO_SETCLR

---
 drivers/clk/mediatek/clk-mtk.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/clk/mediatek/clk-mtk.c +12 -0
index 870b14ed8b..6c6b500d9b 100644
@@ -390,6 +390,12 @@ 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:
+		clrsetbits_le32(priv->base + gate->regs->sta_ofs, bit, 0);
+		break;
 	case CLK_GATE_NO_SETCLR_INV:
 		clrsetbits_le32(priv->base + gate->regs->sta_ofs, bit, bit);
 		break;
@@ -411,6 +417,12 @@ static int mtk_clk_gate_disable(struct clk *clk)
 	case CLK_GATE_SETCLR:
 		writel(bit, priv->base + gate->regs->set_ofs);
 		break;
+	case CLK_GATE_SETCLR_INV:
+		writel(bit, priv->base + gate->regs->clr_ofs);
+		break;
+	case CLK_GATE_NO_SETCLR:
+		clrsetbits_le32(priv->base + gate->regs->sta_ofs, bit, bit);
+		break;
 	case CLK_GATE_NO_SETCLR_INV:
 		clrsetbits_le32(priv->base + gate->regs->sta_ofs, bit, 0);
 		break;
Signature · 1 line
2.20.1
#4 lore raw

PATCH v2 4/6 clk: mediatek: add driver for MT8516

In reply to Fabien Parent

Add clock driver for MediaTek MT8516 SoC.

---

v2:
* Fix invalid GATE_TOP5 flag

---
 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
index 0632dc87b6..a47a5bdbc2 100644
@@ -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
#5 lore raw

PATCH v2 5/6 pinctrl: add driver for MT8516

In reply to Fabien Parent

Add Pinctrl driver for MediaTek MT8516 SoC.

---

v2:
* No change

---
 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
index 1bd9a925a5..9930ca1faf 100644
@@ -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
index f6ef3627e8..c4f29088d2 100644
@@ -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
#6 lore raw

PATCH v2 6/6 ARM: MediaTek: Add support for MT8516 SoC

In reply to Fabien Parent

Add support for MediaTek MT8516 SoC. This include the file that will initialize the SoC after boot and its device tree.

---

v2:
* Move u-boot,dm-pre-reloc into a seperate dts
* Implement dram_init_banksize to get DRAM size correct

---
 arch/arm/dts/mt8516-u-boot.dtsi        |  26 +++++
 arch/arm/dts/mt8516.dtsi               | 137 +++++++++++++++++++++++++
 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   | 120 ++++++++++++++++++++++
 6 files changed, 295 insertions(+)
 create mode 100644 arch/arm/dts/mt8516-u-boot.dtsi
 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-u-boot.dtsi new file +25 -0
new file mode 100644
index 0000000000..3c0d843f35
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2019 BayLibre, SAS
+ * Author: Fabien Parent <[email protected]>
+ */
+
+&infracfg {
+	u-boot,dm-pre-reloc;
+};
+
+&topckgen_ {
+	u-boot,dm-pre-reloc;
+};
+
+&topckgen_cg {
+	u-boot,dm-pre-reloc;
+};
+
+&apmixedsys {
+	u-boot,dm-pre-reloc;
+};
+
+&uart0 {
+	u-boot,dm-pre-reloc;
+};
arch/arm/dts/mt8516.dtsi new file +136 -0

136 lines not on this page · raw message

arch/arm/mach-mediatek/Kconfig +10 -0
index 7a733e95df..b5e91d4a7d 100644
@@ -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
index b5d3a379bc..ea414dc407 100644
@@ -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
new file mode 100644
index 0000000000..886ab7e4eb
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier:	GPL-2.0
+
+obj-y += init.o
arch/arm/mach-mediatek/mt8516/init.c new file +120 -0

120 lines not on this page · raw message

Signature · 1 line
2.20.1
#7 lore raw

PATCH v2 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.

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/20190226/e44370cd/attachment.sig>