Skip to contentSkip to conversation

iommu/rockchip: Add support for multiple interface clocks

PATCH Superseded Chaoyi Chen 3 participants 5 messages Nov 26, 2025 – Nov 27, 2025

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover iommu/rockchip: Add support for multiple interface clocks

From: Chaoyi Chen <[email protected]>

Hi,

Some rockchip iommus require extra clocks besides aclk and interface clock, such as the iommus for NPU and RKVENC in RK3576.

This series adds support for these extra clocks, which are called iface_x.

Chaoyi Chen (2):
dt-bindings: iommu: rockchip: Add support for multiple interface
clocks
iommu/rockchip: Use devm_clk_bulk_get_all() to get multiple iface
clock

 .../bindings/iommu/rockchip,iommu.yaml        |  8 ++++++++
 drivers/iommu/rockchip-iommu.c                | 20 ++++---------------
 2 files changed, 12 insertions(+), 16 deletions(-)

--
2.51.1

#1 lore raw

PATCH 1/2 dt-bindings: iommu: rockchip: Add support for multiple interface clocks

From: Chaoyi Chen <[email protected]>

The iommu found on RK3576 NPU/RKVDEC may contains more than one interface clock.

---
 .../devicetree/bindings/iommu/rockchip,iommu.yaml         | 8 ++++++++
 1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/iommu/rockchip,iommu.yaml +8 -0
index 6ce41d11ff5e..11cc22a0b1d3 100644
@@ -42,14 +42,22 @@ properties:
     minItems: 1
 
   clocks:
+    minItems: 2
     items:
       - description: Core clock
       - description: Interface clock
+      - description: Interface clock 1
+      - description: Interface clock 2
+      - description: Interface clock 3
 
   clock-names:
+    minItems: 2
     items:
       - const: aclk
       - const: iface
+      - const: iface_1
+      - const: iface_2
+      - const: iface_3
 
   "#iommu-cells":
     const: 0
Signature · 1 line
2.51.1
#2 lore raw

Re: [PATCH 1/2] dt-bindings: iommu: rockchip: Add support for multiple interface clocks

Quoted 4 lines · Chaoyi Chen

From: Chaoyi Chen <[email protected]>

The iommu found on RK3576 NPU/RKVDEC may contains more than one interface clock.

So you need to restrict this per each variant. See writign schema doc in DT dir.

Best regards,
Krzysztof

#3 lore raw

Re: [PATCH 1/2] dt-bindings: iommu: rockchip: Add support for multiple interface clocks

Quoted 8 lines · Krzysztof Kozlowski
Quoted 4 lines · Chaoyi Chen

From: Chaoyi Chen <[email protected]>

The iommu found on RK3576 NPU/RKVDEC may contains more than one interface clock.

So you need to restrict this per each variant. See writign schema doc in DT dir.

Oh, I will rewrite it in v2. Thank you.

Quoted 6 lines

Best regards,
Krzysztof

Signature · 2 lines
Best, 
Chaoyi
#4 lore raw

PATCH 2/2 iommu/rockchip: Use devm_clk_bulk_get_all() to get multiple iface clock

In reply to Chaoyi Chen

From: Chaoyi Chen <[email protected]>

The iommu found on RK3576 NPU/RKVDEC may contains more than one interface clock.

Just use devm_clk_bulk_get_all() to get all the clocks and use them.

---
 drivers/iommu/rockchip-iommu.c | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)
drivers/iommu/rockchip-iommu.c +4 -16
index 0861dd469bd8..76f71fb679f8 100644
@@ -93,11 +93,6 @@ struct rk_iommu_domain {
 	struct iommu_domain domain;
 };
 
-/* list of clocks required by IOMMU */
-static const char * const rk_iommu_clocks[] = {
-	"aclk", "iface",
-};
-
 struct rk_iommu_ops {
 	phys_addr_t (*pt_address)(u32 dte);
 	u32 (*mk_dtentries)(dma_addr_t pt_dma);
@@ -1236,25 +1231,18 @@ static int rk_iommu_probe(struct platform_device *pdev)
 	iommu->reset_disabled = device_property_read_bool(dev,
 					"rockchip,disable-mmu-reset");
 
-	iommu->num_clocks = ARRAY_SIZE(rk_iommu_clocks);
-	iommu->clocks = devm_kcalloc(iommu->dev, iommu->num_clocks,
-				     sizeof(*iommu->clocks), GFP_KERNEL);
-	if (!iommu->clocks)
-		return -ENOMEM;
-
-	for (i = 0; i < iommu->num_clocks; ++i)
-		iommu->clocks[i].id = rk_iommu_clocks[i];
-
 	/*
 	 * iommu clocks should be present for all new devices and devicetrees
 	 * but there are older devicetrees without clocks out in the wild.
 	 * So clocks as optional for the time being.
 	 */
-	err = devm_clk_bulk_get(iommu->dev, iommu->num_clocks, iommu->clocks);
+	err = devm_clk_bulk_get_all(dev, &iommu->clocks);
 	if (err == -ENOENT)
 		iommu->num_clocks = 0;
-	else if (err)
+	else if (err < 0)
 		return err;
+	else
+		iommu->num_clocks = err;
 
 	err = clk_bulk_prepare(iommu->num_clocks, iommu->clocks);
 	if (err)
Signature · 1 line
2.51.1