* [PATCH v2 0/3] mediatek-gen3: Add support for MT8196/MT6991
@ 2025-07-03 12:08 AngeloGioacchino Del Regno
2025-07-03 12:08 ` [PATCH v2 1/3] PCI: mediatek-gen3: Implement sys clock ready time setting AngeloGioacchino Del Regno
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-07-03 12:08 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
Changes in v2:
- bindings: Removed useless minItems in reset
- bindings: Defined reset-names items
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] 8+ messages in thread
* [PATCH v2 1/3] PCI: mediatek-gen3: Implement sys clock ready time setting
2025-07-03 12:08 [PATCH v2 0/3] mediatek-gen3: Add support for MT8196/MT6991 AngeloGioacchino Del Regno
@ 2025-07-03 12:08 ` AngeloGioacchino Del Regno
2025-08-19 14:27 ` Manivannan Sadhasivam
2025-07-03 12:08 ` [PATCH v2 2/3] dt-bindings: PCI: mediatek-gen3: Add support for MT6991/MT8196 AngeloGioacchino Del Regno
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-07-03 12:08 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 5464b4ae5c20..8035f7f812aa 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] 8+ messages in thread
* [PATCH v2 2/3] dt-bindings: PCI: mediatek-gen3: Add support for MT6991/MT8196
2025-07-03 12:08 [PATCH v2 0/3] mediatek-gen3: Add support for MT8196/MT6991 AngeloGioacchino Del Regno
2025-07-03 12:08 ` [PATCH v2 1/3] PCI: mediatek-gen3: Implement sys clock ready time setting AngeloGioacchino Del Regno
@ 2025-07-03 12:08 ` AngeloGioacchino Del Regno
2025-07-07 6:46 ` Krzysztof Kozlowski
2025-07-03 12:08 ` [PATCH v2 3/3] PCI: mediatek-gen3: Add support for MediaTek MT8196 SoC AngeloGioacchino Del Regno
2025-08-19 14:37 ` [PATCH v2 0/3] mediatek-gen3: Add support for MT8196/MT6991 Manivannan Sadhasivam
3 siblings, 1 reply; 8+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-07-03 12:08 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..fe3b17b92597 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:
+ maxItems: 2
+
+ reset-names:
+ items:
+ - const: phy
+ - const: mac
+
+ mediatek,pbus-csr: false
+
- if:
properties:
compatible:
--
2.49.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 3/3] PCI: mediatek-gen3: Add support for MediaTek MT8196 SoC
2025-07-03 12:08 [PATCH v2 0/3] mediatek-gen3: Add support for MT8196/MT6991 AngeloGioacchino Del Regno
2025-07-03 12:08 ` [PATCH v2 1/3] PCI: mediatek-gen3: Implement sys clock ready time setting AngeloGioacchino Del Regno
2025-07-03 12:08 ` [PATCH v2 2/3] dt-bindings: PCI: mediatek-gen3: Add support for MT6991/MT8196 AngeloGioacchino Del Regno
@ 2025-07-03 12:08 ` AngeloGioacchino Del Regno
2025-08-19 14:37 ` [PATCH v2 0/3] mediatek-gen3: Add support for MT8196/MT6991 Manivannan Sadhasivam
3 siblings, 0 replies; 8+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-07-03 12:08 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 8035f7f812aa..f8adf88d19b0 100644
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
@@ -1358,6 +1358,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 = {
@@ -1372,6 +1381,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] 8+ messages in thread
* Re: [PATCH v2 2/3] dt-bindings: PCI: mediatek-gen3: Add support for MT6991/MT8196
2025-07-03 12:08 ` [PATCH v2 2/3] dt-bindings: PCI: mediatek-gen3: Add support for MT6991/MT8196 AngeloGioacchino Del Regno
@ 2025-07-07 6:46 ` Krzysztof Kozlowski
2025-08-19 14:36 ` Manivannan Sadhasivam
0 siblings, 1 reply; 8+ messages in thread
From: Krzysztof Kozlowski @ 2025-07-07 6:46 UTC (permalink / raw)
To: AngeloGioacchino Del Regno
Cc: jianjun.wang, ryder.lee, bhelgaas, lpieralisi, kwilczynski,
manivannan.sadhasivam, robh, krzk+dt, conor+dt, matthias.bgg,
linux-pci, linux-mediatek, devicetree, linux-kernel,
linux-arm-kernel, kernel
On Thu, Jul 03, 2025 at 02:08:46PM +0200, AngeloGioacchino Del Regno wrote:
> + 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: 2 is needed (that's a change since some time, comparing to
what was year or earlier)
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/3] PCI: mediatek-gen3: Implement sys clock ready time setting
2025-07-03 12:08 ` [PATCH v2 1/3] PCI: mediatek-gen3: Implement sys clock ready time setting AngeloGioacchino Del Regno
@ 2025-08-19 14:27 ` Manivannan Sadhasivam
0 siblings, 0 replies; 8+ messages in thread
From: Manivannan Sadhasivam @ 2025-08-19 14:27 UTC (permalink / raw)
To: AngeloGioacchino Del Regno
Cc: jianjun.wang, ryder.lee, bhelgaas, lpieralisi, kwilczynski,
manivannan.sadhasivam, robh, krzk+dt, conor+dt, matthias.bgg,
linux-pci, linux-mediatek, devicetree, linux-kernel,
linux-arm-kernel, kernel
On Thu, Jul 03, 2025 at 02:08:45PM GMT, AngeloGioacchino Del Regno wrote:
> 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 5464b4ae5c20..8035f7f812aa 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);
Nit: Mask and update could be simplified with:
FIELD_MODIFY(PCIE_RSRC_SYS_CLK_RDY_TIME_MASK, &val,
pcie->soc->sys_clk_rdy_time_us);
I'll ammend it while applying.
- Mani
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/3] dt-bindings: PCI: mediatek-gen3: Add support for MT6991/MT8196
2025-07-07 6:46 ` Krzysztof Kozlowski
@ 2025-08-19 14:36 ` Manivannan Sadhasivam
0 siblings, 0 replies; 8+ messages in thread
From: Manivannan Sadhasivam @ 2025-08-19 14:36 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: AngeloGioacchino Del Regno, jianjun.wang, ryder.lee, bhelgaas,
lpieralisi, kwilczynski, manivannan.sadhasivam, robh, krzk+dt,
conor+dt, matthias.bgg, linux-pci, linux-mediatek, devicetree,
linux-kernel, linux-arm-kernel, kernel
On Mon, Jul 07, 2025 at 08:46:16AM GMT, Krzysztof Kozlowski wrote:
> On Thu, Jul 03, 2025 at 02:08:46PM +0200, AngeloGioacchino Del Regno wrote:
> > + 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: 2 is needed (that's a change since some time, comparing to
> what was year or earlier)
>
Will do 's/maxItems/minItems' while applying.
- Mani
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/3] mediatek-gen3: Add support for MT8196/MT6991
2025-07-03 12:08 [PATCH v2 0/3] mediatek-gen3: Add support for MT8196/MT6991 AngeloGioacchino Del Regno
` (2 preceding siblings ...)
2025-07-03 12:08 ` [PATCH v2 3/3] PCI: mediatek-gen3: Add support for MediaTek MT8196 SoC AngeloGioacchino Del Regno
@ 2025-08-19 14:37 ` Manivannan Sadhasivam
3 siblings, 0 replies; 8+ messages in thread
From: Manivannan Sadhasivam @ 2025-08-19 14:37 UTC (permalink / raw)
To: jianjun.wang, AngeloGioacchino Del Regno
Cc: ryder.lee, bhelgaas, lpieralisi, kwilczynski, robh, krzk+dt,
conor+dt, matthias.bgg, linux-pci, linux-mediatek, devicetree,
linux-kernel, linux-arm-kernel, kernel, Manivannan Sadhasivam
On Thu, 03 Jul 2025 14:08:44 +0200, AngeloGioacchino Del Regno wrote:
> Changes in v2:
> - bindings: Removed useless minItems in reset
> - bindings: Defined reset-names items
>
> 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.
>
> [...]
Applied, thanks!
[1/3] PCI: mediatek-gen3: Implement sys clock ready time setting
commit: a895dc47ceba63feb711905440585cf2b16e9ce2
[2/3] dt-bindings: PCI: mediatek-gen3: Add support for MT6991/MT8196
commit: 0106b6c114cf8b77d801d9e280b221f8b4d5595b
[3/3] PCI: mediatek-gen3: Add support for MediaTek MT8196 SoC
commit: 81fedb39a9f0da301a11c7a3b81d91c3b9024462
Best regards,
--
Manivannan Sadhasivam <mani@kernel.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-08-19 19:22 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-03 12:08 [PATCH v2 0/3] mediatek-gen3: Add support for MT8196/MT6991 AngeloGioacchino Del Regno
2025-07-03 12:08 ` [PATCH v2 1/3] PCI: mediatek-gen3: Implement sys clock ready time setting AngeloGioacchino Del Regno
2025-08-19 14:27 ` Manivannan Sadhasivam
2025-07-03 12:08 ` [PATCH v2 2/3] dt-bindings: PCI: mediatek-gen3: Add support for MT6991/MT8196 AngeloGioacchino Del Regno
2025-07-07 6:46 ` Krzysztof Kozlowski
2025-08-19 14:36 ` Manivannan Sadhasivam
2025-07-03 12:08 ` [PATCH v2 3/3] PCI: mediatek-gen3: Add support for MediaTek MT8196 SoC AngeloGioacchino Del Regno
2025-08-19 14:37 ` [PATCH v2 0/3] mediatek-gen3: Add support for MT8196/MT6991 Manivannan Sadhasivam
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).