Lines Matching +full:irq +full:- +full:syscfg
1 // SPDX-License-Identifier: GPL-2.0-only
19 #include "pcie-designware.h"
20 #include "pcie-stm32.h"
35 if (stm32_pcie->perst_gpio) { in stm32_pcie_deassert_perst()
37 gpiod_set_value(stm32_pcie->perst_gpio, 0); in stm32_pcie_deassert_perst()
45 gpiod_set_value(stm32_pcie->perst_gpio, 1); in stm32_pcie_assert_perst()
52 return regmap_update_bits(stm32_pcie->regmap, SYSCFG_PCIECR, in stm32_pcie_start_link()
61 regmap_update_bits(stm32_pcie->regmap, SYSCFG_PCIECR, in stm32_pcie_stop_link()
70 ret = dw_pcie_suspend_noirq(&stm32_pcie->pci); in stm32_pcie_suspend_noirq()
76 clk_disable_unprepare(stm32_pcie->clk); in stm32_pcie_suspend_noirq()
79 phy_exit(stm32_pcie->phy); in stm32_pcie_suspend_noirq()
101 ret = phy_init(stm32_pcie->phy); in stm32_pcie_resume_noirq()
108 ret = clk_prepare_enable(stm32_pcie->clk); in stm32_pcie_resume_noirq()
114 ret = dw_pcie_resume_noirq(&stm32_pcie->pci); in stm32_pcie_resume_noirq()
124 clk_disable_unprepare(stm32_pcie->clk); in stm32_pcie_resume_noirq()
127 phy_exit(stm32_pcie->phy); in stm32_pcie_resume_noirq()
148 struct device *dev = stm32_pcie->pci.dev; in stm32_add_pcie_port()
152 ret = phy_set_mode(stm32_pcie->phy, PHY_MODE_PCIE); in stm32_add_pcie_port()
156 ret = phy_init(stm32_pcie->phy); in stm32_add_pcie_port()
160 ret = regmap_update_bits(stm32_pcie->regmap, SYSCFG_PCIECR, in stm32_add_pcie_port()
168 if (stm32_pcie->wake_gpio) { in stm32_add_pcie_port()
169 wake_irq = gpiod_to_irq(stm32_pcie->wake_gpio); in stm32_add_pcie_port()
172 dev_err(dev, "Failed to enable wakeup irq %d\n", ret); in stm32_add_pcie_port()
184 phy_exit(stm32_pcie->phy); in stm32_add_pcie_port()
191 dev_pm_clear_wake_irq(stm32_pcie->pci.dev); in stm32_remove_pcie_port()
195 phy_exit(stm32_pcie->phy); in stm32_remove_pcie_port()
200 struct device *dev = stm32_pcie->pci.dev; in stm32_pcie_parse_port()
203 root_port = of_get_next_available_child(dev->of_node, NULL); in stm32_pcie_parse_port()
205 stm32_pcie->phy = devm_of_phy_get(dev, root_port, NULL); in stm32_pcie_parse_port()
206 if (IS_ERR(stm32_pcie->phy)) { in stm32_pcie_parse_port()
208 return dev_err_probe(dev, PTR_ERR(stm32_pcie->phy), in stm32_pcie_parse_port()
209 "Failed to get pcie-phy\n"); in stm32_pcie_parse_port()
212 stm32_pcie->perst_gpio = devm_fwnode_gpiod_get(dev, of_fwnode_handle(root_port), in stm32_pcie_parse_port()
214 if (IS_ERR(stm32_pcie->perst_gpio)) { in stm32_pcie_parse_port()
215 if (PTR_ERR(stm32_pcie->perst_gpio) != -ENOENT) { in stm32_pcie_parse_port()
217 return dev_err_probe(dev, PTR_ERR(stm32_pcie->perst_gpio), in stm32_pcie_parse_port()
220 stm32_pcie->perst_gpio = NULL; in stm32_pcie_parse_port()
223 stm32_pcie->wake_gpio = devm_fwnode_gpiod_get(dev, of_fwnode_handle(root_port), in stm32_pcie_parse_port()
226 if (IS_ERR(stm32_pcie->wake_gpio)) { in stm32_pcie_parse_port()
227 if (PTR_ERR(stm32_pcie->wake_gpio) != -ENOENT) { in stm32_pcie_parse_port()
229 return dev_err_probe(dev, PTR_ERR(stm32_pcie->wake_gpio), in stm32_pcie_parse_port()
232 stm32_pcie->wake_gpio = NULL; in stm32_pcie_parse_port()
243 struct device *dev = &pdev->dev; in stm32_pcie_probe()
248 return -ENOMEM; in stm32_pcie_probe()
250 stm32_pcie->pci.dev = dev; in stm32_pcie_probe()
251 stm32_pcie->pci.ops = &dw_pcie_ops; in stm32_pcie_probe()
252 stm32_pcie->pci.pp.ops = &stm32_pcie_host_ops; in stm32_pcie_probe()
254 stm32_pcie->regmap = syscon_regmap_lookup_by_compatible("st,stm32mp25-syscfg"); in stm32_pcie_probe()
255 if (IS_ERR(stm32_pcie->regmap)) in stm32_pcie_probe()
256 return dev_err_probe(dev, PTR_ERR(stm32_pcie->regmap), in stm32_pcie_probe()
257 "No syscfg specified\n"); in stm32_pcie_probe()
259 stm32_pcie->clk = devm_clk_get(dev, NULL); in stm32_pcie_probe()
260 if (IS_ERR(stm32_pcie->clk)) in stm32_pcie_probe()
261 return dev_err_probe(dev, PTR_ERR(stm32_pcie->clk), in stm32_pcie_probe()
264 stm32_pcie->rst = devm_reset_control_get_exclusive(dev, NULL); in stm32_pcie_probe()
265 if (IS_ERR(stm32_pcie->rst)) in stm32_pcie_probe()
266 return dev_err_probe(dev, PTR_ERR(stm32_pcie->rst), in stm32_pcie_probe()
279 reset_control_assert(stm32_pcie->rst); in stm32_pcie_probe()
280 reset_control_deassert(stm32_pcie->rst); in stm32_pcie_probe()
282 ret = clk_prepare_enable(stm32_pcie->clk); in stm32_pcie_probe()
302 ret = dw_pcie_host_init(&stm32_pcie->pci.pp); in stm32_pcie_probe()
306 if (stm32_pcie->wake_gpio) in stm32_pcie_probe()
312 clk_disable_unprepare(stm32_pcie->clk); in stm32_pcie_probe()
323 struct dw_pcie_rp *pp = &stm32_pcie->pci.pp; in stm32_pcie_remove()
325 if (stm32_pcie->wake_gpio) in stm32_pcie_remove()
326 device_init_wakeup(&pdev->dev, false); in stm32_pcie_remove()
330 clk_disable_unprepare(stm32_pcie->clk); in stm32_pcie_remove()
334 pm_runtime_put_noidle(&pdev->dev); in stm32_pcie_remove()
338 { .compatible = "st,stm32mp25-pcie-rc" },
346 .name = "stm32-pcie",