From nobody Tue Sep 29 09:09:31 2026 Received: from mail-43166.protonmail.ch (mail-43166.protonmail.ch [185.70.43.166]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1BE33A5433 for ; Mon, 10 Aug 2026 09:51:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.43.166 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786355470; cv=none; b=OODHSDQeB8Hde1e/1bDbERNwHytOGFEX7MMvR/homARGj/7xjCnI01S7Mq2BFUvE+D9PZwOP6mXvjBw38wkcsuxa54aWDQZ/8nNtjVZX9TNR4PGjDaGPXhxKQTTGTsROMfGQiWzSVGoFhQcmsZNKyjiUcOnPWXho81IC8mduHjk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786355470; c=relaxed/simple; bh=ihb16qqgzfb+ZORy3jvepuRYiaQpGA/+Dj8f3i3SIZU=; h=Date:To:From:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=t8lZUNkxXHcCZMngRtDny0kUz2bvS3RvxMVmQeAYD2CEctPV8PtGhg+NsqhV2S32F4fqXvGMy7Rf7BTEeqTH9jhF7WZVa26DdosweKvxArqw2ZiCq7zVbYBd/GctiWOg7XPZ1pJVAXZ1+mKCkAPUMlZO3CAjIUreiUKB5tGpE6M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=protonmail.com; spf=pass smtp.mailfrom=protonmail.com; dkim=pass (2048-bit key) header.d=protonmail.com header.i=@protonmail.com header.b=Sosn8qr4; arc=none smtp.client-ip=185.70.43.166 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=protonmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=protonmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=protonmail.com header.i=@protonmail.com header.b="Sosn8qr4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1786355459; x=1786614659; bh=3gQCmbZiRpTIP78Wgb09iQGd9hbmY0T5UypymMdu5do=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=Sosn8qr4Hy6GO+M0FZme1WadsgJiXdMxGbSAfrGHzjUBJKhgUI7Gbeytow4UKSgYc Dsocy8YYBPUHiEimfrTiifurGOsmU1XFj3AIn91Su+8r+Rna0JFTv+V7TAfYMXX/nD XjdW/BFXFJDPX4IVcTS1nGVik6qAsKFVPu5YGlXeQlGmXR89kI9LSVcplnY1W+wFn7 ESWRsUI1G7jty3geLlJX1GMYYb4f3O4lVIS4PdbPebu/B6wD4tuIMNYntpFY757kY6 f+7/H9sNGgQ9s7WR/aKcp1haOJK1n9bNF8txnid2u9hhdpSYySkUI19KXlIvFjTrXR ou9b1MpSew7YQ== Date: Mon, 10 Aug 2026 09:50:54 +0000 To: Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Shayne Chen , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno From: Ryan Leung Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Ryan Leung Subject: [PATCH v2] wifi: mt76: mt7996: add thermal zone device registration Message-ID: <20260810-mt7996-thermal-zone-v2-1-563dfbbf9175@protonmail.com> Feedback-ID: 184418679:user:proton X-Pm-Message-ID: 3d550f87ccf31ceff35eda65ecd63ca9f0c8d962 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Register the mt7996 phy as a thermal zone sensor using devm_thermal_of_zone_register() so that device tree thermal-zones nodes can reference the Wi-Fi chip as a temperature source. This allows the kernel thermal governor to control external cooling devices such as PWM fans based on Wi-Fi chip temperature. Registration is non-fatal: -ENODEV is returned when no thermal-sensors DT property references this device, which is the expected case on platforms without a thermal zone configured. Signed-off-by: Ryan Leung --- Changes in v2: - Take phy->dev->mt76.mutex around mt7996_mcu_get_temperature() - Unregister phy->tzone explicitly in mt7996_unregister_thermal() before th= e phy is freed - Link to v1: https://patch.msgid.link/20260722-mt7996-thermal-zone-v1-1-88= 896e6e9985@protonmail.com To: Felix Fietkau To: Lorenzo Bianconi To: Ryder Lee To: Shayne Chen To: Sean Wang To: Matthias Brugger To: AngeloGioacchino Del Regno Cc: linux-wireless@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-mediatek@lists.infradead.org --- drivers/net/wireless/mediatek/mt76/mt7996/init.c | 33 ++++++++++++++++++= ++++ drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h | 1 + 2 files changed, 34 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/init.c b/drivers/net= /wireless/mediatek/mt76/mt7996/init.c index fb635a092584..fda9df1fa66b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7996/init.c @@ -234,11 +234,33 @@ static const struct thermal_cooling_device_ops mt7996= _thermal_ops =3D { .set_cur_state =3D mt7996_thermal_set_cur_throttle_state, }; =20 +static int mt7996_thermal_get_temp(struct thermal_zone_device *tz, int *te= mp) +{ + struct mt7996_phy *phy =3D thermal_zone_device_priv(tz); + int val; + + mutex_lock(&phy->dev->mt76.mutex); + val =3D mt7996_mcu_get_temperature(phy); + mutex_unlock(&phy->dev->mt76.mutex); + if (val < 0) + return val; + + *temp =3D val * 1000; + return 0; +} + +static const struct thermal_zone_device_ops mt7996_tz_ops =3D { + .get_temp =3D mt7996_thermal_get_temp, +}; + static void mt7996_unregister_thermal(struct mt7996_phy *phy) { struct wiphy *wiphy =3D phy->mt76->hw->wiphy; char name[sizeof("cooling_deviceXXX")]; =20 + if (phy->tzone) + devm_thermal_of_zone_unregister(phy->dev->mt76.dev, phy->tzone); + if (!phy->cdev) return; =20 @@ -275,6 +297,17 @@ static int mt7996_thermal_init(struct mt7996_phy *phy) phy->throttle_temp[MT7996_CRIT_TEMP_IDX] =3D MT7996_CRIT_TEMP; phy->throttle_temp[MT7996_MAX_TEMP_IDX] =3D MT7996_MAX_TEMP; =20 + phy->tzone =3D devm_thermal_of_zone_register(phy->dev->mt76.dev, + phy->mt76->band_idx, phy, + &mt7996_tz_ops); + if (IS_ERR(phy->tzone)) { + if (PTR_ERR(phy->tzone) !=3D -ENODEV) + dev_warn(phy->dev->mt76.dev, + "failed to register thermal zone %d: %ld\n", + phy->mt76->band_idx, PTR_ERR(phy->tzone)); + phy->tzone =3D NULL; + } + if (!IS_REACHABLE(CONFIG_HWMON)) return 0; =20 diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h b/drivers/n= et/wireless/mediatek/mt76/mt7996/mt7996.h index 2a0cdb56f822..39fa25a562e5 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h +++ b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h @@ -372,6 +372,7 @@ struct mt7996_phy { =20 struct ieee80211_sband_iftype_data iftype[NUM_NL80211_BANDS][NUM_NL80211_= IFTYPES]; =20 + struct thermal_zone_device *tzone; struct thermal_cooling_device *cdev; u8 cdev_state; u8 throttle_state; --- base-commit: ca800a9302764c445de0da0e84d2252400a770ee change-id: 20260722-mt7996-thermal-zone-a1de7cb1d728 Best regards, -- =20 Ryan Leung