Add gpio-presence-sensor
This is to implement the gpio based hw inventory design [1].
There is a new meson option 'gpio-presence' to enable/disable the
daemon.
Summary of the functionality:
- fetch configuration from EM, according to the configuration interface
- the D-Bus interface is
xyz.openbmc_project.Configuration.GPIODeviceDetect
- the configuration represents devices for which presence can be
detected based on gpio values.
- watch gpios for changes
- add/remove the xyz.openbmc_project.Inventory.Source.DevicePresence
interface on the object path based on gpio values.
References:
[1] https://github.com/openbmc/docs/blob/master/designs/inventory/gpio-based-hardware-inventory.md
[2] https://www.kernel.org/doc/html/latest/admin-guide/gpio/gpio-sim.html
Tested: using linux gpio-sim facility, see below
1. create a fake gpio via [2]
2. configure gpio-presence-sensor as per [1]
3. run the gpio-presence-sensor
4. change the value of the gpio previously configured
5. there should be log output (at debug level)
6. the dbus interfaces exposed should appear/disappear as per [1]
Change-Id: I4cf039b583247581aa5c6c6c59e7fc41ced0bb85
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/meson.build b/meson.build
index a63b6a9..ffef7c8 100644
--- a/meson.build
+++ b/meson.build
@@ -28,7 +28,7 @@
i2c = cpp.find_library('i2c')
endif
-if get_option('devicetree-vpd')
+if get_option('devicetree-vpd') or get_option('gpio-presence')
phosphor_dbus_interfaces_dep = dependency(
'phosphor-dbus-interfaces',
include_type: 'system',
@@ -39,6 +39,10 @@
sdbusplus = dependency('sdbusplus', include_type: 'system')
phosphor_logging_dep = dependency('phosphor-logging')
+if get_option('gpio-presence') or get_option('tests').allowed()
+ libgpio_dep = dependency('libgpiodcxx', default_options: ['bindings=cxx'])
+endif
+
systemd = dependency('systemd')
systemd_system_unit_dir = systemd.get_variable(
'systemdsystemunitdir',
@@ -182,4 +186,22 @@
include_directories: 'src',
),
)
+
+ test(
+ 'test_gpio_presence',
+ executable(
+ 'test_gpio_presence',
+ 'test/test_gpio_presence.cpp',
+ cpp_args: test_boost_args,
+ include_directories: ['src'],
+ dependencies: [
+ boost,
+ gtest,
+ gmock,
+ phosphor_logging_dep,
+ libgpio_dep,
+ ],
+ link_with: gpio_presence_lib,
+ ),
+ )
endif