Commit caa2347d authored by Konrad Dybcio's avatar Konrad Dybcio Committed by Bjorn Andersson

clk: qcom: smd-rpm: Keep one rpm handle for all clocks

For no apparent reason (as there's just one RPM per SoC), all clocks
currently store a copy of a pointer to smd_rpm. Introduce a single,
global one to save up on space in each clk definition.

bloat-o-meter reports:

Total: Before=41887, After=40843, chg -2.49%
Signed-off-by: default avatarKonrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: default avatarBjorn Andersson <andersson@kernel.org>
Link: https://lore.kernel.org/r/20230501130400.107771-1-konrad.dybcio@linaro.org
parent 3e4d1795
...@@ -156,6 +156,8 @@ ...@@ -156,6 +156,8 @@
#define to_clk_smd_rpm(_hw) container_of(_hw, struct clk_smd_rpm, hw) #define to_clk_smd_rpm(_hw) container_of(_hw, struct clk_smd_rpm, hw)
static struct qcom_smd_rpm *rpmcc_smd_rpm;
struct clk_smd_rpm { struct clk_smd_rpm {
const int rpm_res_type; const int rpm_res_type;
const int rpm_key; const int rpm_key;
...@@ -166,7 +168,6 @@ struct clk_smd_rpm { ...@@ -166,7 +168,6 @@ struct clk_smd_rpm {
struct clk_smd_rpm *peer; struct clk_smd_rpm *peer;
struct clk_hw hw; struct clk_hw hw;
unsigned long rate; unsigned long rate;
struct qcom_smd_rpm *rpm;
}; };
struct clk_smd_rpm_req { struct clk_smd_rpm_req {
...@@ -191,12 +192,12 @@ static int clk_smd_rpm_handoff(struct clk_smd_rpm *r) ...@@ -191,12 +192,12 @@ static int clk_smd_rpm_handoff(struct clk_smd_rpm *r)
.value = cpu_to_le32(r->branch ? 1 : INT_MAX), .value = cpu_to_le32(r->branch ? 1 : INT_MAX),
}; };
ret = qcom_rpm_smd_write(r->rpm, QCOM_SMD_RPM_ACTIVE_STATE, ret = qcom_rpm_smd_write(rpmcc_smd_rpm, QCOM_SMD_RPM_ACTIVE_STATE,
r->rpm_res_type, r->rpm_clk_id, &req, r->rpm_res_type, r->rpm_clk_id, &req,
sizeof(req)); sizeof(req));
if (ret) if (ret)
return ret; return ret;
ret = qcom_rpm_smd_write(r->rpm, QCOM_SMD_RPM_SLEEP_STATE, ret = qcom_rpm_smd_write(rpmcc_smd_rpm, QCOM_SMD_RPM_SLEEP_STATE,
r->rpm_res_type, r->rpm_clk_id, &req, r->rpm_res_type, r->rpm_clk_id, &req,
sizeof(req)); sizeof(req));
if (ret) if (ret)
...@@ -214,7 +215,7 @@ static int clk_smd_rpm_set_rate_active(struct clk_smd_rpm *r, ...@@ -214,7 +215,7 @@ static int clk_smd_rpm_set_rate_active(struct clk_smd_rpm *r,
.value = cpu_to_le32(DIV_ROUND_UP(rate, 1000)), /* to kHz */ .value = cpu_to_le32(DIV_ROUND_UP(rate, 1000)), /* to kHz */
}; };
return qcom_rpm_smd_write(r->rpm, QCOM_SMD_RPM_ACTIVE_STATE, return qcom_rpm_smd_write(rpmcc_smd_rpm, QCOM_SMD_RPM_ACTIVE_STATE,
r->rpm_res_type, r->rpm_clk_id, &req, r->rpm_res_type, r->rpm_clk_id, &req,
sizeof(req)); sizeof(req));
} }
...@@ -228,7 +229,7 @@ static int clk_smd_rpm_set_rate_sleep(struct clk_smd_rpm *r, ...@@ -228,7 +229,7 @@ static int clk_smd_rpm_set_rate_sleep(struct clk_smd_rpm *r,
.value = cpu_to_le32(DIV_ROUND_UP(rate, 1000)), /* to kHz */ .value = cpu_to_le32(DIV_ROUND_UP(rate, 1000)), /* to kHz */
}; };
return qcom_rpm_smd_write(r->rpm, QCOM_SMD_RPM_SLEEP_STATE, return qcom_rpm_smd_write(rpmcc_smd_rpm, QCOM_SMD_RPM_SLEEP_STATE,
r->rpm_res_type, r->rpm_clk_id, &req, r->rpm_res_type, r->rpm_clk_id, &req,
sizeof(req)); sizeof(req));
} }
...@@ -395,7 +396,7 @@ static unsigned long clk_smd_rpm_recalc_rate(struct clk_hw *hw, ...@@ -395,7 +396,7 @@ static unsigned long clk_smd_rpm_recalc_rate(struct clk_hw *hw,
return r->rate; return r->rate;
} }
static int clk_smd_rpm_enable_scaling(struct qcom_smd_rpm *rpm) static int clk_smd_rpm_enable_scaling(void)
{ {
int ret; int ret;
struct clk_smd_rpm_req req = { struct clk_smd_rpm_req req = {
...@@ -404,7 +405,7 @@ static int clk_smd_rpm_enable_scaling(struct qcom_smd_rpm *rpm) ...@@ -404,7 +405,7 @@ static int clk_smd_rpm_enable_scaling(struct qcom_smd_rpm *rpm)
.value = cpu_to_le32(1), .value = cpu_to_le32(1),
}; };
ret = qcom_rpm_smd_write(rpm, QCOM_SMD_RPM_SLEEP_STATE, ret = qcom_rpm_smd_write(rpmcc_smd_rpm, QCOM_SMD_RPM_SLEEP_STATE,
QCOM_SMD_RPM_MISC_CLK, QCOM_SMD_RPM_MISC_CLK,
QCOM_RPM_SCALING_ENABLE_ID, &req, sizeof(req)); QCOM_RPM_SCALING_ENABLE_ID, &req, sizeof(req));
if (ret) { if (ret) {
...@@ -412,7 +413,7 @@ static int clk_smd_rpm_enable_scaling(struct qcom_smd_rpm *rpm) ...@@ -412,7 +413,7 @@ static int clk_smd_rpm_enable_scaling(struct qcom_smd_rpm *rpm)
return ret; return ret;
} }
ret = qcom_rpm_smd_write(rpm, QCOM_SMD_RPM_ACTIVE_STATE, ret = qcom_rpm_smd_write(rpmcc_smd_rpm, QCOM_SMD_RPM_ACTIVE_STATE,
QCOM_SMD_RPM_MISC_CLK, QCOM_SMD_RPM_MISC_CLK,
QCOM_RPM_SCALING_ENABLE_ID, &req, sizeof(req)); QCOM_RPM_SCALING_ENABLE_ID, &req, sizeof(req));
if (ret) { if (ret) {
...@@ -1301,12 +1302,11 @@ static int rpm_smd_clk_probe(struct platform_device *pdev) ...@@ -1301,12 +1302,11 @@ static int rpm_smd_clk_probe(struct platform_device *pdev)
{ {
int ret; int ret;
size_t num_clks, i; size_t num_clks, i;
struct qcom_smd_rpm *rpm;
struct clk_smd_rpm **rpm_smd_clks; struct clk_smd_rpm **rpm_smd_clks;
const struct rpm_smd_clk_desc *desc; const struct rpm_smd_clk_desc *desc;
rpm = dev_get_drvdata(pdev->dev.parent); rpmcc_smd_rpm = dev_get_drvdata(pdev->dev.parent);
if (!rpm) { if (!rpmcc_smd_rpm) {
dev_err(&pdev->dev, "Unable to retrieve handle to RPM\n"); dev_err(&pdev->dev, "Unable to retrieve handle to RPM\n");
return -ENODEV; return -ENODEV;
} }
...@@ -1322,14 +1322,12 @@ static int rpm_smd_clk_probe(struct platform_device *pdev) ...@@ -1322,14 +1322,12 @@ static int rpm_smd_clk_probe(struct platform_device *pdev)
if (!rpm_smd_clks[i]) if (!rpm_smd_clks[i])
continue; continue;
rpm_smd_clks[i]->rpm = rpm;
ret = clk_smd_rpm_handoff(rpm_smd_clks[i]); ret = clk_smd_rpm_handoff(rpm_smd_clks[i]);
if (ret) if (ret)
goto err; goto err;
} }
ret = clk_smd_rpm_enable_scaling(rpm); ret = clk_smd_rpm_enable_scaling();
if (ret) if (ret)
goto err; goto err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment