1
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/workqueue.h>
10
11struct regmap;
12struct i2c_client;
13struct bmc150_accel_chip_info;
14struct bmc150_accel_interrupt_info;
15
16
17
18
19
20
21
22
23
24
25
26
27enum bmc150_type {
28 BOSCH_UNKNOWN,
29 BOSCH_BMC156,
30};
31
32struct bmc150_accel_interrupt {
33 const struct bmc150_accel_interrupt_info *info;
34 atomic_t users;
35};
36
37struct 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);
41 int intr;
42 bool enabled;
43};
44
45enum 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,
50};
51
52enum bmc150_accel_trigger_id {
53 BMC150_ACCEL_TRIGGER_DATA_READY,
54 BMC150_ACCEL_TRIGGER_ANY_MOTION,
55 BMC150_ACCEL_TRIGGERS,
56};
57
58struct 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];
63 struct mutex mutex;
64 u8 fifo_mode, watermark;
65 s16 buffer[8];
66
67
68
69
70 struct {
71 __le16 channels[3];
72 s64 ts __aligned(8);
73 } scan;
74 u8 bw_bits;
75 u32 slope_dur;
76 u32 slope_thres;
77 u32 range;
78 int ev_enable_state;
79 int64_t timestamp, old_timestamp;
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;
86};
87
88int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq,
89 enum bmc150_type type, const char *name,
90 bool block_supported);
91void bmc150_accel_core_remove(struct device *dev);
92extern const struct dev_pm_ops bmc150_accel_pm_ops;
93extern const struct regmap_config bmc150_regmap_conf;
94
95#endif
96