diff options
author | Andrew McRae <amcrae@google.com> | 2022-01-13 19:04:55 +1100 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-01-18 17:14:33 +0000 |
commit | be788ddde42b62526a76011e44b4bc09e1335b0a (patch) | |
tree | d758f3ec202d01975e3832d240d43c4e3c9389cd | |
parent | 2b89203c47afd335eafaa4bc9187ed03c8c6d75d (diff) | |
download | chrome-ec-be788ddde42b62526a76011e44b4bc09e1335b0a.tar.gz |
zephyr: Initialise non-disabled GPIOs
Allow GPIOs to be configured as 'inactive', and
do not initialise them at the start.
BUG=b:214333364
TEST=zmake configure -b nivviks; flash & run
BRANCH=none
Signed-off-by: Andrew McRae <amcrae@google.com>
Change-Id: I98979f9c025bf4050b384d7e2c84271ff4e30022
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3384130
Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r-- | zephyr/dts/bindings/gpio/named-gpios.yaml | 30 | ||||
-rw-r--r-- | zephyr/shim/src/gpio.c | 19 |
2 files changed, 29 insertions, 20 deletions
diff --git a/zephyr/dts/bindings/gpio/named-gpios.yaml b/zephyr/dts/bindings/gpio/named-gpios.yaml index 1f694a853b..360e15fd9b 100644 --- a/zephyr/dts/bindings/gpio/named-gpios.yaml +++ b/zephyr/dts/bindings/gpio/named-gpios.yaml @@ -3,13 +3,23 @@ description: Named GPIOs parent node compatible: "named-gpios" child-binding: - description: Named GPIOs child node - include: gpio-enum-name.yaml - properties: - gpios: - type: phandle-array - required: true - "#gpio-cells": - type: int - required: false - const: 0 + description: Named GPIOs child node + include: gpio-enum-name.yaml + properties: + gpios: + type: phandle-array + required: true + "#gpio-cells": + type: int + required: false + const: 0 + no-auto-init: + description: + When set, the GPIO is not initialised, and can be + initialised separately in code, but is still saved so that + it appears in the list of GPIOs. + + When not set, the GPIO h/w is configured and initialised at startup + according to the flags in the gpios node. + type: boolean + required: false diff --git a/zephyr/shim/src/gpio.c b/zephyr/shim/src/gpio.c index e277db2e05..8ebff4cdf3 100644 --- a/zephyr/shim/src/gpio.c +++ b/zephyr/shim/src/gpio.c @@ -28,6 +28,8 @@ struct gpio_config { gpio_pin_t pin; /* From DTS, excludes interrupts flags */ gpio_flags_t init_flags; + /* From DTS, skips initialisation */ + bool no_auto_init; }; #define GPIO_CONFIG(id) \ @@ -39,6 +41,7 @@ struct gpio_config { .dev = DEVICE_DT_GET(DT_PHANDLE(id, gpios)), \ .pin = DT_GPIO_PIN(id, gpios), \ .init_flags = DT_GPIO_FLAGS(id, gpios), \ + .no_auto_init = DT_PROP(id, no_auto_init), \ }, ), \ ()) static const struct gpio_config configs[] = { @@ -331,22 +334,18 @@ int gpio_get_default_flags(enum gpio_signal signal) static int init_gpios(const struct device *unused) { gpio_flags_t flags; - struct jump_data *jdata; - bool is_sys_jumped; + struct jump_data *jdata = get_jump_data(); + bool is_sys_jumped = (jdata && jdata->magic == JUMP_DATA_MAGIC); ARG_UNUSED(unused); - jdata = get_jump_data(); - - if (jdata && jdata->magic == JUMP_DATA_MAGIC) - is_sys_jumped = true; - else - is_sys_jumped = false; - - /* Loop through all GPIOs in device tree to set initial configuration */ for (size_t i = 0; i < ARRAY_SIZE(configs); ++i) { int rv; + /* Skip GPIOs that have set no-auto-init. */ + if (configs[i].no_auto_init) + continue; + if (!device_is_ready(configs[i].dev)) LOG_ERR("Not found (%s)", configs[i].name); |