All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Krummenacher <max.oss.09@gmail.com>
To: Max Krummenacher <max.krummenacher@toradex.com>
Cc: Francesco Dolcini <francesco.dolcini@toradex.com>,
	Emanuele Ghidoli <emanuele.ghidoli@toradex.com>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Marcel Ziswiler <marcel.ziswiler@toradex.com>,
	Nishanth Menon <nm@ti.com>,
	u-boot@lists.denx.de
Subject: Re: [PATCH v1 4/4] board: verdin-am62: set cpu core voltage depending on speed grade
Date: Thu, 18 Jan 2024 17:31:20 +0100	[thread overview]
Message-ID: <ZalSWOw7UEvfnrKf@toolbox> (raw)
In-Reply-To: <Zaj0T33xqN3Eq6XT@toolbox>

On Thu, Jan 18, 2024 at 10:50:07AM +0100, Max Krummenacher wrote:
> On Wed, Jan 17, 2024 at 11:16:49AM +0100, Max Krummenacher wrote:
> > From: Max Krummenacher <max.krummenacher@toradex.com>
> > 
> > Speed grade T requires the VDD_CORE voltage to be 0.85V if using
> > the maximum core frequency.
> > 
> > Speed grades G, K, S allow the VDD_CORE voltage to be 0.75V up to the
> > maximum core frequency but allow to run at 0.85V.
> > 
> > For efficiency in manufacturing and code maintenance we use 0.85V for
> > the PMIC defaults and device tree settings and dynamically adjust the
> > voltage in the PMIC and device tree to 0.75V for lower speed SKU to
> > gain more than 100mW power consumption reduction.
> > 
> > Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
> > ---
> > 
> >  board/toradex/verdin-am62/verdin-am62.c | 47 +++++++++++++++++++++++++
> >  1 file changed, 47 insertions(+)
> > 
> > diff --git a/board/toradex/verdin-am62/verdin-am62.c b/board/toradex/verdin-am62/verdin-am62.c
> > index 4e912b5f32f..8b9db224069 100644
> > --- a/board/toradex/verdin-am62/verdin-am62.c
> > +++ b/board/toradex/verdin-am62/verdin-am62.c
> > @@ -13,10 +13,13 @@
> >  #include <fdt_support.h>
> >  #include <init.h>
> >  #include <k3-ddrss.h>
> > +#include <power/regulator.h>
> 
> In the !DM_REGULATOR case regulator.h assumes errno.h to be already included.
> This happens when compiling the R5 SPL.
> 
> Will fix this in a v2 of the series.

Actually we can go on with the series. While it is true that errno.h is not
included in regulator.h, the required header is included and its definitions
available.

I will create a separate patch which cleans up the headers, so that they
become self contained.

Max

> 
> Max
> 
> >  #include <spl.h>
> >  
> >  #include "../common/tdx-cfg-block.h"
> >  
> > +#define VDD_CORE_REG "buck1"
> > +
> >  DECLARE_GLOBAL_DATA_PTR;
> >  
> >  int board_init(void)
> > @@ -49,9 +52,37 @@ int board_fit_config_name_match(const char *name)
> >  }
> >  #endif
> >  
> > +static u32 get_vdd_core_nominal(void)
> > +{
> > +	int core_uvolt;
> > +
> > +	switch (k3_get_speed_grade()) {
> > +	case 'G':
> > +	case 'K':
> > +	case 'S':
> > +		core_uvolt = 750000;
> > +		break;
> > +	case 'T':
> > +	default:
> > +		core_uvolt = 850000;
> > +		break;
> > +	}
> > +	return core_uvolt;
> > +}
> > +
> >  #if IS_ENABLED(CONFIG_OF_LIBFDT) && IS_ENABLED(CONFIG_OF_BOARD_SETUP)
> >  int ft_board_setup(void *blob, struct bd_info *bd)
> >  {
> > +	int core_uvolt;
> > +
> > +	core_uvolt = get_vdd_core_nominal();
> > +	if (core_uvolt != 850000) {
> > +		do_fixup_by_path_u32(blob, "/bus@f0000/i2c@20000000/pmic@30/regulators/buck1",
> > +				     "regulator-max-microvolt", core_uvolt, 0);
> > +		do_fixup_by_path_u32(blob, "/bus@f0000/i2c@20000000/pmic@30/regulators/buck1",
> > +				     "regulator-min-microvolt", core_uvolt, 0);
> > +	}
> > +
> >  	return ft_common_board_setup(blob, bd);
> >  }
> >  #endif
> > @@ -86,6 +117,22 @@ static void select_dt_from_module_version(void)
> >  
> >  int board_late_init(void)
> >  {
> > +	int ret;
> > +	int core_uvolt;
> > +	struct udevice *dev = NULL;
> > +
> > +	core_uvolt = get_vdd_core_nominal();
> > +	if (core_uvolt != 850000) {
> > +		/* Set CPU core voltage to 0.75V for slower speed grades */
> > +		ret = regulator_get_by_devname(VDD_CORE_REG, &dev);
> > +		if (ret)
> > +			pr_err("VDD CORE Regulator get error: %d\n", ret);
> > +
> > +		ret = regulator_set_value_force(dev, core_uvolt);
> > +		if (ret)
> > +			pr_err("VDD CORE Regulator value setting error: %d\n", ret);
> > +	}
> > +
> >  	select_dt_from_module_version();
> >  
> >  	return 0;
> > -- 
> > 2.42.0
> > 

  reply	other threads:[~2024-01-18 16:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-17 10:16 [PATCH v1 0/4] board: verdin-am62: set cpu core voltage depending on speed grade Max Krummenacher
2024-01-17 10:16 ` [PATCH v1 1/4] board: verdin-am62: improve comment on usb phy core voltage Max Krummenacher
2024-01-25 16:14   ` Tom Rini
2024-01-17 10:16 ` [PATCH v1 2/4] arm: mach-k3: am62: move device identification accessor functions to header Max Krummenacher
2024-01-17 10:16 ` [PATCH v1 3/4] arm: mach-k3: am62: provide more soc feature info accessors Max Krummenacher
2024-01-17 10:16 ` [PATCH v1 4/4] board: verdin-am62: set cpu core voltage depending on speed grade Max Krummenacher
2024-01-18  9:50   ` Max Krummenacher
2024-01-18 16:31     ` Max Krummenacher [this message]
2024-01-18 20:49       ` Francesco Dolcini
2024-01-17 10:53 ` [PATCH v1 0/4] " Francesco Dolcini

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=ZalSWOw7UEvfnrKf@toolbox \
    --to=max.oss.09@gmail.com \
    --cc=emanuele.ghidoli@toradex.com \
    --cc=francesco.dolcini@toradex.com \
    --cc=marcel.ziswiler@toradex.com \
    --cc=max.krummenacher@toradex.com \
    --cc=nm@ti.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.