mbox series

[v4,00/10] iio: sx9324/9360: Add settings for precharge, gain and internal resistor

Message ID 20220429220144.1476049-1-gwendal@chromium.org
Headers show
Series iio: sx9324/9360: Add settings for precharge, gain and internal resistor | expand

Message

Gwendal Grignou April 29, 2022, 10:01 p.m. UTC
For Semtech sensors SX9324 and SX9360, allow confugration of the
pre-charge resistor (9324/9360) and internal resistor (9324).

Fix register name spelling mistakes first and set default value properly
for sx9324 internal resistor register.

The 9360 changes are independent from the 9324 changes, but they are
very similar.

Changes since v4:
- Add analog gain setting
- Add missing test when property is not found
- Fix dt-schema errors.

Changes since v3:
- Rename reserved field as _RESERVED_
- Fix invalid string matching with match_string()
- Fix cut and paste error in device tree bindings.

Changes since v2:
- use -ohms instead of -kohms, as ohms is a defined unit in
  dt-schema.git dtschema/schemas/property-units.yaml

Changes sinve v1:
- Add kOhm Unit, add a new patch to fix invalid register setting.

Gwendal Grignou (10):
  iio: sx9324: Fix default precharge internal resistance register
  iio: sx9324: Fix register field spelling
  dt-bindings: iio: sx9324: Add precharge resistor setting
  iio: sx9324: Add precharge internal resistance setting
  dt-bindings: iio: sx9324: Add internal compensation resistor setting
  iio: sx9324: Add Setting for internal compensation resistor
  dt-bindings: iio: sx9324: Add input analog gain
  iio: sx9324: Add Setting for internal analog gain
  dt-bindings: iio: sx9360: Add precharge resistor setting
  iio: sx9360: Add pre-charge resistor setting

 .../iio/proximity/semtech,sx9324.yaml         | 30 +++++++++
 .../iio/proximity/semtech,sx9360.yaml         |  9 +++
 drivers/iio/proximity/sx9324.c                | 66 +++++++++++++++++--
 drivers/iio/proximity/sx9360.c                | 15 ++++-
 4 files changed, 114 insertions(+), 6 deletions(-)

Comments

Jonathan Cameron May 1, 2022, 5:17 p.m. UTC | #1
On Fri, 29 Apr 2022 15:01:41 -0700
Gwendal Grignou <gwendal@chromium.org> wrote:

> Allow setting the configure the input analog gain.
> 
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>

Hi Gwendal.

So, my immediate thought on this is whether it make sense as a
dt controlled thing or not. It's the sort of thing hardwaregain
is for in the userspace ABI. However, I see that's already
in use for the digital gain. This one also unhelpfully applies
to all changes whereas the digital gain is pair wise. Hence
there is basically no way we can map the two controls to a
single ABI element.

So, how would we expect a board designer to set this value?

If the answer is we basically have no idea but some boards do
want it set then I'm fine with this basically being a somewhat magic
value that is in some vague way associated with the antenna setup...

Jonathan

> ---
> New in v5.
> 
>  .../bindings/iio/proximity/semtech,sx9324.yaml        | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
> index 0be87ac05b97a..d265eb5258c84 100644
> --- a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
> +++ b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
> @@ -143,6 +143,17 @@ properties:
>      description:
>        Pre-charge input resistance in Ohm.
>  
> +  semtech,input-analog-gain:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    minimum: 0
> +    maximum: 3
> +    description: |
> +      Defines the input antenna analog gain
> +      0: x1.247
> +      1: x1 (default)
> +      2: x0.768
> +      3: x0.552
> +
>  required:
>    - compatible
>    - reg
Rob Herring May 3, 2022, 6:02 p.m. UTC | #2
On Fri, 29 Apr 2022 15:01:41 -0700, Gwendal Grignou wrote:
> Allow setting the configure the input analog gain.
> 
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
> ---
> New in v5.
> 
>  .../bindings/iio/proximity/semtech,sx9324.yaml        | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 

Reviewed-by: Rob Herring <robh@kernel.org>
Jonathan Cameron June 4, 2022, 4:22 p.m. UTC | #3
On Fri, 29 Apr 2022 15:01:39 -0700
Gwendal Grignou <gwendal@chromium.org> wrote:

> Allow setting the internal resistor used for compensation.
> 
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
> Reviewed-by: Stephen Boyd <swboyd@chromium.org>
> Acked-by: Rob Herring <robh@kernel.org>
Applied.
> ---
> Changes since v4:
> - no changes
> 
> Changes since v3:
> - Added Review tags.
> 
> Changes since v2:
> - no changes
> 
> Changes since v1:
> - no changes
> 
>  .../bindings/iio/proximity/semtech,sx9324.yaml         | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
> index d689b2bab71b4..0be87ac05b97a 100644
> --- a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
> +++ b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9324.yaml
> @@ -126,6 +126,15 @@ properties:
>        UINT_MAX (4294967295) represents infinite. Other values
>        represent 1-1/N.
>  
> +  semtech,int-comp-resistor:
> +    description:
> +      Internal resistor setting for compensation.
> +    enum:
> +      - lowest
> +      - low
> +      - high
> +      - highest
> +
>    semtech,input-precharge-resistor-ohms:
>      default: 4000
>      multipleOf: 2000
> @@ -165,6 +174,7 @@ examples:
>          semtech,ph01-proxraw-strength = <2>;
>          semtech,ph23-proxraw-strength = <2>;
>          semtech,avg-pos-strength = <64>;
> +        semtech,int-comp-resistor = "lowest";
>          semtech,input-precharge-resistor-ohms = <2000>;
>        };
>      };