From nobody Mon Feb 9 12:24:58 2026 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (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 4ABED341653; Thu, 16 Oct 2025 14:22:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760624571; cv=none; b=uQWBy2XyWwZdNPWC+mbET4VMYL93qVKg4n1X10bDWmJvZDRC6o8iA9QtfPHdIn6a55opYON24NQtx8yChTHO/uLmECFmpqiWvjyPgMPO5h2X6I7x+YOKyON6G777JK4VlLmbXGjQ2WvQIJU5IBvSoeXtNjUoBI/wjTBoD4T0x6o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760624571; c=relaxed/simple; bh=HJgqsUhPqd5O/gXRMV+eNJx1cOPKuak3AdTmCh0UBNk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NFayYTlfINJYKaYkYR+YYrgcsDCGzqMP9KxM5vaXzzeLxaxbd9xSvKpXpBX/NjjewUbEahzmBBRaBy07sALL86Jq4MR5EseMPX+7IdwSdCnjxIS238vR5+tzcSrbTr8ukWhFmt/QRvR/ZP9d8KD/Fk1oaXtuxM1HCpRtoCoMFuA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=XfsubArn; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="XfsubArn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1760624567; bh=HJgqsUhPqd5O/gXRMV+eNJx1cOPKuak3AdTmCh0UBNk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XfsubArnyRiHivfenQ7w8x/ypaLvbCN705lmoU+o5pNioWXx9qaf0bKn55Ht+Vq0n U/n4pTujAPE2vyJT5mN7Lev1aIq/wTU/itvAhdAuj+xcBeJ017fq/Dc5L/KoDJL7B+ ijwwaVc8jAC/jthRBtbZtilF24AP7DxfKTlem2vPWclDX80x8/8t93f2k2LHLlqw5G vtt4e8lkJjrYLuzlkDT6CIH07Dx6AIZ0dFhzxsLXOVS/Sn5F6jmU0aMdA89irxi+Ch E053TQs8166kaXHXm2AtsqH+vWxc0yIADc0nqSqr3235cYQmNBSmhuEe2AGbReQEPc 2/iu/gI3U1iew== Received: from laura.lan (unknown [IPv6:2001:b07:646b:e2:655a:5eaa:d2ad:4ee4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: laura.nao) by bali.collaboradmins.com (Postfix) with ESMTPSA id 6CFED17E14FF; Thu, 16 Oct 2025 16:22:46 +0200 (CEST) From: Laura Nao To: srini@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, rafael@kernel.org, daniel.lezcano@linaro.org, rui.zhang@intel.com, lukasz.luba@arm.com, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com Cc: nfraprado@collabora.com, arnd@arndb.de, colin.i.king@gmail.com, u.kleine-koenig@baylibre.com, andrew-ct.chen@mediatek.com, lala.lin@mediatek.com, bchihi@baylibre.com, frank-w@public-files.de, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, kernel@collabora.com, Laura Nao , Chen-Yu Tsai , Fei Shao Subject: [PATCH RESEND v3 5/9] thermal/drivers/mediatek/lvts: Add lvts_temp_to_raw variant Date: Thu, 16 Oct 2025 16:21:54 +0200 Message-Id: <20251016142158.740242-6-laura.nao@collabora.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251016142158.740242-1-laura.nao@collabora.com> References: <20251016142158.740242-1-laura.nao@collabora.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" MT8196/MT6991 require a different version of lvts_temp_to_raw(), specifically the multiplicative inverse of the existing implementation. Introduce a variant of the function with inverted calculation logic to match this requirement. This ensures accurate raw value generation for temperature thresholds, avoiding spurious thermal interrupts or unintended hardware resets on MT8196/MT6991. Reviewed-by: Chen-Yu Tsai Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Fei Shao Tested-by: AngeloGioacchino Del Regno Signed-off-by: Laura Nao --- drivers/thermal/mediatek/lvts_thermal.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/medi= atek/lvts_thermal.c index df1c0f059ad0..31796a5b8858 100644 --- a/drivers/thermal/mediatek/lvts_thermal.c +++ b/drivers/thermal/mediatek/lvts_thermal.c @@ -300,6 +300,18 @@ static u32 lvts_temp_to_raw(int temperature, int temp_= factor) return div_s64(raw_temp, -temp_factor); } =20 +static u32 lvts_temp_to_raw_v2(int temperature, int temp_factor) +{ + u32 raw_temp; + + if (temp_factor =3D=3D 0) + return temperature; + + raw_temp =3D temperature - golden_temp_offset; + + return div_s64((s64)temp_factor << 14, raw_temp); +} + static int lvts_get_temp(struct thermal_zone_device *tz, int *temp) { struct lvts_sensor *lvts_sensor =3D thermal_zone_device_priv(tz); --=20 2.39.5