Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1867560imu; Fri, 14 Dec 2018 01:51:40 -0800 (PST) X-Google-Smtp-Source: AFSGD/VubHTMW2rIOI2KFAoLJWJfrNxIqcYR/ejZNW5wp+W6bCVLzlbLMD9skeyNvMlkD7W7ElHz X-Received: by 2002:a62:d0c1:: with SMTP id p184mr2142771pfg.245.1544781100823; Fri, 14 Dec 2018 01:51:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544781100; cv=none; d=google.com; s=arc-20160816; b=KiWnQOLscYEMnXjX1y9WL8dEcXbnL7q8TyRh66ZQf05waSx8Nk1zNGe7CFP/gAYehB O0MJiWMddLtPZyyuCVGEAEtVLagQws57R630tBnY48cViY0lu2DiEcS69JKRMBOIWW6W b+kv2MQr5qcsbtTL4EQjfPTlcRg2pvkOJPk+7fFTSxgr5/T4vQT2VnyJGEXhrCAXcZQv gODRcesRjYojugOSb9m8caJzvRq4qeyuMs580kwL3aOva1cBcE6l3NRrPaXttFKdll/G +UZ6+HHU9NDJ2MhfVLmALlXJR8GMv11axNrFeWqRHXrllP0V4B3X8DIhon0VGUF27LTY KqqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=nWT8IrVMku4kJkV9k0/1Ook9xqT9hpmJKbC602i8z5Q=; b=H/nS9Pzgw5e8dqfWaAwvbn9P0FQ25udqfuChSUOwqPE8A/SPhb/fgiYN47vvZwQoim dLE2VDMI/mvEYeRRL7Am+B3k8gqJCkIPzHoEeLShNaaKG6PKQVFybWcCg0pZsnmXu1N2 5SZO39MZyXwxYRRNi3/MqKmkuEjmTTNhcIdUV1WN4+EoemAV6Sm0nDDsXXE2wFyTpBoa p6BwTfHlP2BSwx/RYWH09wLWMXvedgxkChlMuVP0fXJD6LteMHJw4U+8Dcesknq+Apnk wwuG77k0HK4J/1aME4dglRtq0lCUguNz3HpRJwnzMtbAwyo8tHcn6s5qsHdhl+rZFx4b lQYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=kciNjGja; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c8si3595561pgl.507.2018.12.14.01.51.26; Fri, 14 Dec 2018 01:51:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=kciNjGja; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729348AbeLNJuJ (ORCPT + 99 others); Fri, 14 Dec 2018 04:50:09 -0500 Received: from hqemgate15.nvidia.com ([216.228.121.64]:10582 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729301AbeLNJuG (ORCPT ); Fri, 14 Dec 2018 04:50:06 -0500 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 14 Dec 2018 01:50:02 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Fri, 14 Dec 2018 01:50:05 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Fri, 14 Dec 2018 01:50:05 -0800 Received: from HQMAIL102.nvidia.com (172.18.146.10) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 14 Dec 2018 09:50:05 +0000 Received: from hqnvemgw02.nvidia.com (172.16.227.111) by HQMAIL102.nvidia.com (172.18.146.10) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Fri, 14 Dec 2018 09:50:05 +0000 Received: from niwei-ubuntu.nvidia.com (Not Verified[10.19.225.182]) by hqnvemgw02.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Fri, 14 Dec 2018 01:50:04 -0800 From: Wei Ni To: , CC: , , , , , Wei Ni Subject: [PATCH v6 3/4] thermal: tegra: parse sensor id before sensor register Date: Fri, 14 Dec 2018 17:49:52 +0800 Message-ID: <1544780993-20744-4-git-send-email-wni@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544780993-20744-1-git-send-email-wni@nvidia.com> References: <1544780993-20744-1-git-send-email-wni@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1544781002; bh=nWT8IrVMku4kJkV9k0/1Ook9xqT9hpmJKbC602i8z5Q=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=kciNjGjaQdqcdRRceLZE1lHp+SYxdpg2Ytj8xK0+66ybZlfx/FWFFyqJ5DvhBxL5n DNogZUTI43DZQ5R29etFjgODA9wCBw+uFmwVLYm4zkZMafjs6l2c1X5E9uB68aXm5i ypEbLAHDIrW9JDraaDJ0F0PIN0RzGnBatPweBSL1cF+l0y/KJs61TpH58poZh7/l7v +fYHVhFXWIbAOs+34y40QF9CFHJcm2WSJ9qFIFLLLtOPA5bUNcuIjS3H/2iTnM79Hm moAHJ51KxI0eKq2jleGRwwkY+MBFr0CnwJVwjM1kgthT+r0MGN34SBAq7vfGkTHb4y n8ZXyCv86W68w== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since different platforms may not support all 4 sensors, so the sensor registration may be failed. Add codes to parse dt to find sensor id which need to be registered. So that the registration can be successful on all platform. Signed-off-by: Wei Ni --- drivers/thermal/tegra/soctherm.c | 45 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c index fd2703c0cfc5..6bee31cd4621 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c @@ -1224,6 +1224,41 @@ static void soctherm_init(struct platform_device *pdev) tegra_soctherm_throttle(&pdev->dev); } +static bool tegra_soctherm_find_sensor_id(unsigned int sensor_id) +{ + bool ret = false; + struct of_phandle_args sensor_specs; + struct device_node *np, *sensor_np; + + np = of_find_node_by_name(NULL, "thermal-zones"); + if (!np) + return ret; + + for_each_available_child_of_node(np, sensor_np) { + if (of_parse_phandle_with_args(sensor_np, "thermal-sensors", + "#thermal-sensor-cells", + 0, &sensor_specs)) + continue; + + if (sensor_specs.args_count != 1) { + WARN(sensor_specs.args_count != 1, + "%s: wrong cells in sensor specifier %d\n", + sensor_specs.np->name, sensor_specs.args_count); + continue; + } + + if (sensor_specs.args[0] == sensor_id) { + of_node_put(sensor_np); + ret = true; + break; + } + } + + of_node_put(np); + + return ret; +} + static const struct of_device_id tegra_soctherm_of_match[] = { #ifdef CONFIG_ARCH_TEGRA_124_SOC { @@ -1365,13 +1400,16 @@ static int tegra_soctherm_probe(struct platform_device *pdev) zone->sg = soc->ttgs[i]; zone->ts = tegra; + if (!tegra_soctherm_find_sensor_id(soc->ttgs[i]->id)) + continue; + z = devm_thermal_zone_of_sensor_register(&pdev->dev, soc->ttgs[i]->id, zone, &tegra_of_thermal_ops); if (IS_ERR(z)) { err = PTR_ERR(z); - dev_err(&pdev->dev, "failed to register sensor: %d\n", - err); + dev_err(&pdev->dev, "failed to register sensor %s: %d\n", + soc->ttgs[i]->name, err); goto disable_clocks; } @@ -1434,6 +1472,9 @@ static int __maybe_unused soctherm_resume(struct device *dev) struct thermal_zone_device *tz; tz = tegra->thermctl_tzs[soc->ttgs[i]->id]; + if (!tz) + continue; + err = tegra_soctherm_set_hwtrips(dev, soc->ttgs[i], tz); if (err) { dev_err(&pdev->dev, -- 2.7.4