Skip to contentSkip to conversation

lib: utils/serial: Add Bouffalo Lab BL808 UART driver

PATCH New Kwanghoon Son 1 participant 1 message Oct 21

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: utils/serial: Add Bouffalo Lab BL808 UART driver

Add a polling UART driver for the Bouffalo Lab BL808 SoC and its FDT frontend, matching bflb,bl808-uart. Read the register base, input clock and baud rate from the device tree and register the SBI console.

The preceding firmware must enable the UART input clock and configure the pinmux before entering OpenSBI. The driver only configures the UART peripheral; it does not change SoC clocks or board pin routing.

---
The BL808 is also used on the PINE64 Ox64 [1]. Zephyr already provides a Bouffalo Lab UART driver using the "bflb,uart" compatible [2], and supports the M1S Dock's E907 core [3].

This patch provides a polling UART console driver for OpenSBI. Testing was performed on the Sipeed M1s Dock's C906 D0 core using UART3 at 2 Mbaud, with the input clock and pinmux configured by the preceding firmware.

The FDT frontend currently requires reg, clock-frequency and current-speed. This patch does not add board initialization or T-Head PMU support.

Validation:
- RV32 and RV64 cross-builds passed with the driver enabled.
- UART output through the OpenSBI banner and handoff to S-mode U-Boot was verified on the UART-only implementation.
- The board-tested revision was 6b317b61. The submitted revision differs only by leaving the driver disabled in generic defconfig; the UART driver sources are unchanged.
- UART RX, operation on the Ox64, and repeated cold boots remain untested.

[1] https://pine64.org/documentation/Ox64/
[2] https://docs.zephyrproject.org/latest/build/dts/api/bindings/serial/bflb,uart.html
[3] https://docs.zephyrproject.org/latest/boards/sipeed/m1s_dock/doc/index.html

 include/sbi_utils/serial/bl808-uart.h |  11 +++
 lib/utils/serial/Kconfig              |   9 +++
 lib/utils/serial/bl808-uart.c         | 107 ++++++++++++++++++++++++++
 lib/utils/serial/fdt_serial_bl808.c   |  44 +++++++++++
 lib/utils/serial/objects.mk           |   4 +
 5 files changed, 175 insertions(+)
 create mode 100644 include/sbi_utils/serial/bl808-uart.h
 create mode 100644 lib/utils/serial/bl808-uart.c
 create mode 100644 lib/utils/serial/fdt_serial_bl808.c
include/sbi_utils/serial/bl808-uart.h new file +11 -0
new file mode 100644
index 00000000..aa6281db
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+#ifndef __SERIAL_BL808_UART_H__
+#define __SERIAL_BL808_UART_H__
+
+#include <sbi/sbi_types.h>
+
+/* The caller must enable the input clock and configure the pinmux. */
+int bl808_uart_init(unsigned long base, u32 in_freq, u32 baudrate);
+
+#endif
lib/utils/serial/Kconfig +9 -0
index 21619d0d..15ede441 100644
@@ -14,6 +14,11 @@ config FDT_SERIAL_ALTR_JUART
 	select SERIAL_ALTR_JUART
 	default n
 
+config FDT_SERIAL_BL808
+	bool "Bouffalo Lab BL808 UART FDT driver"
+	select SERIAL_BL808
+	default n
+
 config FDT_SERIAL_CADENCE
 	bool "Cadence UART FDT driver"
 	select SERIAL_CADENCE
@@ -65,6 +70,10 @@ config SERIAL_ALTR_JUART
 	bool "Altera JTAG UART support"
 	default n
 
+config SERIAL_BL808
+	bool "Bouffalo Lab BL808 UART support"
+	default n
+
 config SERIAL_CADENCE
 	bool "Cadence UART support"
 	default n
lib/utils/serial/bl808-uart.c new file +107 -0

107 lines not on this page · raw message

lib/utils/serial/fdt_serial_bl808.c new file +44 -0

44 lines not on this page · raw message

lib/utils/serial/objects.mk +4 -0
index 94cf3a4b..d8659602 100644
@@ -13,6 +13,9 @@ libsbiutils-objs-$(CONFIG_FDT_SERIAL) += serial/fdt_serial_drivers.carray.o
 carray-fdt_serial_drivers-$(CONFIG_FDT_SERIAL_ALTR_JUART) += fdt_serial_altr_juart
 libsbiutils-objs-$(CONFIG_FDT_SERIAL_ALTR_JUART) += serial/fdt_serial_altr_juart.o
 
+carray-fdt_serial_drivers-$(CONFIG_FDT_SERIAL_BL808) += fdt_serial_bl808
+libsbiutils-objs-$(CONFIG_FDT_SERIAL_BL808) += serial/fdt_serial_bl808.o
+
 carray-fdt_serial_drivers-$(CONFIG_FDT_SERIAL_CADENCE) += fdt_serial_cadence
 libsbiutils-objs-$(CONFIG_FDT_SERIAL_CADENCE) += serial/fdt_serial_cadence.o
 
@@ -41,6 +44,7 @@ carray-fdt_serial_drivers-$(CONFIG_FDT_SERIAL_XILINX_UARTLITE) += fdt_serial_xln
 libsbiutils-objs-$(CONFIG_FDT_SERIAL_XILINX_UARTLITE) += serial/fdt_serial_xlnx_uartlite.o
 
 libsbiutils-objs-$(CONFIG_SERIAL_ALTR_JUART) += serial/altr-juart.o
+libsbiutils-objs-$(CONFIG_SERIAL_BL808) += serial/bl808-uart.o
 libsbiutils-objs-$(CONFIG_SERIAL_CADENCE) += serial/cadence-uart.o
 libsbiutils-objs-$(CONFIG_SERIAL_GAISLER) += serial/gaisler-uart.o
 libsbiutils-objs-$(CONFIG_SERIAL_RENESAS_SCIF) += serial/renesas_scif.o

base-commit: 6ad246a1494807ee91e36ffcf60e4c30bb309d45

Signature · 7 lines
2.47.3


-- 
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi