public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Diederik de Haas" <didi.debian@cknow.org>
To: "Nicolas Frattaroli" <nicolas.frattaroli@collabora.com>,
	"Chanwoo Choi" <cw00.choi@samsung.com>,
	"MyungJoo Ham" <myungjoo.ham@samsung.com>,
	"Kyungmin Park" <kyungmin.park@samsung.com>,
	"Heiko Stuebner" <heiko@sntech.de>,
	"Sascha Hauer" <s.hauer@pengutronix.de>,
	"Jonathan Cameron" <Jonathan.Cameron@huawei.com>,
	"Sebastian Reichel" <sebastian.reichel@collabora.com>
Cc: <linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-rockchip@lists.infradead.org>, <kernel@collabora.com>,
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 2/2] PM / devfreq: rockchip-dfi: add support for LPDDR5
Date: Wed, 04 Jun 2025 10:24:33 +0200	[thread overview]
Message-ID: <DADLSAEF1YPO.V0CQK084KFFO@cknow.org> (raw)
In-Reply-To: <20250530-rk3588-dfi-improvements-v1-2-6e077c243a95@collabora.com>

[-- Attachment #1: Type: text/plain, Size: 3825 bytes --]

Hi Nicolas,

On Fri May 30, 2025 at 3:38 PM CEST, Nicolas Frattaroli wrote:
> <snip>
> Downstream has some special case handling for a hardware version where
> not just the control bits differ, but also the register. Since I don't
> know whether that hardware version is in any production silicon, it's
> left unimplemented for now, with an error message urging users to report
> if they have such a system.
> <snip>
> ---
>  drivers/devfreq/event/rockchip-dfi.c | 84 ++++++++++++++++++++++++++++--------
>  include/soc/rockchip/rk3588_grf.h    |  8 +++-
>  include/soc/rockchip/rockchip_grf.h  |  1 +
>  3 files changed, 73 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/devfreq/event/rockchip-dfi.c b/drivers/devfreq/event/rockchip-dfi.c
> index 54effb63519653d20b40eed88681330983399a77..5a2c9badcc64c552303c2f55c52e5420dec5ffc1 100644
> --- a/drivers/devfreq/event/rockchip-dfi.c
> +++ b/drivers/devfreq/event/rockchip-dfi.c
> @@ -34,15 +34,18 @@
>  
>  /* DDRMON_CTRL */
>  #define DDRMON_CTRL	0x04
> +#define DDRMON_CTRL_LPDDR5		BIT(6)
>  #define DDRMON_CTRL_DDR4		BIT(5)
>  #define DDRMON_CTRL_LPDDR4		BIT(4)
>  #define DDRMON_CTRL_HARDWARE_EN		BIT(3)
>  #define DDRMON_CTRL_LPDDR23		BIT(2)
>  #define DDRMON_CTRL_SOFTWARE_EN		BIT(1)
>  #define DDRMON_CTRL_TIMER_CNT_EN	BIT(0)
> -#define DDRMON_CTRL_DDR_TYPE_MASK	(DDRMON_CTRL_DDR4 | \
> +#define DDRMON_CTRL_DDR_TYPE_MASK	(DDRMON_CTRL_LPDDR5 | \
> +					 DDRMON_CTRL_DDR4 | \
>  					 DDRMON_CTRL_LPDDR4 | \
>  					 DDRMON_CTRL_LPDDR23)
> +#define DDRMON_CTRL_LP5_BANK_MODE_MASK	GENMASK(8, 7)
>  
>  #define DDRMON_CH0_WR_NUM		0x20
>  #define DDRMON_CH0_RD_NUM		0x24
> @@ -116,13 +119,60 @@ struct rockchip_dfi {
>  	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 */
>  };
>  
> +static int rockchip_dfi_ddrtype_to_ctrl(struct rockchip_dfi *dfi, u32 *ctrl,
> +					u32 *mask)
> +{
> +	u32 ddrmon_ver;
> +
> +	*mask = DDRMON_CTRL_DDR_TYPE_MASK;
> +
> +	switch (dfi->ddr_type) {
> +	case ROCKCHIP_DDRTYPE_LPDDR2:
> +	case ROCKCHIP_DDRTYPE_LPDDR3:
> +		*ctrl = DDRMON_CTRL_LPDDR23;
> +		break;
> +	case ROCKCHIP_DDRTYPE_LPDDR4:
> +	case ROCKCHIP_DDRTYPE_LPDDR4X:
> +		*ctrl = DDRMON_CTRL_LPDDR4;
> +		break;
> +	case ROCKCHIP_DDRTYPE_LPDDR5:
> +		ddrmon_ver = readl_relaxed(dfi->regs);
> +		if (ddrmon_ver < 0x40) {
> +			*ctrl = DDRMON_CTRL_LPDDR5 | dfi->lp5_bank_mode;
> +			*mask |= DDRMON_CTRL_LP5_BANK_MODE_MASK;
> +			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);
> +		return -EOPNOTSUPP;

I'm guessing you mean the linux-rockchip mailing list here? If so, I
think it's better to make that explicit as 'Joe User' who may run into
this issue may not be aware of that mailing list. The 'linux' and
'rockchip' name combo is used in quite a few places.

Cheers,
  Diederik

> +	default:
> +		dev_err(&dfi->edev->dev, "unsupported memory type 0x%X\n",
> +			dfi->ddr_type);
> +		return -EOPNOTSUPP;
> +	}
> +
> +	return 0;
> +}
> +
>  static int rockchip_dfi_enable(struct rockchip_dfi *dfi)
>  {
>  	void __iomem *dfi_regs = dfi->regs;
>  	int i, ret = 0;
> +	u32 ctrl;
> +	u32 ctrl_mask;
>  
>  	mutex_lock(&dfi->mutex);
>  
> @@ -136,8 +186,11 @@ static int rockchip_dfi_enable(struct rockchip_dfi *dfi)
> <snip>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2025-06-04  8:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-30 13:38 [PATCH 0/2] RK3588 rockchip-dfi enhancements Nicolas Frattaroli
2025-05-30 13:38 ` [PATCH 1/2] PM / devfreq: rockchip-dfi: double count on RK3588 Nicolas Frattaroli
2025-05-30 13:38 ` [PATCH 2/2] PM / devfreq: rockchip-dfi: add support for LPDDR5 Nicolas Frattaroli
2025-06-04  8:24   ` Diederik de Haas [this message]
2025-06-05 15:14     ` Nicolas Frattaroli
2025-06-05 19:49       ` Diederik de Haas
2025-06-11  7:32   ` Sascha Hauer
2025-09-06 16:09   ` Chanwoo Choi
2025-09-06 18:38     ` Heiko Stübner
2025-09-06 22:46       ` Chanwoo Choi
2025-09-06 18:37   ` Heiko Stübner
2025-06-20 16:08 ` [PATCH 0/2] RK3588 rockchip-dfi enhancements Nicolas Frattaroli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DADLSAEF1YPO.V0CQK084KFFO@cknow.org \
    --to=didi.debian@cknow.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=cw00.choi@samsung.com \
    --cc=heiko@sntech.de \
    --cc=kernel@collabora.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=myungjoo.ham@samsung.com \
    --cc=nicolas.frattaroli@collabora.com \
    --cc=s.hauer@pengutronix.de \
    --cc=sebastian.reichel@collabora.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox