-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dts: bindings: Introduce base sensor device properties #49294
dts: bindings: Introduce base sensor device properties #49294
Conversation
Introduces an initial set of devicetree properties to be inherited by all sensor devices, similar to how we define a base set of devicetree properties for I2C and SPI devices. These properties will be used by the future sensor subsystem to manage and expose sensors to a host operating system, through HID or another protocol. Signed-off-by: Maureen Helm <maureen.helm@intel.com>
Migrates all ST sensors to inherit base sensor device properties, and sets vendor and model default values accordingly. Signed-off-by: Maureen Helm <maureen.helm@intel.com>
Migrates all NXP sensors to inherit base sensor device properties, and sets vendor and model default values accordingly. Signed-off-by: Maureen Helm <maureen.helm@intel.com>
Updates NXP sensor drivers to use SENSOR_DEVICE_DT_INST_DEFINE, which is a sensor-specific variant of DEVICE_DT_DEFINE that enables optional instantiation of additional structures to be used by the future sensor subsystem. Currently this defines an element in the sensor info iterable section to hold the vendor and model name. This approach was inspired by I2C_DEVICE_DT_INST_DEFINE to streamline adding I2C stats support across all I2C drivers. Signed-off-by: Maureen Helm <maureen.helm@intel.com>
Adds a new conditional shell command to the sensor shell to get data from the sensor info iterable section, such as vendor and model name, for all sensors. Signed-off-by: Maureen Helm <maureen.helm@intel.com>
Extends the sensor shell sample application to demonstrate the sensor info shell command and iterable section support. An application-level devicetree overlay for the x_nucleo_iks01a3 shield sets sensor device properties like friendly-name to identify which sensor is the "lid" accelerometer and which is the "base" accelerometer. Signed-off-by: Maureen Helm <maureen.helm@intel.com>
Adds an application-level devicetree overlay for the x_nucleo_iks01a3 shield to demonstrate virtual sensor nodes in the sensor shell sample. A stubbed virtual sensor driver instantiates a sensor device and sensor info structure for each enabled virtual sensor node in the devicetree. Signed-off-by: Maureen Helm <maureen.helm@intel.com>
The lpcxpresso55s16, pan1781_evb, and pan1782_evb boards have some pins missing in their arduino_header devicetree node, which makes them incompatible with the x_nucleo_iks01a3 shield. Signed-off-by: Maureen Helm <maureen.helm@intel.com>
ac27636
to
8aedd8d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we need vendor info, we should extract it from the compatible and expose in gen_defines.py. There's logic already in edtlib.py to parse vendor and compare against 'vendor-prefixes.txt' database. We can expose thus further if needed.
include: base.yaml | ||
|
||
properties: | ||
vendor: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want vendor
and such. We can expose this from edtlib and gen_defines.py. We have a lot of the logic already in _check_compatible
function in edtlib.py.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this idea, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks for this!
@@ -4,6 +4,24 @@ | |||
* SPDX-License-Identifier: Apache-2.0 | |||
*/ | |||
|
|||
/ { | |||
virtual-sensors { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The virtual-sensors
concepts can be leveraged by the proposed senss
(#45370) for virtual sensor device tree node definitions.
But from senss
's view, there're some more things need to consider:
-
senss
can only enumerate and managementsenss sensors
(implemented thesenss sensor
API)
So, suggest define a device tree parent node for allsenss sensors
, such assensor-subsystem
, thensenss
can enumerate allsenss sensors
fromsensor-subsystem
node.
This can also help isolatesenss sensors
nodes with zephyr sensor device nodes for existing API or V2 API (drivers: Add sensors v2 API #44098), and both of them can inherit the base sensor properties, such as vendor, model, friendly-name. -
reporters
phandle property forsenss virtual sensor
must also point tosenss sensor(s)
(either virtual or physical) -
senss physical sensor
is not a zephyr physical device sensor (implement the existing API, or V2 API).Unlike
senss virtual sensor
takes othersenss sensor(s)
(virtual or physical) as input reporters, asenss physical sensor
has nosenss sensors
as inputs (reporters
not defined or empty), it's just a data producer, collect underlying physical device's data etc.
The underlying device can be zephyr physical sensor device (existing API or V2), or even can be any other devices, such as a wifi/ble device, or even pure sw which an produce data and can be abstract as a sensor. This can makesenss
more extensible and powerful.So, in
senss
, we defined theunderlying-device
for asenss physical sensor
to reference a nonesenss sensor
device.For example:
/{ &senss { hinge_angle : hinge-angle { compatible = "senss,hinge-angle" reporters =<&base_accel &lid_accel> } base_accel: base-accel { compatible = "senss,phy-accel" underlying-device = <&bmi_spi> } lid_accel: lid-accel { compatible = "senss,phy-accel" underlying-device = <&bmi_i2c> } } &spi0 { bmi_spi: bmi@3 { compatible = "bosch,bmi160" } } &i2c0 { bmi_i2c: bmi@68 { compatible = "bosch,bmi160" } } }
bmi_i2c
andbmi_spi
are nonsenss sensors
nodes.
I also very like the sensor info command, and can be leveraged in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed about extracting the vendor / device from the compatible property for the matching binding in edtlib. A couple of other questions.
type: string | ||
required: false | ||
|
||
friendly-name: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could maybe use label for this purpose?
Seems like a legitimate usage of label
to me. @galak?
type: string | ||
required: false | ||
|
||
child-binding: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not disagreeing with your analysis, @MaureenHelm , but I am wondering whether you've looked at iio bindings when doing it. It seems to me like iio is the de facto standard for sensor bindings in Linux and I want to understand how decisions to deviate from its bindings, if any, were made, especially given @galak 's tepid enthusiasm for deviating from Linux (conveyed to me privately)
@MaureenHelm The last commit in this PR #49374 shows a POC implementation of how to assign vendor and model to sensors using the new properties files, and how to create a list of sensors and their properties at compile time using the multi api device model. What do you think? |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
Introduces an initial set of devicetree properties to be inherited by
all sensor devices, similar to how we define a base set of devicetree
properties for I2C and SPI devices. These properties will be used by the
future sensor subsystem to manage and expose sensors to a host operating
system, through HID or another protocol.
Signed-off-by: Maureen Helm maureen.helm@intel.com
Fixes #48148
cc: @huhebo
A key difference between this proposal and those discussed in #48148 and #45370 is that existing sensor drivers inherit base sensor properties and don't require corresponding shim nodes for the sensor subsystem. This is one less level of indirection and puts properties like vendor and model name with the physical device. Virtual sensors also inherit base sensor properties, but unlike physical sensors, they don't inherit communication bus properties from
i2c-device.yaml
orspi-device.yaml
.Instantiation of data structures that contain these properties takes some inspiration from network interfaces and utilizes iterable sections to allow enumeration of all sensor drivers in the system.
Further details are documented in commit messages in this PR. If this approach is accepted, I'll extend it to all the other vendors (currently I only instrumented ST and NXP sensors).
Example 1: Physical and mocked virtual sensors
Example 2: Physical sensors on a different board
Note that other sensors on the reel board don't yet appear in the console because I've only instrumented ST and NXP sensors.