From patchwork Fri Nov 22 10:10:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 2014259 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=gm1 header.b=YyrMqLmE; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=139.178.88.99; helo=sv.mirrors.kernel.org; envelope-from=linux-rtc+bounces-2602-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [139.178.88.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XvrV5532Gz1yRg for ; Fri, 22 Nov 2024 21:11:25 +1100 (AEDT) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5C533286852 for ; Fri, 22 Nov 2024 10:11:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C4F221DE4EB; Fri, 22 Nov 2024 10:10:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="YyrMqLmE" X-Original-To: linux-rtc@vger.kernel.org Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (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 6AF391CB9EB; Fri, 22 Nov 2024 10:10:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732270238; cv=none; b=oByNy8cGCSMLuAI8uRbHoLhfcUHLeOOZC8kpXJSFrdV1bK9c09DK+sAGWP4KAIBtp323Ejpqn8ktc16CCYsn2ZMselayrvkE6BI4u2zpJx3bnO0cbsnPIgYZW0LlZBBCuGLsrO4gf5tgFpTB5+D2MPetCtDpGemi7hQWtp/mq7A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732270238; c=relaxed/simple; bh=w64BTwN0IrG1ifZ6kdDwL98cvqCpeA47a/fO6Piqzcc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fhZqd2nCPw7RXMXKuHvfbAJIWH9jHnUlO7tOqW5OXp4EPdn8cowApH304nfrEh+4nl1MzVSbRYVn7riRqW59vMhNmcHPHYjtPB0Seyr+Tp4iOYZBOKGWUoIhljvtVURRm0BORzzeTOnJ5ePRe0lPxMOd8aiOAibQYDyBNtzfTew= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=YyrMqLmE; arc=none smtp.client-ip=217.70.183.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 374E6FF80A; Fri, 22 Nov 2024 10:10:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732270234; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RzlNoZCMziwO+aezX23MTGPRq52iT+GwfwYT6iu22Dg=; b=YyrMqLmEiDglLc/Uox2yq8Mx8K5FMoRcksaNXzP7sgVrk3BDUu5tzmtbwYEWCBtMwcb4eQ /IhPkeZuryDMjNzrExksj1Mx1iuOtkxGIOT6yKoLgxeU/19viguSEZ0nczFUT1gzh5E5is qPPGHj//51CrcgS8A/p9kxUHayiNQIWsluO/AB1vrxIIpYtOO8rcc79fs17gRpKXLbgaJw b5Rudn/omLBXwyVGEoA97dFcE6AKrDxGwjBnonnfPTz9Qa66l1nWPba8T8RENRxGHnfyQk /oQZ3evDGNx20yGPESuplPamG2i9VqCx/ZenUcRIXOV8MRpYzS0kUTBROetiSQ== From: Maxime Chevallier To: Alexandre Belloni , Artem Panfilov Cc: Maxime Chevallier , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Alexis_L?= =?utf-8?q?othor=C3=A9?= , thomas.petazzoni@bootlin.com Subject: [PATCH 1/2] rtc: ab-eoz9: check the lowest voltage threshold first Date: Fri, 22 Nov 2024 11:10:29 +0100 Message-ID: <20241122101031.68916-2-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241122101031.68916-1-maxime.chevallier@bootlin.com> References: <20241122101031.68916-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-rtc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: maxime.chevallier@bootlin.com When checking the internal status flags for time validity, 2 different voltage thresholds are verified : VLOW1 is at 2.1V and indicates that temperature monitoring isn't possible at that voltage. This stops any temperature compensation and can cause time deviations VLOW2 is at 1.3V, below that voltage no timekeeping is possible. In both cases, we consider the reported time to be unreliable and print a warning. The current code checks for VLOW1 undervoltage first, but as it is higher than VLOW2 it will always trigger before the VLOW2 threshold is hit. Make sure we first check the VLOW2 condition when checking time validity. Fixes: 67075b63cce2 ("rtc: add AB-RTCMC-32.768kHz-EOZ9 RTC support") Signed-off-by: Maxime Chevallier --- drivers/rtc/rtc-ab-eoz9.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/rtc/rtc-ab-eoz9.c b/drivers/rtc/rtc-ab-eoz9.c index 02f7d0711287..85853da258d2 100644 --- a/drivers/rtc/rtc-ab-eoz9.c +++ b/drivers/rtc/rtc-ab-eoz9.c @@ -116,15 +116,15 @@ static int abeoz9_check_validity(struct device *dev) return -EINVAL; } - if (val & ABEOZ9_REG_CTRL_STATUS_V1F) { + if (val & ABEOZ9_REG_CTRL_STATUS_V2F) { dev_warn(dev, - "voltage drops below VLOW1 threshold, date is invalid\n"); + "voltage drops below VLOW2 threshold, date is invalid\n"); return -EINVAL; } - if ((val & ABEOZ9_REG_CTRL_STATUS_V2F)) { + if ((val & ABEOZ9_REG_CTRL_STATUS_V1F)) { dev_warn(dev, - "voltage drops below VLOW2 threshold, date is invalid\n"); + "voltage drops below VLOW1 threshold, date is invalid\n"); return -EINVAL; } From patchwork Fri Nov 22 10:10:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 2014260 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=gm1 header.b=YvPCOshk; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.48.161; helo=sy.mirrors.kernel.org; envelope-from=linux-rtc+bounces-2603-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [147.75.48.161]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XvrV701Wtz1yCc for ; Fri, 22 Nov 2024 21:11:26 +1100 (AEDT) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id BE85FB26F4D for ; Fri, 22 Nov 2024 10:11:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F3EC81DE4FB; Fri, 22 Nov 2024 10:10:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="YvPCOshk" X-Original-To: linux-rtc@vger.kernel.org Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (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 F04161DE4CE; Fri, 22 Nov 2024 10:10:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732270238; cv=none; b=vEre2BpeHeu4AqXbQXVHzAQooclTO06VG2jFw+jt3a7ii5B7dQ655IYwZJSdDyf/1SkvlkC0XfquTRsPS6N1XRBpWBRnOIpN6ZQcjRa60/WxTznLnvyaf1tMSpWlPjmHCC/nlRgqc/ZreuJqfRPtTKMv2FuAAGMfywut0y6xht4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732270238; c=relaxed/simple; bh=BFy5SRGzFxcUg9C7k/DpxOdFgMegtRxmNa2Re/g2530=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QxZS8UmmApP4E/k75JGA3Q+3xKzSDpf7xi4MygQa7o6ogCNtD+DaJcD3GkjDAzNbO4CXy1mo6aREdnQ7zfFJ/RSwo3fY/ng3b8b5pYJoIX9aFivs7/NqayQpGn/zSESDiNkidAEitZOGRYEAcmDVKbrEbNx9IAa8UMf7ryeCpQA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=YvPCOshk; arc=none smtp.client-ip=217.70.183.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id B8B4BFF805; Fri, 22 Nov 2024 10:10:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732270235; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Txhc81JR3Ln31TqfibV4BYhT9m2u2q+xnDTcm3jWFd0=; b=YvPCOshkM0KqR19Nq32N9Eksxfysw+o/DMfcY2jVfobV2AIYzpucbpxom8wzvF6ezIK6zl tJJ8xLeCrxRWJBmTyWsCMnsM7fj+pN2rUew2sr+X4QNq2KDM2jKa4QEPw+0zhT9StUozem YWDuSumJnXG6SESXAYFJ6D1p1DrPzC7CXBVy/OAF1YXWruCZjIxqkkCcnT2VRJW7u3S+In PzvHPM8hsUhv20eqFYiKMgsZHwLoo79AsshvB0hvKog2D6Cz4WSww9j5GbJdl61kdU5293 THbz+87rpEcUsieDQ4smLPnSBbNe9i2SHtF/4yGaKrqWAPgT/spsJqlvgoO9mA== From: Maxime Chevallier To: Alexandre Belloni , Artem Panfilov Cc: Maxime Chevallier , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Alexis_L?= =?utf-8?q?othor=C3=A9?= , thomas.petazzoni@bootlin.com Subject: [PATCH 2/2] rtc: ab-eoz9: don't fail temperature reads on undervoltage notification Date: Fri, 22 Nov 2024 11:10:30 +0100 Message-ID: <20241122101031.68916-3-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241122101031.68916-1-maxime.chevallier@bootlin.com> References: <20241122101031.68916-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-rtc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: maxime.chevallier@bootlin.com The undervoltage flags reported by the RTC are useful to know if the time and date are reliable after a reboot. Although the threshold VLOW1 indicates that the thermometer has been shutdown and time compensation is off, it doesn't mean that the temperature readout is currently impossible. As the system is running, the RTC voltage is now fully established and we can read the temperature. Fixes: 67075b63cce2 ("rtc: add AB-RTCMC-32.768kHz-EOZ9 RTC support") Signed-off-by: Maxime Chevallier --- drivers/rtc/rtc-ab-eoz9.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/rtc/rtc-ab-eoz9.c b/drivers/rtc/rtc-ab-eoz9.c index 85853da258d2..52914bb3e5e1 100644 --- a/drivers/rtc/rtc-ab-eoz9.c +++ b/drivers/rtc/rtc-ab-eoz9.c @@ -396,13 +396,6 @@ static int abeoz9z3_temp_read(struct device *dev, if (ret < 0) return ret; - if ((val & ABEOZ9_REG_CTRL_STATUS_V1F) || - (val & ABEOZ9_REG_CTRL_STATUS_V2F)) { - dev_err(dev, - "thermometer might be disabled due to low voltage\n"); - return -EINVAL; - } - switch (attr) { case hwmon_temp_input: ret = regmap_read(regmap, ABEOZ9_REG_REG_TEMP, &val);