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:
parent
0450263393
commit
efec7f73b7
6 changed files with 50 additions and 16 deletions
|
@ -9,6 +9,7 @@
|
|||
menuconfig GPIO_ESP32
|
||||
bool "ESP32 GPIO"
|
||||
depends on SOC_ESP32
|
||||
select HAS_DTS_GPIO
|
||||
help
|
||||
Enables the ESP32 GPIO driver
|
||||
|
||||
|
@ -24,20 +25,10 @@ config GPIO_ESP32_0
|
|||
help
|
||||
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
|
||||
bool "ESP32 GPIO (pins 32-39)"
|
||||
default y
|
||||
help
|
||||
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
|
||||
|
|
|
@ -344,11 +344,11 @@ static struct gpio_esp32_data gpio_data_pins_32_to_39 = {
|
|||
* and the device has 40 GPIO pins.
|
||||
*/
|
||||
#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
|
||||
|
||||
#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
|
||||
|
||||
static void gpio_esp32_isr(void *param)
|
||||
|
|
|
@ -92,14 +92,14 @@ static const char *esp32_get_gpio_for_pin(int pin)
|
|||
{
|
||||
if (pin < 32) {
|
||||
#if defined(CONFIG_GPIO_ESP32_0)
|
||||
return CONFIG_GPIO_ESP32_0_NAME;
|
||||
return DT_INST_0_ESPRESSIF_ESP32_GPIO_LABEL;
|
||||
#else
|
||||
return NULL;
|
||||
#endif /* CONFIG_GPIO_ESP32_0 */
|
||||
}
|
||||
|
||||
#if defined(CONFIG_GPIO_ESP32_1)
|
||||
return CONFIG_GPIO_ESP32_1_NAME;
|
||||
return DT_INST_1_ESPRESSIF_ESP32_GPIO_LABEL;
|
||||
#else
|
||||
return NULL;
|
||||
#endif /* CONFIG_GPIO_ESP32_1 */
|
||||
|
|
27
dts/bindings/gpio/espressif,esp32-gpio.yaml
Normal file
27
dts/bindings/gpio/espressif,esp32-gpio.yaml
Normal 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
|
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <xtensa/xtensa.dtsi>
|
||||
#include <dt-bindings/gpio/gpio.h>
|
||||
|
||||
/ {
|
||||
cpus {
|
||||
|
@ -55,5 +56,20 @@
|
|||
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";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -9,14 +9,14 @@ static const char *gpio_esp32_get_gpio_for_pin(int pin)
|
|||
{
|
||||
if (pin < 32) {
|
||||
#if defined(CONFIG_GPIO_ESP32_0)
|
||||
return CONFIG_GPIO_ESP32_0_NAME;
|
||||
return DT_INST_0_ESPRESSIF_ESP32_GPIO_LABEL;
|
||||
#else
|
||||
return NULL;
|
||||
#endif /* CONFIG_GPIO_ESP32_0 */
|
||||
}
|
||||
|
||||
#if defined(CONFIG_GPIO_ESP32_1)
|
||||
return CONFIG_GPIO_ESP32_1_NAME;
|
||||
return DT_INST_1_ESPRESSIF_ESP32_GPIO_LABEL;
|
||||
#else
|
||||
return NULL;
|
||||
#endif /* CONFIG_GPIO_ESP32_1 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue