2022-10-21 12:09:21

by Matti Vaittinen

[permalink] [raw]
Subject: [PATCH v4 0/3] iio: Support ROHM/Kionix kx022a

Add initial support for ROHM/Kionix kx022a accelerometer

About the HW:
KX022A accelerometer is a sensor which:
- supports G-ranges of (+/-) 2, 4, 8, and 16G
- can be connected to I2C or SPI
- has internal HW FIFO buffer
- supports various ODRs (output data rates)
- support detecting special events like double tap or motion
- can be configured to wake-up system when events are detected.

About the series:

This series adds support for only getting the accelerometer data and
configuring the G-range / ODR via IIO. Motion detection or double-tap
detection are not supported by the series. The other quite important but
still missing piece is the runtime PM. Nevertheless, the driver should be
usable and brings the basic support for getting accelerometer data.

Changelog v4: (More detailed log in individual patches)
- KX022A: mostly styling/print fixes.
- KX022A: fix return value from IRQ thread handler.

Changelog v3: (More detailed log in individual patches)
- dt-bindings: fixed as suggested by Krzysztof
- KX022A: multiple fixes as suggested by Andy
- Fair to mention that couple of suggested changes are
not done (Some styling, boilerplate text in KConfig)
as there has been no consensus whether the suggested
changes improve situation. Ultimately the decision
whether these changes are mandatory lay on the
shoulders of the maintainers... Sorry for that.
- Enable the FIFO without module param now that the "FIFO stuck"
issue can be prevented.
- Fix potential race with time-stamp calculation when user-space
invokes the fifo flush.
- Drop the already merged regulator patches.

Changelog v2: (More detailed log in individual patches)
- dt-bindings: fixed as suggested by Krzysztof
- dt-bindings: support both INT1 and INT2
- KX022A: multiple fixes as suggested by Jonathan
- fixed SPI driver after some testing

---

Matti Vaittinen (3):
dt-bindings: iio: Add KX022A accelerometer
iio: accel: Support Kionix/ROHM KX022A accelerometer
MAINTAINERS: Add KX022A maintainer entry

.../bindings/iio/accel/kionix,kx022a.yaml | 65 +
MAINTAINERS | 5 +
drivers/iio/accel/Kconfig | 21 +
drivers/iio/accel/Makefile | 3 +
drivers/iio/accel/kionix-kx022a-i2c.c | 51 +
drivers/iio/accel/kionix-kx022a-spi.c | 58 +
drivers/iio/accel/kionix-kx022a.c | 1145 +++++++++++++++++
drivers/iio/accel/kionix-kx022a.h | 82 ++
8 files changed, 1430 insertions(+)
create mode 100644 Documentation/devicetree/bindings/iio/accel/kionix,kx022a.yaml
create mode 100644 drivers/iio/accel/kionix-kx022a-i2c.c
create mode 100644 drivers/iio/accel/kionix-kx022a-spi.c
create mode 100644 drivers/iio/accel/kionix-kx022a.c
create mode 100644 drivers/iio/accel/kionix-kx022a.h


base-commit: 9abf2313adc1ca1b6180c508c25f22f9395cc780
--
2.37.3


--
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND

~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =]


Attachments:
(No filename) (3.25 kB)
signature.asc (499.00 B)
Download all attachments

2022-10-21 12:34:41

by Matti Vaittinen

[permalink] [raw]
Subject: [PATCH v4 1/3] dt-bindings: iio: Add KX022A accelerometer

KX022A is a 3-axis Accelerometer from ROHM/Kionix. The sensor features
include variable ODRs, I2C and SPI control, FIFO/LIFO with watermark IRQ,
tap/motion detection, wake-up & back-to-sleep events, four acceleration
ranges (2, 4, 8 and 16g) and probably some other cool features.

Add the basic device tree description for the accelerometer. Only basic
accelerometer features are considered as of now - new properties may or
may not be needed in the future when rest of the features are supported.

Signed-off-by: Matti Vaittinen <[email protected]>
Reviewed-by: Krzysztof Kozlowski <[email protected]>

---
v3 => No changes.

v2 => v3 as suggested by Krzysztof:
- better check for the interrupt-names

RFCv1 => v2:
Based on a review by Krzysztof:
- fix a typo from commit message
- const compatible
- drop unnecessary descriptions/words
- io_vdd-supply => io-vdd-supply
- fix the binding example indentiation
Also,
- change my email address
- support both INT pins
---
.../bindings/iio/accel/kionix,kx022a.yaml | 65 +++++++++++++++++++
1 file changed, 65 insertions(+)
create mode 100644 Documentation/devicetree/bindings/iio/accel/kionix,kx022a.yaml

diff --git a/Documentation/devicetree/bindings/iio/accel/kionix,kx022a.yaml b/Documentation/devicetree/bindings/iio/accel/kionix,kx022a.yaml
new file mode 100644
index 000000000000..986df1a6ff0a
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/accel/kionix,kx022a.yaml
@@ -0,0 +1,65 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/accel/kionix,kx022a.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ROHM/Kionix KX022A Accelerometer
+
+maintainers:
+ - Matti Vaittinen <[email protected]>
+
+description: |
+ KX022A is a 3-axis accelerometer supporting +/- 2G, 4G, 8G and 16G ranges,
+ output data-rates from 0.78Hz to 1600Hz and a hardware-fifo buffering.
+ KX022A can be accessed either via I2C or SPI.
+
+properties:
+ compatible:
+ const: kionix,kx022a
+
+ reg:
+ maxItems: 1
+
+ interrupts:
+ minItems: 1
+ maxItems: 2
+
+ interrupt-names:
+ minItems: 1
+ items:
+ - enum: [INT1, INT2]
+ - const: INT2
+
+ vdd-supply: true
+ io-vdd-supply: true
+
+ mount-matrix:
+ description: |
+ an optional 3x3 mounting rotation matrix.
+
+required:
+ - compatible
+ - reg
+ - interrupts
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/interrupt-controller/irq.h>
+ i2c {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ accel@1f {
+ compatible = "kionix,kx022a";
+ reg = <0x1f>;
+
+ interrupt-parent = <&gpio1>;
+ interrupts = <29 IRQ_TYPE_LEVEL_LOW>;
+ interrupt-names = "INT1";
+
+ io-vdd-supply = <&iovdd>;
+ vdd-supply = <&vdd>;
+ };
+ };
--
2.37.3


--
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND

~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =]


Attachments:
(No filename) (3.29 kB)
signature.asc (499.00 B)
Download all attachments