PM / devfreq: rockchip-dfi: cleanups and RK3576 support
Subsystems (5)
v4 cover PM / devfreq: rockchip-dfi: cleanups and RK3576 support
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/[email protected]/
* https://lore.kernel.org/linux-rockchip/20260921-b4-rockchip-dfi-rk3576-support-v2-0-04f847016321@collabora.com/
Changes in PATCHv4:
* Link to v3: https://patch.msgid.link/20261117-rockchip-dfi-rk3588-cleanups-and-rk3576-support-v3-0-32ff1546b0e4@collabora.com
* In PATCHv3 I accidentally used the patches from PATCHv1 as base with
the wrong DT bindings; this is now fixed
* I've fixed num_clks typo in kernel doc (Sashiko)
* I've fixed incorrect LPDDR5 BANK_MODE_MASK for RK3576 (Sashiko)
* I added a fix at the start of the series correcting LPDDR5 bank
mode value (Sashiko)
* I've added a fix at the start of the series avoiding usage of
uninitialized memory (Sashiko)
Changes in PATCHv3:
* split out DFI driver patches from both series and merge them into a new one; clock controller and DT patches will be sent separately.
* rebase to devfreq-next
* collecting Reviewed-by / Acked-by
---
Nicolas Frattaroli (6):
dt-bindings: devfreq: event: rockchip,dfi: add clocks to rk3588
dt-bindings: devfreq: event: rockchip,dfi: add rk3576 PM / devfreq: rockchip-dfi: move to per-variant const structs PM / devfreq: rockchip-dfi: add NO_INTERRUPT perf capability PM / devfreq: rockchip-dfi: use bulk clock APIs
PM / devfreq: rockchip-dfi: make RK3588 use its clocks
Sebastian Reichel (5):
PM / devfreq: rockchip-dfi: drop incorrect shift of LP5 bank mode PM / devfreq: rockchip-dfi: initialize dmc_count structs PM / devfreq: rockchip-dfi: move register offsets to variant struct PM / devfreq: rockchip-dfi: prepare support for v4 DDRMON PM / devfreq: rockchip-dfi: add RK3576 support
.../bindings/devfreq/event/rockchip,dfi.yaml | 89 +++++- drivers/devfreq/event/rockchip-dfi.c | 297 +++++++++++++++------ 2 files changed, 290 insertions(+), 96 deletions(-)
---
base-commit: f9316c13d6f621af4f6f4a6089d3c989ffe899e6
change-id: 20261117-rockchip-dfi-rk3588-cleanups-and-rk3576-support-74727d64d729
Best regards,
Signature · 1 line
Sebastian Reichel <[email protected]>
PATCH v4 1/11 dt-bindings: devfreq: event: rockchip,dfi: add clocks to rk3588
From: Nicolas Frattaroli <[email protected]>
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.
--- .../bindings/devfreq/event/rockchip,dfi.yaml | 70 ++++++++++++++++++---- 1 file changed, 58 insertions(+), 12 deletions(-)
Documentation/devicetree/bindings/devfreq/event/rockchip,dfi.yaml +58 -12
@@ -17,11 +17,18 @@ properties: - rockchip,rk3588-dfi clocks: - maxItems: 1 + minItems: 1 + maxItems: 4 clock-names: + minItems: 1 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 +47,37 @@ required: - interrupts - reg -if: - properties: - compatible: - contains: - enum: - - rockchip,rk3399-dfi +allOf: + - if: + properties: + compatible: + contains: + enum: + - rockchip,rk3399-dfi + then: + properties: + clocks: + maxItems: 1 + clock-names: + maxItems: 1 + required: + - clocks + - clock-names -then: - required: - - clocks - - clock-names + - if: + properties: + compatible: + contains: + enum: + - rockchip,rk3588-dfi + then: + properties: + clocks: + minItems: 4 + maxItems: 4 + clock-names: + minItems: 4 + maxItems: 4 additionalProperties: false
@@ -72,3 +99,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>; + }; + };
Signature · 1 line
2.53.0
PATCH v4 2/11 dt-bindings: devfreq: event: rockchip,dfi: add rk3576
In reply to Sebastian ReichelFrom: Nicolas Frattaroli <[email protected]>
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.
--- .../bindings/devfreq/event/rockchip,dfi.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
Documentation/devicetree/bindings/devfreq/event/rockchip,dfi.yaml +19 -0
@@ -14,6 +14,7 @@ properties: enum: - rockchip,rk3399-dfi - rockchip,rk3568-dfi + - rockchip,rk3576-dfi - rockchip,rk3588-dfi clocks:
@@ -64,6 +65,24 @@ allOf: - clocks - clock-names + - if: + properties: + compatible: + contains: + enum: + - rockchip,rk3576-dfi + then: + properties: + clocks: + minItems: 2 + maxItems: 2 + clock-names: + minItems: 2 + maxItems: 2 + required: + - clocks + - clock-names + - if: properties: compatible:
Signature · 1 line
2.53.0
PATCH v4 3/11 PM / devfreq: rockchip-dfi: drop incorrect shift of LP5 bank mode
In reply to Sebastian ReichelWhen the driver got converted to the FIELD_PREP_WM16 macro, it was missed that the lp5_bank_mode variable is already shifted in rk3588_dfi_init() resulting in FIELD_PREP_WM16() effectively doing a double shift and thus writing 0.
As most Rockchip boards use LPDDR4 (incl. all of mine) and DFI is more or less exclusively used for debugging with upstream kernel so far, this hasn't been noticed until now.
--- drivers/devfreq/event/rockchip-dfi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/devfreq/event/rockchip-dfi.c +1 -1
@@ -800,7 +800,7 @@ static int rk3588_dfi_init(struct rockchip_dfi *dfi)if (dfi->ddr_type ==ROCKCHIP_DDRTYPE_LPDDR5 ) {regmap_read (regmap_pmu,RK3588_PMUGRF_OS_REG6 , ®6); - dfi->lp5_bank_mode =FIELD_GET (RK3588_PMUGRF_OS_REG6_LP5_BANK_MODE , reg6) <<7 ; + dfi->lp5_bank_mode =FIELD_GET (RK3588_PMUGRF_OS_REG6_LP5_BANK_MODE , reg6); dfi->lp5_ckr =FIELD_GET (RK3588_PMUGRF_OS_REG6_LP5_CKR , reg6);if (dfi->lp5_ckr) dfi->count_multiplier *=2 ;
Signature · 1 line
2.53.0
PATCH v4 4/11 PM / devfreq: rockchip-dfi: initialize dmc_count structs
In reply to Sebastian ReichelInitialize 'struct dmc_count' before filling it with data by rockchip_dfi_read_counters() or rockchip_ddr_perf_counters_add() to avoid exposing uninitialized memory for unused channels.
--- drivers/devfreq/event/rockchip-dfi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/devfreq/event/rockchip-dfi.c +3 -3
@@ -291,7 +291,7 @@ static int rockchip_dfi_get_event(struct devfreq_event_dev *edev, struct devfreq_event_data *edata) {struct rockchip_dfi *dfi =devfreq_event_get_drvdata (edev); -struct dmc_count count; +struct dmc_count count = {};struct dmc_count *last = &dfi->last_event_count;u32 access =0 , clock_cycles =0 ;int i;
@@ -462,7 +462,7 @@ static u64 rockchip_ddr_perf_event_get_count(struct perf_event *event) { struct rockchip_dfi *dfi = container_of(event->pmu, struct rockchip_dfi, pmu);int blen = dfi->burst_len; -struct dmc_count total, now; +struct dmc_count total = {}, now = {};unsigned int seq;u64 count =0 ;int i;
@@ -577,7 +577,7 @@ static void rockchip_ddr_perf_event_del(struct perf_event *event, int flags)static enum hrtimer_restart rockchip_dfi_timer (struct hrtimer *timer) { struct rockchip_dfi *dfi = container_of(timer, struct rockchip_dfi, timer); -struct dmc_count now, total; +struct dmc_count now = {}, total = {};rockchip_dfi_read_counters (dfi, &now);
Signature · 1 line
2.53.0
PATCH v4 5/11 PM / devfreq: rockchip-dfi: move to per-variant const structs
In reply to Sebastian ReichelFrom: Nicolas Frattaroli <[email protected]>
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.
--- drivers/devfreq/event/rockchip-dfi.c | 94 +++++++++++++++++++++--------------- 1 file changed, 54 insertions(+), 40 deletions(-)
drivers/devfreq/event/rockchip-dfi.c +54 -40
@@ -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_counu32 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;
Signature · 1 line
2.53.0
PATCH v4 6/11 PM / devfreq: rockchip-dfi: add NO_INTERRUPT perf capability
In reply to Sebastian ReichelFrom: Nicolas Frattaroli <[email protected]>
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 not 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.
--- drivers/devfreq/event/rockchip-dfi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/devfreq/event/rockchip-dfi.c +1 -1
@@ -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;
Signature · 1 line
2.53.0
PATCH v4 7/11 PM / devfreq: rockchip-dfi: use bulk clock APIs
In reply to Sebastian ReichelFrom: Nicolas Frattaroli <[email protected]>
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.
--- drivers/devfreq/event/rockchip-dfi.c | 41 +++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 10 deletions(-)
drivers/devfreq/event/rockchip-dfi.c +31 -10
@@ -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;
Signature · 1 line
2.53.0
PATCH v4 8/11 PM / devfreq: rockchip-dfi: make RK3588 use its clocks
In reply to Sebastian ReichelFrom: Nicolas Frattaroli <[email protected]>
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.
--- drivers/devfreq/event/rockchip-dfi.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-)
drivers/devfreq/event/rockchip-dfi.c +27 -2
@@ -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_clks: 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" ); }
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v4 08/11] PM / devfreq: rockchip-dfi: make RK3588 use its clocks
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] PM / devfreq: rockchip-dfi: missing kernel-doc short description --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] PM / devfreq: rockchip-dfi: missing kernel-doc short description --
commit 24f7e34d7d4ec9010ccc0577ac36a0764e1b939d
Author: Nicolas Frattaroli <[email protected]>
PM / devfreq: rockchip-dfi: make RK3588 use its clocks
This commit adds optional bulk clock support to struct rockchip_dfi_variant and populates the per-channel DDRMON clocks for RK3588.
drivers/devfreq/event/rockchip-dfi.c struct rockchip_dfi { · line 122
Quoted 11 lines
drivers/devfreq/event/rockchip-dfi.c +3
-0@@ -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
[Severity: Low]
Should this kernel-doc header line include a "- short description" after "struct rockchip_dfi_variant"? Without it, building with W=2 emits a kernel-doc "missing initial short description on line" warning.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20261119-rockchip-dfi-rk3588-cleanups-and-rk3576-support-v4-0-517a68c008fe@collabora.com?part=8
Re: [PATCH v4 08/11] PM / devfreq: rockchip-dfi: make RK3588 use its clocks
In reply to Sebastian ReichelHi,
Quoted 54 lines · Sebastian Reichel
From: Nicolas Frattaroli <[email protected]>
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 <[email protected]>Signed-off-by Sebastian Reichel <[email protected]>--- drivers/devfreq/event/rockchip-dfi.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-)drivers/devfreq/event/rockchip-dfi.c +13
-0@@ -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_clks: 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)
drivers/devfreq/event/rockchip-dfi.c static const char * const rk3399_clk_names[] = { · line 825
Quoted 7 lines
drivers/devfreq/event/rockchip-dfi.c +4
-0@@ -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" , +};
For proper operation of this patch, the following patch should be applied. The following patch is applied to other git?
Quoted 30 lines
drivers/devfreq/event/rockchip-dfi.c +10
-2+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" ); }
Signature · 3 lines
Best Regards, Chanwoo Choi Principal Engineer, Samsung Electronics
Re: [PATCH v4 08/11] PM / devfreq: rockchip-dfi: make RK3588 use its clocks
Hello Chanwoo,
Quoted 9 lines · Chanwoo Choi
drivers/devfreq/event/rockchip-dfi.c static const char * const rk3399_clk_names[] = { · line 825
Quoted 4 lines
drivers/devfreq/event/rockchip-dfi.c +4
-0+static const char *const rk3588_clk_names[] = { +"pclk_ddr_mon_ch0" ,"pclk_ddr_mon_ch1" ,"pclk_ddr_mon_ch2" , +"pclk_ddr_mon_ch3" , +};For proper operation of this patch, the following patch should be applied. The following patch is applied to other git?
Let me quote the cover letter:
Changes in PATCHv3:
* split out DFI driver patches from both series and merge them into a new one; clock controller and DT patches will be sent separately.
FWIW those clock names are from DT, referencing them in DT obviously requires the clocks to exist in the first place. I will send a series with the clocks and the DT changes later today.
Greetings,
-- Sebastian
_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
PATCH v4 9/11 PM / devfreq: rockchip-dfi: move register offsets to variant struct
In reply to Sebastian ReichelDDRMON 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.
--- drivers/devfreq/event/rockchip-dfi.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-)
drivers/devfreq/event/rockchip-dfi.c +24 -10
@@ -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_counif (!(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[] = {
Signature · 1 line
2.53.0
PATCH v4 10/11 PM / devfreq: rockchip-dfi: prepare support for v4 DDRMON
In reply to Sebastian ReichelAdd support for the new control register layout found for DDRMON controllers having version 0x40. This prepares the driver for adding RK3576 support.
--- drivers/devfreq/event/rockchip-dfi.c | 84 ++++++++++++++++++++++++++---------- 1 file changed, 61 insertions(+), 23 deletions(-)
drivers/devfreq/event/rockchip-dfi.c +61 -23
@@ -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_CTRL1_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 );
Signature · 1 line
2.53.0
PATCH v4 11/11 PM / devfreq: rockchip-dfi: add RK3576 support
In reply to Sebastian ReichelAdd 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).
--- drivers/devfreq/event/rockchip-dfi.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/devfreq/event/rockchip-dfi.c +17 -0
@@ -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 }, { }, };
Signature · 1 line
2.53.0
Chanwoo Choi
AppliedQuoted 41 lines · Sebastian Reichel
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/[email protected]/
* https://lore.kernel.org/linux-rockchip/20260921-b4-rockchip-dfi-rk3576-support-v2-0-04f847016321@collabora.com/Changes in PATCHv4:
* Link to v3: https://patch.msgid.link/20261117-rockchip-dfi-rk3588-cleanups-and-rk3576-support-v3-0-32ff1546b0e4@collabora.com
* In PATCHv3 I accidentally used the patches from PATCHv1 as base with
the wrong DT bindings; this is now fixed
* I've fixednum_clkstypo in kernel doc (Sashiko)
* I've fixed incorrect LPDDR5BANK_MODE_MASKfor RK3576 (Sashiko)
* I added a fix at the start of the series correcting LPDDR5 bank
mode value (Sashiko)
* I've added a fix at the start of the series avoiding usage of
uninitialized memory (Sashiko)Changes in PATCHv3:
* split out DFI driver patches from both series and merge them into a new one; clock controller and DT patches will be sent separately.
* rebase to devfreq-next
* collecting Reviewed-by / Acked-bySigned-off-by Sebastian Reichel <[email protected]>---
Nicolas Frattaroli (6):
dt-bindings: devfreq: event: rockchip,dfi: add clocks to rk3588
dt-bindings: devfreq: event: rockchip,dfi: add rk3576 PM / devfreq: rockchip-dfi: move to per-variant const structs PM / devfreq: rockchip-dfi: addNO_INTERRUPTperf capability PM / devfreq: rockchip-dfi: use bulk clock APIs
PM / devfreq: rockchip-dfi: make RK3588 use its clocksSebastian Reichel (5):
PM / devfreq: rockchip-dfi: drop incorrect shift of LP5 bank mode PM / devfreq: rockchip-dfi: initializedmc_countstructs PM / devfreq: rockchip-dfi: move register offsets to variant struct PM / devfreq: rockchip-dfi: prepare support for v4 DDRMON PM / devfreq: rockchip-dfi: add RK3576 support
Quoted 10 lines
.../bindings/devfreq/event/rockchip,dfi.yaml | 89 +++++- drivers/devfreq/event/rockchip-dfi.c | 297 +++++++++++++++------ 2 files changed, 290 insertions(+), 96 deletions(-)---
base-commit:f9316c13d6f621af4f6f4a6089d3c989ffe899e6
change-id: 20261117-rockchip-dfi-rk3588-cleanups-and-rk3576-support-74727d64d729Best regards,
Signature · 1 line
Sebastian Reichel <[email protected]>
Applied them. But you also need to send the clock patch[1] and get it applied.
[1] https://lore.kernel.org/linux-rockchip/[email protected]/
Thanks,
Signature · 3 lines
Best Regards, Chanwoo Choi Principal Engineer, Samsung Electronics
Hi,
Quoted 49 lines · Chanwoo Choi
Quoted 48 lines · Sebastian Reichel
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/[email protected]/
* https://lore.kernel.org/linux-rockchip/20260921-b4-rockchip-dfi-rk3576-support-v2-0-04f847016321@collabora.com/Changes in PATCHv4:
* Link to v3: https://patch.msgid.link/20261117-rockchip-dfi-rk3588-cleanups-and-rk3576-support-v3-0-32ff1546b0e4@collabora.com
* In PATCHv3 I accidentally used the patches from PATCHv1 as base with
the wrong DT bindings; this is now fixed
* I've fixednum_clkstypo in kernel doc (Sashiko)
* I've fixed incorrect LPDDR5BANK_MODE_MASKfor RK3576 (Sashiko)
* I added a fix at the start of the series correcting LPDDR5 bank
mode value (Sashiko)
* I've added a fix at the start of the series avoiding usage of
uninitialized memory (Sashiko)Changes in PATCHv3:
* split out DFI driver patches from both series and merge them into a new one; clock controller and DT patches will be sent separately.
* rebase to devfreq-next
* collecting Reviewed-by / Acked-bySigned-off-by Sebastian Reichel <[email protected]>---
Nicolas Frattaroli (6):
dt-bindings: devfreq: event: rockchip,dfi: add clocks to rk3588
dt-bindings: devfreq: event: rockchip,dfi: add rk3576 PM / devfreq: rockchip-dfi: move to per-variant const structs PM / devfreq: rockchip-dfi: addNO_INTERRUPTperf capability PM / devfreq: rockchip-dfi: use bulk clock APIs
PM / devfreq: rockchip-dfi: make RK3588 use its clocksSebastian Reichel (5):
PM / devfreq: rockchip-dfi: drop incorrect shift of LP5 bank mode PM / devfreq: rockchip-dfi: initializedmc_countstructs PM / devfreq: rockchip-dfi: move register offsets to variant struct PM / devfreq: rockchip-dfi: prepare support for v4 DDRMON PM / devfreq: rockchip-dfi: add RK3576 support.../bindings/devfreq/event/rockchip,dfi.yaml | 89 +++++- drivers/devfreq/event/rockchip-dfi.c | 297 +++++++++++++++------ 2 files changed, 290 insertions(+), 96 deletions(-)---
base-commit:f9316c13d6f621af4f6f4a6089d3c989ffe899e6
change-id: 20261117-rockchip-dfi-rk3588-cleanups-and-rk3576-support-74727d64d729
Quoted 7 lines
Quoted 3 lines
Best regards,
Signature · 1 line
Sebastian Reichel <[email protected]>Applied them. But you also need to send the clock patch[1] and get it applied. [1]
https://lore.kernel.org/linux-rockchip/[email protected]/
Thanks. The clock patches (RK3588 & RK3576) as well as the DT additions are on my TODO list. The DT side had a dependency on the DT binding being merged first, so I was not too much in a hurry to send them out (esp. considering nothing changed in them since v1).
I will see to send them out today.
Greetings,
-- Sebastian
_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip