Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5631831rwd; Mon, 12 Jun 2023 07:42:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6hqQKFQF1RK8OylWDE0cWOQbEU3CpmPbBEONSjCv760lxDbCiuLM/vlIZDEBaJLFp3q55Y X-Received: by 2002:a05:6a20:394f:b0:119:4141:6989 with SMTP id r15-20020a056a20394f00b0011941416989mr12053398pzg.13.1686580929313; Mon, 12 Jun 2023 07:42:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686580929; cv=none; d=google.com; s=arc-20160816; b=PgcMOZ/3+8i+RqISqQw7u9VuuvEYB4KtLBJ0wTiEwn41BUfgBRVmdkwMYEKNQh2hq0 q9dLY7wGlDOc/6BBLRBAYN242ncV9OZS2AfQRGWUThvi1R2fje+LAv/oTC9iUA/d0Rhe D9/OXyGqKKBqowSJLikHeySPrmLVSOeysC0I1Dw0NJ5SmPF2DXZwXFlaaAhlzLB4ripF iAzhAFz5MMWvqgukCab5SXutENJtMa/dT5JW//YpWyfYIjDKdlnmQx4CtJ9b39Q/kkc1 6Nv0Db0b8rpMzC9ijY99+QBb/hQ151L/TjSk/v3xRAz52ihLyTbd3IqTx7EIi+Jp7dCB LI6Q== 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=vXOzp+rKL77JOYC8eYHmA0SNruaXz0Znhi2NTQDe75A=; b=K6ypQazfCof3+N/LtIP8+TqKi2AjRKtxl4ro2GpFXPpXqEQGBTZ/FxLF6DsnppBdHO 6VuSM0/ssv69v50UCy7v/P7KATVo2jFbUsGPke81gwrzP6QEKEMosdDS1lnUnUDv7NUs 0m4FkWAli9f4BURbGJ7uUq9kD5aGe53oi/iat6ZvRZlYZysiO2RZx0i8opt1PQO0qyz2 EsgHhUVJ7ssIZDScOBwbuEVmvXj2ch6+ZM9QgogE0r4Rp11RhfXeFCeTrJSNcdRgz9Ww o0VdlVL5SABtAodUGH4FkHYI40toSGYog5U+tfMaeArmAPPeE/kiN+75XJOQ5WatMOFx 4N+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=L2rSyjdd; 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 c9-20020a639609000000b00543a6b7642esi7095518pge.818.2023.06.12.07.41.56; Mon, 12 Jun 2023 07:42:09 -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=L2rSyjdd; 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 S237781AbjFLOVA (ORCPT + 99 others); Mon, 12 Jun 2023 10:21:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239717AbjFLOUj (ORCPT ); Mon, 12 Jun 2023 10:20:39 -0400 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9FC3420A; Mon, 12 Jun 2023 07:18:13 -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=1686579427; 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=vXOzp+rKL77JOYC8eYHmA0SNruaXz0Znhi2NTQDe75A=; b=L2rSyjdd2xT+aG9LrldbbmkHzSV51aaIVTI2/BKwhGlx/2hD9+F5fdXAO1SGknQSYNhgIX dE4ec/hBMbOMAn0bPRXmGCQPB0krWTT5VJi9QohQAs/ou0eve8wcTvEU/icw2uqYj5abuK Tzl48yoaOlGLKm7v6oqTvpoaDLBOi58GhQ54DLA6zWt5W7w4qx0rtJHl6OHa9J615z9yTW 2Ux0SguA63VvSa35bQeTcLWwUSBd/lb2FSqlfdZ+bijXQp2QlNEH3YeMkvF71SthPSrgm+ PC0EZZSyH14LcwFaKBO6VrpsqCmo4rQIHBDq4R0KiZRTlFTQS4ytuhDFJv6y2g== 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 EF137240006; Mon, 12 Jun 2023 14:17:05 +0000 (UTC) Date: Mon, 12 Jun 2023 16:17:05 +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: <2023061214170504ac9f0b@mail.local> References: <20230612113059.247275-1-linux@rasmusvillemoes.dk> <20230612113059.247275-7-linux@rasmusvillemoes.dk> <665d9926-2e0f-4b16-1414-f6d8fc487124@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <665d9926-2e0f-4b16-1414-f6d8fc487124@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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 14:30:18+0200, Rasmus Villemoes wrote: > On 12/06/2023 13.30, Rasmus Villemoes wrote: > > > 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); > > + return; > > + } > > + > > + ret = isl12022_read_sr(regmap); > > So testing this a bit more thoroughly reveals that the LBAT85/LBAT75 > bits do not get updated immediately after the TSE bit is set; one needs > to wait a little before the battery voltage detection is done and the SR > bits updated. Unfortunately, the data sheet doesn't say anything about > how long that might be or if there's some busy bit one could look at; > all it says is actually exactly what I've done above: > > The battery level monitor is not functional in battery backup > mode. In order to read the monitor bits after powering up VDD, > instigate a battery level measurement by setting the TSE bit to > "1" (BETA register), and then read the bits. > > IOW, please don't apply this patch until I figure out how to do this > properly. > The datasheet states 22ms for the temperature conversion so I would expect it takes about that time. -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com