All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Babic <sbabic@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 1/2] imx: mx6: add get_cpu_speed_grade_hz func to return MHz speed grade from OTP
Date: Fri, 15 May 2015 15:20:25 +0200	[thread overview]
Message-ID: <5555F299.70307@denx.de> (raw)
In-Reply-To: <CAH9NwWczchwW2T7aAi_sR6sX2qXuvG+hb5810ETFvruT1VY0zg@mail.gmail.com>

Hi Christian,

On 15/05/2015 09:53, Christian Gmeiner wrote:
> Hi
> 
> 2015-05-14 7:08 GMT+02:00 Tim Harvey <tharvey@gateworks.com>:
>> The IMX6 has four different speed grades determined by eFUSE SPEED_GRADING
>> indicated by OCOTP_CFG3[17:16] which is at 0x440 in the Fusemap Description
>> Table. Return this frequency so that it can be used elsewhere.
>>
>> Note that the IMX6SDLRM and the IMX6SXRM do not indicate this in the
>> their Fusemap Description Table however Freescale has confirmed that these
>> eFUSE bits match the description within the IMX6DQRM and that they will
>> be added to the next revision of the respective reference manuals.
>>
>> These have been tested with IMX6 Quad/Solo/Dual-light 800Mhz and 1GHz grades.
>>
>> Signed-off-by: Tim Harvey <tharvey@gateworks.com>
>> ---
>>  arch/arm/cpu/armv7/mx6/soc.c              | 41 +++++++++++++++++++++++++++++++
>>  arch/arm/include/asm/arch-mx6/sys_proto.h |  1 +
>>  2 files changed, 42 insertions(+)
>>
>> diff --git a/arch/arm/cpu/armv7/mx6/soc.c b/arch/arm/cpu/armv7/mx6/soc.c
>> index dd34138..71fa1fb 100644
>> --- a/arch/arm/cpu/armv7/mx6/soc.c
>> +++ b/arch/arm/cpu/armv7/mx6/soc.c
>> @@ -83,6 +83,47 @@ u32 get_cpu_rev(void)
>>         return (type << 12) | (reg + 0x10);
>>  }
>>
>> +/*
>> + * OCOTP_CFG3[17:16] (see Fusemap Description Table offset 0x440)
>> + * defines a 2-bit SPEED_GRADING
>> + */
>> +#define OCOTP_CFG3_SPEED_SHIFT 16
>> +#define OCOTP_CFG3_SPEED_800MHZ        0
>> +#define OCOTP_CFG3_SPEED_850MHZ        1
>> +#define OCOTP_CFG3_SPEED_1GHZ  2
>> +#define OCOTP_CFG3_SPEED_1P2GHZ        3
> 
> Note: 0x3 is defined as reserved (IMX6DQRM Rev 2, 06/2014).
> 

That means that the manual is buggy, if the SOC returns exactly this
value ;-)

>> +
>> +u32 get_cpu_speed_grade_hz(void)
>> +{
>> +       struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
>> +       struct fuse_bank *bank = &ocotp->bank[0];
>> +       struct fuse_bank0_regs *fuse =
>> +               (struct fuse_bank0_regs *)bank->fuse_regs;
>> +       uint32_t val;
>> +
>> +       val = readl(&fuse->cfg3);
>> +       val >>= OCOTP_CFG3_SPEED_SHIFT;
>> +       val &= 0x3;
>> +
>> +       switch (val) {
>> +       /* Valid for IMX6DQ */
>> +       case OCOTP_CFG3_SPEED_1P2GHZ:
>> +               if (is_cpu_type(MXC_CPU_MX6Q) || is_cpu_type(MXC_CPU_MX6D))
>> +                       return 1200000000;
>> +       /* Valid for IMX6SX/IMX6SDL/IMX6DQ */
>> +       case OCOTP_CFG3_SPEED_1GHZ:
>> +               return 996000000;
>> +       /* Valid for IMX6DQ */
>> +       case OCOTP_CFG3_SPEED_850MHZ:
>> +               if (is_cpu_type(MXC_CPU_MX6Q) || is_cpu_type(MXC_CPU_MX6D))
>> +                       return 852000000;
>> +       /* Valid for IMX6SX/IMX6SDL/IMX6DQ */
>> +       case OCOTP_CFG3_SPEED_800MHZ:
>> +               return 792000000;
>> +       }
>> +       return 0;
> 
> Do we really need the ifs inside the cases? The speed grading fuse
> value is read only and
> we must simply life with the value we read back. So I would drop the
> is_cpu_type(..) thing.

Function does not returns the value of the fuse, else it should returns
val. The value is parsed for consistency, and if it is not, 0 means a
failure. IMHO this interpretation is correct - I would agree with you
only if the return value would be the read value, but it is not.

Best regards,
Stefano Babic

> 
> greets
> --
> Christian Gmeiner, MSc
> 
> https://soundcloud.com/christian-gmeiner
> 


-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================

  reply	other threads:[~2015-05-15 13:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-14  5:08 [U-Boot] [PATCH v2 0/2]: imx: mx6: use OTP for freq grade Tim Harvey
2015-05-14  5:08 ` [U-Boot] [PATCH v2 1/2] imx: mx6: add get_cpu_speed_grade_hz func to return MHz speed grade from OTP Tim Harvey
2015-05-15  7:53   ` Christian Gmeiner
2015-05-15 13:20     ` Stefano Babic [this message]
2015-05-15 14:26       ` Christian Gmeiner
2015-05-15 14:32         ` Stefano Babic
2015-05-15 19:54           ` Troy Kisky
2015-05-15 20:38             ` Tim Harvey
2015-05-15 20:43               ` Troy Kisky
2015-05-15 22:34                 ` Troy Kisky
2015-05-15 22:57                   ` Otavio Salvador
2015-05-15 23:24                     ` Troy Kisky
2015-05-15 13:42     ` Tim Harvey
2015-05-17 21:37   ` Nikolay Dimitrov
2015-05-14  5:08 ` [U-Boot] [PATCH v2 2/2] mx: mx6: display max cpu frequency in print_cpuinfo() Tim Harvey
2015-05-17 21:38   ` Nikolay Dimitrov

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=5555F299.70307@denx.de \
    --to=sbabic@denx.de \
    --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.