Lines Matching full:pcie

3  * PCIe host controller driver for Intel Gateway SoCs
20 #include "pcie-designware.h"
26 /* PCIe Application logic Registers */
83 static inline void pcie_app_wr(struct intel_pcie *pcie, u32 ofs, u32 val) in pcie_app_wr() argument
85 writel(val, pcie->app_base + ofs); in pcie_app_wr()
88 static void pcie_app_wr_mask(struct intel_pcie *pcie, u32 ofs, in pcie_app_wr_mask() argument
91 pcie_update_bits(pcie->app_base, ofs, mask, val); in pcie_app_wr_mask()
94 static inline u32 pcie_rc_cfg_rd(struct intel_pcie *pcie, u32 ofs) in pcie_rc_cfg_rd() argument
96 return dw_pcie_readl_dbi(&pcie->pci, ofs); in pcie_rc_cfg_rd()
99 static inline void pcie_rc_cfg_wr(struct intel_pcie *pcie, u32 ofs, u32 val) in pcie_rc_cfg_wr() argument
101 dw_pcie_writel_dbi(&pcie->pci, ofs, val); in pcie_rc_cfg_wr()
104 static void pcie_rc_cfg_wr_mask(struct intel_pcie *pcie, u32 ofs, in pcie_rc_cfg_wr_mask() argument
107 pcie_update_bits(pcie->pci.dbi_base, ofs, mask, val); in pcie_rc_cfg_wr_mask()
110 static void intel_pcie_ltssm_enable(struct intel_pcie *pcie) in intel_pcie_ltssm_enable() argument
112 pcie_app_wr_mask(pcie, PCIE_APP_CCR, PCIE_APP_CCR_LTSSM_ENABLE, in intel_pcie_ltssm_enable()
116 static void intel_pcie_ltssm_disable(struct intel_pcie *pcie) in intel_pcie_ltssm_disable() argument
118 pcie_app_wr_mask(pcie, PCIE_APP_CCR, PCIE_APP_CCR_LTSSM_ENABLE, 0); in intel_pcie_ltssm_disable()
121 static void intel_pcie_link_setup(struct intel_pcie *pcie) in intel_pcie_link_setup() argument
124 u8 offset = dw_pcie_find_capability(&pcie->pci, PCI_CAP_ID_EXP); in intel_pcie_link_setup()
126 val = pcie_rc_cfg_rd(pcie, offset + PCI_EXP_LNKCTL); in intel_pcie_link_setup()
129 pcie_rc_cfg_wr(pcie, offset + PCI_EXP_LNKCTL, val); in intel_pcie_link_setup()
148 static int intel_pcie_ep_rst_init(struct intel_pcie *pcie) in intel_pcie_ep_rst_init() argument
150 struct device *dev = pcie->pci.dev; in intel_pcie_ep_rst_init()
153 pcie->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); in intel_pcie_ep_rst_init()
154 if (IS_ERR(pcie->reset_gpio)) { in intel_pcie_ep_rst_init()
155 ret = PTR_ERR(pcie->reset_gpio); in intel_pcie_ep_rst_init()
157 dev_err(dev, "Failed to request PCIe GPIO: %d\n", ret); in intel_pcie_ep_rst_init()
167 static void intel_pcie_core_rst_assert(struct intel_pcie *pcie) in intel_pcie_core_rst_assert() argument
169 reset_control_assert(pcie->core_rst); in intel_pcie_core_rst_assert()
172 static void intel_pcie_core_rst_deassert(struct intel_pcie *pcie) in intel_pcie_core_rst_deassert() argument
179 reset_control_deassert(pcie->core_rst); in intel_pcie_core_rst_deassert()
188 static void intel_pcie_device_rst_assert(struct intel_pcie *pcie) in intel_pcie_device_rst_assert() argument
190 gpiod_set_value_cansleep(pcie->reset_gpio, 1); in intel_pcie_device_rst_assert()
193 static void intel_pcie_device_rst_deassert(struct intel_pcie *pcie) in intel_pcie_device_rst_deassert() argument
195 msleep(pcie->rst_intrvl); in intel_pcie_device_rst_deassert()
196 gpiod_set_value_cansleep(pcie->reset_gpio, 0); in intel_pcie_device_rst_deassert()
199 static void intel_pcie_core_irq_disable(struct intel_pcie *pcie) in intel_pcie_core_irq_disable() argument
201 pcie_app_wr(pcie, PCIE_APP_IRNEN, 0); in intel_pcie_core_irq_disable()
202 pcie_app_wr(pcie, PCIE_APP_IRNCR, PCIE_APP_IRN_INT); in intel_pcie_core_irq_disable()
207 struct intel_pcie *pcie = platform_get_drvdata(pdev); in intel_pcie_get_resources() local
208 struct dw_pcie *pci = &pcie->pci; in intel_pcie_get_resources()
212 pcie->core_clk = devm_clk_get(dev, NULL); in intel_pcie_get_resources()
213 if (IS_ERR(pcie->core_clk)) { in intel_pcie_get_resources()
214 ret = PTR_ERR(pcie->core_clk); in intel_pcie_get_resources()
220 pcie->core_rst = devm_reset_control_get(dev, NULL); in intel_pcie_get_resources()
221 if (IS_ERR(pcie->core_rst)) { in intel_pcie_get_resources()
222 ret = PTR_ERR(pcie->core_rst); in intel_pcie_get_resources()
229 &pcie->rst_intrvl); in intel_pcie_get_resources()
231 pcie->rst_intrvl = RESET_INTERVAL_MS; in intel_pcie_get_resources()
233 pcie->app_base = devm_platform_ioremap_resource_byname(pdev, "app"); in intel_pcie_get_resources()
234 if (IS_ERR(pcie->app_base)) in intel_pcie_get_resources()
235 return PTR_ERR(pcie->app_base); in intel_pcie_get_resources()
237 pcie->phy = devm_phy_get(dev, "pcie"); in intel_pcie_get_resources()
238 if (IS_ERR(pcie->phy)) { in intel_pcie_get_resources()
239 ret = PTR_ERR(pcie->phy); in intel_pcie_get_resources()
241 dev_err(dev, "Couldn't get pcie-phy: %d\n", ret); in intel_pcie_get_resources()
248 static int intel_pcie_wait_l2(struct intel_pcie *pcie) in intel_pcie_wait_l2() argument
252 struct dw_pcie *pci = &pcie->pci; in intel_pcie_wait_l2()
258 pcie_app_wr_mask(pcie, PCIE_APP_MSG_CR, PCIE_APP_MSG_XMT_PM_TURNOFF, in intel_pcie_wait_l2()
262 ret = readl_poll_timeout(pcie->app_base + PCIE_APP_PMC, value, in intel_pcie_wait_l2()
266 dev_err(pcie->pci.dev, "PCIe link enter L2 timeout!\n"); in intel_pcie_wait_l2()
271 static void intel_pcie_turn_off(struct intel_pcie *pcie) in intel_pcie_turn_off() argument
273 if (dw_pcie_link_up(&pcie->pci)) in intel_pcie_turn_off()
274 intel_pcie_wait_l2(pcie); in intel_pcie_turn_off()
277 intel_pcie_device_rst_assert(pcie); in intel_pcie_turn_off()
278 pcie_rc_cfg_wr_mask(pcie, PCI_COMMAND, PCI_COMMAND_MEMORY, 0); in intel_pcie_turn_off()
281 static int intel_pcie_host_setup(struct intel_pcie *pcie) in intel_pcie_host_setup() argument
284 struct dw_pcie *pci = &pcie->pci; in intel_pcie_host_setup()
286 intel_pcie_core_rst_assert(pcie); in intel_pcie_host_setup()
287 intel_pcie_device_rst_assert(pcie); in intel_pcie_host_setup()
289 ret = phy_init(pcie->phy); in intel_pcie_host_setup()
293 intel_pcie_core_rst_deassert(pcie); in intel_pcie_host_setup()
295 ret = clk_prepare_enable(pcie->core_clk); in intel_pcie_host_setup()
297 dev_err(pcie->pci.dev, "Core clock enable failed: %d\n", ret); in intel_pcie_host_setup()
303 intel_pcie_ltssm_disable(pcie); in intel_pcie_host_setup()
304 intel_pcie_link_setup(pcie); in intel_pcie_host_setup()
313 intel_pcie_device_rst_deassert(pcie); in intel_pcie_host_setup()
314 intel_pcie_ltssm_enable(pcie); in intel_pcie_host_setup()
321 pcie_app_wr_mask(pcie, PCIE_APP_IRNEN, PCIE_APP_IRN_INT, in intel_pcie_host_setup()
327 clk_disable_unprepare(pcie->core_clk); in intel_pcie_host_setup()
329 intel_pcie_core_rst_assert(pcie); in intel_pcie_host_setup()
330 phy_exit(pcie->phy); in intel_pcie_host_setup()
335 static void __intel_pcie_remove(struct intel_pcie *pcie) in __intel_pcie_remove() argument
337 intel_pcie_core_irq_disable(pcie); in __intel_pcie_remove()
338 intel_pcie_turn_off(pcie); in __intel_pcie_remove()
339 clk_disable_unprepare(pcie->core_clk); in __intel_pcie_remove()
340 intel_pcie_core_rst_assert(pcie); in __intel_pcie_remove()
341 phy_exit(pcie->phy); in __intel_pcie_remove()
346 struct intel_pcie *pcie = platform_get_drvdata(pdev); in intel_pcie_remove() local
347 struct dw_pcie_rp *pp = &pcie->pci.pp; in intel_pcie_remove()
350 __intel_pcie_remove(pcie); in intel_pcie_remove()
355 struct intel_pcie *pcie = dev_get_drvdata(dev); in intel_pcie_suspend_noirq() local
358 intel_pcie_core_irq_disable(pcie); in intel_pcie_suspend_noirq()
359 ret = intel_pcie_wait_l2(pcie); in intel_pcie_suspend_noirq()
363 phy_exit(pcie->phy); in intel_pcie_suspend_noirq()
364 clk_disable_unprepare(pcie->core_clk); in intel_pcie_suspend_noirq()
370 struct intel_pcie *pcie = dev_get_drvdata(dev); in intel_pcie_resume_noirq() local
372 return intel_pcie_host_setup(pcie); in intel_pcie_resume_noirq()
378 struct intel_pcie *pcie = dev_get_drvdata(pci->dev); in intel_pcie_rc_init() local
380 return intel_pcie_host_setup(pcie); in intel_pcie_rc_init()
393 struct intel_pcie *pcie; in intel_pcie_probe() local
398 pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); in intel_pcie_probe()
399 if (!pcie) in intel_pcie_probe()
402 platform_set_drvdata(pdev, pcie); in intel_pcie_probe()
403 pci = &pcie->pci; in intel_pcie_probe()
412 ret = intel_pcie_ep_rst_init(pcie); in intel_pcie_probe()
434 { .compatible = "intel,lgm-pcie" },
442 .name = "intel-gw-pcie",