From patchwork Thu May 14 05:11:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Harvey X-Patchwork-Id: 472218 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 46A721402B2 for ; Thu, 14 May 2015 15:12:34 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5E5884B624; Thu, 14 May 2015 07:12:31 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3JpJMl_mvgl9; Thu, 14 May 2015 07:12:31 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7E0204B635; Thu, 14 May 2015 07:12:21 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A2F8B4B616 for ; Thu, 14 May 2015 07:12:07 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3YVXY-BALFaZ for ; Thu, 14 May 2015 07:12:07 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pd0-f177.google.com (mail-pd0-f177.google.com [209.85.192.177]) by theia.denx.de (Postfix) with ESMTPS id 17A9F4A039 for ; Thu, 14 May 2015 07:12:03 +0200 (CEST) Received: by pdbnk13 with SMTP id nk13so73670709pdb.0 for ; Wed, 13 May 2015 22:12:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VByX5r7s5ultlimwtERKtCIgYJcSGaDRHtkueivn49Q=; b=RqBTXHwyE6Na/VNv4iZbJTlo1X4jfOgawJZ1+rpxm9jBuEFL96P92bauODZ+52o+z6 uEq+hatGvIVh2WHu6/Fioe5PJw5TukD4S7moNcBYiFzZCYzf+qSwk8vFPbYmZketEAow 5l3LcpVZoMjnmwBiL7ZeHpLKPg5Hc1+0EINs1rPSEDPuNMy8CWv2t4go75L7dCy3X/hS s8jsyY7iWmp0b7ERTk4R9ufZLFdQnPaT5g8ZLWZvMmNCZ6ZlKXcrlHwcHfWnfSl9BJub lUoXBfbX2Y0/5Q6/3w3sQ0FsvsRUggBrC7q3mJvKyHJTtyumbknu/YgLBzCUso190WN6 AsdA== X-Gm-Message-State: ALoCoQm5iddrvwmgQDGUU5kweBfTPUYGW215TlaaA6EpSid2UJM+FE5E2gjJMlmWoszq76YQ4yf8 X-Received: by 10.66.224.237 with SMTP id rf13mr4322432pac.131.1431580321904; Wed, 13 May 2015 22:12:01 -0700 (PDT) Received: from tharvey.gw (68-189-91-139.static.snlo.ca.charter.com. [68.189.91.139]) by mx.google.com with ESMTPSA id a6sm9824467pas.28.2015.05.13.22.12.00 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 May 2015 22:12:01 -0700 (PDT) From: Tim Harvey To: Stefano Babic Date: Wed, 13 May 2015 22:11:50 -0700 Message-Id: <1431580312-24880-3-git-send-email-tharvey@gateworks.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1431580312-24880-1-git-send-email-tharvey@gateworks.com> References: <1431580312-24880-1-git-send-email-tharvey@gateworks.com> Cc: Fabio Estevam , Jon Nettleton , u-boot@lists.denx.de, Ye Li , Stefan Roese , Markus Niebel Subject: [U-Boot] [PATCH v2 2/4] imx: mx6: add get_cpu_temp_grade to obtain cpu temperature grade from OTP X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 Reviewed-by: Christian Gmeiner Tested-by: Nikolay Dimitrov --- 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 --- 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;