Message ID | 20230612113059.247275-5-linux@rasmusvillemoes.dk |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2529352vqr; Mon, 12 Jun 2023 04:56:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5tKKjcTwZrqjqvYxvkk7We/PQU+wvxxo8hhQmyGKM/5ii0V6645ZB1m6GBMufkeYLrPtTn X-Received: by 2002:a17:90a:b8f:b0:25b:f764:580a with SMTP id 15-20020a17090a0b8f00b0025bf764580amr981307pjr.12.1686570989211; Mon, 12 Jun 2023 04:56:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686570989; cv=none; d=google.com; s=arc-20160816; b=fbGgt/MvQbhiadrMS1JPPbz9wrGOYLU+AsPipp0l+fFvxB7+ucjIzi2HS+IsdLpDOy IOAeekZ5lEqKEfxlMvdR5CpDy/hyXLgY+c4mgVeI060BluXkeyyRQSv7ykJdrCGWPhmh CI3et55mG6sUxvRBY+c55vjO6rmfLQ/Tmbf0CDUpO29oTQN96x+Lp8NLsUzHolqsiPxr +LWtALGIM5McoToZS/LJ6w4Kr2gKIC9+e3qaFalsN/Z5O8URrSiFQva4+R80Lf4iDVy6 8xd+YKEBrBZ9TT36me5tIUaQufN0FzZdqHGKorbpnmNIxo7YAfzRAHYXeY1syre2X4qV a0WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iF8XkEzBn2bI8HNyXckNnxzb/f1aF1cm8iChUnH2MYQ=; b=T1ww380XIayiVmqGKTxgeLl1hmGkepsUDXxz1DLx7gVjOAG6zTwrhz7v0HFAlo1xYu 5P+mvkOp9RR7+eZQM4lhRZyHyoKR1ljZ6DEaoDPZgwOJb9hnp2tZGb45+KELFOefsGAk +vk5s8m8ArxA1oGayRtVI5Oyvkh3oLaOosbSiPzdu7+GnP+5OfhACMPrUttTzJdZ2TP/ I10PtI5Picokq3VHr1SD/kgve8FroNHDqDyC0+QKlnrNTkWtjdQkKvnXytYFIvo3rYmI gBoPrHBxxpvVe3dnwHAuSIEIYOt9q/PtUfGULf7JRCaZE3XsCutV1GSWXsJHh0DUiBHl l+9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=iGaBlcQH; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fy1-20020a17090b020100b002507aba141asi6751416pjb.171.2023.06.12.04.56.16; Mon, 12 Jun 2023 04:56:29 -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=iGaBlcQH; 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 S232112AbjFLLjl (ORCPT <rfc822;rust.linux@gmail.com> + 99 others); Mon, 12 Jun 2023 07:39:41 -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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; Mon, 12 Jun 2023 04:31:10 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-4f649db9b25so4857691e87.0 for <linux-kernel@vger.kernel.org>; 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-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 <linux@rasmusvillemoes.dk> To: Alessandro Zummo <a.zummo@towertech.it>, Alexandre Belloni <alexandre.belloni@bootlin.com> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>, devicetree@vger.kernel.org, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Conor Dooley <conor+dt@kernel.org>, linux-rtc@vger.kernel.org, Rasmus Villemoes <linux@rasmusvillemoes.dk>, 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: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768497861840673066?= X-GMAIL-MSGID: =?utf-8?q?1768497861840673066?= |
Series |
rtc: isl12022: battery backup voltage and clock support
|
|
Commit Message
Rasmus Villemoes
June 12, 2023, 11:30 a.m. UTC
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 <linux@rasmusvillemoes.dk>
---
drivers/rtc/rtc-isl12022.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
Comments
On Mon, Jun 12, 2023 at 01:30:54PM +0200, Rasmus Villemoes wrote: > 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. ... > + for (x85 = 0; x85 < ARRAY_SIZE(trip_level85) - 1; ++x85) > + if (level85 <= trip_level85[x85]) > + break; > + > + for (x75 = 0; x75 < ARRAY_SIZE(trip_level75) - 1; ++x75) > + if (level75 <= trip_level75[x75]) > + break; Does preincrement give us anything in comparison to postincrement?
Hi Rasmus, kernel test robot noticed the following build errors: [auto build test ERROR on abelloni/rtc-next] [also build test ERROR on robh/for-next linus/master v6.4-rc6 next-20230609] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Rasmus-Villemoes/rtc-isl12022-remove-wrong-warning-for-low-battery-level/20230612-211434 base: https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next patch link: https://lore.kernel.org/r/20230612113059.247275-5-linux%40rasmusvillemoes.dk patch subject: [PATCH 4/8] rtc: isl12022: add support for trip level DT bindings config: arm-randconfig-r012-20230612 (https://download.01.org/0day-ci/archive/20230613/202306130116.8PIDa21J-lkp@intel.com/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a) reproduce (this is a W=1 build): mkdir -p ~/bin wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install arm cross compiling tool for clang build # apt-get install binutils-arm-linux-gnueabi git remote add abelloni https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git git fetch abelloni rtc-next git checkout abelloni/rtc-next b4 shazam https://lore.kernel.org/r/20230612113059.247275-5-linux@rasmusvillemoes.dk # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=arm olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/rtc/ If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202306130116.8PIDa21J-lkp@intel.com/ All errors (new ones prefixed by >>): >> drivers/rtc/rtc-isl12022.c:238:8: error: call to undeclared function 'FIELD_PREP'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 238 | val = FIELD_PREP(ISL12022_REG_VB85_MASK, x85) | FIELD_PREP(ISL12022_REG_VB75_MASK, x75); | ^ 1 error generated. vim +/FIELD_PREP +238 drivers/rtc/rtc-isl12022.c 219 220 static void isl12022_set_trip_levels(struct device *dev) 221 { 222 struct regmap *regmap = dev_get_drvdata(dev); 223 u32 level85 = 0, level75 = 0; 224 int ret, x85, x75; 225 u8 val, mask; 226 227 device_property_read_u32(dev, "isil,trip-level85-microvolt", &level85); 228 device_property_read_u32(dev, "isil,trip-level75-microvolt", &level75); 229 230 for (x85 = 0; x85 < ARRAY_SIZE(trip_level85) - 1; ++x85) 231 if (level85 <= trip_level85[x85]) 232 break; 233 234 for (x75 = 0; x75 < ARRAY_SIZE(trip_level75) - 1; ++x75) 235 if (level75 <= trip_level75[x75]) 236 break; 237 > 238 val = FIELD_PREP(ISL12022_REG_VB85_MASK, x85) | FIELD_PREP(ISL12022_REG_VB75_MASK, x75); 239 mask = ISL12022_REG_VB85_MASK | ISL12022_REG_VB75_MASK; 240 241 ret = regmap_update_bits(regmap, ISL12022_REG_PWR_VBAT, mask, val); 242 if (ret) 243 dev_warn(dev, "unable to set battery alarm levels: %d\n", ret); 244 } 245
Hi Rasmus, kernel test robot noticed the following build errors: [auto build test ERROR on abelloni/rtc-next] [also build test ERROR on robh/for-next linus/master v6.4-rc6 next-20230609] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Rasmus-Villemoes/rtc-isl12022-remove-wrong-warning-for-low-battery-level/20230612-211434 base: https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next patch link: https://lore.kernel.org/r/20230612113059.247275-5-linux%40rasmusvillemoes.dk patch subject: [PATCH 4/8] rtc: isl12022: add support for trip level DT bindings config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20230613/202306130201.ai7ck1mx-lkp@intel.com/config) compiler: alpha-linux-gcc (GCC) 12.3.0 reproduce (this is a W=1 build): mkdir -p ~/bin wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross git remote add abelloni https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git git fetch abelloni rtc-next git checkout abelloni/rtc-next b4 shazam https://lore.kernel.org/r/20230612113059.247275-5-linux@rasmusvillemoes.dk # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=alpha olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=alpha SHELL=/bin/bash drivers/ If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202306130201.ai7ck1mx-lkp@intel.com/ All errors (new ones prefixed by >>): drivers/rtc/rtc-isl12022.c: In function 'isl12022_set_trip_levels': >> drivers/rtc/rtc-isl12022.c:238:15: error: implicit declaration of function 'FIELD_PREP' [-Werror=implicit-function-declaration] 238 | val = FIELD_PREP(ISL12022_REG_VB85_MASK, x85) | FIELD_PREP(ISL12022_REG_VB75_MASK, x75); | ^~~~~~~~~~ cc1: some warnings being treated as errors vim +/FIELD_PREP +238 drivers/rtc/rtc-isl12022.c 219 220 static void isl12022_set_trip_levels(struct device *dev) 221 { 222 struct regmap *regmap = dev_get_drvdata(dev); 223 u32 level85 = 0, level75 = 0; 224 int ret, x85, x75; 225 u8 val, mask; 226 227 device_property_read_u32(dev, "isil,trip-level85-microvolt", &level85); 228 device_property_read_u32(dev, "isil,trip-level75-microvolt", &level75); 229 230 for (x85 = 0; x85 < ARRAY_SIZE(trip_level85) - 1; ++x85) 231 if (level85 <= trip_level85[x85]) 232 break; 233 234 for (x75 = 0; x75 < ARRAY_SIZE(trip_level75) - 1; ++x75) 235 if (level75 <= trip_level75[x75]) 236 break; 237 > 238 val = FIELD_PREP(ISL12022_REG_VB85_MASK, x85) | FIELD_PREP(ISL12022_REG_VB75_MASK, x75); 239 mask = ISL12022_REG_VB85_MASK | ISL12022_REG_VB75_MASK; 240 241 ret = regmap_update_bits(regmap, ISL12022_REG_PWR_VBAT, mask, val); 242 if (ret) 243 dev_warn(dev, "unable to set battery alarm levels: %d\n", ret); 244 } 245
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 +#define ISL12022_REG_PWR_VBAT 0x0a + #define ISL12022_REG_BETA 0x0d #define ISL12022_REG_TEMP_L 0x28 @@ -42,6 +44,9 @@ #define ISL12022_INT_WRTC (1 << 6) +#define ISL12022_REG_VB85_MASK GENMASK(5, 3) +#define ISL12022_REG_VB75_MASK GENMASK(2, 0) + #define ISL12022_BETA_TSE (1 << 7) static umode_t isl12022_hwmon_is_visible(const void *data, @@ -209,6 +214,35 @@ static const struct regmap_config regmap_config = { .use_single_write = true, }; +static const u32 trip_level85[] = { 2125000, 2295000, 2550000, 2805000, 3060000, 4250000, 4675000 }; +static const u32 trip_level75[] = { 1875000, 2025000, 2250000, 2475000, 2700000, 3750000, 4125000 }; + +static void isl12022_set_trip_levels(struct device *dev) +{ + struct regmap *regmap = dev_get_drvdata(dev); + u32 level85 = 0, level75 = 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 = 0; x85 < ARRAY_SIZE(trip_level85) - 1; ++x85) + if (level85 <= trip_level85[x85]) + break; + + for (x75 = 0; x75 < ARRAY_SIZE(trip_level75) - 1; ++x75) + if (level75 <= trip_level75[x75]) + break; + + val = FIELD_PREP(ISL12022_REG_VB85_MASK, x85) | FIELD_PREP(ISL12022_REG_VB75_MASK, x75); + mask = ISL12022_REG_VB85_MASK | ISL12022_REG_VB75_MASK; + + ret = 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) dev_set_drvdata(&client->dev, regmap); + isl12022_set_trip_levels(&client->dev); isl12022_hwmon_register(&client->dev); rtc = devm_rtc_allocate_device(&client->dev);