Skip to content

Commit 8197ec4

Browse files
John MadieuMani-Sadhasivam
authored andcommitted
PCI: rzg3s-host: Add support for RZ/G3E PCIe controller
Add support for the PCIe controller found in RZ/G3E SoCs to the existing RZ/G3S PCIe host controller driver. The RZ/G3E PCIe controller is similar to the RZ/G3S, with the following key differences: - Supports PCIe Gen3 (8.0 GT/s) link speeds alongside Gen2 (5.0 GT/s) - Uses a different reset control mechanism via AXI registers instead of the Linux reset framework - Requires specific SYSC configuration for link state control and Root Complex mode selection Signed-off-by: John Madieu <john.madieu.xa@bp.renesas.com> [mani: added a readl_relaxed() before fsleep() to flush previous write] Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # RZ/V2N EVK Tested-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> Reviewed-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> Link: https://patch.msgid.link/20260306143423.19562-13-john.madieu.xa@bp.renesas.com
1 parent 5e9a5af commit 8197ec4

1 file changed

Lines changed: 93 additions & 0 deletions

File tree

drivers/pci/controller/pcie-rzg3s-host.c

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,15 @@
111111
#define RZG3S_PCI_PERM_CFG_HWINIT_EN BIT(2)
112112
#define RZG3S_PCI_PERM_PIPE_PHY_REG_EN BIT(1)
113113

114+
#define RZG3S_PCI_RESET 0x310
115+
#define RZG3S_PCI_RESET_RST_OUT_B BIT(6)
116+
#define RZG3S_PCI_RESET_RST_PS_B BIT(5)
117+
#define RZG3S_PCI_RESET_RST_LOAD_B BIT(4)
118+
#define RZG3S_PCI_RESET_RST_CFG_B BIT(3)
119+
#define RZG3S_PCI_RESET_RST_RSM_B BIT(2)
120+
#define RZG3S_PCI_RESET_RST_GP_B BIT(1)
121+
#define RZG3S_PCI_RESET_RST_B BIT(0)
122+
114123
#define RZG3S_PCI_MSIRE(id) (0x600 + (id) * 0x10)
115124
#define RZG3S_PCI_MSIRE_ENA BIT(0)
116125

@@ -183,10 +192,14 @@ struct rzg3s_sysc_function {
183192
/**
184193
* enum rzg3s_sysc_func_id - System controller function IDs
185194
* @RZG3S_SYSC_FUNC_ID_RST_RSM_B: RST_RSM_B SYSC function ID
195+
* @RZG3S_SYSC_FUNC_ID_L1_ALLOW: L1 allow SYSC function ID
196+
* @RZG3S_SYSC_FUNC_ID_MODE: Mode SYSC function ID
186197
* @RZG3S_SYSC_FUNC_ID_MAX: Max SYSC function ID
187198
*/
188199
enum rzg3s_sysc_func_id {
189200
RZG3S_SYSC_FUNC_ID_RST_RSM_B,
201+
RZG3S_SYSC_FUNC_ID_L1_ALLOW,
202+
RZG3S_SYSC_FUNC_ID_MODE,
190203
RZG3S_SYSC_FUNC_ID_MAX,
191204
};
192205

@@ -1151,6 +1164,45 @@ static int rzg3s_pcie_config_deinit(struct rzg3s_pcie_host *host)
11511164
host->cfg_resets);
11521165
}
11531166

1167+
static void rzg3e_pcie_config_pre_init(struct rzg3s_pcie_host *host)
1168+
{
1169+
u32 mask = RZG3S_PCI_RESET_RST_LOAD_B | RZG3S_PCI_RESET_RST_CFG_B;
1170+
1171+
/* De-assert LOAD_B and CFG_B */
1172+
rzg3s_pcie_update_bits(host->axi, RZG3S_PCI_RESET, mask, mask);
1173+
}
1174+
1175+
static int rzg3e_pcie_config_deinit(struct rzg3s_pcie_host *host)
1176+
{
1177+
writel_relaxed(0, host->axi + RZG3S_PCI_RESET);
1178+
return 0;
1179+
}
1180+
1181+
static int rzg3e_pcie_config_post_init(struct rzg3s_pcie_host *host)
1182+
{
1183+
u32 mask = RZG3S_PCI_RESET_RST_PS_B | RZG3S_PCI_RESET_RST_GP_B |
1184+
RZG3S_PCI_RESET_RST_B;
1185+
1186+
/* De-assert PS_B, GP_B, RST_B */
1187+
rzg3s_pcie_update_bits(host->axi, RZG3S_PCI_RESET, mask, mask);
1188+
1189+
/* Flush deassert */
1190+
readl_relaxed(host->axi + RZG3S_PCI_RESET);
1191+
1192+
/*
1193+
* According to the RZ/G3E HW manual (Rev.1.15, Table 6.6-130
1194+
* Initialization Procedure (RC)), hardware requires >= 500us delay
1195+
* before final reset deassert.
1196+
*/
1197+
fsleep(500);
1198+
1199+
/* De-assert OUT_B and RSM_B */
1200+
mask = RZG3S_PCI_RESET_RST_OUT_B | RZG3S_PCI_RESET_RST_RSM_B;
1201+
rzg3s_pcie_update_bits(host->axi, RZG3S_PCI_RESET, mask, mask);
1202+
1203+
return 0;
1204+
}
1205+
11541206
static void rzg3s_pcie_irq_init(struct rzg3s_pcie_host *host)
11551207
{
11561208
/*
@@ -1312,6 +1364,12 @@ static int rzg3s_pcie_host_init(struct rzg3s_pcie_host *host)
13121364
if (ret)
13131365
goto config_deinit;
13141366

1367+
/* Enable ASPM L1 transition for SoCs that use it */
1368+
ret = rzg3s_sysc_config_func(host->sysc,
1369+
RZG3S_SYSC_FUNC_ID_L1_ALLOW, 1);
1370+
if (ret)
1371+
goto config_deinit_and_refclk;
1372+
13151373
/* Initialize the interrupts */
13161374
rzg3s_pcie_irq_init(host);
13171375

@@ -1659,6 +1717,11 @@ static int rzg3s_pcie_probe(struct platform_device *pdev)
16591717
goto port_refclk_put;
16601718
}
16611719

1720+
/* Put controller in RC mode */
1721+
ret = rzg3s_sysc_config_func(sysc, RZG3S_SYSC_FUNC_ID_MODE, 1);
1722+
if (ret)
1723+
goto port_refclk_put;
1724+
16621725
ret = rzg3s_sysc_config_func(sysc, RZG3S_SYSC_FUNC_ID_RST_RSM_B, 1);
16631726
if (ret)
16641727
goto port_refclk_put;
@@ -1769,6 +1832,10 @@ static int rzg3s_pcie_resume_noirq(struct device *dev)
17691832
struct rzg3s_sysc *sysc = host->sysc;
17701833
int ret;
17711834

1835+
ret = rzg3s_sysc_config_func(sysc, RZG3S_SYSC_FUNC_ID_MODE, 1);
1836+
if (ret)
1837+
return ret;
1838+
17721839
ret = rzg3s_sysc_config_func(sysc, RZG3S_SYSC_FUNC_ID_RST_RSM_B, 1);
17731840
if (ret)
17741841
return ret;
@@ -1833,11 +1900,37 @@ static const struct rzg3s_pcie_soc_data rzg3s_soc_data = {
18331900
},
18341901
};
18351902

1903+
static const char * const rzg3e_soc_power_resets[] = { "aresetn" };
1904+
1905+
static const struct rzg3s_pcie_soc_data rzg3e_soc_data = {
1906+
.power_resets = rzg3e_soc_power_resets,
1907+
.num_power_resets = ARRAY_SIZE(rzg3e_soc_power_resets),
1908+
.config_pre_init = rzg3e_pcie_config_pre_init,
1909+
.config_post_init = rzg3e_pcie_config_post_init,
1910+
.config_deinit = rzg3e_pcie_config_deinit,
1911+
.sysc_info = {
1912+
.functions = {
1913+
[RZG3S_SYSC_FUNC_ID_L1_ALLOW] = {
1914+
.offset = 0x1020,
1915+
.mask = BIT(0),
1916+
},
1917+
[RZG3S_SYSC_FUNC_ID_MODE] = {
1918+
.offset = 0x1024,
1919+
.mask = BIT(0),
1920+
},
1921+
},
1922+
},
1923+
};
1924+
18361925
static const struct of_device_id rzg3s_pcie_of_match[] = {
18371926
{
18381927
.compatible = "renesas,r9a08g045-pcie",
18391928
.data = &rzg3s_soc_data,
18401929
},
1930+
{
1931+
.compatible = "renesas,r9a09g047-pcie",
1932+
.data = &rzg3e_soc_data,
1933+
},
18411934
{}
18421935
};
18431936

0 commit comments

Comments
 (0)