From: David Jander <david@protonic.nl>
To: barebox@lists.infradead.org
Cc: David Jander <david@protonic.nl>
Subject: [PATCH 2/8] clk: rockchip: Introduce rockchip_grf_type enum from kernel driver
Date: Mon, 11 Aug 2025 08:40:20 +0200 [thread overview]
Message-ID: <20250811064026.753776-3-david@protonic.nl> (raw)
In-Reply-To: <20250811064026.753776-1-david@protonic.nl>
The MUXGRF macro from the kernel clk driver has an extra field that was
left out of the barebox driver, since it required a dynamically allocated
hashmap that might have been overly complicated to port.
Until now, this wasn't strictly necessary, but for upcoming RK3576 support
this extra parameter will be needed.
This patch introduces a simplified version of the hashmap via a simple
pointer lookup table called grfmap in struct rockchip_clk_provider.
Existing drivers only need one of the entries (grf_type_sys), which is
filled in by default.
Signed-off-by: David Jander <david@protonic.nl>
---
drivers/clk/rockchip/clk-rk3288.c | 2 +-
drivers/clk/rockchip/clk-rk3568.c | 2 +-
drivers/clk/rockchip/clk.c | 4 +++-
drivers/clk/rockchip/clk.h | 15 ++++++++++++++-
4 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/drivers/clk/rockchip/clk-rk3288.c b/drivers/clk/rockchip/clk-rk3288.c
index b4ac2a42d5..9dceb7da0c 100644
--- a/drivers/clk/rockchip/clk-rk3288.c
+++ b/drivers/clk/rockchip/clk-rk3288.c
@@ -419,7 +419,7 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = {
RK3288_CLKSEL_CON(32), 14, 2, MFLAGS, 8, 5, DFLAGS,
RK3288_CLKGATE_CON(3), 11, GFLAGS),
MUXGRF(0, "aclk_vcodec_pre", mux_aclk_vcodec_pre_p, CLK_SET_RATE_PARENT,
- RK3288_GRF_SOC_CON(0), 7, 1, MFLAGS),
+ RK3288_GRF_SOC_CON(0), 7, 1, MFLAGS, grf_type_sys),
GATE(ACLK_VCODEC, "aclk_vcodec", "aclk_vcodec_pre", 0,
RK3288_CLKGATE_CON(9), 0, GFLAGS),
diff --git a/drivers/clk/rockchip/clk-rk3568.c b/drivers/clk/rockchip/clk-rk3568.c
index cdc7b99e47..7ed5aa5213 100644
--- a/drivers/clk/rockchip/clk-rk3568.c
+++ b/drivers/clk/rockchip/clk-rk3568.c
@@ -586,7 +586,7 @@ static struct rockchip_clk_branch rk3568_clk_branches[] __initdata = {
RK3568_CLKSEL_CON(9), 6, 2, MFLAGS, 0, 5, DFLAGS,
RK3568_CLKGATE_CON(4), 0, GFLAGS),
MUXGRF(CLK_DDR1X, "clk_ddr1x", clk_ddr1x_p, CLK_SET_RATE_PARENT,
- RK3568_CLKSEL_CON(9), 15, 1, MFLAGS),
+ RK3568_CLKSEL_CON(9), 15, 1, MFLAGS, grf_type_sys),
COMPOSITE_NOMUX(CLK_MSCH, "clk_msch", "clk_ddr1x", CLK_IGNORE_UNUSED,
RK3568_CLKSEL_CON(10), 0, 2, DFLAGS,
diff --git a/drivers/clk/rockchip/clk.c b/drivers/clk/rockchip/clk.c
index c833f09611..387961c829 100644
--- a/drivers/clk/rockchip/clk.c
+++ b/drivers/clk/rockchip/clk.c
@@ -332,6 +332,7 @@ struct rockchip_clk_provider *rockchip_clk_init(struct device_node *np,
ctx->grf = syscon_regmap_lookup_by_phandle(ctx->cru_node,
"rockchip,grf");
+ ctx->grfmap[grf_type_sys] = ctx->grf;
return ctx;
@@ -438,7 +439,8 @@ void rockchip_clk_register_branches(struct rockchip_clk_provider *ctx,
case branch_muxgrf:
clk = rockchip_clk_register_muxgrf(list->name,
list->parent_names, list->num_parents,
- flags, ctx->grf, list->muxdiv_offset,
+ flags, ctx->grfmap[list->grf_type],
+ list->muxdiv_offset,
list->mux_shift, list->mux_width,
list->mux_flags);
break;
diff --git a/drivers/clk/rockchip/clk.h b/drivers/clk/rockchip/clk.h
index 42da038fdf..ff25de776d 100644
--- a/drivers/clk/rockchip/clk.h
+++ b/drivers/clk/rockchip/clk.h
@@ -308,6 +308,16 @@ enum rockchip_pll_type {
.k = _k, \
}
+enum rockchip_grf_type {
+ grf_type_sys = 0,
+ grf_type_pmu0,
+ grf_type_pmu1,
+ grf_type_ioc,
+ grf_type_vo,
+ grf_type_vpu,
+ grf_type_num
+};
+
/**
* struct rockchip_clk_provider - information about clock provider
* @reg_base: virtual address for the register base.
@@ -321,6 +331,7 @@ struct rockchip_clk_provider {
struct clk_onecell_data clk_data;
struct device_node *cru_node;
struct regmap *grf;
+ struct regmap *grfmap[grf_type_num];
struct restart_handler restart_handler;
unsigned int reg_restart;
spinlock_t lock;
@@ -526,6 +537,7 @@ struct rockchip_clk_branch {
int gate_offset;
u8 gate_shift;
u8 gate_flags;
+ enum rockchip_grf_type grf_type;
struct rockchip_clk_branch *child;
};
@@ -750,7 +762,7 @@ struct rockchip_clk_branch {
.gate_offset = -1, \
}
-#define MUXGRF(_id, cname, pnames, f, o, s, w, mf) \
+#define MUXGRF(_id, cname, pnames, f, o, s, w, mf, gt) \
{ \
.id = _id, \
.branch_type = branch_muxgrf, \
@@ -763,6 +775,7 @@ struct rockchip_clk_branch {
.mux_width = w, \
.mux_flags = mf, \
.gate_offset = -1, \
+ .grf_type = gt, \
}
#define DIV(_id, cname, pname, f, o, s, w, df) \
--
2.47.2
next prev parent reply other threads:[~2025-08-11 6:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-11 6:40 [PATCH 0/8] Add Rockchip RK3576 support David Jander
2025-08-11 6:40 ` [PATCH 1/8] clk: rockchip: clk-pll.c: Fix macro name confusion David Jander
2025-08-11 6:40 ` David Jander [this message]
2025-08-11 6:40 ` [PATCH 3/8] ARM: Initial support for Rockchip RK3576 David Jander
2025-08-11 6:40 ` [PATCH 4/8] arm: dts: Add barebox specific RK3576.dtsi David Jander
2025-08-11 6:40 ` [PATCH 5/8] aiodev: rockchip_saradc.c: Add support for RK3576 David Jander
2025-08-11 6:40 ` [PATCH 6/8] gpio: gpio-rockchip.c: Add support for GPIO_TYPE_V2_2 David Jander
2025-08-11 6:40 ` [PATCH 7/8] arm: dts: rk3576.dtsi: Add gpio aliases David Jander
2025-08-11 6:40 ` [PATCH 8/8] phy: phy-rockchip-inno-usb2.c: Fix crash if phyclk isn't found David Jander
2025-08-13 5:28 ` [PATCH 0/8] Add Rockchip RK3576 support Sascha Hauer
2025-08-13 5:32 ` Sascha Hauer
2025-08-13 6:51 ` David Jander
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250811064026.753776-3-david@protonic.nl \
--to=david@protonic.nl \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox