Josef Gajdusek | fc35a91 | 2014-07-22 16:01:00 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Header file for hmc5843 driver |
| 3 | * |
| 4 | * Split from hmc5843.c |
| 5 | * Copyright (C) Josef Gajdusek <atx@atx.name> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
Cristina Moraru | 4630adb | 2016-02-08 00:21:50 +0200 | [diff] [blame] | 10 | */ |
Josef Gajdusek | fc35a91 | 2014-07-22 16:01:00 +0100 | [diff] [blame] | 11 | |
Josef Gajdusek | fc35a91 | 2014-07-22 16:01:00 +0100 | [diff] [blame] | 12 | #ifndef HMC5843_CORE_H |
| 13 | #define HMC5843_CORE_H |
| 14 | |
| 15 | #include <linux/regmap.h> |
| 16 | #include <linux/iio/iio.h> |
| 17 | |
| 18 | #define HMC5843_CONFIG_REG_A 0x00 |
| 19 | #define HMC5843_CONFIG_REG_B 0x01 |
| 20 | #define HMC5843_MODE_REG 0x02 |
| 21 | #define HMC5843_DATA_OUT_MSB_REGS 0x03 |
| 22 | #define HMC5843_STATUS_REG 0x09 |
| 23 | #define HMC5843_ID_REG 0x0a |
| 24 | #define HMC5843_ID_END 0x0c |
| 25 | |
| 26 | enum hmc5843_ids { |
| 27 | HMC5843_ID, |
| 28 | HMC5883_ID, |
| 29 | HMC5883L_ID, |
Josef Gajdusek | 5a059bd | 2014-07-22 16:02:00 +0100 | [diff] [blame] | 30 | HMC5983_ID, |
Josef Gajdusek | fc35a91 | 2014-07-22 16:01:00 +0100 | [diff] [blame] | 31 | }; |
| 32 | |
Cristina Opriceana | daf56d9 | 2015-03-20 18:09:43 +0200 | [diff] [blame] | 33 | /** |
| 34 | * struct hcm5843_data - device specific data |
| 35 | * @dev: actual device |
| 36 | * @lock: update and read regmap data |
| 37 | * @regmap: hardware access register maps |
| 38 | * @variant: describe chip variants |
| 39 | * @buffer: 3x 16-bit channels + padding + 64-bit timestamp |
Cristina Moraru | 4630adb | 2016-02-08 00:21:50 +0200 | [diff] [blame] | 40 | */ |
Josef Gajdusek | fc35a91 | 2014-07-22 16:01:00 +0100 | [diff] [blame] | 41 | struct hmc5843_data { |
| 42 | struct device *dev; |
| 43 | struct mutex lock; |
| 44 | struct regmap *regmap; |
| 45 | const struct hmc5843_chip_info *variant; |
Cristina Opriceana | daf56d9 | 2015-03-20 18:09:43 +0200 | [diff] [blame] | 46 | __be16 buffer[8]; |
Josef Gajdusek | fc35a91 | 2014-07-22 16:01:00 +0100 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | int hmc5843_common_probe(struct device *dev, struct regmap *regmap, |
Yong Li | 70b2737 | 2015-08-12 21:25:46 +0800 | [diff] [blame] | 50 | enum hmc5843_ids id, const char *name); |
Josef Gajdusek | fc35a91 | 2014-07-22 16:01:00 +0100 | [diff] [blame] | 51 | int hmc5843_common_remove(struct device *dev); |
| 52 | |
| 53 | int hmc5843_common_suspend(struct device *dev); |
| 54 | int hmc5843_common_resume(struct device *dev); |
| 55 | |
| 56 | #ifdef CONFIG_PM_SLEEP |
| 57 | static SIMPLE_DEV_PM_OPS(hmc5843_pm_ops, |
| 58 | hmc5843_common_suspend, |
| 59 | hmc5843_common_resume); |
| 60 | #define HMC5843_PM_OPS (&hmc5843_pm_ops) |
| 61 | #else |
| 62 | #define HMC5843_PM_OPS NULL |
| 63 | #endif |
| 64 | |
| 65 | #endif /* HMC5843_CORE_H */ |