[RFC PATCH v4 3/9] accel: rocket: Add RK3568 SoC support
MidG971
midgy971 at gmail.com
Sat Jun 13 00:01:10 PDT 2026
From: Midgy BALON <midgy971 at gmail.com>
The RK3568 has a single core of the same NVDLA-derived NPU IP as the
RK3588, with a 32-bit AXI master. Add rk3568_soc_data and its
compatible.
Unlike the RK3588, the RK3568 NPU's compute clock is a PVTPLL managed by
TF-A via SCMI; start it from an noc_init callback with a real rate change
(an intermediate rate defeats the clock framework's unchanged-rate
shortcut). Powering on and de-idling the NPU NoC are left to the power
domain (genpd), which performs them when the IOMMU supplier is resumed,
so the driver does not poke the PMU directly.
If noc_init fails, unwind through rocket_core_fini() so the core is torn
down completely rather than leaking the runtime-PM and IOMMU state.
Signed-off-by: Midgy BALON <midgy971 at gmail.com>
---
drivers/accel/rocket/rocket_core.c | 9 +++++++++
drivers/accel/rocket/rocket_core.h | 3 +++
drivers/accel/rocket/rocket_drv.c | 31 ++++++++++++++++++++++++++++++
3 files changed, 43 insertions(+)
diff --git a/drivers/accel/rocket/rocket_core.c b/drivers/accel/rocket/rocket_core.c
index 09c445af7de73..779e951596a15 100644
--- a/drivers/accel/rocket/rocket_core.c
+++ b/drivers/accel/rocket/rocket_core.c
@@ -88,6 +88,15 @@ int rocket_core_init(struct rocket_core *core)
return err;
}
+ if (core->soc_data->noc_init) {
+ err = core->soc_data->noc_init(core);
+ if (err) {
+ pm_runtime_put_sync(dev);
+ rocket_core_fini(core);
+ return err;
+ }
+ }
+
version = rocket_pc_readl(core, VERSION);
version += rocket_pc_readl(core, VERSION_NUM) & 0xffff;
diff --git a/drivers/accel/rocket/rocket_core.h b/drivers/accel/rocket/rocket_core.h
index d6421251670dc..5a145ba8c5a92 100644
--- a/drivers/accel/rocket/rocket_core.h
+++ b/drivers/accel/rocket/rocket_core.h
@@ -18,10 +18,13 @@ struct rocket_core;
* struct rocket_soc_data - per-SoC configuration data
* @num_cores: Number of NPU cores in this SoC.
* @dma_bits: Physical address width reachable by the NPU's AXI master.
+ * @noc_init: Optional callback to bring up the NPU before it is reachable.
+ * Used on RK3568 to start the PVTPLL compute clock via SCMI.
*/
struct rocket_soc_data {
unsigned int num_cores;
unsigned int dma_bits;
+ int (*noc_init)(struct rocket_core *core);
};
#define rocket_pc_readl(core, reg) \
diff --git a/drivers/accel/rocket/rocket_drv.c b/drivers/accel/rocket/rocket_drv.c
index f0beed2d522c7..86484110ad6f0 100644
--- a/drivers/accel/rocket/rocket_drv.c
+++ b/drivers/accel/rocket/rocket_drv.c
@@ -10,6 +10,7 @@
#include <linux/err.h>
#include <linux/iommu.h>
#include <linux/of.h>
+#include <linux/of_clk.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
@@ -223,12 +224,42 @@ static void rocket_remove(struct platform_device *pdev)
}
}
+/*
+ * The NPU compute clock is a PVTPLL managed by TF-A via SCMI; spin it up
+ * with a real rate change (an intermediate rate defeats the clock
+ * framework's unchanged-rate shortcut). Powering on and de-idling the NPU
+ * NoC are handled by the power domain (genpd) before the NPU is accessed.
+ */
+static int rk3568_noc_init(struct rocket_core *core)
+{
+ struct clk *npu_clk;
+
+ npu_clk = of_clk_get_by_name(core->dev->of_node, "npu");
+ if (IS_ERR(npu_clk))
+ return dev_err_probe(core->dev, PTR_ERR(npu_clk),
+ "failed to get the NPU SCMI clock\n");
+
+ if (clk_set_rate(npu_clk, 600000000UL) ||
+ clk_set_rate(npu_clk, 1000000000UL))
+ dev_warn(core->dev, "failed to set the NPU compute clock rate\n");
+ clk_put(npu_clk);
+
+ return 0;
+}
+
+static const struct rocket_soc_data rk3568_soc_data = {
+ .num_cores = 1,
+ .dma_bits = 32,
+ .noc_init = rk3568_noc_init,
+};
+
static const struct rocket_soc_data rk3588_soc_data = {
.num_cores = 3,
.dma_bits = 40,
};
static const struct of_device_id dt_match[] = {
+ { .compatible = "rockchip,rk3568-rknn-core", .data = &rk3568_soc_data },
{ .compatible = "rockchip,rk3588-rknn-core", .data = &rk3588_soc_data },
{}
};
--
2.39.5
More information about the linux-arm-kernel
mailing list