Read GPIO config from JSON instead of D-Bus
Read the GPIO information for the buttons from
/etc/default/obmc/gpio/gpio_defs.json instead of
from D-Bus, as the D-Bus location for these were a
legacy thing and are going away.
This requires that the GPIO pin name, like 'J1', is converted
to the GPIO number as used in /sys/class/gpio.
The libgpioplus utility will handle most of this for us, with the
exception of needing to look up the base offset in the
/sys/class/gpiochip*/base file, where the specific gpiochip*
directory is determined as following:
1) Find the 'label' file in a /sys/class/gpiochipX/ directory
and check for it to match GPIO_BASE_LABEL_NAME, which is
configurable at build time and defaults to the ASPEED BMC
value.
2) Use the value in the 'base' file in that directory as the
base offset.
If a platform doesn't need to use this base offset, it can be
turned off with the LOOKUP_GPIO_BASE dial.
Change-Id: I88d29529ffa8a6d13132ac9059b47f86344837ea
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 723b300..5115501 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,10 +13,12 @@
set(POWER_DBUS_OBJECT_NAME "xyz/openbmc_project/Chassis/Buttons/Power")
set(RESET_DBUS_OBJECT_NAME "xyz/openbmc_project/Chassis/Buttons/Reset")
set(ID_DBUS_OBJECT_NAME "xyz/openbmc_project/Chassis/Buttons/ID")
+set(GPIO_BASE_LABEL_NAME "1e780000.gpio")
add_definitions(-DPOWER_DBUS_OBJECT_NAME="/${POWER_DBUS_OBJECT_NAME}0")
add_definitions(-DRESET_DBUS_OBJECT_NAME="/${RESET_DBUS_OBJECT_NAME}0")
add_definitions(-DID_DBUS_OBJECT_NAME="/${ID_DBUS_OBJECT_NAME}0")
+add_definitions(-DGPIO_BASE_LABEL_NAME="${GPIO_BASE_LABEL_NAME}")
set(SRC_FILES src/power_button.cpp
src/reset_button.cpp
src/id_button.cpp
@@ -24,6 +26,13 @@
src/gpio.cpp
)
+option (
+ LOOKUP_GPIO_BASE
+ "Look up the GPIO base value in /sys/class/gpio. Otherwise use a base of 0." ON
+)
+
+configure_file (settings.hpp.in ${CMAKE_BINARY_DIR}/inc/settings.hpp)
+
# import sdbusplus
find_package(PkgConfig REQUIRED)
pkg_check_modules(SDBUSPLUSPLUS sdbusplus REQUIRED)