From nobody Sun Feb 8 07:14:36 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 5B8A7C7EE45 for ; Mon, 12 Jun 2023 11:39:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231653AbjFLLjd (ORCPT ); Mon, 12 Jun 2023 07:39:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233676AbjFLLiY (ORCPT ); Mon, 12 Jun 2023 07:38:24 -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 BC2FF46BB for ; Mon, 12 Jun 2023 04:31:05 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-4f658a17aa4so3961597e87.0 for ; Mon, 12 Jun 2023 04:31:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1686569464; x=1689161464; 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=i4Mh2nE9YuLTcp2XbpN/eOJwtngu0h1LWO9aEmixp8l0pyW240BMU1J8Q5ABCGlWUM jI57wN1NNeplslst7Ooc8X23+g2BbnCZoA+tMrbPziCy7MgKwyoPhIguKO8jGDCei/5e sbEiItj88sX5FlOPjAzWrmWQbWCrHEad1yJ2Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686569464; x=1689161464; 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=iSqb1amk9bquV6dMbsNCJlJbgK2qTuQGheOH+sg4yyq7av1q68atAULLZV3gEhWF1o MsRocG042WcR27r5zEiUYz8D9YKwyQ+df8S8MXkHVb1cWmEHR5WzIkGpNMOWw+uPbvb1 z+sdyUQIsMyOgMQEQIg1GIJ7HzlHKvLl+fZaiaIjCaPF7QMjBg3a3X5M6P3mFU3GLmFe 0gC+C012VZGseAuLbbrNLjQCRBxEqbQ+AwS3kFmR0zr0ZeHSLuSBL0x4BYjSAfSdf9F5 Ogd1pTZkCAdxbvaXNbygvgIHFKkTSsMJ45p9tnVBI5LWAGFeYJDQqevT274iLBXfX+FX 6gTQ== X-Gm-Message-State: AC+VfDzbl+V8e2o/SkgONloMVBhrqP1oQpUs0oXPFujxEzbv3f+a0rhV DCTACNl7vs11loVH9688y2wdlQ== X-Google-Smtp-Source: ACHHUZ5X5cIhPpNI+TpxMxC3O5qv96l+D82oJntQHh+xdpggjzSo/YDmDHPdePMgi5rAGpSuAPIkUA== X-Received: by 2002:a19:7712:0:b0:4e8:c5d:42a5 with SMTP id s18-20020a197712000000b004e80c5d42a5mr3117418lfc.24.1686569463965; Mon, 12 Jun 2023 04:31:03 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id w26-20020a19c51a000000b004edb8fac1cesm1399320lfe.215.2023.06.12.04.31.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 04:31:03 -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 1/8] rtc: isl12022: remove wrong warning for low battery level Date: Mon, 12 Jun 2023 13:30:51 +0200 Message-Id: <20230612113059.247275-2-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230612113059.247275-1-linux@rasmusvillemoes.dk> References: <20230612113059.247275-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 07:14:36 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 4CD24C83005 for ; Mon, 12 Jun 2023 11:39:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234029AbjFLLjj (ORCPT ); Mon, 12 Jun 2023 07:39:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233010AbjFLLiZ (ORCPT ); Mon, 12 Jun 2023 07:38:25 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EF8346BF for ; Mon, 12 Jun 2023 04:31:07 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-4f6370ddd27so4816998e87.0 for ; Mon, 12 Jun 2023 04:31:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1686569465; x=1689161465; 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=YpuBhKsWEFwrG+U6fAOV3v6Ozr7I0OWP1C3aU0PzTV4=; b=LconL8RHpCpwjklWxyvC74ECVtkdib0L3H+oc1qrqBvkwzexWBLycAyBp4jZWjzYVF FbfFFqTLr7w3aEXgRDnHs8dWJe9JM+P+LRR7Cp506h6WBAFLpN7ANb2nvAygrAkXhKRL TcbDgzjRfLBsHxemcdzt5R6DkVdEwuyG2ChCg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686569465; x=1689161465; 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=YpuBhKsWEFwrG+U6fAOV3v6Ozr7I0OWP1C3aU0PzTV4=; b=M17ebSxCnu3E+AzdCSGWUAV7wAcIfqK7Q6GgkclJnYy5pzf6fEt7SHz0Q0uy5fxtXZ b1edg6jsnOXciEurIqg6WhV5GTHnxzswzLQjgvO1KdYxzMJ9O4OpHFeXZ7zARZygnoUw WTFGIWOxsjTmkue+mt63bD54qhPRAtegotJ4A7uai8k7b/Ajr2E0C5dOUHVtECVGwkKd SKXkNGnZqB2DVp9i03a9xvW6lq4NpV3do/x9+sNaj9nLYsXSzwBtTSLoDbeYHQ7Vy+I9 FJP6frAwx2raQA67TTi+7MAz8BmjXUL+76XTCSc8qTn9sfzrYlWlaa2XBZy5Yj7Ky4so 1KFQ== X-Gm-Message-State: AC+VfDwAU68kyq2tblsjZp//ruz9oErMmNoXaNGgwfIngYlDw5wGcPxF SpDuApwUfbE4JAl/OnlnGQafHg== X-Google-Smtp-Source: ACHHUZ6laWK/Q3Q+PhWV0V2XyJiorOzxc6mfn2Qs3Lr2FsZ8f0qQfCBXjBJIbiby1VE5xsrBnBMasw== X-Received: by 2002:a19:e34e:0:b0:4f6:21db:e584 with SMTP id c14-20020a19e34e000000b004f621dbe584mr3372913lfk.0.1686569465413; Mon, 12 Jun 2023 04:31:05 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id w26-20020a19c51a000000b004edb8fac1cesm1399320lfe.215.2023.06.12.04.31.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 04:31:04 -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 2/8] dt-bindings: rtc: Move isil,isl12022 from trivial-rtc.yaml into own schema file Date: Mon, 12 Jun 2023 13:30:52 +0200 Message-Id: <20230612113059.247275-3-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230612113059.247275-1-linux@rasmusvillemoes.dk> References: <20230612113059.247275-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. Signed-off-by: Rasmus Villemoes --- .../bindings/rtc/intersil,isl12022.yaml | 42 +++++++++++++++++++ .../devicetree/bindings/rtc/trivial-rtc.yaml | 2 - 2 files changed, 42 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..899c5edc72e4 --- /dev/null +++ b/Documentation/devicetree/bindings/rtc/intersil,isl12022.yaml @@ -0,0 +1,42 @@ +# 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 + +allOf: + - $ref: rtc.yaml# + +properties: + compatible: + const: isil,isl12022 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + +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 07:14:36 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 91310C7EE25 for ; Mon, 12 Jun 2023 11:39:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232388AbjFLLjs (ORCPT ); Mon, 12 Jun 2023 07:39:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232115AbjFLLij (ORCPT ); Mon, 12 Jun 2023 07:38:39 -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 5D04C6583 for ; Mon, 12 Jun 2023 04:31:08 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-4f6255ad8aeso4949045e87.2 for ; Mon, 12 Jun 2023 04:31:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1686569466; x=1689161466; 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=yg+ZdBpNlgvOVT9Mel57yzibQ4IWXPPH7Y7NoiRxgV8=; b=B7Fc5rs8l+9HatWL8qTZTKeUxSAhd/s0ahGyNZAoMi0LB1cmD7eWnTI573PL3J5PwY TPfEKiIAh1lyhuAV9Dcj4IVDw1BYb7kuRmglZEqct4uwgeR93b0+mxCTlkNBDESVw+eL AjL3ycniFVHhzfAU2EVnqNOKPOEGPXXhFSYlk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686569466; x=1689161466; 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=yg+ZdBpNlgvOVT9Mel57yzibQ4IWXPPH7Y7NoiRxgV8=; b=SmepOS7n1MrTwjysOrKu1jpugmyABjJgnke2g30YGyeVPnHWx+oVTL3bWo+8z1Hf/4 dSCHpTXNAuTOajusM+dfwBVAQWsuc0fJ10UEDgdhiFcAdc7n9B9V5D6hlUcSmibj/iKa NytIrYGucZgD07mVKPwEugnF0WTNAlZEYZCeasZR+kReX0FwHEtRWIRWHl7ZHrRNjT9m MDcDqJ4SV65IFnDhcQO2Zx7d6lqa16t2aThX+yop199IMVXfVsrdx7fAJm+8VCxRwsmE 238fjFJA50N2zn9asqLzc5VDietrbCKrX0ooq4uwfct0X85GPEP8Q21xJ+FvksodSeWS dsgg== X-Gm-Message-State: AC+VfDwn3pIdYNGvTcZLiOS0dMVxEqWM7J3EP6JttRP/DsqtqAGG0LCg pzutCknzn7+qe9Uh0o/zEc/W+ABRSlxZZh436QXi9A== X-Google-Smtp-Source: ACHHUZ6wSCynoIgW6K8OwvJAGylvueLACSd7ZTlBmVVHf1hvXbDrA/tV5u3JevmTNcOUlIYEHkjBtw== X-Received: by 2002:a05:6512:551:b0:4ee:e0c7:434d with SMTP id h17-20020a056512055100b004eee0c7434dmr3622544lfl.51.1686569466584; Mon, 12 Jun 2023 04:31:06 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id w26-20020a19c51a000000b004edb8fac1cesm1399320lfe.215.2023.06.12.04.31.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 04:31:06 -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 3/8] dt-bindings: rtc: isl12022: add bindings for battery alarm trip levels Date: Mon, 12 Jun 2023 13:30:53 +0200 Message-Id: <20230612113059.247275-4-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230612113059.247275-1-linux@rasmusvillemoes.dk> References: <20230612113059.247275-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 --- .../devicetree/bindings/rtc/intersil,isl12022.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Documentation/devicetree/bindings/rtc/intersil,isl12022.yaml b= /Documentation/devicetree/bindings/rtc/intersil,isl12022.yaml index 899c5edc72e4..1e85a9c8945b 100644 --- a/Documentation/devicetree/bindings/rtc/intersil,isl12022.yaml +++ b/Documentation/devicetree/bindings/rtc/intersil,isl12022.yaml @@ -19,6 +19,18 @@ properties: interrupts: maxItems: 1 =20 + isil,trip-level85-microvolt: + description: | + The battery voltage at which the first alarm should trigger + (normally ~85% of nominal V_BAT). + enum: [2125000, 2295000, 2550000, 2805000, 3060000, 4250000, 4675000] + + isil,trip-level75-microvolt: + description: | + The battery voltage at which the second alarm should trigger + (normally ~75% of nominal V_BAT). + enum: [1875000, 2025000, 2250000, 2475000, 2700000, 3750000, 4125000] + required: - compatible - reg @@ -36,6 +48,8 @@ examples: compatible =3D "isil,isl12022"; reg =3D <0x6f>; interrupts-extended =3D <&gpio1 5 IRQ_TYPE_LEVEL_LOW>; + isil,trip-level85-microvolt =3D <2550000>; + isil,trip-level75-microvolt =3D <2250000>; }; }; =20 --=20 2.37.2 From nobody Sun Feb 8 07:14:36 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 C3F33C7EE23 for ; Mon, 12 Jun 2023 11:39:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232334AbjFLLjm (ORCPT ); Mon, 12 Jun 2023 07:39:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232677AbjFLLiw (ORCPT ); Mon, 12 Jun 2023 07:38:52 -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 D5C536584 for ; Mon, 12 Jun 2023 04:31:10 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-4f649db9b25so4857691e87.0 for ; Mon, 12 Jun 2023 04:31:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1686569469; x=1689161469; 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=iF8XkEzBn2bI8HNyXckNnxzb/f1aF1cm8iChUnH2MYQ=; b=iGaBlcQHbQKwQEkolODsOCPsDLgnefvvS+vIL7gyjiXNj6hoJ4CTU4x6g60FsJywt4 W6qfm3d1pRzijQHQ1LD2X7v7gjk3H80d5bgSHg2aMqgfaNGWq6e3mb/rgHLcnvPRIyaQ 1ovayB1mEWZ7+R6EF4N43+7JwiylhiIKRza7E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686569469; x=1689161469; 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=iF8XkEzBn2bI8HNyXckNnxzb/f1aF1cm8iChUnH2MYQ=; b=G+0xS82dHeah/2NNAMHytRt9jGQbOUW7SgZe3iJy5HhOp+sTOyP/LyqoxYyMKHU3Wq x0zqxBM3CU3bZbj0XmUgxSFaLAuQ4biv1s4bFsxRGo+AD9TDBP5U08oF1nrmVnTSwPT1 s8PLrO47l8dLb7u+ClwivEUQqpnbjALSVov0KNw1Q0uMxKYaP6JzkxQN0lBYk0cbNKfe DsavkHk2DZI1Vsu33lvwzULR5q2bSccC+HFHuijwzM4kFL1zOjwEGgFwVQxocvEz4JLO 5QbbwCKMuupdJg13djuuBtwcIoQ9Be6HbQA/YORTgHpdnYERbz/ITjYUqbLU9HWGD8W0 iePA== X-Gm-Message-State: AC+VfDw1Jsz4oz7M+G3UC2Oejwq5LsS/0JJ0CZ6IDPgGbfru4shHyWBF 8tL79y4E4FVkarMeKXQfqsktng== X-Google-Smtp-Source: ACHHUZ4hOCIN8xKvfoizozIxAJRqo5eCUyzL8mIenSNp8hPEvMwHUDV7qgJAMeF19sXoZyOIvRrI+g== X-Received: by 2002:a19:d611:0:b0:4f7:434b:70b4 with SMTP id n17-20020a19d611000000b004f7434b70b4mr1470471lfg.41.1686569469275; Mon, 12 Jun 2023 04:31:09 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id w26-20020a19c51a000000b004edb8fac1cesm1399320lfe.215.2023.06.12.04.31.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 04:31:07 -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 4/8] rtc: isl12022: add support for trip level DT bindings Date: Mon, 12 Jun 2023 13:30:54 +0200 Message-Id: <20230612113059.247275-5-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230612113059.247275-1-linux@rasmusvillemoes.dk> References: <20230612113059.247275-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,trip-level[87]5-microvolt properties to set appropriate values in the VB[87]5TP bits in the PWR_VBAT register. Signed-off-by: Rasmus Villemoes --- drivers/rtc/rtc-isl12022.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c index ebd66b835cef..cb8f1d92e116 100644 --- a/drivers/rtc/rtc-isl12022.c +++ b/drivers/rtc/rtc-isl12022.c @@ -31,6 +31,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 +44,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 +214,35 @@ static const struct regmap_config regmap_config =3D { .use_single_write =3D true, }; =20 +static const u32 trip_level85[] =3D { 2125000, 2295000, 2550000, 2805000, = 3060000, 4250000, 4675000 }; +static const u32 trip_level75[] =3D { 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 level85 =3D 0, level75 =3D 0; + int ret, x85, x75; + u8 val, mask; + + device_property_read_u32(dev, "isil,trip-level85-microvolt", &level85); + device_property_read_u32(dev, "isil,trip-level75-microvolt", &level75); + + for (x85 =3D 0; x85 < ARRAY_SIZE(trip_level85) - 1; ++x85) + if (level85 <=3D trip_level85[x85]) + break; + + for (x75 =3D 0; x75 < ARRAY_SIZE(trip_level75) - 1; ++x75) + if (level75 <=3D trip_level75[x75]) + break; + + val =3D FIELD_PREP(ISL12022_REG_VB85_MASK, x85) | FIELD_PREP(ISL12022_REG= _VB75_MASK, x75); + 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 +259,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 07:14:36 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 67DF0C7EE25 for ; Mon, 12 Jun 2023 11:41:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235730AbjFLLjw (ORCPT ); Mon, 12 Jun 2023 07:39:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234589AbjFLLiw (ORCPT ); Mon, 12 Jun 2023 07:38:52 -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 46190658D for ; Mon, 12 Jun 2023 04:31:12 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-4f62cf9755eso4832613e87.1 for ; Mon, 12 Jun 2023 04:31:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1686569470; x=1689161470; 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=kq7NS+iMzs82fomvoYuidxYVGVMWQQf8sysX64TDkNs=; b=EpTSnNpebF6RNHMi7hhR1Rc9CBjLQijktT6OPL8V00DFjeXsu4j+bxPvA7nQ/3lzSv FmdlUMEtZdkle4tew7XltHFvviIEl9WjG9C9GoDTRYCh1PFUVk7fBHiCBHkeHDhZaQjs n9wtRqhnsOMq4/YnZyVe2GGzAQs7C0Q+WmFJY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686569470; x=1689161470; 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=kq7NS+iMzs82fomvoYuidxYVGVMWQQf8sysX64TDkNs=; b=OuI35JnY3OzaNdzZ8kb4JmyTyWadzIQs3l86Z3YyKNqgjLx4NkkcCx+OSZZZVf5iAp bvSS0qBMeak8xDP/NLW1UwmFNvZmc4ZYmizKIX8yGc8kSBRFGeo4nNIdth57RYSJ4Wg2 yV5rFQ4pAjddHwOz91WHcLSMdCATZzNVjjzlAeHwYA5WquwGLp/BhxVrvWKQLZiZcXAK 6OOO7uHa0or4MgnIxt62bv3glpAaZaczt8SJvAimGaKXVl4rwvJ8NYRVRwwqWhibZ5oH pAmSpBiE3131P6T4E1VcOntyKYzNwJxUi6cWTB04ZL0GZbIYuBz9ZkKkP2VB4RGAE+ph eMjA== X-Gm-Message-State: AC+VfDz8a5taiOeHQuIlLWza32B3wOZe9KwGeJzIrIiAF1y11jjfE8DI ScosvBL1GOTM8pSyttapgCyvSw== X-Google-Smtp-Source: ACHHUZ5N8xpIBWvNjUIko64UBZMsqLNzVNmlWsaXSYDuzwyjut4I6r+XRV1RCddpqnJHYdIvLcYcqA== X-Received: by 2002:a19:5f0e:0:b0:4f4:d83e:4141 with SMTP id t14-20020a195f0e000000b004f4d83e4141mr4200387lfb.50.1686569470594; Mon, 12 Jun 2023 04:31:10 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id w26-20020a19c51a000000b004edb8fac1cesm1399320lfe.215.2023.06.12.04.31.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 04:31:10 -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 5/8] rtc: isl12022: implement RTC_VL_READ and RTC_VL_CLR ioctls Date: Mon, 12 Jun 2023 13:30:55 +0200 Message-Id: <20230612113059.247275-6-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230612113059.247275-1-linux@rasmusvillemoes.dk> References: <20230612113059.247275-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 | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c index cb8f1d92e116..1b6659a9b33a 100644 --- a/drivers/rtc/rtc-isl12022.c +++ b/drivers/rtc/rtc-isl12022.c @@ -203,7 +203,48 @@ 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_read_sr(struct regmap *regmap) +{ + int ret; + u32 val; + + ret =3D regmap_read(regmap, ISL12022_REG_SR, &val); + if (ret < 0) + return ret; + return val; +} + +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 =3D 0; + int ret; + + switch (cmd) { + case RTC_VL_READ: + ret =3D isl12022_read_sr(regmap); + if (ret < 0) + return ret; + + if (ret & ISL12022_SR_LBAT85) + user |=3D RTC_VL_BACKUP_LOW; + + if (ret & ISL12022_SR_LBAT75) + user |=3D RTC_VL_BACKUP_EMPTY; + + return put_user(user, (u32 __user *)arg); + + case RTC_VL_CLR: + return regmap_clear_bits(regmap, ISL12022_REG_SR, + ISL12022_SR_LBAT85 | ISL12022_SR_LBAT75); + + 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 07:14:36 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 8B809C7EE25 for ; Mon, 12 Jun 2023 11:42:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235238AbjFLLk5 (ORCPT ); Mon, 12 Jun 2023 07:40:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234998AbjFLLix (ORCPT ); Mon, 12 Jun 2023 07:38:53 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CE8A6591 for ; Mon, 12 Jun 2023 04:31:13 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-4f61d79b0f2so5059585e87.3 for ; Mon, 12 Jun 2023 04:31:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1686569471; x=1689161471; 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=oCDq0HPnZ/JW4aurWSialUZv9qnBUgo1v/zNc5H3vQE=; b=TI8xXEHM0E1duX465xqlvlQJlUBu4kdYnE/gYUVnHchpW9NmMKbxTZ7pvXsNZ97Pyw VdSzV3IKFrAyAB5rXaWDofX5i9clGbUukci0IVENYxvf3rlTsTWPLmnoSv10Ew19MEdg l/YWMLYmrX+0ACs423hIDEnPAGTFv2+fxo8R0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686569471; x=1689161471; 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=oCDq0HPnZ/JW4aurWSialUZv9qnBUgo1v/zNc5H3vQE=; b=VP183/FDEDvQjH6DyK+U+WvbQuUV5/QFpWMk2MOETYea1+GCTmT5zltSBkkt+eFTqb 2hTsnrtVqTjbSs+oBSv0BG4b/pG9D7BfLiTFReFqfbtk3KNDFE4UNcTNv3R6pTYWEqLI qNcm7U5xPgNSjIb1Rn4UWuCVIIkuokAw++p01Y8x2bEsved5kk3cXbDxxG7M/+HDQYic SnhkkavmCgKRVdiBO//Z9YJCGQwws7Jb9YWyCgq30EqoBA4r0Kf/Qf/nTlzQnI4t/BMI LCc5iSp6TRy+dwmgaFudV7WKdUZW+BoOnxNXvCsWJLZTXMjW6jdzgyWLlWJaMe7FM92P fgkA== X-Gm-Message-State: AC+VfDwnZN5QlG/tO9ddPurwqxWT780pJcWyZd7JzLQlWUmVbLbQKFCD dXy1iMZhCmZHHb3T74lzVhwtow== X-Google-Smtp-Source: ACHHUZ6Y1cn5VIj9cr5Vm+dkpSLxN9iimVWfRCdcyU5A+yKCFy5s8duTk2D/jOxfIOpE+OpbfMhrww== X-Received: by 2002:a05:6512:3133:b0:4f6:2e4e:e425 with SMTP id p19-20020a056512313300b004f62e4ee425mr4005082lfd.50.1686569471577; Mon, 12 Jun 2023 04:31:11 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id w26-20020a19c51a000000b004edb8fac1cesm1399320lfe.215.2023.06.12.04.31.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 04:31:11 -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 6/8] rtc: isl12022: trigger battery level detection during probe Date: Mon, 12 Jun 2023 13:30:56 +0200 Message-Id: <20230612113059.247275-7-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230612113059.247275-1-linux@rasmusvillemoes.dk> References: <20230612113059.247275-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 (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 *de= v) mask =3D ISL12022_REG_VB85_MASK | ISL12022_REG_VB75_MASK; =20 ret =3D 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 =3D 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 =3D 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); + } } =20 static int isl12022_probe(struct i2c_client *client) --=20 2.37.2 From nobody Sun Feb 8 07:14:36 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 74DA3C7EE2E for ; Mon, 12 Jun 2023 11:42:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238739AbjFLLkw (ORCPT ); Mon, 12 Jun 2023 07:40:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231993AbjFLLix (ORCPT ); Mon, 12 Jun 2023 07:38: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 5DDB36598 for ; Mon, 12 Jun 2023 04:31:14 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-4f63a2e1c5fso4934047e87.2 for ; Mon, 12 Jun 2023 04:31:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1686569472; x=1689161472; 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=A/dhIkHJ/Bd/JpiRxxUt23+FRsEwSHxsnLx/azCSW6k=; b=LecpfOFA5R5ROPy2U4qCs9GjXST0XM1loQRP+J1c5EvCrAsd9vg3Ubk1q79K3T7GaL BAKxYsX2y3JPonza2iOv7Tk47bT4Po5+hRG4xdRnDdnjxbh728+YOQLt49LjKNpod2dd hoqlX3Te6x0E17igFGqYoXS8Sk3zJ8q78VKiQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686569472; x=1689161472; 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=A/dhIkHJ/Bd/JpiRxxUt23+FRsEwSHxsnLx/azCSW6k=; b=WlcWlFnPsVZj1qP+Rm/qJyltyEQpfO+vAAHKHUJ4+YR5Y0n1kSJdGnbtJiLoemOgHR KNzkAjl/sumee7jsOWpCrn07pjhIZYbGGbEZ9p7AZvxX6iFsBKOzlapC7uWW1GeJieks 8Sutc+DAY0S7VgTp+MBVZgKUGQSahHYn7Y35EvtloIsuujZYpX1RGSnYtplcNdOg1p0o 2OQJ82i+E84s8gxYAJAb6PfppQ+WKsQGyr+RleuUNoSoSKT9XG066Hf4sX+BUNyiMiH6 K0IWO4MtwzhPK+PObkORoW3T4jvrmpYEVCA/UgaKyAmX1GJbeP1+qR2RFzxulrV9EEZd pcdA== X-Gm-Message-State: AC+VfDxJomYTUUiI1e/BgbTQwgXW0nypggx1dXYvnns0/D4qPjJx6yQb 0hMeeKksrY5UQuCAjs2JNChzDA== X-Google-Smtp-Source: ACHHUZ6w5tcUE3ULY1nK4ZqT+0gZwpI40pYe1yZEZMnG7ZSDhAjpuXKbtGJjor8ogsv7s6GC6GbELw== X-Received: by 2002:a05:6512:548:b0:4f6:4a10:ac4c with SMTP id h8-20020a056512054800b004f64a10ac4cmr3872985lfl.42.1686569472698; Mon, 12 Jun 2023 04:31:12 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id w26-20020a19c51a000000b004edb8fac1cesm1399320lfe.215.2023.06.12.04.31.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 04:31:12 -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 7/8] dt-bindings: rtc: isl12022: add #clock-cells property Date: Mon, 12 Jun 2023 13:30:57 +0200 Message-Id: <20230612113059.247275-8-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230612113059.247275-1-linux@rasmusvillemoes.dk> References: <20230612113059.247275-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 --- I've tried to express the fact that the pin can either be used for interrupts or as a clock source, so that at most one of "interrupts" and "#clock-cells" can be present, but I don't really have any idea if this is the proper way to do that. .../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 1e85a9c8945b..345abed9234f 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,trip-level85-microvolt: description: | The battery voltage at which the first alarm should trigger @@ -35,6 +38,13 @@ required: - compatible - reg =20 +if: + properties: + '#clock-cells' +then: + properties: + interrupts: false + unevaluatedProperties: false =20 examples: --=20 2.37.2 From nobody Sun Feb 8 07:14:36 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 B09C9C7EE23 for ; Mon, 12 Jun 2023 11:41:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236256AbjFLLkt (ORCPT ); Mon, 12 Jun 2023 07:40:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235371AbjFLLiz (ORCPT ); Mon, 12 Jun 2023 07:38:55 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D6827EFC for ; Mon, 12 Jun 2023 04:31:15 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-4f65779894eso4082206e87.1 for ; Mon, 12 Jun 2023 04:31:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1686569473; x=1689161473; 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=zVISWVLRgW0K7WAKXrrtHEIUr0IbbMXljAPQm1SU8cU=; b=GUirDWmfHeI1PQqvm31QSDtYOSZU83I1TUeXFUGgB/IDFtareX0LOnPd3d4MHo+SvB /LriIHBvcpXzsvClIDa/fc3We2zpJVGoy8P+UZa977vOiVipohu/T/bqQtLI3dndRweE fEQPS78uw6+XpzyHIeyu5jhU2lVehHPDZUZOY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686569473; x=1689161473; 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=zVISWVLRgW0K7WAKXrrtHEIUr0IbbMXljAPQm1SU8cU=; b=L6RffE/rIYnFxiBXu6PAihLyGam+1HSo50FJ/Dw6bxa7SdTTaP1DOUANV9jS//2uY/ CduGdq6yfKYX9ErjSb0VKWx4a4hiAktRoL6sVwiPpPm9oAYDR2ct1kKVQDdsFvvwhmJP V62tKawWaZe1JqbpiFbOyTk/x9PsGKHRRCRd5dSOLmfko9Todwzl99hOyqOOg3K2AGOK AiRU6CPr19ZKUchYHkjdMcR6380BShrJQTUyYQEpTu3/bAUSU5Zum4l6xxl6Vi6Edbxb kZkPaUh9JcRGAzg+KUn2IOMp/0JK/TSH1FMzy7MukOGN1Mex/YqsGWOzNr7faOG5+rc0 DPTA== X-Gm-Message-State: AC+VfDzUy08O1oMQ32q7ZisXb3mfFDFrfnv+3vQYCYbFaOC+qq7Xysn9 ZVqj2pgkJcqDaCrAeCk7JBr4Dg== X-Google-Smtp-Source: ACHHUZ4DO2f4AqARomXkmwy7A7bD4vgSbeOpkJmstbgRVEc/JnlEHVFXdAUVaNOIfvdiIbVhuxyX0g== X-Received: by 2002:ac2:465d:0:b0:4f4:b28d:73e8 with SMTP id s29-20020ac2465d000000b004f4b28d73e8mr3067413lfo.17.1686569473683; Mon, 12 Jun 2023 04:31:13 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id w26-20020a19c51a000000b004edb8fac1cesm1399320lfe.215.2023.06.12.04.31.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 04:31:13 -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 8/8] rtc: isl12022: implement support for the #clock-cells DT property Date: Mon, 12 Jun 2023 13:30:58 +0200 Message-Id: <20230612113059.247275-9-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230612113059.247275-1-linux@rasmusvillemoes.dk> References: <20230612113059.247275-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 | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c index 690dbb446d1a..0054300b744b 100644 --- a/drivers/rtc/rtc-isl12022.c +++ b/drivers/rtc/rtc-isl12022.c @@ -9,6 +9,7 @@ */ =20 #include +#include #include #include #include @@ -43,6 +44,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) @@ -255,6 +259,38 @@ 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%. + */ + ret =3D regmap_update_bits(regmap, ISL12022_REG_INT, ISL12022_INT_FO_MAS= K, + ISL12022_INT_FO_OFF); + if (ret) + dev_warn(dev, "failed to clear FOx bits in INT register: %d", ret); + 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_32kHz", NULL, 0, 32= 768); + 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_level85[] =3D { 2125000, 2295000, 2550000, 2805000, = 3060000, 4250000, 4675000 }; static const u32 trip_level75[] =3D { 1875000, 2025000, 2250000, 2475000, = 2700000, 3750000, 4125000 }; =20 @@ -305,6 +341,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; @@ -317,6 +354,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