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