2023-07-04 09:42:02

by Sascha Hauer

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

This adds RK3568 support to the DFI driver. Only iniitialization
differs from the currently supported RK3399.

Signed-off-by: Sascha Hauer <[email protected]>
---
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);
+
+ 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;
+
+ dfi->channel_mask = 1;
+
+ return 0;
+};
+
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 },
{ },
};
+
MODULE_DEVICE_TABLE(of, rockchip_dfi_id_match);

static int rockchip_dfi_probe(struct platform_device *pdev)
diff --git a/include/soc/rockchip/rk3568_grf.h b/include/soc/rockchip/rk3568_grf.h
new file mode 100644
index 0000000000000..575584e9d8834
--- /dev/null
+++ b/include/soc/rockchip/rk3568_grf.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+#ifndef __SOC_RK3568_GRF_H
+#define __SOC_RK3568_GRF_H
+
+#define RK3568_PMUGRF_OS_REG2 0x208
+#define RK3568_PMUGRF_OS_REG2_DRAMTYPE_INFO GENMASK(15, 13)
+
+#define RK3568_PMUGRF_OS_REG3 0x20c
+#define RK3568_PMUGRF_OS_REG3_DRAMTYPE_INFO_V3 GENMASK(13, 12)
+#define RK3568_PMUGRF_OS_REG3_SYSREG_VERSION GENMASK(31, 28)
+
+#endif /* __SOC_RK3568_GRF_H */
--
2.39.2



2023-10-06 18:17:27

by Chanwoo Choi

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

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 <[email protected]>
> ---
> 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);
> +
> + 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;

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

> +
> + 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);

> +
> + return 0;
> +};
> +
> 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 },
> { },
> };
> +
> MODULE_DEVICE_TABLE(of, rockchip_dfi_id_match);
>
> static int rockchip_dfi_probe(struct platform_device *pdev)
> diff --git a/include/soc/rockchip/rk3568_grf.h b/include/soc/rockchip/rk3568_grf.h
> new file mode 100644
> index 0000000000000..575584e9d8834
> --- /dev/null
> +++ b/include/soc/rockchip/rk3568_grf.h
> @@ -0,0 +1,12 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +#ifndef __SOC_RK3568_GRF_H
> +#define __SOC_RK3568_GRF_H
> +
> +#define RK3568_PMUGRF_OS_REG2 0x208
> +#define RK3568_PMUGRF_OS_REG2_DRAMTYPE_INFO GENMASK(15, 13)
> +
> +#define RK3568_PMUGRF_OS_REG3 0x20c
> +#define RK3568_PMUGRF_OS_REG3_DRAMTYPE_INFO_V3 GENMASK(13, 12)
> +#define RK3568_PMUGRF_OS_REG3_SYSREG_VERSION GENMASK(31, 28)
> +
> +#endif /* __SOC_RK3568_GRF_H */

--
Best Regards,
Samsung Electronics
Chanwoo Choi

2023-10-16 11:35:15

by Sascha Hauer

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

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 <[email protected]>
> > ---
> > 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 |

2023-10-17 08:31:30

by Chanwoo Choi

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

On 23. 10. 16. 20:34, Sascha Hauer wrote:
> 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 <[email protected]>
>>> ---
>>> 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.

It is enough to add the comment. Thanks.

>
>>
>>> +
>>> + 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.

Thanks.

>
> Sascha
>

--
Best Regards,
Samsung Electronics
Chanwoo Choi