From patchwork Sat May 16 20:34:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatolij Gustschin X-Patchwork-Id: 1291968 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=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=BEyXihwF; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49PcTV2DSMz9sTK for ; Sun, 17 May 2020 06:34:54 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 58A3D81767; Sat, 16 May 2020 22:34:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1589661278; bh=bzK3RpQeE75uumKuWHrBNlh+3ch+Ag6nJ3gxEpUYhhM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=BEyXihwFGaTRwehhhsPxy2ICKmJRGcueKRsk+UsKX7yUAfyRSMrASWTS3k8ixHUp+ DKfjVsZJM8KmuZAIB2kjePWdD8myzG1aQfjECX3C049+bqd3nHVyxMd0MtuXoqmP/s WhfVwPLk7d39V9aQqPrj7u/8oWHNMl/RoDbv47JrotDuF+Vgi/5yjUI4oXDE4acW2H zf5z23ftJfGlRO5ZcSWCqEWEtqBJf+hldVzLLwFyqnpQyB2FRPQ3fx8IaDR9fKV2Jf 5taK/O1jc9IuX5VKlHlNSHeDYZCwEqJocfNbV8cqXizM++WOaK2T+PQ3gEy9pxYywA Z4GTuhqKd3egQ== Received: by phobos.denx.de (Postfix, from userid 109) id A8DEB816DA; Sat, 16 May 2020 22:34:35 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-out.m-online.net (mail-out.m-online.net [IPv6:2001:a60:0:28:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C2DFC8168D for ; Sat, 16 May 2020 22:34:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=agust@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 49PcT43dnWz1rrKs; Sat, 16 May 2020 22:34:32 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 49PcT4343yz1shfV; Sat, 16 May 2020 22:34:32 +0200 (CEST) Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id FoEFbVbJksM2; Sat, 16 May 2020 22:34:31 +0200 (CEST) X-Auth-Info: CfpC9dOo/qtF89aP9V3lspe1H0i1/MmBM2/A8d5lPGA= Received: from crub.agik.hopto.org (pd95f11d0.dip0.t-ipconnect.de [217.95.17.208]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Sat, 16 May 2020 22:34:31 +0200 (CEST) From: Anatolij Gustschin To: u-boot@lists.denx.de Cc: peng.fan@nxp.com, ye.li@nxp.com, Frank.Li@nxp.com, sbabic@denx.de Subject: [PATCH 2/2] thermal: imx_scu_thermal: fix getting DT alert property value Date: Sat, 16 May 2020 22:34:20 +0200 Message-Id: <20200516203420.24409-2-agust@denx.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200516203420.24409-1-agust@denx.de> References: <20200516203420.24409-1-agust@denx.de> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean Fix boot hang with endless loop outputting: CPU Temperature (47200C) has beyond alert (0C), close to critical (0C) waiting... Signed-off-by: Anatolij Gustschin --- i.MX8QXP is broken again, this should be appied ASAP! drivers/thermal/imx_scu_thermal.c | 101 ++++++++++++------------------ 1 file changed, 41 insertions(+), 60 deletions(-) diff --git a/drivers/thermal/imx_scu_thermal.c b/drivers/thermal/imx_scu_thermal.c index da13121a09..679ce4e244 100644 --- a/drivers/thermal/imx_scu_thermal.c +++ b/drivers/thermal/imx_scu_thermal.c @@ -57,7 +57,7 @@ int imx_sc_thermal_get_temp(struct udevice *dev, int *temp) if (ret) return ret; - while (cpu_temp >= pdata->alert) { + while (cpu_temp >= pdata->alert && pdata->alert) { printf("CPU Temperature (%dC) has beyond alert (%dC), close to critical (%dC)", cpu_temp, pdata->alert, pdata->critical); puts(" waiting...\n"); @@ -78,7 +78,47 @@ static const struct dm_thermal_ops imx_sc_thermal_ops = { static int imx_sc_thermal_probe(struct udevice *dev) { + struct imx_sc_thermal_plat *pdata = dev_get_platdata(dev); + struct fdtdec_phandle_args args; + ofnode node, trips_np; + int ret; + debug("%s dev name %s\n", __func__, dev->name); + + trips_np = ofnode_path("/thermal-zones/cpu-thermal0/trips"); + node = ofnode_get_parent(trips_np); + ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, node.of_offset, + "thermal-sensors", + "#thermal-sensor-cells", + 0, 0, &args); + if (ret) + return ret; + + if (args.args_count >= 1) + pdata->id = args.args[0]; + else + pdata->id = 0; + + debug("args.args_count %d, id %d\n", args.args_count, pdata->id); + + pdata->polling_delay = ofnode_read_u32_default(node, "polling-delay", + 1000); + ofnode_for_each_subnode(trips_np, trips_np) { + const char *type; + + type = ofnode_get_property(trips_np, "type", NULL); + if (!type) + continue; + if (!strcmp(type, "critical")) + pdata->critical = + ofnode_read_u32_default(trips_np, "temperature", 85); + else if (!strcmp(type, "passive")) + pdata->alert = + ofnode_read_u32_default(trips_np, "temperature", 80); + } + + debug("id %d polling_delay %d, critical %d, alert %d\n", + pdata->id, pdata->polling_delay, pdata->critical, pdata->alert); return 0; } @@ -121,64 +161,6 @@ static int imx_sc_thermal_bind(struct udevice *dev) return 0; } -static int imx_sc_thermal_ofdata_to_platdata(struct udevice *dev) -{ - struct imx_sc_thermal_plat *pdata = dev_get_platdata(dev); - struct fdtdec_phandle_args args; - const char *type; - int ret; - int trips_np; - - debug("%s dev name %s\n", __func__, dev->name); - - if (pdata->zone_node) - return 0; - - ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev), - "thermal-sensors", - "#thermal-sensor-cells", - 0, 0, &args); - if (ret) - return ret; - - if (args.node != dev_of_offset(dev->parent)) - return -EFAULT; - - if (args.args_count >= 1) - pdata->id = args.args[0]; - else - pdata->id = 0; - - debug("args.args_count %d, id %d\n", args.args_count, pdata->id); - - pdata->polling_delay = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), - "polling-delay", 1000); - - trips_np = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(dev), - "trips"); - fdt_for_each_subnode(trips_np, gd->fdt_blob, trips_np) { - type = fdt_getprop(gd->fdt_blob, trips_np, "type", NULL); - if (type) { - if (strcmp(type, "critical") == 0) { - pdata->critical = fdtdec_get_int(gd->fdt_blob, - trips_np, - "temperature", - 85); - } else if (strcmp(type, "passive") == 0) { - pdata->alert = fdtdec_get_int(gd->fdt_blob, - trips_np, - "temperature", - 80); - } - } - } - - debug("id %d polling_delay %d, critical %d, alert %d\n", pdata->id, - pdata->polling_delay, pdata->critical, pdata->alert); - - return 0; -} - static const sc_rsrc_t imx8qm_sensor_rsrc[] = { SC_R_A53, SC_R_A72, SC_R_GPU_0_PID0, SC_R_GPU_1_PID0, SC_R_DRC_0, SC_R_DRC_1, SC_R_VPU_PID0, SC_R_PMIC_0, @@ -205,7 +187,6 @@ U_BOOT_DRIVER(imx_sc_thermal) = { .of_match = imx_sc_thermal_ids, .bind = imx_sc_thermal_bind, .probe = imx_sc_thermal_probe, - .ofdata_to_platdata = imx_sc_thermal_ofdata_to_platdata, .platdata_auto_alloc_size = sizeof(struct imx_sc_thermal_plat), .flags = DM_FLAG_PRE_RELOC, };