1 /* 2 * Copyright 2024 NXP 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef ZEPHYR_DRIVERS_SENSOR_P3T1755_P3T1755_H_ 8 #define ZEPHYR_DRIVERS_SENSOR_P3T1755_P3T1755_H_ 9 10 #include <zephyr/drivers/sensor.h> 11 12 #if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c) 13 #include <zephyr/drivers/i2c.h> 14 #endif /* DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c) */ 15 16 #if DT_ANY_INST_ON_BUS_STATUS_OKAY(i3c) 17 #include <zephyr/drivers/i3c.h> 18 #endif /* DT_ANY_INST_ON_BUS_STATUS_OKAY(i3c) */ 19 20 #include <zephyr/kernel.h> 21 22 #define P3T1755_BUS_I2C (1<<0) 23 #define P3T1755_BUS_I3C (1<<1) 24 /* Registers. */ 25 #define P3T1755_TEMPERATURE_REG (0x00U) 26 #define P3T1755_CONFIG_REG (0x01U) 27 28 #define P3T1755_TEMPERATURE_REG_SHIFT (0x04U) 29 #define P3T1755_TEMPERATURE_SCALE 62500 30 #define P3T1755_TEMPERATURE_SIGN_BIT BIT(12) 31 #define P3T1755_TEMPERATURE_ABS_MASK ((uint16_t)(P3T1755_TEMPERATURE_SIGN_BIT - 1U)) 32 33 #define P3T1755_CONFIG_REG_OS BIT(7) 34 #define P3T1755_CONFIG_REG_SD BIT(0) 35 36 struct p3t1755_io_ops { 37 int (*read)(const struct device *dev, uint8_t reg, uint8_t *byte, uint8_t len); 38 int (*write)(const struct device *dev, uint8_t reg, uint8_t *byte, uint8_t len); 39 }; 40 41 union p3t1755_bus_cfg { 42 #if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c) 43 const struct i2c_dt_spec i2c; 44 #endif 45 #if DT_ANY_INST_ON_BUS_STATUS_OKAY(i3c) 46 struct i3c_device_desc **i3c; 47 #endif 48 }; 49 50 struct p3t1755_config { 51 const union p3t1755_bus_cfg bus_cfg; 52 const struct p3t1755_io_ops ops; 53 #if DT_ANY_INST_ON_BUS_STATUS_OKAY(i3c) 54 struct { 55 const struct device *bus; 56 const struct i3c_device_id dev_id; 57 } i3c; 58 #endif 59 bool oneshot_mode; 60 uint8_t inst_on_bus; 61 }; 62 63 struct p3t1755_data { 64 int16_t sample; 65 uint8_t config_reg; 66 #if DT_ANY_INST_ON_BUS_STATUS_OKAY(i3c) 67 struct i3c_device_desc *i3c_dev; 68 #endif 69 }; 70 71 #endif /* ZEPHYR_DRIVERS_SENSOR_P3T1755_P3T1755_H_ */ 72