xref: /openbmc/linux/drivers/iio/pressure/zpa2326.h (revision 234489ac)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Murata ZPA2326 pressure and temperature sensor IIO driver
4  *
5  * Copyright (c) 2016 Parrot S.A.
6  *
7  * Author: Gregor Boirie <gregor.boirie@parrot.com>
8  */
9 
10 #ifndef _ZPA2326_H
11 #define _ZPA2326_H
12 
13 /* Register map. */
14 #define ZPA2326_REF_P_XL_REG              (0x8)
15 #define ZPA2326_REF_P_L_REG               (0x9)
16 #define ZPA2326_REF_P_H_REG               (0xa)
17 #define ZPA2326_DEVICE_ID_REG             (0xf)
18 #define ZPA2326_DEVICE_ID                 (0xb9)
19 #define ZPA2326_RES_CONF_REG              (0x10)
20 #define ZPA2326_CTRL_REG0_REG             (0x20)
21 #define ZPA2326_CTRL_REG0_ONE_SHOT        BIT(0)
22 #define ZPA2326_CTRL_REG0_ENABLE          BIT(1)
23 #define ZPA2326_CTRL_REG1_REG             (0x21)
24 #define ZPA2326_CTRL_REG1_MASK_DATA_READY BIT(2)
25 #define ZPA2326_CTRL_REG2_REG             (0x22)
26 #define ZPA2326_CTRL_REG2_SWRESET         BIT(2)
27 #define ZPA2326_CTRL_REG3_REG             (0x23)
28 #define ZPA2326_CTRL_REG3_ODR_SHIFT       (4)
29 #define ZPA2326_CTRL_REG3_ENABLE_MEAS     BIT(7)
30 #define ZPA2326_INT_SOURCE_REG            (0x24)
31 #define ZPA2326_INT_SOURCE_DATA_READY     BIT(2)
32 #define ZPA2326_THS_P_LOW_REG             (0x25)
33 #define ZPA2326_THS_P_HIGH_REG            (0x26)
34 #define ZPA2326_STATUS_REG                (0x27)
35 #define ZPA2326_STATUS_P_DA               BIT(1)
36 #define ZPA2326_STATUS_FIFO_E             BIT(2)
37 #define ZPA2326_STATUS_P_OR               BIT(5)
38 #define ZPA2326_PRESS_OUT_XL_REG          (0x28)
39 #define ZPA2326_PRESS_OUT_L_REG           (0x29)
40 #define ZPA2326_PRESS_OUT_H_REG           (0x2a)
41 #define ZPA2326_TEMP_OUT_L_REG            (0x2b)
42 #define ZPA2326_TEMP_OUT_H_REG            (0x2c)
43 
44 struct device;
45 struct regmap;
46 
47 bool zpa2326_isreg_writeable(struct device *dev, unsigned int reg);
48 bool zpa2326_isreg_readable(struct device *dev, unsigned int reg);
49 bool zpa2326_isreg_precious(struct device *dev, unsigned int reg);
50 
51 /**
52  * zpa2326_probe() - Instantiate and register core ZPA2326 IIO device
53  * @parent: Hardware sampling device the created IIO device will be a child of.
54  * @name:   Arbitrary name to identify the device.
55  * @irq:    Interrupt line, negative if none.
56  * @hwid:   Expected device hardware id.
57  * @regmap: Registers map used to abstract underlying bus accesses.
58  *
59  * Return: Zero when successful, a negative error code otherwise.
60  */
61 int zpa2326_probe(struct device        *parent,
62 		  const char           *name,
63 		  int                   irq,
64 		  unsigned int          hwid,
65 		  struct regmap        *regmap);
66 
67 /**
68  * zpa2326_remove() - Unregister and destroy core ZPA2326 IIO device.
69  * @parent: Hardware sampling device the IIO device to remove is a child of.
70  */
71 void zpa2326_remove(const struct device *parent);
72 
73 #ifdef CONFIG_PM
74 #include <linux/pm.h>
75 extern const struct dev_pm_ops zpa2326_pm_ops;
76 #define ZPA2326_PM_OPS (&zpa2326_pm_ops)
77 #else
78 #define ZPA2326_PM_OPS (NULL)
79 #endif
80 
81 #endif
82