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 d471609267172c8e6327739622d5bc52e502a8e0 Author: Eren Terzioglu <eren.terzio...@espressif.com> AuthorDate: Wed Apr 9 12:23:03 2025 +0200 boards/xtensa: Add dedicated GPIO board level support for esp32[-s2|-s3] Add board level dedicated GPIO support for Xtensa based Espressif devices Signed-off-by: Eren Terzioglu <eren.terzio...@espressif.com> --- .../esp32s2/esp32s2-saola-1/src/esp32s2_gpio.c | 45 ++++++++++++++++++++++ .../esp32s3/esp32s3-devkit/src/esp32s3_gpio.c | 45 ++++++++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/boards/xtensa/esp32s2/esp32s2-saola-1/src/esp32s2_gpio.c b/boards/xtensa/esp32s2/esp32s2-saola-1/src/esp32s2_gpio.c index 5278cd0cbf..a641931404 100644 --- a/boards/xtensa/esp32s2/esp32s2-saola-1/src/esp32s2_gpio.c +++ b/boards/xtensa/esp32s2/esp32s2-saola-1/src/esp32s2_gpio.c @@ -42,6 +42,10 @@ #include "esp32s2_gpio.h" #include "hardware/esp32s2_gpio_sigmap.h" +#ifdef CONFIG_ESPRESSIF_DEDICATED_GPIO +#include "espressif/esp_dedic_gpio.h" +#endif + #if defined(CONFIG_DEV_GPIO) && !defined(CONFIG_GPIO_LOWER_HALF) /**************************************************************************** @@ -64,6 +68,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 6 +#define GPIO_DEDIC2 5 +#define GPIO_DEDIC_COUNT 2 + /**************************************************************************** * Private Types ****************************************************************************/ @@ -161,6 +173,33 @@ static const uint32_t g_gpiointinputs[BOARD_NGPIOINT] = static struct esp32s2gpint_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 ****************************************************************************/ @@ -465,6 +504,12 @@ int esp32s2_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/xtensa/esp32s3/esp32s3-devkit/src/esp32s3_gpio.c b/boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3_gpio.c index a95f7f3e0f..702f381f77 100644 --- a/boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3_gpio.c +++ b/boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3_gpio.c @@ -40,6 +40,10 @@ #include "esp32s3_gpio.h" #include "hardware/esp32s3_gpio_sigmap.h" +#ifdef CONFIG_ESPRESSIF_DEDICATED_GPIO +#include "espressif/esp_dedic_gpio.h" +#endif + #if defined(CONFIG_DEV_GPIO) && !defined(CONFIG_GPIO_LOWER_HALF) /**************************************************************************** @@ -68,6 +72,14 @@ #define GPIO_IRQPIN1 21 +/* 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 ****************************************************************************/ @@ -165,6 +177,33 @@ static const uint32_t g_gpiointinputs[BOARD_NGPIOINT] = static struct esp32s3gpint_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 ****************************************************************************/ @@ -385,6 +424,12 @@ int esp32s3_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 */