Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5468940rwd; Mon, 12 Jun 2023 05:43:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7gG3l1zVR8x8Q9LKTjvq8GxRJYJ5ObZyCqKQVLFS0TImErP98j7LG2DwFl3WfBVoNUrTrb X-Received: by 2002:a17:907:6e8c:b0:973:daaa:f3e1 with SMTP id sh12-20020a1709076e8c00b00973daaaf3e1mr11015230ejc.39.1686573788704; Mon, 12 Jun 2023 05:43:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686573788; cv=none; d=google.com; s=arc-20160816; b=QAUvUhNMDeoqYiRXI/L1LklBszOamVpCwb4SbJDzB/rZiSGTvNITLLu/3rfQa7FIsg 57w1C6aZT5ROGJCtEXM6fgS4XTBAR4Y6ZlIzshy9TL7qVmDMD2xWdGUlf16xHrV7t7+/ rE9VmuqOJTi4osLlzKKRM/rOwtOoG+DY3Ry33VhbuvHx9xnnrgDtKiNNtcrRAwwEAlG6 pb4IQHBLX1/jSQbFDyKODB+YFNpnAWE0vud0J/v39UQOHd/QQahCT7w1qLzht09eq2Qx rG2YAHXxaRaRQUAMkMRIBzqPtFwRbgIRTLdfU4obpJTljiWQPTgpRxDFv3v8HClSeuKj H4xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=1U9z6LiWhhNIjZTQZVib3hcbFKnnBjPQBx95lAycLnw=; b=XufzOetd5nzUWy4x9WpZ7F3ZhEBuYSRe96YlZTWfeSGpyd7Iy0bSNdIS/b8Sat2vFR H1g0wyka2P/JCd0wlrAHCL7+8jfct8h9tT90d3HEVIVPygnCwYFWoRjf6Pl1cm7wnK28 frEHXRiEeNld14zBJNUQnuwFwitjazEi4dfhrdSTvbN6BlvaofVDBFDKd537wOjSopE0 2yV22tp4JwzgEYSzFa0DtbO9P4VX+JmPL5N2qBWargDMtHM7O2xoUAYiEQ4bqdy4I+0H yzuKvsM88pX60XuhEM3ablNqwQi2G+xYfx5RkhdelfHamvCAFBofbVU81Evb+82aAXEC AOUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b="F1/6AZav"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a170906110b00b00957c0cf514csi1973815eja.772.2023.06.12.05.42.43; Mon, 12 Jun 2023 05:43:08 -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="F1/6AZav"; 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 S235261AbjFLMbT (ORCPT + 99 others); Mon, 12 Jun 2023 08:31:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234585AbjFLMac (ORCPT ); Mon, 12 Jun 2023 08:30:32 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E620131 for ; Mon, 12 Jun 2023 05:30:21 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-4f64fb05a8aso5040703e87.0 for ; Mon, 12 Jun 2023 05:30:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1686573020; x=1689165020; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=1U9z6LiWhhNIjZTQZVib3hcbFKnnBjPQBx95lAycLnw=; b=F1/6AZava+zQRwLlQeOO1h/1nEAd1sO8wigO0yr61pbTNrL0BaQc9+yIquUpTsISGk WYCTxJXiU1wUtpADftFQCCSxSQGk2LwLUNVNA1gobhcoxkXsoE+nOrs052zVfNkX/fYW i0satxDiN65XV4b0kRadeIDLuIj7mQBVGmiq0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686573020; x=1689165020; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1U9z6LiWhhNIjZTQZVib3hcbFKnnBjPQBx95lAycLnw=; b=dq2Bu82ShFXemfcU61lltmU7p0HVrkMCOIY+c+zuB3FQb9XA/Txf8X+M+xXH4hpeW7 9Tt/VwJrYhnYSy1LhIowwFb06Az9DwoeQRXB11QQBsqwarL94QYJW5OIWvl6vk4ZbM7j f25D/vl1gldWSg2l+TEEbeKpYYQMEYT8d2AltbDvSvEZ4RlwWKWEKunSf/1J2pYdRSwK BE2NBOSVR1hTQj8qAPpSSazFbv+ObRx9ebAAp9anzyQ9Avhj0AfSzLbrN+ANruGaX5W8 upw3N+69v2PkSAyT/jABivQOoywOi7JDOH0+DnFACrBwEoiZKxfI7dm7oKagl//EykWb iM/w== X-Gm-Message-State: AC+VfDyHEZO7/3Q/vw8Huc6ALX4pgDgJdY4vPky1jybf5e03snLNWAfS bUIaNeUhXQRLINdKDem/MIj9vQ== X-Received: by 2002:ac2:465b:0:b0:4f6:1805:6080 with SMTP id s27-20020ac2465b000000b004f618056080mr4892783lfo.4.1686573019770; Mon, 12 Jun 2023 05:30:19 -0700 (PDT) Received: from [172.16.11.116] ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id 11-20020ac2482b000000b004f251e73fc5sm1426472lft.30.2023.06.12.05.30.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jun 2023 05:30:19 -0700 (PDT) Message-ID: <665d9926-2e0f-4b16-1414-f6d8fc487124@rasmusvillemoes.dk> Date: Mon, 12 Jun 2023 14:30:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH 6/8] rtc: isl12022: trigger battery level detection during probe Content-Language: en-US, da To: Alessandro Zummo , Alexandre Belloni Cc: Andy Shevchenko , devicetree@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230612113059.247275-1-linux@rasmusvillemoes.dk> <20230612113059.247275-7-linux@rasmusvillemoes.dk> From: Rasmus Villemoes In-Reply-To: <20230612113059.247275-7-linux@rasmusvillemoes.dk> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, 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, 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. Rasmus