18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Murata ZPA2326 pressure and temperature sensor IIO driver
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (c) 2016 Parrot S.A.
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Author: Gregor Boirie <gregor.boirie@parrot.com>
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#ifndef _ZPA2326_H
118c2ecf20Sopenharmony_ci#define _ZPA2326_H
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci/* Register map. */
148c2ecf20Sopenharmony_ci#define ZPA2326_REF_P_XL_REG              (0x8)
158c2ecf20Sopenharmony_ci#define ZPA2326_REF_P_L_REG               (0x9)
168c2ecf20Sopenharmony_ci#define ZPA2326_REF_P_H_REG               (0xa)
178c2ecf20Sopenharmony_ci#define ZPA2326_DEVICE_ID_REG             (0xf)
188c2ecf20Sopenharmony_ci#define ZPA2326_DEVICE_ID                 (0xb9)
198c2ecf20Sopenharmony_ci#define ZPA2326_RES_CONF_REG              (0x10)
208c2ecf20Sopenharmony_ci#define ZPA2326_CTRL_REG0_REG             (0x20)
218c2ecf20Sopenharmony_ci#define ZPA2326_CTRL_REG0_ONE_SHOT        BIT(0)
228c2ecf20Sopenharmony_ci#define ZPA2326_CTRL_REG0_ENABLE          BIT(1)
238c2ecf20Sopenharmony_ci#define ZPA2326_CTRL_REG1_REG             (0x21)
248c2ecf20Sopenharmony_ci#define ZPA2326_CTRL_REG1_MASK_DATA_READY BIT(2)
258c2ecf20Sopenharmony_ci#define ZPA2326_CTRL_REG2_REG             (0x22)
268c2ecf20Sopenharmony_ci#define ZPA2326_CTRL_REG2_SWRESET         BIT(2)
278c2ecf20Sopenharmony_ci#define ZPA2326_CTRL_REG3_REG             (0x23)
288c2ecf20Sopenharmony_ci#define ZPA2326_CTRL_REG3_ODR_SHIFT       (4)
298c2ecf20Sopenharmony_ci#define ZPA2326_CTRL_REG3_ENABLE_MEAS     BIT(7)
308c2ecf20Sopenharmony_ci#define ZPA2326_INT_SOURCE_REG            (0x24)
318c2ecf20Sopenharmony_ci#define ZPA2326_INT_SOURCE_DATA_READY     BIT(2)
328c2ecf20Sopenharmony_ci#define ZPA2326_THS_P_LOW_REG             (0x25)
338c2ecf20Sopenharmony_ci#define ZPA2326_THS_P_HIGH_REG            (0x26)
348c2ecf20Sopenharmony_ci#define ZPA2326_STATUS_REG                (0x27)
358c2ecf20Sopenharmony_ci#define ZPA2326_STATUS_P_DA               BIT(1)
368c2ecf20Sopenharmony_ci#define ZPA2326_STATUS_FIFO_E             BIT(2)
378c2ecf20Sopenharmony_ci#define ZPA2326_STATUS_P_OR               BIT(5)
388c2ecf20Sopenharmony_ci#define ZPA2326_PRESS_OUT_XL_REG          (0x28)
398c2ecf20Sopenharmony_ci#define ZPA2326_PRESS_OUT_L_REG           (0x29)
408c2ecf20Sopenharmony_ci#define ZPA2326_PRESS_OUT_H_REG           (0x2a)
418c2ecf20Sopenharmony_ci#define ZPA2326_TEMP_OUT_L_REG            (0x2b)
428c2ecf20Sopenharmony_ci#define ZPA2326_TEMP_OUT_H_REG            (0x2c)
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_cistruct device;
458c2ecf20Sopenharmony_cistruct regmap;
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_cibool zpa2326_isreg_writeable(struct device *dev, unsigned int reg);
488c2ecf20Sopenharmony_cibool zpa2326_isreg_readable(struct device *dev, unsigned int reg);
498c2ecf20Sopenharmony_cibool zpa2326_isreg_precious(struct device *dev, unsigned int reg);
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci/**
528c2ecf20Sopenharmony_ci * zpa2326_probe() - Instantiate and register core ZPA2326 IIO device
538c2ecf20Sopenharmony_ci * @parent: Hardware sampling device the created IIO device will be a child of.
548c2ecf20Sopenharmony_ci * @name:   Arbitrary name to identify the device.
558c2ecf20Sopenharmony_ci * @irq:    Interrupt line, negative if none.
568c2ecf20Sopenharmony_ci * @hwid:   Expected device hardware id.
578c2ecf20Sopenharmony_ci * @regmap: Registers map used to abstract underlying bus accesses.
588c2ecf20Sopenharmony_ci *
598c2ecf20Sopenharmony_ci * Return: Zero when successful, a negative error code otherwise.
608c2ecf20Sopenharmony_ci */
618c2ecf20Sopenharmony_ciint zpa2326_probe(struct device        *parent,
628c2ecf20Sopenharmony_ci		  const char           *name,
638c2ecf20Sopenharmony_ci		  int                   irq,
648c2ecf20Sopenharmony_ci		  unsigned int          hwid,
658c2ecf20Sopenharmony_ci		  struct regmap        *regmap);
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci/**
688c2ecf20Sopenharmony_ci * zpa2326_remove() - Unregister and destroy core ZPA2326 IIO device.
698c2ecf20Sopenharmony_ci * @parent: Hardware sampling device the IIO device to remove is a child of.
708c2ecf20Sopenharmony_ci */
718c2ecf20Sopenharmony_civoid zpa2326_remove(const struct device *parent);
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci#ifdef CONFIG_PM
748c2ecf20Sopenharmony_ci#include <linux/pm.h>
758c2ecf20Sopenharmony_ciextern const struct dev_pm_ops zpa2326_pm_ops;
768c2ecf20Sopenharmony_ci#define ZPA2326_PM_OPS (&zpa2326_pm_ops)
778c2ecf20Sopenharmony_ci#else
788c2ecf20Sopenharmony_ci#define ZPA2326_PM_OPS (NULL)
798c2ecf20Sopenharmony_ci#endif
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci#endif
82