From: Nikolay Dimitrov <picmaster@mail.bg>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 2/4] imx: mx6: add get_cpu_temp_grade to obtain cpu temperature grade from OTP
Date: Mon, 18 May 2015 01:33:11 +0300 [thread overview]
Message-ID: <55591727.3020603@mail.bg> (raw)
In-Reply-To: <1431580312-24880-3-git-send-email-tharvey@gateworks.com>
On 05/14/2015 08:11 AM, Tim Harvey wrote:
> The MX6 has a temperature grade defined by OCOTP_MEM0[7:6] which is at 0x480
> in the Fusemap Description Table in the reference manual. Return this value
> as well as min/max temperature based on the value.
>
> 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.
>
> This has been tested with IMX6 Automative and Industrial parts.
>
> Signed-off-by: Tim Harvey <tharvey@gateworks.com>
> ---
> v2:
> - split out adding get_cpu_temp_grade to its own patch
> - added note about support of MX6SDL and MX6SX
>
> Signed-off-by: Tim Harvey <tharvey@gateworks.com>
> ---
> arch/arm/cpu/armv7/mx6/soc.c | 38 +++++++++++++++++++++++++++++++
> arch/arm/include/asm/arch-mx6/sys_proto.h | 1 +
> include/imx_thermal.h | 6 +++++
> 3 files changed, 45 insertions(+)
>
> diff --git a/arch/arm/cpu/armv7/mx6/soc.c b/arch/arm/cpu/armv7/mx6/soc.c
> index 71fa1fb..6f501ac 100644
> --- a/arch/arm/cpu/armv7/mx6/soc.c
> +++ b/arch/arm/cpu/armv7/mx6/soc.c
> @@ -124,6 +124,44 @@ u32 get_cpu_speed_grade_hz(void)
> return 0;
> }
>
> +/*
> + * OCOTP_MEM0[7:6] (see Fusemap Description Table offset 0x480)
> + * defines a 2-bit Temperature Grade
> + *
> + * return temperature grade and min/max temperature in celcius
> + */
> +#define OCOTP_MEM0_TEMP_SHIFT 6
> +
> +u32 get_cpu_temp_grade(int *minc, int *maxc)
> +{
> + struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
> + struct fuse_bank *bank = &ocotp->bank[1];
> + struct fuse_bank1_regs *fuse =
> + (struct fuse_bank1_regs *)bank->fuse_regs;
> + uint32_t val;
> +
> + val = readl(&fuse->mem0);
> + val >>= OCOTP_MEM0_TEMP_SHIFT;
> + val &= 0x3;
> +
> + if (minc && maxc) {
> + if (val == TEMP_AUTOMOTIVE) {
> + *minc = -40;
> + *maxc = 125;
> + } else if (val == TEMP_INDUSTRIAL) {
> + *minc = -40;
> + *maxc = 105;
> + } else if (val == TEMP_EXTCOMMERCIAL) {
> + *minc = -20;
> + *maxc = 105;
> + } else {
> + *minc = 0;
> + *maxc = 95;
> + }
> + }
> + return val;
> +}
> +
> #ifdef CONFIG_REVISION_TAG
> u32 __weak get_board_rev(void)
> {
> diff --git a/arch/arm/include/asm/arch-mx6/sys_proto.h b/arch/arm/include/asm/arch-mx6/sys_proto.h
> index a2cd0a9..c583291 100644
> --- a/arch/arm/include/asm/arch-mx6/sys_proto.h
> +++ b/arch/arm/include/asm/arch-mx6/sys_proto.h
> @@ -17,6 +17,7 @@
> u32 get_nr_cpus(void);
> u32 get_cpu_rev(void);
> u32 get_cpu_speed_grade_hz(void);
> +u32 get_cpu_temp_grade(int *minc, int *maxc);
>
> /* returns MXC_CPU_ value */
> #define cpu_type(rev) (((rev) >> 12)&0xff)
> diff --git a/include/imx_thermal.h b/include/imx_thermal.h
> index be13652..8ce333c 100644
> --- a/include/imx_thermal.h
> +++ b/include/imx_thermal.h
> @@ -8,6 +8,12 @@
> #ifndef _IMX_THERMAL_H_
> #define _IMX_THERMAL_H_
>
> +/* CPU Temperature Grades */
> +#define TEMP_COMMERCIAL 0
> +#define TEMP_EXTCOMMERCIAL 1
> +#define TEMP_INDUSTRIAL 2
> +#define TEMP_AUTOMOTIVE 3
> +
> struct imx_thermal_plat {
> void *regs;
> int fuse_bank;
>
Tested-by: Nikolay Dimitrov <picmaster@mail.bg>
Regards,
Nikolay
next prev parent reply other threads:[~2015-05-17 22:33 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-14 5:11 [U-Boot] [PATCH v2 0/4]: imx: mx6: use OTP for temperature grade info Tim Harvey
2015-05-14 5:11 ` [U-Boot] [PATCH v2 1/4] mx6: add OTP bank1 registers Tim Harvey
2015-05-15 8:08 ` Christian Gmeiner
2015-05-17 22:32 ` Nikolay Dimitrov
2015-05-14 5:11 ` [U-Boot] [PATCH v2 2/4] imx: mx6: add get_cpu_temp_grade to obtain cpu temperature grade from OTP Tim Harvey
2015-05-15 8:17 ` Christian Gmeiner
2015-05-17 22:33 ` Nikolay Dimitrov [this message]
2015-05-14 5:11 ` [U-Boot] [PATCH v2 3/4] imx: mx6: add display of CPU temperature grade in print_cpuinfo() Tim Harvey
2015-05-15 8:14 ` Christian Gmeiner
2015-05-15 13:16 ` Tim Harvey
2015-05-15 13:24 ` Stefano Babic
2015-05-15 13:31 ` Tim Harvey
2015-05-15 13:36 ` Fabio Estevam
2015-05-18 0:11 ` Peng Fan
2015-05-18 13:30 ` Tim Harvey
2015-05-15 13:44 ` Stefano Babic
2015-05-17 22:33 ` Nikolay Dimitrov
2015-05-14 5:11 ` [U-Boot] [PATCH v2 4/4] thermal: imx_thermal: use CPU temperature grade for trip points Tim Harvey
2015-05-17 22:34 ` 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=55591727.3020603@mail.bg \
--to=picmaster@mail.bg \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox