From patchwork Tue Jun 25 21:32:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raphael Gallais-Pou X-Patchwork-Id: 13712069 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 01402C2BBCA for ; Tue, 25 Jun 2024 21:33:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wOp5UqGNK/+aHc+mtLWt/FVtlNV3iPD/WbMrczGg2CE=; b=ZLlb2GtfeQ8HtggogdP/sFEehb +GG27ATYdwC8A0uKN9Hj4+RZFaemjQx74WRuQFrQQn92TSppLHuXmTSdbDj7LPkHzsG8Ux/3Z/Smt Ok7aVDGlnB9mFPaGrOJ4IvXVKNC2DU7HJUZiRPA9tjgGAuEYLAQOru8tktNFdpBFey8UmyMCkdHbe l+ZSn0pPbGcdwbkYTruH0eJHWsxbP3kitvdnsZJk2FKbpfjI3FRvslWjIE+wnP/ywJBU0+xrAtj8w +X9+xsrR12ppIXnIB6PSqjNdZUZ+VC5g6Wv9NAVXWBxGkTMn5Qhdcz0uZYeNRkK464RD6M423/elX 2mI90ggQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMDn5-00000004aCe-0bFh; Tue, 25 Jun 2024 21:33:27 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMDmv-00000004aAY-0XqS for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 21:33:18 +0000 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3658197cdbbso3261114f8f.3 for ; Tue, 25 Jun 2024 14:33:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719351195; x=1719955995; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=wOp5UqGNK/+aHc+mtLWt/FVtlNV3iPD/WbMrczGg2CE=; b=CdCrtC0x+ltd9XZBB7h2ujgIPrrzOiKHcPjIXC4NtsPPttcIc2rSJ9TXo62ygkqU4j 9fU6HYf/I/jBPcpszhAVAk7SqQWLyt8qp4QFY6HXnMLjlHaBx21DqOuoUOPxNzLwig/y ruaysRgoIyhx0YfOq56e9I2rR51tztLTDdzFzjAd1rnqAIFRaZtvSpl8csDhmLCjnrny 9iT7irbhvJZk99AlvWqq9GtQFr/i3zvMsDWFUvCB6lzCmy1T+9+K1lIqUXp7rpvA/YWx C+umj38LokE/iqfyNL3OH2kesh63saTO5bK85Mimm82/gU5fej8JsPEnreqPSjeq2X9A n1cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719351195; x=1719955995; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wOp5UqGNK/+aHc+mtLWt/FVtlNV3iPD/WbMrczGg2CE=; b=caaCTLHPdmzoypeLiusy28fHOQY/U3XtUddRf0eSC9FboZDyMcdXmJ9tlfw27CjhI8 H29edOwFyNvma++85ykqSpMqF79eFi8MAJX/oJbNctuhvY84gY9MkqnOWH1YzUdgdssd zA8W5lujHXLDr+o1Z0af/yKqyLMBNDhlZoBBpdmssaZiBBlNjEZw3/tYppb4vMs7HtAw KfRW2QxvURqBLk3E+JMJva7vF5WXxQQfubAIvq2fGMSaEZ+pGxSo8Hip+V4amJFRyNWa iOEUlpiekGPb1HEXuQfFXBmwICtYnSgxrK2+zOgA97Zb7CI0LodjDNZqOlUCwVZ0CJrI 4kPg== X-Forwarded-Encrypted: i=1; AJvYcCUubJJXUkPgCB72LWyNjY/PiaqeBEpdW9IjnCSaPo/o63fYSriI5mxwf+ReX3Zt8KmCHCcvMbMhcsX3nHBV8ZJ0PZbbJf2QjwiXFWY6NHOcJ3sBnrg= X-Gm-Message-State: AOJu0YwtP4nWErcXV0wqoaoHZNFcjRwX2B3Jw+DHSgCHFzymMG5qEPTG q7f1PRFgu8WcREn0mzlZvnYFkbg+6jmywk3mTShYHeX9Yg8bOUxCpyMRqA== X-Google-Smtp-Source: AGHT+IHM8lLa8Kw/PfBSHM/pQpWPKRg70VziGzuKcSwEmlPeW/23VjI1c7PTAH1z3JhKQC5WZ+U1BQ== X-Received: by 2002:a5d:518c:0:b0:360:9175:2c33 with SMTP id ffacd0b85a97d-366e9461f67mr6558659f8f.8.1719351193778; Tue, 25 Jun 2024 14:33:13 -0700 (PDT) Received: from localhost ([2001:861:3385:e20:6384:4cf:52c5:3194]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-366389b861bsm13854978f8f.29.2024.06.25.14.33.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jun 2024 14:33:13 -0700 (PDT) From: Raphael Gallais-Pou Date: Tue, 25 Jun 2024 23:32:40 +0200 Subject: [PATCH v2 1/3] thermal: st: switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() MIME-Version: 1.0 Message-Id: <20240625-thermal-v2-1-bf8354ed51ee@gmail.com> References: <20240625-thermal-v2-0-bf8354ed51ee@gmail.com> In-Reply-To: <20240625-thermal-v2-0-bf8354ed51ee@gmail.com> To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Maxime Coquelin , Alexandre Torgue , Patrice Chotard , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org X-Mailer: b4 0.14.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_143317_211567_6B637637 X-CRM114-Status: GOOD ( 15.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Letting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less error prone than the use of #ifdef based kernel configuration guards. Remove those guards on every ST thermal related drivers. Reviewed-by: Patrice Chotard Signed-off-by: Raphael Gallais-Pou --- drivers/thermal/st/st_thermal.c | 4 +--- drivers/thermal/st/st_thermal_memmap.c | 2 +- drivers/thermal/st/stm_thermal.c | 8 +++----- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/thermal/st/st_thermal.c b/drivers/thermal/st/st_thermal.c index 2a105409864e..5f33543a3a54 100644 --- a/drivers/thermal/st/st_thermal.c +++ b/drivers/thermal/st/st_thermal.c @@ -236,7 +236,6 @@ void st_thermal_unregister(struct platform_device *pdev) } EXPORT_SYMBOL_GPL(st_thermal_unregister); -#ifdef CONFIG_PM_SLEEP static int st_thermal_suspend(struct device *dev) { struct st_thermal_sensor *sensor = dev_get_drvdata(dev); @@ -265,9 +264,8 @@ static int st_thermal_resume(struct device *dev) return 0; } -#endif -SIMPLE_DEV_PM_OPS(st_thermal_pm_ops, st_thermal_suspend, st_thermal_resume); +DEFINE_SIMPLE_DEV_PM_OPS(st_thermal_pm_ops, st_thermal_suspend, st_thermal_resume); EXPORT_SYMBOL_GPL(st_thermal_pm_ops); MODULE_AUTHOR("STMicroelectronics (R&D) Limited "); diff --git a/drivers/thermal/st/st_thermal_memmap.c b/drivers/thermal/st/st_thermal_memmap.c index 29c2269b0fb3..28b380013956 100644 --- a/drivers/thermal/st/st_thermal_memmap.c +++ b/drivers/thermal/st/st_thermal_memmap.c @@ -180,7 +180,7 @@ static void st_mmap_remove(struct platform_device *pdev) static struct platform_driver st_mmap_thermal_driver = { .driver = { .name = "st_thermal_mmap", - .pm = &st_thermal_pm_ops, + .pm = pm_sleep_ptr(&st_thermal_pm_ops), .of_match_table = st_mmap_thermal_of_match, }, .probe = st_mmap_probe, diff --git a/drivers/thermal/st/stm_thermal.c b/drivers/thermal/st/stm_thermal.c index 34785b9276fc..ffd988600ed6 100644 --- a/drivers/thermal/st/stm_thermal.c +++ b/drivers/thermal/st/stm_thermal.c @@ -440,7 +440,6 @@ static int stm_thermal_prepare(struct stm_thermal_sensor *sensor) return ret; } -#ifdef CONFIG_PM_SLEEP static int stm_thermal_suspend(struct device *dev) { struct stm_thermal_sensor *sensor = dev_get_drvdata(dev); @@ -466,10 +465,9 @@ static int stm_thermal_resume(struct device *dev) return 0; } -#endif /* CONFIG_PM_SLEEP */ -static SIMPLE_DEV_PM_OPS(stm_thermal_pm_ops, - stm_thermal_suspend, stm_thermal_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(stm_thermal_pm_ops, + stm_thermal_suspend, stm_thermal_resume); static const struct thermal_zone_device_ops stm_tz_ops = { .get_temp = stm_thermal_get_temp, @@ -580,7 +578,7 @@ static void stm_thermal_remove(struct platform_device *pdev) static struct platform_driver stm_thermal_driver = { .driver = { .name = "stm_thermal", - .pm = &stm_thermal_pm_ops, + .pm = pm_sleep_ptr(&stm_thermal_pm_ops), .of_match_table = stm_thermal_of_match, }, .probe = stm_thermal_probe, From patchwork Tue Jun 25 21:32:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raphael Gallais-Pou X-Patchwork-Id: 13712068 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 267EBC30653 for ; Tue, 25 Jun 2024 21:33:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zmhey6jWNgkoZcPsesEc/YC3gENWDbb7EazMCNZY/50=; b=CvYI0oHtUY54RnnWNbDgMVT/Kd kOubN1nPuZwFfnXLQi0RmJmhqGurWroFOk+iZNwesxx+5xE5DjH0wRWW99qOsHQDYjeWyNet7e+Hh va1tXFgMjTc8ZThrLUPRM1ceLljMBzYUuLccSYiort3fWFvb83q5x5XM4ijDxlqnfIJlMiOu8DzuU 9PW3qwduuJOIzkeVo5c/delAkKv6ojF86tWZ/8FT56Lhd6QudOqf8MyV80YkEBU69CBLKLQVjKgPP XlSoy7IVj8Gq8DBkNA4wfn3pZ587ybG/S8hoXeDsgDeLAkIkBF1rwynH8LOjDZUMbnJ48lBJbcJgN mmWv2/ow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMDn9-00000004aE9-1oje; Tue, 25 Jun 2024 21:33:31 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMDmv-00000004aAZ-0rw5 for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 21:33:19 +0000 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4217d808034so49089575e9.3 for ; Tue, 25 Jun 2024 14:33:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719351195; x=1719955995; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=zmhey6jWNgkoZcPsesEc/YC3gENWDbb7EazMCNZY/50=; b=eW9cmdQ1HupW2WapNrc/e9qW7BOpaBfBhErrgIRmEFyStV5By01erUnZY16M36/Suw iXhPePimiGnYC2zZ7OZ3iANdyKUp2hsDFf9NNqQV6Z8Az+NCbeLxzlTPZ/aZz5fAYl2P SJ/aIpAFr+FFNbl3UXE7pK9DT8Wm1v4+RI9E3QFls5PRCXTqsWXXMcQrrqJU4pzsrg7S bQkanjY15yq035eJHsHowwzmPHyRW9hg6v/r0Ae8UPQtzU1X3lLQxddCOPRgDRhzML63 DJwokqGHKT4EMXyuiCak0x8PcWg2Sfc5pjh6l0IJBiunEpoam07Lz8nXi/5qPoxfDiIz Rwiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719351195; x=1719955995; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zmhey6jWNgkoZcPsesEc/YC3gENWDbb7EazMCNZY/50=; b=oBR1gMd+2aJTyAKo6usXMecIiEouuONkvIFZL+NwNOyZYCjnyVU2POGh+XV54+xNrd HLFnuFBmVRNEqhdVXwOU2BalFzvbVXGfoIiewZwTABWaRdnKrvMWxyWrWfHz2x6I11O/ 387GCrHkpDn3g4tq2q5HrQDclKoZx//WRoRLDlZ5YyJSZ9hEHRpgTU88VWt+0XK0+nfb y1oY2inJNNqlkC6LUeM4y7y6rrKoVo0KpLWCpHFf8lIIepGx/9Mmz1LOXZzUpCEMOAUJ wl8Gye6ODlZFc4o9NwG2pSOA5NFfNe5JDppOVQoDOg1EJGpWTVuUxN9N8de9ympC4DyU zDHA== X-Forwarded-Encrypted: i=1; AJvYcCVgGIgPXTcU2pc0WHA1GI/ftAYltsh/JYl0t3C3osjCnvZzoYUCl74GOXdAWcQpJi9wYONDcE+uf7+VRQP6PpPxwvyIJo1OIkVN7i5WxT+DMXAZsYo= X-Gm-Message-State: AOJu0YzlxOpcIk/ybJDSwTD+zFy55yQK1NcK0mH0WnZfweMECyokyIp3 tJ0TCVSL3ou/M7huOTm3pzBeBse3WIVpza+ZZX08TT3QxOoCw16K X-Google-Smtp-Source: AGHT+IHZcYPdA/oB1eqxXUZJdRHrdM0ptr8uZAvGcXG5QB+c4jay5cR1N2yLLu/ozoO9syYLBuFxfQ== X-Received: by 2002:a5d:518c:0:b0:362:3b56:dbda with SMTP id ffacd0b85a97d-366e9463e46mr5084476f8f.9.1719351194528; Tue, 25 Jun 2024 14:33:14 -0700 (PDT) Received: from localhost ([2001:861:3385:e20:6384:4cf:52c5:3194]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-366e88c0c38sm9561633f8f.32.2024.06.25.14.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jun 2024 14:33:14 -0700 (PDT) From: Raphael Gallais-Pou Date: Tue, 25 Jun 2024 23:32:41 +0200 Subject: [PATCH v2 2/3] thermal: sti: depend on THERMAL_OF subsystem MIME-Version: 1.0 Message-Id: <20240625-thermal-v2-2-bf8354ed51ee@gmail.com> References: <20240625-thermal-v2-0-bf8354ed51ee@gmail.com> In-Reply-To: <20240625-thermal-v2-0-bf8354ed51ee@gmail.com> To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Maxime Coquelin , Alexandre Torgue , Patrice Chotard , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org X-Mailer: b4 0.14.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_143317_290287_06E856DD X-CRM114-Status: GOOD ( 15.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Switch to thermal_of_zone to handle thermal-zones. Replace thermal_zone_device_register() by devm_thermal_of_zone_register() and remove ops st_thermal_get_trip_type, st_thermal_get_trip_temp. Signed-off-by: Raphael Gallais-Pou --- Changes in v2: - Remove unused struct thermal_trip trip --- drivers/thermal/st/Kconfig | 1 + drivers/thermal/st/st_thermal.c | 25 ++++++++++--------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/thermal/st/Kconfig b/drivers/thermal/st/Kconfig index ecbdf4ef00f4..2d08147876ee 100644 --- a/drivers/thermal/st/Kconfig +++ b/drivers/thermal/st/Kconfig @@ -5,6 +5,7 @@ config ST_THERMAL tristate "Thermal sensors on STMicroelectronics STi series of SoCs" + depends on THERMAL_OF help Support for thermal sensors on STMicroelectronics STi series of SoCs. diff --git a/drivers/thermal/st/st_thermal.c b/drivers/thermal/st/st_thermal.c index 5f33543a3a54..1f2ba5c88cbc 100644 --- a/drivers/thermal/st/st_thermal.c +++ b/drivers/thermal/st/st_thermal.c @@ -12,6 +12,7 @@ #include #include "st_thermal.h" +#include "../thermal_hwmon.h" /* The Thermal Framework expects millidegrees */ #define mcelsius(temp) ((temp) * 1000) @@ -135,8 +136,6 @@ static struct thermal_zone_device_ops st_tz_ops = { .get_temp = st_thermal_get_temp, }; -static struct thermal_trip trip; - int st_thermal_register(struct platform_device *pdev, const struct of_device_id *st_thermal_of_match) { @@ -199,27 +198,22 @@ int st_thermal_register(struct platform_device *pdev, polling_delay = sensor->ops->register_enable_irq ? 0 : 1000; - trip.temperature = sensor->cdata->crit_temp; - trip.type = THERMAL_TRIP_CRITICAL; - sensor->thermal_dev = - thermal_zone_device_register_with_trips(dev_name(dev), &trip, 1, sensor, - &st_tz_ops, NULL, 0, polling_delay); + devm_thermal_of_zone_register(dev, 0, sensor, &st_tz_ops); if (IS_ERR(sensor->thermal_dev)) { - dev_err(dev, "failed to register thermal zone device\n"); + dev_err(dev, "failed to register thermal of zone\n"); ret = PTR_ERR(sensor->thermal_dev); goto sensor_off; } - ret = thermal_zone_device_enable(sensor->thermal_dev); - if (ret) - goto tzd_unregister; platform_set_drvdata(pdev, sensor); - return 0; + /* + * devm_thermal_of_zone_register() doesn't enable hwmon by default + * Enable it here + */ + return devm_thermal_add_hwmon_sysfs(dev, sensor->thermal_dev); -tzd_unregister: - thermal_zone_device_unregister(sensor->thermal_dev); sensor_off: st_thermal_sensor_off(sensor); @@ -232,7 +226,8 @@ void st_thermal_unregister(struct platform_device *pdev) struct st_thermal_sensor *sensor = platform_get_drvdata(pdev); st_thermal_sensor_off(sensor); - thermal_zone_device_unregister(sensor->thermal_dev); + thermal_remove_hwmon_sysfs(sensor->thermal_dev); + devm_thermal_of_zone_unregister(sensor->dev, sensor->thermal_dev); } EXPORT_SYMBOL_GPL(st_thermal_unregister); From patchwork Tue Jun 25 21:32:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raphael Gallais-Pou X-Patchwork-Id: 13712071 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 08523C30659 for ; Tue, 25 Jun 2024 21:33:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VUkVIkbscryFzLdHAGkO+1ya2/2312ktRzQgqWxaXtI=; b=ItdQW+qaSe5FXq815QN/WFb0un HNtEEYYwxacoBNK2BtICIKmmFVkrGnudheeQsj0+KPQid9c3ke9IqRDBqJn20i7dKSXDNXunfcpfs 5a6tW/8YTUeHPcJA6VG8/fiSj57YThHSPBIcpXTSP4W4FLVYw237e44WVo0S4qEnaVFfZGhew8HDT r6PTtfp3gaGEp+6QgmPgp/J4bkgONQOoKW2m0WZ1DzCWaEmOTYJoxvh1cNtvlQHZUaE9gx+UAWz5O zVn4c/saZRmT73vaigBllSjNBwyE9trrcXlAnJ/ZwiTGLiF1o5CenhxJ+xJs193zxF5xj81P8jowV KIjR9Qfg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMDnD-00000004aGC-1Av1; Tue, 25 Jun 2024 21:33:35 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMDmv-00000004aAr-3qUV for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 21:33:19 +0000 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-362b32fbb3bso3893677f8f.2 for ; Tue, 25 Jun 2024 14:33:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719351196; x=1719955996; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=VUkVIkbscryFzLdHAGkO+1ya2/2312ktRzQgqWxaXtI=; b=AS/JffAQHRoPGMv1Y4qs1guRN1ltlRtF88hw0c4DKhmHMvDdBaSO8csDi92ASxAL5U eD6XA4DU6UNkstFtT3IMGXEXAlvJl+fz5m/XCCP5/dqEivMQ211Onfx5WRUpEKEj0Xm8 uxdXFT39UQ8/FtarllvI1qxYmzwrqxKhXn2p3RNEOw3gN2ThT40rOnnNPDizDhVrRYpv ub07mkG96bzppDu6t0L1eqhMz77eJ2FKW/zA70Q7B8wlE2iqv+lQB9nD+NCHOI7KvOJm 70ytRlFIFbDnklVd+erflP/oLUDCt0ACZjypdLer2jXHD2aRW9mARc9NqFhQJaqfke65 T+iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719351196; x=1719955996; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VUkVIkbscryFzLdHAGkO+1ya2/2312ktRzQgqWxaXtI=; b=a0f1Z1aneQJl834MF7UGp9MXd5sgc9srolyqVoBKPmfPAX30ipl2y2oSZ3Jv6bdlCz 7+ZpNYToxnU0lmMK41exGWZ4VNhJA+eyozKmwVB//vfNHK6x0RlT6OW30sf89KCfEyNn j/4rRZK+OsORErG3k8+PzWyM8/mBUcn7KM4h6EsekVshfsoOEh4eyazymBrd32uXe0pS lU3OHxmy89nDt9VhlHhV0GF3Nvb+ICwsod3SsuizXAwPdh5aG0Ef2DVV1ut9bsvRc+4Y r4uPky8dxSTvB1TQ0zUVNZxvcrkx0Zk2RFLEXcPDeaUh1zzwP93UyrgywJpedZ9Bh0C1 Ag0w== X-Forwarded-Encrypted: i=1; AJvYcCWpcdcjtKWtn8hFDgkvl4ti/MSapMMxrnRiDTnQbEtXv46QbRT8s8jxTPuRV5LfaQ4FiItvTDZzb4WqxnD+Kb903B6VgesqB3u4IJQedtD2uY3KxE8= X-Gm-Message-State: AOJu0YxOtcjlglqYnIwDs5ioCf7yTL2PSTICbdylcBF0iOVHbQ0dZQ31 XUsD5NRhHCTc4n9xQp0SH95vI8P6Xkr9Fg4qB26dPokKPxSV8YQ1 X-Google-Smtp-Source: AGHT+IF1vNOVtlSl9cFErkZZ3gZeIrjKfVDkNDpF40NXHmyTCzK4OuWl8NqNcyOSM/LpMW3SCCIssA== X-Received: by 2002:adf:fa4c:0:b0:35d:c106:2db8 with SMTP id ffacd0b85a97d-366e7a63802mr7040004f8f.57.1719351195202; Tue, 25 Jun 2024 14:33:15 -0700 (PDT) Received: from localhost ([2001:861:3385:e20:6384:4cf:52c5:3194]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36647e7eb4fsm13959262f8f.18.2024.06.25.14.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jun 2024 14:33:15 -0700 (PDT) From: Raphael Gallais-Pou Date: Tue, 25 Jun 2024 23:32:42 +0200 Subject: [PATCH v2 3/3] ARM: dts: sti: add thermal-zones support on stih418 MIME-Version: 1.0 Message-Id: <20240625-thermal-v2-3-bf8354ed51ee@gmail.com> References: <20240625-thermal-v2-0-bf8354ed51ee@gmail.com> In-Reply-To: <20240625-thermal-v2-0-bf8354ed51ee@gmail.com> To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Maxime Coquelin , Alexandre Torgue , Patrice Chotard , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org X-Mailer: b4 0.14.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_143317_992261_4C7BEFD4 X-CRM114-Status: GOOD ( 16.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add a 'thermal-zones' node for stih418. A thermal-zone needs three components: - thermal sensors, described in an earlier commit[1] - cooling devices, specified for each CPU - a thermal zone, describing the overall behavior. The thermal zone needs references to both CPUs and thermal sensors, which phandle are also added. The thermal management will then be achieved on CPUs using the cpufreq framework. [1] https://lore.kernel.org/lkml/20240320-thermal-v3-2-700296694c4a@gmail.com/ Reviewed-by: Patrice Chotard Signed-off-by: Raphael Gallais-Pou --- arch/arm/boot/dts/st/stih407-family.dtsi | 6 +++-- arch/arm/boot/dts/st/stih418.dtsi | 41 +++++++++++++++++++++++++++++--- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/arch/arm/boot/dts/st/stih407-family.dtsi b/arch/arm/boot/dts/st/stih407-family.dtsi index 29302e74aa1d..35a55aef7f4b 100644 --- a/arch/arm/boot/dts/st/stih407-family.dtsi +++ b/arch/arm/boot/dts/st/stih407-family.dtsi @@ -33,7 +33,7 @@ delta_reserved: rproc@44000000 { cpus { #address-cells = <1>; #size-cells = <0>; - cpu@0 { + cpu0: cpu@0 { device_type = "cpu"; compatible = "arm,cortex-a9"; reg = <0>; @@ -52,8 +52,9 @@ cpu@0 { clock-latency = <100000>; cpu0-supply = <&pwm_regulator>; st,syscfg = <&syscfg_core 0x8e0>; + #cooling-cells = <2>; }; - cpu@1 { + cpu1: cpu@1 { device_type = "cpu"; compatible = "arm,cortex-a9"; reg = <1>; @@ -66,6 +67,7 @@ cpu@1 { 1200000 0 800000 0 500000 0>; + #cooling-cells = <2>; }; }; diff --git a/arch/arm/boot/dts/st/stih418.dtsi b/arch/arm/boot/dts/st/stih418.dtsi index b35b9b7a7ccc..6622ffa8ecfa 100644 --- a/arch/arm/boot/dts/st/stih418.dtsi +++ b/arch/arm/boot/dts/st/stih418.dtsi @@ -6,23 +6,26 @@ #include "stih418-clock.dtsi" #include "stih407-family.dtsi" #include "stih410-pinctrl.dtsi" +#include / { cpus { #address-cells = <1>; #size-cells = <0>; - cpu@2 { + cpu2: cpu@2 { device_type = "cpu"; compatible = "arm,cortex-a9"; reg = <2>; /* u-boot puts hpen in SBC dmem at 0xa4 offset */ cpu-release-addr = <0x94100A4>; + #cooling-cells = <2>; }; - cpu@3 { + cpu3: cpu@3 { device_type = "cpu"; compatible = "arm,cortex-a9"; reg = <3>; /* u-boot puts hpen in SBC dmem at 0xa4 offset */ cpu-release-addr = <0x94100A4>; + #cooling-cells = <2>; }; }; @@ -44,6 +47,38 @@ usb2_picophy2: phy3 { reset-names = "global", "port"; }; + thermal-zones { + cpu_thermal: cpu-thermal { + polling-delay-passive = <250>; /* 250ms */ + polling-delay = <1000>; /* 1000ms */ + + thermal-sensors = <&thermal>; + + trips { + cpu_crit: cpu-crit { + temperature = <95000>; /* 95C */ + hysteresis = <2000>; + type = "critical"; + }; + cpu_alert: cpu-alert { + temperature = <85000>; /* 85C */ + hysteresis = <2000>; + type = "passive"; + }; + }; + + cooling-maps { + map { + trip = <&cpu_alert>; + cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; + }; + }; + soc { rng11: rng@8a8a000 { status = "disabled"; @@ -107,7 +142,7 @@ mmc0: sdhci@9060000 { assigned-clock-rates = <200000000>; }; - thermal@91a0000 { + thermal: thermal@91a0000 { compatible = "st,stih407-thermal"; reg = <0x91a0000 0x28>; clock-names = "thermal";