Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5632656rwd; Mon, 12 Jun 2023 07:42:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ45/6vPVMDq7BQRp7i0qEZP4qxBXOTLT3JoNxO75XtJOsUe+/sQwCgn8L6+tVJQ1WeiRlsQ X-Received: by 2002:a92:da87:0:b0:331:cd3:90a7 with SMTP id u7-20020a92da87000000b003310cd390a7mr7307671iln.17.1686580973829; Mon, 12 Jun 2023 07:42:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686580973; cv=none; d=google.com; s=arc-20160816; b=dwmkJik+5hBIpfZzPGnqKS0TILtzh67vweFAdc6qbdl7wuGUQq9zKu6FixkUbJY7D5 KZH2OBYM3SvZpPclniBvU06Ab6iC74ZuG9K8+IbLSL+2reLfUQ7ooIlkU1BrZbeOWO79 UkJV0bNjOyocI/QLpqW3FbClZbmBcIYX3KYmbpHjvYQhOZe0D/xLcaMx/03K37lBlhJ2 GfhPfBB+etCPkPCwnTZdF0Om+E/zNVkSC2ffakAtV023rHmThUoql09vDBpgDVnrSbAz vNm/Wr8YL2kN/9KF1/4Nzf4ztaIfUXriSsAKGoxTTmudWTHyXhC/7V2mGiaIlk3V1x8k z3og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=JHme2Jc90CM+3uR1LvpKHCswp5LiVS3SDAsg2avUjr4=; b=lgILjV+VFaRbUa9ul34Sl9hzUd9CoVc5Z11ukq3GcxYCpg5Cypax5zV3AW1W3SHSzl RLwwOQ4OncUdFrbKSIA+DYFYis3LlwCk9SlWhJrzV/ns1Nk3xs3upcUDKuFmfWgnyPI7 zaFzeF6DQNjwMbgEZ1h3XTxDQZ00bo0FYqaRqqLQVB1jPokToLibkXps5HCsnhND6sSX D3x5lhx2cOCjRAPC1CrhW7Z6fFyzOcgEBi50TjnbE0dEKGvBfXMKb69dyiWbaULUzljF DiU+eUBaEuaJGJLGX3tBb1QhoUj5x3+3sk9JGKbdV7O0Hmrjox5eJGbc2xtU4SUqGfKT SGxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="ZPPPCB/P"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g13-20020a63be4d000000b00544054a5f90si6958333pgo.555.2023.06.12.07.42.41; Mon, 12 Jun 2023 07:42:53 -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=@bootlin.com header.s=gm1 header.b="ZPPPCB/P"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237997AbjFLOSU (ORCPT + 99 others); Mon, 12 Jun 2023 10:18:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237981AbjFLOSD (ORCPT ); Mon, 12 Jun 2023 10:18:03 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8565A4217; Mon, 12 Jun 2023 07:15:41 -0700 (PDT) X-GND-Sasl: alexandre.belloni@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686579319; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=JHme2Jc90CM+3uR1LvpKHCswp5LiVS3SDAsg2avUjr4=; b=ZPPPCB/Pd5MH5nDnJs4Dxn2EuPgKqf+VoJZz6e6q+gBxCy+M9uUxyV3+XUUXkIifx7g+5S ZvSZBDEaaE4OsXENv5DDdSOwZzmD8dX6w2iWEyPB/ycbht6OeblmSMz/uWreO66eKQcXRu H/cbfrdkPTXUTHq8dNXFbFh1p8uceAGLkIt5GLkYrJcGubVnYtCxk9EH0jCSX/MP63xXsi nUGWckZxvrEPb+S5wL6bkBiB7qHaVAxz72fGDIXlwwZyYjgb4W05m48QXwqQmvD/9yT1yw 2HBkpYxqOBim8oX6dB3v7OO6YeHAJ6BKRsV/xZ1oV4uMIs8Kw8xFtiIuxjRJvg== X-GND-Sasl: alexandre.belloni@bootlin.com X-GND-Sasl: alexandre.belloni@bootlin.com X-GND-Sasl: alexandre.belloni@bootlin.com X-GND-Sasl: alexandre.belloni@bootlin.com X-GND-Sasl: alexandre.belloni@bootlin.com X-GND-Sasl: alexandre.belloni@bootlin.com X-GND-Sasl: alexandre.belloni@bootlin.com X-GND-Sasl: alexandre.belloni@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 73585E0011; Mon, 12 Jun 2023 14:15:18 +0000 (UTC) Date: Mon, 12 Jun 2023 16:15:18 +0200 From: Alexandre Belloni To: Rasmus Villemoes Cc: Alessandro Zummo , Andy Shevchenko , devicetree@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 6/8] rtc: isl12022: trigger battery level detection during probe Message-ID: <20230612141518c2119835@mail.local> References: <20230612113059.247275-1-linux@rasmusvillemoes.dk> <20230612113059.247275-7-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230612113059.247275-7-linux@rasmusvillemoes.dk> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org On 12/06/2023 13:30:56+0200, Rasmus Villemoes wrote: > 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 (well, probe), and emit a single warning to the kernel log if the > battery is already low. > > Signed-off-by: Rasmus Villemoes > --- > drivers/rtc/rtc-isl12022.c | 19 ++++++++++++++++++- > 1 file changed, 18 insertions(+), 1 deletion(-) > > diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c > index 1b6659a9b33a..690dbb446d1a 100644 > --- a/drivers/rtc/rtc-isl12022.c > +++ b/drivers/rtc/rtc-isl12022.c > @@ -280,8 +280,25 @@ static void isl12022_set_trip_levels(struct device *dev) > mask = ISL12022_REG_VB85_MASK | ISL12022_REG_VB75_MASK; > > ret = regmap_update_bits(regmap, ISL12022_REG_PWR_VBAT, mask, val); > - if (ret) > + if (ret) { > dev_warn(dev, "unable to set battery alarm levels: %d\n", ret); > + return; > + } > + > + ret = regmap_write_bits(regmap, ISL12022_REG_BETA, > + ISL12022_BETA_TSE, ISL12022_BETA_TSE); > + if (ret) { > + dev_warn(dev, "unable to trigger battery level detection: %d\n", ret); This is too verbose, there is no action for the user upon getting this message. Setting TSE also enables temperature compensation, which may be an undesirable side effect. Shouldn't this be reverted if necessary? > + return; > + } > + > + ret = isl12022_read_sr(regmap); > + if (ret < 0) { > + dev_warn(dev, "unable to read status register: %d\n", ret); > + } else if (ret & (ISL12022_SR_LBAT85 | ISL12022_SR_LBAT75)) { > + dev_warn(dev, "battery voltage is below %u%%\n", > + (ret & ISL12022_SR_LBAT75) ? 75 : 85); This message is useless, I'd drop the whole block. > + } > } > > static int isl12022_probe(struct i2c_client *client) > -- > 2.37.2 > -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com