Lines Matching +full:pcie +full:- +full:ep

1 // SPDX-License-Identifier: GPL-2.0-only
3 * STMicroelectronics STM32MP25 PCIe endpoint driver.
18 #include "pcie-designware.h"
19 #include "pcie-stm32.h"
31 static void stm32_pcie_ep_init(struct dw_pcie_ep *ep) in stm32_pcie_ep_init() argument
33 struct dw_pcie *pci = to_dw_pcie_from_ep(ep); in stm32_pcie_ep_init()
44 regmap_update_bits(stm32_pcie->regmap, SYSCFG_PCIECR, in stm32_pcie_enable_link()
55 regmap_update_bits(stm32_pcie->regmap, SYSCFG_PCIECR, STM32MP25_PCIECR_LTSSM_EN, 0); in stm32_pcie_disable_link()
63 dev_dbg(pci->dev, "Enable link\n"); in stm32_pcie_start_link()
67 dev_err(pci->dev, "PCIe cannot establish link: %d\n", ret); in stm32_pcie_start_link()
71 enable_irq(stm32_pcie->perst_irq); in stm32_pcie_start_link()
80 dev_dbg(pci->dev, "Disable link\n"); in stm32_pcie_stop_link()
82 disable_irq(stm32_pcie->perst_irq); in stm32_pcie_stop_link()
87 static int stm32_pcie_raise_irq(struct dw_pcie_ep *ep, u8 func_no, in stm32_pcie_raise_irq() argument
90 struct dw_pcie *pci = to_dw_pcie_from_ep(ep); in stm32_pcie_raise_irq()
94 return dw_pcie_ep_raise_intx_irq(ep, func_no); in stm32_pcie_raise_irq()
96 return dw_pcie_ep_raise_msi_irq(ep, func_no, interrupt_num); in stm32_pcie_raise_irq()
98 dev_err(pci->dev, "UNKNOWN IRQ type\n"); in stm32_pcie_raise_irq()
99 return -EINVAL; in stm32_pcie_raise_irq()
109 stm32_pcie_get_features(struct dw_pcie_ep *ep) in stm32_pcie_get_features() argument
129 ret = phy_init(stm32_pcie->phy); in stm32_pcie_enable_resources()
133 ret = clk_prepare_enable(stm32_pcie->clk); in stm32_pcie_enable_resources()
135 phy_exit(stm32_pcie->phy); in stm32_pcie_enable_resources()
142 clk_disable_unprepare(stm32_pcie->clk); in stm32_pcie_disable_resources()
144 phy_exit(stm32_pcie->phy); in stm32_pcie_disable_resources()
150 struct dw_pcie_ep *ep = &stm32_pcie->pci.ep; in stm32_pcie_perst_assert() local
151 struct device *dev = pci->dev; in stm32_pcie_perst_assert()
155 pci_epc_deinit_notify(ep->epc); in stm32_pcie_perst_assert()
165 struct device *dev = pci->dev; in stm32_pcie_perst_deassert()
166 struct dw_pcie_ep *ep = &pci->ep; in stm32_pcie_perst_deassert() local
169 dev_dbg(dev, "PERST de-asserted by host\n"); in stm32_pcie_perst_deassert()
187 ret = dw_pcie_ep_init_registers(ep); in stm32_pcie_perst_deassert()
193 pci_epc_init_notify(ep->epc); in stm32_pcie_perst_deassert()
207 struct dw_pcie *pci = &stm32_pcie->pci; in stm32_pcie_ep_perst_irq_thread()
210 perst = gpiod_get_value(stm32_pcie->perst_gpio); in stm32_pcie_ep_perst_irq_thread()
216 irq_set_irq_type(gpiod_to_irq(stm32_pcie->perst_gpio), in stm32_pcie_ep_perst_irq_thread()
225 struct dw_pcie_ep *ep = &stm32_pcie->pci.ep; in stm32_add_pcie_ep() local
226 struct device *dev = &pdev->dev; in stm32_add_pcie_ep()
229 ret = regmap_update_bits(stm32_pcie->regmap, SYSCFG_PCIECR, in stm32_add_pcie_ep()
235 reset_control_assert(stm32_pcie->rst); in stm32_add_pcie_ep()
236 reset_control_deassert(stm32_pcie->rst); in stm32_add_pcie_ep()
238 ep->ops = &stm32_pcie_ep_ops; in stm32_add_pcie_ep()
240 ret = dw_pcie_ep_init(ep); in stm32_add_pcie_ep()
242 dev_err(dev, "Failed to initialize ep: %d\n", ret); in stm32_add_pcie_ep()
249 dw_pcie_ep_deinit(ep); in stm32_add_pcie_ep()
259 struct device *dev = &pdev->dev; in stm32_pcie_probe()
264 return -ENOMEM; in stm32_pcie_probe()
266 stm32_pcie->pci.dev = dev; in stm32_pcie_probe()
267 stm32_pcie->pci.ops = &dw_pcie_ops; in stm32_pcie_probe()
269 stm32_pcie->regmap = syscon_regmap_lookup_by_compatible("st,stm32mp25-syscfg"); in stm32_pcie_probe()
270 if (IS_ERR(stm32_pcie->regmap)) in stm32_pcie_probe()
271 return dev_err_probe(dev, PTR_ERR(stm32_pcie->regmap), in stm32_pcie_probe()
274 stm32_pcie->phy = devm_phy_get(dev, NULL); in stm32_pcie_probe()
275 if (IS_ERR(stm32_pcie->phy)) in stm32_pcie_probe()
276 return dev_err_probe(dev, PTR_ERR(stm32_pcie->phy), in stm32_pcie_probe()
277 "failed to get pcie-phy\n"); in stm32_pcie_probe()
279 stm32_pcie->clk = devm_clk_get(dev, NULL); in stm32_pcie_probe()
280 if (IS_ERR(stm32_pcie->clk)) in stm32_pcie_probe()
281 return dev_err_probe(dev, PTR_ERR(stm32_pcie->clk), in stm32_pcie_probe()
282 "Failed to get PCIe clock source\n"); in stm32_pcie_probe()
284 stm32_pcie->rst = devm_reset_control_get_exclusive(dev, NULL); in stm32_pcie_probe()
285 if (IS_ERR(stm32_pcie->rst)) in stm32_pcie_probe()
286 return dev_err_probe(dev, PTR_ERR(stm32_pcie->rst), in stm32_pcie_probe()
287 "Failed to get PCIe reset\n"); in stm32_pcie_probe()
289 stm32_pcie->perst_gpio = devm_gpiod_get(dev, "reset", GPIOD_IN); in stm32_pcie_probe()
290 if (IS_ERR(stm32_pcie->perst_gpio)) in stm32_pcie_probe()
291 return dev_err_probe(dev, PTR_ERR(stm32_pcie->perst_gpio), in stm32_pcie_probe()
294 ret = phy_set_mode(stm32_pcie->phy, PHY_MODE_PCIE); in stm32_pcie_probe()
304 pm_runtime_put_noidle(&pdev->dev); in stm32_pcie_probe()
308 stm32_pcie->perst_irq = gpiod_to_irq(stm32_pcie->perst_gpio); in stm32_pcie_probe()
311 irq_set_status_flags(stm32_pcie->perst_irq, IRQ_NOAUTOEN); in stm32_pcie_probe()
313 ret = devm_request_threaded_irq(dev, stm32_pcie->perst_irq, NULL, in stm32_pcie_probe()
318 pm_runtime_put_noidle(&pdev->dev); in stm32_pcie_probe()
324 pm_runtime_put_noidle(&pdev->dev); in stm32_pcie_probe()
332 struct dw_pcie *pci = &stm32_pcie->pci; in stm32_pcie_remove()
333 struct dw_pcie_ep *ep = &pci->ep; in stm32_pcie_remove() local
337 pci_epc_deinit_notify(ep->epc); in stm32_pcie_remove()
338 dw_pcie_ep_deinit(ep); in stm32_pcie_remove()
342 pm_runtime_put_sync(&pdev->dev); in stm32_pcie_remove()
346 { .compatible = "st,stm32mp25-pcie-ep" },
354 .name = "stm32-ep-pcie",
362 MODULE_DESCRIPTION("STM32MP25 PCIe Endpoint Controller driver");