1*03b262f2SGregor Boirie /* 2*03b262f2SGregor Boirie * Murata ZPA2326 pressure and temperature sensor IIO driver 3*03b262f2SGregor Boirie * 4*03b262f2SGregor Boirie * Copyright (c) 2016 Parrot S.A. 5*03b262f2SGregor Boirie * 6*03b262f2SGregor Boirie * Author: Gregor Boirie <gregor.boirie@parrot.com> 7*03b262f2SGregor Boirie * 8*03b262f2SGregor Boirie * This program is free software; you can redistribute it and/or modify it 9*03b262f2SGregor Boirie * under the terms of the GNU General Public License version 2 as published by 10*03b262f2SGregor Boirie * the Free Software Foundation. 11*03b262f2SGregor Boirie * 12*03b262f2SGregor Boirie * This program is distributed in the hope that it will be useful, but WITHOUT 13*03b262f2SGregor Boirie * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14*03b262f2SGregor Boirie * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 15*03b262f2SGregor Boirie * more details. 16*03b262f2SGregor Boirie */ 17*03b262f2SGregor Boirie 18*03b262f2SGregor Boirie #ifndef _ZPA2326_H 19*03b262f2SGregor Boirie #define _ZPA2326_H 20*03b262f2SGregor Boirie 21*03b262f2SGregor Boirie /* Register map. */ 22*03b262f2SGregor Boirie #define ZPA2326_REF_P_XL_REG (0x8) 23*03b262f2SGregor Boirie #define ZPA2326_REF_P_L_REG (0x9) 24*03b262f2SGregor Boirie #define ZPA2326_REF_P_H_REG (0xa) 25*03b262f2SGregor Boirie #define ZPA2326_DEVICE_ID_REG (0xf) 26*03b262f2SGregor Boirie #define ZPA2326_DEVICE_ID (0xb9) 27*03b262f2SGregor Boirie #define ZPA2326_RES_CONF_REG (0x10) 28*03b262f2SGregor Boirie #define ZPA2326_CTRL_REG0_REG (0x20) 29*03b262f2SGregor Boirie #define ZPA2326_CTRL_REG0_ONE_SHOT BIT(0) 30*03b262f2SGregor Boirie #define ZPA2326_CTRL_REG0_ENABLE BIT(1) 31*03b262f2SGregor Boirie #define ZPA2326_CTRL_REG1_REG (0x21) 32*03b262f2SGregor Boirie #define ZPA2326_CTRL_REG1_MASK_DATA_READY BIT(2) 33*03b262f2SGregor Boirie #define ZPA2326_CTRL_REG2_REG (0x22) 34*03b262f2SGregor Boirie #define ZPA2326_CTRL_REG2_SWRESET BIT(2) 35*03b262f2SGregor Boirie #define ZPA2326_CTRL_REG3_REG (0x23) 36*03b262f2SGregor Boirie #define ZPA2326_CTRL_REG3_ODR_SHIFT (4) 37*03b262f2SGregor Boirie #define ZPA2326_CTRL_REG3_ENABLE_MEAS BIT(7) 38*03b262f2SGregor Boirie #define ZPA2326_INT_SOURCE_REG (0x24) 39*03b262f2SGregor Boirie #define ZPA2326_INT_SOURCE_DATA_READY BIT(2) 40*03b262f2SGregor Boirie #define ZPA2326_THS_P_LOW_REG (0x25) 41*03b262f2SGregor Boirie #define ZPA2326_THS_P_HIGH_REG (0x26) 42*03b262f2SGregor Boirie #define ZPA2326_STATUS_REG (0x27) 43*03b262f2SGregor Boirie #define ZPA2326_STATUS_P_DA BIT(1) 44*03b262f2SGregor Boirie #define ZPA2326_STATUS_FIFO_E BIT(2) 45*03b262f2SGregor Boirie #define ZPA2326_STATUS_P_OR BIT(5) 46*03b262f2SGregor Boirie #define ZPA2326_PRESS_OUT_XL_REG (0x28) 47*03b262f2SGregor Boirie #define ZPA2326_PRESS_OUT_L_REG (0x29) 48*03b262f2SGregor Boirie #define ZPA2326_PRESS_OUT_H_REG (0x2a) 49*03b262f2SGregor Boirie #define ZPA2326_TEMP_OUT_L_REG (0x2b) 50*03b262f2SGregor Boirie #define ZPA2326_TEMP_OUT_H_REG (0x2c) 51*03b262f2SGregor Boirie 52*03b262f2SGregor Boirie struct device; 53*03b262f2SGregor Boirie struct regmap; 54*03b262f2SGregor Boirie 55*03b262f2SGregor Boirie bool zpa2326_isreg_writeable(struct device *dev, unsigned int reg); 56*03b262f2SGregor Boirie bool zpa2326_isreg_readable(struct device *dev, unsigned int reg); 57*03b262f2SGregor Boirie bool zpa2326_isreg_precious(struct device *dev, unsigned int reg); 58*03b262f2SGregor Boirie 59*03b262f2SGregor Boirie /** 60*03b262f2SGregor Boirie * zpa2326_probe() - Instantiate and register core ZPA2326 IIO device 61*03b262f2SGregor Boirie * @parent: Hardware sampling device the created IIO device will be a child of. 62*03b262f2SGregor Boirie * @name: Arbitrary name to identify the device. 63*03b262f2SGregor Boirie * @irq: Interrupt line, negative if none. 64*03b262f2SGregor Boirie * @hwid: Expected device hardware id. 65*03b262f2SGregor Boirie * @regmap: Registers map used to abstract underlying bus accesses. 66*03b262f2SGregor Boirie * 67*03b262f2SGregor Boirie * Return: Zero when successful, a negative error code otherwise. 68*03b262f2SGregor Boirie */ 69*03b262f2SGregor Boirie int zpa2326_probe(struct device *parent, 70*03b262f2SGregor Boirie const char *name, 71*03b262f2SGregor Boirie int irq, 72*03b262f2SGregor Boirie unsigned int hwid, 73*03b262f2SGregor Boirie struct regmap *regmap); 74*03b262f2SGregor Boirie 75*03b262f2SGregor Boirie /** 76*03b262f2SGregor Boirie * zpa2326_remove() - Unregister and destroy core ZPA2326 IIO device. 77*03b262f2SGregor Boirie * @parent: Hardware sampling device the IIO device to remove is a child of. 78*03b262f2SGregor Boirie */ 79*03b262f2SGregor Boirie void zpa2326_remove(const struct device *parent); 80*03b262f2SGregor Boirie 81*03b262f2SGregor Boirie #ifdef CONFIG_PM 82*03b262f2SGregor Boirie #include <linux/pm.h> 83*03b262f2SGregor Boirie extern const struct dev_pm_ops zpa2326_pm_ops; 84*03b262f2SGregor Boirie #define ZPA2326_PM_OPS (&zpa2326_pm_ops) 85*03b262f2SGregor Boirie #else 86*03b262f2SGregor Boirie #define ZPA2326_PM_OPS (NULL) 87*03b262f2SGregor Boirie #endif 88*03b262f2SGregor Boirie 89*03b262f2SGregor Boirie #endif 90