From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 22415CD8CA8 for ; Sat, 13 Jun 2026 06:58:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=q9lCT5hFuQlBjQqDnDlpEFs50IBGKZjmVIr8JFjJQzU=; b=UrtYsIthFbF+Hy/NplFid2w91e /HGFnNcVychGQaUHudrJGbaIjtmpxa5y1604NHBaSgdNzDnWHQ97DwRBYgorTo7OXnsWQ/WYtg3y5 b8qmta6TaMpD93kXgV0Bxqhr3z5zAZmy1sV1kWoHqicgds3Q9nqXS4j6Wpin2TilTFZaRgJhQWJUs pVdOhMaYR9k+gG3fiGNH9EA6Ifn9ifU7Uw0orq3y3v88By/dA4Az/MD+/RvD1woEME5g7qhROtQzE tUh0AdOC58bD+5myjfzLX49Mn9psQMyFy26qzE81AJU6UvBj38/IFEN3zPmkSkqiVZBu5CK4m75BE Zh751DNA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wYIKF-0000000C0tq-46ME; Sat, 13 Jun 2026 06:58:39 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wYIK9-0000000C0oA-45kb for linux-arm-kernel@lists.infradead.org; Sat, 13 Jun 2026 06:58:37 +0000 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-490aaeabdb4so11009295e9.1 for ; Fri, 12 Jun 2026 23:58:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781333912; x=1781938712; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=q9lCT5hFuQlBjQqDnDlpEFs50IBGKZjmVIr8JFjJQzU=; b=dDHBDETwb/6YzziA50e1bFUgfGPtA/lKdDsYhkU0aS9Iw81ueWvKa2TXipiWk+NHfP FrZ8w6fTqH39cmHhwsexhqs6+xhfuKQOlicn2e54IbH7sqWRLw/rcYVFsphibGuYVGby op+twRgp8CrIp8f95EYfzC0Mg79Hoqpm3U5a0cmSNMbRdK2OGna6nehVQG+9abzETLMZ 2Akewic2F8RQy9vINjPlq2ynF/H/C13QHmc3UZQ4LK8uJpy4QfoxXsVq0eY57nRsYlkM wfxJe+FtgyIHNOe1VTWnLnb3jDY/aQPFfL+GMXzzwWZ9GYk1bJfXoNBU2lB+b/rndGM4 LmRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781333912; x=1781938712; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=q9lCT5hFuQlBjQqDnDlpEFs50IBGKZjmVIr8JFjJQzU=; b=n8bIcWdU817maukpaLlx6ClCN6ZM8D+fgltB+OwFUOtUyg12vTimbVMZw4xBR/AiY1 ZaoLL+sELGVbiPBdnzcm4wYqYr/Ut+id9ks+Ho/XK7RnoTevNmwRqTM6Ysj409hp75Oe I3Rc+nAS9ulo0c/irS5fZs4Jf3BZM1X3xFvYFhmUNt3v0JuaFjAox5bryXwhNKLK1hCV iZZha6bWp5jxdy/E/XNj4jTxGM9WQ9ahJ1o6i9A/v72vsGuoagOcthrezopo+YOfcpLj kRrbFZmPVr3/M1jZ17N/fn6l9Dy0UguT4NUR1/QttHeYwc8doGXYHe/9NK59EJavMRwc SuKQ== X-Forwarded-Encrypted: i=1; AFNElJ8KRww4LmdH0DO2joWWd+7nFwjBaa6tXcPbKuSFkkwoNXgdtj3ahCMwBCBqpjPO4Uvs+IDsznQrGkjCrTcuprIG@lists.infradead.org X-Gm-Message-State: AOJu0YxG+3kJlqMCR1WpsFJzKlSDTaDSSJbELrkvcw1feFXqf/bfBT6d nXeRijwHTvyOmDoitDkebD/LeQtyTyjuJHjEWknXs0za2m0XYutxoFcS X-Gm-Gg: Acq92OFUmBNdVob4I4P7uYd7EZq0PKaF45KW+Jwi7ZWK+2JM+GMFHE9eB3kPDZKTlFX HIXD3jzHZhEHvgJkbpJtjOGVeyjCfFWdV+3iu5JhP7N7IU39n5lPfH75uTLMynJZa+cqeQ5igaL bXPNenek5XCw3db+nofiEZwO2f8cLx9w2n77GNSzOD1SAaZ2tJ9pcekvPGIEPnWTwOp34in4cdo yoMIiPU9sILr9zTUh4/sPh8HhG7OXzj/zroRSD1FaONmshnXOr2T3KjJXUSEaUo8C89IO8r/O9Y 2EloMAxno9kI9Td78SmCw/sm3RU/EcrHSx3NunUJV+mchbZNTCDYruezWWaVzpm8YBkdJwU3cwk WS1DbeAItj4O2TXJb73QPJxvPZ0Kz/u+g49GBgp40i6immd6hhErEOpV/iHuDEMTspb2KpLYw44 f9UhPd6A8lTA4N3eXxXAKSR7h6pp7/4/6Yke/O18rWiB516ltjTWUV X-Received: by 2002:a05:600c:4709:b0:490:5057:f5f7 with SMTP id 5b1f17b1804b1-4922007472cmr28836405e9.11.1781333912286; Fri, 12 Jun 2026 23:58:32 -0700 (PDT) Received: from debian.tailb81abf.ts.net ([2a01:e0a:104a:4d80:14c0:9448:1c38:77df]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-492202e5cbasm42917705e9.2.2026.06.12.23.58.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jun 2026 23:58:31 -0700 (PDT) From: MidG971 To: tomeu@tomeuvizoso.net, ogabbay@kernel.org, heiko@sntech.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, ulf.hansson@linaro.org Cc: dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, xxm@rock-chips.com, chaoyi.chen@rock-chips.com, finley.xiao@rock-chips.com, diederik@cknow-tech.com, jonas@kwiboo.se, Midgy BALON Subject: [RFC PATCH v4 3/9] accel: rocket: Add RK3568 SoC support Date: Sat, 13 Jun 2026 09:01:10 +0200 Message-Id: <20260613070116.438906-4-midgy971@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260613070116.438906-1-midgy971@gmail.com> References: <20260613070116.438906-1-midgy971@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260612_235834_032722_94A84BB6 X-CRM114-Status: GOOD ( 18.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Midgy BALON 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 --- 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 #include #include +#include #include #include @@ -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