* [PATCH v2 0/2] iio: proximity: hx9023s: Add performance tuning function
@ 2024-09-25 16:40 Yasin Lee
2024-09-25 16:40 ` [PATCH v2 1/2] dt-bindings: iio: tyhx,hx9023s: Add performance tuning configuration Yasin Lee
2024-09-25 16:40 ` [PATCH v2 2/2] iio: proximity: hx9023s: Add performance tuning function Yasin Lee
0 siblings, 2 replies; 5+ messages in thread
From: Yasin Lee @ 2024-09-25 16:40 UTC (permalink / raw)
To: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, yasin.lee.x
Cc: linux-iio, devicetree, linux-kernel, Yasin Lee
When hardware design introduces significant sensor data noise,
performance can be improved by adjusting register settings.
Signed-off-by: Yasin Lee <yasin.lee.x@gmail.com>
---
Changes in v2:
- In the YAML file, boundary constraints have been applied to the `tyhx,performance-tuning` property, requiring the number of elements to be between 2 and 512. The description also informs users that the number of elements must be a multiple of 2.
- In the function implementation, boundary checks have been added for this property, ensuring that the number of elements is even.
- Link to v1: https://lore.kernel.org/r/20240923-add-performance-tuning-configuration-v1-0-587220c8aece@gmail.com
---
Yasin Lee (2):
dt-bindings: iio: tyhx,hx9023s: Add performance tuning configuration
iio: proximity: hx9023s: Add performance tuning function
.../bindings/iio/proximity/tyhx,hx9023s.yaml | 19 +++++++++
drivers/iio/proximity/hx9023s.c | 45 ++++++++++++++++++++++
2 files changed, 64 insertions(+)
---
base-commit: 7f6f44a9e58cd19093b544423bc04e1d668ec341
change-id: 20240923-add-performance-tuning-configuration-e2016e4d6e02
Best regards,
--
Yasin Lee <yasin.lee.x@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] dt-bindings: iio: tyhx,hx9023s: Add performance tuning configuration
2024-09-25 16:40 [PATCH v2 0/2] iio: proximity: hx9023s: Add performance tuning function Yasin Lee
@ 2024-09-25 16:40 ` Yasin Lee
2024-09-26 6:53 ` Krzysztof Kozlowski
2024-09-25 16:40 ` [PATCH v2 2/2] iio: proximity: hx9023s: Add performance tuning function Yasin Lee
1 sibling, 1 reply; 5+ messages in thread
From: Yasin Lee @ 2024-09-25 16:40 UTC (permalink / raw)
To: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, yasin.lee.x
Cc: linux-iio, devicetree, linux-kernel, Yasin Lee
When hardware design introduces significant sensor data noise,
performance can be improved by adjusting register settings.
Signed-off-by: Yasin Lee <yasin.lee.x@gmail.com>
---
.../bindings/iio/proximity/tyhx,hx9023s.yaml | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/Documentation/devicetree/bindings/iio/proximity/tyhx,hx9023s.yaml b/Documentation/devicetree/bindings/iio/proximity/tyhx,hx9023s.yaml
index 64ce8bc8bd36..0673c40472bd 100644
--- a/Documentation/devicetree/bindings/iio/proximity/tyhx,hx9023s.yaml
+++ b/Documentation/devicetree/bindings/iio/proximity/tyhx,hx9023s.yaml
@@ -28,6 +28,18 @@ properties:
vdd-supply: true
+ tyhx,performance-tuning:
+ description:
+ Optional, When hardware design introduces significant sensor data noise,
+ performance can be improved by adjusting register settings, including
+ but not limited to sample integration time and average sample count.
+ Performance tuning parameters represented as register address-value pairs.
+ The array consists of 8-bit values, where each pair represents a register
+ address followed by the value to be written to that register.
+ $ref: /schemas/types.yaml#/definitions/uint8-array
+ minItems: 2
+ maxItems: 512
+
"#address-cells":
const: 1
@@ -65,6 +77,13 @@ examples:
interrupt-parent = <&pio>;
interrupts = <16 IRQ_TYPE_EDGE_FALLING>;
vdd-supply = <&pp1800_prox>;
+ tyhx,performance-tuning = [00 00
+ 02 17
+ 0D 44
+ 0E 44
+ 0F 04
+ 1F 65
+ 21 65];
#address-cells = <1>;
#size-cells = <0>;
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] iio: proximity: hx9023s: Add performance tuning function
2024-09-25 16:40 [PATCH v2 0/2] iio: proximity: hx9023s: Add performance tuning function Yasin Lee
2024-09-25 16:40 ` [PATCH v2 1/2] dt-bindings: iio: tyhx,hx9023s: Add performance tuning configuration Yasin Lee
@ 2024-09-25 16:40 ` Yasin Lee
1 sibling, 0 replies; 5+ messages in thread
From: Yasin Lee @ 2024-09-25 16:40 UTC (permalink / raw)
To: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, yasin.lee.x
Cc: linux-iio, devicetree, linux-kernel, Yasin Lee
When hardware design introduces significant sensor data noise,
performance can be improved by adjusting register settings.
Signed-off-by: Yasin Lee <yasin.lee.x@gmail.com>
---
drivers/iio/proximity/hx9023s.c | 45 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/drivers/iio/proximity/hx9023s.c b/drivers/iio/proximity/hx9023s.c
index 8b9f84400e00..8f7995816545 100644
--- a/drivers/iio/proximity/hx9023s.c
+++ b/drivers/iio/proximity/hx9023s.c
@@ -582,6 +582,47 @@ 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 addr_val[512];
+ struct device *dev = regmap_get_device(data->regmap);
+ struct fwnode_handle *fwnode = dev_fwnode(dev);
+
+ ret = fwnode_property_count_u8(fwnode, "tyhx,performance-tuning");
+ if (ret < 2 || ret > 512) {
+ if (ret < 0) {
+ dev_err(dev, "Failed to get length of property\n");
+ return ret;
+ }
+ dev_err(dev, "The property requires between 2 and 512 elements\n");
+ return -EINVAL;
+ }
+
+ len = ret;
+ if (len % 2 != 0) {
+ dev_err(dev, "The property must contain an even number of elements\n");
+ return -EINVAL;
+ }
+
+ ret = fwnode_property_read_u8_array(fwnode, "tyhx,performance-tuning", addr_val, len);
+ if (ret < 0) {
+ dev_err(dev, "Failed to read property\n");
+ return ret;
+ }
+
+ for (i = 0; i < len; i += 2) {
+ ret = regmap_write(data->regmap, addr_val[i], addr_val[i + 1]);
+ if (ret) {
+ dev_err(dev, "Failed to write register\n");
+ return ret;
+ }
+ }
+
+ return ret;
+}
+
static int hx9023s_property_get(struct hx9023s_data *data)
{
struct device *dev = regmap_get_device(data->regmap);
@@ -1045,6 +1086,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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: iio: tyhx,hx9023s: Add performance tuning configuration
2024-09-25 16:40 ` [PATCH v2 1/2] dt-bindings: iio: tyhx,hx9023s: Add performance tuning configuration Yasin Lee
@ 2024-09-26 6:53 ` Krzysztof Kozlowski
2024-09-26 7:58 ` Yasin Lee
0 siblings, 1 reply; 5+ messages in thread
From: Krzysztof Kozlowski @ 2024-09-26 6:53 UTC (permalink / raw)
To: Yasin Lee
Cc: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, yasin.lee.x, linux-iio,
devicetree, linux-kernel
On Thu, Sep 26, 2024 at 12:40:17AM +0800, Yasin Lee wrote:
> When hardware design introduces significant sensor data noise,
> performance can be improved by adjusting register settings.
>
> Signed-off-by: Yasin Lee <yasin.lee.x@gmail.com>
> ---
> .../bindings/iio/proximity/tyhx,hx9023s.yaml | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/iio/proximity/tyhx,hx9023s.yaml b/Documentation/devicetree/bindings/iio/proximity/tyhx,hx9023s.yaml
> index 64ce8bc8bd36..0673c40472bd 100644
> --- a/Documentation/devicetree/bindings/iio/proximity/tyhx,hx9023s.yaml
> +++ b/Documentation/devicetree/bindings/iio/proximity/tyhx,hx9023s.yaml
> @@ -28,6 +28,18 @@ properties:
>
> vdd-supply: true
>
> + tyhx,performance-tuning:
> + description:
> + Optional, When hardware design introduces significant sensor data noise,
> + performance can be improved by adjusting register settings, including
> + but not limited to sample integration time and average sample count.
> + Performance tuning parameters represented as register address-value pairs.
> + The array consists of 8-bit values, where each pair represents a register
> + address followed by the value to be written to that register.
> + $ref: /schemas/types.yaml#/definitions/uint8-array
I think you wanted here in such case uint8-matrix with one dimension set
to two and other 256 or whatever.
I also wonder why do allow any register to be tuned. To me "tuning"
sounds like improving or tweaking the configuration, so for example I
would not expect to change some control-like registers, e.g. interrupts,
enable/disable, reset etc.
> + minItems: 2
> + maxItems: 512
> +
> "#address-cells":
> const: 1
>
> @@ -65,6 +77,13 @@ examples:
> interrupt-parent = <&pio>;
> interrupts = <16 IRQ_TYPE_EDGE_FALLING>;
> vdd-supply = <&pp1800_prox>;
> + tyhx,performance-tuning = [00 00
This above is clearing entirely the GLOBAL_CTRL0 register, which is not
tuning.
You are basically avoiding hardware description as properties in DT and
just dump a blob.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: iio: tyhx,hx9023s: Add performance tuning configuration
2024-09-26 6:53 ` Krzysztof Kozlowski
@ 2024-09-26 7:58 ` Yasin Lee
0 siblings, 0 replies; 5+ messages in thread
From: Yasin Lee @ 2024-09-26 7:58 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, yasin.lee.x, linux-iio,
devicetree, linux-kernel
On 9/26/24 14:53, Krzysztof Kozlowski wrote:
> On Thu, Sep 26, 2024 at 12:40:17AM +0800, Yasin Lee wrote:
>> When hardware design introduces significant sensor data noise,
>> performance can be improved by adjusting register settings.
>>
>> Signed-off-by: Yasin Lee <yasin.lee.x@gmail.com>
>> ---
>> .../bindings/iio/proximity/tyhx,hx9023s.yaml | 19 +++++++++++++++++++
>> 1 file changed, 19 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/iio/proximity/tyhx,hx9023s.yaml b/Documentation/devicetree/bindings/iio/proximity/tyhx,hx9023s.yaml
>> index 64ce8bc8bd36..0673c40472bd 100644
>> --- a/Documentation/devicetree/bindings/iio/proximity/tyhx,hx9023s.yaml
>> +++ b/Documentation/devicetree/bindings/iio/proximity/tyhx,hx9023s.yaml
>> @@ -28,6 +28,18 @@ properties:
>>
>> vdd-supply: true
>>
>> + tyhx,performance-tuning:
>> + description:
>> + Optional, When hardware design introduces significant sensor data noise,
>> + performance can be improved by adjusting register settings, including
>> + but not limited to sample integration time and average sample count.
>> + Performance tuning parameters represented as register address-value pairs.
>> + The array consists of 8-bit values, where each pair represents a register
>> + address followed by the value to be written to that register.
>> + $ref: /schemas/types.yaml#/definitions/uint8-array
> I think you wanted here in such case uint8-matrix with one dimension set
> to two and other 256 or whatever.
>
> I also wonder why do allow any register to be tuned. To me "tuning"
> sounds like improving or tweaking the configuration, so for example I
> would not expect to change some control-like registers, e.g. interrupts,
> enable/disable, reset etc.
>
>
>> + minItems: 2
>> + maxItems: 512
>> +
>> "#address-cells":
>> const: 1
>>
>> @@ -65,6 +77,13 @@ examples:
>> interrupt-parent = <&pio>;
>> interrupts = <16 IRQ_TYPE_EDGE_FALLING>;
>> vdd-supply = <&pp1800_prox>;
>> + tyhx,performance-tuning = [00 00
> This above is clearing entirely the GLOBAL_CTRL0 register, which is not
> tuning.
>
> You are basically avoiding hardware description as properties in DT and
> just dump a blob.
>
>
> Best regards,
> Krzysztof
Hi Krzysztof,
Thank you for your feedback.
You're absolutely right about the operation on the 00 register. That was
indeed a mistake on my part, and it was not my intention to clear the
GLOBAL_CTRL0 register. It was only meant to serve as an example.
I also now understand that importing a data block in this manner doesn't
align with the design philosophy of device trees. Moving forward, I will
abstract each possible tuning configuration into separate properties.
Since there are quite a few properties to handle, this will result in a
larger codebase.
Given the additional work required, I will take a few more days to
revise the patch and resubmit it.
Thank you again for your valuable input.
Best regards,
Yasin Lee
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-09-26 7:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-25 16:40 [PATCH v2 0/2] iio: proximity: hx9023s: Add performance tuning function Yasin Lee
2024-09-25 16:40 ` [PATCH v2 1/2] dt-bindings: iio: tyhx,hx9023s: Add performance tuning configuration Yasin Lee
2024-09-26 6:53 ` Krzysztof Kozlowski
2024-09-26 7:58 ` Yasin Lee
2024-09-25 16:40 ` [PATCH v2 2/2] iio: proximity: hx9023s: Add performance tuning function Yasin Lee
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®