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

PCI: qcom: Use clk bulk API for 2.4.0 controllers

Before introducing the QCS404 platform, which uses the same PCIe
controller as IPQ4019, migrate this to use the bulk clock API, in order
to make the error paths slighly cleaner.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Niklas Cassel <niklas.cassel@linaro.org>
Reviewed-by: Vinod Koul <vkoul@kernel.org>
Acked-by: Stanimir Varbanov <svarbanov@mm-sol.com>

authored by

Bjorn Andersson and committed by
Lorenzo Pieralisi
5aa18097 a188339c

+16 -37
+16 -37
drivers/pci/controller/dwc/pcie-qcom.c
··· 112 112 struct regulator_bulk_data supplies[QCOM_PCIE_2_3_2_MAX_SUPPLY]; 113 113 }; 114 114 115 + #define QCOM_PCIE_2_4_0_MAX_CLOCKS 3 115 116 struct qcom_pcie_resources_2_4_0 { 116 - struct clk *aux_clk; 117 - struct clk *master_clk; 118 - struct clk *slave_clk; 117 + struct clk_bulk_data clks[QCOM_PCIE_2_4_0_MAX_CLOCKS]; 118 + int num_clks; 119 119 struct reset_control *axi_m_reset; 120 120 struct reset_control *axi_s_reset; 121 121 struct reset_control *pipe_reset; ··· 638 638 struct qcom_pcie_resources_2_4_0 *res = &pcie->res.v2_4_0; 639 639 struct dw_pcie *pci = pcie->pci; 640 640 struct device *dev = pci->dev; 641 + int ret; 641 642 642 - res->aux_clk = devm_clk_get(dev, "aux"); 643 - if (IS_ERR(res->aux_clk)) 644 - return PTR_ERR(res->aux_clk); 643 + res->clks[0].id = "aux"; 644 + res->clks[1].id = "master_bus"; 645 + res->clks[2].id = "slave_bus"; 645 646 646 - res->master_clk = devm_clk_get(dev, "master_bus"); 647 - if (IS_ERR(res->master_clk)) 648 - return PTR_ERR(res->master_clk); 647 + res->num_clks = 3; 649 648 650 - res->slave_clk = devm_clk_get(dev, "slave_bus"); 651 - if (IS_ERR(res->slave_clk)) 652 - return PTR_ERR(res->slave_clk); 649 + ret = devm_clk_bulk_get(dev, res->num_clks, res->clks); 650 + if (ret < 0) 651 + return ret; 653 652 654 653 res->axi_m_reset = devm_reset_control_get_exclusive(dev, "axi_m"); 655 654 if (IS_ERR(res->axi_m_reset)) ··· 718 719 reset_control_assert(res->axi_m_sticky_reset); 719 720 reset_control_assert(res->pwr_reset); 720 721 reset_control_assert(res->ahb_reset); 721 - clk_disable_unprepare(res->aux_clk); 722 - clk_disable_unprepare(res->master_clk); 723 - clk_disable_unprepare(res->slave_clk); 722 + clk_bulk_disable_unprepare(res->num_clks, res->clks); 724 723 } 725 724 726 725 static int qcom_pcie_init_2_4_0(struct qcom_pcie *pcie) ··· 847 850 848 851 usleep_range(10000, 12000); 849 852 850 - ret = clk_prepare_enable(res->aux_clk); 851 - if (ret) { 852 - dev_err(dev, "cannot prepare/enable iface clock\n"); 853 - goto err_clk_aux; 854 - } 855 - 856 - ret = clk_prepare_enable(res->master_clk); 857 - if (ret) { 858 - dev_err(dev, "cannot prepare/enable core clock\n"); 859 - goto err_clk_axi_m; 860 - } 861 - 862 - ret = clk_prepare_enable(res->slave_clk); 863 - if (ret) { 864 - dev_err(dev, "cannot prepare/enable phy clock\n"); 865 - goto err_clk_axi_s; 866 - } 853 + ret = clk_bulk_prepare_enable(res->num_clks, res->clks); 854 + if (ret) 855 + goto err_clks; 867 856 868 857 /* enable PCIe clocks and resets */ 869 858 val = readl(pcie->parf + PCIE20_PARF_PHY_CTRL); ··· 874 891 875 892 return 0; 876 893 877 - err_clk_axi_s: 878 - clk_disable_unprepare(res->master_clk); 879 - err_clk_axi_m: 880 - clk_disable_unprepare(res->aux_clk); 881 - err_clk_aux: 894 + err_clks: 882 895 reset_control_assert(res->ahb_reset); 883 896 err_rst_ahb: 884 897 reset_control_assert(res->pwr_reset);