From nobody Sun Oct 5 14:33:03 2025 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 92CDD26FD9F; Mon, 4 Aug 2025 13:32:46 +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=1754314369; cv=none; b=mzLB8tOl62ZDGMj9yj4ht3HSoD8U8kSln3rC1+ll/hmJwiODdlyITefowDbxU7Jti5GgGzAsynxioayG6fOKmO6HIAJ6T2CoAgB1G9BHRPnsa/gah8IWn0k8i4R9I1BNHt7vV4z12g6yg5pFIYrKYBTLp0Oghb6XBLQ2usyz7U4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754314369; c=relaxed/simple; bh=p8TNqT/5VVY0x4ZX9U/Edo2dC4tTH5VL+JaK2ksQlv4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=u5EjSL37eEkX+v3B3E9+luQm5Pe2lz0APu78RtOXRvTa5XVjuGwtqcUCJPxuPZyiAqlUjHVV08NI2XSz4uS3aXiBo69Qid/MVT6DeI/d4I1s7Te1CfE6KWY2Ug7zWGmC6TSuNoJJkcEPL1TV2uAVy+pSk7e8CuIp40binNajGd0= 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=IAyB20mF; 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="IAyB20mF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1754314364; bh=p8TNqT/5VVY0x4ZX9U/Edo2dC4tTH5VL+JaK2ksQlv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IAyB20mFKP98JZzTsGAMRSvNOE22Kp81k8/xPcNbRYq2C4i14IelZn/6BBbCnxxpP QjqfD1A52AdrTAYFMswHe7aPfG0MkfSXA+26K7tY45mUYV7YNGSuRdTT0auUg6s8GA SEAQKjFPF+hxNcNFSEdR1JG49ipPpRVQ2BzrEUm938wm5EEotzTuPhtduP8gM/xiKH wD40UVMe4mhj/l+H337zPkXFTTdy/En9iNzrotkX1g+a4z3xaGWFy0xiQEVYHKH5v1 0YMyeujLL9XsnPP9CTy/GwYrmhn9zULywbMjvNMfuboOluPB0mupYvJrRz+Uhwp9Mx Ep5yx0vptsbiQ== Received: from laura.lan (unknown [IPv6:2001:b07:646b:e2:865e:547d:4830:837d]) (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 6460E17E09F0; Mon, 4 Aug 2025 15:32:43 +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 v3 5/9] thermal/drivers/mediatek/lvts: Add lvts_temp_to_raw variant Date: Mon, 4 Aug 2025 15:30:31 +0200 Message-Id: <20250804133035.309990-6-laura.nao@collabora.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250804133035.309990-1-laura.nao@collabora.com> References: <20250804133035.309990-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 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 47124d33ca2e..e29664f1316a 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