diff options
author | Hyungwoo Yang <hyungwoo.yang@intel.corp-partner.google.com> | 2021-03-19 23:16:27 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-03-24 02:10:49 +0000 |
commit | d4ebcc156bc62d9b883882ddd7b3ad629b926803 (patch) | |
tree | 3aa8ff54b4bfe87973aad63a33df94ce76226a0f | |
parent | 687579bc11306fb1a5b7c4cfa8f721718424f989 (diff) | |
download | chrome-ec-d4ebcc156bc62d9b883882ddd7b3ad629b926803.tar.gz |
zephyr: DT: support BMA255
This change is to support BMA255 via DT.
The change includes, using DT,
- creating BMA255 driver specific data
- creating motion sensor entry for BMA255
BUG=b:173507858
BRANCH=none
TEST=make buildall -j8
build volteer on zephyr
Change-Id: Ie67dc1fb7a25872d48c805b5ba4385dae399f240
Signed-off-by: Hyungwoo Yang <hyungwoo.yang@intel.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2778820
Reviewed-by: Simon Glass <sjg@chromium.org>
4 files changed, 88 insertions, 0 deletions
diff --git a/zephyr/dts/bindings/motionsense/driver/cros-ec,bma255.yaml b/zephyr/dts/bindings/motionsense/driver/cros-ec,bma255.yaml new file mode 100644 index 0000000000..a3d5575fb3 --- /dev/null +++ b/zephyr/dts/bindings/motionsense/driver/cros-ec,bma255.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 BMA255 + +compatible: "cros-ec,bma255" + +# every motionsense sensor node should include motionsense-sensor-base.yaml +include: motionsense-sensor-base.yaml + +properties: + i2c-spi-addr-flags: + type: string + required: true + description: i2c address or SPI slave logic GPIO + enum: + - "BMA2x2_I2C_ADDR1_FLAGS" + - "BMA2x2_I2C_ADDR2_FLAGS" + - "BMA2x2_I2C_ADDR3_FLAGS" + - "BMA2x2_I2C_ADDR4_FLAGS" diff --git a/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-bma255.yaml b/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-bma255.yaml new file mode 100644 index 0000000000..4cabd620da --- /dev/null +++ b/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-bma255.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: BMA255 driver data node + +compatible: "cros-ec,drvdata-bma255" + +include: drvdata-base.yaml + +# +# examples: +# +# bma255_data: bma255-drv-data { +# compatible = "cros-ec,drvdata-bma255"; +# status = "okay"; +# }; +# diff --git a/zephyr/shim/src/motionsense_driver/bma255-drvinfo.inc b/zephyr/shim/src/motionsense_driver/bma255-drvinfo.inc new file mode 100644 index 0000000000..7db46811ad --- /dev/null +++ b/zephyr/shim/src/motionsense_driver/bma255-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 "driver/accel_bma2x2_public.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 BMI260 drvinfo instance in device tree. + * (compatible = "cros-ec,drvdata-bma255") + */ +/* Declare BMA255 driver data */ +#define CREATE_SENSOR_DATA_BMA255(id, drvdata_name) \ + static struct accelgyro_saved_data_t drvdata_name; + +CREATE_SENSOR_DATA(cros_ec_drvdata_bma255, CREATE_SENSOR_DATA_BMA255) + +/* + * 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 BMA255 + * instance(compatible = "cros-ec,bma255") in device tree. + */ +CREATE_MOTION_SENSOR(cros_ec_bma255, MOTIONSENSE_CHIP_BMA255, \ + MOTIONSENSE_TYPE_ACCEL, bma2x2_accel_drv, \ + BMA255_ACCEL_MIN_FREQ, BMA255_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 f1e918bc1b..968d64b5dc 100644 --- a/zephyr/shim/src/motionsense_driver/sensor_drv_list.inc +++ b/zephyr/shim/src/motionsense_driver/sensor_drv_list.inc @@ -17,3 +17,8 @@ * #include "bma255-drvinfo.inc" * #endif */ + +/* supported sensor driver list */ +#ifdef CONFIG_ACCEL_BMA255 +#include "bma255-drvinfo.inc" +#endif |