Skip to content

Commit e2efd31

Browse files
Mani-SadhasivamLorenzo Pieralisi
authored andcommitted
PCI: qcom-ep: Rely on the clocks supplied by devicetree
Generally, device drivers should just rely on the platform data like devicetree to supply the clocks required for the functioning of the peripheral. There is no need to hardcode the clk info in the driver. So get rid of the static clk info and obtain the platform supplied clks. The total number of clocks supplied is obtained using the devm_clk_bulk_get_all() API and used for the rest of the clk_bulk_ APIs. Link: https://lore.kernel.org/r/20220914075350.7992-3-manivannan.sadhasivam@linaro.org Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
1 parent f1bfbd0 commit e2efd31

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

drivers/pci/controller/dwc/pcie-qcom-ep.c

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,6 @@ enum qcom_pcie_ep_link_status {
130130
QCOM_PCIE_EP_LINK_DOWN,
131131
};
132132

133-
static struct clk_bulk_data qcom_pcie_ep_clks[] = {
134-
{ .id = "cfg" },
135-
{ .id = "aux" },
136-
{ .id = "bus_master" },
137-
{ .id = "bus_slave" },
138-
{ .id = "ref" },
139-
{ .id = "sleep" },
140-
{ .id = "slave_q2a" },
141-
};
142-
143133
/**
144134
* struct qcom_pcie_ep - Qualcomm PCIe Endpoint Controller
145135
* @pci: Designware PCIe controller struct
@@ -151,6 +141,8 @@ static struct clk_bulk_data qcom_pcie_ep_clks[] = {
151141
* @reset: PERST# GPIO
152142
* @wake: WAKE# GPIO
153143
* @phy: PHY controller block
144+
* @clks: PCIe clocks
145+
* @num_clks: PCIe clocks count
154146
* @perst_en: Flag for PERST enable
155147
* @perst_sep_en: Flag for PERST separation enable
156148
* @link_status: PCIe Link status
@@ -170,6 +162,9 @@ struct qcom_pcie_ep {
170162
struct gpio_desc *wake;
171163
struct phy *phy;
172164

165+
struct clk_bulk_data *clks;
166+
int num_clks;
167+
173168
u32 perst_en;
174169
u32 perst_sep_en;
175170

@@ -244,8 +239,7 @@ static int qcom_pcie_enable_resources(struct qcom_pcie_ep *pcie_ep)
244239
{
245240
int ret;
246241

247-
ret = clk_bulk_prepare_enable(ARRAY_SIZE(qcom_pcie_ep_clks),
248-
qcom_pcie_ep_clks);
242+
ret = clk_bulk_prepare_enable(pcie_ep->num_clks, pcie_ep->clks);
249243
if (ret)
250244
return ret;
251245

@@ -266,8 +260,7 @@ static int qcom_pcie_enable_resources(struct qcom_pcie_ep *pcie_ep)
266260
err_phy_exit:
267261
phy_exit(pcie_ep->phy);
268262
err_disable_clk:
269-
clk_bulk_disable_unprepare(ARRAY_SIZE(qcom_pcie_ep_clks),
270-
qcom_pcie_ep_clks);
263+
clk_bulk_disable_unprepare(pcie_ep->num_clks, pcie_ep->clks);
271264

272265
return ret;
273266
}
@@ -276,8 +269,7 @@ static void qcom_pcie_disable_resources(struct qcom_pcie_ep *pcie_ep)
276269
{
277270
phy_power_off(pcie_ep->phy);
278271
phy_exit(pcie_ep->phy);
279-
clk_bulk_disable_unprepare(ARRAY_SIZE(qcom_pcie_ep_clks),
280-
qcom_pcie_ep_clks);
272+
clk_bulk_disable_unprepare(pcie_ep->num_clks, pcie_ep->clks);
281273
}
282274

283275
static int qcom_pcie_perst_deassert(struct dw_pcie *pci)
@@ -495,10 +487,11 @@ static int qcom_pcie_ep_get_resources(struct platform_device *pdev,
495487
return ret;
496488
}
497489

498-
ret = devm_clk_bulk_get(dev, ARRAY_SIZE(qcom_pcie_ep_clks),
499-
qcom_pcie_ep_clks);
500-
if (ret)
501-
return ret;
490+
pcie_ep->num_clks = devm_clk_bulk_get_all(dev, &pcie_ep->clks);
491+
if (pcie_ep->num_clks < 0) {
492+
dev_err(dev, "Failed to get clocks\n");
493+
return pcie_ep->num_clks;
494+
}
502495

503496
pcie_ep->core_reset = devm_reset_control_get_exclusive(dev, "core");
504497
if (IS_ERR(pcie_ep->core_reset))

0 commit comments

Comments
 (0)