diff --git a/tests/drivers/gpio/gpio_api_1pin/boards/rpi_pico2_rp2350a_m33.overlay b/tests/drivers/gpio/gpio_api_1pin/boards/rpi_pico2_rp2350a_m33.overlay new file mode 100644 index 00000000000..6bfb9f711f7 --- /dev/null +++ b/tests/drivers/gpio/gpio_api_1pin/boards/rpi_pico2_rp2350a_m33.overlay @@ -0,0 +1,13 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * Copyright (c) 2024 Andrew Featherstone + */ + +/ { + resources { + compatible = "test-gpio-external-pulldown"; + /* Choice of pin on the header is arbitrary. */ + gpios = <&pico_header 15 GPIO_ACTIVE_HIGH>; + }; +}; diff --git a/tests/drivers/gpio/gpio_api_1pin/dts/bindings/test-gpio-external-pulldown.yaml b/tests/drivers/gpio/gpio_api_1pin/dts/bindings/test-gpio-external-pulldown.yaml new file mode 100644 index 00000000000..4534b20f7e2 --- /dev/null +++ b/tests/drivers/gpio/gpio_api_1pin/dts/bindings/test-gpio-external-pulldown.yaml @@ -0,0 +1,18 @@ +# +# Copyright (c) 2024 Andrew Featherstone +# +# SPDX-License-Identifier: Apache-2.0 +# + +description: | + This binding provides resources required to build and run the + tests/drivers/gpio/gpio_api_1pin test in Zephyr on certain hardware. + +compatible: "test-gpio-external-pulldown" + +properties: + gpios: + type: phandle-array + required: true + description: | + Identity of a GPIO that will be configured as both an output and input. diff --git a/tests/drivers/gpio/gpio_api_1pin/src/test_gpio_api.h b/tests/drivers/gpio/gpio_api_1pin/src/test_gpio_api.h index 024c9d1a9db..c001c2026bc 100644 --- a/tests/drivers/gpio/gpio_api_1pin/src/test_gpio_api.h +++ b/tests/drivers/gpio/gpio_api_1pin/src/test_gpio_api.h @@ -11,10 +11,18 @@ #include #include -#if DT_NODE_HAS_PROP(DT_ALIAS(led0), gpios) -#define TEST_NODE DT_GPIO_CTLR(DT_ALIAS(led0), gpios) -#define TEST_PIN DT_GPIO_PIN(DT_ALIAS(led0), gpios) -#define TEST_PIN_DTS_FLAGS DT_GPIO_FLAGS(DT_ALIAS(led0), gpios) +/* If possible, use a dedicated GPIO with an external pulldown resistor. + * Otherwise, fallback to repurposing led0 as a GPIO. The latter won't always + * work as expected when reconfigured as an input. + */ +#if DT_NODE_HAS_STATUS(DT_INST(0, test_gpio_external_pulldown), okay) +#define TEST_NODE DT_GPIO_CTLR(DT_INST(0, test_gpio_external_pulldown), gpios) +#define TEST_PIN DT_GPIO_PIN(DT_INST(0, test_gpio_external_pulldown), gpios) +#define TEST_PIN_DTS_FLAGS DT_GPIO_FLAGS(DT_INST(0, test_gpio_external_pulldown), gpios) +#elif DT_NODE_HAS_PROP(DT_ALIAS(led0), gpios) +#define TEST_NODE DT_GPIO_CTLR(DT_ALIAS(led0), gpios) +#define TEST_PIN DT_GPIO_PIN(DT_ALIAS(led0), gpios) +#define TEST_PIN_DTS_FLAGS DT_GPIO_FLAGS(DT_ALIAS(led0), gpios) #else #error Unsupported board #endif diff --git a/tests/drivers/gpio/gpio_api_1pin/testcase.yaml b/tests/drivers/gpio/gpio_api_1pin/testcase.yaml index 94e929dd9af..dd6a1149a25 100644 --- a/tests/drivers/gpio/gpio_api_1pin/testcase.yaml +++ b/tests/drivers/gpio/gpio_api_1pin/testcase.yaml @@ -1,16 +1,19 @@ +common: + tags: + - drivers + - gpio + depends_on: gpio + min_flash: 48 tests: drivers.gpio.1pin: - tags: - - drivers - - gpio - depends_on: gpio - min_flash: 48 + filter: > + dt_enabled_alias_with_parent_compat("led0", "gpio-leds") + and not dt_compat_enabled("test-gpio-external-pulldown") # Fix exclude when we can exclude just sim run platform_exclude: - mps2/an385 - mps2/an521/cpu0 - neorv32 - filter: dt_enabled_alias_with_parent_compat("led0", "gpio-leds") drivers.gpio.1pin.aw9523b: tags: - drivers @@ -27,3 +30,9 @@ tests: dt_compat_enabled("arduino-header-r3") extra_dtc_overlay_files: - "boards/aw9523b_on_arduino_header.overlay" + drivers.gpio.1pin.external_pull_down: + # For testing boards that require a test fixture that provides a pulldown + # resistor on the GPIO used for the test. + filter: dt_compat_enabled("test-gpio-external-pulldown") + harness_config: + fixture: gpio_external_pull_down