dts: esp32: Add GPIO support in DT

Add GPIO support in DT

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
This commit is contained in:
Yannis Damigos 2019-06-21 19:59:25 +03:00 committed by Carles Cufí
commit efec7f73b7
6 changed files with 50 additions and 16 deletions

View file

@ -9,6 +9,7 @@
menuconfig GPIO_ESP32 menuconfig GPIO_ESP32
bool "ESP32 GPIO" bool "ESP32 GPIO"
depends on SOC_ESP32 depends on SOC_ESP32
select HAS_DTS_GPIO
help help
Enables the ESP32 GPIO driver Enables the ESP32 GPIO driver
@ -24,20 +25,10 @@ config GPIO_ESP32_0
help help
Include support for GPIO pins 0-31 on the ESP32. Include support for GPIO pins 0-31 on the ESP32.
config GPIO_ESP32_0_NAME
string "Driver name"
depends on GPIO_ESP32_0
default "GPIO_0"
config GPIO_ESP32_1 config GPIO_ESP32_1
bool "ESP32 GPIO (pins 32-39)" bool "ESP32 GPIO (pins 32-39)"
default y default y
help help
Include support for GPIO pins 32-39 on the ESP32. Include support for GPIO pins 32-39 on the ESP32.
config GPIO_ESP32_1_NAME
string "Driver name"
depends on GPIO_ESP32_1
default "GPIO_1"
endif # GPIO_ESP32 endif # GPIO_ESP32

View file

@ -344,11 +344,11 @@ static struct gpio_esp32_data gpio_data_pins_32_to_39 = {
* and the device has 40 GPIO pins. * and the device has 40 GPIO pins.
*/ */
#if defined(CONFIG_GPIO_ESP32_0) #if defined(CONFIG_GPIO_ESP32_0)
GPIO_DEVICE_INIT(CONFIG_GPIO_ESP32_0_NAME, 0_to_31); GPIO_DEVICE_INIT(DT_INST_0_ESPRESSIF_ESP32_GPIO_LABEL, 0_to_31);
#endif #endif
#if defined(CONFIG_GPIO_ESP32_1) #if defined(CONFIG_GPIO_ESP32_1)
GPIO_DEVICE_INIT(CONFIG_GPIO_ESP32_1_NAME, 32_to_39); GPIO_DEVICE_INIT(DT_INST_1_ESPRESSIF_ESP32_GPIO_LABEL, 32_to_39);
#endif #endif
static void gpio_esp32_isr(void *param) static void gpio_esp32_isr(void *param)

View file

@ -92,14 +92,14 @@ static const char *esp32_get_gpio_for_pin(int pin)
{ {
if (pin < 32) { if (pin < 32) {
#if defined(CONFIG_GPIO_ESP32_0) #if defined(CONFIG_GPIO_ESP32_0)
return CONFIG_GPIO_ESP32_0_NAME; return DT_INST_0_ESPRESSIF_ESP32_GPIO_LABEL;
#else #else
return NULL; return NULL;
#endif /* CONFIG_GPIO_ESP32_0 */ #endif /* CONFIG_GPIO_ESP32_0 */
} }
#if defined(CONFIG_GPIO_ESP32_1) #if defined(CONFIG_GPIO_ESP32_1)
return CONFIG_GPIO_ESP32_1_NAME; return DT_INST_1_ESPRESSIF_ESP32_GPIO_LABEL;
#else #else
return NULL; return NULL;
#endif /* CONFIG_GPIO_ESP32_1 */ #endif /* CONFIG_GPIO_ESP32_1 */

View file

@ -0,0 +1,27 @@
#
# Copyright (c) 2019, Yannis Damigos
#
# SPDX-License-Identifier: Apache-2.0
#
title: ESP32 GPIO
description: >
This is a representation of the ESP32 GPIO nodes
inherits:
!include base.yaml
properties:
compatible:
constraint: "espressif,esp32-gpio"
reg:
category: required
label:
category: required
"#cells":
- pin
- flags

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include <xtensa/xtensa.dtsi> #include <xtensa/xtensa.dtsi>
#include <dt-bindings/gpio/gpio.h>
/ { / {
cpus { cpus {
@ -55,5 +56,20 @@
status = "disabled"; status = "disabled";
}; };
gpio0: gpio@3ff44000 {
compatible = "espressif,esp32-gpio";
gpio-controller;
#gpio-cells = <2>;
reg = <0x3ff44000 0x800>;
label = "GPIO_0";
};
gpio1: gpio@3ff44800 {
compatible = "espressif,esp32-gpio";
gpio-controller;
#gpio-cells = <2>;
reg = <0x3ff44800 0x800>;
label = "GPIO_1";
};
}; };
}; };

View file

@ -9,14 +9,14 @@ static const char *gpio_esp32_get_gpio_for_pin(int pin)
{ {
if (pin < 32) { if (pin < 32) {
#if defined(CONFIG_GPIO_ESP32_0) #if defined(CONFIG_GPIO_ESP32_0)
return CONFIG_GPIO_ESP32_0_NAME; return DT_INST_0_ESPRESSIF_ESP32_GPIO_LABEL;
#else #else
return NULL; return NULL;
#endif /* CONFIG_GPIO_ESP32_0 */ #endif /* CONFIG_GPIO_ESP32_0 */
} }
#if defined(CONFIG_GPIO_ESP32_1) #if defined(CONFIG_GPIO_ESP32_1)
return CONFIG_GPIO_ESP32_1_NAME; return DT_INST_1_ESPRESSIF_ESP32_GPIO_LABEL;
#else #else
return NULL; return NULL;
#endif /* CONFIG_GPIO_ESP32_1 */ #endif /* CONFIG_GPIO_ESP32_1 */