Skip to contentSkip to conversation

mediatek: cumulative trivial fix for OF_UPSTREAM support

PATCH In review Christian Marangi 2 participants 16 messages Jun 24, 2024 – Jul 8, 2024

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

v4 cover mediatek: cumulative trivial fix for OF_UPSTREAM support

This is an initial series that have all the initial trivial fixes required for usage of OF_UPSTREAM for the mediatek SoC

This also contains the pcie-gen3 driver and the required tphy support driver to make it work.

Subsequent series will follow with conversion of the mtk-clk to permit usage of OF_UPSTREAM and upstream clk ID.

MT7981, MT7986 and MT7988 migration to upstream clock ID is complete and working on MT7623.

Series CI tested with PR [0]

[0] https://github.com/u-boot/u-boot/pull/590

Changes v4:
- Fix compilation error catched by Azure CI
- Rework serial with legacy platform
Changes v3:
- Fix copy paste error in gpio-controller (dev instead of parent)
- Rebase on top of next
Changes v2:
- Add mt7986 and mt7988 apmixed trivial PATCH
- Make phy for pcie optional (it is for mt7988)
- Fix broken mmc patch

Christian Marangi (13):
phy: phy-mtk-tphy: add support for phy type switch
spi: mtk_spim: add support for upstream mediatek,spi-ipm compatible
net: mediatek: handle alternative name for pn_swap property
i2c: mediatek: add support for optional arb and pmic clock
serial: mediatek: add support for bus clock and enable it
serial: mediatek: add special handling for highspeed and linux compat
mmc: mediatek: add support for upstream linux clock and property
clk: mediatek: mt7981: support alternative compatible for fixed-plls
pinctrl: mediatek: add support for gpio-controller property in root
node
pinctrl: mediatek: mt7981: init device before relocation
pci: mediatek: make pcie-phy optional for gen3
clk: mediatek: mt7988: support alternative compatible for fixed-plls
clk: mediatek: mt7986: support alternative compatible for fixed-plls

John Crispin (1):
pci: mediatek: add PCIe controller support for filogic silicon

 drivers/clk/mediatek/clk-mt7981.c             |   1 +
 drivers/clk/mediatek/clk-mt7986.c             |   1 +
 drivers/clk/mediatek/clk-mt7988.c             |   1 +
 drivers/i2c/mtk_i2c.c                         |  30 ++
 drivers/mmc/mtk-sd.c                          |  35 +-
 drivers/net/mtk_eth.c                         |   4 +-
 drivers/pci/Kconfig                           |   7 +
 drivers/pci/Makefile                          |   1 +
 drivers/pci/pcie_mediatek_gen3.c              | 384 ++++++++++++++++++
 drivers/phy/Kconfig                           |   2 +
 drivers/phy/phy-mtk-tphy.c                    |  80 ++++
 drivers/pinctrl/mediatek/pinctrl-mt7981.c     |   1 +
 drivers/pinctrl/mediatek/pinctrl-mtk-common.c |  10 +
 drivers/serial/serial_mtk.c                   |  20 +-
 drivers/spi/mtk_spim.c                        |  45 +-
 15 files changed, 614 insertions(+), 8 deletions(-)
 create mode 100644 drivers/pci/pcie_mediatek_gen3.c
Signature · 1 line
2.45.1
#1 lore raw

PATCH v4 1/14 phy: phy-mtk-tphy: add support for phy type switch

Add support for PHY type switch via the mediatek topmisc syscon.

This is needed on mt7981 to make the PCIe correctly work and display LinkUp.

Follow the same implementation done on Linux kernel with the usage of the mediatek,syscon-type property.

Example:

u3port0: usb-phy@11e10700 {
	reg = <0x11e10700 0x900>;
	clocks = <&topckgen CK_TOP_USB3_PHY_SEL>;
	clock-names = "ref";
	#phy-cells = <1>;
	mediatek,syscon-type = <&topmisc 0x218 0>;
	status = "okay";
};
---
 drivers/phy/Kconfig        |  2 +
 drivers/phy/phy-mtk-tphy.c | 80 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 82 insertions(+)
drivers/phy/Kconfig +2 -0
index 8f767877e73..e12347e8a03 100644
@@ -263,6 +263,8 @@ config PHY_MTK_TPHY
 	bool "MediaTek T-PHY Driver"
 	depends on PHY
 	depends on ARCH_MEDIATEK || SOC_MT7621
+	select REGMAP
+	select SYSCON
 	help
 	  MediaTek T-PHY driver supports usb2.0, usb3.0 ports, PCIe and
 	  SATA, and meanwhile supports two version T-PHY which have
drivers/phy/phy-mtk-tphy.c +80 -0

116 lines not on this page · raw message

Signature · 1 line
2.45.1
#2 lore raw

PATCH v4 2/14 pci: mediatek: add PCIe controller support for filogic silicon

In reply to Christian Marangi

From: John Crispin <[email protected]>

Add MediaTek GEN3 PCIe controller support for filogic silicon. This is adapted from the Linux version of the driver.

[ fix minor problems, fix checkpatch errors ]
---
 drivers/pci/Kconfig              |   7 +
 drivers/pci/Makefile             |   1 +
 drivers/pci/pcie_mediatek_gen3.c | 382 +++++++++++++++++++++++++++++++
 3 files changed, 390 insertions(+)
 create mode 100644 drivers/pci/pcie_mediatek_gen3.c
drivers/pci/Kconfig +7 -0
index 8d02ab82ad9..22a56f4ca38 100644
@@ -350,6 +350,13 @@ config PCIE_MEDIATEK
 	  Say Y here if you want to enable Gen2 PCIe controller,
 	  which could be found on MT7623 SoC family.
 
+config PCIE_MEDIATEK_GEN3
+	bool "MediaTek PCIe Gen3 controller"
+	depends on ARCH_MEDIATEK
+	help
+	  Say Y here if you want to enable Gen3 PCIe controller,
+	  which could be found on the Mediatek Filogic SoC family.
+
 config PCIE_DW_MESON
 	bool "Amlogic Meson DesignWare based PCIe controller"
 	depends on ARCH_MESON
drivers/pci/Makefile +1 -0
index 2927c519129..5b2d2969802 100644
@@ -42,6 +42,7 @@ obj-$(CONFIG_PCIE_INTEL_FPGA) += pcie_intel_fpga.o
 obj-$(CONFIG_PCIE_DW_COMMON) += pcie_dw_common.o
 obj-$(CONFIG_PCI_KEYSTONE) += pcie_dw_ti.o
 obj-$(CONFIG_PCIE_MEDIATEK) += pcie_mediatek.o
+obj-$(CONFIG_PCIE_MEDIATEK_GEN3) += pcie_mediatek_gen3.o
 obj-$(CONFIG_PCIE_ROCKCHIP) += pcie_rockchip.o
 obj-$(CONFIG_PCIE_DW_ROCKCHIP) += pcie_dw_rockchip.o
 obj-$(CONFIG_PCIE_DW_MESON) += pcie_dw_meson.o
drivers/pci/pcie_mediatek_gen3.c new file +382 -0

382 lines not on this page · raw message

Signature · 1 line
2.45.1
#3 lore raw

PATCH v4 3/14 spi: mtk_spim: add support for upstream mediatek, spi-ipm compatible

In reply to Christian Marangi

Upstream kernel linux use a different compatible mediatek,spi-ipm.

Add support for this compatible and add handling for the additional clock similar to how it's done by the upstream driver and handling for all the property enabled by default.

---
 drivers/spi/mtk_spim.c | 45 ++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 43 insertions(+), 2 deletions(-)
drivers/spi/mtk_spim.c +43 -2
index 90f4c3cecb9..b360eca2b91 100644
@@ -137,6 +137,8 @@ struct mtk_spim_capability {
  * @state:		Controller state
  * @sel_clk:		Pad clock
  * @spi_clk:		Core clock
+ * @parent_clk:		Parent clock (needed for mediatek,spi-ipm, upstream DTSI)
+ * @hclk:		HCLK clock (needed for mediatek,spi-ipm, upstream DTSI)
  * @pll_clk_rate:	Controller's PLL source clock rate, which is different
  *			from SPI bus clock rate
  * @xfer_len:		Current length of data for transfer
@@ -151,6 +153,7 @@ struct mtk_spim_priv {
 	void __iomem *base;
 	u32 state;
 	struct clk sel_clk, spi_clk;
+	struct clk parent_clk, hclk;
 	u32 pll_clk_rate;
 	u32 xfer_len;
 	struct mtk_spim_capability hw_cap;
@@ -650,7 +653,21 @@ static int mtk_spim_probe(struct udevice *dev)
 	if (!priv->base)
 		return -EINVAL;
 
-	mtk_spim_get_attr(priv, dev);
+	/*
+	 * Upstream linux driver for ipm design enable all the modes
+	 * and setup the calibrarion values directly in the driver with
+	 * standard values.
+	 */
+	if (device_is_compatible(dev, "mediatek,spi-ipm")) {
+		priv->hw_cap.enhance_timing = true;
+		priv->hw_cap.dma_ext = true;
+		priv->hw_cap.ipm_design = true;
+		priv->hw_cap.support_quad = true;
+		priv->sample_sel = 0;
+		priv->tick_dly = 2;
+	} else {
+		mtk_spim_get_attr(priv, dev);
+	}
 
 	ret = clk_get_by_name(dev, "sel-clk", &priv->sel_clk);
 	if (ret < 0) {
@@ -664,8 +681,31 @@ static int mtk_spim_probe(struct udevice *dev)
 		return ret;
 	}
 
-	clk_enable(&priv->sel_clk);
+	/*
+	 * Upstream DTSI use a different compatible that provide additional
+	 * clock instead of the assigned-clock implementation.
+	 */
+	if (device_is_compatible(dev, "mediatek,spi-ipm")) {
+		ret = clk_get_by_name(dev, "parent-clk", &priv->parent_clk);
+		if (ret < 0) {
+			dev_err(dev, "failed to get parent-clk\n");
+			return ret;
+		}
+
+		ret = clk_get_by_name(dev, "hclk", &priv->hclk);
+		if (ret < 0) {
+			dev_err(dev, "failed to get hclk\n");
+			return ret;
+		}
+
+		clk_enable(&priv->parent_clk);
+		clk_set_parent(&priv->sel_clk, &priv->parent_clk);
+
+		clk_enable(&priv->hclk);
+	}
+
 	clk_enable(&priv->spi_clk);
+	clk_enable(&priv->sel_clk);
 
 	priv->pll_clk_rate = clk_get_rate(&priv->spi_clk);
 	if (priv->pll_clk_rate == 0)
@@ -698,6 +738,7 @@ static const struct dm_spi_ops mtk_spim_ops = {
 
 static const struct udevice_id mtk_spim_ids[] = {
 	{ .compatible = "mediatek,ipm-spi" },
+	{ .compatible = "mediatek,spi-ipm", },
 	{}
 };
 
Signature · 1 line
2.45.1
#4 lore raw

PATCH v4 4/14 net: mediatek: handle alternative name for pn_swap property

In reply to Christian Marangi

Handle alternative name for pn_swap property as upstream linux use mediatek,pnswap.

---
 drivers/net/mtk_eth.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/mtk_eth.c +3 -1
index 94f17a97fe0..5098afef8a8 100644
@@ -1964,7 +1964,9 @@ static int mtk_eth_of_to_plat(struct udevice *dev)
 			return -ENODEV;
 		}
 
-		priv->pn_swap = ofnode_read_bool(args.node, "pn_swap");
+		/* Upstream linux use mediatek,pnswap instead of pn_swap */
+		priv->pn_swap = ofnode_read_bool(args.node, "pn_swap") ||
+				ofnode_read_bool(args.node, "mediatek,pnswap");
 	} else if (priv->phy_interface == PHY_INTERFACE_MODE_USXGMII) {
 		/* get corresponding usxgmii phandle */
 		ret = dev_read_phandle_with_args(dev, "mediatek,usxgmiisys",
Signature · 1 line
2.45.1
#5 lore raw

PATCH v4 5/14 i2c: mediatek: add support for optional arb and pmic clock

In reply to Christian Marangi

Add support for optional arb and pmic clock for i2c provided in upstream linux DTSI.

---
 drivers/i2c/mtk_i2c.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
drivers/i2c/mtk_i2c.c +30 -0
index 5592fe91817..3450177741a 100644
@@ -221,6 +221,8 @@ struct mtk_i2c_priv {
 	void __iomem *pdmabase;		/* dma base address*/
 	struct clk clk_main;		/* main clock for i2c bus */
 	struct clk clk_dma;		/* DMA clock for i2c via DMA */
+	struct clk clk_arb;		/* DMA clock for i2c ARB */
+	struct clk clk_pmic;		/* DMA clock for i2c PMIC */
 	const struct mtk_i2c_soc_data *soc_data; /* Compatible data for different IC */
 	int op;				/* operation mode */
 	bool zero_len;			/* Only transfer slave address, no data */
@@ -255,6 +257,18 @@ static int mtk_i2c_clk_enable(struct mtk_i2c_priv *priv)
 	if (ret)
 		return log_msg_ret("enable clk_dma", ret);
 
+	if (priv->clk_arb.dev) {
+		ret = clk_enable(&priv->clk_arb);
+		if (ret)
+			return log_msg_ret("enable clk_arb", ret);
+	}
+
+	if (priv->clk_pmic.dev) {
+		ret = clk_enable(&priv->clk_pmic);
+		if (ret)
+			return log_msg_ret("enable clk_pmic", ret);
+	}
+
 	return 0;
 }
 
@@ -262,6 +276,18 @@ static int mtk_i2c_clk_disable(struct mtk_i2c_priv *priv)
 {
 	int ret;
 
+	if (priv->clk_pmic.dev) {
+		ret = clk_disable(&priv->clk_pmic);
+		if (ret)
+			return log_msg_ret("disable clk_pmic", ret);
+	}
+
+	if (priv->clk_arb.dev) {
+		ret = clk_disable(&priv->clk_arb);
+		if (ret)
+			return log_msg_ret("disable clk_arb", ret);
+	}
+
 	ret = clk_disable(&priv->clk_dma);
 	if (ret)
 		return log_msg_ret("disable clk_dma", ret);
@@ -748,6 +774,10 @@ static int mtk_i2c_of_to_plat(struct udevice *dev)
 
 	ret = clk_get_by_index(dev, 1, &priv->clk_dma);
 
+	/* optional i2c clock */
+	clk_get_by_name(dev, "arb", &priv->clk_arb);
+	clk_get_by_name(dev, "pmic", &priv->clk_pmic);
+
 	return ret;
 }
 
Signature · 1 line
2.45.1
#6 lore raw

PATCH v4 6/14 serial: mediatek: add support for bus clock and enable it

In reply to Christian Marangi

Upstream linux also provide the additional optional bus clock.

Add support for it and also enable the baud and bus clock on probe.

---
 drivers/serial/serial_mtk.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/serial/serial_mtk.c +8 -0
index 3f569c68f22..78e8d9dc735 100644
@@ -76,6 +76,7 @@ struct mtk_serial_regs {
  *				driver
  * @regs:			Register base of the serial port
  * @clk:			The baud clock device
+ * @clk_bus:			The bus clock device
  * @fixed_clk_rate:		Fallback fixed baud clock rate if baud clock
  *				device is not specified
  * @force_highspeed:		Force using high-speed mode
@@ -83,6 +84,7 @@ struct mtk_serial_regs {
 struct mtk_serial_priv {
 	struct mtk_serial_regs __iomem *regs;
 	struct clk clk;
+	struct clk clk_bus;
 	u32 fixed_clk_rate;
 	bool force_highspeed;
 };
@@ -220,6 +222,10 @@ static int mtk_serial_probe(struct udevice *dev)
 	writel(UART_MCRVAL, &priv->regs->mcr);
 	writel(UART_FCRVAL, &priv->regs->fcr);
 
+	clk_enable(&priv->clk);
+	if (priv->clk_bus.dev)
+		clk_enable(&priv->clk_bus);
+
 	return 0;
 }
 
@@ -250,6 +256,8 @@ static int mtk_serial_of_to_plat(struct udevice *dev)
 		}
 	}
 
+	clk_get_by_name(dev, "bus", &priv->clk_bus);
+
 	priv->force_highspeed = dev_read_bool(dev, "mediatek,force-highspeed");
 
 	return 0;
Signature · 1 line
2.45.1
#7 lore raw

PATCH v4 7/14 serial: mediatek: add special handling for highspeed and linux compat

In reply to Christian Marangi

Upstream linux serial driver use a different logic to setup serial regs.

They have 2 interval:
- < 115200 we use lowspeed regs and 16 * baud
- >= 115200 we use highspeed

We currently use force_highspeed property to force usage of highspeed regs even with low baud rate.

Add special handling if the upstream compatible is used where we just apply the same interval with anything >= 115200 in highspeed simulating force_highspeed.

---
 drivers/serial/serial_mtk.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/serial/serial_mtk.c +11 -1
index 78e8d9dc735..becf9317076 100644
@@ -10,6 +10,7 @@
 #include <config.h>
 #include <div64.h>
 #include <dm.h>
+#include <dm/device.h>
 #include <dm/device_compat.h>
 #include <errno.h>
 #include <log.h>
@@ -80,6 +81,7 @@ struct mtk_serial_regs {
  * @fixed_clk_rate:		Fallback fixed baud clock rate if baud clock
  *				device is not specified
  * @force_highspeed:		Force using high-speed mode
+ * @upstream_highspeed_logic:	Apply upstream high-speed logic
  */
 struct mtk_serial_priv {
 	struct mtk_serial_regs __iomem *regs;
@@ -87,6 +89,7 @@ struct mtk_serial_priv {
 	struct clk clk_bus;
 	u32 fixed_clk_rate;
 	bool force_highspeed;
+	bool upstream_highspeed_logic;
 };
 
 static void _mtk_serial_setbrg(struct mtk_serial_priv *priv, int baud,
@@ -113,7 +116,12 @@ static void _mtk_serial_setbrg(struct mtk_serial_priv *priv, int baud,
 		goto set_baud;
 	}
 
-	if (priv->force_highspeed)
+	/*
+	 * Upstream linux use highspeed for anything >= 115200 and lowspeed
+	 * for < 115200. Simulate this if we are using the upstream compatible.
+	 */
+	if (priv->force_highspeed ||
+	    (priv->upstream_highspeed_logic && baud >= 115200))
 		goto use_hs3;
 
 	if (baud <= 115200) {
@@ -259,6 +267,8 @@ static int mtk_serial_of_to_plat(struct udevice *dev)
 	clk_get_by_name(dev, "bus", &priv->clk_bus);
 
 	priv->force_highspeed = dev_read_bool(dev, "mediatek,force-highspeed");
+	priv->upstream_highspeed_logic =
+		device_is_compatible(dev, "mediatek,mt6577-uart");
 
 	return 0;
 }
Signature · 1 line
2.45.1
#8 lore raw

PATCH v4 8/14 mmc: mediatek: add support for upstream linux clock and property

In reply to Christian Marangi

Add support for upstream linux clock and map U-Boot property to the one use in upstream linux where supported.

Also add handling for the use_internal_cd that on upstream is hardcoded enabled on mt7620.

---
 drivers/mmc/mtk-sd.c | 35 +++++++++++++++++++++++++++++++----
 1 file changed, 31 insertions(+), 4 deletions(-)
drivers/mmc/mtk-sd.c +31 -4
index 3a9258255a7..ebd72178b59 100644
@@ -335,6 +335,7 @@ struct msdc_compatible {
 	bool enhance_rx;
 	bool builtin_pad_ctrl;
 	bool default_pad_dly;
+	bool use_internal_cd;
 };
 
 struct msdc_delay_phase {
@@ -365,6 +366,10 @@ struct msdc_host {
 	struct clk src_clk_cg;	/* optional, MSDC source clock control gate */
 	struct clk h_clk;	/* MSDC core clock */
 
+	/* upstream linux clock */
+	struct clk axi_cg_clk;	/* optional, AXI clock */
+	struct clk ahb_cg_clk;	/* optional, AHB clock */
+
 	u32 src_clk_freq;	/* source clock */
 	u32 mclk;		/* mmc framework required bus clock */
 	u32 sclk;		/* actual calculated bus clock */
@@ -1637,6 +1642,11 @@ static void msdc_ungate_clock(struct msdc_host *host)
 	clk_enable(&host->h_clk);
 	if (host->src_clk_cg.dev)
 		clk_enable(&host->src_clk_cg);
+
+	if (host->axi_cg_clk.dev)
+		clk_enable(&host->axi_cg_clk);
+	if (host->ahb_cg_clk.dev)
+		clk_enable(&host->ahb_cg_clk);
 }
 
 static int msdc_drv_probe(struct udevice *dev)
@@ -1650,6 +1660,9 @@ static int msdc_drv_probe(struct udevice *dev)
 
 	host->dev_comp = (struct msdc_compatible *)dev_get_driver_data(dev);
 
+	if (host->dev_comp->use_internal_cd)
+		host->builtin_cd = 1;
+
 	host->src_clk_freq = clk_get_rate(&host->src_clk);
 
 	if (host->dev_comp->clk_div_bits == 8)
@@ -1715,18 +1728,31 @@ static int msdc_of_to_plat(struct udevice *dev)
 
 	clk_get_by_name(dev, "source_cg", &host->src_clk_cg); /* optional */
 
+	/* upstream linux clock */
+	clk_get_by_name(dev, "axi_cg", &host->axi_cg_clk); /* optional */
+	clk_get_by_name(dev, "ahb_cg", &host->ahb_cg_clk); /* optional */
+
 #if CONFIG_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);
 #endif
 
 	host->hs400_ds_delay = dev_read_u32_default(dev, "hs400-ds-delay", 0);
-	host->hs200_cmd_int_delay =
-			dev_read_u32_default(dev, "cmd_int_delay", 0);
+	if (dev_read_u32(dev, "mediatek,hs200-cmd-int-delay",
+			 &host->hs200_cmd_int_delay))
+		host->hs200_cmd_int_delay =
+				dev_read_u32_default(dev, "cmd_int_delay", 0);
+
 	host->hs200_write_int_delay =
 			dev_read_u32_default(dev, "write_int_delay", 0);
-	host->latch_ck = dev_read_u32_default(dev, "latch-ck", 0);
+
+	if (dev_read_u32(dev, "mediatek,latch-ck", &host->latch_ck))
+		host->latch_ck = dev_read_u32_default(dev, "latch-ck", 0);
+
 	host->r_smpl = dev_read_u32_default(dev, "r_smpl", 0);
+	if (dev_read_bool(dev, "mediatek,hs400-cmd-resp-sel-rising"))
+		host->r_smpl = 1;
+
 	host->builtin_cd = dev_read_u32_default(dev, "builtin-cd", 0);
 	host->cd_active_high = dev_read_bool(dev, "cd-active-high");
 
@@ -1775,6 +1801,7 @@ static const struct msdc_compatible mt7620_compat = {
 	.enhance_rx = false,
 	.builtin_pad_ctrl = true,
 	.default_pad_dly = true,
+	.use_internal_cd = true,
 };
 
 static const struct msdc_compatible mt7621_compat = {
@@ -1805,7 +1832,7 @@ static const struct msdc_compatible mt7623_compat = {
 	.data_tune = true,
 	.busy_check = false,
 	.stop_clk_fix = false,
-	.enhance_rx = false
+	.enhance_rx = false,
 };
 
 static const struct msdc_compatible mt7986_compat = {
Signature · 1 line
2.45.1
#9 lore raw

PATCH v4 9/14 clk: mediatek: mt7981: support alternative compatible for fixed-plls

In reply to Christian Marangi

Support alternative compatible for fixed-plls clocks used upstream with the compatible mediatek,mt7981-apmixedsys.

---
 drivers/clk/mediatek/clk-mt7981.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/mediatek/clk-mt7981.c +1 -0
index 7fcb81419cd..13dc3df0e9e 100644
@@ -543,6 +543,7 @@ static const struct mtk_clk_tree mt7981_infracfg_clk_tree = {
 
 static const struct udevice_id mt7981_fixed_pll_compat[] = {
 	{ .compatible = "mediatek,mt7981-fixed-plls" },
+	{ .compatible = "mediatek,mt7981-apmixedsys" },
 	{}
 };
 
Signature · 1 line
2.45.1
#10 lore raw

PATCH v4 10/14 pinctrl: mediatek: add support for gpio-controller property in root node

In reply to Christian Marangi

Add support for gpio-controller property in root pinctrl node. This is to follow upstream linux DTSI that doesn't define the gpio-controller and cells in dedicated nodes.

---
 drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/pinctrl/mediatek/pinctrl-mtk-common.c +10 -0
index 37fc28bb779..ede3959c94f 100644
@@ -761,6 +761,15 @@ static int mtk_gpiochip_register(struct udevice *parent)
 	if (!drv)
 		return -ENOENT;
 
+	/*
+	 * Support upstream linux DTSI that define gpio-controller
+	 * in the root node (instead of a dedicated subnode)
+	 */
+	if (dev_read_bool(parent, "gpio-controller")) {
+		node = dev_ofnode(parent);
+		goto bind;
+	}
+
 	ret = -ENOENT;
 	dev_for_each_subnode(node, parent)
 		if (ofnode_read_bool(node, "gpio-controller")) {
@@ -771,6 +780,7 @@ static int mtk_gpiochip_register(struct udevice *parent)
 	if (ret)
 		return ret;
 
+bind:
 	ret = device_bind_with_driver_data(parent, &mtk_gpio_driver,
 					   "mediatek_gpio", 0, node,
 					   &dev);
Signature · 1 line
2.45.1
#11 lore raw

PATCH v4 11/14 pinctrl: mediatek: mt7981: init device before relocation

In reply to Christian Marangi

Upstream kernel linux define pinctrl for uart0, hence this pin group and pinctrl driver is needed before relocation. Add DM_FLAG_PRE_RELOC flag to init and mute mtk_serial error on early serial init.

---
 drivers/pinctrl/mediatek/pinctrl-mt7981.c | 1 +
 1 file changed, 1 insertion(+)
drivers/pinctrl/mediatek/pinctrl-mt7981.c +1 -0
index 3fa198ed79c..4bc4abe6518 100644
@@ -1050,4 +1050,5 @@ U_BOOT_DRIVER(mt7981_pinctrl) = {
 	.ops = &mtk_pinctrl_ops,
 	.probe = mtk_pinctrl_mt7981_probe,
 	.priv_auto = sizeof(struct mtk_pinctrl_priv),
+	.flags = DM_FLAG_PRE_RELOC,
 };
Signature · 1 line
2.45.1
#12 lore raw

PATCH v4 12/14 pci: mediatek: make pcie-phy optional for gen3

In reply to Christian Marangi

Set pcie-phy optional for PCIe gen3. MT7988 doesn't require it and making it mandatory prevent the driver to correctly probe.

---
 drivers/pci/pcie_mediatek_gen3.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/pci/pcie_mediatek_gen3.c +12 -10
index 673813b8b75..0149edae0bf 100644
@@ -284,9 +284,8 @@ static int mtk_pcie_power_on(struct udevice *dev)
 
 	pcie->priv = dev;
 
-	err = generic_phy_get_by_name(dev, "pcie-phy", &pcie->phy);
-	if (err)
-		return err;
+	/* pcie-phy is optional (mt7988 doesn't need it) */
+	generic_phy_get_by_name(dev, "pcie-phy", &pcie->phy);
 
 	/*
 	 * Upstream linux kernel devine these clock without clock-names
@@ -308,13 +307,15 @@ static int mtk_pcie_power_on(struct udevice *dev)
 	if (err)
 		return err;
 
-	err = generic_phy_init(&pcie->phy);
-	if (err)
-		return err;
+	if (pcie->phy.dev) {
+		err = generic_phy_init(&pcie->phy);
+		if (err)
+			return err;
 
-	err = generic_phy_power_on(&pcie->phy);
-	if (err)
-		goto err_phy_on;
+		err = generic_phy_power_on(&pcie->phy);
+		if (err)
+			goto err_phy_on;
+	}
 
 	err = clk_enable(&pcie->pl_250m_ck);
 	if (err)
@@ -348,7 +349,8 @@ err_clk_tl_26m:
 err_clk_pl_250m:
 	clk_disable(&pcie->pl_250m_ck);
 err_phy_on:
-	generic_phy_exit(&pcie->phy);
+	if (pcie->phy.dev)
+		generic_phy_exit(&pcie->phy);
 
 	return err;
 }
Signature · 1 line
2.45.1
#13 lore raw

PATCH v4 13/14 clk: mediatek: mt7988: support alternative compatible for fixed-plls

In reply to Christian Marangi

Support alternative compatible for fixed-plls clocks used upstream with the compatible mediatek,mt7988-apmixedsys.

---
 drivers/clk/mediatek/clk-mt7988.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/mediatek/clk-mt7988.c +1 -0
index 34e7b2d734c..32b04511781 100644
@@ -833,6 +833,7 @@ static const struct mtk_clk_tree mt7988_infracfg_clk_tree = {
 
 static const struct udevice_id mt7988_fixed_pll_compat[] = {
 	{ .compatible = "mediatek,mt7988-fixed-plls" },
+	{ .compatible = "mediatek,mt7988-apmixedsys" },
 	{}
 };
 
Signature · 1 line
2.45.1
#14 lore raw

PATCH v4 14/14 clk: mediatek: mt7986: support alternative compatible for fixed-plls

In reply to Christian Marangi

Support alternative compatible for fixed-plls clocks used upstream with the compatible mediatek,mt7986-apmixedsys.

---
 drivers/clk/mediatek/clk-mt7986.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/mediatek/clk-mt7986.c +1 -0
index b3fa63fc0ab..efc3d4120b7 100644
@@ -533,6 +533,7 @@ static const struct mtk_clk_tree mt7986_infracfg_clk_tree = {
 
 static const struct udevice_id mt7986_fixed_pll_compat[] = {
 	{ .compatible = "mediatek,mt7986-fixed-plls" },
+	{ .compatible = "mediatek,mt7986-apmixedsys" },
 	{}
 };
 
Signature · 1 line
2.45.1
#15 lore raw
In reply to Christian Marangi
Quoted 10 lines · Christian Marangi

This is an initial series that have all the initial trivial fixes required for usage of OF_UPSTREAM for the mediatek SoC

This also contains the pcie-gen3 driver and the required tphy support driver to make it work.

Subsequent series will follow with conversion of the mtk-clk to permit usage of OF_UPSTREAM and upstream clk ID.

[...]

Applied to u-boot/master, thanks!

Signature · 1 line
Tom