serial: 8250: Add AN7581 UART support
Subsystems (2)
v6 cover serial: 8250: Add AN7581 UART support
This is a new version of [1] to support UART driver for Airoha SoC.
One additional function was needed serial8250_get_baud_rate() for the driver to work correctly for baud rate calculation.
While at it also try to clarify a long standing issue with new UART driver when adding new ids for uart_config[].
[1] https://lore.kernel.org/all/[email protected]/
Changes v6:
- Fix commit description for Documentation
- Add tag to Documentation commit
Changes v5:
- Improve 8250 YAML schema with enum
- Keep alphabetical order for YAML schema
Changes v4:
- Add Review tag
- Add errno and types header
- Drop redundant () from comment
- Use define for get_divisor
Changes v3:
- Address review from ai bot
- Add all missing kernel headers
- Improve divisor calculation
- Fix wrong uart config table
- Simplify divisor table handling
Changes v2:
- Drop intermediate patch
- Use .set_divisor OPs
- Use div_u64 instead of / 40 for 32 bit overflow
- Drop dedicated match table and use compatible for type
Changes compared to [1]:
- Fix all formal error
- Use better compatible names
- Drop unneeded header
- Drop usage of irq (it's filled by the generic function)
- General code cleanup and reorg
- Split to patch and add the UAPI map patch
Benjamin Larsson (1):
dt-bindings: serial: 8250: Add Airoha compatibles
Christian Marangi (2):
dt-bindings: serial: 8250: Reorganize compatible to single enum
serial: 8250: Add Airoha SoC UART and HSUART support
.../devicetree/bindings/serial/8250.yaml | 32 +-- drivers/tty/serial/8250/8250.h | 6 + drivers/tty/serial/8250/8250_airoha.c | 187 ++++++++++++++++++ drivers/tty/serial/8250/8250_port.c | 16 ++ drivers/tty/serial/8250/Kconfig | 11 ++ drivers/tty/serial/8250/Makefile | 1 + 6 files changed, 240 insertions(+), 13 deletions(-) create mode 100644 drivers/tty/serial/8250/8250_airoha.c
Signature · 1 line
2.53.0
PATCH v6 1/3 dt-bindings: serial: 8250: Reorganize compatible to single enum
Instead of declaring each single compatible string with a const, move them to a single enum and reorder the Nuvoton compatible as it wasn't sorted.
Put the generic ns first and then follow alphabetical order.
--- .../devicetree/bindings/serial/8250.yaml | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-)
Documentation/devicetree/bindings/serial/8250.yaml +14 -13
@@ -99,19 +99,20 @@ allOf: properties: compatible: oneOf: - - const: ns8250 - - const: ns16450 - - const: ns16550 - - const: ns16550a - - const: ns16850 - - const: aspeed,ast2400-vuart - - const: aspeed,ast2500-vuart - - const: intel,xscale-uart - - const: mrvl,pxa-uart - - const: nuvoton,wpcm450-uart - - const: nuvoton,npcm750-uart - - const: nvidia,tegra20-uart - - const: nxp,lpc3220-uart + - enum: + - ns8250 + - ns16450 + - ns16550 + - ns16550a + - ns16850 + - aspeed,ast2400-vuart + - aspeed,ast2500-vuart + - intel,xscale-uart + - mrvl,pxa-uart + - nuvoton,npcm750-uart + - nuvoton,wpcm450-uart + - nvidia,tegra20-uart + - nxp,lpc3220-uart - items: - enum: - exar,xr16l2552
Signature · 1 line
2.53.0
Re: [PATCH v6 1/3] dt-bindings: serial: 8250: Reorganize compatible to single enum
Quoted 9 lines · Christian Marangi
Instead of declaring each single compatible string with a const, move them to a single enum and reorder the Nuvoton compatible as it wasn't sorted.
Put the generic ns first and then follow alphabetical order.
Signed-off-by Christian Marangi <[email protected]>--- .../devicetree/bindings/serial/8250.yaml | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-)
Best regards,
Krzysztof
PATCH v6 2/3 dt-bindings: serial: 8250: Add Airoha compatibles
In reply to Christian MarangiFrom: Benjamin Larsson <[email protected]>
The Airoha SoC family have a mostly 16550-compatible UART and High-Speed UART hardware with the exception of custom baud rate settings register.
--- Documentation/devicetree/bindings/serial/8250.yaml | 5 +++++ 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/serial/8250.yaml +5 -0
@@ -105,6 +105,8 @@ properties: - ns16550 - ns16550a - ns16850 + - airoha,an7581-hsuart + - airoha,en7523-uart - aspeed,ast2400-vuart - aspeed,ast2500-vuart - intel,xscale-uart
@@ -113,6 +115,9 @@ properties: - nuvoton,wpcm450-uart - nvidia,tegra20-uart - nxp,lpc3220-uart + - items: + - const: airoha,an7581-uart + - const: airoha,en7523-uart - items: - enum: - exar,xr16l2552
Signature · 1 line
2.53.0
PATCH v6 3/3 serial: 8250: Add Airoha SoC UART and HSUART support
In reply to Christian MarangiAdd support for Airoha AN7523 UART and AN7581 HSUART.
These implement a standard 16550 UART with only some custom logic for baud rate handling.
--- drivers/tty/serial/8250/8250.h | 6 + drivers/tty/serial/8250/8250_airoha.c | 187 ++++++++++++++++++++++++++ drivers/tty/serial/8250/8250_port.c | 16 +++ drivers/tty/serial/8250/Kconfig | 11 ++ drivers/tty/serial/8250/Makefile | 1 + 5 files changed, 221 insertions(+) create mode 100644 drivers/tty/serial/8250/8250_airoha.c
drivers/tty/serial/8250/8250.h +6 -0
@@ -73,6 +73,12 @@ struct serial8250_config {unsigned int flags; }; +enum uart_port_type { +/* Internal 8250 only */ +UART_PORT_AIROHA =124 , +UART_PORT_AIROHA_HS =125 , +}; +#define UART_CAP_FIFO BIT(8)/* UART has FIFO */ #define UART_CAP_EFR BIT(9)/* UART has EFR */ #define UART_CAP_SLEEP BIT(10)/* UART has IER sleep */
drivers/tty/serial/8250/8250_airoha.c new file +187 -0
187 lines not on this page · raw message
drivers/tty/serial/8250/8250_port.c +16 -0
@@ -311,6 +311,22 @@ static const struct serial8250_config uart_config[] = { .rxtrig_bytes = {1, 8, 16, 30}, .flags = UART_CAP_FIFO | UART_CAP_AFE, }, + [UART_PORT_AIROHA] = { + .name ="Airoha UART" , + .fifo_size = 8, + .tx_loadsz = 1, + .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_01 | UART_FCR_CLEAR_RCVR, + .rxtrig_bytes = {1, 4, 4, 4}, + .flags = UART_CAP_FIFO, + }, + [UART_PORT_AIROHA_HS] = { + .name ="Airoha HSUART" , + .fifo_size = 128, + .tx_loadsz = 128, + .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_01 | UART_FCR_CLEAR_RCVR, + .rxtrig_bytes = {1, 4}, + .flags = UART_CAP_FIFO, + }, };/* Uart divisor latch read */
drivers/tty/serial/8250/Kconfig +11 -0
@@ -337,6 +337,17 @@ config SERIAL_8250_ACORN system, say Y to this option. The driver can handle 1, 2, or 3 port cards. If unsure, say N. +config SERIAL_8250_AIROHA + tristate "Airoha UART support" + depends on ARCH_AIROHA || COMPILE_TEST + depends on SERIAL_8250 + help + Selecting this option enables an Airoha SoC specific baud rate + calculation routine on an otherwise 16550 compatible UART hardware. + + If you have an Airoha based board and want to use the serial port, + say Y to this option. If unsure, say N. + config SERIAL_8250_BCM2835AUX tristate "BCM2835 auxiliar mini UART support" depends on ARCH_BCM2835 || COMPILE_TEST
drivers/tty/serial/8250/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_SERIAL_8250_CONSOLE) += 8250_early.o obj-$(CONFIG_SERIAL_8250_ACCENT) += 8250_accent.o obj-$(CONFIG_SERIAL_8250_ACORN) += 8250_acorn.o +obj-$(CONFIG_SERIAL_8250_AIROHA) += 8250_airoha.o obj-$(CONFIG_SERIAL_8250_ASPEED_VUART) += 8250_aspeed_vuart.o obj-$(CONFIG_SERIAL_8250_BCM2835AUX) += 8250_bcm2835aux.o obj-$(CONFIG_SERIAL_8250_BCM7271) += 8250_bcm7271.o
Signature · 1 line
2.53.0