Skip to content

Commit b89ff41

Browse files
Prasad Malisettybjorn-helgaas
authored andcommitted
PCI: qcom: Replace ops with struct pcie_cfg in pcie match data
Add struct qcom_pcie_cfg as match data for all platforms. Assign appropriate platform ops into struct qcom_pcie_cfg and read using of_device_get_match_data() in qcom_pcie_probe(). Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Prasad Malisetty <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Stephen Boyd <[email protected]>
1 parent 7935292 commit b89ff41

File tree

1 file changed

+55
-11
lines changed

1 file changed

+55
-11
lines changed

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

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ struct qcom_pcie_ops {
189189
int (*config_sid)(struct qcom_pcie *pcie);
190190
};
191191

192+
struct qcom_pcie_cfg {
193+
const struct qcom_pcie_ops *ops;
194+
};
195+
192196
struct qcom_pcie {
193197
struct dw_pcie *pci;
194198
void __iomem *parf; /* DT parf */
@@ -1456,6 +1460,38 @@ static const struct qcom_pcie_ops ops_1_9_0 = {
14561460
.config_sid = qcom_pcie_config_sid_sm8250,
14571461
};
14581462

1463+
static const struct qcom_pcie_cfg apq8084_cfg = {
1464+
.ops = &ops_1_0_0,
1465+
};
1466+
1467+
static const struct qcom_pcie_cfg ipq8064_cfg = {
1468+
.ops = &ops_2_1_0,
1469+
};
1470+
1471+
static const struct qcom_pcie_cfg msm8996_cfg = {
1472+
.ops = &ops_2_3_2,
1473+
};
1474+
1475+
static const struct qcom_pcie_cfg ipq8074_cfg = {
1476+
.ops = &ops_2_3_3,
1477+
};
1478+
1479+
static const struct qcom_pcie_cfg ipq4019_cfg = {
1480+
.ops = &ops_2_4_0,
1481+
};
1482+
1483+
static const struct qcom_pcie_cfg sdm845_cfg = {
1484+
.ops = &ops_2_7_0,
1485+
};
1486+
1487+
static const struct qcom_pcie_cfg sm8250_cfg = {
1488+
.ops = &ops_1_9_0,
1489+
};
1490+
1491+
static const struct qcom_pcie_cfg sc7280_cfg = {
1492+
.ops = &ops_1_9_0,
1493+
};
1494+
14591495
static const struct dw_pcie_ops dw_pcie_ops = {
14601496
.link_up = qcom_pcie_link_up,
14611497
.start_link = qcom_pcie_start_link,
@@ -1467,6 +1503,7 @@ static int qcom_pcie_probe(struct platform_device *pdev)
14671503
struct pcie_port *pp;
14681504
struct dw_pcie *pci;
14691505
struct qcom_pcie *pcie;
1506+
const struct qcom_pcie_cfg *pcie_cfg;
14701507
int ret;
14711508

14721509
pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
@@ -1488,7 +1525,13 @@ static int qcom_pcie_probe(struct platform_device *pdev)
14881525

14891526
pcie->pci = pci;
14901527

1491-
pcie->ops = of_device_get_match_data(dev);
1528+
pcie_cfg = of_device_get_match_data(dev);
1529+
if (!pcie_cfg || !pcie_cfg->ops) {
1530+
dev_err(dev, "Invalid platform data\n");
1531+
return -EINVAL;
1532+
}
1533+
1534+
pcie->ops = pcie_cfg->ops;
14921535

14931536
pcie->reset = devm_gpiod_get_optional(dev, "perst", GPIOD_OUT_HIGH);
14941537
if (IS_ERR(pcie->reset)) {
@@ -1545,16 +1588,17 @@ static int qcom_pcie_probe(struct platform_device *pdev)
15451588
}
15461589

15471590
static const struct of_device_id qcom_pcie_match[] = {
1548-
{ .compatible = "qcom,pcie-apq8084", .data = &ops_1_0_0 },
1549-
{ .compatible = "qcom,pcie-ipq8064", .data = &ops_2_1_0 },
1550-
{ .compatible = "qcom,pcie-ipq8064-v2", .data = &ops_2_1_0 },
1551-
{ .compatible = "qcom,pcie-apq8064", .data = &ops_2_1_0 },
1552-
{ .compatible = "qcom,pcie-msm8996", .data = &ops_2_3_2 },
1553-
{ .compatible = "qcom,pcie-ipq8074", .data = &ops_2_3_3 },
1554-
{ .compatible = "qcom,pcie-ipq4019", .data = &ops_2_4_0 },
1555-
{ .compatible = "qcom,pcie-qcs404", .data = &ops_2_4_0 },
1556-
{ .compatible = "qcom,pcie-sdm845", .data = &ops_2_7_0 },
1557-
{ .compatible = "qcom,pcie-sm8250", .data = &ops_1_9_0 },
1591+
{ .compatible = "qcom,pcie-apq8084", .data = &apq8084_cfg },
1592+
{ .compatible = "qcom,pcie-ipq8064", .data = &ipq8064_cfg },
1593+
{ .compatible = "qcom,pcie-ipq8064-v2", .data = &ipq8064_cfg },
1594+
{ .compatible = "qcom,pcie-apq8064", .data = &ipq8064_cfg },
1595+
{ .compatible = "qcom,pcie-msm8996", .data = &msm8996_cfg },
1596+
{ .compatible = "qcom,pcie-ipq8074", .data = &ipq8074_cfg },
1597+
{ .compatible = "qcom,pcie-ipq4019", .data = &ipq4019_cfg },
1598+
{ .compatible = "qcom,pcie-qcs404", .data = &ipq4019_cfg },
1599+
{ .compatible = "qcom,pcie-sdm845", .data = &sdm845_cfg },
1600+
{ .compatible = "qcom,pcie-sm8250", .data = &sm8250_cfg },
1601+
{ .compatible = "qcom,pcie-sc7280", .data = &sc7280_cfg },
15581602
{ }
15591603
};
15601604

0 commit comments

Comments
 (0)