[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240923-add-performance-tuning-configuration-v1-2-587220c8aece@gmail.com>
Date: Mon, 23 Sep 2024 09:16:11 +0800
From: Yasin Lee <yasin.lee.x@...il.com>
To: Jonathan Cameron <jic23@...nel.org>,
Lars-Peter Clausen <lars@...afoo.de>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>
Cc: linux-iio@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, Yasin Lee <yasin.lee.x@...il.com>
Subject: [PATCH 2/2] iio: proximity: hx9023s: Add performance tuning
function
When hardware design introduces significant sensor data noise,
performance can be improved by adjusting register settings.
Signed-off-by: Yasin Lee <yasin.lee.x@...il.com>
---
drivers/iio/proximity/hx9023s.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/drivers/iio/proximity/hx9023s.c b/drivers/iio/proximity/hx9023s.c
index 8b9f84400e00..963da240c9b9 100644
--- a/drivers/iio/proximity/hx9023s.c
+++ b/drivers/iio/proximity/hx9023s.c
@@ -582,6 +582,39 @@ static int hx9023s_ch_en(struct hx9023s_data *data, u8 ch_id, bool en)
return regmap_write(data->regmap, HX9023S_CH_NUM_CFG, data->ch_en_stat);
}
+static int hx9023s_performance_tuning(struct hx9023s_data *data)
+{
+ int ret;
+ u32 i, len;
+ u8 *reg_init;
+ u8 reg, val;
+ struct device *dev = regmap_get_device(data->regmap);
+ struct fwnode_handle *fwnode = dev_fwnode(dev);
+
+ ret = fwnode_property_read_u8_array(fwnode, "tyhx,performance-tuning", NULL, 0);
+ if (ret < 0)
+ return ret;
+
+ len = ret;
+ reg_init = devm_kmalloc(dev, len, GFP_KERNEL);
+ if (!reg_init)
+ return -ENOMEM;
+
+ ret = fwnode_property_read_u8_array(fwnode, "tyhx,performance-tuning", reg_init, len);
+ if (ret < 0)
+ return ret;
+
+ for (i = 0; i < len; i += 2) {
+ reg = reg_init[i];
+ val = reg_init[i + 1];
+ ret = regmap_write(data->regmap, reg, val);
+ if (ret)
+ return ret;
+ }
+
+ return ret;
+}
+
static int hx9023s_property_get(struct hx9023s_data *data)
{
struct device *dev = regmap_get_device(data->regmap);
@@ -1045,6 +1078,10 @@ static int hx9023s_probe(struct i2c_client *client)
if (ret)
return dev_err_probe(dev, ret, "channel config failed\n");
+ ret = hx9023s_performance_tuning(data);
+ if (ret)
+ dev_warn(dev, "performance tuning not configured\n");
+
ret = regcache_sync(data->regmap);
if (ret)
return dev_err_probe(dev, ret, "regcache sync failed\n");
--
2.43.0
Powered by blists - more mailing lists