All of lore.kernel.org
 help / color / mirror / Atom feed
From: Baruch Siach <baruch@tkos.co.il>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] arm: mvebu: set 38x and 39x AVS on lower frequency
Date: Tue, 25 Jun 2019 08:50:10 +0300	[thread overview]
Message-ID: <878stqp625.fsf@tarshish> (raw)
In-Reply-To: <CAFOYHZBuHyJg9j=kKspvCP5P=hFPjk8AMOy_1-=4kO3X1recBQ@mail.gmail.com>

Hi Chris,

On Tue, Jun 25 2019, Chris Packham wrote:
> On Mon, Jun 24, 2019 at 8:30 PM Baruch Siach <baruch@tkos.co.il> wrote:
>>
>> Reduce Auto Voltage Scaling VDD limit when core frequency is lower than
>> 1600MHz. This reduces core voltage level from 1.25V to 1.15V, which
>> saves power.
>>
>> The code is taken from Marvell's U-Boot 2013.01 revision 18.06.
>>
>> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
>
> I gave it a quick spin on DB-88F6820-AMC and x530. Both booted fine.

Is there AVS feedback circuit on these boards? If so, have you measured
how this patch affects core voltage?

> Reviewed-by: Chris Packham <judge.packham@gmail.com>
> Tested-by: Chris Packham <judge.packham@gmail.com>

Thanks,
baruch

>> ---
>>  arch/arm/mach-mvebu/include/mach/cpu.h        |  3 +++
>>  arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.c | 26 +++++++++++++++++++
>>  arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.h |  4 +++
>>  arch/arm/mach-mvebu/spl.c                     |  3 +++
>>  4 files changed, 36 insertions(+)
>>
>> diff --git a/arch/arm/mach-mvebu/include/mach/cpu.h b/arch/arm/mach-mvebu/include/mach/cpu.h
>> index e6140d67293e..e1128ee90f01 100644
>> --- a/arch/arm/mach-mvebu/include/mach/cpu.h
>> +++ b/arch/arm/mach-mvebu/include/mach/cpu.h
>> @@ -163,6 +163,9 @@ int serdes_phy_config(void);
>>   */
>>  int ddr3_init(void);
>>
>> +/* Auto Voltage Scaling */
>> +void mv_avs_init(void);
>> +
>>  /*
>>   * get_ref_clk
>>   *
>> diff --git a/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.c b/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.c
>> index d387893af37d..e9dd096ad0f5 100644
>> --- a/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.c
>> +++ b/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.c
>> @@ -256,3 +256,29 @@ u8 sys_env_device_rev_get(void)
>>         value = reg_read(DEV_VERSION_ID_REG);
>>         return (value & (REVISON_ID_MASK)) >> REVISON_ID_OFFS;
>>  }
>> +
>> +void mv_avs_init(void)
>> +{
>> +       u32 sar_freq;
>> +
>> +       if (!(IS_ENABLED(CONFIG_ARMADA_38X) || IS_ENABLED(CONFIG_ARMADA_39X)))
>> +               return;
>> +
>> +       reg_write(AVS_DEBUG_CNTR_REG, AVS_DEBUG_CNTR_DEFAULT_VALUE);
>> +       reg_write(AVS_DEBUG_CNTR_REG, AVS_DEBUG_CNTR_DEFAULT_VALUE);
>> +
>> +       sar_freq = reg_read(DEVICE_SAMPLE_AT_RESET1_REG);
>> +       sar_freq = sar_freq >> SAR_FREQ_OFFSET & SAR_FREQ_MASK;
>> +
>> +       /* Set AVS value only for core frequency of 1600MHz or less.
>> +        * For higher frequency leave the default value.
>> +        */
>> +       if (sar_freq <= 0xd) {
>> +               u32 avs_reg_data = reg_read(AVS_ENABLED_CONTROL);
>> +
>> +               avs_reg_data &= ~(AVS_LOW_VDD_LIMIT_MASK
>> +                               | AVS_HIGH_VDD_LIMIT_MASK);
>> +               avs_reg_data |= AVS_LOW_VDD_SLOW_VAL | AVS_HIGH_VDD_SLOW_VAL;
>> +               reg_write(AVS_ENABLED_CONTROL, avs_reg_data);
>> +       }
>> +}
>> diff --git a/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.h b/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.h
>> index 365332d2b048..1774a5b780ca 100644
>> --- a/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.h
>> +++ b/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.h
>> @@ -33,6 +33,8 @@
>>  #define DEV_ID_REG_DEVICE_ID_OFFS      16
>>  #define DEV_ID_REG_DEVICE_ID_MASK      0xffff0000
>>
>> +#define SAR_FREQ_OFFSET                        10
>> +#define SAR_FREQ_MASK                  0x1f
>>  #define SAR_DEV_ID_OFFS                        27
>>  #define SAR_DEV_ID_MASK                        0x7
>>
>> @@ -155,10 +157,12 @@
>>  #define AVS_LOW_VDD_LIMIT_OFFS         4
>>  #define AVS_LOW_VDD_LIMIT_MASK         (0xff << AVS_LOW_VDD_LIMIT_OFFS)
>>  #define AVS_LOW_VDD_LIMIT_VAL          (0x27 << AVS_LOW_VDD_LIMIT_OFFS)
>> +#define AVS_LOW_VDD_SLOW_VAL           (0x23 << AVS_LOW_VDD_LIMIT_OFFS)
>>
>>  #define AVS_HIGH_VDD_LIMIT_OFFS                12
>>  #define AVS_HIGH_VDD_LIMIT_MASK                (0xff << AVS_HIGH_VDD_LIMIT_OFFS)
>>  #define AVS_HIGH_VDD_LIMIT_VAL         (0x27 << AVS_HIGH_VDD_LIMIT_OFFS)
>> +#define AVS_HIGH_VDD_SLOW_VAL          (0x23 << AVS_HIGH_VDD_LIMIT_OFFS)
>>
>>  /* Board ID numbers */
>>  #define MARVELL_BOARD_ID_MASK          0x10
>> diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
>> index d54de5195624..3cb27b7f4b20 100644
>> --- a/arch/arm/mach-mvebu/spl.c
>> +++ b/arch/arm/mach-mvebu/spl.c
>> @@ -126,6 +126,9 @@ void board_init_f(ulong dummy)
>>         ddr3_init();
>>  #endif
>>
>> +       /* Initialize Auto Voltage Scaling */
>> +       mv_avs_init();
>> +
>>         /*
>>          * Return to the BootROM to continue the Marvell xmodem
>>          * UART boot protocol. As initiated by the kwboot tool.

--
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -

  reply	other threads:[~2019-06-25  5:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-24  8:29 [U-Boot] [PATCH] arm: mvebu: set 38x and 39x AVS on lower frequency Baruch Siach
2019-06-25  5:40 ` Chris Packham
2019-06-25  5:50   ` Baruch Siach [this message]
2019-06-25  7:49     ` Chris Packham
2019-06-26  5:07       ` Chris Packham
2019-07-10  9:07 ` Stefan Roese

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=878stqp625.fsf@tarshish \
    --to=baruch@tkos.co.il \
    --cc=u-boot@lists.denx.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.