This is an automated email from the ASF dual-hosted git repository. raiden00 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 21e580b9c43ac714a598c6b2e59eeb10dd9afc58 Author: Eren Terzioglu <eren.terzio...@espressif.com> AuthorDate: Tue Apr 8 15:17:47 2025 +0200 boards/risc-v: Add dedicated GPIO board level support for esp32[-c3|-c6|-h2] Add board level dedicated GPIO support for risc-v based Espressif devices Signed-off-by: Eren Terzioglu <eren.terzio...@espressif.com> --- .../esp32c3/esp32c3-generic/src/esp32c3_gpio.c | 44 ++++++++++++++++++++++ .../esp32c6/esp32c6-devkitc/src/esp32c6_gpio.c | 44 ++++++++++++++++++++++ .../esp32h2/esp32h2-devkit/src/esp32h2_gpio.c | 44 ++++++++++++++++++++++ 3 files changed, 132 insertions(+) diff --git a/boards/risc-v/esp32c3/esp32c3-generic/src/esp32c3_gpio.c b/boards/risc-v/esp32c3/esp32c3-generic/src/esp32c3_gpio.c index c751699193..0d9417d37e 100644 --- a/boards/risc-v/esp32c3/esp32c3-generic/src/esp32c3_gpio.c +++ b/boards/risc-v/esp32c3/esp32c3-generic/src/esp32c3_gpio.c @@ -44,6 +44,9 @@ /* Arch */ #include "espressif/esp_gpio.h" +#ifdef CONFIG_ESPRESSIF_DEDICATED_GPIO +#include "espressif/esp_dedic_gpio.h" +#endif /* Board */ @@ -75,6 +78,14 @@ #define GPIO_IRQPIN 9 +/* Dedicated GPIO pins. GPIO4 and GPIO5 is used as an example, any other + * GPIOs could be used. + */ + +#define GPIO_DEDIC1 4 +#define GPIO_DEDIC2 5 +#define GPIO_DEDIC_COUNT 2 + /**************************************************************************** * Private Types ****************************************************************************/ @@ -155,6 +166,33 @@ static const uint32_t g_gpiointinputs[BOARD_NGPIOINT] = static struct espgpint_dev_s g_gpint[BOARD_NGPIOINT]; #endif +/* This array maps the GPIO pins used as Dedicated GPIO */ + +#ifdef CONFIG_ESPRESSIF_DEDICATED_GPIO +static const int g_gpioidedic[GPIO_DEDIC_COUNT] = +{ + GPIO_DEDIC1, GPIO_DEDIC2 +}; + +static struct esp_dedic_gpio_flags_s dedic_gpio_flags = +{ + .input_enable = 1, + .invert_input_enable = 0, + .output_enable = 1, + .invert_output_enable = 0 +}; + +struct esp_dedic_gpio_config_s dedic_gpio_conf = +{ + .gpio_array = g_gpioidedic, + .array_size = GPIO_DEDIC_COUNT, + .flags = &dedic_gpio_flags, + .path = "/dev/dedic_gpio0" +}; + +struct file *dedicated_gpio = NULL; +#endif + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -509,6 +547,12 @@ int esp_gpio_init(void) } #endif +#ifdef CONFIG_ESPRESSIF_DEDICATED_GPIO + dedicated_gpio = esp_dedic_gpio_new_bundle(&dedic_gpio_conf); + + pincount++; +#endif + return OK; } #endif /* CONFIG_DEV_GPIO && !CONFIG_GPIO_LOWER_HALF */ diff --git a/boards/risc-v/esp32c6/esp32c6-devkitc/src/esp32c6_gpio.c b/boards/risc-v/esp32c6/esp32c6-devkitc/src/esp32c6_gpio.c index c88a2217b5..3d869c79ba 100644 --- a/boards/risc-v/esp32c6/esp32c6-devkitc/src/esp32c6_gpio.c +++ b/boards/risc-v/esp32c6/esp32c6-devkitc/src/esp32c6_gpio.c @@ -44,6 +44,9 @@ /* Arch */ #include "espressif/esp_gpio.h" +#ifdef CONFIG_ESPRESSIF_DEDICATED_GPIO +#include "espressif/esp_dedic_gpio.h" +#endif /* Board */ @@ -75,6 +78,14 @@ #define GPIO_IRQPIN 9 +/* Dedicated GPIO pins. GPIO4 and GPIO5 is used as an example, any other + * GPIOs could be used. + */ + +#define GPIO_DEDIC1 4 +#define GPIO_DEDIC2 5 +#define GPIO_DEDIC_COUNT 2 + /**************************************************************************** * Private Types ****************************************************************************/ @@ -155,6 +166,33 @@ static const uint32_t g_gpiointinputs[BOARD_NGPIOINT] = static struct espgpint_dev_s g_gpint[BOARD_NGPIOINT]; #endif +/* This array maps the GPIO pins used as Dedicated GPIO */ + +#ifdef CONFIG_ESPRESSIF_DEDICATED_GPIO +static const int g_gpioidedic[GPIO_DEDIC_COUNT] = +{ + GPIO_DEDIC1, GPIO_DEDIC2 +}; + +static struct esp_dedic_gpio_flags_s dedic_gpio_flags = +{ + .input_enable = 1, + .invert_input_enable = 0, + .output_enable = 1, + .invert_output_enable = 0 +}; + +struct esp_dedic_gpio_config_s dedic_gpio_conf = +{ + .gpio_array = g_gpioidedic, + .array_size = GPIO_DEDIC_COUNT, + .flags = &dedic_gpio_flags, + .path = "/dev/dedic_gpio0" +}; + +struct file *dedicated_gpio = NULL; +#endif + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -509,6 +547,12 @@ int esp_gpio_init(void) } #endif +#ifdef CONFIG_ESPRESSIF_DEDICATED_GPIO + dedicated_gpio = esp_dedic_gpio_new_bundle(&dedic_gpio_conf); + + pincount++; +#endif + return OK; } #endif /* CONFIG_DEV_GPIO && !CONFIG_GPIO_LOWER_HALF */ diff --git a/boards/risc-v/esp32h2/esp32h2-devkit/src/esp32h2_gpio.c b/boards/risc-v/esp32h2/esp32h2-devkit/src/esp32h2_gpio.c index bd1ae75d01..95eaa5ef3f 100644 --- a/boards/risc-v/esp32h2/esp32h2-devkit/src/esp32h2_gpio.c +++ b/boards/risc-v/esp32h2/esp32h2-devkit/src/esp32h2_gpio.c @@ -44,6 +44,9 @@ /* Arch */ #include "espressif/esp_gpio.h" +#ifdef CONFIG_ESPRESSIF_DEDICATED_GPIO +#include "espressif/esp_dedic_gpio.h" +#endif /* Board */ @@ -75,6 +78,14 @@ #define GPIO_IRQPIN 9 +/* Dedicated GPIO pins. GPIO4 and GPIO5 is used as an example, any other + * GPIOs could be used. + */ + +#define GPIO_DEDIC1 4 +#define GPIO_DEDIC2 5 +#define GPIO_DEDIC_COUNT 2 + /**************************************************************************** * Private Types ****************************************************************************/ @@ -155,6 +166,33 @@ static const uint32_t g_gpiointinputs[BOARD_NGPIOINT] = static struct espgpint_dev_s g_gpint[BOARD_NGPIOINT]; #endif +/* This array maps the GPIO pins used as Dedicated GPIO */ + +#ifdef CONFIG_ESPRESSIF_DEDICATED_GPIO +static const int g_gpioidedic[GPIO_DEDIC_COUNT] = +{ + GPIO_DEDIC1, GPIO_DEDIC2 +}; + +static struct esp_dedic_gpio_flags_s dedic_gpio_flags = +{ + .input_enable = 1, + .invert_input_enable = 0, + .output_enable = 1, + .invert_output_enable = 0 +}; + +struct esp_dedic_gpio_config_s dedic_gpio_conf = +{ + .gpio_array = g_gpioidedic, + .array_size = GPIO_DEDIC_COUNT, + .flags = &dedic_gpio_flags, + .path = "/dev/dedic_gpio0" +}; + +struct file *dedicated_gpio = NULL; +#endif + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -509,6 +547,12 @@ int esp_gpio_init(void) } #endif +#ifdef CONFIG_ESPRESSIF_DEDICATED_GPIO + dedicated_gpio = esp_dedic_gpio_new_bundle(&dedic_gpio_conf); + + pincount++; +#endif + return OK; } #endif /* CONFIG_DEV_GPIO && !CONFIG_GPIO_LOWER_HALF */