Skip to contentSkip to conversation

dt-bindings: iio: accel: adxl313: Add compatibles for adxl312 and adxl314

PATCH New George Mois 1 participant 2 messages Sep 5, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/2 dt-bindings: iio: accel: adxl313: Add compatibles for adxl312 and adxl314

Extend the adi,adxl313.yaml file with information regrding the ADXL312 and ADXL314 devices.

---
changes in v4:
- rename patch title to comply with dt-bindings patches title format

 .../devicetree/bindings/iio/accel/adi,adxl313.yaml     | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/iio/accel/adi,adxl313.yaml +7 -3
index d6afc1b8c272..59d48ff1a16c 100644
@@ -4,20 +4,24 @@
 $id: http://devicetree.org/schemas/iio/accel/adi,adxl313.yaml#
 $schema: http://devicetree.org/meta-schemas/core.yaml#
 
-title: Analog Devices ADXL313 3-Axis Digital Accelerometer
+title: Analog Devices ADXL312, ADXL313, and ADXL314 3-Axis Digital Accelerometers
 
 maintainers:
   - Lucas Stankus <[email protected]>
 
 description: |
-  Analog Devices ADXL313 3-Axis Digital Accelerometer that supports
-  both I2C & SPI interfaces.
+  Analog Devices ADXL312, ADXL313, and ADXL314 3-Axis Digital Accelerometer that
+  support both I2C & SPI interfaces.
+    https://www.analog.com/en/products/adxl312.html
     https://www.analog.com/en/products/adxl313.html
+    https://www.analog.com/en/products/adxl314.html
 
 properties:
   compatible:
     enum:
+      - adi,adxl312
       - adi,adxl313
+      - adi,adxl314
 
   reg:
     maxItems: 1
Signature · 1 line
2.30.2
#1 lore raw

PATCH v4 2/2 drivers: iio: accel: adxl312 and adxl314 support

ADXL312 and ADXL314 are small, thin, low power, 3-axis accelerometers with high resolution (13-bit) measurement up to +/-12 g and +/- 200 g respectively.

Implement support for ADXL312 and ADXL314 by extending the ADXL313 driver.

Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/ADXL312.pdf
Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/ADXL314.pdf

---
changes in v4:
- remove blank line after Datasheet
- rename adxl312_adxl314_check_id() after first supported part
- handle part ID check via callback functions
- move the adxl313_data structure to adxl313.h header for addition of callbacks to device specific information
- add pointer to device specific data to the device id structures
- get chip_data for either registration path
- use chip_data in the core_probe() call
- replace chip_type from regmap_config with chip_data->type
- move the .data member on the same line with .compatible in the module device table

 drivers/iio/accel/adxl313.h      |  35 +++++-
 drivers/iio/accel/adxl313_core.c | 202 ++++++++++++++++++++++---------
 drivers/iio/accel/adxl313_i2c.c  |  74 +++++++----
 drivers/iio/accel/adxl313_spi.c  |  63 +++++++---
 4 files changed, 281 insertions(+), 93 deletions(-)
drivers/iio/accel/adxl313.h +33 -2
index 4415f2fc07e1..72f624af4686 100644
@@ -8,6 +8,8 @@
 #ifndef _ADXL313_H_
 #define _ADXL313_H_
 
+#include <linux/iio/iio.h>
+
 /* ADXL313 register definitions */
 #define ADXL313_REG_DEVID0		0x00
 #define ADXL313_REG_DEVID1		0x01
@@ -26,6 +28,7 @@
 #define ADXL313_REG_FIFO_STATUS		0x39
 
 #define ADXL313_DEVID0			0xAD
+#define ADXL313_DEVID0_ADXL312_314	0xE5
 #define ADXL313_DEVID1			0x1D
 #define ADXL313_PARTID			0xCB
 #define ADXL313_SOFT_RESET		0x52
@@ -37,18 +40,46 @@
 #define ADXL313_MEASUREMENT_MODE	BIT(3)
 
 #define ADXL313_RANGE_MSK		GENMASK(1, 0)
-#define ADXL313_RANGE_4G		3
+#define ADXL313_RANGE_MAX		3
 
 #define ADXL313_FULL_RES		BIT(3)
 #define ADXL313_SPI_3WIRE		BIT(6)
 #define ADXL313_I2C_DISABLE		BIT(6)
 
+extern const struct regmap_access_table adxl312_readable_regs_table;
 extern const struct regmap_access_table adxl313_readable_regs_table;
+extern const struct regmap_access_table adxl314_readable_regs_table;
 
+extern const struct regmap_access_table adxl312_writable_regs_table;
 extern const struct regmap_access_table adxl313_writable_regs_table;
+extern const struct regmap_access_table adxl314_writable_regs_table;
+
+enum adxl313_device_type {
+	ADXL312,
+	ADXL313,
+	ADXL314,
+};
+
+struct adxl313_data {
+	struct regmap	*regmap;
+	const struct adxl313_chip_info *chip_info;
+	struct mutex	lock; /* lock to protect transf_buf */
+	__le16		transf_buf __aligned(IIO_DMA_MINALIGN);
+};
+
+struct adxl313_chip_info {
+	const char			*name;
+	enum adxl313_device_type	type;
+	int				scale_factor;
+	bool				variable_range;
+	bool				soft_reset;
+	int (*check_id)(struct device *dev, struct adxl313_data *data);
+};
+
+extern const struct adxl313_chip_info adxl31x_chip_info[];
 
 int adxl313_core_probe(struct device *dev,
 		       struct regmap *regmap,
-		       const char *name,
+		       const struct adxl313_chip_info *chip_info,
 		       int (*setup)(struct device *, struct regmap *));
 #endif /* _ADXL313_H_ */
drivers/iio/accel/adxl313_core.c +147 -55

297 lines not on this page · raw message

drivers/iio/accel/adxl313_i2c.c +52 -22

94 lines not on this page · raw message

drivers/iio/accel/adxl313_spi.c +49 -14

99 lines not on this page · raw message

Signature · 1 line
2.30.2