xref: /linux/drivers/iio/pressure/zpa2326.h (revision 75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37)
1*1802d0beSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
203b262f2SGregor Boirie /*
303b262f2SGregor Boirie  * Murata ZPA2326 pressure and temperature sensor IIO driver
403b262f2SGregor Boirie  *
503b262f2SGregor Boirie  * Copyright (c) 2016 Parrot S.A.
603b262f2SGregor Boirie  *
703b262f2SGregor Boirie  * Author: Gregor Boirie <gregor.boirie@parrot.com>
803b262f2SGregor Boirie  */
903b262f2SGregor Boirie 
1003b262f2SGregor Boirie #ifndef _ZPA2326_H
1103b262f2SGregor Boirie #define _ZPA2326_H
1203b262f2SGregor Boirie 
1303b262f2SGregor Boirie /* Register map. */
1403b262f2SGregor Boirie #define ZPA2326_REF_P_XL_REG              (0x8)
1503b262f2SGregor Boirie #define ZPA2326_REF_P_L_REG               (0x9)
1603b262f2SGregor Boirie #define ZPA2326_REF_P_H_REG               (0xa)
1703b262f2SGregor Boirie #define ZPA2326_DEVICE_ID_REG             (0xf)
1803b262f2SGregor Boirie #define ZPA2326_DEVICE_ID                 (0xb9)
1903b262f2SGregor Boirie #define ZPA2326_RES_CONF_REG              (0x10)
2003b262f2SGregor Boirie #define ZPA2326_CTRL_REG0_REG             (0x20)
2103b262f2SGregor Boirie #define ZPA2326_CTRL_REG0_ONE_SHOT        BIT(0)
2203b262f2SGregor Boirie #define ZPA2326_CTRL_REG0_ENABLE          BIT(1)
2303b262f2SGregor Boirie #define ZPA2326_CTRL_REG1_REG             (0x21)
2403b262f2SGregor Boirie #define ZPA2326_CTRL_REG1_MASK_DATA_READY BIT(2)
2503b262f2SGregor Boirie #define ZPA2326_CTRL_REG2_REG             (0x22)
2603b262f2SGregor Boirie #define ZPA2326_CTRL_REG2_SWRESET         BIT(2)
2703b262f2SGregor Boirie #define ZPA2326_CTRL_REG3_REG             (0x23)
2803b262f2SGregor Boirie #define ZPA2326_CTRL_REG3_ODR_SHIFT       (4)
2903b262f2SGregor Boirie #define ZPA2326_CTRL_REG3_ENABLE_MEAS     BIT(7)
3003b262f2SGregor Boirie #define ZPA2326_INT_SOURCE_REG            (0x24)
3103b262f2SGregor Boirie #define ZPA2326_INT_SOURCE_DATA_READY     BIT(2)
3203b262f2SGregor Boirie #define ZPA2326_THS_P_LOW_REG             (0x25)
3303b262f2SGregor Boirie #define ZPA2326_THS_P_HIGH_REG            (0x26)
3403b262f2SGregor Boirie #define ZPA2326_STATUS_REG                (0x27)
3503b262f2SGregor Boirie #define ZPA2326_STATUS_P_DA               BIT(1)
3603b262f2SGregor Boirie #define ZPA2326_STATUS_FIFO_E             BIT(2)
3703b262f2SGregor Boirie #define ZPA2326_STATUS_P_OR               BIT(5)
3803b262f2SGregor Boirie #define ZPA2326_PRESS_OUT_XL_REG          (0x28)
3903b262f2SGregor Boirie #define ZPA2326_PRESS_OUT_L_REG           (0x29)
4003b262f2SGregor Boirie #define ZPA2326_PRESS_OUT_H_REG           (0x2a)
4103b262f2SGregor Boirie #define ZPA2326_TEMP_OUT_L_REG            (0x2b)
4203b262f2SGregor Boirie #define ZPA2326_TEMP_OUT_H_REG            (0x2c)
4303b262f2SGregor Boirie 
4403b262f2SGregor Boirie struct device;
4503b262f2SGregor Boirie struct regmap;
4603b262f2SGregor Boirie 
4703b262f2SGregor Boirie bool zpa2326_isreg_writeable(struct device *dev, unsigned int reg);
4803b262f2SGregor Boirie bool zpa2326_isreg_readable(struct device *dev, unsigned int reg);
4903b262f2SGregor Boirie bool zpa2326_isreg_precious(struct device *dev, unsigned int reg);
5003b262f2SGregor Boirie 
5103b262f2SGregor Boirie /**
5203b262f2SGregor Boirie  * zpa2326_probe() - Instantiate and register core ZPA2326 IIO device
5303b262f2SGregor Boirie  * @parent: Hardware sampling device the created IIO device will be a child of.
5403b262f2SGregor Boirie  * @name:   Arbitrary name to identify the device.
5503b262f2SGregor Boirie  * @irq:    Interrupt line, negative if none.
5603b262f2SGregor Boirie  * @hwid:   Expected device hardware id.
5703b262f2SGregor Boirie  * @regmap: Registers map used to abstract underlying bus accesses.
5803b262f2SGregor Boirie  *
5903b262f2SGregor Boirie  * Return: Zero when successful, a negative error code otherwise.
6003b262f2SGregor Boirie  */
6103b262f2SGregor Boirie int zpa2326_probe(struct device        *parent,
6203b262f2SGregor Boirie 		  const char           *name,
6303b262f2SGregor Boirie 		  int                   irq,
6403b262f2SGregor Boirie 		  unsigned int          hwid,
6503b262f2SGregor Boirie 		  struct regmap        *regmap);
6603b262f2SGregor Boirie 
6703b262f2SGregor Boirie /**
6803b262f2SGregor Boirie  * zpa2326_remove() - Unregister and destroy core ZPA2326 IIO device.
6903b262f2SGregor Boirie  * @parent: Hardware sampling device the IIO device to remove is a child of.
7003b262f2SGregor Boirie  */
7103b262f2SGregor Boirie void zpa2326_remove(const struct device *parent);
7203b262f2SGregor Boirie 
7303b262f2SGregor Boirie #ifdef CONFIG_PM
7403b262f2SGregor Boirie #include <linux/pm.h>
7503b262f2SGregor Boirie extern const struct dev_pm_ops zpa2326_pm_ops;
7603b262f2SGregor Boirie #define ZPA2326_PM_OPS (&zpa2326_pm_ops)
7703b262f2SGregor Boirie #else
7803b262f2SGregor Boirie #define ZPA2326_PM_OPS (NULL)
7903b262f2SGregor Boirie #endif
8003b262f2SGregor Boirie 
8103b262f2SGregor Boirie #endif
82