* [PATCH v1 0/3] mediatek-gen3: Add support for MT8196/MT6991
@ 2025-06-23 12:00 AngeloGioacchino Del Regno
2025-06-23 12:00 ` [PATCH v1 1/3] PCI: mediatek-gen3: Implement sys clock ready time setting AngeloGioacchino Del Regno
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-06-23 12:00 UTC (permalink / raw)
To: jianjun.wang
Cc: ryder.lee, bhelgaas, lpieralisi, kwilczynski,
manivannan.sadhasivam, robh, krzk+dt, conor+dt, matthias.bgg,
angelogioacchino.delregno, linux-pci, linux-mediatek, devicetree,
linux-kernel, linux-arm-kernel, kernel
This series adds (at least partial) support for the MediaTek MT8196
Chromebook SoC and for the MT6991 Dimensity 9400 Smartphone SoC's
PCI-Express controller.
Some strange PEXTP settings were omitted, as the intention is to find
a way to set those bits *outside* of the PCI-Express driver itself as
the downstream implementation is using ugly syscons to make the PCIe
controller driver to change bits inside of a clock controller.
In the meanwhile, this is a set of clean changes that are required for
the controller inside those SoCs in *any* case; further development
will occur, with high hopes to find a solution outside of this driver.
AngeloGioacchino Del Regno (3):
PCI: mediatek-gen3: Implement sys clock ready time setting
dt-bindings: PCI: mediatek-gen3: Add support for MT6991/MT8196
PCI: mediatek-gen3: Add support for MediaTek MT8196 SoC
.../bindings/pci/mediatek-pcie-gen3.yaml | 35 +++++++++++++++++++
drivers/pci/controller/pcie-mediatek-gen3.c | 24 +++++++++++++
2 files changed, 59 insertions(+)
--
2.49.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v1 1/3] PCI: mediatek-gen3: Implement sys clock ready time setting
2025-06-23 12:00 [PATCH v1 0/3] mediatek-gen3: Add support for MT8196/MT6991 AngeloGioacchino Del Regno
@ 2025-06-23 12:00 ` AngeloGioacchino Del Regno
2025-06-23 12:00 ` [PATCH v1 2/3] dt-bindings: PCI: mediatek-gen3: Add support for MT6991/MT8196 AngeloGioacchino Del Regno
2025-06-23 12:00 ` [PATCH v1 3/3] PCI: mediatek-gen3: Add support for MediaTek MT8196 SoC AngeloGioacchino Del Regno
2 siblings, 0 replies; 5+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-06-23 12:00 UTC (permalink / raw)
To: jianjun.wang
Cc: ryder.lee, bhelgaas, lpieralisi, kwilczynski,
manivannan.sadhasivam, robh, krzk+dt, conor+dt, matthias.bgg,
angelogioacchino.delregno, linux-pci, linux-mediatek, devicetree,
linux-kernel, linux-arm-kernel, kernel
In preparation to add support for the PCI-Express Gen3 controller
found in newer MediaTek SoCs, such as the Dimensity 9400 MT6991
and the MT8196 Chromebook SoC, add the definition for the PCIE
Resource Control register and a new sys_clk_rdy_time_us variable
in platform data.
If sys_clk_rdy_time_us is found (> 0), set the new value in the
aforementioned register only after configuring the controller to
RC mode, as this may otherwise be reset.
Overriding the register defaults for SYS_CLK_RDY_TIME allows to
work around sys_clk_rdy signal glitching in MT6991 and MT8196.
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
drivers/pci/controller/pcie-mediatek-gen3.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
index b55f5973414c..00c9f2532870 100644
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
@@ -101,6 +101,9 @@
#define PCIE_MSI_SET_ADDR_HI_BASE 0xc80
#define PCIE_MSI_SET_ADDR_HI_OFFSET 0x04
+#define PCIE_RESOURCE_CTRL_REG 0xd2c
+#define PCIE_RSRC_SYS_CLK_RDY_TIME_MASK GENMASK(7, 0)
+
#define PCIE_ICMD_PM_REG 0x198
#define PCIE_TURN_OFF_LINK BIT(4)
@@ -148,6 +151,7 @@ enum mtk_gen3_pcie_flags {
* struct mtk_gen3_pcie_pdata - differentiate between host generations
* @power_up: pcie power_up callback
* @phy_resets: phy reset lines SoC data.
+ * @sys_clk_rdy_time_us: System clock ready time override (microseconds)
* @flags: pcie device flags.
*/
struct mtk_gen3_pcie_pdata {
@@ -156,6 +160,7 @@ struct mtk_gen3_pcie_pdata {
const char *id[MAX_NUM_PHY_RESETS];
int num_resets;
} phy_resets;
+ u8 sys_clk_rdy_time_us;
u32 flags;
};
@@ -436,6 +441,15 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie)
writel_relaxed(val, pcie->base + PCIE_CONF_LINK2_CTL_STS);
}
+ /* If parameter is present, adjust SYS_CLK_RDY_TIME to avoid glitching */
+ if (pcie->soc->sys_clk_rdy_time_us) {
+ val = readl_relaxed(pcie->base + PCIE_RESOURCE_CTRL_REG);
+ val &= ~PCIE_RSRC_SYS_CLK_RDY_TIME_MASK;
+ val |= FIELD_PREP(PCIE_RSRC_SYS_CLK_RDY_TIME_MASK,
+ pcie->soc->sys_clk_rdy_time_us);
+ writel_relaxed(val, pcie->base + PCIE_RESOURCE_CTRL_REG);
+ }
+
/* Set class code */
val = readl_relaxed(pcie->base + PCIE_PCI_IDS_1);
val &= ~GENMASK(31, 8);
--
2.49.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v1 2/3] dt-bindings: PCI: mediatek-gen3: Add support for MT6991/MT8196
2025-06-23 12:00 [PATCH v1 0/3] mediatek-gen3: Add support for MT8196/MT6991 AngeloGioacchino Del Regno
2025-06-23 12:00 ` [PATCH v1 1/3] PCI: mediatek-gen3: Implement sys clock ready time setting AngeloGioacchino Del Regno
@ 2025-06-23 12:00 ` AngeloGioacchino Del Regno
2025-06-27 20:11 ` Rob Herring
2025-06-23 12:00 ` [PATCH v1 3/3] PCI: mediatek-gen3: Add support for MediaTek MT8196 SoC AngeloGioacchino Del Regno
2 siblings, 1 reply; 5+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-06-23 12:00 UTC (permalink / raw)
To: jianjun.wang
Cc: ryder.lee, bhelgaas, lpieralisi, kwilczynski,
manivannan.sadhasivam, robh, krzk+dt, conor+dt, matthias.bgg,
angelogioacchino.delregno, linux-pci, linux-mediatek, devicetree,
linux-kernel, linux-arm-kernel, kernel
Add compatible strings for MT8196 and MT6991 (which are fully
compatible between each other) and clock definitions.
These new SoCs don't have tl_96m and tl_32k clocks, but need
an AHB to APB bus clock and a low power clock.
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
.../bindings/pci/mediatek-pcie-gen3.yaml | 35 +++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml b/Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml
index 162406e0691a..02cddf0246ce 100644
--- a/Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml
+++ b/Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml
@@ -52,7 +52,12 @@ properties:
- mediatek,mt8188-pcie
- mediatek,mt8195-pcie
- const: mediatek,mt8192-pcie
+ - items:
+ - enum:
+ - mediatek,mt6991-pcie
+ - const: mediatek,mt8196-pcie
- const: mediatek,mt8192-pcie
+ - const: mediatek,mt8196-pcie
- const: airoha,en7581-pcie
reg:
@@ -212,6 +217,36 @@ allOf:
mediatek,pbus-csr: false
+ - if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - mediatek,mt8196-pcie
+ then:
+ properties:
+ clocks:
+ minItems: 6
+
+ clock-names:
+ items:
+ - const: pl_250m
+ - const: tl_26m
+ - const: bus
+ - const: low_power
+ - const: peri_26m
+ - const: peri_mem
+
+ resets:
+ minItems: 1
+ maxItems: 2
+
+ reset-names:
+ minItems: 1
+ maxItems: 2
+
+ mediatek,pbus-csr: false
+
- if:
properties:
compatible:
--
2.49.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v1 3/3] PCI: mediatek-gen3: Add support for MediaTek MT8196 SoC
2025-06-23 12:00 [PATCH v1 0/3] mediatek-gen3: Add support for MT8196/MT6991 AngeloGioacchino Del Regno
2025-06-23 12:00 ` [PATCH v1 1/3] PCI: mediatek-gen3: Implement sys clock ready time setting AngeloGioacchino Del Regno
2025-06-23 12:00 ` [PATCH v1 2/3] dt-bindings: PCI: mediatek-gen3: Add support for MT6991/MT8196 AngeloGioacchino Del Regno
@ 2025-06-23 12:00 ` AngeloGioacchino Del Regno
2 siblings, 0 replies; 5+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-06-23 12:00 UTC (permalink / raw)
To: jianjun.wang
Cc: ryder.lee, bhelgaas, lpieralisi, kwilczynski,
manivannan.sadhasivam, robh, krzk+dt, conor+dt, matthias.bgg,
angelogioacchino.delregno, linux-pci, linux-mediatek, devicetree,
linux-kernel, linux-arm-kernel, kernel
Introduce support for the PCI-Express Gen3 controller found in the
MT8196 (and MT6991) SoC by adding a compatible string and platform
specific data.
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
drivers/pci/controller/pcie-mediatek-gen3.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
index 00c9f2532870..43b99779274f 100644
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
@@ -1359,6 +1359,15 @@ static const struct mtk_gen3_pcie_pdata mtk_pcie_soc_mt8192 = {
},
};
+static const struct mtk_gen3_pcie_pdata mtk_pcie_soc_mt8196 = {
+ .power_up = mtk_pcie_power_up,
+ .phy_resets = {
+ .id[0] = "phy",
+ .num_resets = 1,
+ },
+ .sys_clk_rdy_time_us = 10,
+};
+
static const struct mtk_gen3_pcie_pdata mtk_pcie_soc_en7581 = {
.power_up = mtk_pcie_en7581_power_up,
.phy_resets = {
@@ -1373,6 +1382,7 @@ static const struct mtk_gen3_pcie_pdata mtk_pcie_soc_en7581 = {
static const struct of_device_id mtk_pcie_of_match[] = {
{ .compatible = "airoha,en7581-pcie", .data = &mtk_pcie_soc_en7581 },
{ .compatible = "mediatek,mt8192-pcie", .data = &mtk_pcie_soc_mt8192 },
+ { .compatible = "mediatek,mt8196-pcie", .data = &mtk_pcie_soc_mt8196 },
{},
};
MODULE_DEVICE_TABLE(of, mtk_pcie_of_match);
--
2.49.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v1 2/3] dt-bindings: PCI: mediatek-gen3: Add support for MT6991/MT8196
2025-06-23 12:00 ` [PATCH v1 2/3] dt-bindings: PCI: mediatek-gen3: Add support for MT6991/MT8196 AngeloGioacchino Del Regno
@ 2025-06-27 20:11 ` Rob Herring
0 siblings, 0 replies; 5+ messages in thread
From: Rob Herring @ 2025-06-27 20:11 UTC (permalink / raw)
To: AngeloGioacchino Del Regno
Cc: jianjun.wang, ryder.lee, bhelgaas, lpieralisi, kwilczynski,
manivannan.sadhasivam, krzk+dt, conor+dt, matthias.bgg, linux-pci,
linux-mediatek, devicetree, linux-kernel, linux-arm-kernel,
kernel
On Mon, Jun 23, 2025 at 02:00:57PM +0200, AngeloGioacchino Del Regno wrote:
> Add compatible strings for MT8196 and MT6991 (which are fully
> compatible between each other) and clock definitions.
>
> These new SoCs don't have tl_96m and tl_32k clocks, but need
> an AHB to APB bus clock and a low power clock.
>
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> ---
> .../bindings/pci/mediatek-pcie-gen3.yaml | 35 +++++++++++++++++++
> 1 file changed, 35 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml b/Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml
> index 162406e0691a..02cddf0246ce 100644
> --- a/Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml
> +++ b/Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml
> @@ -52,7 +52,12 @@ properties:
> - mediatek,mt8188-pcie
> - mediatek,mt8195-pcie
> - const: mediatek,mt8192-pcie
> + - items:
> + - enum:
> + - mediatek,mt6991-pcie
> + - const: mediatek,mt8196-pcie
> - const: mediatek,mt8192-pcie
> + - const: mediatek,mt8196-pcie
> - const: airoha,en7581-pcie
>
> reg:
> @@ -212,6 +217,36 @@ allOf:
>
> mediatek,pbus-csr: false
>
> + - if:
> + properties:
> + compatible:
> + contains:
> + enum:
> + - mediatek,mt8196-pcie
> + then:
> + properties:
> + clocks:
> + minItems: 6
> +
> + clock-names:
> + items:
> + - const: pl_250m
> + - const: tl_26m
> + - const: bus
> + - const: low_power
> + - const: peri_26m
> + - const: peri_mem
> +
> + resets:
> + minItems: 1
The min is already 1.
> + maxItems: 2
> +
> + reset-names:
> + minItems: 1
> + maxItems: 2
It would be good to define what the names are. I assume they are fixed
and not just any of the allowed ones.
> +
> + mediatek,pbus-csr: false
> +
> - if:
> properties:
> compatible:
> --
> 2.49.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-06-27 20:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-23 12:00 [PATCH v1 0/3] mediatek-gen3: Add support for MT8196/MT6991 AngeloGioacchino Del Regno
2025-06-23 12:00 ` [PATCH v1 1/3] PCI: mediatek-gen3: Implement sys clock ready time setting AngeloGioacchino Del Regno
2025-06-23 12:00 ` [PATCH v1 2/3] dt-bindings: PCI: mediatek-gen3: Add support for MT6991/MT8196 AngeloGioacchino Del Regno
2025-06-27 20:11 ` Rob Herring
2025-06-23 12:00 ` [PATCH v1 3/3] PCI: mediatek-gen3: Add support for MediaTek MT8196 SoC AngeloGioacchino Del Regno
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).