Skip to contentSkip to conversation

Add support for MediaTek MT8518 Soc

PATCH New mingming lee 2 participants 11 messages Nov 7, 2019 – Dec 4, 2019

Subsystems (9)
lore
Share & tools
lore
#0 lore raw

v3 cover Add support for MediaTek MT8518 Soc

This patch series adds basic boot support on eMMC for the MediaTek MT8518 SoC based boards. This series add the clock, pinctrl drivers and the SoC initializaton code.

---

Changes for v3:
- Fix top clock register definition which cause unused warning.
- Change hs400 to hs200 since the dts is hs200
- Fixed all build warnings using gcc version 740

Changes for v2:
- Fixed issues in v1: drop unused 'devices',delete no need code and print debug log using debug()
- Delete unnecessary configs in defconfig
- Adjust the mmc tuning flow to support HS400

mingming lee (5):
ARM: MediaTek: Add support for MediaTek MT8518 SoC
clk: mediatek: add driver for MT8518
mmc: mtk-sd: Adjust the mmc tuning flow
pinctrl: add driver for MT8518
ARM: MediaTek: add basic support for MT8518 boards

 arch/arm/dts/Makefile                         |    3 +-
 arch/arm/dts/mt8518-ap1-emmc.dts              |  104 ++
 arch/arm/dts/mt8518.dtsi                      |   98 ++
 arch/arm/mach-mediatek/Kconfig                |   10 +
 arch/arm/mach-mediatek/Makefile               |    1 +
 arch/arm/mach-mediatek/mt8518/Makefile        |    4 +
 arch/arm/mach-mediatek/mt8518/init.c          |   71 +
 arch/arm/mach-mediatek/mt8518/lowlevel_init.S |   32 +
 board/mediatek/mt8518/Kconfig                 |   14 +
 board/mediatek/mt8518/MAINTAINERS             |    6 +
 board/mediatek/mt8518/Makefile                |    3 +
 board/mediatek/mt8518/mt8518_ap1.c            |   18 +
 configs/mt8518_ap1_emmc_defconfig             |   41 +
 drivers/clk/mediatek/Makefile                 |    1 +
 drivers/clk/mediatek/clk-mt8518.c             | 1558 +++++++++++++++++
 drivers/mmc/mtk-sd.c                          |  209 ++-
 drivers/pinctrl/mediatek/Kconfig              |    4 +
 drivers/pinctrl/mediatek/Makefile             |    1 +
 drivers/pinctrl/mediatek/pinctrl-mt8518.c     |  411 +++++
 include/configs/mt8518.h                      |   68 +
 include/dt-bindings/clock/mt8518-clk.h        |  249 +++
 21 files changed, 2889 insertions(+), 17 deletions(-)
 create mode 100644 arch/arm/dts/mt8518-ap1-emmc.dts
 create mode 100644 arch/arm/dts/mt8518.dtsi
 create mode 100644 arch/arm/mach-mediatek/mt8518/Makefile
 create mode 100644 arch/arm/mach-mediatek/mt8518/init.c
 create mode 100644 arch/arm/mach-mediatek/mt8518/lowlevel_init.S
 create mode 100644 board/mediatek/mt8518/Kconfig
 create mode 100644 board/mediatek/mt8518/MAINTAINERS
 create mode 100644 board/mediatek/mt8518/Makefile
 create mode 100644 board/mediatek/mt8518/mt8518_ap1.c
 create mode 100644 configs/mt8518_ap1_emmc_defconfig
 create mode 100644 drivers/clk/mediatek/clk-mt8518.c
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8518.c
 create mode 100644 include/configs/mt8518.h
 create mode 100644 include/dt-bindings/clock/mt8518-clk.h
Signature · 1 line
2.23.0
#1 lore raw

PATCH v3 1/5 ARM: MediaTek: Add support for MediaTek MT8518 SoC

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

---

Changes for v3:
-drop unused api to keep it simple

Changes for v2:
-drop unused 'device' in dtsi to keep it simple

---
 arch/arm/dts/mt8518.dtsi                      | 91 +++++++++++++++++++
 arch/arm/mach-mediatek/Kconfig                |  9 ++
 arch/arm/mach-mediatek/Makefile               |  1 +
 arch/arm/mach-mediatek/mt8518/Makefile        |  4 +
 arch/arm/mach-mediatek/mt8518/init.c          | 71 +++++++++++++++
 arch/arm/mach-mediatek/mt8518/lowlevel_init.S | 32 +++++++
 6 files changed, 208 insertions(+)
 create mode 100644 arch/arm/dts/mt8518.dtsi
 create mode 100644 arch/arm/mach-mediatek/mt8518/Makefile
 create mode 100644 arch/arm/mach-mediatek/mt8518/init.c
 create mode 100644 arch/arm/mach-mediatek/mt8518/lowlevel_init.S
arch/arm/dts/mt8518.dtsi new file +91 -0
new file mode 100644
index 0000000000..9f56122319
@@ -0,0 +1,91 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2019 MediaTek Inc.
+ * Author: Mingming Lee <[email protected]>
+ *
+ */
+
+#include <dt-bindings/clock/mt8518-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,mt8518";
+	interrupt-parent = <&sysirq>;
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+
+
+	topckgen: clock-controller at 10000000 {
+		compatible = "mediatek,mt8518-topckgen";
+		reg = <0x10000000 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 */
+			  <0xc100000 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_CLK26M_D2>,
+			 <&topckgen CLK_TOP_CLK32K>,
+			 <&topckgen CLK_TOP_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;
+	};
+
+
+
+	mmc0: mmc at 11120000 {
+		compatible = "mediatek,mt8516-mmc";
+		reg = <0x11120000 0x1000>;
+		interrupts = <GIC_SPI 78 IRQ_TYPE_LEVEL_LOW>;
+		clocks = <&topckgen CLK_TOP_MSDC0>,
+			<&topckgen CLK_TOP_MSDC0>,
+			<&topckgen CLK_TOP_MSDC0_B>;
+		clock-names = "source", "hclk", "source_cg";
+		status = "disabled";
+	};
+
+	uart0: serial at 11005000 {
+		compatible = "mediatek,hsuart";
+		reg = <0x11005000 0x1000>;
+		interrupts = <GIC_SPI 84 IRQ_TYPE_LEVEL_LOW>;
+		clocks = <&topckgen CLK_TOP_UART0_SEL>,
+			<&topckgen CLK_TOP_UART0>;
+		clock-names = "baud", "bus";
+		status = "disabled";
+	};
+
+};
arch/arm/mach-mediatek/Kconfig +9 -0
index 25ef7651f0..8e343c3182 100644
@@ -38,6 +38,15 @@ config TARGET_MT8516
 	  Ethernet, IR TX/RX, I2C, I2S, S/PDIF, and built-in Wi-Fi / Bluetooth combo
 	  chip and several DDR3 and DDR4 options.
 
+config TARGET_MT8518
+	bool "MediaTek MT8518 SoC"
+	select ARM64
+	help
+	  The MediaTek MT8518 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.
+
 endchoice
 
 source "board/mediatek/mt7623/Kconfig"
arch/arm/mach-mediatek/Makefile +1 -0
index ea414dc407..b9b2355e03 100644
@@ -6,3 +6,4 @@ obj-$(CONFIG_SPL_BUILD)	+= spl.o
 obj-$(CONFIG_TARGET_MT7623) += mt7623/
 obj-$(CONFIG_TARGET_MT7629) += mt7629/
 obj-$(CONFIG_TARGET_MT8516) += mt8516/
+obj-$(CONFIG_TARGET_MT8518) += mt8518/
arch/arm/mach-mediatek/mt8518/Makefile new file +4 -0
new file mode 100644
index 0000000000..007eb4a367
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier:	GPL-2.0
+
+obj-y += init.o
+obj-y += lowlevel_init.o
arch/arm/mach-mediatek/mt8518/init.c new file +71 -0

71 lines not on this page · raw message

arch/arm/mach-mediatek/mt8518/lowlevel_init.S new file +32 -0
new file mode 100644
index 0000000000..ad392120f4
@@ -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.23.0
#3 lore raw

PATCH v3 2/5 clk: mediatek: add driver for MT8518

In reply to mingming lee

Add clock driver for MediaTek MT8518 SoC.

---
Changes for v3:
-fix top clock register definition which cause unused warning.

---
 drivers/clk/mediatek/Makefile          |    1 +
 drivers/clk/mediatek/clk-mt8518.c      | 1558 ++++++++++++++++++++++++
 include/dt-bindings/clock/mt8518-clk.h |  249 ++++
 3 files changed, 1808 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8518.c
 create mode 100644 include/dt-bindings/clock/mt8518-clk.h
drivers/clk/mediatek/Makefile +1 -0
index a47a5bdbc2..e92bcd4efe 100644
@@ -6,3 +6,4 @@ obj-$(CONFIG_ARCH_MEDIATEK) += clk-mtk.o
 obj-$(CONFIG_TARGET_MT7623) += clk-mt7623.o
 obj-$(CONFIG_TARGET_MT7629) += clk-mt7629.o
 obj-$(CONFIG_TARGET_MT8516) += clk-mt8516.o
+obj-$(CONFIG_TARGET_MT8518) += clk-mt8518.o
drivers/clk/mediatek/clk-mt8518.c new file +1558 -0

1,558 lines not on this page · raw message

include/dt-bindings/clock/mt8518-clk.h new file +249 -0

249 lines not on this page · raw message

Signature · 1 line
2.23.0
#5 lore raw

PATCH v3 3/5 mmc: mtk-sd: Adjust the mmc tuning flow

In reply to mingming lee

1.Support cmd response and data tuning together.
2.Support hs400 cmd responese tuning.

---
Changes for v2:
- add hs400 support

---
 drivers/mmc/mtk-sd.c | 209 +++++++++++++++++++++++++++++++++++++++----
 1 file changed, 193 insertions(+), 16 deletions(-)
drivers/mmc/mtk-sd.c +193 -16
index ffd647fac7..eaa584a4df 100644
@@ -125,6 +125,9 @@
 #define MSDC_PAD_TUNE_DATWRDLY_M	0x1f
 #define MSDC_PAD_TUNE_DATWRDLY_S	0
 
+#define PAD_CMD_TUNE_RX_DLY3		0x3E
+#define PAD_CMD_TUNE_RX_DLY3_S		1
+
 /* EMMC50_CFG0 */
 #define EMMC50_CFG_CFCSTS_SEL		BIT(4)
 
@@ -209,7 +212,8 @@ struct mtk_sd_regs {
 	u32 eco_ver;
 	u32 reserved6[27];
 	u32 pad_ds_tune;
-	u32 reserved7[31];
+	u32 pad_cmd_tune;
+	u32 reserved7[30];
 	u32 emmc50_cfg0;
 	u32 reserved8[7];
 	u32 sdc_fifo_cfg;
@@ -240,6 +244,7 @@ struct msdc_plat {
 struct msdc_tune_para {
 	u32 iocon;
 	u32 pad_tune;
+	u32 pad_cmd_tune;
 };
 
 struct msdc_host {
@@ -364,6 +369,8 @@ static u32 msdc_cmd_prepare_raw_cmd(struct msdc_host *host,
 	case MMC_CMD_WRITE_SINGLE_BLOCK:
 	case MMC_CMD_READ_SINGLE_BLOCK:
 	case SD_CMD_APP_SEND_SCR:
+	case MMC_CMD_SEND_TUNING_BLOCK:
+	case MMC_CMD_SEND_TUNING_BLOCK_HS200:
 		dtype = 1;
 		break;
 	case SD_CMD_SWITCH_FUNC: /* same as MMC_CMD_SWITCH */
@@ -469,6 +476,14 @@ static int msdc_start_command(struct msdc_host *host, struct mmc_cmd *cmd,
 	if (!msdc_cmd_is_ready(host))
 		return -EIO;
 
+	if ((readl(&host->base->msdc_fifocs) &
+	    MSDC_FIFOCS_TXCNT_M) >> MSDC_FIFOCS_TXCNT_S ||
+	    (readl(&host->base->msdc_fifocs) &
+	    MSDC_FIFOCS_RXCNT_M) >> MSDC_FIFOCS_RXCNT_S) {
+		pr_err("TX/RX FIFO non-empty before start of IO. Reset\n");
+		msdc_reset_hw(host);
+	}
+
 	msdc_fifo_clr(host);
 
 	host->last_resp_type = cmd->resp_type;
@@ -652,14 +667,22 @@ static int msdc_ops_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
 			     struct mmc_data *data)
 {
 	struct msdc_host *host = dev_get_priv(dev);
-	int ret;
+	int cmd_ret, data_ret;
 
-	ret = msdc_start_command(host, cmd, data);
-	if (ret)
-		return ret;
+	cmd_ret = msdc_start_command(host, cmd, data);
+	if (cmd_ret &&
+	    !(cmd_ret == -EIO &&
+	    (cmd->cmdidx == MMC_CMD_SEND_TUNING_BLOCK ||
+	    cmd->cmdidx == MMC_CMD_SEND_TUNING_BLOCK_HS200)))
+		return cmd_ret;
 
-	if (data)
-		return msdc_start_data(host, data);
+	if (data) {
+		data_ret = msdc_start_data(host, data);
+		if (cmd_ret)
+			return cmd_ret;
+		else
+			return data_ret;
+	}
 
 	return 0;
 }
@@ -941,6 +964,56 @@ static struct msdc_delay_phase get_best_delay(struct msdc_host *host, u32 delay)
 	return delay_phase;
 }
 
+static int hs400_tune_response(struct udevice *dev, u32 opcode)
+{
+	struct msdc_plat *plat = dev_get_platdata(dev);
+	struct msdc_host *host = dev_get_priv(dev);
+	struct mmc *mmc = &plat->mmc;
+	u32 cmd_delay  = 0;
+	struct msdc_delay_phase final_cmd_delay = { 0, };
+	u8 final_delay;
+	void __iomem *tune_reg = &host->base->pad_cmd_tune;
+	int cmd_err;
+	int i, j;
+
+	setbits_le32(&host->base->pad_cmd_tune, BIT(0));
+
+	if (mmc->selected_mode == MMC_HS_200 ||
+	    mmc->selected_mode == UHS_SDR104)
+		clrsetbits_le32(tune_reg, MSDC_PAD_TUNE_CMDRRDLY_M,
+				host->hs200_cmd_int_delay <<
+				MSDC_PAD_TUNE_CMDRRDLY_S);
+
+	if (host->r_smpl)
+		clrbits_le32(&host->base->msdc_iocon, MSDC_IOCON_RSPL);
+	else
+		setbits_le32(&host->base->msdc_iocon, MSDC_IOCON_RSPL);
+
+	for (i = 0; i < PAD_DELAY_MAX; i++) {
+		clrsetbits_le32(tune_reg, PAD_CMD_TUNE_RX_DLY3,
+				i << PAD_CMD_TUNE_RX_DLY3_S);
+
+		for (j = 0; j < 3; j++) {
+			mmc_send_tuning(mmc, opcode, &cmd_err);
+			if (!cmd_err) {
+				cmd_delay |= (1 << i);
+			} else {
+				cmd_delay &= ~(1 << i);
+				break;
+			}
+		}
+	}
+
+	final_cmd_delay = get_best_delay(host, cmd_delay);
+	clrsetbits_le32(tune_reg, PAD_CMD_TUNE_RX_DLY3,
+			final_cmd_delay.final_phase <<
+			PAD_CMD_TUNE_RX_DLY3_S);
+	final_delay = final_cmd_delay.final_phase;
+
+	dev_err(dev, "Final cmd pad delay: %x\n", final_delay);
+	return final_delay == 0xff ? -EIO : 0;
+}
+
 static int msdc_tune_response(struct udevice *dev, u32 opcode)
 {
 	struct msdc_plat *plat = dev_get_platdata(dev);
@@ -1132,34 +1205,138 @@ skip_fall:
 	return final_delay == 0xff ? -EIO : 0;
 }
 
+/*
+ * MSDC IP which supports data tune + async fifo can do CMD/DAT tune
+ * together, which can save the tuning time.
+ */
+static int msdc_tune_together(struct udevice *dev, u32 opcode)
+{
+	struct msdc_plat *plat = dev_get_platdata(dev);
+	struct msdc_host *host = dev_get_priv(dev);
+	struct mmc *mmc = &plat->mmc;
+	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);
+
+		ret = mmc_send_tuning(mmc, opcode, NULL);
+		if (!ret)
+			rise_delay |= (1 << i);
+	}
+
+	final_rise_delay = get_best_delay(host, rise_delay);
+	if (final_rise_delay.maxlen >= 12 ||
+	    (final_rise_delay.start == 0 && final_rise_delay.maxlen >= 4))
+		goto skip_fall;
+
+	setbits_le32(&host->base->msdc_iocon, MSDC_IOCON_DSPL);
+	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);
+
+		ret = mmc_send_tuning(mmc, opcode, NULL);
+		if (!ret)
+			fall_delay |= (1 << i);
+	}
+
+	final_fall_delay = get_best_delay(host, fall_delay);
+
+skip_fall:
+	final_maxlen = max(final_rise_delay.maxlen, final_fall_delay.maxlen);
+	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);
+
+	return final_delay == 0xff ? -EIO : 0;
+}
+
 static int msdc_execute_tuning(struct udevice *dev, uint opcode)
 {
 	struct msdc_plat *plat = dev_get_platdata(dev);
 	struct msdc_host *host = dev_get_priv(dev);
 	struct mmc *mmc = &plat->mmc;
-	int ret;
+	int ret = 0;
+
+	if (host->dev_comp->data_tune && host->dev_comp->async_fifo) {
+		ret = msdc_tune_together(dev, opcode);
+		if (ret == -EIO) {
+			dev_err(dev, "Tune fail!\n");
+			return ret;
+		}
 
-	if (mmc->selected_mode == MMC_HS_400) {
-		writel(host->hs400_ds_delay, &host->base->pad_ds_tune);
-		/* for hs400 mode it must be set to 0 */
-		clrbits_le32(&host->base->patch_bit2, MSDC_PB2_CFGCRCSTS);
-		host->hs400_mode = true;
+		if (mmc->selected_mode == MMC_HS_400) {
+			clrbits_le32(&host->base->msdc_iocon,
+				     MSDC_IOCON_DSPL | MSDC_IOCON_W_DSPL);
+			clrsetbits_le32(&host->base->pad_tune,
+					MSDC_PAD_TUNE_DATRRDLY_M, 0);
+
+			writel(host->hs400_ds_delay, &host->base->pad_ds_tune);
+			/* for hs400 mode it must be set to 0 */
+			clrbits_le32(&host->base->patch_bit2,
+				     MSDC_PB2_CFGCRCSTS);
+			host->hs400_mode = true;
+		}
+		goto tune_done;
 	}
 
-	ret = msdc_tune_response(dev, opcode);
+	if (mmc->selected_mode == MMC_HS_400)
+		ret = hs400_tune_response(dev, opcode);
+	else
+		ret = msdc_tune_response(dev, opcode);
 	if (ret == -EIO) {
 		dev_err(dev, "Tune response fail!\n");
 		return ret;
 	}
 
-	if (!host->hs400_mode) {
+	if (mmc->selected_mode != MMC_HS_400) {
 		ret = msdc_tune_data(dev, opcode);
-		if (ret == -EIO)
+		if (ret == -EIO) {
 			dev_err(dev, "Tune data fail!\n");
+			return ret;
+		}
 	}
 
+tune_done:
 	host->saved_tune_para.iocon = readl(&host->base->msdc_iocon);
 	host->saved_tune_para.pad_tune = readl(&host->base->pad_tune);
+	host->saved_tune_para.pad_cmd_tune = readl(&host->base->pad_cmd_tune);
 
 	return ret;
 }
Signature · 1 line
2.23.0
#7 lore raw

PATCH v3 4/5 pinctrl: add driver for MT8518

In reply to mingming lee

Add Pinctrl driver for MediaTek MT8518 SoC.

---
 arch/arm/dts/mt8518.dtsi                  |   9 +-
 drivers/pinctrl/mediatek/Kconfig          |   4 +
 drivers/pinctrl/mediatek/Makefile         |   1 +
 drivers/pinctrl/mediatek/pinctrl-mt8518.c | 411 ++++++++++++++++++++++
 4 files changed, 424 insertions(+), 1 deletion(-)
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8518.c
arch/arm/dts/mt8518.dtsi +8 -1
index 9f56122319..c2d17fda4a 100644
@@ -65,7 +65,14 @@
 		reset-on-timeout;
 	};
 
-
+	pinctrl: pinctrl at 10005000 {
+		compatible = "mediatek,mt8518-pinctrl";
+		reg = <0x10005000 0x1000>;
+		gpio: gpio-controller {
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+	};
 
 	mmc0: mmc at 11120000 {
 		compatible = "mediatek,mt8516-mmc";
drivers/pinctrl/mediatek/Kconfig +4 -0
index 9930ca1faf..22ee62362b 100644
@@ -16,4 +16,8 @@ config PINCTRL_MT8516
 	bool "MT8516 SoC pinctrl driver"
 	select PINCTRL_MTK
 
+config PINCTRL_MT8518
+        bool "MT8518 SoC pinctrl driver"
+	select PINCTRL_MTK
+
 endif
drivers/pinctrl/mediatek/Makefile +1 -0
index c4f29088d2..0ab7b1595b 100644
@@ -6,3 +6,4 @@ obj-$(CONFIG_PINCTRL_MTK) += pinctrl-mtk-common.o
 obj-$(CONFIG_PINCTRL_MT7623) += pinctrl-mt7623.o
 obj-$(CONFIG_PINCTRL_MT7629) += pinctrl-mt7629.o
 obj-$(CONFIG_PINCTRL_MT8516) += pinctrl-mt8516.o
+obj-$(CONFIG_PINCTRL_MT8518) += pinctrl-mt8518.o
drivers/pinctrl/mediatek/pinctrl-mt8518.c new file +411 -0

411 lines not on this page · raw message

Signature · 1 line
2.23.0
#9 lore raw

PATCH v3 5/5 ARM: MediaTek: add basic support for MT8518 boards

In reply to mingming lee

This adds a general board file based on MT8518 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 MT8518 eMMC board.

---
Changes for v3:
- change hs400 to hs200 since the dts is hs200
- disable ENV in emmc

Changes for v2:
- print debug log using debug() api
- delete unnecessary configs and code
- change emmc hs200 to hs400 to speed up boot time

---
 arch/arm/dts/Makefile              |   3 +-
 arch/arm/dts/mt8518-ap1-emmc.dts   | 104 +++++++++++++++++++++++++++++
 arch/arm/mach-mediatek/Kconfig     |   1 +
 board/mediatek/mt8518/Kconfig      |  14 ++++
 board/mediatek/mt8518/MAINTAINERS  |   6 ++
 board/mediatek/mt8518/Makefile     |   3 +
 board/mediatek/mt8518/mt8518_ap1.c |  18 +++++
 configs/mt8518_ap1_emmc_defconfig  |  41 ++++++++++++
 include/configs/mt8518.h           |  68 +++++++++++++++++++
 9 files changed, 257 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/mt8518-ap1-emmc.dts
 create mode 100644 board/mediatek/mt8518/Kconfig
 create mode 100644 board/mediatek/mt8518/MAINTAINERS
 create mode 100644 board/mediatek/mt8518/Makefile
 create mode 100644 board/mediatek/mt8518/mt8518_ap1.c
 create mode 100644 configs/mt8518_ap1_emmc_defconfig
 create mode 100644 include/configs/mt8518.h
arch/arm/dts/Makefile +2 -1
index 251d32ca62..7071a7c1b9 100644
@@ -825,7 +825,8 @@ dtb-$(CONFIG_SOC_K3_J721E) += k3-j721e-common-proc-board.dtb \
 dtb-$(CONFIG_ARCH_MEDIATEK) += \
 	mt7623n-bananapi-bpi-r2.dtb \
 	mt7629-rfb.dtb \
-	mt8516-pumpkin.dtb
+	mt8516-pumpkin.dtb \
+	mt8518-ap1-emmc.dtb
 
 dtb-$(CONFIG_TARGET_GE_BX50V3) += imx6q-bx50v3.dtb
 dtb-$(CONFIG_TARGET_MX53PPD) += imx53-ppd.dtb
arch/arm/dts/mt8518-ap1-emmc.dts new file +104 -0

104 lines not on this page · raw message

arch/arm/mach-mediatek/Kconfig +1 -0
index 8e343c3182..ad453a60c1 100644
@@ -51,6 +51,7 @@ endchoice
 
 source "board/mediatek/mt7623/Kconfig"
 source "board/mediatek/mt7629/Kconfig"
+source "board/mediatek/mt8518/Kconfig"
 source "board/mediatek/pumpkin/Kconfig"
 
 endif
board/mediatek/mt8518/Kconfig new file +14 -0
new file mode 100644
index 0000000000..1971c4d8c3
@@ -0,0 +1,14 @@
+if TARGET_MT8518
+
+config SYS_BOARD
+	default "mt8518"
+
+config SYS_CONFIG_NAME
+	default "mt8518"
+
+
+config MTK_BROM_HEADER_INFO
+	string
+	default "media=nor"
+
+endif
board/mediatek/mt8518/MAINTAINERS new file +6 -0
new file mode 100644
index 0000000000..c9151947ad
@@ -0,0 +1,6 @@
+MT8518
+M:	Mingming lee <[email protected]>
+S:	Maintained
+F:	board/mediatek/mt8518
+F:	include/configs/mt8518.h
+F:	configs/mt8518_ap1_emmc_defconfig
board/mediatek/mt8518/Makefile new file +3 -0
new file mode 100644
index 0000000000..0884b32c56
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier:	GPL-2.0
+
+obj-y += mt8518_ap1.o
board/mediatek/mt8518/mt8518_ap1.c new file +18 -0
new file mode 100644
index 0000000000..9710907fe2
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2019 MediaTek Inc.
+ */
+
+#include <common.h>
+#include <dm.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int board_init(void)
+{
+	/* address of boot parameters */
+	gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
+
+	debug("gd->fdt_blob is %p\n", gd->fdt_blob);
+	return 0;
+}
configs/mt8518_ap1_emmc_defconfig new file +41 -0

41 lines not on this page · raw message

include/configs/mt8518.h new file +68 -0

68 lines not on this page · raw message

Signature · 1 line
2.23.0
#2 lore raw

PATCH v3 1/5 ARM: MediaTek: Add support for MediaTek MT8518 SoC

In reply to mingming lee
Quoted 4 lines · mingming lee

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

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20191203/6011a5bd/attachment.sig>
#4 lore raw

PATCH v3 2/5 clk: mediatek: add driver for MT8518

In reply to mingming lee
Quoted 3 lines · mingming lee

Add clock driver for MediaTek MT8518 SoC.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20191203/525013a4/attachment.sig>
#6 lore raw

PATCH v3 3/5 mmc: mtk-sd: Adjust the mmc tuning flow

In reply to mingming lee
Quoted 4 lines · mingming lee

1.Support cmd response and data tuning together.
2.Support hs400 cmd responese tuning.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20191203/344b9395/attachment.sig>
#8 lore raw

PATCH v3 4/5 pinctrl: add driver for MT8518

In reply to mingming lee
Quoted 3 lines · mingming lee

Add Pinctrl driver for MediaTek MT8518 SoC.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20191203/f548f777/attachment.sig>
#10 lore raw

PATCH v3 5/5 ARM: MediaTek: add basic support for MT8518 boards

In reply to mingming lee
Quoted 8 lines · mingming lee

This adds a general board file based on MT8518 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 MT8518 eMMC board.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20191203/1a48223e/attachment.sig>