zephyr: Implement gpio_or_ioex_[gs]et_level
This implements gpio_or_ioex_set_level and gpio_or_ioex_get_level in the
shim layer to match cros ec functionality.
BRANCH=none
TEST=zmake build for volteer and brya pass
#include "gpio.h"
#include "gpio/gpio.h"
+#include "ioexpander.h"
#include "sysjump.h"
#include "cros_version.h"
@@ -148,6 +149,22 @@ void gpio_set_level_verbose(enum console_channel channel,
gpio_set_level(signal, value);
}
+void gpio_or_ioex_set_level(int signal, int value)
+{
+ if (IS_ENABLED(CONFIG_PLATFORM_EC_IOEX) && signal_is_ioex(signal))
+ ioex_set_level(signal, value);
+ else
+ gpio_set_level(signal, value);
+}
+
+int gpio_or_ioex_get_level(int signal, int *value)
+{
+ if (IS_ENABLED(CONFIG_PLATFORM_EC_IOEX) && signal_is_ioex(signal))
+ return ioex_get_level(signal, value);
+ *value = gpio_get_level(signal);
+ return EC_SUCCESS;
+}
+
/* GPIO flags which are the same in Zephyr and this codebase */
#define GPIO_CONVERSION_SAME_BITS \
(GPIO_OPEN_DRAIN | GPIO_PULL_UP | GPIO_PULL_DOWN | GPIO_INPUT | \
