diff options
-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); |