@@ -189,6 +189,10 @@ struct qcom_pcie_ops {
189
189
int (* config_sid )(struct qcom_pcie * pcie );
190
190
};
191
191
192
+ struct qcom_pcie_cfg {
193
+ const struct qcom_pcie_ops * ops ;
194
+ };
195
+
192
196
struct qcom_pcie {
193
197
struct dw_pcie * pci ;
194
198
void __iomem * parf ; /* DT parf */
@@ -1456,6 +1460,38 @@ static const struct qcom_pcie_ops ops_1_9_0 = {
1456
1460
.config_sid = qcom_pcie_config_sid_sm8250 ,
1457
1461
};
1458
1462
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
+
1459
1495
static const struct dw_pcie_ops dw_pcie_ops = {
1460
1496
.link_up = qcom_pcie_link_up ,
1461
1497
.start_link = qcom_pcie_start_link ,
@@ -1467,6 +1503,7 @@ static int qcom_pcie_probe(struct platform_device *pdev)
1467
1503
struct pcie_port * pp ;
1468
1504
struct dw_pcie * pci ;
1469
1505
struct qcom_pcie * pcie ;
1506
+ const struct qcom_pcie_cfg * pcie_cfg ;
1470
1507
int ret ;
1471
1508
1472
1509
pcie = devm_kzalloc (dev , sizeof (* pcie ), GFP_KERNEL );
@@ -1488,7 +1525,13 @@ static int qcom_pcie_probe(struct platform_device *pdev)
1488
1525
1489
1526
pcie -> pci = pci ;
1490
1527
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 ;
1492
1535
1493
1536
pcie -> reset = devm_gpiod_get_optional (dev , "perst" , GPIOD_OUT_HIGH );
1494
1537
if (IS_ERR (pcie -> reset )) {
@@ -1545,16 +1588,17 @@ static int qcom_pcie_probe(struct platform_device *pdev)
1545
1588
}
1546
1589
1547
1590
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 },
1558
1602
{ }
1559
1603
};
1560
1604
0 commit comments