2023-06-12 11:52:48

by Rasmus Villemoes

[permalink] [raw]
Subject: [PATCH 4/8] rtc: isl12022: add support for trip level DT bindings

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 <[email protected]>
---
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

+#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);
--
2.37.2



2023-06-12 16:11:20

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH 4/8] rtc: isl12022: add support for trip level DT bindings

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?

--
With Best Regards,
Andy Shevchenko



2023-06-12 18:26:53

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 4/8] rtc: isl12022: add support for trip level DT bindings

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/[email protected]/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/[email protected]
# 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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

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

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

2023-06-12 19:21:48

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 4/8] rtc: isl12022: add support for trip level DT bindings

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/[email protected]/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/[email protected]
# 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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

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

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki