From patchwork Fri Apr 26 01:44:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 1091176 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="VIODdmuE"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44qxgb6Txyz9s6w for ; Fri, 26 Apr 2019 11:44:41 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 0BA32C21CB1; Fri, 26 Apr 2019 01:44:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_PASS, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 45E09C21C27; Fri, 26 Apr 2019 01:44:34 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 305F9C21C27; Fri, 26 Apr 2019 01:44:32 +0000 (UTC) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150083.outbound.protection.outlook.com [40.107.15.83]) by lists.denx.de (Postfix) with ESMTPS id 1F2C9C21BE5 for ; Fri, 26 Apr 2019 01:44:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=525LpDmlgzfZdq1pyObRz6uHVgmdQUfcE+kTVDF3FuQ=; b=VIODdmuE5pjTAFOg+DqDkXOa/U6w6ti3rTNUtWlUU1Fk87gipihVAojeLMO+BWpgFy3UxHoG6uYRWEHfttLZQUgUei1XU8/dgltIPnWRMyIB5JGqUpFE1gcHccYsJfi6Zl6w5rs5e+5bltu5JX0jZ3kZ8LXirszSHp3zLdpWMxM= Received: from DB7PR04MB4490.eurprd04.prod.outlook.com (52.135.138.16) by DB7PR04MB4043.eurprd04.prod.outlook.com (52.135.130.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1813.16; Fri, 26 Apr 2019 01:44:27 +0000 Received: from DB7PR04MB4490.eurprd04.prod.outlook.com ([fe80::9c1e:27f0:1ee9:fdb3]) by DB7PR04MB4490.eurprd04.prod.outlook.com ([fe80::9c1e:27f0:1ee9:fdb3%7]) with mapi id 15.20.1813.017; Fri, 26 Apr 2019 01:44:27 +0000 From: Peng Fan To: "sbabic@denx.de" , "festevam@gmail.com" Thread-Topic: [PATCH V2] imx8: cpu: get temperature when print cpu desc Thread-Index: AQHU+9GVCax56NynFE6uVjiu11iCrg== Date: Fri, 26 Apr 2019 01:44:27 +0000 Message-ID: <20190426015747.14909-1-peng.fan@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.16.4 x-clientproxiedby: HK0P153CA0031.APCP153.PROD.OUTLOOK.COM (2603:1096:203:17::19) To DB7PR04MB4490.eurprd04.prod.outlook.com (2603:10a6:5:35::16) authentication-results: spf=none (sender IP is ) smtp.mailfrom=peng.fan@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.71] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 14b96386-309f-454d-33ba-08d6c9e8b7d8 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(4618075)(2017052603328)(7193020); SRVR:DB7PR04MB4043; x-ms-traffictypediagnostic: DB7PR04MB4043: x-ms-exchange-purlcount: 1 x-microsoft-antispam-prvs: x-forefront-prvs: 001968DD50 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(396003)(346002)(366004)(136003)(39860400002)(189003)(199004)(54906003)(5660300002)(26005)(52116002)(6506007)(110136005)(99286004)(14454004)(6486002)(36756003)(4326008)(6436002)(86362001)(71200400001)(44832011)(53936002)(102836004)(66066001)(81156014)(66476007)(50226002)(68736007)(66446008)(386003)(476003)(14444005)(186003)(66946007)(6512007)(6306002)(66556008)(305945005)(73956011)(8676002)(71190400001)(2616005)(97736004)(316002)(6116002)(478600001)(7736002)(3846002)(1076003)(8936002)(25786009)(256004)(2501003)(966005)(64756008)(2906002)(81166006)(486006); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR04MB4043; H:DB7PR04MB4490.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: bfUHJw+Cm2h1K37ESkBh3V8qp4UzQBm4Dvf1pDJFv0prPzC6T+ywsRaB84HB40Wm6ehUb7f0GFDbJ4VG6bKK2lZAEiVV2ifmvn8rpKXYV0J5//9Cu0WzWrO8zLZpn6NGCeRKZ5kWms//9DU866WQvHefWUqZQp/CgzeUFIIy/gCY3yOB7b8avunrLs3agBulZSvofFaH622D+EdFuclbN3C4vdk/xVJWT2AB6IuW7DVoh9zUgsyR65IPeIObk+zMQGwRj7kxcBROG8nPZ3deaC6K/tpakjzZ/qDqN3YZgkh/cEx8I6Kv5s/xlXnZF7weEOOMv3/AG+6DJY5MQWmj4KcgDSrfRYI3IN9Tsc6zTQI4/39wfbrvB/4vEAyk7pMvJ5iKIY80bBkIjRaiWPZ4vcDuUkxoODBvCxfQlOFaKFI= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 14b96386-309f-454d-33ba-08d6c9e8b7d8 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Apr 2019 01:44:27.7591 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4043 Cc: "u-boot@lists.denx.de" , dl-uboot-imx Subject: [U-Boot] [PATCH V2] imx8: cpu: get temperature when print cpu desc X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Read the temperature when print cpu inforation. Signed-off-by: Peng Fan --- V2: Fix build warning when CONFIG_IMX_SCU_THERMAL not defined. Hi Stefano, I not post the whole series, not posted out this specific patch, the v1 patch https://patchwork.ozlabs.org/patch/1084464/ or do you expect the repost the whole series? arch/arm/mach-imx/imx8/cpu.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-imx/imx8/cpu.c b/arch/arm/mach-imx/imx8/cpu.c index 4bbc956f9d..1ee7ea649d 100644 --- a/arch/arm/mach-imx/imx8/cpu.c +++ b/arch/arm/mach-imx/imx8/cpu.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -571,15 +572,50 @@ const char *get_core_name(void) return "?"; } +#if IS_ENABLED(CONFIG_IMX_SCU_THERMAL) +static int cpu_imx_get_temp(void) +{ + struct udevice *thermal_dev; + int cpu_tmp, ret; + + ret = uclass_get_device_by_name(UCLASS_THERMAL, "cpu-thermal0", + &thermal_dev); + + if (!ret) { + ret = thermal_get_temp(thermal_dev, &cpu_tmp); + if (ret) + return 0xdeadbeef; + } else { + return 0xdeadbeef; + } + + return cpu_tmp; +} +#else +static int cpu_imx_get_temp(void) +{ + return 0; +} +#endif + int cpu_imx_get_desc(struct udevice *dev, char *buf, int size) { struct cpu_imx_platdata *plat = dev_get_platdata(dev); + int ret; if (size < 100) return -ENOSPC; - snprintf(buf, size, "NXP i.MX8%s Rev%s %s at %u MHz\n", - plat->type, plat->rev, plat->name, plat->freq_mhz); + ret = snprintf(buf, size, "NXP i.MX8%s Rev%s %s at %u MHz", + plat->type, plat->rev, plat->name, plat->freq_mhz); + + if (IS_ENABLED(CONFIG_IMX_SCU_THERMAL)) { + buf = buf + ret; + size = size - ret; + ret = snprintf(buf, size, " at %dC", cpu_imx_get_temp()); + } + + snprintf(buf + ret, size - ret, "\n"); return 0; }