Skip to contentSkip to conversation

Add support for StarFive JHB100 UART Routing

PATCH In review Changhuang Liang 2 participants 8 messages Oct 19 – Nov 23

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v4 cover Add support for StarFive JHB100 UART Routing

Currently, since Aspeed also has a similar driver, there is some code with identical structures on both sides, but a common framework is lacking. Therefore, this series introduces a generic UART routing framework. It also moves aspeed-uart-routing.c under this generic framework and makes it use the interfaces provided by the generic framework. At the same time, StarFive also registers its own driver based on this generic framework.

StarFive JHB100 UART Routing allows dynamic routing of inputs between built-in UARTs and physical serial I/O ports, enabling use cases such as Host <-> BMC communication via UARTs.

This series has been tested on the EVB1 board.

changes since v3:

PATCH 1:
- Use dev_get/set_drvdata() to obtain struct uart_routing * to avoid null-ptr-deref issues.
- Update uart-routing.rst: since dev_set_drvdata() is now used by the framework, remind the SoC driver side not to use dev_set_drvdata().

PATCH 3:
- Add Rob's "Reviewed-by" tag.

v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/

Changhuang Liang (4):
uart-routing: Add common UART routing framework
soc: aspeed: Move UART routing driver to drivers/uart-routing
dt-bindings: soc: starfive: Add StarFive JHB100 UART routing
uart-routing: Add UART Routing driver for StarFive JHB100 SoC

 .../sysfs-driver-starfive-uart-routing        |  49 ++
 .../soc/starfive/starfive,uart-routing.yaml   |  46 ++
 Documentation/driver-api/index.rst            |   1 +
 Documentation/driver-api/uart-routing.rst     | 144 +++++
 MAINTAINERS                                   |  25 +
 drivers/Kconfig                               |   2 +
 drivers/Makefile                              |   1 +
 drivers/soc/aspeed/Kconfig                    |  10 -
 drivers/soc/aspeed/Makefile                   |   1 -
 drivers/soc/aspeed/aspeed-uart-routing.c      | 601 ------------------
 drivers/uart-routing/Kconfig                  |  45 ++
 drivers/uart-routing/Makefile                 |   5 +
 drivers/uart-routing/aspeed-uart-routing.c    | 415 ++++++++++++
 drivers/uart-routing/starfive-uart-routing.c  | 192 ++++++
 drivers/uart-routing/uart-routing.c           | 183 ++++++
 drivers/uart-routing/uart-routing.h           |  84 +++
 16 files changed, 1192 insertions(+), 612 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-starfive-uart-routing
 create mode 100644 Documentation/devicetree/bindings/soc/starfive/starfive,uart-routing.yaml
 create mode 100644 Documentation/driver-api/uart-routing.rst
 delete mode 100644 drivers/soc/aspeed/aspeed-uart-routing.c
 create mode 100644 drivers/uart-routing/Kconfig
 create mode 100644 drivers/uart-routing/Makefile
 create mode 100644 drivers/uart-routing/aspeed-uart-routing.c
 create mode 100644 drivers/uart-routing/starfive-uart-routing.c
 create mode 100644 drivers/uart-routing/uart-routing.c
 create mode 100644 drivers/uart-routing/uart-routing.h

--
2.25.1

#1 lore raw

PATCH v4 1/4 uart-routing: Add common UART routing framework

Several SoCs contain a serial crossbar, usually called UART routing, that lets the RX line of any on-chip UART controller or physical serial port be fed from any other endpoint. The Aspeed AST2400/2500/2600 and the StarFive JHB100 both have one, and both expose it through the same user space interface: one sysfs file per endpoint, listing the routing targets with the current one in square brackets.

The two drivers implementing that interface duplicate the whole sysfs plumbing and only really differ in the description of their register layout, so factor the common part out into a framework.

An SoC driver now only describes each mux with a
struct uart_routing_selector - register offset, bit position, field mask and the array of routing target names indexed by the raw field value - gathers them in an attribute group and hands the group and a regmap to devm_uart_routing_register(). The framework validates the description, creates the files and implements the show()/store() handlers.

The framework keeps its state in the device drvdata, the sysfs files are removed by devres, so drivers do not need a remove() callback for them.

---
 Documentation/driver-api/index.rst        |   1 +
 Documentation/driver-api/uart-routing.rst | 144 +++++++++++++++++
 MAINTAINERS                               |   7 +
 drivers/Kconfig                           |   2 +
 drivers/Makefile                          |   1 +
 drivers/uart-routing/Kconfig              |  16 ++
 drivers/uart-routing/Makefile             |   2 +
 drivers/uart-routing/uart-routing.c       | 183 ++++++++++++++++++++++
 drivers/uart-routing/uart-routing.h       |  84 ++++++++++
 9 files changed, 440 insertions(+)
 create mode 100644 Documentation/driver-api/uart-routing.rst
 create mode 100644 drivers/uart-routing/Kconfig
 create mode 100644 drivers/uart-routing/Makefile
 create mode 100644 drivers/uart-routing/uart-routing.c
 create mode 100644 drivers/uart-routing/uart-routing.h
Documentation/driver-api/index.rst +1 -0
index aaf5d76ed074..11a535bb9caf 100644
@@ -148,6 +148,7 @@ Subsystem-specific APIs
    tee
    thermal/index
    tty/index
+   uart-routing
    wbrf
    wmi
    xilinx/index
Documentation/driver-api/uart-routing.rst new file +144 -0

144 lines not on this page · raw message

MAINTAINERS +7 -0
index d6039e440efb..3f33f8184be1 100644
@@ -28403,6 +28403,13 @@ F:	drivers/misc/uacce/
 F:	include/linux/uacce.h
 F:	include/uapi/misc/uacce/
 
+UART ROUTING FRAMEWORK
+M:	Changhuang Liang <[email protected]>
+L:	[email protected] (moderated for non-subscribers)
+S:	Maintained
+F:	Documentation/driver-api/uart-routing.rst
+F:	drivers/uart-routing/
+
 UBI FILE SYSTEM (UBIFS)
 M:	Richard Weinberger <[email protected]>
 R:	Zhihao Cheng <[email protected]>
drivers/Kconfig +2 -0
index f2bed2ddeb66..57983a019075 100644
@@ -253,4 +253,6 @@ source "drivers/cdx/Kconfig"
 
 source "drivers/resctrl/Kconfig"
 
+source "drivers/uart-routing/Kconfig"
+
 endmenu
drivers/Makefile +1 -0
index 0841ea851847..fe4b11419496 100644
@@ -195,6 +195,7 @@ obj-$(CONFIG_DRM_ACCEL)		+= accel/
 obj-$(CONFIG_CDX_BUS)		+= cdx/
 obj-$(CONFIG_DPLL)		+= dpll/
 obj-y				+= resctrl/
+obj-$(CONFIG_UART_ROUTING)	+= uart-routing/
 
 obj-$(CONFIG_DIBS)		+= dibs/
 obj-$(CONFIG_S390)		+= s390/
drivers/uart-routing/Kconfig new file +16 -0
new file mode 100644
index 000000000000..a0c45a7bba47
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+menu "UART routing drivers"
+
+config UART_ROUTING
+	tristate
+	help
+	  Common framework for the UART routing controllers found on several
+	  SoCs. It turns a description of the routing selectors of a crossbar
+	  into a set of sysfs files, one per endpoint, that report and change
+	  the current routing at runtime.
+
+	  This symbol is selected by the SoC specific drivers below and is
+	  not meant to be enabled on its own.
+
+endmenu
drivers/uart-routing/Makefile new file +2 -0
new file mode 100644
index 000000000000..975165f070a5
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_UART_ROUTING)			+= uart-routing.o
drivers/uart-routing/uart-routing.c new file +183 -0

183 lines not on this page · raw message

drivers/uart-routing/uart-routing.h new file +84 -0

84 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

PATCH v4 2/4 soc: aspeed: Move UART routing driver to drivers/uart-routing

In reply to Changhuang Liang

The Aspeed UART routing driver is not really a SoC driver: it only exposes a serial crossbar through sysfs, and the same hardware block exists on SoCs from other vendors. Move it to drivers/uart-routing/ and convert it to the common framework living there.

The register layout description, that is the list of selectors with their register offset, bit position, field mask and routing targets, is kept as it is; only the surrounding sysfs plumbing is dropped in favour of the framework. The per selector option lists become separate arrays because the framework refers to them by pointer instead of embedding them in the selector.

The Kconfig symbol and the platform driver name are unchanged, so the sysfs paths documented in Documentation/ABI/testing/sysfs-driver-aspeed-uart-routing stay valid and existing configurations keep working.

Also update MAINTAINERS to add entries for aspeed-uart-routing.c based on the file authors, as the file currently lacks maintainers.

---
 MAINTAINERS                                |  10 +
 drivers/soc/aspeed/Kconfig                 |  10 -
 drivers/soc/aspeed/Makefile                |   1 -
 drivers/soc/aspeed/aspeed-uart-routing.c   | 601 ---------------------
 drivers/uart-routing/Kconfig               |  16 +
 drivers/uart-routing/Makefile              |   2 +
 drivers/uart-routing/aspeed-uart-routing.c | 415 ++++++++++++++
 7 files changed, 443 insertions(+), 612 deletions(-)
 delete mode 100644 drivers/soc/aspeed/aspeed-uart-routing.c
 create mode 100644 drivers/uart-routing/aspeed-uart-routing.c
MAINTAINERS +10 -0
index 3f33f8184be1..13dfdc1f7aa7 100644
@@ -4132,6 +4132,16 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/pci/aspeed,ast2600-pcie.yaml
 F:	drivers/pci/controller/pcie-aspeed.c
 
+ASPEED UART ROUTING DRIVER
+M:	Chia-Wei Wang <[email protected]>
+M:	Oskar Senft <[email protected]>
+L:	[email protected] (moderated for non-subscribers)
+L:	[email protected] (moderated for non-subscribers)
+S:	Maintained
+F:	Documentation/ABI/testing/sysfs-driver-aspeed-uart-routing
+F:	Documentation/devicetree/bindings/soc/aspeed/uart-routing.yaml
+F:	drivers/uart-routing/aspeed-uart-routing.c
+
 ASUS EC HARDWARE MONITOR DRIVER
 M:	Eugene Shalygin <[email protected]>
 L:	[email protected]
drivers/soc/aspeed/Kconfig +0 -10
index 63a656449a1a..e27623a94fd2 100644
@@ -24,16 +24,6 @@ config ASPEED_LPC_SNOOP
 	  allows the BMC to listen on and save the data written by
 	  the host to an arbitrary LPC I/O port.
 
-config ASPEED_UART_ROUTING
-	tristate "ASPEED uart routing control"
-	select REGMAP
-	select MFD_SYSCON
-	default ARCH_ASPEED
-	help
-	  Provides a driver to control the UART routing paths, allowing
-	  users to perform runtime configuration of the RX muxes among
-	  the UART controllers and I/O pins.
-
 config ASPEED_P2A_CTRL
 	tristate "ASPEED P2A (VGA MMIO to BMC) bridge control"
 	select REGMAP
drivers/soc/aspeed/Makefile +0 -1
index b5188dcde37a..ace038b6ff22 100644
@@ -1,7 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 obj-$(CONFIG_ASPEED_LPC_CTRL)		+= aspeed-lpc-ctrl.o
 obj-$(CONFIG_ASPEED_LPC_SNOOP)		+= aspeed-lpc-snoop.o
-obj-$(CONFIG_ASPEED_UART_ROUTING)	+= aspeed-uart-routing.o
 obj-$(CONFIG_ASPEED_P2A_CTRL)		+= aspeed-p2a-ctrl.o
 obj-$(CONFIG_ASPEED_SOCINFO)		+= aspeed-socinfo.o
 CONTEXT_ANALYSIS_aspeed-lpc-snoop.o	:= y
drivers/soc/aspeed/aspeed-uart-routing.c deleted +0 -601

601 lines not on this page · raw message

drivers/uart-routing/Kconfig +16 -0
index a0c45a7bba47..983e7fbd1bc4 100644
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
 menu "UART routing drivers"
+	depends on ARCH_ASPEED || COMPILE_TEST
 
 config UART_ROUTING
 	tristate
@@ -13,4 +14,19 @@ config UART_ROUTING
 	  This symbol is selected by the SoC specific drivers below and is
 	  not meant to be enabled on its own.
 
+config ASPEED_UART_ROUTING
+	tristate "ASPEED uart routing control"
+	depends on ARCH_ASPEED || COMPILE_TEST
+	select UART_ROUTING
+	select REGMAP
+	select MFD_SYSCON
+	default ARCH_ASPEED
+	help
+	  Provides a driver to control the UART routing paths, allowing
+	  users to perform runtime configuration of the RX muxes among
+	  the UART controllers and I/O pins.
+
+	  If M is selected, the module will be called
+	  aspeed-uart-routing.
+
 endmenu
drivers/uart-routing/Makefile +2 -0
index 975165f070a5..226980c639a4 100644
@@ -1,2 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
 obj-$(CONFIG_UART_ROUTING)			+= uart-routing.o
+
+obj-$(CONFIG_ASPEED_UART_ROUTING)		+= aspeed-uart-routing.o
drivers/uart-routing/aspeed-uart-routing.c new file +415 -0

415 lines not on this page · raw message

Signature · 1 line
2.25.1
maintainer
#3 lore raw

Re: [PATCH v4 2/4] soc: aspeed: Move UART routing driver to drivers/uart-routing

Quoted 29 lines · Changhuang Liang

The Aspeed UART routing driver is not really a SoC driver: it only exposes a serial crossbar through sysfs, and the same hardware block exists on SoCs from other vendors. Move it to drivers/uart-routing/ and convert it to the common framework living there.

The register layout description, that is the list of selectors with their register offset, bit position, field mask and routing targets, is kept as it is; only the surrounding sysfs plumbing is dropped in favour of the framework. The per selector option lists become separate arrays because the framework refers to them by pointer instead of embedding them in the selector.

The Kconfig symbol and the platform driver name are unchanged, so the sysfs paths documented in Documentation/ABI/testing/sysfs-driver-aspeed-uart-routing stay valid and existing configurations keep working.

Also update MAINTAINERS to add entries for aspeed-uart-routing.c based on the file authors, as the file currently lacks maintainers.

---
 MAINTAINERS                                |  10 + drivers/soc/aspeed/Kconfig                 |  10 - drivers/soc/aspeed/Makefile                |   1 - drivers/soc/aspeed/aspeed-uart-routing.c   | 601 --------------------- drivers/uart-routing/Kconfig               |  16 + drivers/uart-routing/Makefile              |   2 + drivers/uart-routing/aspeed-uart-routing.c | 415 ++++++++++++++

Quoted 4 lines
 7 files changed, 443 insertions(+), 612 deletions(-)

 delete mode 100644 drivers/soc/aspeed/aspeed-uart-routing.c create mode 100644 drivers/uart-routing/aspeed-uart-routing.c

I'm certainly in favour of moving code out of drivers/soc/aspeed, and having a small subsystem to handle this is fine, but it's not clear what happened to the direction of doing this by designing a user ABI for pinctrl?

https://lore.kernel.org/all/CAD++jLm7hQnCHACsZH0LVnXuCJm0dZ6Bq0hAyOTvVomy6WVRug@mail.gmail.com/

Existing code would need to be converted, but motivating that with the JHB100 support would seem sensible?

Andrew

#4 lore raw

Re: [PATCH v4 2/4] soc: aspeed: Move UART routing driver to drivers/uart-routing

Hi, Andrew

Quoted 40 lines · Changhuang Liang
Quoted 30 lines

The Aspeed UART routing driver is not really a SoC driver: it only exposes a serial crossbar through sysfs, and the same hardware block exists on SoCs from other vendors. Move it to drivers/uart-routing/ and convert it to the common framework living there.

The register layout description, that is the list of selectors with their register offset, bit position, field mask and routing targets, is kept as it is; only the surrounding sysfs plumbing is dropped in favour of the framework. The per selector option lists become separate arrays because the framework refers to them by pointer instead of embedding them in the selector.

The Kconfig symbol and the platform driver name are unchanged, so the sysfs paths documented in Documentation/ABI/testing/sysfs-driver-aspeed-uart-routing stay valid and existing configurations keep working.

Also update MAINTAINERS to add entries for aspeed-uart-routing.c based on the file authors, as the file currently lacks maintainers.

---
 MAINTAINERS                                |  10 + drivers/soc/aspeed/Kconfig                 |  10 - drivers/soc/aspeed/Makefile                |   1 - drivers/soc/aspeed/aspeed-uart-routing.c   | 601
---------------------
 drivers/uart-routing/Kconfig               |  16 + drivers/uart-routing/Makefile              |   2 + drivers/uart-routing/aspeed-uart-routing.c | 415 ++++++++++++++

Quoted 4 lines
 7 files changed, 443 insertions(+), 612 deletions(-)

 delete mode 100644 drivers/soc/aspeed/aspeed-uart-routing.c create mode 100644 drivers/uart-routing/aspeed-uart-routing.c

I'm certainly in favour of moving code out of drivers/soc/aspeed, and having a small subsystem to handle this is fine, but it's not clear what happened to the direction of doing this by designing a user ABI for pinctrl?

Quoted 5 lines

https://lore.kernel.org/all/CAD++jLm7hQnCHACsZH0LVnXuCJm0dZ6Bq0hAyO
[email protected]/

Existing code would need to be converted, but motivating that with the JHB100 support would seem sensible?

I'm not currently pursuing the pinctrl direction anymore, because I don't have a good way to implement that direction at the moment. So I'm proceeding with this series in the current way, and the main benefit is that it doesn't affect the Aspeed test commands.

Best Regards,
Changhuang

#5 lore raw

PATCH v4 3/4 dt-bindings: soc: starfive: Add StarFive JHB100 UART routing

In reply to Changhuang Liang

Add device tree binding for the StarFive JHB100 UART routing controller. This controller allows dynamic routing of inputs between built-in UARTs and physical serial I/O ports, enabling use cases such as Host <-> BMC communication via UARTs.

The clocks property exists in the hardware, but the driver does not use it.

---
 .../soc/starfive/starfive,uart-routing.yaml   | 46 +++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/starfive/starfive,uart-routing.yaml
Documentation/devicetree/bindings/soc/starfive/starfive,uart-routing.yaml new file +46 -0
new file mode 100644
index 000000000000..5de809ab3a99
@@ -0,0 +1,46 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/soc/starfive/starfive,uart-routing.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: StarFive JHB100 UART Routing Controller
+
+maintainers:
+  - Changhuang Liang <[email protected]>
+
+description: |
+  The StarFive JHB100 UART routing controller allows dynamic routing of the
+  inputs for the built-in UARTs and the physical serial I/O ports.
+
+  This allows, for example, connecting the output of one UART to another
+  UART, which can be used to enable Host <-> BMC communication over UARTs,
+  e.g. to give the BMC access to the Host's serial console.
+
+properties:
+  compatible:
+    const: starfive,jhb100-uart-routing
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  resets:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - resets
+
+additionalProperties: false
+
+examples:
+  - |
+    uart-routing@11a42a00 {
+        compatible = "starfive,jhb100-uart-routing";
+        reg = <0x11a42a00 0x100>;
+        resets = <&per0crg 74>;
+    };
Signature · 1 line
2.25.1
#6 lore raw

PATCH v4 4/4 uart-routing: Add UART Routing driver for StarFive JHB100 SoC

In reply to Changhuang Liang

Add driver support for JHB100 UART Routing control, allowing runtime configuration of RX muxes between UART controllers and I/O pins.

A sysfs interface is provided for easy checking and updating of routing paths.

---
 .../sysfs-driver-starfive-uart-routing        |  49 +++++
 MAINTAINERS                                   |   8 +
 drivers/uart-routing/Kconfig                  |  15 +-
 drivers/uart-routing/Makefile                 |   1 +
 drivers/uart-routing/starfive-uart-routing.c  | 192 ++++++++++++++++++
 5 files changed, 264 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-starfive-uart-routing
 create mode 100644 drivers/uart-routing/starfive-uart-routing.c
Documentation/ABI/testing/sysfs-driver-starfive-uart-routing new file +49 -0
new file mode 100644
index 000000000000..76aeed729d4b
@@ -0,0 +1,49 @@
+What:		/sys/bus/platform/drivers/starfive-uart-routing/*/uart*
+Date:		August 2026
+Contact:	Changhuang Liang <[email protected]>
+Description:	Selects the RX source of the UARTx device.
+
+		When read, each file shows the list of available options with currently
+		selected option marked by brackets "[]". The list of available options
+		depends on the selected file.
+
+		E.g.::
+
+		  cat /sys/bus/platform/drivers/starfive-uart-routing/\*.uart-routing/uart1
+		  io0 [io1] io2 io3 io4 io5 io6 io7 io8 io9 io10 io11 io12 io13 io14 uart0 uart1
+		  uart2 uart3 uart4 uart5 uart6 uart7 uart8 uart9 uart10 uart11 uart12 uart13 uart14
+
+		In this case, UART1 gets its input from IO1 (physical serial port 1).
+
+		To switch the RX source of UART1 to UART2, write the desired source to the file::
+
+		  echo uart2 > /sys/bus/platform/drivers/starfive-uart-routing/*.uart-routing/uart1
+
+		This indicates that UART1 now receives its input from UART2.
+
+Users:		OpenBMC.  Proposed changes should be mailed to
+		[email protected]
+
+What:		/sys/bus/platform/drivers/starfive-uart-routing/*/io*
+Date:		August 2026
+Contact:	Changhuang Liang <[email protected]>
+Description:	Selects the RX source of IOx serial port. The current selection
+		will be marked by brackets "[]". The list of available options
+		depends on the selected file.
+
+		E.g.::
+
+		  cat /sys/bus/platform/drivers/starfive-uart-routing/\*.uart-routing/io9
+		  uart0 uart1 uart2 uart3 uart4 uart5 uart6 uart7 uart8 [uart9] uart10 uart11 uart12
+		  uart13 uart14 io0 io1 io2 io3 io4 io5 io6 io7 io8 io9 io10 io11 io12 io13 io14
+
+		In this case, IO9 (physical serial port 9) gets its input from UART9.
+
+		To switch the RX source of IO9 to UART10, write the desired source to the file::
+
+		  echo uart10 > /sys/bus/platform/drivers/starfive-uart-routing/*.uart-routing/io9
+
+		This indicates that IO9 now receives its input from UART10.
+
+Users:		OpenBMC.  Proposed changes should be mailed to
+		[email protected]
MAINTAINERS +8 -0
index 13dfdc1f7aa7..83c853c45261 100644
@@ -26676,6 +26676,14 @@ S:	Supported
 F:	drivers/reset/starfive/reset-starfive-jhb1*
 F:	include/dt-bindings/reset/starfive,jhb1*.h
 
+STARFIVE UART ROUTING DRIVER
+M:	Changhuang Liang <[email protected]>
+L:	[email protected] (moderated for non-subscribers)
+S:	Maintained
+F:	Documentation/ABI/testing/sysfs-driver-starfive-uart-routing
+F:	Documentation/devicetree/bindings/soc/starfive/starfive,uart-routing.yaml
+F:	drivers/uart-routing/starfive-uart-routing.c
+
 STATIC BRANCH/CALL
 M:	Peter Zijlstra <[email protected]>
 M:	Josh Poimboeuf <[email protected]>
drivers/uart-routing/Kconfig +14 -1
index 983e7fbd1bc4..be6f5d54721e 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
 menu "UART routing drivers"
-	depends on ARCH_ASPEED || COMPILE_TEST
+	depends on ARCH_ASPEED || ARCH_STARFIVE || COMPILE_TEST
 
 config UART_ROUTING
 	tristate
@@ -29,4 +29,17 @@ config ASPEED_UART_ROUTING
 	  If M is selected, the module will be called
 	  aspeed-uart-routing.
 
+config STARFIVE_UART_ROUTING
+	tristate "StarFive uart routing control"
+	depends on ARCH_STARFIVE || COMPILE_TEST
+	select UART_ROUTING
+	select REGMAP_MMIO
+	help
+	  Provides a driver to control the UART routing paths, allowing
+	  users to perform runtime configuration of the RX muxes among
+	  the UART controllers and I/O pins.
+
+	  If M is selected, the module will be called
+	  starfive-uart-routing.
+
 endmenu
drivers/uart-routing/Makefile +1 -0
index 226980c639a4..59d9b65c2273 100644
@@ -2,3 +2,4 @@
 obj-$(CONFIG_UART_ROUTING)			+= uart-routing.o
 
 obj-$(CONFIG_ASPEED_UART_ROUTING)		+= aspeed-uart-routing.o
+obj-$(CONFIG_STARFIVE_UART_ROUTING)		+= starfive-uart-routing.o
drivers/uart-routing/starfive-uart-routing.c new file +192 -0

192 lines not on this page · raw message

Signature · 1 line
2.25.1
#7 lore raw
In reply to Changhuang Liang

Hello, Aspeed colleagues,

Quoted 34 lines

Currently, since Aspeed also has a similar driver, there is some code with identical structures on both sides, but a common framework is lacking. Therefore, this series introduces a generic UART routing framework. It also moves aspeed-uart-routing.c under this generic framework and makes it use the interfaces provided by the generic framework. At the same time, StarFive also registers its own driver based on this generic framework.

StarFive JHB100 UART Routing allows dynamic routing of inputs between built-in UARTs and physical serial I/O ports, enabling use cases such as Host <-> BMC communication via UARTs.

This series has been tested on the EVB1 board.

changes since v3:

PATCH 1:
- Use dev_get/set_drvdata() to obtain struct uart_routing * to avoid null-ptr-deref issues.
- Update uart-routing.rst: since dev_set_drvdata() is now used by the framework, remind the SoC driver side not to use dev_set_drvdata().

PATCH 3:
- Add Rob's "Reviewed-by" tag.

v3:
https://lore.kernel.org/all/20260925050947.9900-1-changhuang.liang@star
fivetech.com/
v2:
https://lore.kernel.org/all/20260905102901.126035-1-changhuang.liang@st
arfivetech.com/
v1:
https://lore.kernel.org/all/20260830065118.51551-1-changhuang.liang@star
fivetech.com/

Quoted 5 lines

Changhuang Liang (4):
uart-routing: Add common UART routing framework
soc: aspeed: Move UART routing driver to drivers/uart-routing
dt-bindings: soc: starfive: Add StarFive JHB100 UART routing
uart-routing: Add UART Routing driver for StarFive JHB100 SoC

Could someone help to test this series? Thank you very much.

Quoted 29 lines
 .../sysfs-driver-starfive-uart-routing        |  49 ++
 .../soc/starfive/starfive,uart-routing.yaml   |  46 ++
 Documentation/driver-api/index.rst            |   1 +
 Documentation/driver-api/uart-routing.rst     | 144 +++++
 MAINTAINERS                                   |  25 +
 drivers/Kconfig                               |   2 +
 drivers/Makefile                              |   1 +
 drivers/soc/aspeed/Kconfig                    |  10 -
 drivers/soc/aspeed/Makefile                   |   1 -
 drivers/soc/aspeed/aspeed-uart-routing.c      | 601 ------------------
 drivers/uart-routing/Kconfig                  |  45 ++
 drivers/uart-routing/Makefile                 |   5 +
 drivers/uart-routing/aspeed-uart-routing.c    | 415 ++++++++++++
 drivers/uart-routing/starfive-uart-routing.c  | 192 ++++++
 drivers/uart-routing/uart-routing.c           | 183 ++++++
 drivers/uart-routing/uart-routing.h           |  84 +++
 16 files changed, 1192 insertions(+), 612 deletions(-)  create mode 100644
Documentation/ABI/testing/sysfs-driver-starfive-uart-routing
 create mode 100644
Documentation/devicetree/bindings/soc/starfive/starfive,uart-routing.yaml
 create mode 100644 Documentation/driver-api/uart-routing.rst
 delete mode 100644 drivers/soc/aspeed/aspeed-uart-routing.c
 create mode 100644 drivers/uart-routing/Kconfig  create mode 100644
drivers/uart-routing/Makefile  create mode 100644
drivers/uart-routing/aspeed-uart-routing.c
 create mode 100644 drivers/uart-routing/starfive-uart-routing.c
 create mode 100644 drivers/uart-routing/uart-routing.c
 create mode 100644 drivers/uart-routing/uart-routing.h
Quoted 2 lines

--
2.25.1

Best Regards,
Changhuang