Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'pci/controller/dwc-qcom'

- Parse PERST# from all PCIe bridge nodes for future platforms that will
have PERST# in Switch Downstream Ports as well as in Root Ports
(Manivannan Sadhasivam)

- Rename qcom PERST# assert/deassert helpers, e.g., qcom_ep_reset_assert(),
to avoid confusion with Endpoint interfaces (Manivannan Sadhasivam)

* pci/controller/dwc-qcom:
PCI: qcom: Rename PERST# assert/deassert helpers for uniformity
PCI: qcom: Parse PERST# from all PCIe bridge nodes

# Conflicts:
# drivers/pci/controller/dwc/pcie-qcom.c

+95 -27
+95 -27
drivers/pci/controller/dwc/pcie-qcom.c
··· 261 261 bool no_l0s; 262 262 }; 263 263 264 + struct qcom_pcie_perst { 265 + struct list_head list; 266 + struct gpio_desc *desc; 267 + }; 268 + 264 269 struct qcom_pcie_port { 265 270 struct list_head list; 266 - struct gpio_desc *reset; 267 271 struct phy *phy; 272 + struct list_head perst; 268 273 }; 269 274 270 275 struct qcom_pcie { ··· 288 283 289 284 #define to_qcom_pcie(x) dev_get_drvdata((x)->dev) 290 285 291 - static void qcom_perst_assert(struct qcom_pcie *pcie, bool assert) 286 + static void __qcom_pcie_perst_assert(struct qcom_pcie *pcie, bool assert) 292 287 { 288 + struct qcom_pcie_perst *perst; 293 289 struct qcom_pcie_port *port; 294 290 int val = assert ? 1 : 0; 295 291 296 - list_for_each_entry(port, &pcie->ports, list) 297 - gpiod_set_value_cansleep(port->reset, val); 292 + list_for_each_entry(port, &pcie->ports, list) { 293 + list_for_each_entry(perst, &port->perst, list) 294 + gpiod_set_value_cansleep(perst->desc, val); 295 + } 298 296 299 297 usleep_range(PERST_DELAY_US, PERST_DELAY_US + 500); 300 298 } 301 299 302 - static void qcom_ep_reset_assert(struct qcom_pcie *pcie) 300 + static void qcom_pcie_perst_assert(struct qcom_pcie *pcie) 303 301 { 304 - qcom_perst_assert(pcie, true); 302 + __qcom_pcie_perst_assert(pcie, true); 305 303 } 306 304 307 - static void qcom_ep_reset_deassert(struct qcom_pcie *pcie) 305 + static void qcom_pcie_perst_deassert(struct qcom_pcie *pcie) 308 306 { 309 - /* Ensure that PERST has been asserted for at least 100 ms */ 307 + /* Ensure that PERST# has been asserted for at least 100 ms */ 310 308 msleep(PCIE_T_PVPERL_MS); 311 - qcom_perst_assert(pcie, false); 309 + __qcom_pcie_perst_assert(pcie, false); 312 310 } 313 311 314 312 static int qcom_pcie_start_link(struct dw_pcie *pci) ··· 1290 1282 struct qcom_pcie *pcie = to_qcom_pcie(pci); 1291 1283 int ret; 1292 1284 1293 - qcom_ep_reset_assert(pcie); 1285 + qcom_pcie_perst_assert(pcie); 1294 1286 1295 1287 ret = pcie->cfg->ops->init(pcie); 1296 1288 if (ret) ··· 1317 1309 dw_pcie_remove_capability(pcie->pci, PCI_CAP_ID_MSIX); 1318 1310 dw_pcie_remove_ext_capability(pcie->pci, PCI_EXT_CAP_ID_DPC); 1319 1311 1320 - qcom_ep_reset_deassert(pcie); 1312 + qcom_pcie_perst_deassert(pcie); 1321 1313 1322 1314 if (pcie->cfg->ops->config_sid) { 1323 1315 ret = pcie->cfg->ops->config_sid(pcie); ··· 1328 1320 return 0; 1329 1321 1330 1322 err_assert_reset: 1331 - qcom_ep_reset_assert(pcie); 1323 + qcom_pcie_perst_assert(pcie); 1332 1324 err_pwrctrl_power_off: 1333 1325 pci_pwrctrl_power_off_devices(pci->dev); 1334 1326 err_pwrctrl_destroy: ··· 1347 1339 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); 1348 1340 struct qcom_pcie *pcie = to_qcom_pcie(pci); 1349 1341 1350 - qcom_ep_reset_assert(pcie); 1342 + qcom_pcie_perst_assert(pcie); 1351 1343 1352 1344 /* 1353 1345 * No need to destroy pwrctrl devices as this function only gets called ··· 1687 1679 } 1688 1680 }; 1689 1681 1682 + /* Parse PERST# from all nodes in depth first manner starting from @np */ 1683 + static int qcom_pcie_parse_perst(struct qcom_pcie *pcie, 1684 + struct qcom_pcie_port *port, 1685 + struct device_node *np) 1686 + { 1687 + struct device *dev = pcie->pci->dev; 1688 + struct qcom_pcie_perst *perst; 1689 + struct gpio_desc *reset; 1690 + int ret; 1691 + 1692 + if (!of_find_property(np, "reset-gpios", NULL)) 1693 + goto parse_child_node; 1694 + 1695 + reset = devm_fwnode_gpiod_get(dev, of_fwnode_handle(np), "reset", 1696 + GPIOD_OUT_HIGH, "PERST#"); 1697 + if (IS_ERR(reset)) { 1698 + /* 1699 + * FIXME: GPIOLIB currently supports exclusive GPIO access only. 1700 + * Non exclusive access is broken. But shared PERST# requires 1701 + * non-exclusive access. So once GPIOLIB properly supports it, 1702 + * implement it here. 1703 + */ 1704 + if (PTR_ERR(reset) == -EBUSY) 1705 + dev_err(dev, "Shared PERST# is not supported\n"); 1706 + 1707 + return PTR_ERR(reset); 1708 + } 1709 + 1710 + perst = devm_kzalloc(dev, sizeof(*perst), GFP_KERNEL); 1711 + if (!perst) 1712 + return -ENOMEM; 1713 + 1714 + INIT_LIST_HEAD(&perst->list); 1715 + perst->desc = reset; 1716 + list_add_tail(&perst->list, &port->perst); 1717 + 1718 + parse_child_node: 1719 + for_each_available_child_of_node_scoped(np, child) { 1720 + ret = qcom_pcie_parse_perst(pcie, port, child); 1721 + if (ret) 1722 + return ret; 1723 + } 1724 + 1725 + return 0; 1726 + } 1727 + 1690 1728 static int qcom_pcie_parse_port(struct qcom_pcie *pcie, struct device_node *node) 1691 1729 { 1692 1730 struct device *dev = pcie->pci->dev; 1693 1731 struct qcom_pcie_port *port; 1694 - struct gpio_desc *reset; 1695 1732 struct phy *phy; 1696 1733 int ret; 1697 - 1698 - reset = devm_fwnode_gpiod_get(dev, of_fwnode_handle(node), 1699 - "reset", GPIOD_OUT_HIGH, "PERST#"); 1700 - if (IS_ERR(reset)) 1701 - return PTR_ERR(reset); 1702 1734 1703 1735 phy = devm_of_phy_get(dev, node, NULL); 1704 1736 if (IS_ERR(phy)) ··· 1752 1704 if (ret) 1753 1705 return ret; 1754 1706 1755 - port->reset = reset; 1707 + INIT_LIST_HEAD(&port->perst); 1708 + 1709 + ret = qcom_pcie_parse_perst(pcie, port, node); 1710 + if (ret) 1711 + return ret; 1712 + 1756 1713 port->phy = phy; 1757 1714 INIT_LIST_HEAD(&port->list); 1758 1715 list_add_tail(&port->list, &pcie->ports); ··· 1767 1714 1768 1715 static int qcom_pcie_parse_ports(struct qcom_pcie *pcie) 1769 1716 { 1717 + struct qcom_pcie_perst *perst, *tmp_perst; 1718 + struct qcom_pcie_port *port, *tmp_port; 1770 1719 struct device *dev = pcie->pci->dev; 1771 - struct qcom_pcie_port *port, *tmp; 1772 - int ret = -ENOENT; 1720 + int ret = -ENODEV; 1773 1721 1774 1722 for_each_available_child_of_node_scoped(dev->of_node, of_port) { 1775 1723 if (!of_node_is_type(of_port, "pci")) ··· 1783 1729 return ret; 1784 1730 1785 1731 err_port_del: 1786 - list_for_each_entry_safe(port, tmp, &pcie->ports, list) { 1732 + list_for_each_entry_safe(port, tmp_port, &pcie->ports, list) { 1733 + list_for_each_entry_safe(perst, tmp_perst, &port->perst, list) 1734 + list_del(&perst->list); 1787 1735 phy_exit(port->phy); 1788 1736 list_del(&port->list); 1789 1737 } ··· 1796 1740 static int qcom_pcie_parse_legacy_binding(struct qcom_pcie *pcie) 1797 1741 { 1798 1742 struct device *dev = pcie->pci->dev; 1743 + struct qcom_pcie_perst *perst; 1799 1744 struct qcom_pcie_port *port; 1800 1745 struct gpio_desc *reset; 1801 1746 struct phy *phy; ··· 1818 1761 if (!port) 1819 1762 return -ENOMEM; 1820 1763 1821 - port->reset = reset; 1764 + perst = devm_kzalloc(dev, sizeof(*perst), GFP_KERNEL); 1765 + if (!perst) 1766 + return -ENOMEM; 1767 + 1822 1768 port->phy = phy; 1823 1769 INIT_LIST_HEAD(&port->list); 1824 1770 list_add_tail(&port->list, &pcie->ports); 1771 + 1772 + perst->desc = reset; 1773 + INIT_LIST_HEAD(&port->perst); 1774 + INIT_LIST_HEAD(&perst->list); 1775 + list_add_tail(&perst->list, &port->perst); 1825 1776 1826 1777 return 0; 1827 1778 } 1828 1779 1829 1780 static int qcom_pcie_probe(struct platform_device *pdev) 1830 1781 { 1782 + struct qcom_pcie_perst *perst, *tmp_perst; 1783 + struct qcom_pcie_port *port, *tmp_port; 1831 1784 const struct qcom_pcie_cfg *pcie_cfg; 1832 1785 unsigned long max_freq = ULONG_MAX; 1833 - struct qcom_pcie_port *port, *tmp; 1834 1786 struct device *dev = &pdev->dev; 1835 1787 struct dev_pm_opp *opp; 1836 1788 struct qcom_pcie *pcie; ··· 1979 1913 1980 1914 ret = qcom_pcie_parse_ports(pcie); 1981 1915 if (ret) { 1982 - if (ret != -ENOENT) { 1916 + if (ret != -ENODEV) { 1983 1917 dev_err_probe(pci->dev, ret, 1984 1918 "Failed to parse Root Port: %d\n", ret); 1985 1919 goto err_pm_runtime_put; ··· 2011 1945 return 0; 2012 1946 2013 1947 err_phy_exit: 2014 - list_for_each_entry_safe(port, tmp, &pcie->ports, list) { 1948 + list_for_each_entry_safe(port, tmp_port, &pcie->ports, list) { 1949 + list_for_each_entry_safe(perst, tmp_perst, &port->perst, list) 1950 + list_del(&perst->list); 2015 1951 phy_exit(port->phy); 2016 1952 list_del(&port->list); 2017 1953 }