xref: /linux/drivers/iio/magnetometer/hmc5843.h (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Header file for hmc5843 driver
4  *
5  * Split from hmc5843.c
6  * Copyright (C) Josef Gajdusek <atx@atx.name>
7  */
8 
9 #ifndef HMC5843_CORE_H
10 #define HMC5843_CORE_H
11 
12 #include <linux/regmap.h>
13 #include <linux/iio/iio.h>
14 
15 #define HMC5843_CONFIG_REG_A			0x00
16 #define HMC5843_CONFIG_REG_B			0x01
17 #define HMC5843_MODE_REG			0x02
18 #define HMC5843_DATA_OUT_MSB_REGS		0x03
19 #define HMC5843_STATUS_REG			0x09
20 #define HMC5843_ID_REG				0x0a
21 #define HMC5843_ID_END				0x0c
22 
23 enum hmc5843_ids {
24 	HMC5843_ID,
25 	HMC5883_ID,
26 	HMC5883L_ID,
27 	HMC5983_ID,
28 };
29 
30 /**
31  * struct hmc5843_data	- device specific data
32  * @dev:		actual device
33  * @lock:		update and read regmap data
34  * @regmap:		hardware access register maps
35  * @variant:		describe chip variants
36  * @scan:		buffer to pack data for passing to
37  *			iio_push_to_buffers_with_timestamp()
38  */
39 struct hmc5843_data {
40 	struct device *dev;
41 	struct mutex lock;
42 	struct regmap *regmap;
43 	const struct hmc5843_chip_info *variant;
44 	struct iio_mount_matrix orientation;
45 	struct {
46 		__be16 chans[3];
47 		s64 timestamp __aligned(8);
48 	} scan;
49 };
50 
51 int hmc5843_common_probe(struct device *dev, struct regmap *regmap,
52 			 enum hmc5843_ids id, const char *name);
53 void hmc5843_common_remove(struct device *dev);
54 
55 extern const struct dev_pm_ops hmc5843_pm_ops;
56 #endif /* HMC5843_CORE_H */
57