From cdc3459d092e015123dfae32fe79320d1479205e Mon Sep 17 00:00:00 2001 From: Xubin Bai Date: Tue, 2 Aug 2022 21:37:58 +0800 Subject: [PATCH] clk: qcom: Mark the parent's clock of critical-devices as critical MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The clocks of devices with the “qcom,critical-devices” property are marked as critical and can be enabled on default, the parent's clocks of these child critical-devices also need to be marked as critical. Rather than adding child and parent devices in the dts property "qcom,critical-devices", it's better to automatically mark the clock of parent device as critical. Change-Id: If7b0f53c45194dbc0cd41e13316101a9149a4dc8 Signed-off-by: Xubin Bai --- drivers/clk/qcom/common.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c index 88cce2535199..21f5c2ae2354 100644 --- a/drivers/clk/qcom/common.c +++ b/drivers/clk/qcom/common.c @@ -252,26 +252,29 @@ static void qcom_cc_set_critical(struct device *dev, struct qcom_cc *cc) } of_property_for_each_u32(dev->of_node, "qcom,critical-devices", prop, p, i) { - np = of_find_node_by_phandle(i); - if (!np) - continue; - - cnt = of_count_phandle_with_args(np, "clocks", "#clock-cells"); - - for (i = 0; i < cnt; i++) { - of_parse_phandle_with_args(np, "clocks", "#clock-cells", - i, &args); - clock_idx = args.args[0]; - - if (args.np != dev->of_node || clock_idx >= cc->num_rclks) + for (np = of_find_node_by_phandle(i); np; np = of_get_parent(np)) { + if (!of_property_read_bool(np, "clocks")) { + of_node_put(np); continue; + } - if (cc->rclks[clock_idx]) - cc->rclks[clock_idx]->flags |= QCOM_CLK_IS_CRITICAL; - of_node_put(args.np); + cnt = of_count_phandle_with_args(np, "clocks", "#clock-cells"); + + for (i = 0; i < cnt; i++) { + of_parse_phandle_with_args(np, "clocks", "#clock-cells", + i, &args); + clock_idx = args.args[0]; + + if (args.np != dev->of_node || clock_idx >= cc->num_rclks) + continue; + + if (cc->rclks[clock_idx]) + cc->rclks[clock_idx]->flags |= QCOM_CLK_IS_CRITICAL; + of_node_put(args.np); + } + + of_node_put(np); } - - of_node_put(np); } }