Lines Matching +full:pci +full:- +full:phy
1 // SPDX-License-Identifier: GPL-2.0-only
13 #include <linux/phy/phy.h>
18 #include "pcie-designware.h"
19 #include "pcie-stm32.h"
22 struct dw_pcie pci;
25 struct phy *phy;
33 struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
37 dw_pcie_ep_reset_bar(pci, bar);
40 static int stm32_pcie_start_link(struct dw_pcie *pci)
42 struct stm32_pcie *stm32_pcie = to_stm32_pcie(pci);
44 enable_irq(stm32_pcie->perst_irq);
49 static void stm32_pcie_stop_link(struct dw_pcie *pci)
51 struct stm32_pcie *stm32_pcie = to_stm32_pcie(pci);
53 disable_irq(stm32_pcie->perst_irq);
59 struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
67 dev_err(pci->dev, "UNKNOWN IRQ type\n");
68 return -EINVAL;
98 ret = phy_init(stm32_pcie->phy);
102 ret = clk_prepare_enable(stm32_pcie->clk);
104 phy_exit(stm32_pcie->phy);
111 clk_disable_unprepare(stm32_pcie->clk);
113 phy_exit(stm32_pcie->phy);
116 static void stm32_pcie_perst_assert(struct dw_pcie *pci)
118 struct stm32_pcie *stm32_pcie = to_stm32_pcie(pci);
119 struct dw_pcie_ep *ep = &stm32_pcie->pci.ep;
120 struct device *dev = pci->dev;
124 regmap_update_bits(stm32_pcie->regmap, SYSCFG_PCIECR,
127 pci_epc_deinit_notify(ep->epc);
134 static void stm32_pcie_perst_deassert(struct dw_pcie *pci)
136 struct stm32_pcie *stm32_pcie = to_stm32_pcie(pci);
137 struct device *dev = pci->dev;
138 struct dw_pcie_ep *ep = &pci->ep;
141 dev_dbg(dev, "PERST de-asserted by host\n");
157 * registers were reset by the PHY RCC during phy_init().
165 pci_epc_init_notify(ep->epc);
168 regmap_update_bits(stm32_pcie->regmap, SYSCFG_PCIECR,
184 struct dw_pcie *pci = &stm32_pcie->pci;
187 perst = gpiod_get_value(stm32_pcie->perst_gpio);
189 stm32_pcie_perst_assert(pci);
191 stm32_pcie_perst_deassert(pci);
193 irq_set_irq_type(gpiod_to_irq(stm32_pcie->perst_gpio),
202 struct dw_pcie_ep *ep = &stm32_pcie->pci.ep;
203 struct device *dev = &pdev->dev;
206 ret = regmap_update_bits(stm32_pcie->regmap, SYSCFG_PCIECR,
212 reset_control_assert(stm32_pcie->rst);
213 reset_control_deassert(stm32_pcie->rst);
215 ep->ops = &stm32_pcie_ep_ops;
217 ep->page_size = stm32_pcie_epc_features.align;
238 struct device *dev = &pdev->dev;
243 return -ENOMEM;
245 stm32_pcie->pci.dev = dev;
246 stm32_pcie->pci.ops = &dw_pcie_ops;
248 stm32_pcie->regmap = syscon_regmap_lookup_by_compatible("st,stm32mp25-syscfg");
249 if (IS_ERR(stm32_pcie->regmap))
250 return dev_err_probe(dev, PTR_ERR(stm32_pcie->regmap),
253 stm32_pcie->phy = devm_phy_get(dev, NULL);
254 if (IS_ERR(stm32_pcie->phy))
255 return dev_err_probe(dev, PTR_ERR(stm32_pcie->phy),
256 "failed to get pcie-phy\n");
258 stm32_pcie->clk = devm_clk_get(dev, NULL);
259 if (IS_ERR(stm32_pcie->clk))
260 return dev_err_probe(dev, PTR_ERR(stm32_pcie->clk),
263 stm32_pcie->rst = devm_reset_control_get_exclusive(dev, NULL);
264 if (IS_ERR(stm32_pcie->rst))
265 return dev_err_probe(dev, PTR_ERR(stm32_pcie->rst),
268 stm32_pcie->perst_gpio = devm_gpiod_get(dev, "reset", GPIOD_IN);
269 if (IS_ERR(stm32_pcie->perst_gpio))
270 return dev_err_probe(dev, PTR_ERR(stm32_pcie->perst_gpio),
273 ret = phy_set_mode(stm32_pcie->phy, PHY_MODE_PCIE);
283 pm_runtime_put_noidle(&pdev->dev);
287 stm32_pcie->perst_irq = gpiod_to_irq(stm32_pcie->perst_gpio);
290 irq_set_status_flags(stm32_pcie->perst_irq, IRQ_NOAUTOEN);
292 ret = devm_request_threaded_irq(dev, stm32_pcie->perst_irq, NULL,
297 pm_runtime_put_noidle(&pdev->dev);
303 pm_runtime_put_noidle(&pdev->dev);
311 struct dw_pcie *pci = &stm32_pcie->pci;
312 struct dw_pcie_ep *ep = &pci->ep;
314 dw_pcie_stop_link(pci);
316 pci_epc_deinit_notify(ep->epc);
321 pm_runtime_put_sync(&pdev->dev);
325 { .compatible = "st,stm32mp25-pcie-ep" },
333 .name = "stm32-ep-pcie",