• Home
  • Raw
  • Download

Lines Matching +full:pcie +full:- +full:phy

1 // SPDX-License-Identifier: GPL-2.0
3 // Cadence PCIe controller driver.
4 // Author: Cyrille Pitchen <cyrille.pitchen@free-electrons.com>
8 #include "pcie-cadence.h"
10 void cdns_pcie_detect_quiet_min_delay_set(struct cdns_pcie *pcie) in cdns_pcie_detect_quiet_min_delay_set() argument
18 ltssm_control_cap = cdns_pcie_readl(pcie, CDNS_PCIE_LTSSM_CONTROL_CAP); in cdns_pcie_detect_quiet_min_delay_set()
23 cdns_pcie_writel(pcie, CDNS_PCIE_LTSSM_CONTROL_CAP, ltssm_control_cap); in cdns_pcie_detect_quiet_min_delay_set()
26 void cdns_pcie_set_outbound_region(struct cdns_pcie *pcie, u8 busnr, u8 fn, in cdns_pcie_set_outbound_region() argument
34 u64 sz = 1ULL << fls64(size - 1); in cdns_pcie_set_outbound_region()
46 cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_PCI_ADDR0(r), addr0); in cdns_pcie_set_outbound_region()
47 cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_PCI_ADDR1(r), addr1); in cdns_pcie_set_outbound_region()
49 /* Set the PCIe header descriptor */ in cdns_pcie_set_outbound_region()
58 * PCIe descriptor, the PCI function number must be set into in cdns_pcie_set_outbound_region()
62 * mode, the PCIe controller may support more than one function. This in cdns_pcie_set_outbound_region()
63 * function number needs to be set properly into the outbound PCIe in cdns_pcie_set_outbound_region()
72 * the PCIe controller will use the captured values for the bus and in cdns_pcie_set_outbound_region()
75 if (pcie->is_rc) { in cdns_pcie_set_outbound_region()
88 cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_DESC0(r), desc0); in cdns_pcie_set_outbound_region()
89 cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_DESC1(r), desc1); in cdns_pcie_set_outbound_region()
92 if (pcie->ops->cpu_addr_fixup) in cdns_pcie_set_outbound_region()
93 cpu_addr = pcie->ops->cpu_addr_fixup(pcie, cpu_addr); in cdns_pcie_set_outbound_region()
99 cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_CPU_ADDR0(r), addr0); in cdns_pcie_set_outbound_region()
100 cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_CPU_ADDR1(r), addr1); in cdns_pcie_set_outbound_region()
103 void cdns_pcie_set_outbound_region_for_normal_msg(struct cdns_pcie *pcie, in cdns_pcie_set_outbound_region_for_normal_msg() argument
113 if (pcie->is_rc) { in cdns_pcie_set_outbound_region_for_normal_msg()
122 if (pcie->ops->cpu_addr_fixup) in cdns_pcie_set_outbound_region_for_normal_msg()
123 cpu_addr = pcie->ops->cpu_addr_fixup(pcie, cpu_addr); in cdns_pcie_set_outbound_region_for_normal_msg()
129 cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_PCI_ADDR0(r), 0); in cdns_pcie_set_outbound_region_for_normal_msg()
130 cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_PCI_ADDR1(r), 0); in cdns_pcie_set_outbound_region_for_normal_msg()
131 cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_DESC0(r), desc0); in cdns_pcie_set_outbound_region_for_normal_msg()
132 cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_DESC1(r), desc1); in cdns_pcie_set_outbound_region_for_normal_msg()
133 cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_CPU_ADDR0(r), addr0); in cdns_pcie_set_outbound_region_for_normal_msg()
134 cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_CPU_ADDR1(r), addr1); in cdns_pcie_set_outbound_region_for_normal_msg()
137 void cdns_pcie_reset_outbound_region(struct cdns_pcie *pcie, u32 r) in cdns_pcie_reset_outbound_region() argument
139 cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_PCI_ADDR0(r), 0); in cdns_pcie_reset_outbound_region()
140 cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_PCI_ADDR1(r), 0); in cdns_pcie_reset_outbound_region()
142 cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_DESC0(r), 0); in cdns_pcie_reset_outbound_region()
143 cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_DESC1(r), 0); in cdns_pcie_reset_outbound_region()
145 cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_CPU_ADDR0(r), 0); in cdns_pcie_reset_outbound_region()
146 cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_CPU_ADDR1(r), 0); in cdns_pcie_reset_outbound_region()
149 void cdns_pcie_disable_phy(struct cdns_pcie *pcie) in cdns_pcie_disable_phy() argument
151 int i = pcie->phy_count; in cdns_pcie_disable_phy()
153 while (i--) { in cdns_pcie_disable_phy()
154 phy_power_off(pcie->phy[i]); in cdns_pcie_disable_phy()
155 phy_exit(pcie->phy[i]); in cdns_pcie_disable_phy()
159 int cdns_pcie_enable_phy(struct cdns_pcie *pcie) in cdns_pcie_enable_phy() argument
164 for (i = 0; i < pcie->phy_count; i++) { in cdns_pcie_enable_phy()
165 ret = phy_init(pcie->phy[i]); in cdns_pcie_enable_phy()
169 ret = phy_power_on(pcie->phy[i]); in cdns_pcie_enable_phy()
171 phy_exit(pcie->phy[i]); in cdns_pcie_enable_phy()
179 while (--i >= 0) { in cdns_pcie_enable_phy()
180 phy_power_off(pcie->phy[i]); in cdns_pcie_enable_phy()
181 phy_exit(pcie->phy[i]); in cdns_pcie_enable_phy()
187 int cdns_pcie_init_phy(struct device *dev, struct cdns_pcie *pcie) in cdns_pcie_init_phy() argument
189 struct device_node *np = dev->of_node; in cdns_pcie_init_phy()
191 struct phy **phy; in cdns_pcie_init_phy() local
197 phy_count = of_property_count_strings(np, "phy-names"); in cdns_pcie_init_phy()
199 dev_err(dev, "no phy-names. PHY will not be initialized\n"); in cdns_pcie_init_phy()
200 pcie->phy_count = 0; in cdns_pcie_init_phy()
204 phy = devm_kcalloc(dev, phy_count, sizeof(*phy), GFP_KERNEL); in cdns_pcie_init_phy()
205 if (!phy) in cdns_pcie_init_phy()
206 return -ENOMEM; in cdns_pcie_init_phy()
210 return -ENOMEM; in cdns_pcie_init_phy()
213 of_property_read_string_index(np, "phy-names", i, &name); in cdns_pcie_init_phy()
214 phy[i] = devm_phy_get(dev, name); in cdns_pcie_init_phy()
215 if (IS_ERR(phy[i])) { in cdns_pcie_init_phy()
216 ret = PTR_ERR(phy[i]); in cdns_pcie_init_phy()
219 link[i] = device_link_add(dev, &phy[i]->dev, DL_FLAG_STATELESS); in cdns_pcie_init_phy()
221 devm_phy_put(dev, phy[i]); in cdns_pcie_init_phy()
222 ret = -EINVAL; in cdns_pcie_init_phy()
227 pcie->phy_count = phy_count; in cdns_pcie_init_phy()
228 pcie->phy = phy; in cdns_pcie_init_phy()
229 pcie->link = link; in cdns_pcie_init_phy()
231 ret = cdns_pcie_enable_phy(pcie); in cdns_pcie_init_phy()
238 while (--i >= 0) { in cdns_pcie_init_phy()
240 devm_phy_put(dev, phy[i]); in cdns_pcie_init_phy()
249 struct cdns_pcie *pcie = dev_get_drvdata(dev); in cdns_pcie_suspend_noirq() local
251 cdns_pcie_disable_phy(pcie); in cdns_pcie_suspend_noirq()
258 struct cdns_pcie *pcie = dev_get_drvdata(dev); in cdns_pcie_resume_noirq() local
261 ret = cdns_pcie_enable_phy(pcie); in cdns_pcie_resume_noirq()
263 dev_err(dev, "failed to enable phy\n"); in cdns_pcie_resume_noirq()