Commit | Line | Data |
---|---|---|
03b262f2 GB |
1 | /* |
2 | * Murata ZPA2326 pressure and temperature sensor IIO driver | |
3 | * | |
4 | * Copyright (c) 2016 Parrot S.A. | |
5 | * | |
6 | * Author: Gregor Boirie <gregor.boirie@parrot.com> | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify it | |
9 | * under the terms of the GNU General Public License version 2 as published by | |
10 | * the Free Software Foundation. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, but WITHOUT | |
13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
15 | * more details. | |
16 | */ | |
17 | ||
18 | #ifndef _ZPA2326_H | |
19 | #define _ZPA2326_H | |
20 | ||
21 | /* Register map. */ | |
22 | #define ZPA2326_REF_P_XL_REG (0x8) | |
23 | #define ZPA2326_REF_P_L_REG (0x9) | |
24 | #define ZPA2326_REF_P_H_REG (0xa) | |
25 | #define ZPA2326_DEVICE_ID_REG (0xf) | |
26 | #define ZPA2326_DEVICE_ID (0xb9) | |
27 | #define ZPA2326_RES_CONF_REG (0x10) | |
28 | #define ZPA2326_CTRL_REG0_REG (0x20) | |
29 | #define ZPA2326_CTRL_REG0_ONE_SHOT BIT(0) | |
30 | #define ZPA2326_CTRL_REG0_ENABLE BIT(1) | |
31 | #define ZPA2326_CTRL_REG1_REG (0x21) | |
32 | #define ZPA2326_CTRL_REG1_MASK_DATA_READY BIT(2) | |
33 | #define ZPA2326_CTRL_REG2_REG (0x22) | |
34 | #define ZPA2326_CTRL_REG2_SWRESET BIT(2) | |
35 | #define ZPA2326_CTRL_REG3_REG (0x23) | |
36 | #define ZPA2326_CTRL_REG3_ODR_SHIFT (4) | |
37 | #define ZPA2326_CTRL_REG3_ENABLE_MEAS BIT(7) | |
38 | #define ZPA2326_INT_SOURCE_REG (0x24) | |
39 | #define ZPA2326_INT_SOURCE_DATA_READY BIT(2) | |
40 | #define ZPA2326_THS_P_LOW_REG (0x25) | |
41 | #define ZPA2326_THS_P_HIGH_REG (0x26) | |
42 | #define ZPA2326_STATUS_REG (0x27) | |
43 | #define ZPA2326_STATUS_P_DA BIT(1) | |
44 | #define ZPA2326_STATUS_FIFO_E BIT(2) | |
45 | #define ZPA2326_STATUS_P_OR BIT(5) | |
46 | #define ZPA2326_PRESS_OUT_XL_REG (0x28) | |
47 | #define ZPA2326_PRESS_OUT_L_REG (0x29) | |
48 | #define ZPA2326_PRESS_OUT_H_REG (0x2a) | |
49 | #define ZPA2326_TEMP_OUT_L_REG (0x2b) | |
50 | #define ZPA2326_TEMP_OUT_H_REG (0x2c) | |
51 | ||
52 | struct device; | |
53 | struct regmap; | |
54 | ||
55 | bool zpa2326_isreg_writeable(struct device *dev, unsigned int reg); | |
56 | bool zpa2326_isreg_readable(struct device *dev, unsigned int reg); | |
57 | bool zpa2326_isreg_precious(struct device *dev, unsigned int reg); | |
58 | ||
59 | /** | |
60 | * zpa2326_probe() - Instantiate and register core ZPA2326 IIO device | |
61 | * @parent: Hardware sampling device the created IIO device will be a child of. | |
62 | * @name: Arbitrary name to identify the device. | |
63 | * @irq: Interrupt line, negative if none. | |
64 | * @hwid: Expected device hardware id. | |
65 | * @regmap: Registers map used to abstract underlying bus accesses. | |
66 | * | |
67 | * Return: Zero when successful, a negative error code otherwise. | |
68 | */ | |
69 | int zpa2326_probe(struct device *parent, | |
70 | const char *name, | |
71 | int irq, | |
72 | unsigned int hwid, | |
73 | struct regmap *regmap); | |
74 | ||
75 | /** | |
76 | * zpa2326_remove() - Unregister and destroy core ZPA2326 IIO device. | |
77 | * @parent: Hardware sampling device the IIO device to remove is a child of. | |
78 | */ | |
79 | void zpa2326_remove(const struct device *parent); | |
80 | ||
81 | #ifdef CONFIG_PM | |
82 | #include <linux/pm.h> | |
83 | extern const struct dev_pm_ops zpa2326_pm_ops; | |
84 | #define ZPA2326_PM_OPS (&zpa2326_pm_ops) | |
85 | #else | |
86 | #define ZPA2326_PM_OPS (NULL) | |
87 | #endif | |
88 | ||
89 | #endif |