1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _BMC150_ACCEL_H_
3 #define _BMC150_ACCEL_H_
5 #include <linux/atomic.h>
6 #include <linux/iio/iio.h>
7 #include <linux/mutex.h>
8 #include <linux/regulator/consumer.h>
9 #include <linux/workqueue.h>
13 struct bmc150_accel_chip_info
;
14 struct bmc150_accel_interrupt_info
;
17 * We can often guess better than "UNKNOWN" based on the device IDs
18 * but unfortunately this information is not always accurate. There are some
19 * devices where ACPI firmware specifies an ID like "BMA250E" when the device
20 * actually has a BMA222E. The driver attempts to detect those by reading the
21 * chip ID from the registers but this information is not always enough either.
23 * Therefore, this enum should be only used when the chip ID detection is not
24 * enough and we can be reasonably sure that the device IDs are reliable
25 * in practice (e.g. for device tree platforms).
32 struct bmc150_accel_interrupt
{
33 const struct bmc150_accel_interrupt_info
*info
;
37 struct bmc150_accel_trigger
{
38 struct bmc150_accel_data
*data
;
39 struct iio_trigger
*indio_trig
;
40 int (*setup
)(struct bmc150_accel_trigger
*t
, bool state
);
45 enum bmc150_accel_interrupt_id
{
46 BMC150_ACCEL_INT_DATA_READY
,
47 BMC150_ACCEL_INT_ANY_MOTION
,
48 BMC150_ACCEL_INT_WATERMARK
,
49 BMC150_ACCEL_INTERRUPTS
,
52 enum bmc150_accel_trigger_id
{
53 BMC150_ACCEL_TRIGGER_DATA_READY
,
54 BMC150_ACCEL_TRIGGER_ANY_MOTION
,
55 BMC150_ACCEL_TRIGGERS
,
58 struct bmc150_accel_data
{
59 struct regmap
*regmap
;
60 struct regulator_bulk_data regulators
[2];
61 struct bmc150_accel_interrupt interrupts
[BMC150_ACCEL_INTERRUPTS
];
62 struct bmc150_accel_trigger triggers
[BMC150_ACCEL_TRIGGERS
];
64 u8 fifo_mode
, watermark
;
67 * Ensure there is sufficient space and correct alignment for
68 * the timestamp if enabled
79 int64_t timestamp
, old_timestamp
; /* Only used in hw fifo mode. */
80 const struct bmc150_accel_chip_info
*chip_info
;
81 enum bmc150_type type
;
82 struct i2c_client
*second_device
;
83 void (*resume_callback
)(struct device
*dev
);
84 struct delayed_work resume_work
;
85 struct iio_mount_matrix orientation
;
88 int bmc150_accel_core_probe(struct device
*dev
, struct regmap
*regmap
, int irq
,
89 enum bmc150_type type
, const char *name
,
90 bool block_supported
);
91 void bmc150_accel_core_remove(struct device
*dev
);
92 extern const struct dev_pm_ops bmc150_accel_pm_ops
;
93 extern const struct regmap_config bmc150_regmap_conf
;
95 #endif /* _BMC150_ACCEL_H_ */