2023-10-10 09:00:44

by Max Filippov

[permalink] [raw]
Subject: [PATCH v5 0/5] 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

--
2.30.2


2023-10-10 09:00:58

by Max Filippov

[permalink] [raw]
Subject: [PATCH v5 2/5] dt-bindings: serial: document esp32-uart

Add documentation for the ESP32xx UART controllers.

Signed-off-by: Max Filippov <[email protected]>
Reviewed-by: Rob Herring <[email protected]>
---
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

diff --git a/Documentation/devicetree/bindings/serial/esp,esp32-uart.yaml b/Documentation/devicetree/bindings/serial/esp,esp32-uart.yaml
new file mode 100644
index 000000000000..2a80ca997a0c
--- /dev/null
+++ b/Documentation/devicetree/bindings/serial/esp,esp32-uart.yaml
@@ -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>;
+ };
--
2.30.2

2023-10-10 09:01:03

by Max Filippov

[permalink] [raw]
Subject: [PATCH v5 4/5] dt-bindings: serial: document esp32s3-acm

Add documentation for the ESP32S3 USB CDC-ACM gadget controller.

Signed-off-by: Max Filippov <[email protected]>
Reviewed-by: Rob Herring <[email protected]>
---
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

diff --git a/Documentation/devicetree/bindings/serial/esp,esp32-acm.yaml b/Documentation/devicetree/bindings/serial/esp,esp32-acm.yaml
new file mode 100644
index 000000000000..77fbb2c72171
--- /dev/null
+++ b/Documentation/devicetree/bindings/serial/esp,esp32-acm.yaml
@@ -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>;
+ };
--
2.30.2

2023-10-10 09:01:16

by Max Filippov

[permalink] [raw]
Subject: [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.

Signed-off-by: Max Filippov <[email protected]>
---
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(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 7bdc21d5e13b..3f130fe9f1a0 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -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);
--
2.30.2