|
111 | 111 | #define RZG3S_PCI_PERM_CFG_HWINIT_EN BIT(2) |
112 | 112 | #define RZG3S_PCI_PERM_PIPE_PHY_REG_EN BIT(1) |
113 | 113 |
|
| 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 | + |
114 | 123 | #define RZG3S_PCI_MSIRE(id) (0x600 + (id) * 0x10) |
115 | 124 | #define RZG3S_PCI_MSIRE_ENA BIT(0) |
116 | 125 |
|
@@ -183,10 +192,14 @@ struct rzg3s_sysc_function { |
183 | 192 | /** |
184 | 193 | * enum rzg3s_sysc_func_id - System controller function IDs |
185 | 194 | * @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 |
186 | 197 | * @RZG3S_SYSC_FUNC_ID_MAX: Max SYSC function ID |
187 | 198 | */ |
188 | 199 | enum rzg3s_sysc_func_id { |
189 | 200 | RZG3S_SYSC_FUNC_ID_RST_RSM_B, |
| 201 | + RZG3S_SYSC_FUNC_ID_L1_ALLOW, |
| 202 | + RZG3S_SYSC_FUNC_ID_MODE, |
190 | 203 | RZG3S_SYSC_FUNC_ID_MAX, |
191 | 204 | }; |
192 | 205 |
|
@@ -1151,6 +1164,45 @@ static int rzg3s_pcie_config_deinit(struct rzg3s_pcie_host *host) |
1151 | 1164 | host->cfg_resets); |
1152 | 1165 | } |
1153 | 1166 |
|
| 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 | + |
1154 | 1206 | static void rzg3s_pcie_irq_init(struct rzg3s_pcie_host *host) |
1155 | 1207 | { |
1156 | 1208 | /* |
@@ -1312,6 +1364,12 @@ static int rzg3s_pcie_host_init(struct rzg3s_pcie_host *host) |
1312 | 1364 | if (ret) |
1313 | 1365 | goto config_deinit; |
1314 | 1366 |
|
| 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 | + |
1315 | 1373 | /* Initialize the interrupts */ |
1316 | 1374 | rzg3s_pcie_irq_init(host); |
1317 | 1375 |
|
@@ -1659,6 +1717,11 @@ static int rzg3s_pcie_probe(struct platform_device *pdev) |
1659 | 1717 | goto port_refclk_put; |
1660 | 1718 | } |
1661 | 1719 |
|
| 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 | + |
1662 | 1725 | ret = rzg3s_sysc_config_func(sysc, RZG3S_SYSC_FUNC_ID_RST_RSM_B, 1); |
1663 | 1726 | if (ret) |
1664 | 1727 | goto port_refclk_put; |
@@ -1769,6 +1832,10 @@ static int rzg3s_pcie_resume_noirq(struct device *dev) |
1769 | 1832 | struct rzg3s_sysc *sysc = host->sysc; |
1770 | 1833 | int ret; |
1771 | 1834 |
|
| 1835 | + ret = rzg3s_sysc_config_func(sysc, RZG3S_SYSC_FUNC_ID_MODE, 1); |
| 1836 | + if (ret) |
| 1837 | + return ret; |
| 1838 | + |
1772 | 1839 | ret = rzg3s_sysc_config_func(sysc, RZG3S_SYSC_FUNC_ID_RST_RSM_B, 1); |
1773 | 1840 | if (ret) |
1774 | 1841 | return ret; |
@@ -1833,11 +1900,37 @@ static const struct rzg3s_pcie_soc_data rzg3s_soc_data = { |
1833 | 1900 | }, |
1834 | 1901 | }; |
1835 | 1902 |
|
| 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 | + |
1836 | 1925 | static const struct of_device_id rzg3s_pcie_of_match[] = { |
1837 | 1926 | { |
1838 | 1927 | .compatible = "renesas,r9a08g045-pcie", |
1839 | 1928 | .data = &rzg3s_soc_data, |
1840 | 1929 | }, |
| 1930 | + { |
| 1931 | + .compatible = "renesas,r9a09g047-pcie", |
| 1932 | + .data = &rzg3e_soc_data, |
| 1933 | + }, |
1841 | 1934 | {} |
1842 | 1935 | }; |
1843 | 1936 |
|
|
0 commit comments