Skip to contentSkip to conversation

riscv: add Bouffalolab bl808 support

PATCH Superseded Jisheng Zhang 8 participants 27 messages Nov 20, 2022 – Nov 30, 2022

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover riscv: add Bouffalolab bl808 support

This series adds Bouffalolab uart driver and basic devicetrees for Bouffalolab bl808 SoC and Sipeed M1S dock board.

It's too late for v6.2-rc1, but I hope I can catch up the v6.3-rc1 window.

Jisheng Zhang (7):
dt-bindings: serial: add bindings doc for Bouffalolab
serial: bflb_uart: add Bouffalolab UART Driver
MAINTAINERS: add myself as a reviewer for Bouffalolab uart driver
riscv: add the Bouffalolab SoC family Kconfig option
riscv: dts: bouffalolab: add the bl808 SoC base device tree
riscv: dts: bouffalolab: add Sipeed M1S dock devicetree
MAINTAINERS: add myself as Bouffalolab SoC entry maintainer

 .../bindings/serial/bouffalolab,uart.yaml     |  50 ++
 MAINTAINERS                                   |  12 +
 arch/riscv/Kconfig.socs                       |   6 +
 arch/riscv/boot/dts/Makefile                  |   1 +
 arch/riscv/boot/dts/bouffalolab/Makefile      |   2 +
 .../boot/dts/bouffalolab/bl808-sipeed-m1s.dts |  30 +
 arch/riscv/boot/dts/bouffalolab/bl808.dtsi    |  74 ++
 drivers/tty/serial/Kconfig                    |  18 +
 drivers/tty/serial/Makefile                   |   1 +
 drivers/tty/serial/bflb_uart.c                | 659 ++++++++++++++++++
 include/uapi/linux/serial_core.h              |   3 +
 11 files changed, 856 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/serial/bouffalolab,uart.yaml
 create mode 100644 arch/riscv/boot/dts/bouffalolab/Makefile
 create mode 100644 arch/riscv/boot/dts/bouffalolab/bl808-sipeed-m1s.dts
 create mode 100644 arch/riscv/boot/dts/bouffalolab/bl808.dtsi
 create mode 100644 drivers/tty/serial/bflb_uart.c
Signature · 1 line
2.37.2
#1 lore raw

PATCH 1/7 dt-bindings: serial: add bindings doc for Bouffalolab uart driver

Add bindings doc for Bouffalolab UART Driver

---
 .../bindings/serial/bouffalolab,uart.yaml     | 50 +++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/serial/bouffalolab,uart.yaml
Documentation/devicetree/bindings/serial/bouffalolab,uart.yaml new file +50 -0
new file mode 100644
index 000000000000..6cef956d33d2
@@ -0,0 +1,50 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2022 Jisheng Zhang <[email protected]>
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/serial/bouffalolab,uart.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Bouffalolab UART Controller
+
+maintainers:
+  - Jisheng Zhang <[email protected]>
+
+allOf:
+  - $ref: serial.yaml#
+
+properties:
+  compatible:
+    const: bouffalolab,uart
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    aliases {
+        serial0 = &uart0;
+    };
+
+    uart0: serial@30002000 {
+        compatible = "bouffalolab,uart";
+        reg = <0x30002000 0x1000>;
+        interrupts = <53 IRQ_TYPE_LEVEL_HIGH>;
+        clocks = <&xtal>;
+    };
+...
Signature · 1 line
2.37.2
#4 lore raw

PATCH 2/7 serial: bflb_uart: add Bouffalolab UART Driver

In reply to Jisheng Zhang

Add the driver for Bouffalolab UART IP which is found in Bouffalolab SoCs such as bl808.

UART driver probe will create path named "/dev/ttySx".

---
 drivers/tty/serial/Kconfig       |  18 +
 drivers/tty/serial/Makefile      |   1 +
 drivers/tty/serial/bflb_uart.c   | 659 +++++++++++++++++++++++++++++++
 include/uapi/linux/serial_core.h |   3 +
 4 files changed, 681 insertions(+)
 create mode 100644 drivers/tty/serial/bflb_uart.c
drivers/tty/serial/Kconfig +18 -0
index 434f83168546..056a8144e2cc 100644
@@ -179,6 +179,24 @@ config SERIAL_ATMEL_TTYAT
 
 	  Say Y if you have an external 8250/16C550 UART.  If unsure, say N.
 
+config SERIAL_BFLB
+	tristate "Bouffalolab serial port support"
+	select SERIAL_CORE
+	depends on COMMON_CLK
+	help
+	  This enables the driver for the Bouffalolab's serial.
+
+config SERIAL_BFLB_CONSOLE
+	bool "Support for console on Bouffalolab serial port"
+	depends on SERIAL_BFLB
+	select SERIAL_CORE_CONSOLE
+	select SERIAL_EARLYCON
+	help
+	  Say Y here if you wish to use a Bouffalolab UART as the
+	  system console (the system console is the device which
+	  receives all kernel messages and warnings and which allows
+	  logins in single user mode) as /dev/ttySn.
+
 config SERIAL_KGDB_NMI
 	bool "Serial console over KGDB NMI debugger port"
 	depends on KGDB_SERIAL_CONSOLE
drivers/tty/serial/Makefile +1 -0
index 238a9557b487..8509cdc11d87 100644
@@ -25,6 +25,7 @@ obj-$(CONFIG_SERIAL_8250) += 8250/
 
 obj-$(CONFIG_SERIAL_AMBA_PL010) += amba-pl010.o
 obj-$(CONFIG_SERIAL_AMBA_PL011) += amba-pl011.o
+obj-$(CONFIG_SERIAL_BFLB) += bflb_uart.o
 obj-$(CONFIG_SERIAL_CLPS711X) += clps711x.o
 obj-$(CONFIG_SERIAL_PXA_NON8250) += pxa.o
 obj-$(CONFIG_SERIAL_SA1100) += sa1100.o
drivers/tty/serial/bflb_uart.c new file +659 -0

659 lines not on this page · raw message

include/uapi/linux/serial_core.h +3 -0
index 3ba34d8378bd..dabbb5ea2857 100644
@@ -276,4 +276,7 @@
 /* Sunplus UART */
 #define PORT_SUNPLUS	123
 
+/* Bouffalolab UART */
+#define PORT_BFLB	124
+
 #endif /* _UAPILINUX_SERIAL_CORE_H */
Signature · 1 line
2.37.2
#7 lore raw

PATCH 3/7 MAINTAINERS: add myself as a reviewer for Bouffalolab uart driver

In reply to Jisheng Zhang

I want to maintain this Bouffalolab uart driver from now on.

---
 MAINTAINERS | 6 ++++++
 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
index 2585e7edc335..92451834b940 100644
@@ -3718,6 +3718,12 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/iio/accel/bosch,bma400.yaml
 F:	drivers/iio/accel/bma400*
 
+BOUFFALOLAB UART DRIVER
+M:	Jisheng Zhang <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/serial/bouffalolab,uart.yaml
+F:	drivers/tty/serial/bflb_uart.c
+
 BPF [GENERAL] (Safe Dynamic Programs and Tools)
 M:	Alexei Starovoitov <[email protected]>
 M:	Daniel Borkmann <[email protected]>
Signature · 1 line
2.37.2
#8 lore raw

PATCH 4/7 riscv: add the Bouffalolab SoC family Kconfig option

In reply to Jisheng Zhang

The Bouffalolab bl808 SoC contains three riscv CPUs, namely M0, D0 and LP. The D0 is 64bit RISC-V GC compatible, so can run linux.

---
 arch/riscv/Kconfig.socs | 6 ++++++
 1 file changed, 6 insertions(+)
arch/riscv/Kconfig.socs +6 -0
index 69774bb362d6..90256f44ed4a 100644
@@ -1,5 +1,11 @@
 menu "SoC selection"
 
+config SOC_BOUFFALOLAB
+	bool "Bouffalolab SoCs"
+	select SIFIVE_PLIC
+	help
+	  This enables support for Bouffalolab SoC platforms.
+
 config SOC_MICROCHIP_POLARFIRE
 	bool "Microchip PolarFire SoCs"
 	select MCHP_CLK_MPFS
Signature · 7 lines
2.37.2


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#10 lore raw

PATCH 5/7 riscv: dts: bouffalolab: add the bl808 SoC base device tree

In reply to Jisheng Zhang

Add a baisc dtsi for the bouffalolab bl808 SoC.

---
 arch/riscv/boot/dts/Makefile               |  1 +
 arch/riscv/boot/dts/bouffalolab/bl808.dtsi | 74 ++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 100644 arch/riscv/boot/dts/bouffalolab/bl808.dtsi
arch/riscv/boot/dts/Makefile +1 -0
index ff174996cdfd..b525467152b2 100644
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
+subdir-y += bouffalolab
 subdir-y += sifive
 subdir-y += starfive
 subdir-$(CONFIG_SOC_CANAAN_K210_DTB_BUILTIN) += canaan
arch/riscv/boot/dts/bouffalolab/bl808.dtsi new file +74 -0

74 lines not on this page · raw message

Signature · 7 lines
2.37.2


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#20 lore raw

PATCH 6/7 riscv: dts: bouffalolab: add Sipeed M1S dock devicetree

In reply to Jisheng Zhang

Sipeed manufactures a M1S system-on-module and dock board, add basic support for them.

---
 arch/riscv/boot/dts/bouffalolab/Makefile      |  2 ++
 .../boot/dts/bouffalolab/bl808-sipeed-m1s.dts | 30 +++++++++++++++++++
 2 files changed, 32 insertions(+)
 create mode 100644 arch/riscv/boot/dts/bouffalolab/Makefile
 create mode 100644 arch/riscv/boot/dts/bouffalolab/bl808-sipeed-m1s.dts
arch/riscv/boot/dts/bouffalolab/Makefile new file +2 -0
new file mode 100644
index 000000000000..42e17e1a97bd
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+dtb-$(CONFIG_SOC_BOUFFALOLAB) += bl808-sipeed-m1s.dtb
arch/riscv/boot/dts/bouffalolab/bl808-sipeed-m1s.dts new file +30 -0
new file mode 100644
index 000000000000..64421fb2ad67
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: (GPL-2.0+ or MIT)
+/*
+ * Copyright (C) 2022 Jisheng Zhang <[email protected]>
+ */
+
+/dts-v1/;
+
+#include "bl808.dtsi"
+
+/ {
+	model = "Sipeed M1S";
+	compatible = "sipeed,m1s", "bouffalolab,bl808";
+
+	aliases {
+		serial0 = &uart0;
+	};
+
+	chosen {
+		stdout-path = "serial0:2000000n8";
+	};
+
+	memory@50000000 {
+		device_type = "memory";
+		reg = <0x50000000 0x04000000>;
+	};
+};
+
+&uart0 {
+	status = "okay";
+};
Signature · 7 lines
2.37.2


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#25 lore raw

PATCH 7/7 MAINTAINERS: add myself as Bouffalolab SoC entry maintainer

In reply to Jisheng Zhang

I want to maintain this Bouffalolab riscv SoC entry from now on.

---
 MAINTAINERS | 6 ++++++
 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
index 92451834b940..3564b27d7da4 100644
@@ -17738,6 +17738,12 @@ F:	arch/riscv/
 N:	riscv
 K:	riscv
 
+RISC-V BOUFFALOLAB SOC SUPPORT
+M:	Jisheng Zhang <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	arch/riscv/boot/dts/bouffalolab/
+
 RISC-V MICROCHIP FPGA SUPPORT
 M:	Conor Dooley <[email protected]>
 M:	Daire McNamara <[email protected]>
Signature · 7 lines
2.37.2


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Reviewed-by on v1 4/7
#9 lore raw

Re: [PATCH 4/7] riscv: add the Bouffalolab SoC family Kconfig option

In reply to Jisheng Zhang
Quoted 2 lines · Jisheng Zhang

The Bouffalolab bl808 SoC contains three riscv CPUs, namely M0, D0 and LP. The D0 is 64bit RISC-V GC compatible, so can run linux.

Could you also add this new SOC_BOUFFALOLAB symbol to defconfig please?

Quoted 25 lines
---
 arch/riscv/Kconfig.socs | 6 ++++++
 1 file changed, 6 insertions(+)
arch/riscv/Kconfig.socs +6 -0
index 69774bb362d6..90256f44ed4a 100644
@@ -1,5 +1,11 @@
 menu "SoC selection"
 
+config SOC_BOUFFALOLAB
+	bool "Bouffalolab SoCs"
+	select SIFIVE_PLIC
+	help
+	  This enables support for Bouffalolab SoC platforms.
+
 config SOC_MICROCHIP_POLARFIRE
 	bool "Microchip PolarFire SoCs"
 	select MCHP_CLK_MPFS
Signature · 1 line
2.37.2
#11 lore raw

Re: [PATCH 5/7] riscv: dts: bouffalolab: add the bl808 SoC base device tree

In reply to Jisheng Zhang
Quoted 34 lines · Jisheng Zhang

Add a baisc dtsi for the bouffalolab bl808 SoC.

---
 arch/riscv/boot/dts/Makefile               |  1 +
 arch/riscv/boot/dts/bouffalolab/bl808.dtsi | 74 ++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 100644 arch/riscv/boot/dts/bouffalolab/bl808.dtsi
arch/riscv/boot/dts/Makefile +1 -0
index ff174996cdfd..b525467152b2 100644
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
+subdir-y += bouffalolab
 subdir-y += sifive
 subdir-y += starfive
 subdir-$(CONFIG_SOC_CANAAN_K210_DTB_BUILTIN) += canaan
arch/riscv/boot/dts/bouffalolab/bl808.dtsi new file +9 -0
new file mode 100644
index 000000000000..c98ebb14ee10
@@ -0,0 +1,74 @@
+// SPDX-License-Identifier: (GPL-2.0+ or MIT)
+/*
+ * Copyright (C) 2022 Jisheng Zhang <[email protected]>
+ */
+
+#include <dt-bindings/interrupt-controller/irq.h>
+
+/ {
+	compatible = "bouffalolab,bl808";

arch/riscv/boot/dts/bouffalolab/bl808.dtsi line 19

Quoted 10 lines
arch/riscv/boot/dts/bouffalolab/bl808.dtsi new file +10 -0
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	cpus {
+		timebase-frequency = <1000000>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cpu0: cpu@0 {
+			compatible = "thead,c906", "riscv";

So this is not yet defined as the dt etc for the d1 has not yet landed. I think I will go pick up that patch for v6.2 as it should make everyone's life easier.

Without that, dtbs_check produces:
arch/riscv/boot/dts/bouffalolab/bl808-sipeed-m1s.dtb:0:0: /cpus/cpu@0: failed to match any schema with compatible: ['thead,c906', 'riscv']

Quoted 35 lines
arch/riscv/boot/dts/bouffalolab/bl808.dtsi new file +35 -0
+			device_type = "cpu";
+			reg = <0>;
+			d-cache-block-size = <64>;
+			d-cache-sets = <256>;
+			d-cache-size = <32768>;
+			i-cache-block-size = <64>;
+			i-cache-sets = <128>;
+			i-cache-size = <32768>;
+			mmu-type = "riscv,sv39";
+			riscv,isa = "rv64imafdc";
+
+			cpu0_intc: interrupt-controller {
+				compatible = "riscv,cpu-intc";
+				interrupt-controller;
+				#address-cells = <0>;
+				#interrupt-cells = <1>;
+			};
+		};
+	};
+
+	xtal: xtal-clk {
+		compatible = "fixed-clock";
+		clock-frequency = <40000000>;
+		clock-output-names = "xtal";
+		#clock-cells = <0>;
+	};
+
+	soc {
+		compatible = "simple-bus";
+		ranges;
+		interrupt-parent = <&plic>;
+		dma-noncoherent;
+		#address-cells = <1>;
+		#size-cells = <1>;
+

arch/riscv/boot/dts/bouffalolab/bl808.dtsi line 64

Quoted 10 lines
arch/riscv/boot/dts/bouffalolab/bl808.dtsi new file +10 -0
+		uart0: serial@30002000 {
+			compatible = "bouffalolab,uart";
+			reg = <0x30002000 0x1000>;
+			interrupts = <20 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&xtal>;
+			status = "disabled";
+		};
+
+		plic: interrupt-controller@e0000000 {
+			compatible = "thead,c900-plic";

Hmm, this one fails validation too. Likely you need to add a "bouffalolab,plic" to the plic dt-binding or otherwise modify the binding such that thead,c900-plic on it's own is permitted. CC Samuel on that patch please in case he has an opinion on it.

Also, I've taken over picking up the misc dt stuff that Palmer used to apply - so canaan, starfive & sifive stuff. Do you intended sending PRs to Arnd for this stuff, or would you like to me bundle it with what I am going to be sending anyway?

Thanks,
Conor.

Quoted 13 lines
arch/riscv/boot/dts/bouffalolab/bl808.dtsi new file +10 -0
+			reg = <0xe0000000 0x4000000>;
+			interrupts-extended = <&cpu0_intc 0xffffffff>,
+					      <&cpu0_intc 9>;
+			interrupt-controller;
+			#address-cells = <0>;
+			#interrupt-cells = <2>;
+			riscv,ndev = <64>;
+		};
+	};
+};
Signature · 1 line
2.37.2
#21 lore raw

Re: [PATCH 6/7] riscv: dts: bouffalolab: add Sipeed M1S dock devicetree

In reply to Jisheng Zhang
Quoted 27 lines · Jisheng Zhang

Sipeed manufactures a M1S system-on-module and dock board, add basic support for them.

---
 arch/riscv/boot/dts/bouffalolab/Makefile      |  2 ++
 .../boot/dts/bouffalolab/bl808-sipeed-m1s.dts | 30 +++++++++++++++++++
 2 files changed, 32 insertions(+)
 create mode 100644 arch/riscv/boot/dts/bouffalolab/Makefile
 create mode 100644 arch/riscv/boot/dts/bouffalolab/bl808-sipeed-m1s.dts
arch/riscv/boot/dts/bouffalolab/Makefile new file +2 -0
new file mode 100644
index 000000000000..42e17e1a97bd
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+dtb-$(CONFIG_SOC_BOUFFALOLAB) += bl808-sipeed-m1s.dtb
arch/riscv/boot/dts/bouffalolab/bl808-sipeed-m1s.dts new file +2 -0
new file mode 100644
index 000000000000..64421fb2ad67
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: (GPL-2.0+ or MIT)
+/*

arch/riscv/boot/dts/bouffalolab/bl808-sipeed-m1s.dts line 12

Quoted 10 lines
arch/riscv/boot/dts/bouffalolab/bl808-sipeed-m1s.dts new file +10 -0
+ * Copyright (C) 2022 Jisheng Zhang <[email protected]>
+ */
+
+/dts-v1/;
+
+#include "bl808.dtsi"
+
+/ {
+	model = "Sipeed M1S";
+	compatible = "sipeed,m1s", "bouffalolab,bl808";

These compatibles also need to be defined, in a bouffalolab.yaml in the
riscv/ bindings subdirectory. Otherwise:
arch/riscv/boot/dts/bouffalolab/bl808-sipeed-m1s.dtb:0:0: /: failed to match any schema with compatible: ['sipeed,m1s', 'bouffalolab,bl808']

Thanks,
Conor.

Quoted 21 lines
arch/riscv/boot/dts/bouffalolab/bl808-sipeed-m1s.dts new file +18 -0
+
+	aliases {
+		serial0 = &uart0;
+	};
+
+	chosen {
+		stdout-path = "serial0:2000000n8";
+	};
+
+	memory@50000000 {
+		device_type = "memory";
+		reg = <0x50000000 0x04000000>;
+	};
+};
+
+&uart0 {
+	status = "okay";
+};
Signature · 1 line
2.37.2
#22 lore raw

Re: [PATCH 6/7] riscv: dts: bouffalolab: add Sipeed M1S dock devicetree

In reply to Jisheng Zhang
Quoted 7 lines · 在 2022-11-20星期日的 16:21 +0800,Jisheng Zhang写道:

Sipeed manufactures a M1S system-on-module and dock board, add basic support for them.

---
 arch/riscv/boot/dts/bouffalolab/Makefile      |  2 ++ .../boot/dts/bouffalolab/bl808-sipeed-m1s.dts | 30

I suggest a M1s DTSI and a M1s Dock DTS.

Quoted 52 lines

+++++++++++++++++++

 2 files changed, 32 insertions(+)

 create mode 100644 arch/riscv/boot/dts/bouffalolab/Makefile create mode 100644 arch/riscv/boot/dts/bouffalolab/bl808-sipeed- m1s.dts

arch/riscv/boot/dts/bouffalolab/Makefile new file +2 -0
new file mode 100644
index 000000000000..42e17e1a97bd
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+dtb-$(CONFIG_SOC_BOUFFALOLAB) += bl808-sipeed-m1s.dtb
arch/riscv/boot/dts/bouffalolab/bl808-sipeed-m1s.dts new file +30 -0
new file mode 100644
index 000000000000..64421fb2ad67
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: (GPL-2.0+ or MIT)
+/*
+ * Copyright (C) 2022 Jisheng Zhang <[email protected]>
+ */
+
+/dts-v1/;
+
+#include "bl808.dtsi"
+
+/ {
+       model = "Sipeed M1S";
+       compatible = "sipeed,m1s", "bouffalolab,bl808";
+
+       aliases {
+               serial0 = &uart0;
+       };
+
+       chosen {
+               stdout-path = "serial0:2000000n8";
+       };
+
+       memory@50000000 {
+               device_type = "memory";
+               reg = <0x50000000 0x04000000>;
+       };
+};
+
+&uart0 {
+       status = "okay";
+};
#12 lore raw

Re: [PATCH 5/7] riscv: dts: bouffalolab: add the bl808 SoC base device tree

In reply to Conor Dooley
Quoted 102 lines · 在 2022-11-20星期日的 11:02 +0000,Conor Dooley写道:
Quoted 37 lines · Jisheng Zhang

Add a baisc dtsi for the bouffalolab bl808 SoC.

---
 arch/riscv/boot/dts/Makefile               |  1 + arch/riscv/boot/dts/bouffalolab/bl808.dtsi | 74
++++++++++++++++++++++

 2 files changed, 75 insertions(+)

 create mode 100644 arch/riscv/boot/dts/bouffalolab/bl808.dtsi

arch/riscv/boot/dts/Makefile +1 -0
index ff174996cdfd..b525467152b2 100644
@@ -1,4 +1,5 @@
  # SPDX-License-Identifier: GPL-2.0
+subdir-y += bouffalolab

 subdir-y += sifive
 subdir-y += starfive subdir-$(CONFIG_SOC_CANAAN_K210_DTB_BUILTIN) += canaan

arch/riscv/boot/dts/bouffalolab/bl808.dtsi new file +9 -0
new file mode 100644
index 000000000000..c98ebb14ee10
@@ -0,0 +1,74 @@
+// SPDX-License-Identifier: (GPL-2.0+ or MIT)
+/*
+ * Copyright (C) 2022 Jisheng Zhang <[email protected]>
+ */
+
+#include <dt-bindings/interrupt-controller/irq.h>
+
+/ {
+       compatible = "bouffalolab,bl808";

arch/riscv/boot/dts/bouffalolab/bl808.dtsi line 19

Quoted 10 lines
arch/riscv/boot/dts/bouffalolab/bl808.dtsi new file +10 -0
+       #address-cells = <1>;
+       #size-cells = <1>;
+
+       cpus {
+               timebase-frequency = <1000000>;
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               cpu0: cpu@0 {
+                       compatible = "thead,c906", "riscv";

So this is not yet defined as the dt etc for the d1 has not yet landed.
I think I will go pick up that patch for v6.2 as it should make everyone's life easier.

Without that, dtbs_check produces:
arch/riscv/boot/dts/bouffalolab/bl808-sipeed-m1s.dtb:0:0:
/cpus/cpu@0: failed to match any schema with compatible:
['thead,c906', 'riscv']

Quoted 43 lines
arch/riscv/boot/dts/bouffalolab/bl808.dtsi new file +43 -0
+                       device_type = "cpu";
+                       reg = <0>;
+                       d-cache-block-size = <64>;
+                       d-cache-sets = <256>;
+                       d-cache-size = <32768>;
+                       i-cache-block-size = <64>;
+                       i-cache-sets = <128>;
+                       i-cache-size = <32768>;
+                       mmu-type = "riscv,sv39";
+                       riscv,isa = "rv64imafdc";
+
+                       cpu0_intc: interrupt-controller {
+                               compatible = "riscv,cpu-intc";
+                               interrupt-controller;
+                               #address-cells = <0>;
+                               #interrupt-cells = <1>;
+                       };
+               };
+       };
+
+       xtal: xtal-clk {
+               compatible = "fixed-clock";
+               clock-frequency = <40000000>;
+               clock-output-names = "xtal";
+               #clock-cells = <0>;
+       };
+
+       soc {
+               compatible = "simple-bus";
+               ranges;
+               interrupt-parent = <&plic>;
+               dma-noncoherent;
+               #address-cells = <1>;
+               #size-cells = <1>;
+
+               uart0: serial@30002000 {
+                       compatible = "bouffalolab,uart";
+                       reg = <0x30002000 0x1000>;
+                       interrupts = <20 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&xtal>;
+                       status = "disabled";
+               };
+
Quoted 8 lines

arch/riscv/boot/dts/bouffalolab/bl808.dtsi line 64

Quoted 2 lines
arch/riscv/boot/dts/bouffalolab/bl808.dtsi new file +2 -0
+               plic: interrupt-controller@e0000000 {
+                       compatible = "thead,c900-plic";

Hmm, this one fails validation too. Likely you need to add a "bouffalolab,plic" to the plic dt-binding or otherwise modify the binding such that thead,c900-plic on it's own is permitted. CC Samuel on
that patch please in case he has an opinion on it.

Personally I prefer a single c900-plic in compatible, because the PLIC doesn't look so configurable in C906/C910 (the interrupt source number is really adjustable, but it's already in the riscv,ndev property).

Quoted 31 lines

Also, I've taken over picking up the misc dt stuff that Palmer used to
apply - so canaan, starfive & sifive stuff. Do you intended sending PRs
to Arnd for this stuff, or would you like to me bundle it with what I am
going to be sending anyway?

Thanks,
Conor.

Quoted 14 lines
arch/riscv/boot/dts/bouffalolab/bl808.dtsi new file +2 -0
+                       reg = <0xe0000000 0x4000000>;
+                       interrupts-extended = <&cpu0_intc

0xffffffff>,
+                                             <&cpu0_intc 9>; +                       interrupt-controller;
+                       #address-cells = <0>;
+                       #interrupt-cells = <2>;
+                       riscv,ndev = <64>;
+               };
+       };
+};

Signature · 1 line
2.37.2

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

#13 lore raw

Re: [PATCH 5/7] riscv: dts: bouffalolab: add the bl808 SoC base device tree

Quoted 13 lines · Icenowy Zheng
Quoted 11 lines · 在 2022-11-20星期日的 11:02 +0000,Conor Dooley写道:
Quoted 4 lines · Jisheng Zhang

Add a baisc dtsi for the bouffalolab bl808 SoC.

+               plic: interrupt-controller@e0000000 { +                       compatible = "thead,c900-plic";

Hmm, this one fails validation too. Likely you need to add a "bouffalolab,plic" to the plic dt-binding or otherwise modify the binding such that thead,c900-plic on it's own is permitted. CC Samuel on
that patch please in case he has an opinion on it.

Quoted 3 lines

Personally I prefer a single c900-plic in compatible, because the PLIC doesn't look so configurable in C906/C910 (the interrupt source number is really adjustable, but it's already in the riscv,ndev property).

Right, if all implementations are going to be identical (modulo the riscv,ndev) allowing thead,c900-plic in isolation makes sense to me. I had a bit of a check in the history & it looks like there was no explanation given for why the D1 needed a specific compatible (although there's no harm in having one in case something comes up in the future that'd require special handling for a given implementation).

#14 lore raw

Re: [PATCH 5/7] riscv: dts: bouffalolab: add the bl808 SoC base device tree

In reply to Jisheng Zhang
Quoted 58 lines · Jisheng Zhang

Add a baisc dtsi for the bouffalolab bl808 SoC.

---
 arch/riscv/boot/dts/Makefile               |  1 +
 arch/riscv/boot/dts/bouffalolab/bl808.dtsi | 74 ++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 100644 arch/riscv/boot/dts/bouffalolab/bl808.dtsi
arch/riscv/boot/dts/Makefile +1 -0
index ff174996cdfd..b525467152b2 100644
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
+subdir-y += bouffalolab
 subdir-y += sifive
 subdir-y += starfive
 subdir-$(CONFIG_SOC_CANAAN_K210_DTB_BUILTIN) += canaan
arch/riscv/boot/dts/bouffalolab/bl808.dtsi new file +32 -0
new file mode 100644
index 000000000000..c98ebb14ee10
@@ -0,0 +1,74 @@
+// SPDX-License-Identifier: (GPL-2.0+ or MIT)
+/*
+ * Copyright (C) 2022 Jisheng Zhang <[email protected]>
+ */
+
+#include <dt-bindings/interrupt-controller/irq.h>
+
+/ {
+       compatible = "bouffalolab,bl808";
+       #address-cells = <1>;
+       #size-cells = <1>;
+
+       cpus {
+               timebase-frequency = <1000000>;
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               cpu0: cpu@0 {
+                       compatible = "thead,c906", "riscv";
+                       device_type = "cpu";
+                       reg = <0>;
+                       d-cache-block-size = <64>;
+                       d-cache-sets = <256>;
+                       d-cache-size = <32768>;
+                       i-cache-block-size = <64>;
+                       i-cache-sets = <128>;
+                       i-cache-size = <32768>;
+                       mmu-type = "riscv,sv39";
+                       riscv,isa = "rv64imafdc";
+
+                       cpu0_intc: interrupt-controller {
+                               compatible = "riscv,cpu-intc";

arch/riscv/boot/dts/bouffalolab/bl808.dtsi line 42

Quoted 10 lines
arch/riscv/boot/dts/bouffalolab/bl808.dtsi new file +10 -0
+                               interrupt-controller;
+                               #address-cells = <0>;
+                               #interrupt-cells = <1>;
+                       };
+               };
+       };
+
+       xtal: xtal-clk {
+               compatible = "fixed-clock";
+               clock-frequency = <40000000>;

This was discussed many times before, but I think the conclusion was that the frequency is a property of the crystal on the board, so this should be 0 in the SoC dtsi, and then overwritten in the board device tree.

Quoted 40 lines
arch/riscv/boot/dts/bouffalolab/bl808.dtsi new file +32 -1
+               clock-output-names = "xtal";
+               #clock-cells = <0>;
+       };
+
+       soc {
+               compatible = "simple-bus";
+               ranges;
+               interrupt-parent = <&plic>;
+               dma-noncoherent;
+               #address-cells = <1>;
+               #size-cells = <1>;
+
+               uart0: serial@30002000 {
+                       compatible = "bouffalolab,uart";
+                       reg = <0x30002000 0x1000>;
+                       interrupts = <20 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&xtal>;
+                       status = "disabled";
+               };
+
+               plic: interrupt-controller@e0000000 {
+                       compatible = "thead,c900-plic";
+                       reg = <0xe0000000 0x4000000>;
+                       interrupts-extended = <&cpu0_intc 0xffffffff>,
+                                             <&cpu0_intc 9>;
+                       interrupt-controller;
+                       #address-cells = <0>;
+                       #interrupt-cells = <2>;
+                       riscv,ndev = <64>;
+               };
+       };
+};
--

2.37.2

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

#23 lore raw

Re: [PATCH 6/7] riscv: dts: bouffalolab: add Sipeed M1S dock devicetree

In reply to Jisheng Zhang
Quoted 27 lines · Jisheng Zhang

Sipeed manufactures a M1S system-on-module and dock board, add basic support for them.

---
 arch/riscv/boot/dts/bouffalolab/Makefile      |  2 ++
 .../boot/dts/bouffalolab/bl808-sipeed-m1s.dts | 30 +++++++++++++++++++
 2 files changed, 32 insertions(+)
 create mode 100644 arch/riscv/boot/dts/bouffalolab/Makefile
 create mode 100644 arch/riscv/boot/dts/bouffalolab/bl808-sipeed-m1s.dts
arch/riscv/boot/dts/bouffalolab/Makefile new file +2 -0
new file mode 100644
index 000000000000..42e17e1a97bd
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+dtb-$(CONFIG_SOC_BOUFFALOLAB) += bl808-sipeed-m1s.dtb
arch/riscv/boot/dts/bouffalolab/bl808-sipeed-m1s.dts new file +1 -0
new file mode 100644
index 000000000000..64421fb2ad67
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: (GPL-2.0+ or MIT)

arch/riscv/boot/dts/bouffalolab/bl808-sipeed-m1s.dts line 11

Quoted 10 lines
arch/riscv/boot/dts/bouffalolab/bl808-sipeed-m1s.dts new file +10 -0
+/*
+ * Copyright (C) 2022 Jisheng Zhang <[email protected]>
+ */
+
+/dts-v1/;
+
+#include "bl808.dtsi"
+
+/ {
+       model = "Sipeed M1S";

On seeedstudio.com and everywhere else I look I only see this written as "Sipeed M1s".

And to echo what Icenowy writes, this is better split as a .dtsi for the Sipeed M1s module that can then be included by a .dts for the using the module with the dock, which should then have something like

model = "Sipeed M1s Dock";

Quoted 27 lines
arch/riscv/boot/dts/bouffalolab/bl808-sipeed-m1s.dts new file +19 -1
+       compatible = "sipeed,m1s", "bouffalolab,bl808";
+
+       aliases {
+               serial0 = &uart0;
+       };
+
+       chosen {
+               stdout-path = "serial0:2000000n8";
+       };
+
+       memory@50000000 {
+               device_type = "memory";
+               reg = <0x50000000 0x04000000>;
+       };
+};
+
+&uart0 {
+       status = "okay";
+};
---

2.37.2

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

#15 lore raw

Re: [PATCH 5/7] riscv: dts: bouffalolab: add the bl808 SoC base device tree

In reply to Emil Renner Berthing
Quoted 4 lines · Emil Renner Berthing
Quoted 2 lines · Jisheng Zhang

Add a baisc dtsi for the bouffalolab bl808 SoC.

Quoted 8 lines

arch/riscv/boot/dts/bouffalolab/bl808.dtsi line 42

Quoted 3 lines
arch/riscv/boot/dts/bouffalolab/bl808.dtsi new file +3 -0
+       xtal: xtal-clk {
+               compatible = "fixed-clock";
+               clock-frequency = <40000000>;

This was discussed many times before, but I think the conclusion was that the frequency is a property of the crystal on the board, so this should be 0 in the SoC dtsi, and then overwritten in the board device tree.

Or set nothing in soc.dtsi so that dtbs_check can be used to see if someone forgot to set a clock for their board?

Quoted 3 lines
Quoted 3 lines
arch/riscv/boot/dts/bouffalolab/bl808.dtsi new file +3 -0
+               clock-output-names = "xtal";
+               #clock-cells = <0>;
+       };
#16 lore raw

Re: [PATCH 5/7] riscv: dts: bouffalolab: add the bl808 SoC base device tree

Quoted 10 lines · Conor Dooley
Quoted 8 lines · Emil Renner Berthing
Quoted 6 lines · Jisheng Zhang

Add a baisc dtsi for the bouffalolab bl808 SoC.

arch/riscv/boot/dts/bouffalolab/bl808.dtsi new file +3 -0
+       xtal: xtal-clk {
+               compatible = "fixed-clock";
+               clock-frequency = <40000000>;
Quoted 7 lines
Quoted 4 lines

This was discussed many times before, but I think the conclusion was that the frequency is a property of the crystal on the board, so this should be 0 in the SoC dtsi, and then overwritten in the board device tree.

Or set nothing in soc.dtsi so that dtbs_check can be used to see if someone forgot to set a clock for their board?

Sure. That sounds even better.

Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
arch/riscv/boot/dts/bouffalolab/bl808.dtsi new file +3 -0
+               clock-output-names = "xtal";
+               #clock-cells = <0>;
+       };
#17 lore raw

Re: [PATCH 5/7] riscv: dts: bouffalolab: add the bl808 SoC base device tree

In reply to Emil Renner Berthing
Quoted 70 lines · 在 2022-11-20星期日的 15:57 +0100,Emil Renner Berthing写道:
Quoted 68 lines · Jisheng Zhang

Add a baisc dtsi for the bouffalolab bl808 SoC.

---
 arch/riscv/boot/dts/Makefile               |  1 + arch/riscv/boot/dts/bouffalolab/bl808.dtsi | 74
++++++++++++++++++++++

 2 files changed, 75 insertions(+)

 create mode 100644 arch/riscv/boot/dts/bouffalolab/bl808.dtsi

arch/riscv/boot/dts/Makefile +1 -0
index ff174996cdfd..b525467152b2 100644
@@ -1,4 +1,5 @@
  # SPDX-License-Identifier: GPL-2.0
+subdir-y += bouffalolab

 subdir-y += sifive
 subdir-y += starfive subdir-$(CONFIG_SOC_CANAAN_K210_DTB_BUILTIN) += canaan

arch/riscv/boot/dts/bouffalolab/bl808.dtsi new file +39 -0
new file mode 100644
index 000000000000..c98ebb14ee10
@@ -0,0 +1,74 @@
+// SPDX-License-Identifier: (GPL-2.0+ or MIT)
+/*
+ * Copyright (C) 2022 Jisheng Zhang <[email protected]>
+ */
+
+#include <dt-bindings/interrupt-controller/irq.h>
+
+/ {
+       compatible = "bouffalolab,bl808";
+       #address-cells = <1>;
+       #size-cells = <1>;
+
+       cpus {
+               timebase-frequency = <1000000>;
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               cpu0: cpu@0 {
+                       compatible = "thead,c906", "riscv";
+                       device_type = "cpu";
+                       reg = <0>;
+                       d-cache-block-size = <64>;
+                       d-cache-sets = <256>;
+                       d-cache-size = <32768>;
+                       i-cache-block-size = <64>;
+                       i-cache-sets = <128>;
+                       i-cache-size = <32768>;
+                       mmu-type = "riscv,sv39";
+                       riscv,isa = "rv64imafdc";
+
+                       cpu0_intc: interrupt-controller {
+                               compatible = "riscv,cpu-intc";
+                               interrupt-controller;
+                               #address-cells = <0>;
+                               #interrupt-cells = <1>;
+                       };
+               };
+       };
+
Quoted 8 lines

arch/riscv/boot/dts/bouffalolab/bl808.dtsi line 42

Quoted 3 lines
arch/riscv/boot/dts/bouffalolab/bl808.dtsi new file +3 -0
+       xtal: xtal-clk {
+               compatible = "fixed-clock";
+               clock-frequency = <40000000>;

This was discussed many times before, but I think the conclusion was that the frequency is a property of the crystal on the board, so this should be 0 in the SoC dtsi, and then overwritten in the board device tree.

But many chips just specify an accepted frequency in their datasheet, and using a frequency other than this is undefined behavior.

Quoted 47 lines
Quoted 38 lines
arch/riscv/boot/dts/bouffalolab/bl808.dtsi new file +24 -0
+               clock-output-names = "xtal";
+               #clock-cells = <0>;
+       };
+
+       soc {
+               compatible = "simple-bus";
+               ranges;
+               interrupt-parent = <&plic>;
+               dma-noncoherent;
+               #address-cells = <1>;
+               #size-cells = <1>;
+
+               uart0: serial@30002000 {
+                       compatible = "bouffalolab,uart";
+                       reg = <0x30002000 0x1000>;
+                       interrupts = <20 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&xtal>;
+                       status = "disabled";
+               };
+
+               plic: interrupt-controller@e0000000 {
+                       compatible = "thead,c900-plic";
+                       reg = <0xe0000000 0x4000000>;
+                       interrupts-extended = <&cpu0_intc

0xffffffff>,
+                                             <&cpu0_intc 9>; +                       interrupt-controller;
+                       #address-cells = <0>;
+                       #interrupt-cells = <2>;
+                       riscv,ndev = <64>;
+               };
+       };
+};
--
2.37.2

Quoted 4 lines

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

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

maintainer
#5 lore raw

Re: [PATCH 2/7] serial: bflb_uart: add Bouffalolab UART Driver

In reply to Jisheng Zhang

Hi,

Quoted 6 lines · Jisheng Zhang

Add the driver for Bouffalolab UART IP which is found in Bouffalolab SoCs such as bl808.

UART driver probe will create path named "/dev/ttySx".

...

Quoted 1 line

#define UART_FIFO_CONFIG_0 (0x80)

Superfluous parentheses.

...

drivers/tty/serial/bflb_uart.c line 179

Quoted 9 lines
drivers/tty/serial/bflb_uart.c new file +9 -0
+static void bflb_uart_set_termios(struct uart_port *port,
+				  struct ktermios *termios,
+				  const struct ktermios *old)
+{
+	unsigned long flags;
+	u32 valt, valr, val;
+	unsigned int baud, min;
+
+	valt = valr = 0;

Unneeded (see below).

drivers/tty/serial/bflb_uart.c line 185

Quoted 6 lines
drivers/tty/serial/bflb_uart.c new file +6 -0
+
+	spin_lock_irqsave(&port->lock, flags);
+
+	/* set data length */
+	val = tty_get_char_size(termios->c_cflag) - 1;
+	valt |= (val << UART_CR_UTX_BIT_CNT_D_SFT);

Use =, not |=. Other than that, can FIELD_SET() be used, provided you already define the constants using GENMASK()?

drivers/tty/serial/bflb_uart.c line 192

Quoted 7 lines
drivers/tty/serial/bflb_uart.c new file +7 -0
+
+	/* calculate parity */
+	termios->c_cflag &= ~CMSPAR;	/* no support mark/space */
+	if (termios->c_cflag & PARENB) {
+		valt |= UART_CR_UTX_PRT_EN;
+		if (termios->c_cflag & PARODD)
+			valr |= UART_CR_UTX_PRT_SEL;

This should be valt, IMO.

drivers/tty/serial/bflb_uart.c line 195

Quoted 3 lines
drivers/tty/serial/bflb_uart.c new file +3 -0
+	}
+
+	valr = valt;

If not, this doesn't make sense to me.

Quoted 6 lines
drivers/tty/serial/bflb_uart.c new file +6 -0
+	/* calculate stop bits */
+	if (termios->c_cflag & CSTOPB)
+		val = 2;
+	else
+		val = 1;
+	valt |= (val << UART_CR_UTX_BIT_CNT_P_SFT);

drivers/tty/serial/bflb_uart.c line 212

Quoted 10 lines
drivers/tty/serial/bflb_uart.c new file +10 -0
+
+	/* flow control */
+	if (termios->c_cflag & CRTSCTS)
+		valt |= UART_CR_UTX_CTS_EN;
+
+	/* enable TX freerunning mode */
+	valt |= UART_CR_UTX_FRM_EN;
+
+	valt |= UART_CR_UTX_EN;
+	valr |= UART_CR_URX_EN;

Why this is not the very first and only for valt and copied to valr above?

Quoted 10 lines
drivers/tty/serial/bflb_uart.c new file +10 -0
+
+	wrl(port, UART_UTX_CONFIG, valt);
+	wrl(port, UART_URX_CONFIG, valr);
+
+	min = port->uartclk / (UART_CR_UTX_BIT_PRD + 1);
+	baud = uart_get_baud_rate(port, termios, old, min, 4000000);
+
+	val = DIV_ROUND_CLOSEST(port->uartclk, baud) - 1;
+	val &= UART_CR_UTX_BIT_PRD;
+	val |= (val << 16);

drivers/tty/serial/bflb_uart.c line 232

Quoted 10 lines
drivers/tty/serial/bflb_uart.c new file +10 -0
+	wrl(port, UART_BIT_PRD, val);
+
+	uart_update_timeout(port, termios->c_cflag, baud);
+
+	spin_unlock_irqrestore(&port->lock, flags);
+}
+
+static void bflb_uart_rx_chars(struct uart_port *port)
+{
+	unsigned char ch, flag;

Please use u8. (serial_core should too, but that's only on a TODO list yet)

drivers/tty/serial/bflb_uart.c line 233

Quoted 1 line
drivers/tty/serial/bflb_uart.c new file +1 -0
+	unsigned long status;

Long? I think u32.

drivers/tty/serial/bflb_uart.c line 237

Quoted 4 lines
drivers/tty/serial/bflb_uart.c new file +4 -0
+
+	while ((status = rdl(port, UART_FIFO_CONFIG_1)) & UART_RX_FIFO_CNT_MSK) {
+		ch = rdl(port, UART_FIFO_RDATA) & UART_FIFO_RDATA_MSK;
+		flag = TTY_NORMAL;

Drop this flag completely and use the constant below directly.

Quoted 4 lines
drivers/tty/serial/bflb_uart.c new file +4 -0
+		port->icount.rx++;
+
+		if (uart_handle_sysrq_char(port, ch))
+			continue;

drivers/tty/serial/bflb_uart.c line 251

Quoted 10 lines
drivers/tty/serial/bflb_uart.c new file +10 -0
+		uart_insert_char(port, 0, 0, ch, flag);
+	}
+
+	spin_unlock(&port->lock);
+	tty_flip_buffer_push(&port->state->port);
+	spin_lock(&port->lock);
+}
+
+static void bflb_uart_tx_chars(struct uart_port *port)
+{

Are you unable to use the TX helper? If so:
* why?
* use uart_advance_xmit() at least.

Quoted 51 lines
drivers/tty/serial/bflb_uart.c new file +51 -0
+	struct circ_buf *xmit = &port->state->xmit;
+	unsigned int pending, count;
+
+	if (port->x_char) {
+		/* Send special char - probably flow control */
+		wrl(port, UART_FIFO_WDATA, port->x_char);
+		port->x_char = 0;
+		port->icount.tx++;
+		return;
+	}
+
+	pending = uart_circ_chars_pending(xmit);
+	if (pending > 0) {
+		count = (rdl(port, UART_FIFO_CONFIG_1) &
+			 UART_TX_FIFO_CNT_MSK) >> UART_TX_FIFO_CNT_SFT;
+		if (count > pending)
+			count = pending;
+		if (count > 0) {
+			pending -= count;
+			while (count--) {
+				wrl(port, UART_FIFO_WDATA, xmit->buf[xmit->tail]);
+				xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
+				port->icount.tx++;
+			}
+			if (pending < WAKEUP_CHARS)
+				uart_write_wakeup(port);
+		}
+	}
+
+	if (pending == 0)
+		bflb_uart_stop_tx(port);
+}
+
+static irqreturn_t bflb_uart_interrupt(int irq, void *data)
+{
+	struct uart_port *port = data;
+	u32 isr, val;
+
+	isr = rdl(port, UART_INT_STS);
+	wrl(port, UART_INT_CLEAR, isr);
+
+	isr &= ~rdl(port, UART_INT_MASK);
+
+	spin_lock(&port->lock);
+
+	if (isr & UART_URX_FER_INT) {
+		/* RX FIFO error interrupt */
+		val = rdl(port, UART_FIFO_CONFIG_0);
+		if (val & UART_RX_FIFO_OVERFLOW)
+			port->icount.overrun++;
+

drivers/tty/serial/bflb_uart.c line 312

Quoted 10 lines
drivers/tty/serial/bflb_uart.c new file +10 -0
+		val |= UART_RX_FIFO_CLR;
+		wrl(port, UART_FIFO_CONFIG_0, val);
+	}
+
+	if (isr & (UART_URX_FIFO_INT | UART_URX_RTO_INT)) {
+		bflb_uart_rx_chars(port);
+	}
+	if (isr & (UART_UTX_FIFO_INT | UART_UTX_END_INT)) {
+		bflb_uart_tx_chars(port);
+	}

Superfluous braces.

drivers/tty/serial/bflb_uart.c line 316

Quoted 4 lines
drivers/tty/serial/bflb_uart.c new file +4 -0
+
+	spin_unlock(&port->lock);
+
+	return IRQ_RETVAL(isr);

Can it happen that UART_INT_STS is nonzero and UART_INT_MASK is zero? You'd cause "irqX: nobody cared" in that case.

drivers/tty/serial/bflb_uart.c line 325

Quoted 9 lines
drivers/tty/serial/bflb_uart.c new file +9 -0
+}
+
+static void bflb_uart_config_port(struct uart_port *port, int flags)
+{
+	u32 val;
+
+	port->type = PORT_BFLB;
+
+	/* Clear mask, so no surprise interrupts. */

surprising?

Quoted 17 lines
drivers/tty/serial/bflb_uart.c new file +17 -0
+	val = rdl(port, UART_INT_MASK);
+	val |= UART_UTX_END_INT;
+	val |= UART_UTX_FIFO_INT;
+	val |= UART_URX_FIFO_INT;
+	val |= UART_URX_RTO_INT;
+	val |= UART_URX_FER_INT;
+	wrl(port, UART_INT_MASK, val);
+}
+
+static int bflb_uart_startup(struct uart_port *port)
+{
+	unsigned long flags;
+	int ret;
+	u32 val;
+
+	ret = devm_request_irq(port->dev, port->irq, bflb_uart_interrupt,
+			       IRQF_SHARED, port->name, port);

drivers/tty/serial/bflb_uart.c line 352

Quoted 10 lines
drivers/tty/serial/bflb_uart.c new file +10 -0
+	if (ret) {
+		dev_err(port->dev, "fail to request serial irq %d, ret=%d\n",
+			port->irq, ret);
+		return ret;
+	}
+
+	spin_lock_irqsave(&port->lock, flags);
+
+	val = rdl(port, UART_INT_MASK);
+	val |= 0xfff;

Can this be a defined macro too, please?

drivers/tty/serial/bflb_uart.c line 357

Quoted 5 lines
drivers/tty/serial/bflb_uart.c new file +5 -0
+	wrl(port, UART_INT_MASK, val);
+
+	wrl(port, UART_DATA_CONFIG, 0);
+	wrl(port, UART_SW_MODE, 0);
+	wrl(port, UART_URX_RTO_TIMER, 0x4f);

Another magic constant.

drivers/tty/serial/bflb_uart.c line 361

Quoted 4 lines
drivers/tty/serial/bflb_uart.c new file +4 -0
+
+	val = rdl(port, UART_FIFO_CONFIG_1);
+	val &= ~UART_RX_FIFO_TH_MSK;
+	val |= BFLB_UART_RX_FIFO_TH << UART_RX_FIFO_TH_SFT;

FIELD_SET()?

Quoted 19 lines
drivers/tty/serial/bflb_uart.c new file +19 -0
+	wrl(port, UART_FIFO_CONFIG_1, val);
+
+	/* Unmask RX interrupts now */
+	val = rdl(port, UART_INT_MASK);
+	val &= ~UART_URX_FIFO_INT;
+	val &= ~UART_URX_RTO_INT;
+	val &= ~UART_URX_FER_INT;
+	wrl(port, UART_INT_MASK, val);
+	val = rdl(port, UART_UTX_CONFIG);
+	val |= UART_CR_UTX_EN;
+	wrl(port, UART_UTX_CONFIG, val);
+	val = rdl(port, UART_URX_CONFIG);
+	val |= UART_CR_URX_EN;
+	wrl(port, UART_URX_CONFIG, val);
+
+	spin_unlock_irqrestore(&port->lock, flags);
+
+	return 0;
+}

...

drivers/tty/serial/bflb_uart.c line 454

Quoted 12 lines
drivers/tty/serial/bflb_uart.c new file +12 -0
+/*
+ * Interrupts are disabled on entering
+ */
+static void bflb_uart_console_write(struct console *co, const char *s,
+				    u_int count)
+{
+	struct uart_port *port = &bflb_uart_ports[co->index]->port;
+	u32 status, reg, mask;
+
+	/* save then disable interrupts */
+	mask = rdl(port, UART_INT_MASK);
+	reg = -1;

You use 0xfff earlier, now 0xffffffff. Is that OK? Why not use the same constant?

Quoted 7 lines
drivers/tty/serial/bflb_uart.c new file +7 -0
+	wrl(port, UART_INT_MASK, reg);
+
+	/* Make sure that tx is enabled */
+	reg = rdl(port, UART_UTX_CONFIG);
+	reg |= UART_CR_UTX_EN;
+	wrl(port, UART_UTX_CONFIG, reg);
+

drivers/tty/serial/bflb_uart.c line 471

Quoted 10 lines
drivers/tty/serial/bflb_uart.c new file +10 -0
+	uart_console_write(port, s, count, bflb_console_putchar);
+
+	/* wait for TX done */
+	do {
+		status = rdl(port, UART_STATUS);
+	} while ((status & UART_STS_UTX_BUS_BUSY));
+
+	/* restore IRQ mask */
+	wrl(port, UART_INT_MASK, mask);
+}

regards,

Signature · 2 lines
js
suse labs
#2 lore raw

Re: [PATCH 1/7] dt-bindings: serial: add bindings doc for Bouffalolab uart driver

In reply to Jisheng Zhang
Quoted 1 line · Jisheng Zhang

Add bindings doc for Bouffalolab UART Driver

Subject: drop second, redundant "bindings doc".

Quoted 13 lines
---
 .../bindings/serial/bouffalolab,uart.yaml     | 50 +++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/serial/bouffalolab,uart.yaml
Documentation/devicetree/bindings/serial/bouffalolab,uart.yaml new file +0 -0
new file mode 100644
index 000000000000..6cef956d33d2

Documentation/devicetree/bindings/serial/bouffalolab,uart.yaml line 6

Quoted 6 lines
Documentation/devicetree/bindings/serial/bouffalolab,uart.yaml new file +6 -0
@@ -0,0 +1,50 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2022 Jisheng Zhang <[email protected]>
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/serial/bouffalolab,uart.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"

Drop quotes from both lines.

Documentation/devicetree/bindings/serial/bouffalolab,uart.yaml line 18

Quoted 12 lines
Documentation/devicetree/bindings/serial/bouffalolab,uart.yaml new file +12 -0
+
+title: Bouffalolab UART Controller
+
+maintainers:
+  - Jisheng Zhang <[email protected]>
+
+allOf:
+  - $ref: serial.yaml#
+
+properties:
+  compatible:
+    const: bouffalolab,uart

No model number? From bouffalolab there will be only one, exactly UART model? No new models in next 5, 10, 100 years?

Quoted 14 lines
Documentation/devicetree/bindings/serial/bouffalolab,uart.yaml new file +14 -0
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts

Documentation/devicetree/bindings/serial/bouffalolab,uart.yaml line 42

Quoted 10 lines
Documentation/devicetree/bindings/serial/bouffalolab,uart.yaml new file +10 -0
+  - clocks
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    aliases {
+        serial0 = &uart0;
+    };

Drop aliases, not related.

Best regards,
Krzysztof

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

#19 lore raw

Re: [PATCH 5/7] riscv: dts: bouffalolab: add the bl808 SoC base device tree

In reply to Jisheng Zhang
Quoted 14 lines · Jisheng Zhang

Add a baisc dtsi for the bouffalolab bl808 SoC.

---
 arch/riscv/boot/dts/Makefile               |  1 +
 arch/riscv/boot/dts/bouffalolab/bl808.dtsi | 74 ++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 100644 arch/riscv/boot/dts/bouffalolab/bl808.dtsi
arch/riscv/boot/dts/Makefile +0 -0
index ff174996cdfd..b525467152b2 100644

arch/riscv/boot/dts/Makefile line 2

Quoted 2 lines
arch/riscv/boot/dts/Makefile +1 -0
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
+subdir-y += bouffalolab

Nothing to build there, so not yet.

Best regards,
Krzysztof

#24 lore raw

Re: [PATCH 6/7] riscv: dts: bouffalolab: add Sipeed M1S dock devicetree

In reply to Jisheng Zhang
Quoted 27 lines · Jisheng Zhang

Sipeed manufactures a M1S system-on-module and dock board, add basic support for them.

---
 arch/riscv/boot/dts/bouffalolab/Makefile      |  2 ++
 .../boot/dts/bouffalolab/bl808-sipeed-m1s.dts | 30 +++++++++++++++++++
 2 files changed, 32 insertions(+)
 create mode 100644 arch/riscv/boot/dts/bouffalolab/Makefile
 create mode 100644 arch/riscv/boot/dts/bouffalolab/bl808-sipeed-m1s.dts
arch/riscv/boot/dts/bouffalolab/Makefile new file +2 -0
new file mode 100644
index 000000000000..42e17e1a97bd
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+dtb-$(CONFIG_SOC_BOUFFALOLAB) += bl808-sipeed-m1s.dtb
arch/riscv/boot/dts/bouffalolab/bl808-sipeed-m1s.dts new file +2 -0
new file mode 100644
index 000000000000..64421fb2ad67
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: (GPL-2.0+ or MIT)
+/*

arch/riscv/boot/dts/bouffalolab/bl808-sipeed-m1s.dts line 12

Quoted 10 lines
arch/riscv/boot/dts/bouffalolab/bl808-sipeed-m1s.dts new file +10 -0
+ * Copyright (C) 2022 Jisheng Zhang <[email protected]>
+ */
+
+/dts-v1/;
+
+#include "bl808.dtsi"
+
+/ {
+	model = "Sipeed M1S";
+	compatible = "sipeed,m1s", "bouffalolab,bl808";

Missing bindings.

Best regards,
Krzysztof

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

#26 lore raw

Re: [PATCH 7/7] MAINTAINERS: add myself as Bouffalolab SoC entry maintainer

In reply to Jisheng Zhang
Quoted 1 line · Jisheng Zhang

I want to maintain this Bouffalolab riscv SoC entry from now on.

Use 3rd person narrative, so:
1. Subject: MAINTAINERS: riscv: add entry for Bouffalolab SoC
2. Commit: Add Jisheng Zhang as Bouffalolab SoC maintainer.

Quoted 13 lines
---
 MAINTAINERS | 6 ++++++
 1 file changed, 6 insertions(+)
MAINTAINERS +0 -0
index 92451834b940..3564b27d7da4 100644
@@ -17738,6 +17738,12 @@ F:	arch/riscv/
 N:	riscv
 K:	riscv

MAINTAINERS F: arch/riscv/ · line 17749

Quoted 10 lines
MAINTAINERS +6 -0
 
+RISC-V BOUFFALOLAB SOC SUPPORT
+M:	Jisheng Zhang <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	arch/riscv/boot/dts/bouffalolab/
+
 RISC-V MICROCHIP FPGA SUPPORT
 M:	Conor Dooley <[email protected]>
 M:	Daire McNamara <[email protected]>

Best regards,
Krzysztof

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

#18 lore raw

Re: [PATCH 5/7] riscv: dts: bouffalolab: add the bl808 SoC base device tree

In reply to Icenowy Zheng
Quoted 81 lines · Icenowy Zheng
Quoted 70 lines · 在 2022-11-20星期日的 15:57 +0100,Emil Renner Berthing写道:
Quoted 68 lines · Jisheng Zhang

Add a baisc dtsi for the bouffalolab bl808 SoC.

---
 arch/riscv/boot/dts/Makefile               |  1 +
 arch/riscv/boot/dts/bouffalolab/bl808.dtsi | 74
++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 100644 arch/riscv/boot/dts/bouffalolab/bl808.dtsi
arch/riscv/boot/dts/Makefile +1 -0
index ff174996cdfd..b525467152b2 100644
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
+subdir-y += bouffalolab
 subdir-y += sifive
 subdir-y += starfive
 subdir-$(CONFIG_SOC_CANAAN_K210_DTB_BUILTIN) += canaan
arch/riscv/boot/dts/bouffalolab/bl808.dtsi new file +39 -0
new file mode 100644
index 000000000000..c98ebb14ee10
@@ -0,0 +1,74 @@
+// SPDX-License-Identifier: (GPL-2.0+ or MIT)
+/*
+ * Copyright (C) 2022 Jisheng Zhang <[email protected]>
+ */
+
+#include <dt-bindings/interrupt-controller/irq.h>
+
+/ {
+       compatible = "bouffalolab,bl808";
+       #address-cells = <1>;
+       #size-cells = <1>;
+
+       cpus {
+               timebase-frequency = <1000000>;
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               cpu0: cpu@0 {
+                       compatible = "thead,c906", "riscv";
+                       device_type = "cpu";
+                       reg = <0>;
+                       d-cache-block-size = <64>;
+                       d-cache-sets = <256>;
+                       d-cache-size = <32768>;
+                       i-cache-block-size = <64>;
+                       i-cache-sets = <128>;
+                       i-cache-size = <32768>;
+                       mmu-type = "riscv,sv39";
+                       riscv,isa = "rv64imafdc";
+
+                       cpu0_intc: interrupt-controller {
+                               compatible = "riscv,cpu-intc";
+                               interrupt-controller;
+                               #address-cells = <0>;
+                               #interrupt-cells = <1>;
+                       };
+               };
+       };
+
Quoted 8 lines

arch/riscv/boot/dts/bouffalolab/bl808.dtsi line 42

Quoted 3 lines
arch/riscv/boot/dts/bouffalolab/bl808.dtsi new file +3 -0
+       xtal: xtal-clk {
+               compatible = "fixed-clock";
+               clock-frequency = <40000000>;

This was discussed many times before, but I think the conclusion was that the frequency is a property of the crystal on the board, so this should be 0 in the SoC dtsi, and then overwritten in the board device tree.

Quoted 2 lines

But many chips just specify an accepted frequency in their datasheet, and using a frequency other than this is undefined behavior.

Yes, this was the argument in previous discussions, but the conclusion was still that it should go in the board dts. To be clear I'm just summing up the conclusion from previous discussions about this, and have no strong opinion other than we should do the same everywhere.

Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
arch/riscv/boot/dts/bouffalolab/bl808.dtsi new file +24 -0
+               clock-output-names = "xtal";
+               #clock-cells = <0>;
+       };
+
+       soc {
+               compatible = "simple-bus";
+               ranges;
+               interrupt-parent = <&plic>;
+               dma-noncoherent;
+               #address-cells = <1>;
+               #size-cells = <1>;
+
+               uart0: serial@30002000 {
+                       compatible = "bouffalolab,uart";
+                       reg = <0x30002000 0x1000>;
+                       interrupts = <20 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&xtal>;
+                       status = "disabled";
+               };
+
+               plic: interrupt-controller@e0000000 {
+                       compatible = "thead,c900-plic";
+                       reg = <0xe0000000 0x4000000>;
+                       interrupts-extended = <&cpu0_intc

0xffffffff>,

arch/riscv/boot/dts/bouffalolab/bl808.dtsi new file +8 -1
+                                             <&cpu0_intc 9>;
+                       interrupt-controller;
+                       #address-cells = <0>;
+                       #interrupt-cells = <2>;
+                       riscv,ndev = <64>;
+               };
+       };
+};
--

2.37.2

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

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

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

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

#6 lore raw

Re: [PATCH 2/7] serial: bflb_uart: add Bouffalolab UART Driver

In reply to Jisheng Zhang
Quoted 25 lines · Jisheng Zhang

Add the driver for Bouffalolab UART IP which is found in Bouffalolab SoCs such as bl808.

UART driver probe will create path named "/dev/ttySx".

drivers/tty/serial/Makefile +1 -0
index 238a9557b487..8509cdc11d87 100644
@@ -25,6 +25,7 @@ obj-$(CONFIG_SERIAL_8250) += 8250/
 
 obj-$(CONFIG_SERIAL_AMBA_PL010) += amba-pl010.o
 obj-$(CONFIG_SERIAL_AMBA_PL011) += amba-pl011.o
+obj-$(CONFIG_SERIAL_BFLB) += bflb_uart.o
 obj-$(CONFIG_SERIAL_CLPS711X) += clps711x.o
 obj-$(CONFIG_SERIAL_PXA_NON8250) += pxa.o
 obj-$(CONFIG_SERIAL_SA1100) += sa1100.o
drivers/tty/serial/bflb_uart.c new file +0 -0
new file mode 100644
index 000000000000..65f98ccf8fa8

drivers/tty/serial/bflb_uart.c line 5

Quoted 5 lines
drivers/tty/serial/bflb_uart.c new file +5 -0
@@ -0,0 +1,659 @@
+#define UART_FIFO_CONFIG_1		(0x84)
+#define  UART_TX_FIFO_CNT_SFT		0
+#define  UART_TX_FIFO_CNT_MSK		GENMASK(5, 0)
+#define  UART_RX_FIFO_CNT_MSK		GENMASK(13, 8)
+#define  UART_TX_FIFO_TH_SFT		16

Use FIELD_PREP() instead of adding a separate *_SFT define.

Quoted 5 lines
drivers/tty/serial/bflb_uart.c new file +5 -0
+#define  UART_TX_FIFO_TH_MSK		GENMASK(20, 16)
+#define  UART_RX_FIFO_TH_SFT		24
+#define  UART_RX_FIFO_TH_MSK		GENMASK(28, 24)
+#define UART_FIFO_WDATA			0x88
+#define UART_FIFO_RDATA			0x8c

drivers/tty/serial/bflb_uart.c line 163

Quoted 10 lines
drivers/tty/serial/bflb_uart.c new file +8 -0
+#define  UART_FIFO_RDATA_MSK		GENMASK(7, 0)
 
 
+	val = rdl(port, UART_URX_CONFIG);
+	val &= ~UART_CR_URX_EN;
+	wrl(port, UART_URX_CONFIG, val);
+
+	val = rdl(port, UART_INT_MASK);
+	val |= UART_URX_FIFO_INT | UART_URX_RTO_INT |
+	       UART_URX_FER_INT;

Fits to single line.

drivers/tty/serial/bflb_uart.c line 331

Quoted 9 lines
drivers/tty/serial/bflb_uart.c new file +9 -0
+	port->type = PORT_BFLB;
+
+	/* Clear mask, so no surprise interrupts. */
+	val = rdl(port, UART_INT_MASK);
+	val |= UART_UTX_END_INT;
+	val |= UART_UTX_FIFO_INT;
+	val |= UART_URX_FIFO_INT;
+	val |= UART_URX_RTO_INT;
+	val |= UART_URX_FER_INT;

Why to split it to this many lines?

drivers/tty/serial/bflb_uart.c line 352

Quoted 4 lines
drivers/tty/serial/bflb_uart.c new file +4 -0
+	spin_lock_irqsave(&port->lock, flags);
+
+	val = rdl(port, UART_INT_MASK);
+	val |= 0xfff;

In most of the other places, the bits used with UART_INT_MASK are named, but for some reason you don't do it here and the bits extend beyond the ones which are defined with name.

drivers/tty/serial/bflb_uart.c line 357

Quoted 5 lines
drivers/tty/serial/bflb_uart.c new file +5 -0
+	wrl(port, UART_INT_MASK, val);
+
+	wrl(port, UART_DATA_CONFIG, 0);
+	wrl(port, UART_SW_MODE, 0);
+	wrl(port, UART_URX_RTO_TIMER, 0x4f);

FIELD_PREP(UART_CR_URX_RTO_VALUE_MSK, 0x4f)? It would document what field is written explicitly.

drivers/tty/serial/bflb_uart.c line 368

Quoted 11 lines
drivers/tty/serial/bflb_uart.c new file +11 -0
+
+	val = rdl(port, UART_FIFO_CONFIG_1);
+	val &= ~UART_RX_FIFO_TH_MSK;
+	val |= BFLB_UART_RX_FIFO_TH << UART_RX_FIFO_TH_SFT;
+	wrl(port, UART_FIFO_CONFIG_1, val);
+
+	/* Unmask RX interrupts now */
+	val = rdl(port, UART_INT_MASK);
+	val &= ~UART_URX_FIFO_INT;
+	val &= ~UART_URX_RTO_INT;
+	val &= ~UART_URX_FER_INT;

Combine to single line.

drivers/tty/serial/bflb_uart.c line 407

Quoted 9 lines
drivers/tty/serial/bflb_uart.c new file +9 -0
+static int bflb_uart_request_port(struct uart_port *port)
+{
+	/* UARTs always present */
+	return 0;
+}
+static void bflb_uart_release_port(struct uart_port *port)
+{
+	/* Nothing to release... */
+}

Both release_port and request_port are NULL checked by the caller, there's no need to provide and empty one.

Quoted 17 lines
drivers/tty/serial/bflb_uart.c new file +17 -0
+static const struct uart_ops bflb_uart_ops = {
+	.tx_empty = bflb_uart_tx_empty,
+	.get_mctrl = bflb_uart_get_mctrl,
+	.set_mctrl = bflb_uart_set_mctrl,
+	.start_tx = bflb_uart_start_tx,
+	.stop_tx = bflb_uart_stop_tx,
+	.stop_rx = bflb_uart_stop_rx,
+	.break_ctl = bflb_uart_break_ctl,
+	.startup = bflb_uart_startup,
+	.shutdown = bflb_uart_shutdown,
+	.set_termios = bflb_uart_set_termios,
+	.type = bflb_uart_type,
+	.request_port = bflb_uart_request_port,
+	.release_port = bflb_uart_release_port,
+	.config_port = bflb_uart_config_port,
+	.verify_port = bflb_uart_verify_port,
+};

drivers/tty/serial/bflb_uart.c line 454

Quoted 10 lines
drivers/tty/serial/bflb_uart.c new file +9 -0
 
+static void bflb_uart_console_write(struct console *co, const char *s,
+				    u_int count)
+{
+	struct uart_port *port = &bflb_uart_ports[co->index]->port;
+	u32 status, reg, mask;
+
+	/* save then disable interrupts */
+	mask = rdl(port, UART_INT_MASK);
+	reg = -1;

Use ~0 instead. Why -1 here and 0xfff in the other place?

Signature · 6 lines
 i.

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
maintainer
#3 lore raw

Re: [PATCH 1/7] dt-bindings: serial: add bindings doc for Bouffalolab uart driver

In reply to Jisheng Zhang
Quoted 22 lines · Jisheng Zhang

Add bindings doc for Bouffalolab UART Driver

---
 .../bindings/serial/bouffalolab,uart.yaml     | 50 +++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/serial/bouffalolab,uart.yaml
Documentation/devicetree/bindings/serial/bouffalolab,uart.yaml new file +8 -0
new file mode 100644
index 000000000000..6cef956d33d2
@@ -0,0 +1,50 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2022 Jisheng Zhang <[email protected]>
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/serial/bouffalolab,uart.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Bouffalolab UART Controller

Documentation/devicetree/bindings/serial/bouffalolab,uart.yaml line 18

Quoted 10 lines
Documentation/devicetree/bindings/serial/bouffalolab,uart.yaml new file +10 -0
+
+maintainers:
+  - Jisheng Zhang <[email protected]>
+
+allOf:
+  - $ref: serial.yaml#
+
+properties:
+  compatible:
+    const: bouffalolab,uart

'bouffalolab' needs to be documented in vendor-prefixes.yaml.

Quoted 12 lines
Documentation/devicetree/bindings/serial/bouffalolab,uart.yaml new file +12 -0
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+required:
+  - compatible

Documentation/devicetree/bindings/serial/bouffalolab,uart.yaml line 40

Quoted 10 lines
Documentation/devicetree/bindings/serial/bouffalolab,uart.yaml new file +10 -0
+  - reg
+  - interrupts
+  - clocks
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    aliases {

Drop, not relevant to the binding.

Quoted 14 lines
Documentation/devicetree/bindings/serial/bouffalolab,uart.yaml new file +10 -0
+        serial0 = &uart0;
+    };
+
+    uart0: serial@30002000 {
+        compatible = "bouffalolab,uart";
+        reg = <0x30002000 0x1000>;
+        interrupts = <53 IRQ_TYPE_LEVEL_HIGH>;
+        clocks = <&xtal>;
+    };
+...
Signature · 1 line
2.37.2