Thread (9 messages) 9 messages, 5 authors, 2025-09-17

Re: [PATCH v2 4/4] pmdomain: mediatek: Add power domain driver for MT8189 SoC

From: Simon Horman <horms@kernel.org>
Date: 2025-09-13 09:16:11
Also in: linux-clk, linux-devicetree, linux-mediatek, linux-pm, lkml, netdev

On Fri, Sep 12, 2025 at 08:04:53PM +0800, irving.ch.lin wrote:
From: Irving-ch Lin <redacted>

Introduce a new power domain (pmd) driver for the MediaTek mt8189 SoC.
This driver ports and refines the power domain framework, dividing
hardware blocks (CPU, GPU, peripherals, etc.) into independent power
domains for precise and energy-efficient power management.

Signed-off-by: Irving-ch Lin <redacted>
...
quoted hunk ↗ jump to hunk
diff --git a/drivers/pmdomain/mediatek/mtk-scpsys.c b/drivers/pmdomain/mediatek/mtk-scpsys.c
...
quoted hunk ↗ jump to hunk
@@ -419,54 +848,145 @@ static void init_clks(struct platform_device *pdev, struct clk **clk)
 		clk[i] = devm_clk_get(&pdev->dev, clk_names[i]);
 }
 
+static int init_subsys_clks(struct platform_device *pdev,
+			    const char *prefix, struct clk **clk)
+{
+	struct device_node *node = pdev->dev.of_node;
+	u32 prefix_len, sub_clk_cnt = 0;
+	struct property *prop;
+	const char *clk_name;
+
+	if (!node) {
+		dev_err(&pdev->dev, "Cannot find scpsys node: %ld\n",
+			PTR_ERR(node));
+		return PTR_ERR(node);
Hi Irving-ch,

Here node is NULL. So PTR_ERR(node) will be zero.
This is probably not what you are after here.

Flagged by Smatch
+	}
+
+	prefix_len = strlen(prefix);
+
+	of_property_for_each_string(node, "clock-names", prop, clk_name) {
+		if (!strncmp(clk_name, prefix, prefix_len) &&
+		    (strlen(clk_name) > prefix_len + 1) &&
+		    (clk_name[prefix_len] == '-')) {
+			if (sub_clk_cnt >= MAX_SUBSYS_CLKS) {
+				dev_err(&pdev->dev,
+					"subsys clk out of range %d\n",
+					sub_clk_cnt);
+				return -EINVAL;
+			}
+
+			clk[sub_clk_cnt] = devm_clk_get(&pdev->dev, clk_name);
+
+			if (IS_ERR(clk[sub_clk_cnt])) {
+				dev_err(&pdev->dev,
+					"Subsys clk get fail %ld\n",
+					PTR_ERR(clk[sub_clk_cnt]));
+				return PTR_ERR(clk[sub_clk_cnt]);
+			}
+			sub_clk_cnt++;
+		}
+	}
+
+	return sub_clk_cnt;
+}
...
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help