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