Skip to content

Commit a895dc4

Browse files
AngeloGioacchino Del RegnoMani-Sadhasivam
authored andcommitted
PCI: mediatek-gen3: Implement sys clock ready time setting
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> [mani: used FIELD_MODIFY() to simplify mask and update] Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> Link: https://patch.msgid.link/20250703120847.121826-2-angelogioacchino.delregno@collabora.com
1 parent 8f5ae30 commit a895dc4

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

drivers/pci/controller/pcie-mediatek-gen3.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@
102102
#define PCIE_MSI_SET_ADDR_HI_BASE 0xc80
103103
#define PCIE_MSI_SET_ADDR_HI_OFFSET 0x04
104104

105+
#define PCIE_RESOURCE_CTRL_REG 0xd2c
106+
#define PCIE_RSRC_SYS_CLK_RDY_TIME_MASK GENMASK(7, 0)
107+
105108
#define PCIE_ICMD_PM_REG 0x198
106109
#define PCIE_TURN_OFF_LINK BIT(4)
107110

@@ -149,6 +152,7 @@ enum mtk_gen3_pcie_flags {
149152
* struct mtk_gen3_pcie_pdata - differentiate between host generations
150153
* @power_up: pcie power_up callback
151154
* @phy_resets: phy reset lines SoC data.
155+
* @sys_clk_rdy_time_us: System clock ready time override (microseconds)
152156
* @flags: pcie device flags.
153157
*/
154158
struct mtk_gen3_pcie_pdata {
@@ -157,6 +161,7 @@ struct mtk_gen3_pcie_pdata {
157161
const char *id[MAX_NUM_PHY_RESETS];
158162
int num_resets;
159163
} phy_resets;
164+
u8 sys_clk_rdy_time_us;
160165
u32 flags;
161166
};
162167

@@ -435,6 +440,14 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie)
435440
writel_relaxed(val, pcie->base + PCIE_CONF_LINK2_CTL_STS);
436441
}
437442

443+
/* If parameter is present, adjust SYS_CLK_RDY_TIME to avoid glitching */
444+
if (pcie->soc->sys_clk_rdy_time_us) {
445+
val = readl_relaxed(pcie->base + PCIE_RESOURCE_CTRL_REG);
446+
FIELD_MODIFY(PCIE_RSRC_SYS_CLK_RDY_TIME_MASK, &val,
447+
pcie->soc->sys_clk_rdy_time_us);
448+
writel_relaxed(val, pcie->base + PCIE_RESOURCE_CTRL_REG);
449+
}
450+
438451
/* Set class code */
439452
val = readl_relaxed(pcie->base + PCIE_PCI_IDS_1);
440453
val &= ~GENMASK(31, 8);

0 commit comments

Comments
 (0)