1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * ADXL345 3-Axis Digital Accelerometer
5 * Copyright (c) 2017 Eva Rachel Retuya <eraretuya@gmail.com>
11 #define ADXL345_REG_DEVID 0x00
12 #define ADXL345_REG_OFSX 0x1E
13 #define ADXL345_REG_OFSY 0x1F
14 #define ADXL345_REG_OFSZ 0x20
15 #define ADXL345_REG_OFS_AXIS(index) (ADXL345_REG_OFSX + (index))
16 #define ADXL345_REG_BW_RATE 0x2C
17 #define ADXL345_REG_POWER_CTL 0x2D
18 #define ADXL345_REG_DATA_FORMAT 0x31
19 #define ADXL345_REG_DATAX0 0x32
20 #define ADXL345_REG_DATAY0 0x34
21 #define ADXL345_REG_DATAZ0 0x36
22 #define ADXL345_REG_DATA_AXIS(index) \
23 (ADXL345_REG_DATAX0 + (index) * sizeof(__le16))
25 #define ADXL345_BW_RATE GENMASK(3, 0)
26 #define ADXL345_BASE_RATE_NANO_HZ 97656250LL
28 #define ADXL345_POWER_CTL_MEASURE BIT(3)
29 #define ADXL345_POWER_CTL_STANDBY 0x00
31 #define ADXL345_DATA_FORMAT_RANGE GENMASK(1, 0) /* Set the g range */
32 #define ADXL345_DATA_FORMAT_JUSTIFY BIT(2) /* Left-justified (MSB) mode */
33 #define ADXL345_DATA_FORMAT_FULL_RES BIT(3) /* Up to 13-bits resolution */
34 #define ADXL345_DATA_FORMAT_SPI_3WIRE BIT(6) /* 3-wire SPI mode */
35 #define ADXL345_DATA_FORMAT_SELF_TEST BIT(7) /* Enable a self test */
37 #define ADXL345_DATA_FORMAT_2G 0
38 #define ADXL345_DATA_FORMAT_4G 1
39 #define ADXL345_DATA_FORMAT_8G 2
40 #define ADXL345_DATA_FORMAT_16G 3
42 #define ADXL345_DEVID 0xE5
45 * In full-resolution mode, scale factor is maintained at ~4 mg/LSB
48 * At +/- 16g with 13-bit resolution, scale is computed as:
49 * (16 + 16) * 9.81 / (2^13 - 1) = 0.0383
51 #define ADXL345_USCALE 38300
54 * The Datasheet lists a resolution of Resolution is ~49 mg per LSB. That's
55 * ~480mm/s**2 per LSB.
57 #define ADXL375_USCALE 480000
59 struct adxl345_chip_info
{
64 int adxl345_core_probe(struct device
*dev
, struct regmap
*regmap
,
65 int (*setup
)(struct device
*, struct regmap
*));
67 #endif /* _ADXL345_H_ */