serial: add drivers for the ESP32xx serial devices
Subsystems (2)
v5 cover serial: add drivers for the ESP32xx serial devices
Hello,
this series adds drivers for the UART and ACM gadget controllers found in the Espressif ESP32 and ESP32S3 SoCs.
Changes v4->v5:
- address review comments, listed in each patch
- rebase on top of change introducing PORT_GENERIC
Changes v3->v4:
- address review comments, listed in each patch
- add reviewed-by tags
Changes v2->v3:
- address review comments, listed in each patch
Changes v1->v2:
- address review comments, listed in each patch
- add cleanup for the uart_get_baud_rate function
Max Filippov (5):
serial: core: tidy invalid baudrate handling in uart_get_baud_rate
dt-bindings: serial: document esp32-uart drivers/tty/serial: add driver for the ESP32 UART
dt-bindings: serial: document esp32s3-acm drivers/tty/serial: add ESP32S3 ACM gadget driver
.../bindings/serial/esp,esp32-acm.yaml | 42 + .../bindings/serial/esp,esp32-uart.yaml | 51 ++ drivers/tty/serial/Kconfig | 26 + drivers/tty/serial/Makefile | 2 + drivers/tty/serial/esp32_acm.c | 459 +++++++++++ drivers/tty/serial/esp32_uart.c | 741 ++++++++++++++++++ drivers/tty/serial/serial_core.c | 4 +- 7 files changed, 1322 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/serial/esp,esp32-acm.yaml create mode 100644 Documentation/devicetree/bindings/serial/esp,esp32-uart.yaml create mode 100644 drivers/tty/serial/esp32_acm.c create mode 100644 drivers/tty/serial/esp32_uart.c
Signature · 1 line
2.30.2
PATCH v5 1/5 serial: core: tidy invalid baudrate handling in uart_get_baud_rate
uart_get_baud_rate has input parameters 'min' and 'max' limiting the range of acceptable baud rates from the caller's perspective. If neither current or old termios structures have acceptable baud rate setting and 9600 is not in the min/max range either the function returns 0 and issues a warning.
However for a UART that does not support speed of 9600 baud this is expected behavior.
Clarify that 0 can be (and always could be) returned from the uart_get_baud_rate. Don't issue a warning in that case.
---
Changes v4->v5:
- fix commit message
Changes v3->v4:
- drop WARN_ON from uart_get_divisor()
drivers/tty/serial/serial_core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/tty/serial/serial_core.c +1 -3
@@ -431,7 +431,7 @@ EXPORT_SYMBOL(uart_update_timeout);* baud. * * If the new baud rate is invalid, try the @old termios setting. If it's still -* invalid, we try 9600 baud. +* invalid, we try 9600 baud. If that is also invalid 0 is returned. * * The @termios structure is updated to reflect the baud rate we're actually * going to be using. Don't do this for the case where B0 is requested ("hang
@@ -515,8 +515,6 @@ uart_get_baud_rate(struct uart_port *port, struct ktermios *termios, max - 1, max - 1); } } -/* Should never happen */ -WARN_ON (1 );return 0 ; }EXPORT_SYMBOL (uart_get_baud_rate);
Signature · 1 line
2.30.2
PATCH v5 2/5 dt-bindings: serial: document esp32-uart
In reply to Max FilippovAdd documentation for the ESP32xx UART controllers.
---
Changes v2->v3:
- add a reference to serial.yaml
Changes v1->v2:
- drop '|' from description
- change 'compatible' property type to enum
- drop label from the example node
- fix example indentation
.../bindings/serial/esp,esp32-uart.yaml | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Documentation/devicetree/bindings/serial/esp,esp32-uart.yaml
Documentation/devicetree/bindings/serial/esp,esp32-uart.yaml new file +51 -0
@@ -0,0 +1,51 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause + +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/serial/esp,esp32-uart.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ESP32xx UART controllers + +maintainers: + - Max Filippov <[email protected]> + +description: + ESP32 UART controller is a part of the ESP32 SoC. + ESP32S3 UART controller is a part of the ESP32S3 SoC. + Both SoCs are produced by Espressif Systems Co. Ltd. + +allOf: + - $ref: serial.yaml# + +properties: + compatible: + enum: + - esp,esp32-uart + - esp,esp32s3-uart + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + - clocks + +additionalProperties: false + +examples: + - | + serial@60000000 { + compatible = "esp,esp32s3-uart"; + reg = <0x60000000 0x80>; + interrupts = <27 1 0>; + clocks = <&serial_clk>; + };
Signature · 1 line
2.30.2
PATCH v5 3/5 drivers/tty/serial: add driver for the ESP32 UART
In reply to Max FilippovAdd driver for the UART controllers of the Espressif ESP32 and ESP32S3 SoCs. Hardware specification is available at the following URLs:
https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf
(Chapter 13 UART Controller)
https://www.espressif.com/sites/default/files/documentation/esp32-s3_technical_reference_manual_en.pdf
(Chapter 26 UART Controller)
---
Changes v4->v5:
- use PORT_GENERIC instead of unique PORT_ESP32UART
Changes v2->v3:
- rework brk handling in esp32_uart_rxint
- only increment port->icount.rx in case insert_flip_char() is called
- use HZ instead of msecs_to_jiffies(1000) in esp32_uart_put_char_sync
- add early return to esp32_uart_transmit_buffer
- use request_irq/free_irq instead of devm_* versions
- add blank lines before certain return statements
Changes v1->v2:
- redefine register fields using BIT and GENMASK
- drop _MASK suffix from register field definitions
- drop *_SHIFT definitions where possible
- drop unused rxfifo_full_thrhd_mask and txfifo_empty_thrhd_mask
- split register reads/writes and bitwise operations into multiple lines
- use u8 instead of unsigned char in internal functions
- add timeout to esp32_uart_put_char_sync
- use uart_port_tx_limited in esp32_uart_transmit_buffer
- use IRQ_RETVAL in esp32_uart_int
- disable clock in esp32_uart_startup in case devm_request_irq fails
- rearrange devm_request_irq with enabling IRQs in the UART registers
- drop empty esp32_uart_release_port and esp32_uart_request_port
- simplify esp32_uart_tx_empty
- mask out unsupported CMSPAR flag in termios->c_cflag in esp32_uart_set_termios
- invoke uart_update_timeout in esp32_uart_set_termios
- drop MODULE_DESCRIPTION
- rearrange esp32_uart_set_baud: return bool indicating whether baud rate was set or not, use it in the esp32_uart_set_termios to set the default 115200
- turn 'locked' into bool in esp32_uart_console_write
- turn num_read into unsigned int in esp32_uart_earlycon_read
drivers/tty/serial/Kconfig | 13 + drivers/tty/serial/Makefile | 1 + drivers/tty/serial/esp32_uart.c | 741 ++++++++++++++++++++++++++++++++ 3 files changed, 755 insertions(+) create mode 100644 drivers/tty/serial/esp32_uart.c
drivers/tty/serial/Kconfig +13 -0
@@ -1578,6 +1578,19 @@ config SERIAL_NUVOTON_MA35D1_CONSOLE but you can alter that using a kernel command line option such as "console=ttyNVTx". +config SERIAL_ESP32 + tristate "Espressif ESP32 UART support" + depends on XTENSA_PLATFORM_ESP32 || (COMPILE_TEST && OF) + select SERIAL_CORE + select SERIAL_CORE_CONSOLE + select SERIAL_EARLYCON + help + Driver for the UART controllers of the Espressif ESP32xx SoCs. + When earlycon option is enabled the following kernel command line + snippets may be used: + earlycon=esp32s3uart,mmio32,0x60000000,115200n8,40000000 + earlycon=esp32uart,mmio32,0x3ff40000,115200n8 + endmenu config SERIAL_MCTRL_GPIO
drivers/tty/serial/Makefile +1 -0
@@ -88,6 +88,7 @@ obj-$(CONFIG_SERIAL_MILBEAUT_USIO) += milbeaut_usio.o obj-$(CONFIG_SERIAL_SIFIVE) += sifive.o obj-$(CONFIG_SERIAL_LITEUART) += liteuart.o obj-$(CONFIG_SERIAL_SUNPLUS) += sunplus-uart.o +obj-$(CONFIG_SERIAL_ESP32) += esp32_uart.o # GPIOLIB helpers for modem control lines obj-$(CONFIG_SERIAL_MCTRL_GPIO) += serial_mctrl_gpio.o
drivers/tty/serial/esp32_uart.c new file +741 -0
741 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v5 4/5 dt-bindings: serial: document esp32s3-acm
In reply to Max FilippovAdd documentation for the ESP32S3 USB CDC-ACM gadget controller.
---
Changes v4->v5:
- add the word 'gadget' to the description to make it more consistent with linux terminology
Changes v2->v3:
- add a reference to serial.yaml
Changes v1->v2:
- fix description
- rename node in the example
- fix example indentation
.../bindings/serial/esp,esp32-acm.yaml | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/devicetree/bindings/serial/esp,esp32-acm.yaml
Documentation/devicetree/bindings/serial/esp,esp32-acm.yaml new file +42 -0
@@ -0,0 +1,42 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause + +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/serial/esp,esp32-acm.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ESP32S3 ACM gadget controller + +maintainers: + - Max Filippov <[email protected]> + +description: + Fixed function USB CDC-ACM gadget controller of the Espressif ESP32S3 SoC. + +allOf: + - $ref: serial.yaml# + +properties: + compatible: + const: esp,esp32s3-acm + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + serial@60038000 { + compatible = "esp,esp32s3-acm"; + reg = <0x60038000 0x1000>; + interrupts = <96 3 0>; + };
Signature · 1 line
2.30.2
PATCH v5 5/5 drivers/tty/serial: add ESP32S3 ACM gadget driver
In reply to Max FilippovAdd driver for the ACM gadget controller of the Espressif ESP32S3 SoC. Hardware specification is available at the following URL:
https://www.espressif.com/sites/default/files/documentation/esp32-s3_technical_reference_manual_en.pdf
(Chapter 33 USB Serial/JTAG Controller)
---
Changes v4->v5:
- fix commit message formatting
- rename device from ttyACM to ttyiGS
- drop ttyACM device name mention from the Kconfig entry help
- use PORT_GENERIC instead of unique PORT_ESP32ACM
- add the word 'gadget' to the commit description and to Kconfig text to make it more consistent with linux terminology
Changes v2->v3:
- use HZ instead of msecs_to_jiffies(1000) in esp32_acm_put_char_sync
- add early return to esp32_acm_transmit_buffer
- use request_irq/free_irq instead of devm_* versions
Changes v1->v2:
- redefine register fields using BIT and GENMASK
- drop _MASK suffix from register field definitions
- drop *_SHIFT definitions where possible
- split register reads/writes and bitwise operations into multiple lines
- use u8 instead of unsigned char in internal functions
- add timeout to esp32_acm_put_char_sync
- use uart_port_tx_limited in esp32_acm_transmit_buffer
- use IRQ_RETVAL in esp32_acm_int
- drop esp32s3_acm_console_putchar and esp32s3_acm_earlycon_putchar
- turn num_read into unsigned int in esp32_acm_earlycon_read
- drop MODULE_DESCRIPTION
drivers/tty/serial/Kconfig | 13 + drivers/tty/serial/Makefile | 1 + drivers/tty/serial/esp32_acm.c | 459 +++++++++++++++++++++++++++++++++ 3 files changed, 473 insertions(+) create mode 100644 drivers/tty/serial/esp32_acm.c
drivers/tty/serial/Kconfig +13 -0
@@ -1591,6 +1591,19 @@ config SERIAL_ESP32 earlycon=esp32s3uart,mmio32,0x60000000,115200n8,40000000 earlycon=esp32uart,mmio32,0x3ff40000,115200n8 +config SERIAL_ESP32_ACM + tristate "Espressif ESP32 USB ACM gadget support" + depends on XTENSA_PLATFORM_ESP32 || (COMPILE_TEST && OF) + select SERIAL_CORE + select SERIAL_CORE_CONSOLE + select SERIAL_EARLYCON + help + Driver for the CDC ACM gadget controller of the Espressif ESP32S3 + SoCs that share separate USB controller with the JTAG adapter. + When earlycon option is enabled the following kernel command line + snippet may be used: + earlycon=esp32s3acm,mmio32,0x60038000 + endmenu config SERIAL_MCTRL_GPIO
drivers/tty/serial/Makefile +1 -0
@@ -89,6 +89,7 @@ obj-$(CONFIG_SERIAL_SIFIVE) += sifive.o obj-$(CONFIG_SERIAL_LITEUART) += liteuart.o obj-$(CONFIG_SERIAL_SUNPLUS) += sunplus-uart.o obj-$(CONFIG_SERIAL_ESP32) += esp32_uart.o +obj-$(CONFIG_SERIAL_ESP32_ACM) += esp32_acm.o # GPIOLIB helpers for modem control lines obj-$(CONFIG_SERIAL_MCTRL_GPIO) += serial_mctrl_gpio.o
drivers/tty/serial/esp32_acm.c new file +459 -0
459 lines not on this page · raw message
Signature · 1 line
2.30.2