From fef83fc50ea2e59049af733711cc952a19e2cc1c Mon Sep 17 00:00:00 2001 From: Camille BAUD Date: Tue, 5 Nov 2024 12:02:06 +0100 Subject: [PATCH] sensor: Introduce Phosense XBR818 Driver This Introduces a driver for the i2c interface of Phosense XBR818. XBR818 is a 10.525Ghz Radar chip with builtin detection algorithm. Signed-off-by: Camille BAUD --- drivers/sensor/CMakeLists.txt | 1 + drivers/sensor/Kconfig | 1 + drivers/sensor/xbr818/CMakeLists.txt | 5 + drivers/sensor/xbr818/Kconfig | 10 + drivers/sensor/xbr818/xbr818.c | 473 +++++++++++++++++++++++ drivers/sensor/xbr818/xbr818.h | 102 +++++ dts/bindings/sensor/phosense,xbr818.yaml | 20 + dts/bindings/vendor-prefixes.txt | 1 + tests/drivers/build_all/sensor/i2c.dtsi | 7 + 9 files changed, 620 insertions(+) create mode 100644 drivers/sensor/xbr818/CMakeLists.txt create mode 100644 drivers/sensor/xbr818/Kconfig create mode 100644 drivers/sensor/xbr818/xbr818.c create mode 100644 drivers/sensor/xbr818/xbr818.h create mode 100644 dts/bindings/sensor/phosense,xbr818.yaml diff --git a/drivers/sensor/CMakeLists.txt b/drivers/sensor/CMakeLists.txt index 53f12d5eeb63a0..a3394aad502274 100644 --- a/drivers/sensor/CMakeLists.txt +++ b/drivers/sensor/CMakeLists.txt @@ -61,6 +61,7 @@ add_subdirectory_ifdef(CONFIG_TH02 th02) add_subdirectory_ifdef(CONFIG_TSIC_XX6 tsic_xx6) add_subdirectory_ifdef(CONFIG_VEAA_X_3 veaa_x_3) add_subdirectory_ifdef(CONFIG_VOLTAGE_DIVIDER voltage_divider) +add_subdirectory_ifdef(CONFIG_XBR818 xbr818) add_subdirectory_ifdef(CONFIG_TACH_ENE_KB1200 ene_tach_kb1200) zephyr_syscall_header(${ZEPHYR_BASE}/include/zephyr/drivers/sensor.h) diff --git a/drivers/sensor/Kconfig b/drivers/sensor/Kconfig index 329a6a858698ab..34e01003fce248 100644 --- a/drivers/sensor/Kconfig +++ b/drivers/sensor/Kconfig @@ -145,6 +145,7 @@ source "drivers/sensor/th02/Kconfig" source "drivers/sensor/tsic_xx6/Kconfig" source "drivers/sensor/veaa_x_3/Kconfig" source "drivers/sensor/voltage_divider/Kconfig" +source "drivers/sensor/xbr818/Kconfig" source "drivers/sensor/ene_tach_kb1200/Kconfig" endif # SENSOR diff --git a/drivers/sensor/xbr818/CMakeLists.txt b/drivers/sensor/xbr818/CMakeLists.txt new file mode 100644 index 00000000000000..96d6c578d64dbc --- /dev/null +++ b/drivers/sensor/xbr818/CMakeLists.txt @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 + +zephyr_library() + +zephyr_library_sources_ifdef(CONFIG_XBR818 xbr818.c) diff --git a/drivers/sensor/xbr818/Kconfig b/drivers/sensor/xbr818/Kconfig new file mode 100644 index 00000000000000..75b91c758ac784 --- /dev/null +++ b/drivers/sensor/xbr818/Kconfig @@ -0,0 +1,10 @@ +# Copyright (c) 2024 MASSDRIVER EI (massdriver.space) +# SPDX-License-Identifier: Apache-2.0 + +config XBR818 + bool "XBR818 Radar" + default y + depends on DT_HAS_PHOSENSE_XBR818_ENABLED + select I2C + help + Enable driver for the Phosense XBR818 Radar Sensor diff --git a/drivers/sensor/xbr818/xbr818.c b/drivers/sensor/xbr818/xbr818.c new file mode 100644 index 00000000000000..c3cdbc318ccf80 --- /dev/null +++ b/drivers/sensor/xbr818/xbr818.c @@ -0,0 +1,473 @@ +/* + * Copyright (c) 2024 MASSDRIVER EI (massdriver.space) + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#define DT_DRV_COMPAT phosense_xbr818 + +#include +#include +#include +#include +#include + +#include +LOG_MODULE_REGISTER(XBR818, CONFIG_SENSOR_LOG_LEVEL); + +#include "xbr818.h" + +static int xbr818_sample_fetch(const struct device *dev, enum sensor_channel chan) +{ + const struct xbr818_config *config = dev->config; + struct xbr818_data *data = dev->data; + int ret; + + if (chan != SENSOR_CHAN_PROX && chan != SENSOR_CHAN_ALL) { + LOG_ERR("%s: requesting unsupported channel %i", dev->name, chan); + return -ENOTSUP; + } + + ret = gpio_pin_get_dt(&config->io_val); + if (ret < 0) { + return ret; + } + data->value = (ret == 1 ? true : false); + + return 0; +} + +static int xbr818_channel_get(const struct device *dev, enum sensor_channel chan, + struct sensor_value *val) +{ + struct xbr818_data *data = dev->data; + + if (chan != SENSOR_CHAN_PROX) { + LOG_ERR("%s: requesting unsupported channel %i", dev->name, chan); + return -ENOTSUP; + } + + val->val1 = (data->value ? 1 : 0); + val->val2 = 0; + + return 0; +} + +static int xbr818_attr_set(const struct device *dev, enum sensor_channel chan, + enum sensor_attribute attr, const struct sensor_value *val) +{ + const struct xbr818_config *config = dev->config; + int ret; + uint32_t tmp; + uint64_t tmpf; + + if (chan != SENSOR_CHAN_PROX) { + LOG_ERR("%s: requesting unsupported channel %i", dev->name, chan); + return -ENOTSUP; + } + + if (val->val1 < 0) { + return -EINVAL; + } + + gpio_pin_set_dt(&config->i2c_en, 1); + + switch (attr) { + case SENSOR_ATTR_LOWER_THRESH: + if (val->val1 > 0xFFFF) { + return -EINVAL; + } + tmp = val->val1 & 0xFF; + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_THRESHOLD_1, tmp); + if (ret != 0) { + break; + } + tmp = (val->val1 & 0xFF00) >> 8; + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_THRESHOLD_2, tmp); + break; + case SENSOR_ATTR_XBR818_NOISE_FLOOR: + if (val->val1 > 0xFFFF) { + return -EINVAL; + } + tmp = val->val1 & 0xFF; + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_THRESHOLD_NOISE_1, tmp); + if (ret != 0) { + break; + } + tmp = (val->val1 & 0xFF00) >> 8; + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_THRESHOLD_NOISE_2, tmp); + break; + case SENSOR_ATTR_XBR818_DELAY_TIME: + tmpf = (uint64_t)val->val1 * 1000000 + (uint64_t)val->val2; + tmpf = (tmpf * SENSOR_XBR818_CLOCKRATE) / 1000000; + if (tmpf > 0xFFFFFF) { + return -EINVAL; + } + tmp = tmpf & 0xFF; + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_DELAY_TIME_1, tmp); + if (ret != 0) { + break; + } + tmp = (tmpf & 0xFF00) >> 8; + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_DELAY_TIME_2, tmp); + if (ret != 0) { + break; + } + tmp = (tmpf & 0xFF0000) >> 16; + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_DELAY_TIME_3, tmp); + break; + case SENSOR_ATTR_XBR818_LOCK_TIME: + tmpf = (uint64_t)val->val1 * 1000000 + (uint64_t)val->val2; + tmpf = (tmpf * SENSOR_XBR818_CLOCKRATE) / 1000000; + if (tmpf > 0xFFFFFF) { + return -EINVAL; + } + tmp = tmpf & 0xFF; + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_LOCK_TIME_1, tmp); + if (ret != 0) { + break; + } + tmp = (tmpf & 0xFF00) >> 8; + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_LOCK_TIME_2, tmp); + if (ret != 0) { + break; + } + tmp = (tmpf & 0xFF0000) >> 16; + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_LOCK_TIME_3, tmp); + break; + case SENSOR_ATTR_XBR818_RF_POWER: + if (val->val1 > 0x7) { + return -EINVAL; + } + tmp = val->val1 & 0x7; + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_RF_POWER, tmp); + break; + case SENSOR_ATTR_SAMPLING_FREQUENCY: + if (val->val1 > SENSOR_XBR818_CLOCKRATE) { + return -EINVAL; + } + tmp = SENSOR_XBR818_CLOCKRATE / val->val1; + if (tmp > 0xFF) { + return -EINVAL; + } + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_SAMPLE_RATE_DIVIDER, tmp); + break; + default: + ret = -ENODEV; + + break; + } + + gpio_pin_set_dt(&config->i2c_en, 0); + + return ret; +} + +static int xbr818_attr_get(const struct device *dev, enum sensor_channel chan, + enum sensor_attribute attr, struct sensor_value *val) +{ + const struct xbr818_config *config = dev->config; + int ret; + uint8_t tmp = 0; + uint64_t tmpf; + + if (chan != SENSOR_CHAN_PROX) { + LOG_ERR("%s: requesting unsupported channel %i", dev->name, chan); + return -ENOTSUP; + } + + gpio_pin_set_dt(&config->i2c_en, 1); + + switch (attr) { + case SENSOR_ATTR_LOWER_THRESH: + ret = i2c_reg_read_byte_dt(&config->i2c, XBR818_THRESHOLD_1, &tmp); + if (ret != 0) { + break; + } + val->val1 = tmp & 0xFF; + ret = i2c_reg_read_byte_dt(&config->i2c, XBR818_THRESHOLD_2, &tmp); + if (ret != 0) { + break; + } + val->val1 |= tmp << 8; + break; + case SENSOR_ATTR_XBR818_NOISE_FLOOR: + ret = i2c_reg_read_byte_dt(&config->i2c, XBR818_THRESHOLD_NOISE_1, &tmp); + if (ret != 0) { + break; + } + val->val1 = tmp & 0xFF; + ret = i2c_reg_read_byte_dt(&config->i2c, XBR818_THRESHOLD_NOISE_2, &tmp); + if (ret != 0) { + break; + } + val->val1 |= tmp << 8; + break; + case SENSOR_ATTR_XBR818_DELAY_TIME: + ret = i2c_reg_read_byte_dt(&config->i2c, XBR818_DELAY_TIME_1, &tmp); + if (ret != 0) { + break; + } + val->val1 = tmp & 0xFF; + ret = i2c_reg_read_byte_dt(&config->i2c, XBR818_DELAY_TIME_2, &tmp); + if (ret != 0) { + break; + } + val->val1 |= tmp << 8; + ret = i2c_reg_read_byte_dt(&config->i2c, XBR818_DELAY_TIME_3, &tmp); + if (ret != 0) { + break; + } + val->val1 |= tmp << 16; + tmpf = (uint64_t)val->val1 * 1000000; + tmpf /= SENSOR_XBR818_CLOCKRATE; + val->val1 = tmpf / 1000000; + val->val2 = tmpf - val->val1 * 1000000; + break; + case SENSOR_ATTR_XBR818_LOCK_TIME: + ret = i2c_reg_read_byte_dt(&config->i2c, XBR818_LOCK_TIME_1, &tmp); + if (ret != 0) { + break; + } + val->val1 = tmp & 0xFF; + ret = i2c_reg_read_byte_dt(&config->i2c, XBR818_LOCK_TIME_2, &tmp); + if (ret != 0) { + break; + } + val->val1 |= tmp << 8; + ret = i2c_reg_read_byte_dt(&config->i2c, XBR818_LOCK_TIME_3, &tmp); + if (ret != 0) { + break; + } + val->val1 |= tmp << 16; + tmpf = (uint64_t)val->val1 * 1000000; + tmpf /= SENSOR_XBR818_CLOCKRATE; + val->val1 = tmpf / 1000000; + val->val2 = tmpf - val->val1 * 1000000; + break; + case SENSOR_ATTR_XBR818_RF_POWER: + ret = i2c_reg_read_byte_dt(&config->i2c, XBR818_RF_POWER, &tmp); + if (ret != 0) { + break; + } + val->val1 = tmp & 0x7; + break; + case SENSOR_ATTR_SAMPLING_FREQUENCY: + ret = i2c_reg_read_byte_dt(&config->i2c, XBR818_SAMPLE_RATE_DIVIDER, &tmp); + if (ret != 0) { + break; + } + val->val1 = SENSOR_XBR818_CLOCKRATE / tmp; + break; + default: + ret = -ENODEV; + + break; + } + + gpio_pin_set_dt(&config->i2c_en, 0); + + return ret; +} + +static void xbr818_work(struct k_work *work) +{ + struct xbr818_data *data = CONTAINER_OF(work, struct xbr818_data, work); + + if (likely(data->handler != NULL)) { + data->handler(data->dev, data->trigger); + } +} + +static void xbr818_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) +{ + struct xbr818_data *data = CONTAINER_OF(cb, struct xbr818_data, gpio_cb); + + k_work_submit(&data->work); +} + +static int xbr818_trigger_set(const struct device *dev, const struct sensor_trigger *trig, + sensor_trigger_handler_t handler) +{ + const struct xbr818_config *config = dev->config; + struct xbr818_data *data = dev->data; + int ret; + + if (trig->chan != SENSOR_CHAN_PROX) { + LOG_ERR("%s: requesting unsupported channel %i", dev->name, trig->chan); + return -ENOTSUP; + } + + if (trig->type != SENSOR_TRIG_MOTION) { + LOG_ERR("%s: requesting unsupported trigger %i", dev->name, trig->type); + return -ENOTSUP; + } + + data->handler = handler; + data->trigger = trig; + ret = gpio_pin_interrupt_configure_dt(&config->io_val, GPIO_INT_EDGE_RISING); + if (ret < 0) { + return ret; + } + + if (handler) { + ret = gpio_add_callback(config->io_val.port, &data->gpio_cb); + } else { + ret = gpio_remove_callback(config->io_val.port, &data->gpio_cb); + } + + return ret; +} + +static int xbr818_init_defaults(const struct device *dev) +{ + const struct xbr818_config *config = dev->config; + int ret; + + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_IO_ACTIVE_VALUE_REG, 0x03); + if (ret != 0) { + return ret; + } + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_RF_EN_SEL, 0x20); + if (ret != 0) { + return ret; + } + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_SAMPLE_RATE_DIVIDER, 0x20); + if (ret != 0) { + return ret; + } + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_RF_POWER, 0x45); + if (ret != 0) { + return ret; + } + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_TIMER_CTRL, 0x21); + if (ret != 0) { + return ret; + } + + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_THRESHOLD_1, 0x5a); + if (ret != 0) { + return ret; + } + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_THRESHOLD_2, 0x01); + if (ret != 0) { + return ret; + } + + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_THRESHOLD_NOISE_1, 0x55); + if (ret != 0) { + return ret; + } + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_THRESHOLD_NOISE_2, 0x01); + if (ret != 0) { + return ret; + } + + /* 0.1 seconds */ + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_DELAY_TIME_1, 0x80); + if (ret != 0) { + return ret; + } + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_DELAY_TIME_2, 0x0C); + if (ret != 0) { + return ret; + } + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_DELAY_TIME_3, 0x00); + if (ret != 0) { + return ret; + } + + /* 0.5 seconds */ + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_LOCK_TIME_1, 0x80); + if (ret != 0) { + return ret; + } + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_LOCK_TIME_2, 0x3E); + if (ret != 0) { + return ret; + } + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_LOCK_TIME_3, 0x00); + if (ret != 0) { + return ret; + } + + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_PIN_SETTINGS, 0x0C); + if (ret != 0) { + return ret; + } + + ret = i2c_reg_write_byte_dt(&config->i2c, XBR818_I2C_OUT, 0x1); + if (ret != 0) { + return ret; + } + + return 0; +} + +static int xbr818_init(const struct device *dev) +{ + const struct xbr818_config *config = dev->config; + struct xbr818_data *data = dev->data; + int ret; + + if (!i2c_is_ready_dt(&config->i2c)) { + LOG_ERR("I2C device not ready"); + return -ENODEV; + } + + data->dev = dev; + data->work.handler = xbr818_work; + + ret = gpio_pin_configure_dt(&config->io_val, GPIO_INPUT); + if (ret != 0) { + return ret; + } + + ret = gpio_pin_configure_dt(&config->i2c_en, GPIO_OUTPUT); + if (ret != 0) { + return ret; + } + + gpio_pin_set_dt(&config->i2c_en, 1); + + ret = xbr818_init_defaults(dev); + + gpio_pin_set_dt(&config->i2c_en, 0); + + if (ret != 0) { + LOG_ERR("%s: unable to configure", dev->name); + } + + ret = gpio_pin_interrupt_configure_dt(&config->io_val, GPIO_INT_DISABLE); + if (ret) { + LOG_ERR("failed to configure gpio interrupt: %d", ret); + return ret; + } + + gpio_init_callback(&data->gpio_cb, xbr818_gpio_callback, BIT(config->io_val.pin)); + + return ret; +} + +static const struct sensor_driver_api xbr818_api = { + .sample_fetch = xbr818_sample_fetch, + .channel_get = xbr818_channel_get, + .attr_set = xbr818_attr_set, + .attr_get = xbr818_attr_get, + .trigger_set = xbr818_trigger_set, +}; + +#define XBR818_INIT(inst) \ + static const struct xbr818_config xbr818_##inst##_config = { \ + .i2c = I2C_DT_SPEC_INST_GET(inst), \ + .i2c_en = GPIO_DT_SPEC_GET(DT_INST(inst, phosense_xbr818), i2c_en_gpios), \ + .io_val = GPIO_DT_SPEC_GET(DT_INST(inst, phosense_xbr818), int_gpios), \ + }; \ + \ + static struct xbr818_data xbr818_##inst##_data; \ + \ + SENSOR_DEVICE_DT_INST_DEFINE(inst, xbr818_init, NULL, &xbr818_##inst##_data, \ + &xbr818_##inst##_config, POST_KERNEL, \ + CONFIG_SENSOR_INIT_PRIORITY, &xbr818_api); + +DT_INST_FOREACH_STATUS_OKAY(XBR818_INIT); diff --git a/drivers/sensor/xbr818/xbr818.h b/drivers/sensor/xbr818/xbr818.h new file mode 100644 index 00000000000000..ba6f548afe1e02 --- /dev/null +++ b/drivers/sensor/xbr818/xbr818.h @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2024 MASSDRIVER EI (massdriver.space) + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_DRIVERS_SENSOR_XBR818_XBR818_H_ +#define ZEPHYR_DRIVERS_SENSOR_XBR818_XBR818_H_ + +#include +#include +#include +#include + +#define SENSOR_ATTR_XBR818_DELAY_TIME (SENSOR_ATTR_PRIV_START) +#define SENSOR_ATTR_XBR818_LOCK_TIME (SENSOR_ATTR_PRIV_START + 1) +#define SENSOR_ATTR_XBR818_NOISE_FLOOR (SENSOR_ATTR_PRIV_START + 2) +#define SENSOR_ATTR_XBR818_RF_POWER (SENSOR_ATTR_PRIV_START + 3) + +/* 32Khz clockrate, most time values are multiple of this */ +#define SENSOR_XBR818_CLOCKRATE 32000 + +struct xbr818_config { + struct i2c_dt_spec i2c; + struct gpio_dt_spec i2c_en; + struct gpio_dt_spec io_val; +}; + +struct xbr818_data { + bool value; + uint32_t trigger_type; + sensor_trigger_handler_t handler; + struct gpio_callback gpio_cb; + const struct sensor_trigger *trigger; + const struct device *dev; + struct k_work work; +}; + +/* reference rd-04 module manual for more information */ +/* [0-2]: power of PA + * [4-6]: mixer trim + */ +#define XBR818_RF_POWER 0x03 +#define XBR818_RF_EN_SEL 0x04 +/* minimum value of 2 */ +#define XBR818_SAMPLE_RATE_DIVIDER 0x10 +/* [0]: enable detection + * [1-2]: readable data. 0: det_dc_sum 1: det_ac_sum 2: det_dc_used 3: det_noise + * [3]: enable read on 0x28-0x29 + * [4]: signal detection threshold. 0: auto by pin 1: register + * [7]: enable read on 0x26-0x29 + */ +#define XBR818_I2C_OUT 0x13 +/* Threshold for detection + * [0-7] + */ +#define XBR818_THRESHOLD_1 0x18 +/* [8-15] */ +#define XBR818_THRESHOLD_2 0x19 +/* Threshold for noise + * [0-7] + */ +#define XBR818_THRESHOLD_NOISE_1 0x1A +/* [8-15] */ +#define XBR818_THRESHOLD_NOISE_2 0x1B +/* Delay Time (in 1/32000 seconds) + * [0-7] + */ +#define XBR818_DELAY_TIME_1 0x1D +/* [8-15] */ +#define XBR818_DELAY_TIME_2 0x1E +/* [16-23] */ +#define XBR818_DELAY_TIME_3 0x1F +/* [0]: enable + * [1-2]: light sensor timer. 0: disabled 1: 4 sec 2: 1 minute 3: 1 hour + * [3-4]: output timer. 0: 1 sec 1: 1 minute 2: 1 hour 3: 1 day + * [5]: delay time. 0: 'configure by pin' 1: configure by register + */ +#define XBR818_TIMER_CTRL 0x1C +/* Lock Time (in 1/32000 seconds) + * [0-7] + */ +#define XBR818_LOCK_TIME_1 0x20 +/* [8-15] */ +#define XBR818_LOCK_TIME_2 0x21 +/* [16-23] */ +#define XBR818_LOCK_TIME_3 0x22 +/* Pin settings + * [0-3]: IO_VAL pin + * 0xc: io_value_out, 0xd: io_value_out inverted, 0xf: GPIO + * [4-7]: INT_IRQ pin + * 0x0: t3_int_irq, 0x9: io_value_out, 0xa: io_value_out inverted, 0xf: GPIO + */ +#define XBR818_PIN_SETTINGS 0x23 +/* [0]: ADC1 is configuration for VCO trimming. 0: enable, 1: disable + * [1]: Low power mode is pin or register. 0: pin 1: register + * [2]: If IO_VAL pin is GPIO, output. 0: no 1: yes + * [3]: if INT_IRQ pin is GPIO, output. 0:no 1:yes + */ +#define XBR818_IO_ACTIVE_VALUE_REG 0x24 + +#endif /* ZEPHYR_DRIVERS_SENSOR_XBR818_XBR818_H_ */ diff --git a/dts/bindings/sensor/phosense,xbr818.yaml b/dts/bindings/sensor/phosense,xbr818.yaml new file mode 100644 index 00000000000000..67084055165760 --- /dev/null +++ b/dts/bindings/sensor/phosense,xbr818.yaml @@ -0,0 +1,20 @@ +# Copyright (c) 2024 MASSDRIVER EI (massdriver.space) +# SPDX-License-Identifier: Apache-2.0 + +description: | + Phosense XBR818 I2C-capable 10Ghz Radar Sensor + +compatible: "phosense,xbr818" + +include: [sensor-device.yaml, i2c-device.yaml] + +properties: + int-gpios: + type: phandle-array + required: true + description: GPIO pin connected to IO pin (IO_VAL) + + i2c_en-gpios: + type: phandle-array + required: true + description: GPIO pin connected to I2C enable (I2C_EN) diff --git a/dts/bindings/vendor-prefixes.txt b/dts/bindings/vendor-prefixes.txt index 5ad47d5969b67a..c00a52f9530c37 100644 --- a/dts/bindings/vendor-prefixes.txt +++ b/dts/bindings/vendor-prefixes.txt @@ -505,6 +505,7 @@ pda Precision Design Associates, Inc. pericom Pericom Technology Inc. pervasive Pervasive Displays, Inc. phicomm PHICOMM Co., Ltd. +phosense Beijing Phosense Electronic Technology Co., Ltd. phytec PHYTEC picochip Picochip Ltd pine64 Pine64 diff --git a/tests/drivers/build_all/sensor/i2c.dtsi b/tests/drivers/build_all/sensor/i2c.dtsi index 9a21c61a698a70..545a3c3b5bdc02 100644 --- a/tests/drivers/build_all/sensor/i2c.dtsi +++ b/tests/drivers/build_all/sensor/i2c.dtsi @@ -768,6 +768,13 @@ test_i2c_tsl2540: tsl2540@71 { int-gpios = <&test_gpio 0 0>; }; +test_i2c_xbr818: xrb8180@71 { + compatible = "phosense,xbr818"; + reg = <0x71>; + int-gpios = <&test_gpio 0 0>; + i2c_en-gpios = <&test_gpio 0 0>; +}; + test_i2c_adltc2990@72 { compatible = "adi,adltc2990"; reg = <0x72>;