Message ID | 20230613130011.305589-7-linux@rasmusvillemoes.dk |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp526768vqr; Tue, 13 Jun 2023 06:04:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5FQy2sBJBg284HTgMKLdcSHs8Whps0YBU3rFQ1PmNpNMnaEhPEaMZUJULTovAgR79IPZAO X-Received: by 2002:a17:907:9728:b0:97d:f8db:601 with SMTP id jg40-20020a170907972800b0097df8db0601mr9283064ejc.62.1686661482300; Tue, 13 Jun 2023 06:04:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686661482; cv=none; d=google.com; s=arc-20160816; b=WhC7Cy3xPHaqC6CUSpvjX6Eqk7LSU+r5P0mp+hVVpZ2Pd2Y397ejSYyc40hBX7dP9a aHLqBW4IcVtYmRRzYPqFSFTRlt0t7ciuwtnBZOlcDDugrsLLfADsXo/zgotPfO5Xuvze dCwEDxY9Wr/6jhkHi6SkEqRka64dag9lhffxyEpea38drHc1iXMv+SAbcMPuPFGMyRJr 8wD2WJ+srR6QnammnyoSs26ZUNtx+p3SPTXfglIY9OLny+hPi0qgrtLTZIDVw2g6jaGo TuV5/rQTz92Bf2YbRvlNFbiPbTpr5PN6kfr8aGPHBYqegF8czBxViz6qajgXeH23dYIG TTDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=s3seTEyzOFrrpdej6mUJHYVSg+iFFYvDZ8cnJx/G6/U=; b=oquFe3hxWJYXHgqLUTo+v6jrpbQhxBEe6CPlkpMF0sf9wt8DVlFaakvf6x4rW6F4fe vIOuKudj17PrZ8jNrGR92//tDHbdKJTCY+hQYSPUSwhMiELz7Wb7iXsVGW6fQ66TiqXG C+e5ays2ODlIgBGxDQjtC+G043+qjpGeQAsaVLhMEV9xWCKb2Tzstf9nAMcLCsZKEMDd 6ReaDgcuNwoyxO5kogiVLliGDVG0EBudDM069EhtEiQjkYIqD8P4OrJQcdhbBbtSV3eG STmBcwsu4fwgtbRioS6el7flpzqblp0LrafEne2aUNof0ZKFXZg1mUEJA1DXb/wHEpC0 KzKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=Zxtr6S2z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q26-20020a170906a09a00b00974572e9d74si6263931ejy.224.2023.06.13.06.03.50; Tue, 13 Jun 2023 06:04:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=Zxtr6S2z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242566AbjFMNBn (ORCPT <rfc822;lekhanya01809@gmail.com> + 99 others); Tue, 13 Jun 2023 09:01:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242397AbjFMNBN (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 13 Jun 2023 09:01:13 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 918061738 for <linux-kernel@vger.kernel.org>; Tue, 13 Jun 2023 06:01:11 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-4f63ea7bfb6so6392422e87.3 for <linux-kernel@vger.kernel.org>; Tue, 13 Jun 2023 06:01:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1686661270; x=1689253270; 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; bh=s3seTEyzOFrrpdej6mUJHYVSg+iFFYvDZ8cnJx/G6/U=; b=Zxtr6S2z8XnVFD+tHbZOvxufbCCSddA+s67PIqPl4nvDcX65ZbN5o6gRuKwlESRGgg wC5+5hV4vam4CRDExDKeXyS06KbNHrxKZT+ymr3JeIdrNN9YIm8f1yHMLgoziQw4G5GA NOUSzJUMQ8QxagoMUV9PGBdMc4/tAtjTtB95o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686661270; x=1689253270; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s3seTEyzOFrrpdej6mUJHYVSg+iFFYvDZ8cnJx/G6/U=; b=HszET/ouAQkt7lKG8DGEQPLW9KD/Fm7Rkj5v2dHVqYXkeWED8HbixsuLS3AiuvaLTA 0DnGOldfFaXp9efJzrgDu39IUIL7yAWfqWlu/JdHtQ2/0K4Vt4Z8WO0KTgYz3JA7hxDs HXExrd9R7pfcf4CcmJK2x8hyK6bsIbJ/yqFGdIBcLzzBjfNrmR0Lm5XuHpoyh4YrIxHA sa+/ty+GoWr1H+/CViXUnU0pwwnLNFDncPEHMo+aEDUT5KQLIT4gXTaktB6WBz2d9+a3 diB3VkpFetIo4NrHUZbvTkVc8OAJuFaO6tGWQIj1Ol3j7E1WWBjot+ujHJts1S1T9J+o U56g== X-Gm-Message-State: AC+VfDyRFz3YeZvztBaiFNWZXrhK1op5CJddIn96ZXqivXUm59rv6Be6 I8t69acayJOWMs2R1K1vqEruAg== X-Received: by 2002:a05:6512:32ad:b0:4f4:b3a6:4140 with SMTP id q13-20020a05651232ad00b004f4b3a64140mr4935980lfe.42.1686661269606; Tue, 13 Jun 2023 06:01:09 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id u24-20020ac243d8000000b004f14ae5ded8sm1793786lfl.28.2023.06.13.06.01.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 06:01:09 -0700 (PDT) From: Rasmus Villemoes <linux@rasmusvillemoes.dk> To: Alessandro Zummo <a.zummo@towertech.it>, Alexandre Belloni <alexandre.belloni@bootlin.com> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>, devicetree@vger.kernel.org, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Conor Dooley <conor+dt@kernel.org>, linux-rtc@vger.kernel.org, Rasmus Villemoes <linux@rasmusvillemoes.dk>, linux-kernel@vger.kernel.org Subject: [PATCH v2 6/8] rtc: isl12022: trigger battery level detection during probe Date: Tue, 13 Jun 2023 15:00:08 +0200 Message-Id: <20230613130011.305589-7-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230613130011.305589-1-linux@rasmusvillemoes.dk> References: <20230612113059.247275-1-linux@rasmusvillemoes.dk> <20230613130011.305589-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768497057752789514?= X-GMAIL-MSGID: =?utf-8?q?1768592750621462488?= |
Series |
rtc: isl12022: battery backup voltage and clock support
|
|
Commit Message
Rasmus Villemoes
June 13, 2023, 1 p.m. UTC
Since the meaning of the SR_LBAT85 and SR_LBAT75 bits are different in
battery backup mode, they may very well be set after power on, and
stay set for up to a minute (i.e. until the battery detection in VDD
mode happens when the seconds counter hits 59). This would mean that
userspace doing a ioctl(RTC_VL_READ) early on could get a false
positive.
The battery level detection can also be triggered by explicitly
writing a 1 to the TSE bit in the BETA register. Do that once during
boot. Empirically, this does not immediately update the bits in
the status register (i.e., an immediate read of SR after this write
can still show stale values), but the update is done after a few
milliseconds, so certainly before the RTC device gets registered and
userspace has a chance of doing the ioctl() on this device.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
drivers/rtc/rtc-isl12022.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c index bf0d65643897..44603169e575 100644 --- a/drivers/rtc/rtc-isl12022.c +++ b/drivers/rtc/rtc-isl12022.c @@ -268,6 +268,16 @@ static void isl12022_set_trip_levels(struct device *dev) ret = regmap_update_bits(regmap, ISL12022_REG_PWR_VBAT, mask, val); if (ret) dev_warn(dev, "unable to set battery alarm levels: %d\n", ret); + + /* + * Force a write of the TSE bit in the BETA register, in order + * to trigger an update of the LBAT75 and LBAT85 bits in the + * status register. In battery backup mode, those bits have + * another meaning, so without this, they may contain stale + * values for up to a minute after power-on. + */ + regmap_write_bits(regmap, ISL12022_REG_BETA, + ISL12022_BETA_TSE, ISL12022_BETA_TSE); } static int isl12022_probe(struct i2c_client *client)