diff options
4 files changed, 86 insertions, 0 deletions
diff --git a/zephyr/dts/bindings/motionsense/driver/cros-ec,kx022.yaml b/zephyr/dts/bindings/motionsense/driver/cros-ec,kx022.yaml new file mode 100644 index 0000000000..b90d824575 --- /dev/null +++ b/zephyr/dts/bindings/motionsense/driver/cros-ec,kx022.yaml @@ -0,0 +1,21 @@ +# Copyright 2021 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +description: motionsense sensor node for KX022 + +compatible: "cros-ec,kx022" + +# every motionsense sensor node should include motionsense-sensor-base.yaml +include: motionsense-sensor-base.yaml + +properties: + i2c-spi-addr-flags: + type: string + description: i2c address or SPI slave logic GPIO + enum: + - "KX022_ADDR0_FLAGS" + - "KX022_ADDR1_FLAGS" + default: "KX022_ADDR0_FLAGS" + default-range: + default: 2 diff --git a/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-kionix.yaml b/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-kionix.yaml new file mode 100644 index 0000000000..3151412b79 --- /dev/null +++ b/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-kionix.yaml @@ -0,0 +1,18 @@ +# Copyright 2021 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +description: Kionix driver data node + +compatible: "cros-ec,drvdata-kionix" + +include: drvdata-base.yaml + +# +# examples: +# +# kx022_data: kx022-drv-data { +# compatible = "cros-ec,drvdata-kionix"; +# status = "okay"; +# }; +# diff --git a/zephyr/shim/src/motionsense_driver/kx022-drvinfo.inc b/zephyr/shim/src/motionsense_driver/kx022-drvinfo.inc new file mode 100644 index 0000000000..93e471b859 --- /dev/null +++ b/zephyr/shim/src/motionsense_driver/kx022-drvinfo.inc @@ -0,0 +1,44 @@ +/* Copyright 2021 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "accel_kx022.h" + +/* + * CREATE_SENSOR_DATA which is defined in motionsense_sensors.c is + * the helper to create sensor driver specific data. + * + * CREATE_SENSOR_DATA gets two arguments. One is the compatible + * property value specified in device tree and the other one is the macro + * that actually creates sensor driver specific data. The macro gets + * node id and the name to be used for the sensor driver data. + */ + +/* + * Create driver data for each Kionix drvinfo instance in device tree. + * (compatible = "cros-ec,drvdata-kionix") + */ +/* Declare Kionix driver data */ +#define CREATE_SENSOR_DATA_KIONIX(id, drvdata_name) \ + static struct kionix_accel_data drvdata_name; + +CREATE_SENSOR_DATA(cros_ec_drvdata_kionix, CREATE_SENSOR_DATA_KIONIX) + +/* + * CREATE_MOTION_SENSOR which is defined in motionsense_sensors.c is + * the macro to create an entry in motion_sensors array. + * The macro gets value of compatible property of + * the sensor in device tree and sensor specific values like chip ID, + * type of sensor, name of driver, default min/max frequency. + * Then using the values, it creates the corresponding motion_sense_t entry + * in motion_sensors array. + */ + +/* + * Create a motion_sensor_t entry for each KX022 + * instance(compatible = "cros-ec,kx022") in device tree. + */ +CREATE_MOTION_SENSOR(cros_ec_kx022, MOTIONSENSE_CHIP_KX022, \ + MOTIONSENSE_TYPE_ACCEL, kionix_accel_drv, \ + KX022_ACCEL_MIN_FREQ, KX022_ACCEL_MAX_FREQ) diff --git a/zephyr/shim/src/motionsense_driver/sensor_drv_list.inc b/zephyr/shim/src/motionsense_driver/sensor_drv_list.inc index 67fb660dbe..b9b3a189ad 100644 --- a/zephyr/shim/src/motionsense_driver/sensor_drv_list.inc +++ b/zephyr/shim/src/motionsense_driver/sensor_drv_list.inc @@ -22,6 +22,9 @@ #ifdef CONFIG_PLATFORM_EC_ACCEL_BMA255 #include "bma255-drvinfo.inc" #endif +#ifdef CONFIG_PLATFORM_EC_ACCEL_KX022 +#include "kx022-drvinfo.inc" +#endif #ifdef CONFIG_PLATFORM_EC_ACCELGYRO_BMI160 #include "bmi160-drvinfo.inc" #endif |