Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _BMC150_ACCEL_H_
3#define _BMC150_ACCEL_H_
4
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/types.h>
10#include <linux/workqueue.h>
11
12struct regmap;
13struct i2c_client;
14struct bmc150_accel_chip_info;
15struct bmc150_accel_interrupt_info;
16
17/*
18 * We can often guess better than "UNKNOWN" based on the device IDs
19 * but unfortunately this information is not always accurate. There are some
20 * devices where ACPI firmware specifies an ID like "BMA250E" when the device
21 * actually has a BMA222E. The driver attempts to detect those by reading the
22 * chip ID from the registers but this information is not always enough either.
23 *
24 * Therefore, this enum should be only used when the chip ID detection is not
25 * enough and we can be reasonably sure that the device IDs are reliable
26 * in practice (e.g. for device tree platforms).
27 */
28enum bmc150_type {
29 BOSCH_UNKNOWN,
30 BOSCH_BMC156,
31};
32
33struct bmc150_accel_interrupt {
34 const struct bmc150_accel_interrupt_info *info;
35 atomic_t users;
36};
37
38struct bmc150_accel_trigger {
39 struct bmc150_accel_data *data;
40 struct iio_trigger *indio_trig;
41 int (*setup)(struct bmc150_accel_trigger *t, bool state);
42 int intr;
43 bool enabled;
44};
45
46enum bmc150_accel_interrupt_id {
47 BMC150_ACCEL_INT_DATA_READY,
48 BMC150_ACCEL_INT_ANY_MOTION,
49 BMC150_ACCEL_INT_WATERMARK,
50 BMC150_ACCEL_INTERRUPTS,
51};
52
53enum bmc150_accel_trigger_id {
54 BMC150_ACCEL_TRIGGER_DATA_READY,
55 BMC150_ACCEL_TRIGGER_ANY_MOTION,
56 BMC150_ACCEL_TRIGGERS,
57};
58
59struct bmc150_accel_data {
60 struct regmap *regmap;
61 int irq;
62 struct regulator_bulk_data regulators[2];
63 struct bmc150_accel_interrupt interrupts[BMC150_ACCEL_INTERRUPTS];
64 struct bmc150_accel_trigger triggers[BMC150_ACCEL_TRIGGERS];
65 struct mutex mutex;
66 u8 fifo_mode, watermark;
67 s16 buffer[8];
68 /*
69 * Ensure there is sufficient space and correct alignment for
70 * the timestamp if enabled
71 */
72 struct {
73 __le16 channels[3];
74 aligned_s64 ts;
75 } scan;
76 u8 bw_bits;
77 u32 slope_dur;
78 u32 slope_thres;
79 u32 range;
80 int ev_enable_state;
81 int64_t timestamp, old_timestamp; /* Only used in hw fifo mode. */
82 const struct bmc150_accel_chip_info *chip_info;
83 enum bmc150_type type;
84 struct i2c_client *second_device;
85 void (*resume_callback)(struct device *dev);
86 struct delayed_work resume_work;
87 struct iio_mount_matrix orientation;
88};
89
90int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq,
91 enum bmc150_type type, const char *name,
92 bool block_supported);
93void bmc150_accel_core_remove(struct device *dev);
94extern const struct dev_pm_ops bmc150_accel_pm_ops;
95extern const struct regmap_config bmc150_regmap_conf;
96
97#endif /* _BMC150_ACCEL_H_ */