From nobody Fri Sep 25 06:46:57 2026 Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04962439327 for ; Tue, 15 Sep 2026 17:13:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789492401; cv=none; b=TOLNNM1yL1wkjV0k3umwNOXPVOTvfqumANA7KF362SyU/Od6eAL6ZGRxMPLr8Lz88L7mWyztkFhiMCOcVwVOCOhmtrlZG/0kE5ayCqfdkaXfdJc+Vo0XzTlKIJ8wjr90SbuzyYwbq8jukLzjr4E1B/KRU8n5439WkF2ow5g5SsE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789492401; c=relaxed/simple; bh=qwRW5YP/OsxI03pqmCcnKn2ESNhEIHF0NnfugvT2Rec=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kGZA3qLtZAm6zh6TES09EbV7b6FVJ89UjhQIi2egcwMkihCmQnwyeh9TZVlea284RKbG2pqQWMewm3clTviT8I+J47YgtvhOD2kVNPFPeXsyyRQTPd/+DeXTZVaOCNmfN2AfQRy6HiWqg+2Gr7jOMCLfU+gyYcCbL7qRw26AjpI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LZ7N3x24; arc=none smtp.client-ip=209.85.167.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LZ7N3x24" Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-5b5f21afe8cso1277816e87.1 for ; Tue, 15 Sep 2026 10:13:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789492397; x=1790097197; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=SRE517es95kbkROai5n0sLeTok/JKNa+OL5tekr+lZM=; b=LZ7N3x24VKcV0Ep6KtvOpO7XcqBkoZUL7mgIyqmHjklZEud0H+kvh+7GjgMV0BjloA GdNS/49XZCqE+LXfF7GoP3umOsKOGxh9pSIWAItjzK0MtPoeAJ/lUF1aw3ohVbfIQK65 oC/v0dfPARqSdbFaEAAX5dOK6gP2er5jqiP46389pHD6mcU4IDKxebda7sliIvbgjepn A2vdvziOd0Cj3k5Fj43P0fgUOjA5gJZL1hXNm7QfEXmGa7yaf8RKJ/pCJAs6QN9VTpAr LGrsgWSsQ0583W3oRu5rpVcSB2pvh5G4kIsw+kU5RJmZJlKFPfV+hzx9Ssq2zvroza/b kJGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789492397; x=1790097197; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=SRE517es95kbkROai5n0sLeTok/JKNa+OL5tekr+lZM=; b=uRXHLX62SuCRzFovWda3ywZ30AayXPKrJTn3+aWCuoaLKdFGwaNLeToCSLvS7Uim4W XYgBcwE6q0sPDi/NDm1rURqvywG4Ld2efRsf4PwL7oMGSO1WltZPsU42Cy7drviX24xE ShyR1ChBDOAN85IbCnRSagbdgQOrEV3rfc8FBILDI3cvnxFxj35nrSwFQV9prs6j4bJs gjM1iVibctjZItsXhJhtFbTqYoWRlIeqrymSQIAWoOeKAR9UvEr0UGoZpNR3GoA+bST3 SmM/Js8lx2yMXAN7+9CwgEcp4Antx6eX0colc545OEEw+xtjb6b0U0T2T5ojvEi2WHFR LG7A== X-Forwarded-Encrypted: i=1; AKwUvBysaHGRzSjnDqYkKYhgrzcFLE7FqirA/5OsZooOcPYjzYZMk0QBl0tUMaoDuUe/ccqf+E5ZEzucvYAWmug=@vger.kernel.org X-Gm-Message-State: AFuF++nFBuLNZQQSv5pjfja/arvk4b+mjjI3EUHWMtxhJU8S6pjd3AN8 vYHjnxDwgocRfNw/YPSqP9ZxQ4Fp8VA+cGdHaI5FKb0fvAQ30wD1g1s= X-Gm-Gg: AYBFou3sGohsQNWUSxFbTCpuOy8OXwOuYni0rcz31VYqwqR2rP9u7rRtgkTbimQrQ4a vsCq1k0dLtVmCBBJSjyyChpy/Lej8/oM43OeLD9UAtaRfjw/wxbXW4qQfW0LKWwoH+bIIY6D0xR he3X2+dkTr2NKrtsdkVSaJecfaPm7YeewekY/bR8NN4yj9ddpM6JnZCasQmsw48Tm+helvkBpmi 2NhBX6skmrXWCPAnKYpjoFzqNlLiFZDoERg1e6jSjggLhyqnzrIr+xYu2YFJdrUB9sTuGxd33Cz cEaeii/0OhhvmFXB/t2WDyGqHZJx4C38jGkeLEINGVvAyaMZGtmckbU5y/ELKLAyxDRk+cOeTXj ba74FWVrcwF1RzlbuIMe5v31ZZXxs0wwpEspnw4gPvYo5v18KraiJeqsSSyZtc8le1Xia73Hn0i wupGWhHoiveky67bZ4D/txcf6S2AiGzan/yvB85XpQljhuRVcakdgLZDTMqo/a+g== X-Received: by 2002:a05:6512:10d1:b0:5b6:10bc:dc44 with SMTP id 2adb3069b0e04-5b8b2a86711mr1243660e87.27.1789492396486; Tue, 15 Sep 2026 10:13:16 -0700 (PDT) Received: from fedora ([46.8.219.5]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b8b57eb908sm91791e87.79.2026.09.15.10.13.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2026 10:13:16 -0700 (PDT) From: Vitaliy Sochnev To: "Rafael J. Wysocki" , Daniel Lezcano Cc: Zhang Rui , Lukasz Luba , Christian Marangi , Lorenzo Bianconi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Vitaliy Sochnev Subject: [PATCH v2 1/4] thermal/drivers/airoha: Fix AN7583 ADC mux field mapping Date: Tue, 15 Sep 2026 20:11:28 +0100 Message-ID: <20260915191131.25214-2-sochnev.v.74@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260915191131.25214-1-sochnev.v.74@gmail.com> References: <20260915191131.25214-1-sochnev.v.74@gmail.com> 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" On AN7583, bits 3:1 of 0x2e4 select the sensor (0 bandgap, 5 GbE, 6 CPU) and bits 3:2 of 0x2a0 select the diode (0 D0, 1 ZERO, 2 D1). The driver names them the other way round: MUX_TADC is 0x2e4, MUX_SENSOR is 0x2a0. v5 of the AN7583 series swapped the airoha_set_thermal_mux() arguments to match these names. The diode index now goes to the sensor selector, so the zone reads mux positions 1, 0 and 2 (PAD_AVS, bandgap, core voltage) instead of the bandgap diodes. On a Nokia XG-040G-MF the result crosses the critical trip and the board powers off during boot. Swap the field definitions. MUX_TADC then selects the diode, as on EN7581, and the existing call order is correct. Fixes: b20d9782756a ("thermal/drivers/airoha: Add support for AN7583 Therma= l Sensor") Signed-off-by: Vitaliy Sochnev --- drivers/thermal/airoha_thermal.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/airoha_thermal.c b/drivers/thermal/airoha_ther= mal.c index 77b3a1af271f..2934d6aba0ed 100644 --- a/drivers/thermal/airoha_thermal.c +++ b/drivers/thermal/airoha_thermal.c @@ -18,10 +18,10 @@ #define EN7581_DOUT_TADC 0x2f8 #define EN7581_DOUT_TADC_MASK GENMASK(15, 0) =20 -#define AN7583_MUX_SENSOR 0x2a0 +#define AN7583_MUX_TADC 0x2a0 #define AN7583_LOAD_ADJ GENMASK(3, 2) -#define AN7583_MUX_TADC 0x2e4 -#define AN7583_MUX_TADC_MASK GENMASK(3, 1) +#define AN7583_MUX_SENSOR 0x2e4 +#define AN7583_MUX_SENSOR_MASK GENMASK(3, 1) #define AN7583_DOUT_TADC 0x2f0 =20 /* PTP_THERMAL regs */ @@ -634,8 +634,8 @@ static const struct thermal_zone_device_ops an7583_tz_o= ps =3D { =20 static const struct reg_field an7583_chip_scu_fields[AIROHA_THERMAL_FIELD_= MAX] =3D { [AIROHA_THERMAL_DOUT_TADC] =3D REG_FIELD(AN7583_DOUT_TADC, 0, 31), - [AIROHA_THERMAL_MUX_TADC] =3D REG_FIELD(AN7583_MUX_TADC, 1, 3), - [AIROHA_THERMAL_MUX_SENSOR] =3D REG_FIELD(AN7583_MUX_SENSOR, 2, 3), + [AIROHA_THERMAL_MUX_TADC] =3D REG_FIELD(AN7583_MUX_TADC, 2, 3), + [AIROHA_THERMAL_MUX_SENSOR] =3D REG_FIELD(AN7583_MUX_SENSOR, 1, 3), }; =20 static int an7583_thermal_probe(struct platform_device *pdev, --=20 2.55.0 From nobody Fri Sep 25 06:46:57 2026 Received: from mail-lf2-f12.google.com (mail-lf2-f12.google.com [74.125.229.204]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47C7443849F for ; Tue, 15 Sep 2026 17:13:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.229.204 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789492402; cv=none; b=OZ9THKPZ7KpotrYrB5yeWaB7MD7gvptK4aYianY/od/TaI9AmizJHBRVIdpNH0H9RyJ+GdwbskKPIOZiTWjf8sUGvuWrwEwXdY+Yh9S82ZbzHP17y6/4BjNIP5HPjAjJqAXuXS1iBMKm8jJ3OQkdT2GAIF21Vl6BR5FleSrm/Eg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789492402; c=relaxed/simple; bh=2r0CGwnbhw+4LMmv7iYh/YHAix4sdwnKIMTStdJVtsM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tn8NGBYhcPfskKBjkyTZE6q3N5u11NciF242E0naofHDowvr9sDD7uMwkelYrDg49Ea/HwOMufwm+u9Qy4p0OKj4alfdfVp4W4xXU5JQ8NGE6yD+mVZ+fpHyOhGQ+D6aRjfd1hY6eiS6IPeunh7eSrB+MOW2AJKkhCr/W9RqRII= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZM5sncDP; arc=none smtp.client-ip=74.125.229.204 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZM5sncDP" Received: by mail-lf2-f12.google.com with SMTP id 2adb3069b0e04-5b5e4f16f12so3809663e87.1 for ; Tue, 15 Sep 2026 10:13:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789492398; x=1790097198; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=qhwkJWnv59ZKHCv2u+n64jx0w7NQkxuLbLuAE4ou0xQ=; b=ZM5sncDP+8texOSeFeFr8gC/i1ugBafurUUBKpq9X/vwAlKsAvkhHOW6MWCpO2fa2c sTEB1RxuvSd3Svhx7joHNAdMR6v9QdrQrp9JWwbbBVyhKwaobng9HgXEkIK8b1ySZgLP T7XHyL4HqEYWnB3Stra3rvi610DcBkz3b7OwOfdMQzMHLILgv7T6ndWyNWEfRPdkLBj0 nZ/Zw8S5fmSrqV4/kL3Meovj1wxtTc5GzHhzy/XMVjg6mN+jU7AjwQXBkd8kPKl2fz9a 9aVSWemz43rUwMUZVYe1rZ7IKBS7ZPhknpzAdhGY8pPceaLRggPaAYYFutzWmlok156k ceBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789492398; x=1790097198; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=qhwkJWnv59ZKHCv2u+n64jx0w7NQkxuLbLuAE4ou0xQ=; b=OTwzRvB8gdCag1ydGJP94SZyDkcwZWfGZBIhKbjLM9rzes37g5za1P3SmfxB3DtAti EY3CZMzAtw02e2ofhHBE35hLTBOnYpQ/IQU5eR04o8Hrrxxi8WgjDmVPI/PlvLijRopl VSAI1umS4NWU9og1HSVSp/3QLJAu3Ah8Wk1rNHpesCiUbpLkONgF1GEPtqLAq1I6UNKo Y0xShH5kvbMNFNJXnTG8ggvfvQDTZF7f6Q98Xy+M4ihCZa+Beieegr1/7WYxj4nd/A0G k/V6K3+fbDohuI5YXraG5z+fFyOA+hmSryy6YSlNwTjORGwxVBc3IJdIhZ/7DgCo9UR7 UI3g== X-Forwarded-Encrypted: i=1; AKwUvBx2ZLjwzU9p5Bh50E3m9TQEx3PTTjQvoA2wK8m42CQ8ZHVFa8qqoaWJ99+ViOWxJt6TMUBVq58Eu+jyPYo=@vger.kernel.org X-Gm-Message-State: AFuF++nj7jJ4L7gG9tl9oE0LCN2bf8SbxX+fVdFercdHIRTRU9lo3RYK BD/oiqBW7gtNIq2F3+S0X0F2qEsfXznOJSGwDWkqCk5//FnNcgbfVOY= X-Gm-Gg: AYBFou310VVmOyjaxQIMAwn4enZAVXMoDzOyAuuU3yZGsu4kAmlytFCyoGD6ogiW+vt BjnjHSwPbwegXY1Vc8qnOvmOD8/Zl6IxzzD0vrA/XLIKi4jaYrOhPupcFHIx8ub80tDL7EkiF5K FMFgR1ec2kQCuMDxet5kiYYmzzxXhTbgSxccirS9fT2JdmSAwfLyMadC+clyqCBhpcUpJf5ML2z 0+bifTJdujfHT6tj8rE2OcMtLGEosGeh0pyy1nUzNfjjz7MJ++2wD0H9lHRuoQnHAnVVvkckm9w TGumkL45yPj+ESz5bgTtyJRp9gFgpJrE1/Cx+HuWB6hz5dhnFPRDdJWqQqd9Usf8VvpfjH4MhLB N55Ge4unRz8ycWol3eTIbTZGqG0pyvz5tEHbSPiidwklzgytPM7W4XvbACJ1SEm0dh3juud7tx8 8aXtbgxGwfYNzkxWmbPDxMCr1iR42MYw4ppzsJW8mauwBAeHnctqXlY4y3hcyPjw== X-Received: by 2002:a05:6512:3a96:b0:5b6:19fe:a5a9 with SMTP id 2adb3069b0e04-5b8ae6b8986mr4523493e87.26.1789492397996; Tue, 15 Sep 2026 10:13:17 -0700 (PDT) Received: from fedora ([46.8.219.5]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b8b57eb908sm91791e87.79.2026.09.15.10.13.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2026 10:13:17 -0700 (PDT) From: Vitaliy Sochnev To: "Rafael J. Wysocki" , Daniel Lezcano Cc: Zhang Rui , Lukasz Luba , Christian Marangi , Lorenzo Bianconi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Vitaliy Sochnev Subject: [PATCH v2 2/4] thermal/drivers/airoha: Serialise access to the shared ADC Date: Tue, 15 Sep 2026 20:11:29 +0100 Message-ID: <20260915191131.25214-3-sochnev.v.74@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260915191131.25214-1-sochnev.v.74@gmail.com> References: <20260915191131.25214-1-sochnev.v.74@gmail.com> 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" A read selects the sensor and walks three diodes with a 10 ms settle on each. Nothing serialises this, so concurrent reads interleave and convert samples taken at another mux position. Mux writes are dropped silently unless PLLRG_PROTECT is lifted, and its save and restore do not nest. The cached TADC value also skips a write after another reader has moved the mux. With the AN7583 sensors read as parallel zones during CPU frequency changes, a zone crossed its critical trip on a chip at 55 C and the board shut down. Serialise the sequence, drop the cache, check the selection after writing and after sampling, and return -EAGAIN if it does not hold. Signed-off-by: Vitaliy Sochnev --- drivers/thermal/airoha_thermal.c | 85 +++++++++++++++++++++++++------- 1 file changed, 68 insertions(+), 17 deletions(-) diff --git a/drivers/thermal/airoha_thermal.c b/drivers/thermal/airoha_ther= mal.c index 2934d6aba0ed..d7e4a088b7ea 100644 --- a/drivers/thermal/airoha_thermal.c +++ b/drivers/thermal/airoha_thermal.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -191,6 +192,7 @@ #define AN7583_NUM_SENSOR 3 =20 #define AIROHA_THERMAL_NO_MUX_SENSOR -1 +#define AIROHA_THERMAL_MUX_TRIES 3 =20 /* Convert temp to raw value as read from ADC ((((temp / 100) - init) * sl= ope) / 1000) + offset */ #define TEMP_TO_RAW(priv, temp) ((((((temp) / 100) - (priv)->init_temp) = * \ @@ -250,7 +252,8 @@ struct airoha_thermal_priv { struct resource scu_adc_res; =20 u32 pllrg_protect; - int current_adc; + /* Serialises mux selection and ADC sampling */ + struct mutex lock; =20 struct thermal_zone_device *tz; int init_temp; @@ -294,9 +297,26 @@ static int airoha_get_thermal_ADC(struct airoha_therma= l_priv *priv) return val; } =20 +static bool airoha_thermal_mux_holds(struct airoha_thermal_priv *priv, + int tdac_idx, int sensor_idx) +{ + unsigned int val; + + if (regmap_field_read(priv->chip_scu_fields[AIROHA_THERMAL_MUX_TADC], &va= l) || + val !=3D tdac_idx) + return false; + + if (sensor_idx =3D=3D AIROHA_THERMAL_NO_MUX_SENSOR) + return true; + + return !regmap_field_read(priv->chip_scu_fields[AIROHA_THERMAL_MUX_SENSOR= ], &val) && + val =3D=3D sensor_idx; +} + static void airoha_set_thermal_mux(struct airoha_thermal_priv *priv, int tdac_idx, int sensor_idx) { + int tries =3D AIROHA_THERMAL_MUX_TRIES; u32 pllrg; =20 /* Save PLLRG current value */ @@ -307,19 +327,17 @@ static void airoha_set_thermal_mux(struct airoha_ther= mal_priv *priv, priv->pllrg_protect); =20 /* - * Configure Thermal Sensor mux to sensor_idx. + * Configure Thermal Sensor mux to sensor_idx and Thermal ADC mux to + * tdac_idx. Writes can be dropped silently, so read them back. * (if not supported, sensor_idx is AIROHA_THERMAL_NO_MUX_SENSOR) */ - if (sensor_idx !=3D AIROHA_THERMAL_NO_MUX_SENSOR) - regmap_field_write(priv->chip_scu_fields[AIROHA_THERMAL_MUX_SENSOR], - sensor_idx); - - /* Configure Thermal ADC mux to tdac_idx */ - if (priv->current_adc !=3D tdac_idx) { + do { + if (sensor_idx !=3D AIROHA_THERMAL_NO_MUX_SENSOR) + regmap_field_write(priv->chip_scu_fields[AIROHA_THERMAL_MUX_SENSOR], + sensor_idx); regmap_field_write(priv->chip_scu_fields[AIROHA_THERMAL_MUX_TADC], tdac_idx); - priv->current_adc =3D tdac_idx; - } + } while (!airoha_thermal_mux_holds(priv, tdac_idx, sensor_idx) && --tries= ); =20 /* Restore PLLRG value on exit */ regmap_write(priv->chip_scu, EN7581_PLLRG_PROTECT, pllrg); @@ -594,12 +612,40 @@ static int en7581_thermal_post_probe(struct platform_= device *pdev) return 0; } =20 +static int an7583_thermal_read_diode(struct airoha_thermal_priv *priv, + int diode, int sensor_idx, int *val) +{ + airoha_set_thermal_mux(priv, diode, sensor_idx); + *val =3D airoha_get_thermal_ADC(priv); + + return airoha_thermal_mux_holds(priv, diode, sensor_idx) ? 0 : -EAGAIN; +} + +static int an7583_thermal_read_diodes(struct airoha_thermal_priv *priv, + int sensor_idx, int *zero, int *d0, + int *d1) +{ + int ret; + + ret =3D an7583_thermal_read_diode(priv, AN7583_ZERO_TADC, sensor_idx, zer= o); + if (ret) + return ret; + + ret =3D an7583_thermal_read_diode(priv, AN7583_D0_TADC, sensor_idx, d0); + if (ret) + return ret; + + return an7583_thermal_read_diode(priv, AN7583_D1_TADC, sensor_idx, d1); +} + static int an7583_thermal_get_temp(struct thermal_zone_device *tz, int *te= mp) { struct airoha_thermal_priv *priv =3D thermal_zone_device_priv(tz); int sensor_idx; int delta_diode, delta_gain; int coeff, slope, offset; + int tries =3D AIROHA_THERMAL_MUX_TRIES; + int ret; =20 int diode_zero, diode_d0, diode_d1; =20 @@ -610,12 +656,14 @@ static int an7583_thermal_get_temp(struct thermal_zon= e_device *tz, int *temp) slope =3D an7583_thermal_slope[sensor_idx]; offset =3D an7583_thermal_offset[sensor_idx]; =20 - airoha_set_thermal_mux(priv, AN7583_ZERO_TADC, sensor_idx); - diode_zero =3D airoha_get_thermal_ADC(priv); - airoha_set_thermal_mux(priv, AN7583_D0_TADC, sensor_idx); - diode_d0 =3D airoha_get_thermal_ADC(priv); - airoha_set_thermal_mux(priv, AN7583_D1_TADC, sensor_idx); - diode_d1 =3D airoha_get_thermal_ADC(priv); + mutex_lock(&priv->lock); + do { + ret =3D an7583_thermal_read_diodes(priv, sensor_idx, &diode_zero, + &diode_d0, &diode_d1); + } while (ret =3D=3D -EAGAIN && --tries); + mutex_unlock(&priv->lock); + if (ret) + return ret; =20 delta_diode =3D diode_d1 - diode_d0; delta_gain =3D (delta_diode * coeff) / 100 + (diode_zero - diode_d1); @@ -676,7 +724,10 @@ static int airoha_thermal_probe(struct platform_device= *pdev) return -ENOMEM; =20 priv->pllrg_protect =3D soc_data->pllrg_protect; - priv->current_adc =3D -1; + + ret =3D devm_mutex_init(dev, &priv->lock); + if (ret) + return ret; =20 if (!soc_data->probe) return -EINVAL; --=20 2.55.0 From nobody Fri Sep 25 06:46:57 2026 Received: from mail-lf2-f12.google.com (mail-lf2-f12.google.com [74.125.229.204]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9804A4AD7F0 for ; Tue, 15 Sep 2026 17:13:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.229.204 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789492403; cv=none; b=HYYo0M4qOAnC7pDp9uHTdwlxpSn2S2kfwK3y/9JlkOtlx8PRs9WovN7cvinXpnwgfFhOIRvkOzLF7FBqluwiTn60IEpR0fHgX8ndhYSjMLUObImgNMIfvtB3WLKnQ61wpjFKfc+Z1qdEiU6WdsfwmWt5gt39Lc1qibDZZ43aPa0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789492403; c=relaxed/simple; bh=uqGrsfhQVXplRsdUQGFvRbPRKj8lI1bt0w9YLpudhHo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=geLWRpHwyTUuJej/uzqO2mlxi7STma5gmilrWldDcwsaxh9tUuJ1vOZ3dY5u7o58K2xCMVvbKHcuMMtOnRCoMkGvBfQmNzhwoYU80n+SF6KVCSACvOcrZc7KObDMdoFLUqfYgTq8G9WOYtJzvGqrwf612Y0ortPvrYirhnKuCWo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kcO3CCYm; arc=none smtp.client-ip=74.125.229.204 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kcO3CCYm" Received: by mail-lf2-f12.google.com with SMTP id 2adb3069b0e04-5b5e4f1651bso3289156e87.3 for ; Tue, 15 Sep 2026 10:13:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789492399; x=1790097199; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=crm5nugieczeEoBXBtWI2YHGx1NS43N1iIME//CgsMQ=; b=kcO3CCYm4h13lTkKJ/DVNN14Wf7YGEGB2l0blocauL1o5J5Hc+LxJufeWxK63srb4o gdbA5TWw+DNlJwG/UPOEmfXvwfs353tTAO6d82PBjHWUzBuAX5GIARf9VXPmfOPB4ck5 nhgNX/ZhljTN8JP6xMCahIcQwIxrsdJzBDQJD1avhowTssuO9a3ZOLoWLNCZYmpv9h8T BHe2uQ97J06SGkLn99Rb6z8E64uh9MZR3R/++jKaV+c9/rFQWHXbWInNw/CCeeRgGemi UU9GdBfjsh6Vs9NXF/1fIBI80d2Ie400Kz+Epr962VpZTnbdJKm1/QKOzV1kRVkjAsCW GbSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789492399; x=1790097199; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=crm5nugieczeEoBXBtWI2YHGx1NS43N1iIME//CgsMQ=; b=WZJ3gdefokffD8B8TYDFB4HmpxoW545GLcaE24MwqsB5SHVwtXhLVie64/I2DAv/lQ wa0Aay5pvrtOGBwvan0/a2VoNJNWsysGogwIuYtjMtuje79MO4QTqi1Jork1myMiDxrz D2awY7HHaIJOdvsr/zecbEst3vL2qRrxVH7iaR0zGnL3VRbwaCq5N9HfEOETEzLqLKH5 4S0ALlDRLB1gATqC6zt2IpVnKzu4zR62T/EpUHeZ/rlDGrAotRoZP+H6IK5TdZmVAdRT Lu8rju1kr8EFzwuBCNNpLAmAr8dpCBfNvduGPDjJI+C96nhnkACQ8tmRTo3W1FPtWybm 2VZw== X-Forwarded-Encrypted: i=1; AKwUvBxfk+7WER9kHwManAOsAZZHG1LcDhhyKljWyPKrJBrXOXGpF1pPSFoIOHraocDbzL7/HywE/I8irsJoGSY=@vger.kernel.org X-Gm-Message-State: AFuF++nUvvQaud4BsW3JHQgH/jQLQ9iLljuiIcYBskclODvPsVDWrU8/ aqjIbQXMVL6Z5FFWatpzuMUuJTG/SbvLr6yAvRGUFlCff+UWo7C9+zE= X-Gm-Gg: AYBFou2evpy/MouaWazeij0eZbRoakAI2ylGfaZsqNrgNO7LUOQzYXixjYJsPqfI5Ts MuPBQmohM+o55mXUncgTY94vUh5vYaR1lOqyhjjBbHlUADx0+gwbR3zv28uVYPww+DUOAp9fg2c 6ssoAnCcE7iW/KI+LY66Vc0zymVJBSARYvUBV2phOip1havcGbT7/kBdGrUYN8DfR8VxzEyRFOw gCbl6Cx2Em6wNERfEjM2L4z5p5Bma0U0UlqPhOW2qEmfyMrPuvSswhTLIL2Hs6RPYWygxyqnu20 7AmQVRwZjrJTlDst6Z3WJXoT63gSW9fMbwkH0XjPQnRAdjWgAQKOn/18y3GNv84iHkOLihcpfK/ cs0JGgE7wk9UICn3Cz0kjhpK/RSdwhssZlfLWnwjXts+ICPcDRCo8/i9TkDkpvaE0AXAvdqzW2/ 1jHf4xEf3pknvkIjCsJspQKIRb9k8vMu0KLTCG/5HihCwo8CvTIGrVDP25FEtpeg== X-Received: by 2002:a05:6512:1388:b0:5b2:e947:b3de with SMTP id 2adb3069b0e04-5b8ae6847acmr1952542e87.7.1789492399189; Tue, 15 Sep 2026 10:13:19 -0700 (PDT) Received: from fedora ([46.8.219.5]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b8b57eb908sm91791e87.79.2026.09.15.10.13.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2026 10:13:18 -0700 (PDT) From: Vitaliy Sochnev To: "Rafael J. Wysocki" , Daniel Lezcano Cc: Zhang Rui , Lukasz Luba , Christian Marangi , Lorenzo Bianconi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Vitaliy Sochnev Subject: [PATCH v2 3/4] dt-bindings: arm: airoha: Use one thermal sensor cell for AN7583 Date: Tue, 15 Sep 2026 20:11:30 +0100 Message-ID: <20260915191131.25214-4-sochnev.v.74@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260915191131.25214-1-sochnev.v.74@gmail.com> References: <20260915191131.25214-1-sochnev.v.74@gmail.com> 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" AN7583 has three temperature sensors behind the chip SCU: bandgap, GbE and CPU. With no cells a thermal zone can only refer to the bandgap sensor. Use one cell to select the sensor. The AN7583 compatible is new in 7.3-rc1 and no device tree uses the property yet. Signed-off-by: Vitaliy Sochnev Reviewed-by: Rob Herring (Arm) --- .../devicetree/bindings/arm/airoha,en7581-chip-scu.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/arm/airoha,en7581-chip-scu.y= aml b/Documentation/devicetree/bindings/arm/airoha,en7581-chip-scu.yaml index cc564dc7b414..4a10d024f5fa 100644 --- a/Documentation/devicetree/bindings/arm/airoha,en7581-chip-scu.yaml +++ b/Documentation/devicetree/bindings/arm/airoha,en7581-chip-scu.yaml @@ -26,7 +26,8 @@ properties: maxItems: 1 =20 '#thermal-sensor-cells': - const: 0 + description: Sensor index, 0 bandgap, 1 GbE, 2 CPU. + const: 1 =20 required: - compatible --=20 2.55.0 From nobody Fri Sep 25 06:46:57 2026 Received: from mail-lf2-f12.google.com (mail-lf2-f12.google.com [74.125.229.204]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91301480DE0 for ; Tue, 15 Sep 2026 17:13:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.229.204 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789492404; cv=none; b=iVPsGJGiEdybQ3XI5L5y9uUZTN7D21uuDqNSE9s0xjjC1U3ODW3GAU/NGSU5rTITzQFLCof8I8PGgCQZy73CIRgqn4jlcY5HTd31UNcVfGhXRObH8d1/3pxpNXlPcKIIN7A9LmU06HYFagjeDzw5gWc5v+6GJ7/RLVcMC9RllZk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789492404; c=relaxed/simple; bh=9dqGjDEI4RbdLK6jt6HCd0s+ya3fCD6ApoTxnVl2Ciw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jbF4GHCbXRuBCY6XXbAIZC4DA5/AjuSAlBFC9gXtAv06Zf4/B2PQ3nUoMGBeK6ou11gTqEdXRCSsy8vAHIqvzZ9DtH1mSSU5aacbW82aTYnWgzbihZc6w5t5hXHFkSb7Q12Dbte6uY2qdF0Q/OnoH8e1IfSVThbKINmXUdu1e8s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Egl0OnqY; arc=none smtp.client-ip=74.125.229.204 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Egl0OnqY" Received: by mail-lf2-f12.google.com with SMTP id 2adb3069b0e04-5b5e4f17450so3118895e87.0 for ; Tue, 15 Sep 2026 10:13:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789492400; x=1790097200; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=RgfH4fC1RNbYMj7TSVJSUxYa5garvCg3vB3RQ2vnJ3I=; b=Egl0OnqYkB5fE9jobJioPZLB9QdaUloRMx6rPwZLjRcVEKn1HILwXsZ13U+TgAzojV 2Am7pvs+kgdnCdxKcpzA1cpucqCGQRXyGMjK3L+LkxAGrib+Q+OvAyGsr6yRDasicTE4 eUpkb44J0OLXPjKDqXZOH078vCJnweuqvPwYTMLtDUJRaIEBGppV/NuquaH7PY6ByRma nZi4AHwicCNxwiYkURC1p5tVpRkSuwW+NfzBPigdu4SISg+ELh51zARK/409644F/Es1 eZLTXpIMc1J6KczyM9/wnetQ3qSmV1hwX891RXAvLvLuPmaxb+YDgFdgGVDw84Vmdr8c o6FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789492400; x=1790097200; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=RgfH4fC1RNbYMj7TSVJSUxYa5garvCg3vB3RQ2vnJ3I=; b=nBhRPsCfkvtbCN8286K7Ff/ceFw7DJ0wmN7ReZDMYWTqUL5pbU3qCTI4Z31YhgdvCP W6yM+ZhsHSH/o93vjvddU40P13e+vjHwA0+02MXXavp/zP2Stv0a1FAQVSirAwRZU7k1 R7rdfomyJgdZ8As+pckfbl6xLzyQwux0rEUxOFKy0suAUGfvV19X+AzvzQ1AzMEI7ff3 M50Pv/5fdxDUVJy54RM6LEef8fhIsWRRg0Yvku9+hu/a7TwyUg6Uz+M9vJK3X6pUXI3s n+Q52qL8nyIOBvLwgBwXri4+NAy4nn8WTG2579oknrTixIupgTa+qJruWV5VWgaGJyTa Ft/A== X-Forwarded-Encrypted: i=1; AKwUvByukFtz7NDI1FSt48B4IWWwKPksicY5gGNfAxMm6vivCiHagmi/HUt//bsLFzw8bXsqjpz/Wc3xfn6jneY=@vger.kernel.org X-Gm-Message-State: AFuF++nvIFjhVZWx070P0bLQREbq44BFDJTjBxmUTZUcWsfpb6oD2paj 9M9zdR6Dun4GE5XbmoWszz7g4WMsZTAjD2BX+ChaaxKC757mLl8DTd0= X-Gm-Gg: AYBFou0YUCg2qzSy4IV+FXHN/wv+rj4CajS3MyP4rHeQ8YDR5/nBOwaKjOi3cbCEfPb GwZr6Ijav7fX02J8XCbh6nK+CU6vfG19fFwcBVGIt5MbCHxJfltVN0m27SiZPysSbClYY/+pCYx +zlV7yt3EOfSYnyI1Dm4yOVAv00Cd8Sm3++otGHjf6OMv+cUCfCZFo86RIjXGtUjdYqGbDcINLV 14ozCLS4gRJddqjFMs4qw/EFdttoZziQLmdMWAZgvbWv89Fwvq9nPFgzqJPi5QpnJxSZgku5rlL mTdFhF9ecH1aDbY0GfuW3KDeCiqhzRXhAbDEuVanjYvWdoGfD3C1YPNg+jofSrpKTVQxwY3Ny/O h4R/S/wEzrVi+CMuIV2QSUcdYo9Fz2DZdpEIgBBBfEVIwQL/pu7aEmZhMBgdM14ugi5ijs3+oZ5 hxZGe8vD7IwGOOYFLp2U4Yx7stFZcZVw95XFbOfz2O8j08XT17cRVdWPOuDuIXVALiB+87uXJK X-Received: by 2002:a05:6512:3ca9:b0:5b6:183c:5c94 with SMTP id 2adb3069b0e04-5b8ae69f54fmr2035444e87.50.1789492400503; Tue, 15 Sep 2026 10:13:20 -0700 (PDT) Received: from fedora ([46.8.219.5]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b8b57eb908sm91791e87.79.2026.09.15.10.13.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2026 10:13:20 -0700 (PDT) From: Vitaliy Sochnev To: "Rafael J. Wysocki" , Daniel Lezcano Cc: Zhang Rui , Lukasz Luba , Christian Marangi , Lorenzo Bianconi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Vitaliy Sochnev Subject: [PATCH v2 4/4] thermal/drivers/airoha: Register a thermal zone per AN7583 sensor Date: Tue, 15 Sep 2026 20:11:31 +0100 Message-ID: <20260915191131.25214-5-sochnev.v.74@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260915191131.25214-1-sochnev.v.74@gmail.com> References: <20260915191131.25214-1-sochnev.v.74@gmail.com> 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" AN7583 has three temperature sensors and the driver has constants for all of them, but it registers one zone and reads only the bandgap sensor. Register a zone per sensor; the thermal sensor cell selects it. A device tree may describe fewer zones than sensors. EN7581 still registers one zone. Idle and with both cores loaded on a Nokia XG-040G-MF: bandgap 56.9 C -> 59.3 C GbE 58.7 C -> 61.5 C CPU 57.0 C -> 61.1 C Signed-off-by: Vitaliy Sochnev --- drivers/thermal/airoha_thermal.c | 64 +++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 13 deletions(-) diff --git a/drivers/thermal/airoha_thermal.c b/drivers/thermal/airoha_ther= mal.c index d7e4a088b7ea..d996ef539fa1 100644 --- a/drivers/thermal/airoha_thermal.c +++ b/drivers/thermal/airoha_thermal.c @@ -245,6 +245,11 @@ enum airoha_thermal_chip_scu_field { AIROHA_THERMAL_FIELD_MAX, }; =20 +struct airoha_thermal_zone { + struct airoha_thermal_priv *priv; + int sensor; +}; + struct airoha_thermal_priv { struct regmap *map; struct regmap *chip_scu; @@ -263,6 +268,9 @@ struct airoha_thermal_priv { =20 struct airoha_thermal_soc_data { u32 pllrg_protect; + /* Sensor mux value per zone, NULL without a sensor mux */ + const int *sensors; + int num_sensors; =20 const struct thermal_zone_device_ops *thdev_ops; int (*probe)(struct platform_device *pdev, @@ -348,7 +356,8 @@ static void airoha_set_thermal_mux(struct airoha_therma= l_priv *priv, =20 static int en7581_thermal_get_temp(struct thermal_zone_device *tz, int *te= mp) { - struct airoha_thermal_priv *priv =3D thermal_zone_device_priv(tz); + struct airoha_thermal_zone *zone =3D thermal_zone_device_priv(tz); + struct airoha_thermal_priv *priv =3D zone->priv; int min_value, max_value, avg_value, value; int i; =20 @@ -374,7 +383,8 @@ static int en7581_thermal_get_temp(struct thermal_zone_= device *tz, int *temp) static int en7581_thermal_set_trips(struct thermal_zone_device *tz, int lo= w, int high) { - struct airoha_thermal_priv *priv =3D thermal_zone_device_priv(tz); + struct airoha_thermal_zone *zone =3D thermal_zone_device_priv(tz); + struct airoha_thermal_priv *priv =3D zone->priv; bool enable_monitor =3D false; =20 if (high !=3D INT_MAX) { @@ -640,8 +650,9 @@ static int an7583_thermal_read_diodes(struct airoha_the= rmal_priv *priv, =20 static int an7583_thermal_get_temp(struct thermal_zone_device *tz, int *te= mp) { - struct airoha_thermal_priv *priv =3D thermal_zone_device_priv(tz); - int sensor_idx; + struct airoha_thermal_zone *zone =3D thermal_zone_device_priv(tz); + struct airoha_thermal_priv *priv =3D zone->priv; + int sensor_idx =3D zone->sensor; int delta_diode, delta_gain; int coeff, slope, offset; int tries =3D AIROHA_THERMAL_MUX_TRIES; @@ -649,9 +660,6 @@ static int an7583_thermal_get_temp(struct thermal_zone_= device *tz, int *temp) =20 int diode_zero, diode_d0, diode_d1; =20 - /* Always read sensor AN7583_BGP_TEMP_SENSOR */ - sensor_idx =3D AN7583_BGP_TEMP_SENSOR; - coeff =3D an7583_thermal_coeff[sensor_idx]; slope =3D an7583_thermal_slope[sensor_idx]; offset =3D an7583_thermal_offset[sensor_idx]; @@ -715,7 +723,7 @@ static int airoha_thermal_probe(struct platform_device = *pdev) const struct airoha_thermal_soc_data *soc_data; struct airoha_thermal_priv *priv; struct device *dev =3D &pdev->dev; - int ret; + int ret, i; =20 soc_data =3D device_get_match_data(dev); =20 @@ -737,11 +745,31 @@ static int airoha_thermal_probe(struct platform_devic= e *pdev) return ret; =20 /* register of thermal sensor and get info from DT */ - priv->tz =3D devm_thermal_of_zone_register(dev, 0, priv, - soc_data->thdev_ops); - if (IS_ERR(priv->tz)) { - dev_err(dev, "register thermal zone sensor failed\n"); - return PTR_ERR(priv->tz); + for (i =3D 0; i < soc_data->num_sensors; i++) { + struct airoha_thermal_zone *zone; + struct thermal_zone_device *tz; + + zone =3D devm_kzalloc(dev, sizeof(*zone), GFP_KERNEL); + if (!zone) + return -ENOMEM; + + zone->priv =3D priv; + zone->sensor =3D soc_data->sensors ? soc_data->sensors[i] : + AIROHA_THERMAL_NO_MUX_SENSOR; + + tz =3D devm_thermal_of_zone_register(dev, i, zone, + soc_data->thdev_ops); + if (IS_ERR(tz)) { + /* A DT may describe fewer zones than sensors */ + if (i && PTR_ERR(tz) =3D=3D -ENODEV) + continue; + + dev_err(dev, "register thermal zone %d failed\n", i); + return PTR_ERR(tz); + } + + if (!i) + priv->tz =3D tz; } =20 platform_set_drvdata(pdev, priv); @@ -749,7 +777,15 @@ static int airoha_thermal_probe(struct platform_device= *pdev) return soc_data->post_probe ? soc_data->post_probe(pdev) : 0; } =20 +/* Zone order; the bandgap sensor stays zone 0 */ +static const int an7583_zone_sensors[AN7583_NUM_SENSOR] =3D { + AN7583_BGP_TEMP_SENSOR, + AN7583_GBE_TEMP_SENSOR, + AN7583_CPU_TEMP_SENSOR, +}; + static const struct airoha_thermal_soc_data en7581_data =3D { + .num_sensors =3D 1, .pllrg_protect =3D EN7581_SCU_THERMAL_PROTECT_KEY, .thdev_ops =3D &en7581_thdev_ops, .probe =3D &en7581_thermal_probe, @@ -757,6 +793,8 @@ static const struct airoha_thermal_soc_data en7581_data= =3D { }; =20 static const struct airoha_thermal_soc_data an7583_data =3D { + .sensors =3D an7583_zone_sensors, + .num_sensors =3D AN7583_NUM_SENSOR, .pllrg_protect =3D AN7583_SCU_THERMAL_PROTECT_KEY, .thdev_ops =3D &an7583_tz_ops, .probe =3D &an7583_thermal_probe, --=20 2.55.0