devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/3] Add driver for Nicera D3-323-AA PIR sensor
@ 2025-07-04 16:14 Waqar Hameed
  2025-07-04 16:14 ` [PATCH v3 1/3] dt-bindings: vendor-prefixes: Add Nicera Waqar Hameed
  2025-07-04 16:14 ` [PATCH v3 2/3] dt-bindings: iio: proximity: Add Nicera D3-323-AA PIR sensor Waqar Hameed
  0 siblings, 2 replies; 5+ messages in thread
From: Waqar Hameed @ 2025-07-04 16:14 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko
  Cc: kernel, devicetree, linux-kernel, linux-iio

Nicera D3-323-AA is a PIR sensor for human detection. It has support for
raw data measurements and detection notification. The communication
protocol is custom made and therefore needs to be GPIO bit banged.

Previously, there has been an attempt to add a driver for this device
[1]. However, that driver was written for the wrong sub-system. `hwmon`
is clearly not a suitable framework for a proximity device.

In this series, we add a driver for support for event notification for
detections through IIO (the more appropriate sub-system!). The various
settings have been mapped to existing `sysfs` ABIs in the IIO framework.

The public datasheet [2] is quite sparse. A more detailed version can be
obtained through the company.

[1] https://lore.kernel.org/lkml/20241212042412.702044-2-Hermes.Zhang@axis.com/
[2] https://www.endrich.com/Datenbl%C3%A4tter/Sensoren/D3-323-AA_e.pdf

Changes in v3:

[dt-bindings]
* Re-add gpio include header and use a constant from that header.

[iio]
* Convert `irq_reset_count` from `atomic_t` into an `u8`.
* Add a comment in `d3323aa_reset()` explaining
  `regulator_is_enabled()`-check is for `probe()`.
* Use `flseep()` in places where the delay is flexible.
* Rephrase comment about enabling VDD and counting falling edges.
* Declare and use a variable for `struct device*` in `probe()`.
* Remove impossible error print for `devm_add_action_or_reset()`.
* Add a comment for `devm_add_action_or_reset()` call in
  `d3323aa_probe()` explaining when the regulator is enabled.
* Add a comment clarifying the `regulator_is_enabled()` check in
  `d3323aa_disable_regulator()`.
* Change `-ERANGE` return values to `-EINVAL` for the set-functions in
  `d3323aa_write_raw()`.

Link to v2: https://lore.kernel.org/lkml/cover.1749938844.git.waqar.hameed@axis.com/

Changes in v2:

[dt-bindings]
* Convert `vdd-gpio` to a `vdd-supply`.
* Rename `clk-vout-gpio` to `vout-clk-gpios`.
* Add description for `data-gpios` explaining the rename to a more
  descriptive name.
* Drop all references to driver.
* Remove unused gpio include in examples.
* Re-phrase commit message to only describe the hardware.

[iio]
* Add newline after variable definitions inside the for-loop in
  `d3323aa_set_lp_filter_freq()`.
* Remove error code in string in `dev_err_probe()`.
* Remove driver name macro and use it inline instead.
* Format filter gain arrays into one line.
* Drop structure comment in `probe()`.
* Format sentinel value in `of_device_id` with a space.
* Rename `gpiod_clk_vout` to `gpiod_clkin_detectout`.
* Request `vout-clk` GPIO to match rename in dt-bindings.
* Use the regulator framework for supply voltage.
* Use only one IRQ handler for both reset and detection.
* Reword comment about Vout/CLK ramp-up behavior (it's because of VDD charging
  up).
* Add comment for why we have both `IRQF_TRIGGER_RISING` and
  `IRQF_TRIGGER_FALLING`.
* Rename `regmap` to `regbitmap` to not confuse with the `regmap`-framework.
* Move `d3323aa_setup()` into the set-functions.
* Use state variables in `d3323aa_data` instead of bitmap and move bitmap
  handling to read/write settings functions.
* Pad bitmap with compulsory end pattern in `d3323aa_write_settings()`.
* Add `d3323aa_set_hp_filter_freq()` and allow userspace to set it.

Link to v1: https://lore.kernel.org/lkml/cover.1746802541.git.waqar.hameed@axis.com/

Waqar Hameed (3):
  dt-bindings: vendor-prefixes: Add Nicera
  dt-bindings: iio: proximity: Add Nicera D3-323-AA PIR sensor
  iio: Add driver for Nicera D3-323-AA PIR sensor

 .../iio/proximity/nicera,d3323aa.yaml         |  62 ++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 drivers/iio/proximity/Kconfig                 |   9 +
 drivers/iio/proximity/Makefile                |   1 +
 drivers/iio/proximity/d3323aa.c               | 814 ++++++++++++++++++
 5 files changed, 888 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/proximity/nicera,d3323aa.yaml
 create mode 100644 drivers/iio/proximity/d3323aa.c


base-commit: 66701750d5565c574af42bef0b789ce0203e3071
-- 
2.39.5


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3 1/3] dt-bindings: vendor-prefixes: Add Nicera
  2025-07-04 16:14 [PATCH v3 0/3] Add driver for Nicera D3-323-AA PIR sensor Waqar Hameed
@ 2025-07-04 16:14 ` Waqar Hameed
  2025-07-04 16:14 ` [PATCH v3 2/3] dt-bindings: iio: proximity: Add Nicera D3-323-AA PIR sensor Waqar Hameed
  1 sibling, 0 replies; 5+ messages in thread
From: Waqar Hameed @ 2025-07-04 16:14 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: kernel, Rob Herring, devicetree, linux-kernel, linux-iio

Nicera (Nippon Ceramic Co.) is a manufacturer of a wide range of
sensors. For example infrared, ultrasonic, gas sensors and much more.

Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index 5d2a7a8d3ac6..9df4cb54eea9 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -1067,6 +1067,8 @@ patternProperties:
     description: Next Thing Co.
   "^ni,.*":
     description: National Instruments
+  "^nicera,.*":
+    description: Nippon Ceramic Co., Ltd.
   "^nintendo,.*":
     description: Nintendo
   "^nlt,.*":
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v3 2/3] dt-bindings: iio: proximity: Add Nicera D3-323-AA PIR sensor
  2025-07-04 16:14 [PATCH v3 0/3] Add driver for Nicera D3-323-AA PIR sensor Waqar Hameed
  2025-07-04 16:14 ` [PATCH v3 1/3] dt-bindings: vendor-prefixes: Add Nicera Waqar Hameed
@ 2025-07-04 16:14 ` Waqar Hameed
  2025-07-06 10:53   ` Jonathan Cameron
  2025-07-07  6:44   ` Krzysztof Kozlowski
  1 sibling, 2 replies; 5+ messages in thread
From: Waqar Hameed @ 2025-07-04 16:14 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: kernel, linux-iio, devicetree, linux-kernel

Nicera D3-323-AA is a PIR sensor for human detection. It has two GPIOs
for detection and data communication.

Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
---
 .../iio/proximity/nicera,d3323aa.yaml         | 62 +++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/proximity/nicera,d3323aa.yaml

diff --git a/Documentation/devicetree/bindings/iio/proximity/nicera,d3323aa.yaml b/Documentation/devicetree/bindings/iio/proximity/nicera,d3323aa.yaml
new file mode 100644
index 000000000000..65d9b44fcd5e
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/proximity/nicera,d3323aa.yaml
@@ -0,0 +1,62 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/proximity/nicera,d3323aa.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nicera D3-323-AA PIR sensor
+
+maintainers:
+  - Waqar Hameed <waqar.hameed@axis.com>
+
+description: |
+  PIR sensor for human detection.
+  Datasheet: https://www.endrich.com/Datenbl%C3%A4tter/Sensoren/D3-323-AA_e.pdf
+
+properties:
+  compatible:
+    const: nicera,d3323aa
+
+  vdd-supply:
+    description:
+      Supply voltage (1.8 to 5.5 V).
+
+  vout-clk-gpios:
+    maxItems: 1
+    description:
+      GPIO for clock and detection.
+      After reset, the device signals with two falling edges on this pin that it
+      is ready for configuration (within 1.2 s).
+      During configuration, it is used as clock for data reading and writing (on
+      data-gpios).
+      After all this, when device is in operational mode, it signals on this pin
+      for any detections.
+
+  data-gpios:
+    maxItems: 1
+    description:
+      GPIO for data reading and writing. This is denoted "DO (SI)" in datasheet.
+      During configuration, this pin is used for writing and reading
+      configuration data (together with vout-clk-gpios as clock).
+      After this, during operational mode, the device will output serial data on
+      this GPIO.
+
+required:
+  - compatible
+  - vdd-supply
+  - vout-clk-gpios
+  - data-gpios
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    proximity {
+        compatible = "nicera,d3323aa";
+        vdd-supply = <&regulator_3v3>;
+        vout-clk-gpios = <&gpio 78 GPIO_ACTIVE_HIGH>;
+        data-gpios = <&gpio 76 GPIO_ACTIVE_HIGH>;
+    };
+...
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 2/3] dt-bindings: iio: proximity: Add Nicera D3-323-AA PIR sensor
  2025-07-04 16:14 ` [PATCH v3 2/3] dt-bindings: iio: proximity: Add Nicera D3-323-AA PIR sensor Waqar Hameed
@ 2025-07-06 10:53   ` Jonathan Cameron
  2025-07-07  6:44   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2025-07-06 10:53 UTC (permalink / raw)
  To: Waqar Hameed
  Cc: David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, kernel, linux-iio, devicetree,
	linux-kernel

On Fri, 4 Jul 2025 18:14:38 +0200
Waqar Hameed <waqar.hameed@axis.com> wrote:

> Nicera D3-323-AA is a PIR sensor for human detection. It has two GPIOs
> for detection and data communication.
> 
> Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
> ---
>  .../iio/proximity/nicera,d3323aa.yaml         | 62 +++++++++++++++++++
>  1 file changed, 62 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/iio/proximity/nicera,d3323aa.yaml
> 
> diff --git a/Documentation/devicetree/bindings/iio/proximity/nicera,d3323aa.yaml b/Documentation/devicetree/bindings/iio/proximity/nicera,d3323aa.yaml
> new file mode 100644
> index 000000000000..65d9b44fcd5e
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/proximity/nicera,d3323aa.yaml
> @@ -0,0 +1,62 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/iio/proximity/nicera,d3323aa.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Nicera D3-323-AA PIR sensor
> +
> +maintainers:
> +  - Waqar Hameed <waqar.hameed@axis.com>
> +
> +description: |
> +  PIR sensor for human detection.
> +  Datasheet: https://www.endrich.com/Datenbl%C3%A4tter/Sensoren/D3-323-AA_e.pdf
> +
> +properties:
> +  compatible:
> +    const: nicera,d3323aa
> +
> +  vdd-supply:
> +    description:
> +      Supply voltage (1.8 to 5.5 V).
> +
> +  vout-clk-gpios:
> +    maxItems: 1
> +    description:
> +      GPIO for clock and detection.
> +      After reset, the device signals with two falling edges on this pin that it
> +      is ready for configuration (within 1.2 s).
> +      During configuration, it is used as clock for data reading and writing (on
> +      data-gpios).
> +      After all this, when device is in operational mode, it signals on this pin
> +      for any detections.

Don't start a new line for a new sentence. 

> +
> +  data-gpios:
> +    maxItems: 1
> +    description:
> +      GPIO for data reading and writing. This is denoted "DO (SI)" in datasheet.
> +      During configuration, this pin is used for writing and reading
> +      configuration data (together with vout-clk-gpios as clock).
> +      After this, during operational mode, the device will output serial data on
> +      this GPIO.
> +
> +required:
> +  - compatible
> +  - vdd-supply
> +  - vout-clk-gpios
> +  - data-gpios
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/gpio/gpio.h>
> +
> +    proximity {
> +        compatible = "nicera,d3323aa";
> +        vdd-supply = <&regulator_3v3>;
> +        vout-clk-gpios = <&gpio 78 GPIO_ACTIVE_HIGH>;
> +        data-gpios = <&gpio 76 GPIO_ACTIVE_HIGH>;
> +    };
> +...


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 2/3] dt-bindings: iio: proximity: Add Nicera D3-323-AA PIR sensor
  2025-07-04 16:14 ` [PATCH v3 2/3] dt-bindings: iio: proximity: Add Nicera D3-323-AA PIR sensor Waqar Hameed
  2025-07-06 10:53   ` Jonathan Cameron
@ 2025-07-07  6:44   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2025-07-07  6:44 UTC (permalink / raw)
  To: Waqar Hameed
  Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, kernel, linux-iio,
	devicetree, linux-kernel

On Fri, Jul 04, 2025 at 06:14:38PM +0200, Waqar Hameed wrote:
> Nicera D3-323-AA is a PIR sensor for human detection. It has two GPIOs
> for detection and data communication.
> 
> Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
> ---
>  .../iio/proximity/nicera,d3323aa.yaml         | 62 +++++++++++++++++++
>  1 file changed, 62 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/iio/proximity/nicera,d3323aa.yaml

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-07-07  6:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-04 16:14 [PATCH v3 0/3] Add driver for Nicera D3-323-AA PIR sensor Waqar Hameed
2025-07-04 16:14 ` [PATCH v3 1/3] dt-bindings: vendor-prefixes: Add Nicera Waqar Hameed
2025-07-04 16:14 ` [PATCH v3 2/3] dt-bindings: iio: proximity: Add Nicera D3-323-AA PIR sensor Waqar Hameed
2025-07-06 10:53   ` Jonathan Cameron
2025-07-07  6:44   ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).