From nobody Sun Feb 8 06:55:37 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47A35C0015E for ; Thu, 15 Jun 2023 10:58:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239653AbjFOK6o (ORCPT ); Thu, 15 Jun 2023 06:58:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343683AbjFOK6i (ORCPT ); Thu, 15 Jun 2023 06:58:38 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57767269A for ; Thu, 15 Jun 2023 03:58:34 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-4f4b2bc1565so10175909e87.2 for ; Thu, 15 Jun 2023 03:58:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1686826712; x=1689418712; 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=jgVb0YJLMNEKVO6C16PIZb2dGiXFxsfavrt5+857HKY=; b=Yj0kx/mnMznFixbKd4cfvllbue4ow0vPQ2gb+hHs05qEo6g4Jz/KzZ0EHGDOTImMCh zHMvXOrN5dBlTFH+k4+0P3iorwv+DW9guDy5mX/Ti9JcTz4AzcAoL9X/pN9kqQNA8VrI JplgpIs/BHXocNT0DLT/VPqf/fiJ63TRiu0js= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686826712; x=1689418712; 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=jgVb0YJLMNEKVO6C16PIZb2dGiXFxsfavrt5+857HKY=; b=Bm65Hb4wxXdDxTMbxdX3U7ZcL3T/NVnVsbDaOg9kFdMjqx/yN5W3SLjObif0+WwLhB xNdmH/qAw16F1D1kQrZlRB6Tesn8j/oqnlMV1hdXEMW7gUklAlvHmjRTcu9RElrEAyf8 B1Qb1fblJiRA9poNf1c2HbivzWdBi84oc1gQ3LYJE7SqUOjIlw/5/6p+F+F5SmXmyHdO NLfEqAA/W7X0aTAAXqR7nKfzve3DTQ8gTmbFtTXPkjb2iBjlvwsDpGwnqXGhuwOSZ99z wjQewJzmnVKSdtlpxxzEpUpvMx5IfZoD+cviZtwXBChhs7tfnzBR0+Yzn1wGYaWEaejb odpw== X-Gm-Message-State: AC+VfDwdCp0xFwIDDXIkrvqJ1hJak5//weVCK68yLvnvGi1CiOTPLJg8 MnamjCW7d6GB/cEpDt6yFOSfnw== X-Google-Smtp-Source: ACHHUZ7R1TJP7+lICTrGlXmck65FIWV3+MNalxpQW7+KmHqWIgonNn0yfiR966KdXWuQYILZ/lSe4Q== X-Received: by 2002:a19:9145:0:b0:4f6:4bf6:59a1 with SMTP id y5-20020a199145000000b004f64bf659a1mr9728645lfj.34.1686826712565; Thu, 15 Jun 2023 03:58:32 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id h7-20020ac25967000000b004f13f4ec267sm165364lfp.186.2023.06.15.03.58.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 03:58:31 -0700 (PDT) From: Rasmus Villemoes To: Alessandro Zummo , Alexandre Belloni Cc: Andy Shevchenko , devicetree@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-rtc@vger.kernel.org, Rasmus Villemoes , linux-kernel@vger.kernel.org Subject: [PATCH v3 1/8] rtc: isl12022: remove wrong warning for low battery level Date: Thu, 15 Jun 2023 12:58:19 +0200 Message-Id: <20230615105826.411953-2-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230615105826.411953-1-linux@rasmusvillemoes.dk> References: <20230612113059.247275-1-linux@rasmusvillemoes.dk> <20230615105826.411953-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" There are multiple problems with this warning. First of all, it triggers way too often, in fact nearly on every boot, because the SR_LBAT85/SR_LBAT75 bits have another meaning when in battery backup mode. Quoting from the data sheet: LOW BATTERY INDICATOR 85% BIT (LBAT85) In Normal Mode (VDD), this bit indicates when the battery level has dropped below the pre-selected trip levels. [...] The LBAT85 detection happens automatically once every minute when seconds register reaches 59. In Battery Mode (VBAT), this bit indicates the device has entered into battery mode by polling once every 10 minutes. The LBAT85 detection happens automatically once when the minute register reaches x9h or x0h minutes. Similar wording applies to the LBAT75 bit. This means that if the device is powered off for more than 10 minutes, the LBAT85 bit is guaranteed to be set. Upon power-on, unless we're close enough to the end of a minute and/or the boot is slow enough that the second register passes 59, the LBAT85 bit is still set when the kernel (or early userspace) reads the RTC to set the system's wallclock time. Another minor problem is with the bit logic. If the 75% level is reached, logically we're also below 85%, so both bits would most likely be set. So even if the battery is below 75%, the warning would still say "voltage dropped below 85%". A third problem is that the driver and current DT binding offer no way to indicate the nominal battery level and/or settings of the Battery Level Monitor Trip Bits. Since the default value of the VB85TP[2:0] and VB75TP[2:0] bits are 000, this means the actual setting of the LBAT85/LBAT75 bits in VDD mode doesn't happen until the battery is below 2.125V/1.875V, which for a standard 3V battery is way too late. A fourth problem is emitting this warning from ->read_time: util-linux' hwclock will, in the absence of support for getting an interrupt when the seconds counter is updated, issue ioctl(RTC_RD_TIME) in a busy-loop until it sees a change in the seconds field. In that case, if the battery low bits are set (either genuinely, more than a minute after boot, due to the battery actually being low, or as above, bogusly shortly after boot), the kernel log is swamped with hundreds of identical warnings. Subsequent patches will add such bindings and driver support, and also proper support for RTC_VL_READ. For now, remove the broken warning. Signed-off-by: Rasmus Villemoes --- drivers/rtc/rtc-isl12022.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c index e68a79b5e00e..ebd66b835cef 100644 --- a/drivers/rtc/rtc-isl12022.c +++ b/drivers/rtc/rtc-isl12022.c @@ -141,12 +141,6 @@ static int isl12022_rtc_read_time(struct device *dev, = struct rtc_time *tm) if (ret) return ret; =20 - if (buf[ISL12022_REG_SR] & (ISL12022_SR_LBAT85 | ISL12022_SR_LBAT75)) { - dev_warn(dev, - "voltage dropped below %u%%, date and time is not reliable.\n", - buf[ISL12022_REG_SR] & ISL12022_SR_LBAT85 ? 85 : 75); - } - dev_dbg(dev, "raw data is sec=3D%02x, min=3D%02x, hr=3D%02x, mday=3D%02x, mon=3D%02x,= year=3D%02x, wday=3D%02x, sr=3D%02x, int=3D%02x", buf[ISL12022_REG_SC], --=20 2.37.2 From nobody Sun Feb 8 06:55:37 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97B8EEB64D9 for ; Thu, 15 Jun 2023 10:58:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245447AbjFOK6q (ORCPT ); Thu, 15 Jun 2023 06:58:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244393AbjFOK6j (ORCPT ); Thu, 15 Jun 2023 06:58:39 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64E342729 for ; Thu, 15 Jun 2023 03:58:36 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-4f63ab1ac4aso10132288e87.0 for ; Thu, 15 Jun 2023 03:58:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1686826714; x=1689418714; 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=/O5ajNJ8bhgs1nhXgvSUBPUBne+CmT1+jmqUtcvu2LU=; b=ErbZPPZXvUKlQoXhYWpKMzUgIlmgtXFL8h1xF9US85iurYsE0eidYdhkKCulFoGDNC yaZXHMQdvSNUb5rErJvZNzwcMQY1Chend81fZFofkkfCs+UOz0PSM2uzq+iR+qPci9am OenACAI9pG5a12e5V3H8qwYx0Ab61FVdbUbiE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686826714; x=1689418714; 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=/O5ajNJ8bhgs1nhXgvSUBPUBne+CmT1+jmqUtcvu2LU=; b=d4GLhMfUG4QiiWGZ223yxq5Xu35wOWwW/AJ6prfbW9vS9l1/9pQC+RtWVsicO17jho QATVQ5qjlt9i7JfZfL6GXoy3U/gT0buAkIPqE2feWIde9fv21TAP3IekS0AWLUpwbkN1 LL02EgRxvJBKxE3DxbNxbeQ4ipyru1WnmjqBFNoY4ve74Dm2IaroBmtRGfCvOdCtcVJM EjYI7meiMvRVO8cbxJ0bn/x4NK+CgwkY6v41n0N9I0IVKaaUde+BxdAMYl2BT/XTL3dx JhiGyjMu5thSb6PaabHDrW5tgic6s7gG4HkoLeO4olTpVpBwVTwj0EWH+/VtEniCEPsa uWEw== X-Gm-Message-State: AC+VfDzSGX3szTka3SLrQ/952agidlZMkJlevt8T3cxHumVrVxPus56C 54HV8YQQ7eoRtSDvgzyRCvzRBQ== X-Google-Smtp-Source: ACHHUZ67E82lkWq68LWSYGH0WEyZLC4mCttbXHLuYdkqTEasoP0CoqOEBdlvhoaiKO/uXnrlxYM/lA== X-Received: by 2002:a19:9212:0:b0:4f6:2ce6:124 with SMTP id u18-20020a199212000000b004f62ce60124mr8184297lfd.39.1686826714625; Thu, 15 Jun 2023 03:58:34 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id h7-20020ac25967000000b004f13f4ec267sm165364lfp.186.2023.06.15.03.58.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 03:58:33 -0700 (PDT) From: Rasmus Villemoes To: Alessandro Zummo , Alexandre Belloni Cc: Andy Shevchenko , devicetree@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-rtc@vger.kernel.org, Rasmus Villemoes , Krzysztof Kozlowski , linux-kernel@vger.kernel.org Subject: [PATCH v3 2/8] dt-bindings: rtc: Move isil,isl12022 from trivial-rtc.yaml into own schema file Date: Thu, 15 Jun 2023 12:58:20 +0200 Message-Id: <20230615105826.411953-3-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230615105826.411953-1-linux@rasmusvillemoes.dk> References: <20230612113059.247275-1-linux@rasmusvillemoes.dk> <20230615105826.411953-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Move the isil,isl12022 RTC bindings from trivial-rtc.yaml into its own intersil,isl12022.yaml file, in preparation for adding more bindings. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Rasmus Villemoes --- .../bindings/rtc/intersil,isl12022.yaml | 45 +++++++++++++++++++ .../devicetree/bindings/rtc/trivial-rtc.yaml | 2 - 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/rtc/intersil,isl12022= .yaml diff --git a/Documentation/devicetree/bindings/rtc/intersil,isl12022.yaml b= /Documentation/devicetree/bindings/rtc/intersil,isl12022.yaml new file mode 100644 index 000000000000..054d3fc649ba --- /dev/null +++ b/Documentation/devicetree/bindings/rtc/intersil,isl12022.yaml @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/rtc/intersil,isl12022.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Intersil ISL12022 Real-time Clock + +maintainers: + - Alexandre Belloni + +properties: + compatible: + const: isil,isl12022 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + +allOf: + - $ref: rtc.yaml# + +unevaluatedProperties: false + +examples: + - | + #include + i2c { + #address-cells =3D <1>; + #size-cells =3D <0>; + + rtc@6f { + compatible =3D "isil,isl12022"; + reg =3D <0x6f>; + interrupts-extended =3D <&gpio1 5 IRQ_TYPE_LEVEL_LOW>; + }; + }; + +... diff --git a/Documentation/devicetree/bindings/rtc/trivial-rtc.yaml b/Docum= entation/devicetree/bindings/rtc/trivial-rtc.yaml index a3603e638c37..b062c64266a6 100644 --- a/Documentation/devicetree/bindings/rtc/trivial-rtc.yaml +++ b/Documentation/devicetree/bindings/rtc/trivial-rtc.yaml @@ -45,8 +45,6 @@ properties: - isil,isl1208 # Intersil ISL1218 Low Power RTC with Battery Backed SRAM - isil,isl1218 - # Intersil ISL12022 Real-time Clock - - isil,isl12022 # Loongson-2K Socs/LS7A bridge Real-time Clock - loongson,ls2x-rtc # Real Time Clock Module with I2C-Bus --=20 2.37.2 From nobody Sun Feb 8 06:55:37 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0FEAEEB64DC for ; Thu, 15 Jun 2023 10:58:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343816AbjFOK6z (ORCPT ); Thu, 15 Jun 2023 06:58:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343729AbjFOK6l (ORCPT ); Thu, 15 Jun 2023 06:58:41 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2C24E57 for ; Thu, 15 Jun 2023 03:58:38 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-4f762b3227dso825704e87.1 for ; Thu, 15 Jun 2023 03:58:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1686826717; x=1689418717; 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=cfopBjHrRqDySJuSAMCUvhXmj8ZxffTN4Fp5DsieY7A=; b=Lz6b6vSFV436npcr01hqfn/fSPQ3iCiWMoVTbEZAZeaDjmqE5NJUwJofa1Mqm0ORzg IyzgJkRfQEkALXUjUiCeKMY3E/6lAZqVq0T+ta77WY2h/GVPUdggQ6vemrz3VanJr10E dAfiyEgfami0fJahzDv9md1i7sRI5xr3dysBQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686826717; x=1689418717; 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=cfopBjHrRqDySJuSAMCUvhXmj8ZxffTN4Fp5DsieY7A=; b=G2wAuGHtO3063B7KPW1NS8WFbU/fLhN45sgsxDM64q3SyhIyUYDvDrb70w6kDmdF5Q EdjSFlzRukB4Gyieyz2QyVxXuDukBx5nI5hnLOrd8f9sD3g9HjKmqd1pFvC3f/Rk6AqN eSGEajeFY+gbiEp31dj18cVlYHMhXpWHURwdR9VQOT9BaIhFisJhBUHgAmDcgtcFSrxy /hV6Tecq9fcp5ripl3Cz6xFNeUvIl60q34NwRw3MaByqEjovkLArFthP0CpHRveZ4t+1 Cm1of7bwRPYBgV/q992pmR3txuQhRJbmoN1LbfFE8RZPK1dbrmmXnJui9lLYKOjOw2vk jaZw== X-Gm-Message-State: AC+VfDwiHGcuK/mQX3yT04ZkYxywZ0XUDXLoAP3Xpez1eYWJV01/Z3qk E9dkLB8Mw2/kJxIZKveJWULH7Q== X-Google-Smtp-Source: ACHHUZ7IkH/iPRuaojwiROlR5IplUqvPDIVOTVziRavD7wWfI4f+xvSDjHul6Uwh8je0aBQ193us0A== X-Received: by 2002:a05:6512:46d:b0:4f1:2ebf:536f with SMTP id x13-20020a056512046d00b004f12ebf536fmr1457824lfd.16.1686826717359; Thu, 15 Jun 2023 03:58:37 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id h7-20020ac25967000000b004f13f4ec267sm165364lfp.186.2023.06.15.03.58.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 03:58:37 -0700 (PDT) From: Rasmus Villemoes To: Alessandro Zummo , Alexandre Belloni Cc: Andy Shevchenko , devicetree@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-rtc@vger.kernel.org, Rasmus Villemoes , linux-kernel@vger.kernel.org Subject: [PATCH v3 3/8] dt-bindings: rtc: isl12022: add bindings for battery alarm trip levels Date: Thu, 15 Jun 2023 12:58:21 +0200 Message-Id: <20230615105826.411953-4-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230615105826.411953-1-linux@rasmusvillemoes.dk> References: <20230612113059.247275-1-linux@rasmusvillemoes.dk> <20230615105826.411953-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The isl12022 has a built-in support for monitoring the voltage of the backup battery, and setting bits in the status register when that voltage drops below two predetermined levels (usually 85% and 75% of the nominal voltage). However, since it can operate at wide range of battery voltages (2.5V - 5.5V), one must configure those trip levels according to which battery is used on a given board. Add bindings for defining these two trip levels. While the register and bit names suggest that they should correspond to 85% and 75% of the nominal battery voltage, the data sheet also says There are total of 7 levels that could be selected for the first alarm. Any of the of levels could be selected as the first alarm with no reference as to nominal Battery voltage level. Hence this provides the hardware designer the ability to choose values based on the discharge characteristics of the battery chosen for the given product, rather than just having one battery-microvolt property and having the driver choose levels close to 0.85/0.75 times that. Signed-off-by: Rasmus Villemoes Reviewed-by: Krzysztof Kozlowski --- .../devicetree/bindings/rtc/intersil,isl12022.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/devicetree/bindings/rtc/intersil,isl12022.yaml b= /Documentation/devicetree/bindings/rtc/intersil,isl12022.yaml index 054d3fc649ba..3c6c07aaa78f 100644 --- a/Documentation/devicetree/bindings/rtc/intersil,isl12022.yaml +++ b/Documentation/devicetree/bindings/rtc/intersil,isl12022.yaml @@ -19,6 +19,14 @@ properties: interrupts: maxItems: 1 =20 + isil,battery-trip-levels-microvolt: + description: + The battery voltages at which the first alarm and second alarm + should trigger (normally ~85% and ~75% of nominal V_BAT). + items: + - enum: [2125000, 2295000, 2550000, 2805000, 3060000, 4250000, 46750= 00] + - enum: [1875000, 2025000, 2250000, 2475000, 2700000, 3750000, 41250= 00] + required: - compatible - reg @@ -39,6 +47,7 @@ examples: compatible =3D "isil,isl12022"; reg =3D <0x6f>; interrupts-extended =3D <&gpio1 5 IRQ_TYPE_LEVEL_LOW>; + isil,battery-trip-levels-microvolt =3D <2550000>, <2250000>; }; }; =20 --=20 2.37.2 From nobody Sun Feb 8 06:55:37 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 317FAEB64D9 for ; Thu, 15 Jun 2023 10:59:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244494AbjFOK66 (ORCPT ); Thu, 15 Jun 2023 06:58:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343756AbjFOK6x (ORCPT ); Thu, 15 Jun 2023 06:58:53 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9D012711 for ; Thu, 15 Jun 2023 03:58:40 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-4f841b7a697so1020973e87.3 for ; Thu, 15 Jun 2023 03:58:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1686826719; x=1689418719; 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=LYfZJ0PxZixY0dLK5zmM+/mrSboE1mU7I13VvIoENDw=; b=PmuxOTSVjQn1kT6lIyY95Bndpk5NDtK6UeKpy3xHbzizb3puAVukBDCtUxEPKQQjHA rQ3dN0xutz377HnXe/t98WxB455hiS0Ot4M2IwFEzX3had6VAfBEGlmSmP1509pLvZXp WJqGClZ0ivwsespZ3HxA/nCKE0l3PKt4bEwKc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686826719; x=1689418719; 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=LYfZJ0PxZixY0dLK5zmM+/mrSboE1mU7I13VvIoENDw=; b=H9zd+4NfNhhsLc9demv7pa6NvwZGKqES5FMmJpVqjEYQjjuaWjwdl8aJJ2Z3Q2MrRL R6BD5W+Q/8LXCBbMpDWH1SnLg6tWarqeDa+DvQwjSQ0TGzclfIG67MKWGdyubiVyOPVR K3Y045o3ijHm0xon2YaTdFNhIQZKIIkN5LGrgq5bqnBxTNRgVTTLZXY5gGRuOPn5n/pv 80Q2amfnMsAGNwyfABnemPTvS+3hJl07+HXk3QGq5b5WjuGIcaNzhmVKwqtlzU3OjHus leSVjzCI3lnIEnzwXGf49zZnGhMrBwMXBSSyRmfhxvnKLs9Qa3dzjH5V6yF5VqQKYQzG WPdA== X-Gm-Message-State: AC+VfDzkLD6mptYv2207QYFQW6rNZBWCd6TEZo7CgbuQr8FUbRiKM8i+ VjQuPSbdLQiXk0akKdMYdtb9VA== X-Google-Smtp-Source: ACHHUZ4Ki/3UyNWljzTgPUtV1FL38EtSQGnHyLqfoIZ+0hG7grzuUa8EpnVtVNvrik6Id4QlmX/GMA== X-Received: by 2002:a19:5007:0:b0:4f6:29b2:f92a with SMTP id e7-20020a195007000000b004f629b2f92amr10870918lfb.21.1686826719087; Thu, 15 Jun 2023 03:58:39 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id h7-20020ac25967000000b004f13f4ec267sm165364lfp.186.2023.06.15.03.58.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 03:58:38 -0700 (PDT) From: Rasmus Villemoes To: Alessandro Zummo , Alexandre Belloni Cc: Andy Shevchenko , devicetree@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-rtc@vger.kernel.org, Rasmus Villemoes , linux-kernel@vger.kernel.org Subject: [PATCH v3 4/8] rtc: isl12022: add support for trip level DT binding Date: Thu, 15 Jun 2023 12:58:22 +0200 Message-Id: <20230615105826.411953-5-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230615105826.411953-1-linux@rasmusvillemoes.dk> References: <20230612113059.247275-1-linux@rasmusvillemoes.dk> <20230615105826.411953-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Implement support for using the values given in the isil,battery-trip-levels-microvolt property to set appropriate values in the VB85TP/VB75TP bits in the PWR_VBAT register. Signed-off-by: Rasmus Villemoes --- drivers/rtc/rtc-isl12022.c | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c index ebd66b835cef..6a757f0a4736 100644 --- a/drivers/rtc/rtc-isl12022.c +++ b/drivers/rtc/rtc-isl12022.c @@ -9,6 +9,7 @@ */ =20 #include +#include #include #include #include @@ -31,6 +32,8 @@ #define ISL12022_REG_SR 0x07 #define ISL12022_REG_INT 0x08 =20 +#define ISL12022_REG_PWR_VBAT 0x0a + #define ISL12022_REG_BETA 0x0d #define ISL12022_REG_TEMP_L 0x28 =20 @@ -42,6 +45,9 @@ =20 #define ISL12022_INT_WRTC (1 << 6) =20 +#define ISL12022_REG_VB85_MASK GENMASK(5, 3) +#define ISL12022_REG_VB75_MASK GENMASK(2, 0) + #define ISL12022_BETA_TSE (1 << 7) =20 static umode_t isl12022_hwmon_is_visible(const void *data, @@ -209,6 +215,38 @@ static const struct regmap_config regmap_config =3D { .use_single_write =3D true, }; =20 +static const u32 trip_levels[2][7] =3D { + { 2125000, 2295000, 2550000, 2805000, 3060000, 4250000, 4675000 }, + { 1875000, 2025000, 2250000, 2475000, 2700000, 3750000, 4125000 }, +}; + +static void isl12022_set_trip_levels(struct device *dev) +{ + struct regmap *regmap =3D dev_get_drvdata(dev); + u32 levels[2] =3D {0, 0}; + int ret, i, j, x[2]; + u8 val, mask; + + device_property_read_u32_array(dev, "isil,battery-trip-levels-microvolt", + levels, 2); + + for (i =3D 0; i < 2; i++) { + for (j =3D 0; j < ARRAY_SIZE(trip_levels[i]) - 1; j++) { + if (levels[i] <=3D trip_levels[i][j]) + break; + } + x[i] =3D j; + } + + val =3D FIELD_PREP(ISL12022_REG_VB85_MASK, x[0]) | + FIELD_PREP(ISL12022_REG_VB75_MASK, x[1]); + mask =3D ISL12022_REG_VB85_MASK | ISL12022_REG_VB75_MASK; + + ret =3D regmap_update_bits(regmap, ISL12022_REG_PWR_VBAT, mask, val); + if (ret) + dev_warn(dev, "unable to set battery alarm levels: %d\n", ret); +} + static int isl12022_probe(struct i2c_client *client) { struct rtc_device *rtc; @@ -225,6 +263,7 @@ static int isl12022_probe(struct i2c_client *client) =20 dev_set_drvdata(&client->dev, regmap); =20 + isl12022_set_trip_levels(&client->dev); isl12022_hwmon_register(&client->dev); =20 rtc =3D devm_rtc_allocate_device(&client->dev); --=20 2.37.2 From nobody Sun Feb 8 06:55:37 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30FB1EB64D9 for ; Thu, 15 Jun 2023 10:59:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244393AbjFOK7C (ORCPT ); Thu, 15 Jun 2023 06:59:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343788AbjFOK6y (ORCPT ); Thu, 15 Jun 2023 06:58:54 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 906D8272E for ; Thu, 15 Jun 2023 03:58:44 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-4f63ab1ac4aso10132472e87.0 for ; Thu, 15 Jun 2023 03:58:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1686826723; x=1689418723; 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=Gv+DyaZll/H2jD9ow4C+es+DNFI9kuFxb3UaUHDFHqk=; b=Mb+vso8FaqEEofawsYkCeO6DcWi2o/+zW8gnJATEZQOM4QaWY0QPvGxuwLl7IJogHB dxeDv8yKMU27OtF5I5Mqlk/X3lbiRg0CZ75rF51wFgaN2G1UjUmiO9BkQ3TuKjnMNJ6T kUrCQabCoKJ8kJXxwDkmuwQJZhNOaEqoRjsJQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686826723; x=1689418723; 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=Gv+DyaZll/H2jD9ow4C+es+DNFI9kuFxb3UaUHDFHqk=; b=bnaL8ITTCkUPtjZIqWUjT3BfGbe8f8y6p8+7WYkxxtNEYOO4NhSuNNPQ0AolkCPiEp hb2+d2gXuQAwj4T1EwE7EvefhKzRV9HSVpVXNt25smpj96Sti1cxSdn9i6D2cldc+zmj UKQXW/U2D+iZAqSipZuQQdbmtmTTerrKYBOlRFFpTAglvh4MuO0YgP6YO1e80xRDP7Qi glQBUzMf/8nOjeV8HMczqy61dGv68R/fT0dSZYScjYfJKjKQbF9pxrgBUcFQfZWMDthX RyYaozD6OnYLYcinS/vcOQkqsBVmhxNdETf0uhw1giTxLq3zpNq6GyFaC+oGY4xfPTSA mmcg== X-Gm-Message-State: AC+VfDytYg6pCut/BNPP1k00qq8/gvf8s3GuxnwBSGsk6V00gnQL3nfu taZ0ewzlAH8/gaxi+VYtca5X+Q== X-Google-Smtp-Source: ACHHUZ55S44mbroI4h4dOvkl5CJL0C/g7l1shWyyYYaWVWNVM1qxhxYMPsD8IgVniWLYd4y5+ukC6Q== X-Received: by 2002:a19:9150:0:b0:4f8:48f3:f08 with SMTP id y16-20020a199150000000b004f848f30f08mr12996lfj.21.1686826722859; Thu, 15 Jun 2023 03:58:42 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id h7-20020ac25967000000b004f13f4ec267sm165364lfp.186.2023.06.15.03.58.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 03:58:40 -0700 (PDT) From: Rasmus Villemoes To: Alessandro Zummo , Alexandre Belloni Cc: Andy Shevchenko , devicetree@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-rtc@vger.kernel.org, Rasmus Villemoes , linux-kernel@vger.kernel.org Subject: [PATCH v3 5/8] rtc: isl12022: implement RTC_VL_READ ioctl Date: Thu, 15 Jun 2023 12:58:23 +0200 Message-Id: <20230615105826.411953-6-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230615105826.411953-1-linux@rasmusvillemoes.dk> References: <20230612113059.247275-1-linux@rasmusvillemoes.dk> <20230615105826.411953-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Hook up support for reading the values of the SR_LBAT85 and SR_LBAT75 bits. Translate the former to "battery low", and the latter to "battery empty or not-present". Signed-off-by: Rasmus Villemoes --- drivers/rtc/rtc-isl12022.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c index 6a757f0a4736..a48456abdcb9 100644 --- a/drivers/rtc/rtc-isl12022.c +++ b/drivers/rtc/rtc-isl12022.c @@ -204,7 +204,34 @@ static int isl12022_rtc_set_time(struct device *dev, s= truct rtc_time *tm) return regmap_bulk_write(regmap, ISL12022_REG_SC, buf, sizeof(buf)); } =20 +static int isl12022_rtc_ioctl(struct device *dev, unsigned int cmd, unsign= ed long arg) +{ + struct regmap *regmap =3D dev_get_drvdata(dev); + u32 user, val; + int ret; + + switch (cmd) { + case RTC_VL_READ: + ret =3D regmap_read(regmap, ISL12022_REG_SR, &val); + if (ret) + return ret; + + user =3D 0; + if (val & ISL12022_SR_LBAT85) + user |=3D RTC_VL_BACKUP_LOW; + + if (val & ISL12022_SR_LBAT75) + user |=3D RTC_VL_BACKUP_EMPTY; + + return put_user(user, (u32 __user *)arg); + + default: + return -ENOIOCTLCMD; + } +} + static const struct rtc_class_ops isl12022_rtc_ops =3D { + .ioctl =3D isl12022_rtc_ioctl, .read_time =3D isl12022_rtc_read_time, .set_time =3D isl12022_rtc_set_time, }; --=20 2.37.2 From nobody Sun Feb 8 06:55:37 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35213C001DD for ; Thu, 15 Jun 2023 10:59:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230389AbjFOK7L (ORCPT ); Thu, 15 Jun 2023 06:59:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343817AbjFOK6z (ORCPT ); Thu, 15 Jun 2023 06:58:55 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AD13295D for ; Thu, 15 Jun 2023 03:58:50 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-4f61d79b0f2so10528051e87.3 for ; Thu, 15 Jun 2023 03:58:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1686826728; x=1689418728; 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=N6N4ojvwXgyqqnUo/wtTdbg/VBkKSYsLenHRuGk8XAM=; b=Rw5sSbfvjOx+S2rKxZwJjwADqE3HdGV7U3SRGxcQi45apK6bFKUzEgtmB5NwCcftep k4Xa4HGviEy7FndmC/dYBURZCl8nuKOxJnHh1e3Gr9kvwB0If82SSXyBHV98aMS/YcGv 1XWU6Fz0nQHtjZK5jqrw4y4XnrvtXW7meYQcA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686826728; x=1689418728; 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=N6N4ojvwXgyqqnUo/wtTdbg/VBkKSYsLenHRuGk8XAM=; b=OWdJKva1f8zeVXIj1XxuEahuATXMUXS77jA0Q5lj6YfI0bUEReLE5fL0V8OnZGtdwi IF5rQeZGVbGt2jKXM1FUhIcFHM42wFIkXMLpbd7r7OweXMWARLd+GcagCb5qQBOW2xBn 6R6RuZqkF/V65a7+qPV1Azv1N5FpeSecqnscAmsnDxPa3pU1+boj1/fKQoNxP/P6IdVW gDs2wUXhTMYLTUWGq3ZsdrsazPUQ0hHH60EOO/d2E5Gii/OQrwrEtCNDfIri+O9CM+nv XnwVzXLWRprecBGnY4rSObUPaZO1Dd0hJ/JMdJVGh7XA3ykTlbRkQzlinZNclPG8aquh vILw== X-Gm-Message-State: AC+VfDxJ1gWHyUc419GRwU975XGiLnzB5TL+zVOqZinDNENE4PAP9oit xz6wQhxpcca164t66jE7EdYFBg== X-Google-Smtp-Source: ACHHUZ7BeNID2yzxlZkWzwvz+EhuQh45YUNB0n+mUzuq6O1PUeD+FGtrkV2yRiz7A7m5tscCJmu/qA== X-Received: by 2002:a05:6512:619:b0:4f8:48f3:f06 with SMTP id b25-20020a056512061900b004f848f30f06mr15465lfe.48.1686826728635; Thu, 15 Jun 2023 03:58:48 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id h7-20020ac25967000000b004f13f4ec267sm165364lfp.186.2023.06.15.03.58.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 03:58:43 -0700 (PDT) From: Rasmus Villemoes To: Alessandro Zummo , Alexandre Belloni Cc: Andy Shevchenko , devicetree@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-rtc@vger.kernel.org, Rasmus Villemoes , linux-kernel@vger.kernel.org Subject: [PATCH v3 6/8] rtc: isl12022: trigger battery level detection during probe Date: Thu, 15 Jun 2023 12:58:24 +0200 Message-Id: <20230615105826.411953-7-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230615105826.411953-1-linux@rasmusvillemoes.dk> References: <20230612113059.247275-1-linux@rasmusvillemoes.dk> <20230615105826.411953-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --- 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 a48456abdcb9..916879b0388c 100644 --- a/drivers/rtc/rtc-isl12022.c +++ b/drivers/rtc/rtc-isl12022.c @@ -272,6 +272,16 @@ static void isl12022_set_trip_levels(struct device *de= v) ret =3D 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); } =20 static int isl12022_probe(struct i2c_client *client) --=20 2.37.2 From nobody Sun Feb 8 06:55:37 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5944EEB64D9 for ; Thu, 15 Jun 2023 10:59:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238604AbjFOK7Q (ORCPT ); Thu, 15 Jun 2023 06:59:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343821AbjFOK64 (ORCPT ); Thu, 15 Jun 2023 06:58:56 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72C202963 for ; Thu, 15 Jun 2023 03:58:51 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-4f5f728c4aaso816581e87.0 for ; Thu, 15 Jun 2023 03:58:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1686826729; x=1689418729; 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=aIDXI/11BslSskl54h414rVvg2lyuYHt6cU/p8nUA9g=; b=c+yjgpGdQDmhjuZnQbwyxD0bDl3q0M4kNfPSdir/p7LY1WGleDG12sNdYUO7Rb5WlH 03N73vRJzClXVVrzkZo0u1dim3YMGTaAQPixcPL6a0FxZCV9VUpHlth3LUTwwf7q7W37 /iBl5UwPSg2+YwoOnEP/twQHno662NOBmN2fQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686826729; x=1689418729; 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=aIDXI/11BslSskl54h414rVvg2lyuYHt6cU/p8nUA9g=; b=WikVQVG3wcVQnL/fvYJE4U3df1Q8bl0oUce9NsC9n5tQTqzYCjDxoJ++YR+sMSe0h/ ikcmQEHeIaLQkRAlDvZG4GPlBW5uujCPXgfXDS1ypvjczIVp20YMyF/JH3ZIvhBlDzAM 3I5pl7PmyyW4bTnFXRsO2iX69vvyMV9Smq0RrOjLHGbGgqKL6FqxDImnXCS5l4f7B+VL 6fxo7dSvXZtfT5VjsDLEjyq9VJWvxZKo4Gcsz8EoTjdkBla3stilfjjj1REja+m024ER qIKXG36/Pa0Lk8+rt5t45LLd+ewMU7PMYGXvRF41fj7cixwWD7W+pGoDzsh4aKNQlFGs 2SHw== X-Gm-Message-State: AC+VfDwJFOjMPDj/IpbgRVz9UKJWNox7PuVLnXFHlEjc2z/cLh26ksjN k6II7Ol9CzNb5H5V7N8p80jpdA== X-Google-Smtp-Source: ACHHUZ7f9+BJ+Uy13A8hOyIDEh2/w/DuN5eK4X5Jue10bhs+MZzLvyEWhKBWBwM8XgHJSKNwg3wfVQ== X-Received: by 2002:a05:6512:398a:b0:4f4:e509:ef56 with SMTP id j10-20020a056512398a00b004f4e509ef56mr1374697lfu.25.1686826729727; Thu, 15 Jun 2023 03:58:49 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id h7-20020ac25967000000b004f13f4ec267sm165364lfp.186.2023.06.15.03.58.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 03:58:49 -0700 (PDT) From: Rasmus Villemoes To: Alessandro Zummo , Alexandre Belloni Cc: Andy Shevchenko , devicetree@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-rtc@vger.kernel.org, Rasmus Villemoes , linux-kernel@vger.kernel.org Subject: [PATCH v3 7/8] dt-bindings: rtc: isl12022: add #clock-cells property Date: Thu, 15 Jun 2023 12:58:25 +0200 Message-Id: <20230615105826.411953-8-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230615105826.411953-1-linux@rasmusvillemoes.dk> References: <20230612113059.247275-1-linux@rasmusvillemoes.dk> <20230615105826.411953-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The isl12022 has a dual-purpose irq/f_out pin, which can either be used as an interrupt or clock output. Signed-off-by: Rasmus Villemoes Reviewed-by: Krzysztof Kozlowski --- .../devicetree/bindings/rtc/intersil,isl12022.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/devicetree/bindings/rtc/intersil,isl12022.yaml b= /Documentation/devicetree/bindings/rtc/intersil,isl12022.yaml index 3c6c07aaa78f..c2d1441ef273 100644 --- a/Documentation/devicetree/bindings/rtc/intersil,isl12022.yaml +++ b/Documentation/devicetree/bindings/rtc/intersil,isl12022.yaml @@ -19,6 +19,9 @@ properties: interrupts: maxItems: 1 =20 + '#clock-cells': + const: 0 + isil,battery-trip-levels-microvolt: description: The battery voltages at which the first alarm and second alarm @@ -33,6 +36,13 @@ required: =20 allOf: - $ref: rtc.yaml# + # If #clock-cells is present, interrupts must not be present + - if: + required: + - '#clock-cells' + then: + properties: + interrupts: false =20 unevaluatedProperties: false =20 --=20 2.37.2 From nobody Sun Feb 8 06:55:37 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B44EEB64D9 for ; Thu, 15 Jun 2023 10:59:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240245AbjFOK7T (ORCPT ); Thu, 15 Jun 2023 06:59:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343782AbjFOK64 (ORCPT ); Thu, 15 Jun 2023 06:58:56 -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 739FB2967 for ; Thu, 15 Jun 2023 03:58:52 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-4f764e92931so2949811e87.2 for ; Thu, 15 Jun 2023 03:58:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1686826731; x=1689418731; 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=guPKntobdnOXU3BYd6z8xQJYVopEOSCbah3uJeL+Sfw=; b=TEHAhgNm41CCRwEVD8tBtQTviwEd/ignaLVJWRkWLDVKPmae6V133qtn9YFXa8tk4n VO7KHvcb/mC7MddDywgjRsid1Ro49PtUNuzEq1MGncUjwITeqHJiK0HuCXx6yw4647Xc M/9m2nrHUKo4NAYIN1uGgRfwzvtgPDzw58UgE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686826731; x=1689418731; 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=guPKntobdnOXU3BYd6z8xQJYVopEOSCbah3uJeL+Sfw=; b=IWd1hOqQg8k0RicrbWzkq/n8bdCF5yhzAv8XYBSY15ht3bTYdzmANzF7gaP5iE09sK qRWryNF4OkD5hj0LCz1xmv2+Ab80QIRno+HAXsoZ284MPYQdQGzlKpIsnUEjipXvRkeP oaLOizVE4+flLOolYt2qZCFyytSRsaD/yzatKXQYtcsuwlF0LSegVG0ajJ7pV+FYpdAU 4ad9nZddzYL7IrQ9ig90FTT6/UjJmbxTROMs2oPwpUcQS5l6FxjTnYaAuFNcQGmiA3JC 2ktnYJ5CG9D4q2FT6ghv0xdrRjEVyvoG8D+M/KdHAWwSAT/BX6OpYOxzzONnL3TSBfvV o2CA== X-Gm-Message-State: AC+VfDyQ8ClewhswcIW402djGu485YUxcZMM17YiVqjQ9PpoVH1s3Grs Gl1p4FpbTUYIkH7v2q4kvQh21g== X-Google-Smtp-Source: ACHHUZ6cP/1mx3rG6mCoceJ9Evt/5HsBXHmUVs8oH0mPAJ2eLChokCNNCJMmK0dwCKlxpnttwIgEuQ== X-Received: by 2002:a19:5045:0:b0:4f6:8156:f6e with SMTP id z5-20020a195045000000b004f681560f6emr7771691lfj.53.1686826730778; Thu, 15 Jun 2023 03:58:50 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id h7-20020ac25967000000b004f13f4ec267sm165364lfp.186.2023.06.15.03.58.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 03:58:50 -0700 (PDT) From: Rasmus Villemoes To: Alessandro Zummo , Alexandre Belloni Cc: Andy Shevchenko , devicetree@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-rtc@vger.kernel.org, Rasmus Villemoes , linux-kernel@vger.kernel.org Subject: [PATCH v3 8/8] rtc: isl12022: implement support for the #clock-cells DT property Date: Thu, 15 Jun 2023 12:58:26 +0200 Message-Id: <20230615105826.411953-9-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230615105826.411953-1-linux@rasmusvillemoes.dk> References: <20230612113059.247275-1-linux@rasmusvillemoes.dk> <20230615105826.411953-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" If device tree implies that the chip's IRQ/F_OUT pin is used as a clock, expose that in the driver. For now, pretend it is a fixed-rate (32kHz) clock; if other use cases appear the driver can be updated to provide its own clk_ops etc. When the clock output is not used on a given board, one can prolong the battery life by ensuring that the FOx bits are 0. For the hardware I'm currently working on, the RTC draws 1.2uA with the FOx bits at their default 0001 value, dropping to 0.88uA when those bits are cleared. Signed-off-by: Rasmus Villemoes --- drivers/rtc/rtc-isl12022.c | 44 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c index 916879b0388c..05f50ab0e69a 100644 --- a/drivers/rtc/rtc-isl12022.c +++ b/drivers/rtc/rtc-isl12022.c @@ -10,6 +10,7 @@ =20 #include #include +#include #include #include #include @@ -44,6 +45,9 @@ #define ISL12022_SR_LBAT75 (1 << 1) =20 #define ISL12022_INT_WRTC (1 << 6) +#define ISL12022_INT_FO_MASK GENMASK(3, 0) +#define ISL12022_INT_FO_OFF 0x0 +#define ISL12022_INT_FO_32K 0x1 =20 #define ISL12022_REG_VB85_MASK GENMASK(5, 3) #define ISL12022_REG_VB75_MASK GENMASK(2, 0) @@ -242,6 +246,41 @@ static const struct regmap_config regmap_config =3D { .use_single_write =3D true, }; =20 +static int isl12022_register_clock(struct device *dev) +{ + struct regmap *regmap =3D dev_get_drvdata(dev); + struct clk_hw *hw; + int ret; + + if (!device_property_present(dev, "#clock-cells")) { + /* + * Disabling the F_OUT pin reduces the power + * consumption in battery mode by ~25%. + */ + regmap_update_bits(regmap, ISL12022_REG_INT, ISL12022_INT_FO_MASK, + ISL12022_INT_FO_OFF); + + return 0; + } + + if (!IS_ENABLED(CONFIG_COMMON_CLK)) + return 0; + + /* + * For now, only support a fixed clock of 32768Hz (the reset default). + */ + ret =3D regmap_update_bits(regmap, ISL12022_REG_INT, + ISL12022_INT_FO_MASK, ISL12022_INT_FO_32K); + if (ret) + return ret; + + hw =3D devm_clk_hw_register_fixed_rate(dev, "isl12022", NULL, 0, 32768); + if (IS_ERR(hw)) + return PTR_ERR(hw); + + return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, hw); +} + static const u32 trip_levels[2][7] =3D { { 2125000, 2295000, 2550000, 2805000, 3060000, 4250000, 4675000 }, { 1875000, 2025000, 2250000, 2475000, 2700000, 3750000, 4125000 }, @@ -288,6 +327,7 @@ static int isl12022_probe(struct i2c_client *client) { struct rtc_device *rtc; struct regmap *regmap; + int ret; =20 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) return -ENODEV; @@ -300,6 +340,10 @@ static int isl12022_probe(struct i2c_client *client) =20 dev_set_drvdata(&client->dev, regmap); =20 + ret =3D isl12022_register_clock(&client->dev); + if (ret) + return ret; + isl12022_set_trip_levels(&client->dev); isl12022_hwmon_register(&client->dev); =20 --=20 2.37.2