From nobody Fri Sep 25 11:05:14 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 84F193EB819 for ; Sun, 13 Sep 2026 12:52:59 +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=1789303981; cv=none; b=nP8fA8FJrMS5YWx+HHJDlIeYKSw6bT3NHOPszCB8AEyEkyra6r5yl5ESbCGbyqgyACB69F2uacJwI/g30s6hjxLmhUqGGRq8+xDQTLZKnv4KSVAx+aWhIX/cXcPpeMcDmrjALGzNce2hZk2alSZCHLvz3/gzTAM1z8Ir9OtsCc8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789303981; c=relaxed/simple; bh=qwRW5YP/OsxI03pqmCcnKn2ESNhEIHF0NnfugvT2Rec=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SPKnullwO1+bXt8ZXdb3eUhZn3+lZO+qEd6ynDong6M05Np97l2GWbtb4cx4Cs/jddosTMyZHmlZlurTBZRamLnJibZ3aJS20t4op7KPikVwqv4O2V3ploQn4N890fxHi1uGA7r7dxwCBEvlHC5mZIZ0U3ryBlj90/qQoo8MsYk= 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=LUDsGS5N; 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="LUDsGS5N" Received: by mail-lf2-f12.google.com with SMTP id 2adb3069b0e04-5b5e4f16f16so1363670e87.0 for ; Sun, 13 Sep 2026 05:52:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789303977; x=1789908777; 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=LUDsGS5N3P5+jgUabSqC4MAmSG4JN9jMk2LeMPwAYvkDOUrPFNsgtRFwKOUTswHTTv QU18CJ8xfEs4GoaihrflAWKUh2xwbxk+wJlxrdLBpbSdIO1lqVnIFGttvHZbSXWD6nKG WOh42QWCIgUikzXX+Erm385/7m2AUNx3ED4j+vdMBO/T8KxevlB7AZQqIq6TQvx1zNXs ettfrt0RzxHJKxdS910GrE2HNSjQ2jBiN6ajLs99gclNjAz9qwSxjiQ9ZDapBIdMX7ww JuzLB6+S/5Xdrbw5NPo1ZwlRon2cDzJsd/dCwtHT/d1wEGXEJNauK7VnmUV6q9dWZzKm X9WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789303977; x=1789908777; 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=ENTjZTOiSuMUwJyCP8l0cqP4lbb/qyt1KShzRB3F0fMxhkR4VXj1DNlC5pzyHHNkd9 9x1UQ8NfjEISDhtPNcVfDvRTgI1eHc7OMTcjbx7DE32JQ2rH4EtM+sHBEPxPm2O92L5M n0hXaURudJSX1GDDvxTNHg6q5OSH7nKhcrGu5RSBMraR4joPkfH2N0966ibKP6c3E1iT CNv03m5xEJ4JMQ/E1EXzQxoWw0fvbnT/bDv57bN49srpDIQpZUBUYElltIgVBBZj+HI6 awVicnPZu05YJl23FHBF/haowDzd0W+Ya237xjFaY3lVIicvuMncz2qhqVs+0S+lHIUG OmSg== X-Forwarded-Encrypted: i=1; AKwUvBzNInWyPtR2bfDh2UMMcf7ke1oeHR2ZYijRDrQqgQ4ccPcVGqZdTx5FfY6+zFYr6fXqb+dygW3g6MQWUR0=@vger.kernel.org X-Gm-Message-State: AFuF++kNOhBWNdjsD2uviCc6H5qxEHd6KVvQvN17YdDhm2Nc8hChOWft wMi/eglxS8mrVx3cVX0C+UWeBYD8+hKQT5fDpKepShsZCLJ87Gu9eCQ= X-Gm-Gg: AYBFou2AhGeD3MnD+ubxpv1DY5gmRLaFhwIeMCegewiIcr9Y1ebJdLZ76Q41Bkk+Ff9 4mkGTYrG1oYCs3vQh8ZsjUIcABtzR2IVIOeyvIJsptuT7CtHHkwU7qUN0I03MgT/qc+hgL8IcsT RWtleF1wBd0ecFQRftxHTa3z1GbRQCj5jENg0Ruasc+yMJRgYrUWUJ1I3YSz63msc/GlCfDETC4 POk7uvRvscFwG2x62L+3UA7jSnbXpiHatSMlzSnDR9DEDZ2SoTOyy7YYP9CYbA7MyRwbDiOBg/7 AagW8XiMjUU+mcClEEv9kmnkfrVneoWCjtRqsLcQnELOCDXnpn7MrNNYpx6Z4oBuyE12APkLW2O anKrJ0afjkE8ecnX7aGEQrGTN7egdHv09Jf6L6dZttw5rdXwkwJwHJU9RtqAxTMFDlE+0ep2qYw rq2r3ACqS49NKr2WGiJO3eUku9eifgSpQkJqUvLGWSEqAY3id568dgzjm76P0AxVkUog3eAdKg X-Received: by 2002:a05:6512:39c5:b0:5b8:99a2:9f2d with SMTP id 2adb3069b0e04-5b8a0325821mr4604271e87.17.1789303977336; Sun, 13 Sep 2026 05:52:57 -0700 (PDT) Received: from fedora ([46.8.219.5]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b8a0469a8esm1762844e87.50.2026.09.13.05.52.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2026 05:52:57 -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 1/4] thermal/drivers/airoha: Fix AN7583 ADC mux field mapping Date: Sun, 13 Sep 2026 15:52:23 +0100 Message-ID: <20260913145226.34643-2-sochnev.v.74@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260913145226.34643-1-sochnev.v.74@gmail.com> References: <20260913145226.34643-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 11:05:14 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 B7E363ED132 for ; Sun, 13 Sep 2026 12:53:00 +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=1789303982; cv=none; b=V12OeNqtUF99XlrYEKkJXNAciWsKkC4vOzai+Iq7ge9Bzvc/PgHS5iF/CK8Tc31omE+E6ZjMEvCZSm2uMAuej4fUxQfBJmBTQSRRWbLr30GujWi/q82vCTrC5b+o4tFHadqymctO+6/GT2fCSlRFGQaOLMzr6uhfkpsxpAluPYs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789303982; c=relaxed/simple; bh=2r0CGwnbhw+4LMmv7iYh/YHAix4sdwnKIMTStdJVtsM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A3Bu1wc7Nq9Saf7YRurxKHyxFD31lsHH+bX+c4g8DyURDjEluejkOq40EJJFOunYMfCHBtoX2FjAiwWUgLBwGm1QJYqRvTfPeslIgBLHYKN8V9p2nZQ9OV6Q4M0sTGJharAL+8pSmv1AP6MgCKPxS45aq95DGf9RO5c/M2ARX5k= 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=Cjy+BW8r; 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="Cjy+BW8r" Received: by mail-lf2-f12.google.com with SMTP id 2adb3069b0e04-5b79784a6edso1103452e87.1 for ; Sun, 13 Sep 2026 05:53:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789303979; x=1789908779; 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=Cjy+BW8r1bhyo3sHyI9aWSnH9GwoFinNgx6O1kWLt6Ozrfgewm+vbhlR8bnGvEQhs4 oicZHm1Bh7TNOl1JVAYGb0lqmGyEQWWwYj7AJRqiLQFw0XmmktRBoCqlJUtK/2y/CnDT ThSuQ/BCF5Ao2kP+6TyeHDXzlDcciVZjHeuCcfbeLoih+p5K62XGC58z/+0Wk5Ij4A3I sHPKJbBPC+r8CRlRKUp+4YttX7xah6VCBMr7WxJsGqxZL4sys89aDk/usVUjWBP13O4T R6/S0PEq3r3QTmObB5Kt26YEv+OZfvyj3RjrpHjOH8Lgqg8MiaYycAVWg5A2NRBFplce OPig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789303979; x=1789908779; 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=RnPrBQqRvcBio5SF8atqyS6LPEwZfY851/3fuccht/MlIMLtsNCtWrLrhoHDtfVF65 2NJGG9MRlGLpi1UAzNCdNh1LTZA6IhosnHCPYYLlinMEN7hSljoJUr/LgQwfGyTU56gW B44+tdz2e7AdTJDQ4cOSZ0MCAI59pyai54fiNdPOa2VRCYeXJtXT+EnzRVt/xY1/SE60 DCfb4A1aTBvcLfnfl1UkzYLo5KZNIo9QKaqQORW2k6H5gvEl4d48DfxDERX76sOnv6Nn mzLkAlI9iN0LNtZUsEDqEK+/nlA2Fd6SXjvdMtG+UQKdzK9/ifPfvaN+eeU/Dtb8Tv1c dDcw== X-Forwarded-Encrypted: i=1; AKwUvBxs+3EjHOdDQAQ8MuQbZ7UaNIxkWMzBN153i5bS0AVu4twNMLycXqxyP+XoWL5DqOrF//wFZhV0PQGUjVA=@vger.kernel.org X-Gm-Message-State: AFuF++m7cwQbSzOGtjJqg7SRC5XpYFSrva9CmDMqbdv2Z2IE6MCuYn3b GpWu7x4p7dP49M74iVjg5Udxrh1nCphKUg0zgAFFYO1SMb9UxkGT4DY= X-Gm-Gg: AYBFou31FrR1UF6zDaNSg6p8/+CooNuSFGVhDoGSJm90k7kWaQBHdTGEDrM3GKfHm1h rxx7MeR4W9Cr6e8+pk6vHEgFkEsFzNDcCZAVChzbh986Nrk0tP3YkeauAQbybo4383RM/ZiryXw BlhUfU27nKSL4Z58jKw23uggsH9CCsFLJmaaca59cnEuxDzOUyP0oi3B7ECDkQZwtDXrD+AXV9F /hUKutRan3G2Xq1gX9S+ou9dEvRAzrMDgV0mJY/5o2FMqf/ieRRozj4Sgt6Fu7Zpy5rGJel+ps6 k18jxE8Upjwwh6al/Hc/wu7gQc1DUU2cXzLaHMU/74X+AXhx2L/84g5PvSiTQLtGkpEiS+VALS6 UK69HD/OaEEmxTE9z5/tyZMuBEcRlf3jmUFu7q8sy62Y4oJcOpsfK//Fw2xeTxL157MVfaTdfjH zZgMPaAY62kNEOeqjHOq3sn7zdEcrh/32rXETBUBl3G96HuJP/bldCGRSsEtC/7vI= X-Received: by 2002:a05:6512:224e:b0:5b6:1870:268b with SMTP id 2adb3069b0e04-5b8a8eff12bmr1319989e87.60.1789303978537; Sun, 13 Sep 2026 05:52:58 -0700 (PDT) Received: from fedora ([46.8.219.5]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b8a0469a8esm1762844e87.50.2026.09.13.05.52.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2026 05:52:58 -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 2/4] thermal/drivers/airoha: Serialise access to the shared ADC Date: Sun, 13 Sep 2026 15:52:24 +0100 Message-ID: <20260913145226.34643-3-sochnev.v.74@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260913145226.34643-1-sochnev.v.74@gmail.com> References: <20260913145226.34643-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 11:05:14 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 BB3353EDAA0 for ; Sun, 13 Sep 2026 12:53:01 +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=1789303983; cv=none; b=Au4Ck6DRwISV//PuSwIA8eIlBAcJuAD/z1gReplMkHFdeCUe2juXUJaebtbeyvSLGm//kD7/jNmqEi2C8D/mNVdGfoq8yogygVvx0riqjTq7ykdnnWVcusJTfQNoMFkbexCik67EGlS45EjNbIeBjVy7LIFLfyu7fLCql8iqjy4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789303983; c=relaxed/simple; bh=uqSZ9vaYLLr+IlpI+wNqRUJ19lOtB5XlEKHqPxDiWeM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JI+d9S5MwH6ETwY5CMRFff2xci/Ef9QyqSWitGwxECUa0uP08pFQN+x7kT+u/Uu6yjgndNUznE67xRZTIimHAJwQCKALRZ1lQl5BOf6kM5ejE2oS7WJZ+FwtUH+tNNhCg2bjK9saSsHGX+fWOCn47RsNTHV+4Mt9jMA66/rrlhA= 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=ouJNpdD8; 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="ouJNpdD8" Received: by mail-lf2-f12.google.com with SMTP id 2adb3069b0e04-5b5e4f16f16so1363679e87.0 for ; Sun, 13 Sep 2026 05:53:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789303980; x=1789908780; 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=pjCp7DsLa8JOzDd9QVc9nOTCPNziCux3eLTHVXVPDfY=; b=ouJNpdD8I11bkZFl2GYdEx2p1znfZF4lskK/OyWMEuhnduVqnlbqU32osjRApFaCBh Dy6/n3g91MXmVXfbECEf6anBgHIhvBKzoi/jtg4L+eCp1QCK/OYqlMPRLjhlmf+BCDws K3KavWc9QzikLiXxEIX2oJCTKQ4gCAZ3Dd8zrO1hoZeugtU3yhuWKSi4mSIn/Hkx721+ 9zg2/2csPEFsSk0zCHPVUTQ6kN8coWxkMJb/tq7rFiQaVLCcphjCv63JIjBLFx/tplnh B59Kl6rr6G3BGil6YedOs/OR/1fPNeX64nEyqLCauJ6y1JMViN/dbqjz58o4WG/bg2RU iGyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789303980; x=1789908780; 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=pjCp7DsLa8JOzDd9QVc9nOTCPNziCux3eLTHVXVPDfY=; b=NyshrFyM/LZy64HwPzP2uh35d4Y2Wp8rorJ2OA07uAf0f5Dto6UdqfGl07Yv9K35AC AHJHjlsWYF+PfrYFQAhG7VhT50YcAk7CB6H/uwDFdqmLDXu02mQR2AgsW23ePaamjrwb C1L3o5UQkD1giGGcYfLL4JhMa2bbWFOdeVaZ6vYcFtTeIripjCoXSIEJkB7yBRc2jTuI uA/THEP43g3LufUbJJ90g845YXsgsinZ1AHeYmqScGFbY+a21ODNgsYgXhHtcQMWzatI lVUQ4SixXwPt0A7PaeN6scHwLztBsqUk8nizzxzFHe5BftKXJVqx99ntoOVp8Uk7vOeV A9/A== X-Forwarded-Encrypted: i=1; AKwUvBwB24tUXWEDILUnL/W0vOrLglZ435Xmn31r3nF3IyyuZkECmX9fjRmGuJT+wMfrEzxaG4w0EdWS0gzMe4Q=@vger.kernel.org X-Gm-Message-State: AFuF++mqe8x43Ipoqhi1JqyEICyob8yBGjmIDNhyJiYuq/ibLrDHzqX3 lcjG+ei71n1LwMcy5V6Ye3if5PfLq7RwmtuqYH8TGCRUnXrWPHtcp1U= X-Gm-Gg: AYBFou0EXOjJ2Q8HnjodQvFaiGh4J6aWbidya3nP+6/Tm8x472P1WFIAWZa6d/jbN4T 6KrkD5Pz3UQASax4Orwhf5fkSbYV1SMeaM84ZICkWvn2fIZrUMUaM42sRjveyxpF7w9qTKvRYCy BKFgq8cbihL/WP5JoDZqK2zVoTV+1LTfMg93S6Md/XxVn9i1TnU+m2QZtAPQ9ZC5aWgKGsk51fT jx94qr6+XQMvCOPpFRNwYFD2gXrgoVxSbHXEyaC1l2i8Zbw9fgfVFkViIbK7+yTilxWP2Ac7132 ILr8fN4KP1n+zD8AccVyGlJ6A5C91qAeUghJFJ2viMdaf8ODnUPXdHarnQm0KYSysEOzeO8m5p7 6yjIpuNUx9SlnKys8ImG3rlRrUlyDw6hJGKL/oUmgfGI01JHwmIc3pQVOgkYGRSzVXQ5AN3tcxB ytEiZARX7U8jTtTUZWp7HvdjhReUpIITjvT8It/7aGx3PQrl+Bp0GlcXc9zyKmWlJjYm8eg65E X-Received: by 2002:a05:6512:2344:b0:5b4:ab2f:5bd5 with SMTP id 2adb3069b0e04-5b8a02fa1e4mr5509677e87.8.1789303979805; Sun, 13 Sep 2026 05:52:59 -0700 (PDT) Received: from fedora ([46.8.219.5]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b8a0469a8esm1762844e87.50.2026.09.13.05.52.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2026 05:52:59 -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 3/4] dt-bindings: arm: airoha: Allow one thermal sensor cell for AN7583 Date: Sun, 13 Sep 2026 15:52:25 +0100 Message-ID: <20260913145226.34643-4-sochnev.v.74@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260913145226.34643-1-sochnev.v.74@gmail.com> References: <20260913145226.34643-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. Allow one cell to select the sensor. Zero cells stay valid and refer to the bandgap sensor. Signed-off-by: Vitaliy Sochnev --- .../devicetree/bindings/arm/airoha,en7581-chip-scu.yaml | 5 ++++- 1 file changed, 4 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..da159b7572f3 100644 --- a/Documentation/devicetree/bindings/arm/airoha,en7581-chip-scu.yaml +++ b/Documentation/devicetree/bindings/arm/airoha,en7581-chip-scu.yaml @@ -26,7 +26,10 @@ properties: maxItems: 1 =20 '#thermal-sensor-cells': - const: 0 + description: + 0 refers to the bandgap sensor. 1 selects the sensor with one cell, + 0 bandgap, 1 GbE, 2 CPU. + enum: [0, 1] =20 required: - compatible --=20 2.55.0 From nobody Fri Sep 25 11:05:14 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 DDA913EFFD2 for ; Sun, 13 Sep 2026 12:53:02 +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=1789303985; cv=none; b=UKoHGBXbiMelR1mZdUl5t9ppxLG1iC31UQ/aNoyIF4yFfmeir7iK1YDcQYk+pNb+XAY+7FQaKUSpaGKfrzog9WUrkoom9HapUroba/BQg95QDs88QGWGwkMlTN6xldHtTU4d18v42VXRReuv5KkRYht7uA4oBQtjHsf8gzjIB0E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789303985; c=relaxed/simple; bh=2jdLhS0f6LGPinV6mDXuEBf99CtvYJn2mzTEPg7/Skk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ei71N2IsrRpJhOE35lx+qB50qbhKkXT3SP0IzRsFzzR4rWv+iNrnnyCVeIXKmA0l30tyBOg6dwryE7WwLLJXI6kFUE4DuddU2u/QY6speLAH7W7Xxi9hY4BSEIu3k2QYyST8O+7CLyjbFLX4Ja61vaooRkcckG42HLeTrmA7v3w= 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=OTyL2irv; 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="OTyL2irv" Received: by mail-lf2-f12.google.com with SMTP id 2adb3069b0e04-5b5e4f15b7aso1460248e87.3 for ; Sun, 13 Sep 2026 05:53:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789303981; x=1789908781; 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=vuRUfdHSYsUBwVaQaiL7xtjOAdBqEJ7KfcBMX3K0Kbc=; b=OTyL2irvIUNbrNFKY8UWKInl3NNL/zVAaV2RPb0GvKG6tMoeOjbND7YQo/CXaBDFCb 5cnNE45R5PtRX6hKPNO5s+aYd4WRCNqgaag8M7xLggaFYGAgjScoEMppzMwpwcFuEEWe NOQwd2l6t6yHrNTAfjLx928uduiBMc9SV6gS80a03ST7u+XI0AITqhh1YF8GPPcuJytP gWth0iNvlVzmvcpojDK2jzzgmde6DFyEqMH2o8XJrL+NmpMUvaRmWPTuz0ZUM9Xpy9JO gUhURWjWAaEhhFrPjGvXm85GktDVf4J6YlQ97H7GVmlQeNy48HF4pNwaNMJh0ECtBu+z M7Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789303981; x=1789908781; 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=vuRUfdHSYsUBwVaQaiL7xtjOAdBqEJ7KfcBMX3K0Kbc=; b=q2zlQiNAD19EZpuhKx/xqNagUT+nNCIy+6UO9eTMah9N+ZxuldtTsPUAaiqud+pkXN Oxc+fR+BsbVIMYAOSrq3XoqSBPxq271iFBWWp5nb6xGriebwXJweh6iXQE1sv2LQpO28 iEWH7IikXUDeYV5JED4uuqnHBvLeTA09pbHJCZKMZpqyZTWZBAVCh6h1HqeKOWpT3Ayv xsvZJ7qiquuld/OINGxq230yfqgeNYcV9kmVnacXv/8c7XklZ2htyFd0Qz9Ql0mMSIj6 FNEQOz/nxiuNup62VRWcJNaTUpcA1CWzoA/95dVoLGIQjfCyim1r68wU/vXi2h23zQzr Au2A== X-Forwarded-Encrypted: i=1; AKwUvBwuQHAI/eu6eJEw99kjEpMOEGDXGOHDFO+Xth2Nr32yNSkx2wLCQqVnGUarthAhxGRaA7O2PiOGp7OtX7Y=@vger.kernel.org X-Gm-Message-State: AFuF++nE3k3YGvaKZgw/AmCI/h1BhjdzfbbdgmLmqABCstMucTyOYfHB YHmWHO7IcY4I47QmvDN2LUzWQAvln8xWBKmqFxHEK9pJHEMoeDyPmmc= X-Gm-Gg: AYBFou0FBfvO5ZjRCZng5jftAPC8yVFg/V+qWvZIhkGOb9G/Bp8ORkhxh4Hz4haKXHd Zkf35ybEJP5Nr/b8TcrJ3LbHYG2NC+S3n1ZoRXbnMAylnv6PSpNI1cwRE1Gb5ZxFs2fWIFVZvz1 BM/7OTO/AsR0n8xVZxfXrNE5K4j4X5H5fYbjn0W5JAH4Iq4EX78hDQYJy1ptWxbYjlIcUR8pLcp AL9Yfe4LsnIaomkNfJoz7/rFRGLPLYKONtg28+YvFIIERB2q+qGJJ47TDDWSX7GuozWr9Fx7CQW 6nkgWfxjJ8XOuWsVE3/7hedTzkzeLpf4lz+ubTUrpr3rfaOy0viWzKyB9+z7vfcxUWMZULQksq8 xjbgdjMptKjz2SaFDa85xiwfm3XuefrBaBfv2tqAre4Z5vXirumfLG9oe/yC8W8GwhzbWorO6nb t372wm9nCAJDtgJMIuFTzZ5U2yT8ZJ4LQHVXARCHBquL4jtCHTAtgyo/OjPEH2KA== X-Received: by 2002:a05:6512:1111:b0:5b0:1e16:e60c with SMTP id 2adb3069b0e04-5b8a0328740mr5196128e87.25.1789303980770; Sun, 13 Sep 2026 05:53:00 -0700 (PDT) Received: from fedora ([46.8.219.5]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b8a0469a8esm1762844e87.50.2026.09.13.05.52.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2026 05:53:00 -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 4/4] thermal/drivers/airoha: Register a thermal zone per AN7583 sensor Date: Sun, 13 Sep 2026 15:52:26 +0100 Message-ID: <20260913145226.34643-5-sochnev.v.74@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260913145226.34643-1-sochnev.v.74@gmail.com> References: <20260913145226.34643-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. With one thermal sensor cell the cell selects the sensor. Device trees without cells describe only zone 0 and keep reading the bandgap sensor. 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