* [PATCH v3 1/9] dt-bindings: devfreq: event: rockchip,dfi: add clocks to rk3588
2026-11-17 15:35 [PATCH v3 0/9] PM / devfreq: rockchip-dfi: cleanups and RK3576 support Sebastian Reichel
@ 2026-11-17 15:35 ` Sebastian Reichel
2026-11-18 13:09 ` Rob Herring (Arm)
2026-11-17 15:35 ` [PATCH v3 2/9] dt-bindings: devfreq: event: rockchip,dfi: add rk3576 Sebastian Reichel
` (8 subsequent siblings)
9 siblings, 1 reply; 13+ messages in thread
From: Sebastian Reichel @ 2026-11-17 15:35 UTC (permalink / raw)
To: Chanwoo Choi, MyungJoo Ham, Kyungmin Park, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Heiko Stuebner, Sascha Hauer
Cc: Nicolas Frattaroli, linux-pm, devicetree, linux-arm-kernel,
linux-rockchip, linux-kernel, kernel, Sebastian Reichel
From: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
RK3588's DFI has pclks for each channel. They just weren't noticed as
missing until now because nothing ever gates them, and they're ungated
by default on power-on.
The RK3399 clock situation needs no changes, as there the hardware
really just has one monitoring unit for both channels.
Add these clocks to the binding, so that drivers for this device can
properly know about their existence.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
.../bindings/devfreq/event/rockchip,dfi.yaml | 84 ++++++++++++++++++----
1 file changed, 72 insertions(+), 12 deletions(-)
diff --git a/Documentation/devicetree/bindings/devfreq/event/rockchip,dfi.yaml b/Documentation/devicetree/bindings/devfreq/event/rockchip,dfi.yaml
index 50d3fabe958d..d6e06a9bea19 100644
--- a/Documentation/devicetree/bindings/devfreq/event/rockchip,dfi.yaml
+++ b/Documentation/devicetree/bindings/devfreq/event/rockchip,dfi.yaml
@@ -17,11 +17,19 @@ properties:
- rockchip,rk3588-dfi
clocks:
- maxItems: 1
+ minItems: 1
+ maxItems: 4
clock-names:
+ minItems: 1
+ maxItems: 4
items:
- - const: pclk_ddr_mon
+ - enum:
+ - pclk_ddr_mon
+ - pclk_ddr_mon_ch0
+ - const: pclk_ddr_mon_ch1
+ - const: pclk_ddr_mon_ch2
+ - const: pclk_ddr_mon_ch3
interrupts:
minItems: 1
@@ -40,17 +48,50 @@ required:
- interrupts
- reg
-if:
- properties:
- compatible:
- contains:
- enum:
- - rockchip,rk3399-dfi
+allOf:
+ - if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - rockchip,rk3399-dfi
+ then:
+ properties:
+ clocks:
+ items:
+ - description:
+ clock driving the DDR monitoring logic for all channels
+ clock-names:
+ items:
+ - const: pclk_ddr_mon
+ required:
+ - clocks
+ - clock-names
-then:
- required:
- - clocks
- - clock-names
+ - if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - rockchip,rk3588-dfi
+ then:
+ properties:
+ clocks:
+ items:
+ - description:
+ clock driving the DDR monitoring logic for memory channel 0
+ - description:
+ clock driving the DDR monitoring logic for memory channel 1
+ - description:
+ clock driving the DDR monitoring logic for memory channel 2
+ - description:
+ clock driving the DDR monitoring logic for memory channel 3
+ clock-names:
+ items:
+ - const: pclk_ddr_mon_ch0
+ - const: pclk_ddr_mon_ch1
+ - const: pclk_ddr_mon_ch2
+ - const: pclk_ddr_mon_ch3
additionalProperties: false
@@ -72,3 +113,22 @@ examples:
clock-names = "pclk_ddr_mon";
};
};
+
+ - |
+ bus {
+ #address-cells = <2>;
+ #size-cells = <2>;
+
+ dfi_rk3588: dfi@fe060000 {
+ compatible = "rockchip,rk3588-dfi";
+ reg = <0x00 0xfe060000 0x00 0x10000>;
+ clocks = <&cru 0x53>, <&cru 0x48>, <&cru 0x49>, <&cru 0x54>;
+ clock-names = "pclk_ddr_mon_ch0", "pclk_ddr_mon_ch1",
+ "pclk_ddr_mon_ch2", "pclk_ddr_mon_ch3";
+ interrupts = <GIC_SPI 28 IRQ_TYPE_LEVEL_HIGH 0>,
+ <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH 0>,
+ <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH 0>,
+ <GIC_SPI 58 IRQ_TYPE_LEVEL_HIGH 0>;
+ rockchip,pmu = <&pmugrf>;
+ };
+ };
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH v3 1/9] dt-bindings: devfreq: event: rockchip,dfi: add clocks to rk3588
2026-11-17 15:35 ` [PATCH v3 1/9] dt-bindings: devfreq: event: rockchip,dfi: add clocks to rk3588 Sebastian Reichel
@ 2026-11-18 13:09 ` Rob Herring (Arm)
0 siblings, 0 replies; 13+ messages in thread
From: Rob Herring (Arm) @ 2026-11-18 13:09 UTC (permalink / raw)
To: Sebastian Reichel
Cc: Nicolas Frattaroli, linux-kernel, Krzysztof Kozlowski,
Kyungmin Park, linux-pm, Chanwoo Choi, linux-arm-kernel, kernel,
Heiko Stuebner, devicetree, MyungJoo Ham, Sascha Hauer,
linux-rockchip, Conor Dooley
On Tue, 17 Nov 2026 16:35:37 +0100, Sebastian Reichel wrote:
> From: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
>
> RK3588's DFI has pclks for each channel. They just weren't noticed as
> missing until now because nothing ever gates them, and they're ungated
> by default on power-on.
>
> The RK3399 clock situation needs no changes, as there the hardware
> really just has one monitoring unit for both channels.
>
> Add these clocks to the binding, so that drivers for this device can
> properly know about their existence.
>
> Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
> Acked-by: Rob Herring (Arm) <robh@kernel.org>
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
> .../bindings/devfreq/event/rockchip,dfi.yaml | 84 ++++++++++++++++++----
> 1 file changed, 72 insertions(+), 12 deletions(-)
>
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/devfreq/event/rockchip,dfi.yaml: properties:clock-names: {"required":["maxItems"]} is not allowed for {"minItems":1,"maxItems":4,"items":[{"enum":["pclk_ddr_mon","pclk_ddr_mon_ch0"]},{"const":"pclk_ddr_mon_ch1"},{"const":"pclk_ddr_mon_ch2"},{"const":"pclk_ddr_mon_ch3"}]}
doc reference errors (make refcheckdocs):
See https://patchwork.kernel.org/project/devicetree/patch/20261117-rockchip-dfi-rk3588-cleanups-and-rk3576-support-v3-1-32ff1546b0e4@collabora.com
The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v3 2/9] dt-bindings: devfreq: event: rockchip,dfi: add rk3576
2026-11-17 15:35 [PATCH v3 0/9] PM / devfreq: rockchip-dfi: cleanups and RK3576 support Sebastian Reichel
2026-11-17 15:35 ` [PATCH v3 1/9] dt-bindings: devfreq: event: rockchip,dfi: add clocks to rk3588 Sebastian Reichel
@ 2026-11-17 15:35 ` Sebastian Reichel
2026-11-17 15:35 ` [PATCH v3 3/9] PM / devfreq: rockchip-dfi: move to per-variant const structs Sebastian Reichel
` (7 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Sebastian Reichel @ 2026-11-17 15:35 UTC (permalink / raw)
To: Chanwoo Choi, MyungJoo Ham, Kyungmin Park, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Heiko Stuebner, Sascha Hauer
Cc: Nicolas Frattaroli, linux-pm, devicetree, linux-arm-kernel,
linux-rockchip, linux-kernel, kernel, Sebastian Reichel
From: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
The RK3576 has DFI hardware for monitoring the DDR's bandwidth much
like other rockchip SoCs do. Unlike the RK3588 however, it only has two
memory channels, so only two per-channel pclks for DFI.
Add a compatible for this SoC's variant, and add it to the conditionals
at the bottom of the bindings file.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
.../bindings/devfreq/event/rockchip,dfi.yaml | 23 ++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/Documentation/devicetree/bindings/devfreq/event/rockchip,dfi.yaml b/Documentation/devicetree/bindings/devfreq/event/rockchip,dfi.yaml
index d6e06a9bea19..964f1827496a 100644
--- a/Documentation/devicetree/bindings/devfreq/event/rockchip,dfi.yaml
+++ b/Documentation/devicetree/bindings/devfreq/event/rockchip,dfi.yaml
@@ -14,6 +14,7 @@ properties:
enum:
- rockchip,rk3399-dfi
- rockchip,rk3568-dfi
+ - rockchip,rk3576-dfi
- rockchip,rk3588-dfi
clocks:
@@ -68,6 +69,28 @@ allOf:
- clocks
- clock-names
+ - if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - rockchip,rk3576-dfi
+ then:
+ properties:
+ clocks:
+ items:
+ - description:
+ clock driving the DDR monitoring logic for memory channel 0
+ - description:
+ clock driving the DDR monitoring logic for memory channel 1
+ clock-names:
+ items:
+ - const: pclk_ddr_mon_ch0
+ - const: pclk_ddr_mon_ch1
+ required:
+ - clocks
+ - clock-names
+
- if:
properties:
compatible:
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v3 3/9] PM / devfreq: rockchip-dfi: move to per-variant const structs
2026-11-17 15:35 [PATCH v3 0/9] PM / devfreq: rockchip-dfi: cleanups and RK3576 support Sebastian Reichel
2026-11-17 15:35 ` [PATCH v3 1/9] dt-bindings: devfreq: event: rockchip,dfi: add clocks to rk3588 Sebastian Reichel
2026-11-17 15:35 ` [PATCH v3 2/9] dt-bindings: devfreq: event: rockchip,dfi: add rk3576 Sebastian Reichel
@ 2026-11-17 15:35 ` Sebastian Reichel
2026-11-17 15:35 ` [PATCH v3 4/9] PM / devfreq: rockchip-dfi: add NO_INTERRUPT perf capability Sebastian Reichel
` (6 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Sebastian Reichel @ 2026-11-17 15:35 UTC (permalink / raw)
To: Chanwoo Choi, MyungJoo Ham, Kyungmin Park, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Heiko Stuebner, Sascha Hauer
Cc: Nicolas Frattaroli, linux-pm, devicetree, linux-arm-kernel,
linux-rockchip, linux-kernel, kernel, Sebastian Reichel
From: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
The rockchip-dfi driver supports several variants of the DDR monitoring
hardware. The differences in these variants are handled with one init
function for each variant.
However, some of the members that these init functions set are actually
constants, specific to that variant, with no runtime involvement from
reading registers or anything.
Refactor the code to move those values (and the soc_init function
pointer) into a new struct. Declare some const instances of this variant
struct, and use it wherever needed.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/devfreq/event/rockchip-dfi.c | 94 +++++++++++++++++++++---------------
1 file changed, 54 insertions(+), 40 deletions(-)
diff --git a/drivers/devfreq/event/rockchip-dfi.c b/drivers/devfreq/event/rockchip-dfi.c
index e0b942028e50..d02a01188ea2 100644
--- a/drivers/devfreq/event/rockchip-dfi.c
+++ b/drivers/devfreq/event/rockchip-dfi.c
@@ -103,7 +103,6 @@ struct rockchip_dfi {
struct mutex mutex;
u32 ddr_type;
unsigned int channel_mask;
- unsigned int max_channels;
enum cpuhp_state cpuhp_state;
struct hlist_node node;
struct pmu pmu;
@@ -112,11 +111,17 @@ struct rockchip_dfi {
int active_events;
int burst_len;
int buswidth[DMC_MAX_CHANNELS];
- int ddrmon_stride;
- bool ddrmon_ctrl_single;
u32 lp5_bank_mode;
bool lp5_ckr; /* true if in 4:1 command-to-data clock ratio mode */
unsigned int count_multiplier; /* number of data clocks per count */
+ const struct rockchip_dfi_variant *variant;
+};
+
+struct rockchip_dfi_variant {
+ int (*init)(struct rockchip_dfi *dfi);
+ int stride;
+ bool ctrl_single;
+ unsigned int max_channels;
};
static int rockchip_dfi_ddrtype_to_ctrl(struct rockchip_dfi *dfi, u32 *ctrl)
@@ -190,7 +195,7 @@ static int rockchip_dfi_enable(struct rockchip_dfi *dfi)
goto out;
}
- for (i = 0; i < dfi->max_channels; i++) {
+ for (i = 0; i < dfi->variant->max_channels; i++) {
if (!(dfi->channel_mask & BIT(i)))
continue;
@@ -199,16 +204,16 @@ static int rockchip_dfi_enable(struct rockchip_dfi *dfi)
writel_relaxed(FIELD_PREP_WM16(DDRMON_CTRL_TIMER_CNT_EN, 0) |
FIELD_PREP_WM16(DDRMON_CTRL_SOFTWARE_EN, 0) |
FIELD_PREP_WM16(DDRMON_CTRL_HARDWARE_EN, 0),
- dfi_regs + i * dfi->ddrmon_stride + DDRMON_CTRL);
+ dfi_regs + i * dfi->variant->stride + DDRMON_CTRL);
- writel_relaxed(ctrl, dfi_regs + i * dfi->ddrmon_stride +
+ writel_relaxed(ctrl, dfi_regs + i * dfi->variant->stride +
DDRMON_CTRL);
/* enable count, use software mode */
writel_relaxed(FIELD_PREP_WM16(DDRMON_CTRL_SOFTWARE_EN, 1),
- dfi_regs + i * dfi->ddrmon_stride + DDRMON_CTRL);
+ dfi_regs + i * dfi->variant->stride + DDRMON_CTRL);
- if (dfi->ddrmon_ctrl_single)
+ if (dfi->variant->ctrl_single)
break;
}
out:
@@ -231,14 +236,14 @@ static void rockchip_dfi_disable(struct rockchip_dfi *dfi)
if (dfi->usecount > 0)
goto out;
- for (i = 0; i < dfi->max_channels; i++) {
+ for (i = 0; i < dfi->variant->max_channels; i++) {
if (!(dfi->channel_mask & BIT(i)))
continue;
writel_relaxed(FIELD_PREP_WM16(DDRMON_CTRL_SOFTWARE_EN, 0),
- dfi_regs + i * dfi->ddrmon_stride + DDRMON_CTRL);
+ dfi_regs + i * dfi->variant->stride + DDRMON_CTRL);
- if (dfi->ddrmon_ctrl_single)
+ if (dfi->variant->ctrl_single)
break;
}
@@ -252,17 +257,17 @@ static void rockchip_dfi_read_counters(struct rockchip_dfi *dfi, struct dmc_coun
u32 i;
void __iomem *dfi_regs = dfi->regs;
- for (i = 0; i < dfi->max_channels; i++) {
+ for (i = 0; i < dfi->variant->max_channels; i++) {
if (!(dfi->channel_mask & BIT(i)))
continue;
res->c[i].read_access = readl_relaxed(dfi_regs +
- DDRMON_CH0_RD_NUM + i * dfi->ddrmon_stride);
+ DDRMON_CH0_RD_NUM + i * dfi->variant->stride);
res->c[i].write_access = readl_relaxed(dfi_regs +
- DDRMON_CH0_WR_NUM + i * dfi->ddrmon_stride);
+ DDRMON_CH0_WR_NUM + i * dfi->variant->stride);
res->c[i].access = readl_relaxed(dfi_regs +
- DDRMON_CH0_DFI_ACCESS_NUM + i * dfi->ddrmon_stride);
+ DDRMON_CH0_DFI_ACCESS_NUM + i * dfi->variant->stride);
res->c[i].clock_cycles = readl_relaxed(dfi_regs +
- DDRMON_CH0_COUNT_NUM + i * dfi->ddrmon_stride);
+ DDRMON_CH0_COUNT_NUM + i * dfi->variant->stride);
}
}
@@ -299,7 +304,7 @@ static int rockchip_dfi_get_event(struct devfreq_event_dev *edev,
rockchip_dfi_read_counters(dfi, &count);
/* We can only report one channel, so find the busiest one */
- for (i = 0; i < dfi->max_channels; i++) {
+ for (i = 0; i < dfi->variant->max_channels; i++) {
u32 a, c;
if (!(dfi->channel_mask & BIT(i)))
@@ -338,7 +343,7 @@ static void rockchip_ddr_perf_counters_add(struct rockchip_dfi *dfi,
const struct dmc_count *last = &dfi->last_perf_count;
int i;
- for (i = 0; i < dfi->max_channels; i++) {
+ for (i = 0; i < dfi->variant->max_channels; i++) {
res->c[i].read_access = dfi->total_count.c[i].read_access +
(u32)(now->c[i].read_access - last->c[i].read_access);
res->c[i].write_access = dfi->total_count.c[i].write_access +
@@ -479,11 +484,11 @@ static u64 rockchip_ddr_perf_event_get_count(struct perf_event *event)
count = total.c[0].clock_cycles * dfi->count_multiplier;
break;
case PERF_EVENT_READ_BYTES:
- for (i = 0; i < dfi->max_channels; i++)
+ for (i = 0; i < dfi->variant->max_channels; i++)
count += total.c[i].read_access * blen * dfi->buswidth[i];
break;
case PERF_EVENT_WRITE_BYTES:
- for (i = 0; i < dfi->max_channels; i++)
+ for (i = 0; i < dfi->variant->max_channels; i++)
count += total.c[i].write_access * blen * dfi->buswidth[i];
break;
case PERF_EVENT_READ_BYTES0:
@@ -511,7 +516,7 @@ static u64 rockchip_ddr_perf_event_get_count(struct perf_event *event)
count = total.c[3].write_access * blen * dfi->buswidth[3];
break;
case PERF_EVENT_BYTES:
- for (i = 0; i < dfi->max_channels; i++)
+ for (i = 0; i < dfi->variant->max_channels; i++)
count += total.c[i].access * blen * dfi->buswidth[i];
break;
}
@@ -728,14 +733,10 @@ static int rk3399_dfi_init(struct rockchip_dfi *dfi)
dfi->ddr_type = FIELD_GET(RK3399_PMUGRF_OS_REG2_DDRTYPE, val);
dfi->channel_mask = GENMASK(1, 0);
- dfi->max_channels = 2;
dfi->buswidth[0] = FIELD_GET(RK3399_PMUGRF_OS_REG2_BW_CH0, val) == 0 ? 4 : 2;
dfi->buswidth[1] = FIELD_GET(RK3399_PMUGRF_OS_REG2_BW_CH1, val) == 0 ? 4 : 2;
- dfi->ddrmon_stride = 0x14;
- dfi->ddrmon_ctrl_single = true;
-
return 0;
};
@@ -758,13 +759,9 @@ static int rk3568_dfi_init(struct rockchip_dfi *dfi)
dfi->ddr_type |= FIELD_GET(RK3568_PMUGRF_OS_REG3_DRAMTYPE_INFO_V3, reg3) << 3;
dfi->channel_mask = BIT(0);
- dfi->max_channels = 1;
dfi->buswidth[0] = FIELD_GET(RK3568_PMUGRF_OS_REG2_BW_CH0, reg2) == 0 ? 4 : 2;
- dfi->ddrmon_stride = 0x0; /* not relevant, we only have a single channel on this SoC */
- dfi->ddrmon_ctrl_single = true;
-
return 0;
};
@@ -793,9 +790,7 @@ static int rk3588_dfi_init(struct rockchip_dfi *dfi)
dfi->buswidth[3] = FIELD_GET(RK3588_PMUGRF_OS_REG2_BW_CH1, reg4) == 0 ? 4 : 2;
dfi->channel_mask = FIELD_GET(RK3588_PMUGRF_OS_REG2_CH_INFO, reg2) |
FIELD_GET(RK3588_PMUGRF_OS_REG2_CH_INFO, reg4) << 2;
- dfi->max_channels = 4;
- dfi->ddrmon_stride = 0x4000;
dfi->count_multiplier = 2;
if (dfi->ddr_type == ROCKCHIP_DDRTYPE_LPDDR5) {
@@ -809,10 +804,30 @@ static int rk3588_dfi_init(struct rockchip_dfi *dfi)
return 0;
};
+static const struct rockchip_dfi_variant rk3399_variant = {
+ .init = rk3399_dfi_init,
+ .stride = 0x14,
+ .ctrl_single = true,
+ .max_channels = 2,
+};
+
+static const struct rockchip_dfi_variant rk3568_variant = {
+ .init = rk3568_dfi_init,
+ .stride = 0x0,
+ .ctrl_single = true,
+ .max_channels = 1,
+};
+
+static const struct rockchip_dfi_variant rk3588_variant = {
+ .init = rk3588_dfi_init,
+ .stride = 0x4000,
+ .max_channels = 4,
+};
+
static const struct of_device_id rockchip_dfi_id_match[] = {
- { .compatible = "rockchip,rk3399-dfi", .data = rk3399_dfi_init },
- { .compatible = "rockchip,rk3568-dfi", .data = rk3568_dfi_init },
- { .compatible = "rockchip,rk3588-dfi", .data = rk3588_dfi_init },
+ { .compatible = "rockchip,rk3399-dfi", .data = &rk3399_variant },
+ { .compatible = "rockchip,rk3568-dfi", .data = &rk3568_variant },
+ { .compatible = "rockchip,rk3588-dfi", .data = &rk3588_variant },
{ },
};
@@ -824,17 +839,16 @@ static int rockchip_dfi_probe(struct platform_device *pdev)
struct rockchip_dfi *dfi;
struct devfreq_event_desc *desc;
struct device_node *np = pdev->dev.of_node, *node;
- int (*soc_init)(struct rockchip_dfi *dfi);
int ret;
- soc_init = of_device_get_match_data(&pdev->dev);
- if (!soc_init)
- return -EINVAL;
-
dfi = devm_kzalloc_obj(dev, *dfi);
if (!dfi)
return -ENOMEM;
+ dfi->variant = of_device_get_match_data(dev);
+ if (!dfi->variant)
+ return -EINVAL;
+
dfi->regs = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(dfi->regs))
return PTR_ERR(dfi->regs);
@@ -856,7 +870,7 @@ static int rockchip_dfi_probe(struct platform_device *pdev)
desc->driver_data = dfi;
desc->name = np->name;
- ret = soc_init(dfi);
+ ret = dfi->variant->init(dfi);
if (ret)
return ret;
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v3 4/9] PM / devfreq: rockchip-dfi: add NO_INTERRUPT perf capability
2026-11-17 15:35 [PATCH v3 0/9] PM / devfreq: rockchip-dfi: cleanups and RK3576 support Sebastian Reichel
` (2 preceding siblings ...)
2026-11-17 15:35 ` [PATCH v3 3/9] PM / devfreq: rockchip-dfi: move to per-variant const structs Sebastian Reichel
@ 2026-11-17 15:35 ` Sebastian Reichel
2026-11-17 15:35 ` [PATCH v3 5/9] PM / devfreq: rockchip-dfi: use bulk clock APIs Sebastian Reichel
` (5 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Sebastian Reichel @ 2026-11-17 15:35 UTC (permalink / raw)
To: Chanwoo Choi, MyungJoo Ham, Kyungmin Park, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Heiko Stuebner, Sascha Hauer
Cc: Nicolas Frattaroli, linux-pm, devicetree, linux-arm-kernel,
linux-rockchip, linux-kernel, kernel, Sebastian Reichel
From: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
The perf subsystem's PERF_PMU_CAP_NO_INTERRUPT is a bit of a
misnomer.[1] Instead of meaning that the PMU has no interrupt, it
actually means that the PMU does support sampling. On CPU PMUs, this is
equivalent to not having an interrupt, but for uncore PMUs like the
rockchip-dfi PMU is, no meaningful sample data could ever be generated
regardless of whether or not there is an interrupt, as it is not a CPU.
Since rockchip-dfi doesn't seem to make use of the interrupt the DT
provides it with anyway, this was probably never a confusion that
existed in this case; the capability flag was likely just forgotten.
Add PERF_PMU_CAP_NO_INTERRUPT to the set flags for the pmu struct's
capabilities member, so that the perf core knows about this limitation.
Fixes: 4d586b5724d3 ("PM / devfreq: rockchip-dfi: Add perf support")
Link: https://lore.kernel.org/all/20250619140442.GH1613376@noisy.programming.kicks-ass.net/ [1]
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/devfreq/event/rockchip-dfi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/devfreq/event/rockchip-dfi.c b/drivers/devfreq/event/rockchip-dfi.c
index d02a01188ea2..eb47a1f622b1 100644
--- a/drivers/devfreq/event/rockchip-dfi.c
+++ b/drivers/devfreq/event/rockchip-dfi.c
@@ -648,7 +648,7 @@ static int rockchip_ddr_perf_init(struct rockchip_dfi *dfi)
seqlock_init(&dfi->count_seqlock);
pmu->module = THIS_MODULE;
- pmu->capabilities = PERF_PMU_CAP_NO_EXCLUDE;
+ pmu->capabilities = PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_INTERRUPT;
pmu->task_ctx_nr = perf_invalid_context;
pmu->attr_groups = attr_groups;
pmu->event_init = rockchip_ddr_perf_event_init;
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v3 5/9] PM / devfreq: rockchip-dfi: use bulk clock APIs
2026-11-17 15:35 [PATCH v3 0/9] PM / devfreq: rockchip-dfi: cleanups and RK3576 support Sebastian Reichel
` (3 preceding siblings ...)
2026-11-17 15:35 ` [PATCH v3 4/9] PM / devfreq: rockchip-dfi: add NO_INTERRUPT perf capability Sebastian Reichel
@ 2026-11-17 15:35 ` Sebastian Reichel
2026-11-17 15:35 ` [PATCH v3 6/9] PM / devfreq: rockchip-dfi: make RK3588 use its clocks Sebastian Reichel
` (4 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Sebastian Reichel @ 2026-11-17 15:35 UTC (permalink / raw)
To: Chanwoo Choi, MyungJoo Ham, Kyungmin Park, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Heiko Stuebner, Sascha Hauer
Cc: Nicolas Frattaroli, linux-pm, devicetree, linux-arm-kernel,
linux-rockchip, linux-kernel, kernel, Sebastian Reichel
From: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Currently, the only clock rockchip-dfi will ever use is on the rk3399,
namely pclk_ddr_mon. However, this is mainly because every other SoC's
mainline clock tree and bindings are probably lying and not telling us
about some clock gate branches that do exist in hardware, but nothing
happens ever gate.
Get preparations out of the way to fix this by moving to the bulk clock
APIs, which will make handling the one-clock-per-channel cases easier to
deal with.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/devfreq/event/rockchip-dfi.c | 41 +++++++++++++++++++++++++++---------
1 file changed, 31 insertions(+), 10 deletions(-)
diff --git a/drivers/devfreq/event/rockchip-dfi.c b/drivers/devfreq/event/rockchip-dfi.c
index eb47a1f622b1..150fdf577e11 100644
--- a/drivers/devfreq/event/rockchip-dfi.c
+++ b/drivers/devfreq/event/rockchip-dfi.c
@@ -98,7 +98,7 @@ struct rockchip_dfi {
struct device *dev;
void __iomem *regs;
struct regmap *regmap_pmu;
- struct clk *clk;
+ struct clk_bulk_data *clocks;
int usecount;
struct mutex mutex;
u32 ddr_type;
@@ -122,6 +122,8 @@ struct rockchip_dfi_variant {
int stride;
bool ctrl_single;
unsigned int max_channels;
+ const char * const *clk_names;
+ unsigned int num_clks;
};
static int rockchip_dfi_ddrtype_to_ctrl(struct rockchip_dfi *dfi, u32 *ctrl)
@@ -183,15 +185,16 @@ static int rockchip_dfi_enable(struct rockchip_dfi *dfi)
if (dfi->usecount > 1)
goto out;
- ret = clk_prepare_enable(dfi->clk);
+ ret = clk_bulk_prepare_enable(dfi->variant->num_clks, dfi->clocks);
if (ret) {
- dev_err(&dfi->edev->dev, "failed to enable dfi clk: %d\n", ret);
+ dev_err(&dfi->edev->dev, "failed to enable dfi clocks: %pe\n",
+ ERR_PTR(ret));
goto out;
}
ret = rockchip_dfi_ddrtype_to_ctrl(dfi, &ctrl);
if (ret) {
- clk_disable_unprepare(dfi->clk);
+ clk_bulk_disable_unprepare(dfi->variant->num_clks, dfi->clocks);
goto out;
}
@@ -247,7 +250,7 @@ static void rockchip_dfi_disable(struct rockchip_dfi *dfi)
break;
}
- clk_disable_unprepare(dfi->clk);
+ clk_bulk_disable_unprepare(dfi->variant->num_clks, dfi->clocks);
out:
mutex_unlock(&dfi->mutex);
}
@@ -723,11 +726,6 @@ static int rk3399_dfi_init(struct rockchip_dfi *dfi)
struct regmap *regmap_pmu = dfi->regmap_pmu;
u32 val;
- dfi->clk = devm_clk_get(dfi->dev, "pclk_ddr_mon");
- if (IS_ERR(dfi->clk))
- return dev_err_probe(dfi->dev, PTR_ERR(dfi->clk),
- "Cannot get the clk pclk_ddr_mon\n");
-
/* get ddr type */
regmap_read(regmap_pmu, RK3399_PMUGRF_OS_REG2, &val);
dfi->ddr_type = FIELD_GET(RK3399_PMUGRF_OS_REG2_DDRTYPE, val);
@@ -804,11 +802,17 @@ static int rk3588_dfi_init(struct rockchip_dfi *dfi)
return 0;
};
+static const char * const rk3399_clk_names[] = {
+ "pclk_ddr_mon",
+};
+
static const struct rockchip_dfi_variant rk3399_variant = {
.init = rk3399_dfi_init,
.stride = 0x14,
.ctrl_single = true,
.max_channels = 2,
+ .clk_names = rk3399_clk_names,
+ .num_clks = ARRAY_SIZE(rk3399_clk_names),
};
static const struct rockchip_dfi_variant rk3568_variant = {
@@ -839,6 +843,7 @@ static int rockchip_dfi_probe(struct platform_device *pdev)
struct rockchip_dfi *dfi;
struct devfreq_event_desc *desc;
struct device_node *np = pdev->dev.of_node, *node;
+ unsigned int i;
int ret;
dfi = devm_kzalloc_obj(dev, *dfi);
@@ -870,6 +875,22 @@ static int rockchip_dfi_probe(struct platform_device *pdev)
desc->driver_data = dfi;
desc->name = np->name;
+ if (dfi->variant->num_clks) {
+ /* NB: CCF is fine with us leaving this NULL if num_clks = 0 */
+ dfi->clocks = devm_kcalloc(dev, dfi->variant->num_clks,
+ sizeof(*dfi->clocks), GFP_KERNEL);
+ if (!dfi->clocks)
+ return -ENOMEM;
+
+ for (i = 0; i < dfi->variant->num_clks; i++)
+ dfi->clocks[i].id = dfi->variant->clk_names[i];
+
+ ret = devm_clk_bulk_get(dev, dfi->variant->num_clks,
+ dfi->clocks);
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to get clocks\n");
+ }
+
ret = dfi->variant->init(dfi);
if (ret)
return ret;
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v3 6/9] PM / devfreq: rockchip-dfi: make RK3588 use its clocks
2026-11-17 15:35 [PATCH v3 0/9] PM / devfreq: rockchip-dfi: cleanups and RK3576 support Sebastian Reichel
` (4 preceding siblings ...)
2026-11-17 15:35 ` [PATCH v3 5/9] PM / devfreq: rockchip-dfi: use bulk clock APIs Sebastian Reichel
@ 2026-11-17 15:35 ` Sebastian Reichel
2026-11-18 20:54 ` kernel test robot
2026-11-17 15:35 ` [PATCH v3 7/9] PM / devfreq: rockchip-dfi: move register offsets to variant struct Sebastian Reichel
` (3 subsequent siblings)
9 siblings, 1 reply; 13+ messages in thread
From: Sebastian Reichel @ 2026-11-17 15:35 UTC (permalink / raw)
To: Chanwoo Choi, MyungJoo Ham, Kyungmin Park, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Heiko Stuebner, Sascha Hauer
Cc: Nicolas Frattaroli, linux-pm, devicetree, linux-arm-kernel,
linux-rockchip, linux-kernel, kernel, Sebastian Reichel
From: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
So far, RK3588 doesn't have the pclks for DDRMON used in the driver, as
they weren't modelled before.
However, they are now correctly modelled, so the driver should use them
when possible.
Instead of unconditionally getting them for this SoC, add a new variant
member that specifies whether the driver should let missing clocks
slide. This is needed because we want old device trees to keep
functioning, as otherwise we'd be introducing a breaking change for
literally no functional difference here.
Fill out a clock name list for this variant as well, and hand it to it.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/devfreq/event/rockchip-dfi.c | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
diff --git a/drivers/devfreq/event/rockchip-dfi.c b/drivers/devfreq/event/rockchip-dfi.c
index 150fdf577e11..a97c63cdab57 100644
--- a/drivers/devfreq/event/rockchip-dfi.c
+++ b/drivers/devfreq/event/rockchip-dfi.c
@@ -117,6 +117,18 @@ struct rockchip_dfi {
const struct rockchip_dfi_variant *variant;
};
+/**
+ * struct rockchip_dfi_variant
+ * @init: pointer to the variant-specific initialisation function
+ * @stride: address offset between the DDRMON per-channel instances
+ * @ctrl_single: whether only one DDRMON instance monitors multiple channels
+ * @max_channels: maximum number of memory channels for this SoC
+ * @clk_names: pointer to a constant array of constant clock name strings
+ * @num_clk: the number of elements in the @clk_names array
+ * @clocks_optional: whether not finding the clocks is non-fatal. Set if the
+ * DT binding for this variant didn't require clocks in the
+ * past, so that the driver remains compatible with old DTs.
+ */
struct rockchip_dfi_variant {
int (*init)(struct rockchip_dfi *dfi);
int stride;
@@ -124,6 +136,7 @@ struct rockchip_dfi_variant {
unsigned int max_channels;
const char * const *clk_names;
unsigned int num_clks;
+ bool clocks_optional;
};
static int rockchip_dfi_ddrtype_to_ctrl(struct rockchip_dfi *dfi, u32 *ctrl)
@@ -806,6 +819,11 @@ static const char * const rk3399_clk_names[] = {
"pclk_ddr_mon",
};
+static const char * const rk3588_clk_names[] = {
+ "pclk_ddr_mon_ch0", "pclk_ddr_mon_ch1", "pclk_ddr_mon_ch2",
+ "pclk_ddr_mon_ch3",
+};
+
static const struct rockchip_dfi_variant rk3399_variant = {
.init = rk3399_dfi_init,
.stride = 0x14,
@@ -826,6 +844,9 @@ static const struct rockchip_dfi_variant rk3588_variant = {
.init = rk3588_dfi_init,
.stride = 0x4000,
.max_channels = 4,
+ .clk_names = rk3588_clk_names,
+ .num_clks = ARRAY_SIZE(rk3588_clk_names),
+ .clocks_optional = true,
};
static const struct of_device_id rockchip_dfi_id_match[] = {
@@ -885,8 +906,12 @@ static int rockchip_dfi_probe(struct platform_device *pdev)
for (i = 0; i < dfi->variant->num_clks; i++)
dfi->clocks[i].id = dfi->variant->clk_names[i];
- ret = devm_clk_bulk_get(dev, dfi->variant->num_clks,
- dfi->clocks);
+ if (dfi->variant->clocks_optional)
+ ret = devm_clk_bulk_get_optional(dev, dfi->variant->num_clks,
+ dfi->clocks);
+ else
+ ret = devm_clk_bulk_get(dev, dfi->variant->num_clks,
+ dfi->clocks);
if (ret)
return dev_err_probe(dev, ret, "failed to get clocks\n");
}
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH v3 6/9] PM / devfreq: rockchip-dfi: make RK3588 use its clocks
2026-11-17 15:35 ` [PATCH v3 6/9] PM / devfreq: rockchip-dfi: make RK3588 use its clocks Sebastian Reichel
@ 2026-11-18 20:54 ` kernel test robot
0 siblings, 0 replies; 13+ messages in thread
From: kernel test robot @ 2026-11-18 20:54 UTC (permalink / raw)
To: Sebastian Reichel, Chanwoo Choi, MyungJoo Ham, Kyungmin Park,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Heiko Stuebner,
Sascha Hauer
Cc: oe-kbuild-all, Nicolas Frattaroli, linux-pm, devicetree,
linux-arm-kernel, linux-rockchip, linux-kernel, kernel,
Sebastian Reichel
Hi Sebastian,
kernel test robot noticed the following build warnings:
[auto build test WARNING on chanwoo/devfreq-next]
[also build test WARNING on chanwoo/devfreq-testing next-20261116]
[cannot apply to rockchip/for-next robh/for-next linus/master v7.4-rc3]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Sebastian-Reichel/dt-bindings-devfreq-event-rockchip-dfi-add-clocks-to-rk3588/20261117-163537
base: https://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/linux.git devfreq-next
patch link: https://lore.kernel.org/r/20261117-rockchip-dfi-rk3588-cleanups-and-rk3576-support-v3-6-32ff1546b0e4%40collabora.com
patch subject: [PATCH v3 6/9] PM / devfreq: rockchip-dfi: make RK3588 use its clocks
config: arm64-defconfig (https://download.01.org/0day-ci/archive/20261119/202611190436.kIOKt8jJ-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 16.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261119/202611190436.kIOKt8jJ-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202611190436.kIOKt8jJ-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> Warning: drivers/devfreq/event/rockchip-dfi.c:139 struct member 'num_clks' not described in 'rockchip_dfi_variant'
>> Warning: drivers/devfreq/event/rockchip-dfi.c:139 Excess struct member 'num_clk' description in 'rockchip_dfi_variant' (did you mean one of: 'num_clks')
>> Warning: drivers/devfreq/event/rockchip-dfi.c:139 struct member 'num_clks' not described in 'rockchip_dfi_variant'
>> Warning: drivers/devfreq/event/rockchip-dfi.c:139 Excess struct member 'num_clk' description in 'rockchip_dfi_variant' (did you mean one of: 'num_clks')
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v3 7/9] PM / devfreq: rockchip-dfi: move register offsets to variant struct
2026-11-17 15:35 [PATCH v3 0/9] PM / devfreq: rockchip-dfi: cleanups and RK3576 support Sebastian Reichel
` (5 preceding siblings ...)
2026-11-17 15:35 ` [PATCH v3 6/9] PM / devfreq: rockchip-dfi: make RK3588 use its clocks Sebastian Reichel
@ 2026-11-17 15:35 ` Sebastian Reichel
2026-11-17 15:35 ` [PATCH v3 8/9] PM / devfreq: rockchip-dfi: prepare support for v4 DDRMON Sebastian Reichel
` (2 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Sebastian Reichel @ 2026-11-17 15:35 UTC (permalink / raw)
To: Chanwoo Choi, MyungJoo Ham, Kyungmin Park, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Heiko Stuebner, Sascha Hauer
Cc: Nicolas Frattaroli, linux-pm, devicetree, linux-arm-kernel,
linux-rockchip, linux-kernel, kernel, Sebastian Reichel
DDRMON in version 0x40 (found in RK3576) has two control registers,
which moves the register addresses. Move the register offsets from the
defines to the varaint struct to ease supporting the newer version.
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/devfreq/event/rockchip-dfi.c | 34 ++++++++++++++++++++++++----------
1 file changed, 24 insertions(+), 10 deletions(-)
diff --git a/drivers/devfreq/event/rockchip-dfi.c b/drivers/devfreq/event/rockchip-dfi.c
index a97c63cdab57..33a379618eb5 100644
--- a/drivers/devfreq/event/rockchip-dfi.c
+++ b/drivers/devfreq/event/rockchip-dfi.c
@@ -42,12 +42,6 @@
#define DDRMON_CTRL_TIMER_CNT_EN BIT(0)
#define DDRMON_CTRL_LP5_BANK_MODE_MASK GENMASK(8, 7)
-#define DDRMON_CH0_WR_NUM 0x20
-#define DDRMON_CH0_RD_NUM 0x24
-#define DDRMON_CH0_COUNT_NUM 0x28
-#define DDRMON_CH0_DFI_ACCESS_NUM 0x2c
-#define DDRMON_CH1_COUNT_NUM 0x3c
-#define DDRMON_CH1_DFI_ACCESS_NUM 0x40
#define PERF_EVENT_CYCLES 0x0
#define PERF_EVENT_READ_BYTES 0x1
@@ -128,6 +122,10 @@ struct rockchip_dfi {
* @clocks_optional: whether not finding the clocks is non-fatal. Set if the
* DT binding for this variant didn't require clocks in the
* past, so that the driver remains compatible with old DTs.
+ * @reg_write_access: register offset for writes access
+ * @reg_read_access: register offset for read access
+ * @reg_access: register offset for read/write access
+ * @reg_clock_cycles: register offset for clock cycles
*/
struct rockchip_dfi_variant {
int (*init)(struct rockchip_dfi *dfi);
@@ -137,6 +135,10 @@ struct rockchip_dfi_variant {
const char * const *clk_names;
unsigned int num_clks;
bool clocks_optional;
+ u8 reg_write_access;
+ u8 reg_read_access;
+ u8 reg_access;
+ u8 reg_clock_cycles;
};
static int rockchip_dfi_ddrtype_to_ctrl(struct rockchip_dfi *dfi, u32 *ctrl)
@@ -277,13 +279,13 @@ static void rockchip_dfi_read_counters(struct rockchip_dfi *dfi, struct dmc_coun
if (!(dfi->channel_mask & BIT(i)))
continue;
res->c[i].read_access = readl_relaxed(dfi_regs +
- DDRMON_CH0_RD_NUM + i * dfi->variant->stride);
+ dfi->variant->reg_read_access + i * dfi->variant->stride);
res->c[i].write_access = readl_relaxed(dfi_regs +
- DDRMON_CH0_WR_NUM + i * dfi->variant->stride);
+ dfi->variant->reg_write_access + i * dfi->variant->stride);
res->c[i].access = readl_relaxed(dfi_regs +
- DDRMON_CH0_DFI_ACCESS_NUM + i * dfi->variant->stride);
+ dfi->variant->reg_access + i * dfi->variant->stride);
res->c[i].clock_cycles = readl_relaxed(dfi_regs +
- DDRMON_CH0_COUNT_NUM + i * dfi->variant->stride);
+ dfi->variant->reg_clock_cycles + i * dfi->variant->stride);
}
}
@@ -831,6 +833,10 @@ static const struct rockchip_dfi_variant rk3399_variant = {
.max_channels = 2,
.clk_names = rk3399_clk_names,
.num_clks = ARRAY_SIZE(rk3399_clk_names),
+ .reg_write_access = 0x20,
+ .reg_read_access = 0x24,
+ .reg_clock_cycles = 0x28,
+ .reg_access = 0x2c,
};
static const struct rockchip_dfi_variant rk3568_variant = {
@@ -838,6 +844,10 @@ static const struct rockchip_dfi_variant rk3568_variant = {
.stride = 0x0,
.ctrl_single = true,
.max_channels = 1,
+ .reg_write_access = 0x20,
+ .reg_read_access = 0x24,
+ .reg_clock_cycles = 0x28,
+ .reg_access = 0x2c,
};
static const struct rockchip_dfi_variant rk3588_variant = {
@@ -847,6 +857,10 @@ static const struct rockchip_dfi_variant rk3588_variant = {
.clk_names = rk3588_clk_names,
.num_clks = ARRAY_SIZE(rk3588_clk_names),
.clocks_optional = true,
+ .reg_write_access = 0x20,
+ .reg_read_access = 0x24,
+ .reg_clock_cycles = 0x28,
+ .reg_access = 0x2c,
};
static const struct of_device_id rockchip_dfi_id_match[] = {
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v3 8/9] PM / devfreq: rockchip-dfi: prepare support for v4 DDRMON
2026-11-17 15:35 [PATCH v3 0/9] PM / devfreq: rockchip-dfi: cleanups and RK3576 support Sebastian Reichel
` (6 preceding siblings ...)
2026-11-17 15:35 ` [PATCH v3 7/9] PM / devfreq: rockchip-dfi: move register offsets to variant struct Sebastian Reichel
@ 2026-11-17 15:35 ` Sebastian Reichel
2026-11-17 15:35 ` [PATCH v3 9/9] PM / devfreq: rockchip-dfi: add RK3576 support Sebastian Reichel
2026-11-18 21:03 ` [PATCH v3 0/9] PM / devfreq: rockchip-dfi: cleanups and " Sebastian Reichel
9 siblings, 0 replies; 13+ messages in thread
From: Sebastian Reichel @ 2026-11-17 15:35 UTC (permalink / raw)
To: Chanwoo Choi, MyungJoo Ham, Kyungmin Park, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Heiko Stuebner, Sascha Hauer
Cc: Nicolas Frattaroli, linux-pm, devicetree, linux-arm-kernel,
linux-rockchip, linux-kernel, kernel, Sebastian Reichel
Add support for the new control register layout found for DDRMON
controllers having version 0x40. This prepares the driver for
adding RK3576 support.
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/devfreq/event/rockchip-dfi.c | 84 ++++++++++++++++++++++++++----------
1 file changed, 61 insertions(+), 23 deletions(-)
diff --git a/drivers/devfreq/event/rockchip-dfi.c b/drivers/devfreq/event/rockchip-dfi.c
index 33a379618eb5..ed28dc6446f1 100644
--- a/drivers/devfreq/event/rockchip-dfi.c
+++ b/drivers/devfreq/event/rockchip-dfi.c
@@ -42,6 +42,19 @@
#define DDRMON_CTRL_TIMER_CNT_EN BIT(0)
#define DDRMON_CTRL_LP5_BANK_MODE_MASK GENMASK(8, 7)
+#define DDRMON_CTRL0 0x04
+#define DDRMON_CTRL0_EXT_TRIGGER_EN BIT(6)
+#define DDRMON_CTRL0_DDR4 BIT(5)
+#define DDRMON_CTRL0_LPDDR4 BIT(4)
+#define DDRMON_CTRL0_HARDWARE_EN BIT(3)
+#define DDRMON_CTRL0_LPDDR23 BIT(2)
+#define DDRMON_CTRL0_SOFTWARE_EN BIT(1)
+#define DDRMON_CTRL0_TIMER_CNT_EN BIT(0)
+#define DDRMON_CTRL0_HOT_RANK GENMASK(8, 7)
+
+#define DDRMON_CTRL1 0x08
+#define DDRMON_CTRL1_LPDDR5 BIT(0)
+#define DDRMON_CTRL1_LP5_BANK_MODE_MASK GENMASK(2, 1)
#define PERF_EVENT_CYCLES 0x0
#define PERF_EVENT_READ_BYTES 0x1
@@ -143,8 +156,6 @@ struct rockchip_dfi_variant {
static int rockchip_dfi_ddrtype_to_ctrl(struct rockchip_dfi *dfi, u32 *ctrl)
{
- u32 ddrmon_ver;
-
switch (dfi->ddr_type) {
case ROCKCHIP_DDRTYPE_LPDDR2:
case ROCKCHIP_DDRTYPE_LPDDR3:
@@ -159,26 +170,43 @@ static int rockchip_dfi_ddrtype_to_ctrl(struct rockchip_dfi *dfi, u32 *ctrl)
FIELD_PREP_WM16(DDRMON_CTRL_LPDDR5, 0);
break;
case ROCKCHIP_DDRTYPE_LPDDR5:
- ddrmon_ver = readl_relaxed(dfi->regs);
- if (ddrmon_ver < 0x40) {
- *ctrl = FIELD_PREP_WM16(DDRMON_CTRL_LPDDR23, 0) |
- FIELD_PREP_WM16(DDRMON_CTRL_LPDDR4, 0) |
- FIELD_PREP_WM16(DDRMON_CTRL_LPDDR5, 1) |
- FIELD_PREP_WM16(DDRMON_CTRL_LP5_BANK_MODE_MASK,
- dfi->lp5_bank_mode);
- break;
- }
-
- /*
- * As it is unknown whether the unpleasant special case
- * behaviour used by the vendor kernel is needed for any
- * shipping hardware, ask users to report if they have
- * some of that hardware.
- */
- dev_err(&dfi->edev->dev,
- "unsupported DDRMON version 0x%04X, please let linux-rockchip know!\n",
- ddrmon_ver);
+ *ctrl = FIELD_PREP_WM16(DDRMON_CTRL_LPDDR23, 0) |
+ FIELD_PREP_WM16(DDRMON_CTRL_LPDDR4, 0) |
+ FIELD_PREP_WM16(DDRMON_CTRL_LPDDR5, 1) |
+ FIELD_PREP_WM16(DDRMON_CTRL_LP5_BANK_MODE_MASK,
+ dfi->lp5_bank_mode);
+ break;
+ default:
+ dev_err(&dfi->edev->dev, "unsupported memory type 0x%X\n",
+ dfi->ddr_type);
return -EOPNOTSUPP;
+ }
+
+ return 0;
+}
+
+static int rockchip_dfi_v4_ddrtype_to_ctrl(struct rockchip_dfi *dfi, u32 *ctrl0, u32 *ctrl1)
+{
+ switch (dfi->ddr_type) {
+ case ROCKCHIP_DDRTYPE_LPDDR2:
+ case ROCKCHIP_DDRTYPE_LPDDR3:
+ *ctrl0 = FIELD_PREP_WM16(DDRMON_CTRL0_LPDDR23, 1) |
+ FIELD_PREP_WM16(DDRMON_CTRL0_LPDDR4, 0);
+ *ctrl1 = FIELD_PREP_WM16(DDRMON_CTRL1_LPDDR5, 0);
+ break;
+ case ROCKCHIP_DDRTYPE_LPDDR4:
+ case ROCKCHIP_DDRTYPE_LPDDR4X:
+ *ctrl0 = FIELD_PREP_WM16(DDRMON_CTRL0_LPDDR23, 0) |
+ FIELD_PREP_WM16(DDRMON_CTRL0_LPDDR4, 1);
+ *ctrl1 = FIELD_PREP_WM16(DDRMON_CTRL1_LPDDR5, 0);
+ break;
+ case ROCKCHIP_DDRTYPE_LPDDR5:
+ *ctrl0 = FIELD_PREP_WM16(DDRMON_CTRL0_LPDDR23, 0) |
+ FIELD_PREP_WM16(DDRMON_CTRL0_LPDDR4, 0);
+ *ctrl1 = FIELD_PREP_WM16(DDRMON_CTRL1_LPDDR5, 1) |
+ FIELD_PREP_WM16(DDRMON_CTRL_LP5_BANK_MODE_MASK,
+ dfi->lp5_bank_mode);
+ break;
default:
dev_err(&dfi->edev->dev, "unsupported memory type 0x%X\n",
dfi->ddr_type);
@@ -188,11 +216,12 @@ static int rockchip_dfi_ddrtype_to_ctrl(struct rockchip_dfi *dfi, u32 *ctrl)
return 0;
}
+
static int rockchip_dfi_enable(struct rockchip_dfi *dfi)
{
void __iomem *dfi_regs = dfi->regs;
+ u32 ctrl, ctrl1, ddrmon_ver;
int i, ret = 0;
- u32 ctrl;
mutex_lock(&dfi->mutex);
@@ -207,7 +236,12 @@ static int rockchip_dfi_enable(struct rockchip_dfi *dfi)
goto out;
}
- ret = rockchip_dfi_ddrtype_to_ctrl(dfi, &ctrl);
+ ddrmon_ver = readl_relaxed(dfi->regs);
+ if (ddrmon_ver < 0x40)
+ ret = rockchip_dfi_ddrtype_to_ctrl(dfi, &ctrl);
+ else
+ ret = rockchip_dfi_v4_ddrtype_to_ctrl(dfi, &ctrl, &ctrl1);
+
if (ret) {
clk_bulk_disable_unprepare(dfi->variant->num_clks, dfi->clocks);
goto out;
@@ -227,6 +261,10 @@ static int rockchip_dfi_enable(struct rockchip_dfi *dfi)
writel_relaxed(ctrl, dfi_regs + i * dfi->variant->stride +
DDRMON_CTRL);
+ if (ddrmon_ver >= 0x40)
+ writel_relaxed(ctrl1, dfi_regs + i * dfi->variant->stride +
+ DDRMON_CTRL1);
+
/* enable count, use software mode */
writel_relaxed(FIELD_PREP_WM16(DDRMON_CTRL_SOFTWARE_EN, 1),
dfi_regs + i * dfi->variant->stride + DDRMON_CTRL);
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v3 9/9] PM / devfreq: rockchip-dfi: add RK3576 support
2026-11-17 15:35 [PATCH v3 0/9] PM / devfreq: rockchip-dfi: cleanups and RK3576 support Sebastian Reichel
` (7 preceding siblings ...)
2026-11-17 15:35 ` [PATCH v3 8/9] PM / devfreq: rockchip-dfi: prepare support for v4 DDRMON Sebastian Reichel
@ 2026-11-17 15:35 ` Sebastian Reichel
2026-11-18 21:03 ` [PATCH v3 0/9] PM / devfreq: rockchip-dfi: cleanups and " Sebastian Reichel
9 siblings, 0 replies; 13+ messages in thread
From: Sebastian Reichel @ 2026-11-17 15:35 UTC (permalink / raw)
To: Chanwoo Choi, MyungJoo Ham, Kyungmin Park, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Heiko Stuebner, Sascha Hauer
Cc: Nicolas Frattaroli, linux-pm, devicetree, linux-arm-kernel,
linux-rockchip, linux-kernel, kernel, Sebastian Reichel
Add RK3576 support to the DFI driver exposing the same functionality
as found on previous chips. This uses the RK3588 init for getting the
DRAM type info from the GRF registers. In contrast to RK3588 it uses
a newer DDRMON controller IP, though (version 0x40).
Co-developed-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/devfreq/event/rockchip-dfi.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/drivers/devfreq/event/rockchip-dfi.c b/drivers/devfreq/event/rockchip-dfi.c
index ed28dc6446f1..91b6dd01b453 100644
--- a/drivers/devfreq/event/rockchip-dfi.c
+++ b/drivers/devfreq/event/rockchip-dfi.c
@@ -859,6 +859,10 @@ static const char * const rk3399_clk_names[] = {
"pclk_ddr_mon",
};
+static const char * const rk3576_clk_names[] = {
+ "pclk_ddr_mon_ch0", "pclk_ddr_mon_ch1",
+};
+
static const char * const rk3588_clk_names[] = {
"pclk_ddr_mon_ch0", "pclk_ddr_mon_ch1", "pclk_ddr_mon_ch2",
"pclk_ddr_mon_ch3",
@@ -888,6 +892,18 @@ static const struct rockchip_dfi_variant rk3568_variant = {
.reg_access = 0x2c,
};
+static const struct rockchip_dfi_variant rk3576_variant = {
+ .init = rk3588_dfi_init,
+ .stride = 0x10000,
+ .max_channels = 2,
+ .clk_names = rk3576_clk_names,
+ .num_clks = ARRAY_SIZE(rk3576_clk_names),
+ .reg_write_access = 0x28,
+ .reg_read_access = 0x2c,
+ .reg_access = 0x34,
+ .reg_clock_cycles = 0x30,
+};
+
static const struct rockchip_dfi_variant rk3588_variant = {
.init = rk3588_dfi_init,
.stride = 0x4000,
@@ -904,6 +920,7 @@ static const struct rockchip_dfi_variant rk3588_variant = {
static const struct of_device_id rockchip_dfi_id_match[] = {
{ .compatible = "rockchip,rk3399-dfi", .data = &rk3399_variant },
{ .compatible = "rockchip,rk3568-dfi", .data = &rk3568_variant },
+ { .compatible = "rockchip,rk3576-dfi", .data = &rk3576_variant },
{ .compatible = "rockchip,rk3588-dfi", .data = &rk3588_variant },
{ },
};
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH v3 0/9] PM / devfreq: rockchip-dfi: cleanups and RK3576 support
2026-11-17 15:35 [PATCH v3 0/9] PM / devfreq: rockchip-dfi: cleanups and RK3576 support Sebastian Reichel
` (8 preceding siblings ...)
2026-11-17 15:35 ` [PATCH v3 9/9] PM / devfreq: rockchip-dfi: add RK3576 support Sebastian Reichel
@ 2026-11-18 21:03 ` Sebastian Reichel
9 siblings, 0 replies; 13+ messages in thread
From: Sebastian Reichel @ 2026-11-18 21:03 UTC (permalink / raw)
To: Chanwoo Choi, MyungJoo Ham, Kyungmin Park, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Heiko Stuebner, Sascha Hauer
Cc: Nicolas Frattaroli, linux-pm, devicetree, linux-arm-kernel,
linux-rockchip, linux-kernel, kernel
[-- Attachment #1: Type: text/plain, Size: 786 bytes --]
Hi,
On Tue, Nov 17, 2026 at 04:35:36PM +0100, Sebastian Reichel wrote:
> This is a combination of the DFI driver patches from the following two
> series to ease applying to devfreq tree. It is based on devfreq-next
> and there are no other dependencies.
>
> * https://lore.kernel.org/linux-rockchip/20260921-rockchip-dfi-cleanup-v2-0-43ff34ac8599@collabora.com/
> * https://lore.kernel.org/linux-rockchip/20260921-b4-rockchip-dfi-rk3576-support-v2-0-04f847016321@collabora.com/
>
> Changes since PATCHv2:
> * split out DFI driver patches from both series and merge them into a
> new one; clock controller and DT patches will be send separately.
Sorry, I accidently took the v1 patches for this. I will send
corrected v4 tomorrow.
Greetings,
-- Sebastian
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread