Skip to content

Commit 5130464

Browse files
konradybcioandersson
authored andcommitted
firmware: qcom_scm: Always try to consume all three clocks
The code for handling more than 1 clock is a bit messy and requires one to add new, SoC-specific compatibles if one wants to attach a clock. Switch devm_clk_get to devm_clk_get_optional to prevent throwing it from throwing errors when the clock is absent and defer checking the clock requirements to dt schema. This lets us get rid of compatibles that aren't necessary for backwards compatibility *and* will hopefully prevent the addition of meaningless new compatibles. Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org> Link: https://lore.kernel.org/r/20230623-topic-scm_cleanup-v2-1-9db8c583138d@linaro.org Signed-off-by: Bjorn Andersson <andersson@kernel.org>
1 parent 7dc3ea5 commit 5130464

1 file changed

Lines changed: 13 additions & 60 deletions

File tree

drivers/firmware/qcom_scm.c

Lines changed: 13 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@
2626
static bool download_mode = IS_ENABLED(CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT);
2727
module_param(download_mode, bool, 0);
2828

29-
#define SCM_HAS_CORE_CLK BIT(0)
30-
#define SCM_HAS_IFACE_CLK BIT(1)
31-
#define SCM_HAS_BUS_CLK BIT(2)
32-
3329
struct qcom_scm {
3430
struct device *dev;
3531
struct clk *core_clk;
@@ -1405,7 +1401,6 @@ static irqreturn_t qcom_scm_irq_handler(int irq, void *data)
14051401
static int qcom_scm_probe(struct platform_device *pdev)
14061402
{
14071403
struct qcom_scm *scm;
1408-
unsigned long clks;
14091404
int irq, ret;
14101405

14111406
scm = devm_kzalloc(&pdev->dev, sizeof(*scm), GFP_KERNEL);
@@ -1418,50 +1413,27 @@ static int qcom_scm_probe(struct platform_device *pdev)
14181413

14191414
mutex_init(&scm->scm_bw_lock);
14201415

1421-
clks = (unsigned long)of_device_get_match_data(&pdev->dev);
1422-
14231416
scm->path = devm_of_icc_get(&pdev->dev, NULL);
14241417
if (IS_ERR(scm->path))
14251418
return dev_err_probe(&pdev->dev, PTR_ERR(scm->path),
14261419
"failed to acquire interconnect path\n");
14271420

1428-
scm->core_clk = devm_clk_get(&pdev->dev, "core");
1421+
scm->core_clk = devm_clk_get_optional(&pdev->dev, "core");
14291422
if (IS_ERR(scm->core_clk)) {
14301423
if (PTR_ERR(scm->core_clk) == -EPROBE_DEFER)
14311424
return PTR_ERR(scm->core_clk);
1432-
1433-
if (clks & SCM_HAS_CORE_CLK) {
1434-
dev_err(&pdev->dev, "failed to acquire core clk\n");
1435-
return PTR_ERR(scm->core_clk);
1436-
}
1437-
1438-
scm->core_clk = NULL;
14391425
}
14401426

1441-
scm->iface_clk = devm_clk_get(&pdev->dev, "iface");
1427+
scm->iface_clk = devm_clk_get_optional(&pdev->dev, "iface");
14421428
if (IS_ERR(scm->iface_clk)) {
14431429
if (PTR_ERR(scm->iface_clk) == -EPROBE_DEFER)
14441430
return PTR_ERR(scm->iface_clk);
1445-
1446-
if (clks & SCM_HAS_IFACE_CLK) {
1447-
dev_err(&pdev->dev, "failed to acquire iface clk\n");
1448-
return PTR_ERR(scm->iface_clk);
1449-
}
1450-
1451-
scm->iface_clk = NULL;
14521431
}
14531432

1454-
scm->bus_clk = devm_clk_get(&pdev->dev, "bus");
1433+
scm->bus_clk = devm_clk_get_optional(&pdev->dev, "bus");
14551434
if (IS_ERR(scm->bus_clk)) {
14561435
if (PTR_ERR(scm->bus_clk) == -EPROBE_DEFER)
14571436
return PTR_ERR(scm->bus_clk);
1458-
1459-
if (clks & SCM_HAS_BUS_CLK) {
1460-
dev_err(&pdev->dev, "failed to acquire bus clk\n");
1461-
return PTR_ERR(scm->bus_clk);
1462-
}
1463-
1464-
scm->bus_clk = NULL;
14651437
}
14661438

14671439
scm->reset.ops = &qcom_scm_pas_reset_ops;
@@ -1512,38 +1484,19 @@ static void qcom_scm_shutdown(struct platform_device *pdev)
15121484
}
15131485

15141486
static const struct of_device_id qcom_scm_dt_match[] = {
1515-
{ .compatible = "qcom,scm-apq8064",
1516-
/* FIXME: This should have .data = (void *) SCM_HAS_CORE_CLK */
1517-
},
1518-
{ .compatible = "qcom,scm-apq8084", .data = (void *)(SCM_HAS_CORE_CLK |
1519-
SCM_HAS_IFACE_CLK |
1520-
SCM_HAS_BUS_CLK)
1521-
},
1487+
{ .compatible = "qcom,scm-apq8064" },
1488+
{ .compatible = "qcom,scm-apq8084" },
15221489
{ .compatible = "qcom,scm-ipq4019" },
1523-
{ .compatible = "qcom,scm-mdm9607", .data = (void *)(SCM_HAS_CORE_CLK |
1524-
SCM_HAS_IFACE_CLK |
1525-
SCM_HAS_BUS_CLK) },
1526-
{ .compatible = "qcom,scm-msm8660", .data = (void *) SCM_HAS_CORE_CLK },
1527-
{ .compatible = "qcom,scm-msm8960", .data = (void *) SCM_HAS_CORE_CLK },
1528-
{ .compatible = "qcom,scm-msm8916", .data = (void *)(SCM_HAS_CORE_CLK |
1529-
SCM_HAS_IFACE_CLK |
1530-
SCM_HAS_BUS_CLK)
1531-
},
1532-
{ .compatible = "qcom,scm-msm8953", .data = (void *)(SCM_HAS_CORE_CLK |
1533-
SCM_HAS_IFACE_CLK |
1534-
SCM_HAS_BUS_CLK)
1535-
},
1536-
{ .compatible = "qcom,scm-msm8974", .data = (void *)(SCM_HAS_CORE_CLK |
1537-
SCM_HAS_IFACE_CLK |
1538-
SCM_HAS_BUS_CLK)
1539-
},
1540-
{ .compatible = "qcom,scm-msm8976", .data = (void *)(SCM_HAS_CORE_CLK |
1541-
SCM_HAS_IFACE_CLK |
1542-
SCM_HAS_BUS_CLK)
1543-
},
1490+
{ .compatible = "qcom,scm-mdm9607" },
1491+
{ .compatible = "qcom,scm-msm8660" },
1492+
{ .compatible = "qcom,scm-msm8960" },
1493+
{ .compatible = "qcom,scm-msm8916" },
1494+
{ .compatible = "qcom,scm-msm8953" },
1495+
{ .compatible = "qcom,scm-msm8974" },
1496+
{ .compatible = "qcom,scm-msm8976" },
15441497
{ .compatible = "qcom,scm-msm8994" },
15451498
{ .compatible = "qcom,scm-msm8996" },
1546-
{ .compatible = "qcom,scm-sm6375", .data = (void *)SCM_HAS_CORE_CLK },
1499+
{ .compatible = "qcom,scm-sm6375" },
15471500
{ .compatible = "qcom,scm" },
15481501
{}
15491502
};

0 commit comments

Comments
 (0)