Re: [PATCH v7 10/26] PM / devfreq: rockchip-dfi: Add RK3568 support

From: Sascha Hauer
Date: Mon Oct 16 2023 - 07:35:04 EST


On Sat, Oct 07, 2023 at 03:17:14AM +0900, Chanwoo Choi wrote:
> On 23. 7. 4. 18:32, Sascha Hauer wrote:
> > This adds RK3568 support to the DFI driver. Only iniitialization
> > differs from the currently supported RK3399.
> >
> > Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
> > ---
> > drivers/devfreq/event/rockchip-dfi.c | 21 +++++++++++++++++++++
> > include/soc/rockchip/rk3568_grf.h | 12 ++++++++++++
> > 2 files changed, 33 insertions(+)
> > create mode 100644 include/soc/rockchip/rk3568_grf.h
> >
> > diff --git a/drivers/devfreq/event/rockchip-dfi.c b/drivers/devfreq/event/rockchip-dfi.c
> > index 6b3ef97b3be09..261d112580c9e 100644
> > --- a/drivers/devfreq/event/rockchip-dfi.c
> > +++ b/drivers/devfreq/event/rockchip-dfi.c
> > @@ -23,6 +23,7 @@
> >
> > #include <soc/rockchip/rockchip_grf.h>
> > #include <soc/rockchip/rk3399_grf.h>
> > +#include <soc/rockchip/rk3568_grf.h>
> >
> > #define DMC_MAX_CHANNELS 2
> >
> > @@ -209,10 +210,30 @@ static int rk3399_dfi_init(struct rockchip_dfi *dfi)
> > return 0;
> > };
> >
> > +static int rk3568_dfi_init(struct rockchip_dfi *dfi)
> > +{
> > + struct regmap *regmap_pmu = dfi->regmap_pmu;
> > + u32 reg2, reg3;
> > +
> > + regmap_read(regmap_pmu, RK3568_PMUGRF_OS_REG2, &reg2);
> > + regmap_read(regmap_pmu, RK3568_PMUGRF_OS_REG3, &reg3);
> > +
> > + dfi->ddr_type = FIELD_GET(RK3568_PMUGRF_OS_REG2_DRAMTYPE_INFO, reg2);

The ddr_type is 5 bits wide. The lower three bits are here.

> > +
> > + if (FIELD_GET(RK3568_PMUGRF_OS_REG3_SYSREG_VERSION, reg3) >= 0x3)
> > + dfi->ddr_type |= FIELD_GET(RK3568_PMUGRF_OS_REG3_DRAMTYPE_INFO_V3, reg3) << 3;

The upper two bits are here, hence we need to shift the value above the
lower three bits.

>
> There are no reason of why shifting the '3'.
> Could you add the comment about '3' or add the constant definition '3'?

I don't think adding a constant makes sense. I'll add a comment making
it more clear what happens.

>
> > +
> > + dfi->channel_mask = 1;
>
> nitpick.
> On other rkXXXX_dfi_init, use GENMASK() to initialize 'dfi->channel_mask'.
> In order to keep the consistency, it is better to use BIT() macro as following:
> dfi->channel_mask = BIT(0);

Ok, will do.

Sascha

--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |