162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Murata ZPA2326 pressure and temperature sensor IIO driver
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (c) 2016 Parrot S.A.
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * Author: Gregor Boirie <gregor.boirie@parrot.com>
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#ifndef _ZPA2326_H
1162306a36Sopenharmony_ci#define _ZPA2326_H
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci/* Register map. */
1462306a36Sopenharmony_ci#define ZPA2326_REF_P_XL_REG              (0x8)
1562306a36Sopenharmony_ci#define ZPA2326_REF_P_L_REG               (0x9)
1662306a36Sopenharmony_ci#define ZPA2326_REF_P_H_REG               (0xa)
1762306a36Sopenharmony_ci#define ZPA2326_DEVICE_ID_REG             (0xf)
1862306a36Sopenharmony_ci#define ZPA2326_DEVICE_ID                 (0xb9)
1962306a36Sopenharmony_ci#define ZPA2326_RES_CONF_REG              (0x10)
2062306a36Sopenharmony_ci#define ZPA2326_CTRL_REG0_REG             (0x20)
2162306a36Sopenharmony_ci#define ZPA2326_CTRL_REG0_ONE_SHOT        BIT(0)
2262306a36Sopenharmony_ci#define ZPA2326_CTRL_REG0_ENABLE          BIT(1)
2362306a36Sopenharmony_ci#define ZPA2326_CTRL_REG1_REG             (0x21)
2462306a36Sopenharmony_ci#define ZPA2326_CTRL_REG1_MASK_DATA_READY BIT(2)
2562306a36Sopenharmony_ci#define ZPA2326_CTRL_REG2_REG             (0x22)
2662306a36Sopenharmony_ci#define ZPA2326_CTRL_REG2_SWRESET         BIT(2)
2762306a36Sopenharmony_ci#define ZPA2326_CTRL_REG3_REG             (0x23)
2862306a36Sopenharmony_ci#define ZPA2326_CTRL_REG3_ODR_SHIFT       (4)
2962306a36Sopenharmony_ci#define ZPA2326_CTRL_REG3_ENABLE_MEAS     BIT(7)
3062306a36Sopenharmony_ci#define ZPA2326_INT_SOURCE_REG            (0x24)
3162306a36Sopenharmony_ci#define ZPA2326_INT_SOURCE_DATA_READY     BIT(2)
3262306a36Sopenharmony_ci#define ZPA2326_THS_P_LOW_REG             (0x25)
3362306a36Sopenharmony_ci#define ZPA2326_THS_P_HIGH_REG            (0x26)
3462306a36Sopenharmony_ci#define ZPA2326_STATUS_REG                (0x27)
3562306a36Sopenharmony_ci#define ZPA2326_STATUS_P_DA               BIT(1)
3662306a36Sopenharmony_ci#define ZPA2326_STATUS_FIFO_E             BIT(2)
3762306a36Sopenharmony_ci#define ZPA2326_STATUS_P_OR               BIT(5)
3862306a36Sopenharmony_ci#define ZPA2326_PRESS_OUT_XL_REG          (0x28)
3962306a36Sopenharmony_ci#define ZPA2326_PRESS_OUT_L_REG           (0x29)
4062306a36Sopenharmony_ci#define ZPA2326_PRESS_OUT_H_REG           (0x2a)
4162306a36Sopenharmony_ci#define ZPA2326_TEMP_OUT_L_REG            (0x2b)
4262306a36Sopenharmony_ci#define ZPA2326_TEMP_OUT_H_REG            (0x2c)
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_cistruct device;
4562306a36Sopenharmony_cistruct regmap;
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_cibool zpa2326_isreg_writeable(struct device *dev, unsigned int reg);
4862306a36Sopenharmony_cibool zpa2326_isreg_readable(struct device *dev, unsigned int reg);
4962306a36Sopenharmony_cibool zpa2326_isreg_precious(struct device *dev, unsigned int reg);
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci/**
5262306a36Sopenharmony_ci * zpa2326_probe() - Instantiate and register core ZPA2326 IIO device
5362306a36Sopenharmony_ci * @parent: Hardware sampling device the created IIO device will be a child of.
5462306a36Sopenharmony_ci * @name:   Arbitrary name to identify the device.
5562306a36Sopenharmony_ci * @irq:    Interrupt line, negative if none.
5662306a36Sopenharmony_ci * @hwid:   Expected device hardware id.
5762306a36Sopenharmony_ci * @regmap: Registers map used to abstract underlying bus accesses.
5862306a36Sopenharmony_ci *
5962306a36Sopenharmony_ci * Return: Zero when successful, a negative error code otherwise.
6062306a36Sopenharmony_ci */
6162306a36Sopenharmony_ciint zpa2326_probe(struct device        *parent,
6262306a36Sopenharmony_ci		  const char           *name,
6362306a36Sopenharmony_ci		  int                   irq,
6462306a36Sopenharmony_ci		  unsigned int          hwid,
6562306a36Sopenharmony_ci		  struct regmap        *regmap);
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci/**
6862306a36Sopenharmony_ci * zpa2326_remove() - Unregister and destroy core ZPA2326 IIO device.
6962306a36Sopenharmony_ci * @parent: Hardware sampling device the IIO device to remove is a child of.
7062306a36Sopenharmony_ci */
7162306a36Sopenharmony_civoid zpa2326_remove(const struct device *parent);
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ci#ifdef CONFIG_PM
7462306a36Sopenharmony_ci#include <linux/pm.h>
7562306a36Sopenharmony_ciextern const struct dev_pm_ops zpa2326_pm_ops;
7662306a36Sopenharmony_ci#define ZPA2326_PM_OPS (&zpa2326_pm_ops)
7762306a36Sopenharmony_ci#else
7862306a36Sopenharmony_ci#define ZPA2326_PM_OPS (NULL)
7962306a36Sopenharmony_ci#endif
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci#endif
82