Skip to contentSkip to conversation

serial: 8250: Add driver for Broadcom UART

PATCH Superseded Al Cooper 4 participants 8 messages Nov 20, 2020 – Nov 26, 2020

Subsystems (4)

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Al Cooper

author maintainer
#0 lore raw

cover serial: 8250: Add driver for Broadcom UART

Add UART driver for the new Broadcom 8250 based STB UART. The new UART is backward compatible with the standard 8250, but has some additional features. The new features include a high accuracy baud rate clock system and DMA support.

Al Cooper (2):
dt-bindings: Add support for the Broadcom UART driver
serial: 8250: Add new 8250-core based Broadcom STB driver

Jim Quinlan (1):
serial: 8250: of: Check for CONFIG_SERIAL_8250_BCM7271

 .../bindings/serial/brcm,bcm7271-uart.yaml    |   94 ++
 MAINTAINERS                                   |    8 +
 drivers/tty/serial/8250/8250_bcm7271.c        | 1131 +++++++++++++++++
 drivers/tty/serial/8250/8250_of.c             |    4 +
 drivers/tty/serial/8250/Kconfig               |   11 +
 drivers/tty/serial/8250/Makefile              |    1 +
 drivers/tty/serial/8250/bcm7271_uart.h        |  158 +++
 7 files changed, 1407 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/serial/brcm,bcm7271-uart.yaml
 create mode 100644 drivers/tty/serial/8250/8250_bcm7271.c
 create mode 100644 drivers/tty/serial/8250/bcm7271_uart.h
Signature · 1 line
2.17.1
author maintainer
#1 lore raw

PATCH 1/3 serial: 8250: of: Check for CONFIG_SERIAL_8250_BCM7271

From: Jim Quinlan <[email protected]>

This commit has of_platform_serial_probe() check specifically for the "brcm,bcm7271-uart" and whether its companion driver is enabled. If it is the case, and the clock provider is not ready, we want to make sure that when the 8250_bcm7271.c driver returns EPROBE_DEFER, we are not getting the UART registered via 8250_of.c.

---
 drivers/tty/serial/8250/8250_of.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/tty/serial/8250/8250_of.c +4 -0
index 65e9045dafe6..aa458f3c6644 100644
@@ -192,6 +192,10 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
 	u32 tx_threshold;
 	int ret;
 
+	if (IS_ENABLED(CONFIG_SERIAL_8250_BCM7271) &&
+	    of_device_is_compatible(ofdev->dev.of_node, "brcm,bcm7271-uart"))
+		return -ENODEV;
+
 	port_type = (unsigned long)of_device_get_match_data(&ofdev->dev);
 	if (port_type == PORT_UNKNOWN)
 		return -EINVAL;
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH 1/3] serial: 8250: of: Check for CONFIG_SERIAL_8250_BCM7271

Quoted 19 lines · Al Cooper

From: Jim Quinlan <[email protected]>

This commit has of_platform_serial_probe() check specifically for the "brcm,bcm7271-uart" and whether its companion driver is enabled. If it is the case, and the clock provider is not ready, we want to make sure that when the 8250_bcm7271.c driver returns EPROBE_DEFER, we are not getting the UART registered via 8250_of.c.

---
 drivers/tty/serial/8250/8250_of.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/tty/serial/8250/8250_of.c +0 -0
index 65e9045dafe6..aa458f3c6644 100644

drivers/tty/serial/8250/8250_of.c static int of_platform_serial_probe(struct platform_device *ofdev) · line 198

Quoted 7 lines
drivers/tty/serial/8250/8250_of.c +4 -0
@@ -192,6 +192,10 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
        u32 tx_threshold;
        int ret;
 
+       if (IS_ENABLED(CONFIG_SERIAL_8250_BCM7271) &&
+           of_device_is_compatible(ofdev->dev.of_node, "brcm,bcm7271-uart"))
+               return -ENODEV;
+

NOTE: this commit is a "strawman" commit, and I will not be surprised if it gets quickly NAKed. We have a new idea on how to solve this issue, and if that not is not viable, will ask for a dialog on this problem either in this thread or through a separate RFC.

Regards,
Jim Quinlan
Broadcom STB

Quoted 6 lines
drivers/tty/serial/8250/8250_of.c +0 -1
        port_type = (unsigned long)of_device_get_match_data(&ofdev->dev);
        if (port_type == PORT_UNKNOWN)
                return -EINVAL;
--

2.17.1

#3 lore raw

Re: [PATCH 1/3] serial: 8250: of: Check for CONFIG_SERIAL_8250_BCM7271

Quoted 24 lines · Jim Quinlan
Quoted 22 lines · Al Cooper

From: Jim Quinlan <[email protected]>

This commit has of_platform_serial_probe() check specifically for the "brcm,bcm7271-uart" and whether its companion driver is enabled. If it is the case, and the clock provider is not ready, we want to make sure that when the 8250_bcm7271.c driver returns EPROBE_DEFER, we are not getting the UART registered via 8250_of.c.

---
 drivers/tty/serial/8250/8250_of.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/tty/serial/8250/8250_of.c +0 -0
index 65e9045dafe6..aa458f3c6644 100644
@@ -192,6 +192,10 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
        u32 tx_threshold;
        int ret;
 
Quoted 8 lines

drivers/tty/serial/8250/8250_of.c static int of_platform_serial_probe(struct platform_device *ofdev) · line 198

Quoted 4 lines
drivers/tty/serial/8250/8250_of.c +4 -0
+       if (IS_ENABLED(CONFIG_SERIAL_8250_BCM7271) &&
+           of_device_is_compatible(ofdev->dev.of_node, "brcm,bcm7271-uart"))
+               return -ENODEV;
+

NOTE: this commit is a "strawman" commit, and I will not be surprised if it gets quickly NAKed. We have a new idea on how to solve this issue, and if that not is not viable, will ask for a dialog on this problem either in this thread or through a separate RFC.

This commit is no longer needed as part of this patchset; we have addressed the problem elsewhere. Sorry about the noise.

Quoted 14 lines

Regards,
Jim Quinlan
Broadcom STB

Quoted 6 lines
drivers/tty/serial/8250/8250_of.c +0 -1
        port_type = (unsigned long)of_device_get_match_data(&ofdev->dev);
        if (port_type == PORT_UNKNOWN)
                return -EINVAL;
--

2.17.1

#4 lore raw

Re: [PATCH 1/3] serial: 8250: of: Check for CONFIG_SERIAL_8250_BCM7271

In reply to Al Cooper
Quoted 10 lines · Al Cooper

From: Jim Quinlan <[email protected]>

This commit has of_platform_serial_probe() check specifically for the "brcm,bcm7271-uart" and whether its companion driver is enabled. If it is the case, and the clock provider is not ready, we want to make sure that when the 8250_bcm7271.c driver returns EPROBE_DEFER, we are not getting the UART registered via 8250_of.c.

---

When forwarding on patches from others, always include your
signed-off-by: as well, to ensure that you have reviewed this and are ok with it. I can't take this as-is, sorry.

And why did you include linux-usb@vger for this patch series?

thanks,

greg k-h

author maintainer
#5 lore raw

PATCH 2/3 dt-bindings: Add support for the Broadcom UART driver

In reply to Al Cooper

Add DT bindings for the Broadcom 8250 based UART driver. This UART is based on an 8250 but adds additional functionality. The additional features include the ability to use DMA for transfers and a baud rate clock system that is more accurate at high baud rates. This UART is backward compatible with the standard 8250 UART.

---
 .../bindings/serial/brcm,bcm7271-uart.yaml    | 94 +++++++++++++++++++
 1 file changed, 94 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/serial/brcm,bcm7271-uart.yaml
Documentation/devicetree/bindings/serial/brcm,bcm7271-uart.yaml new file +94 -0
new file mode 100644
index 000000000000..76aff2c21394
@@ -0,0 +1,94 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/serial/brcm,bcm7271-uart.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom 8250 based serial port devicetree bindings
+
+maintainers:
+  - Al Cooper <[email protected]>
+
+description: |+
+  The Broadcom UART is based on the basic 8250 UART but with
+  enhancements for more accurate high speed baud rates and support
+  for DMA.
+
+properties:
+  $nodename:
+    pattern: "^serial@[0-9a-f]+$"
+
+  compatible:
+    items:
+      - enum:
+          - brcm,bcm7271-uart
+          - brcm,bcm7278-uart
+  reg:
+    minItems: 1
+    maxItems: 5
+
+  reg-names:
+    description: The UART register block and optionally the DMA register blocks.
+    oneOf:
+      - items:
+          - const: uart
+      - items:
+          - const: uart
+          - const: dma_arb
+          - const: dma_rx
+          - const: dma_tx
+          - const: dma_intr2
+
+  clocks:
+    minItems: 1
+
+  clock-names:
+    const: sw_baud
+
+  interrupts:
+    minItems: 1
+    maxItems: 2
+
+  interrupt-names:
+    description: The UART interrupt and optionally the DMA interrupt.
+    oneOf:
+      - items:
+          - const: uart
+      - items:
+          - const: uart
+          - const: dma
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - clocks
+  - clock-names
+  - interrupts
+  - interrupt-names
+
+examples:
+  - |
+    serial@840d000 {
+        compatible = "brcm,bcm7271-uart";
+        reg = <0x840d000 0x20>;
+        reg-names = "uart";
+        interrupts = <0x0 0x62 0x4>;
+        interrupt-names = "uart";
+        clocks = <&scmi_clk 190>;
+        clock-names = "sw_baud";
+    };
+
+    serial@840e000 {
+        compatible = "brcm,bcm7271-uart";
+        reg = <0x840e000 0x20>,
+              <0x840e080 0x8>,
+              <0x840e100 0xa8>,
+              <0x840e200 0x4c>,
+              <0x840e300 0x30>;
+        reg-names = "uart", "dma_arb", "dma_rx", "dma_tx", "dma_intr2";
+        interrupts = <0x0 0x62 0x4>, <0x0 0x75 0x4>;
+        interrupt-names = "uart", "dma";
+        clocks = <&scmi_clk 190>;
+        clock-names = "sw_baud";
+    };
Signature · 1 line
2.17.1
maintainer
#6 lore raw

Re: [PATCH 2/3] dt-bindings: Add support for the Broadcom UART driver

Quoted 6 lines · Al Cooper

Add DT bindings for the Broadcom 8250 based UART driver. This UART is based on an 8250 but adds additional functionality. The additional features include the ability to use DMA for transfers and a baud rate clock system that is more accurate at high baud rates. This UART is backward compatible with the standard 8250 UART.

Quoted 6 lines
---
 .../bindings/serial/brcm,bcm7271-uart.yaml    | 94 +++++++++++++++++++
 1 file changed, 94 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/serial/brcm,bcm7271-uart.yaml

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/serial/brcm,bcm7271-uart.yaml: 'additionalProperties' is a required property /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/serial/brcm,bcm7271-uart.yaml: ignoring, error in schema:
warning: no schema found in file: ./Documentation/devicetree/bindings/serial/brcm,bcm7271-uart.yaml

See https://patchwork.ozlabs.org/patch/1404090

The base for the patch is generally the last rc1. Any dependencies should be noted.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit.

author maintainer
#7 lore raw

PATCH 3/3 serial: 8250: Add new 8250-core based Broadcom STB driver

In reply to Al Cooper

Add a UART driver for the new Broadcom 8250 based STB UART. The new UART is backward compatible with the standard 8250, but has some additional features. The new features include a high accuracy baud rate clock system and DMA support.

The driver will use the new optional BAUD MUX clock to select the best one of the four master clocks (81MHz, 108MHz, 64MHz and 48MHz) to feed the baud rate selection logic for any requested baud rate. This allows for more accurate BAUD rates when high speed baud rates are selected.

The driver will use the new UART DMA hardware if the UART DMA registers are specified in Device Tree "reg" property. The DMA functionality can be disabled on kernel boot with the argument:
"8250_bcm7271.disable_dma=Y".

The driver also set the UPSTAT_AUTOCTS flag when hardware flow control is enabled. This flag is needed for UARTs that don't assert a CTS changed interrupt when CTS changes and AFE (Hardware Flow Control) is enabled.

The driver also contains a workaround for a bug in the Synopsis 8250 core. The problem is that at high baud rates, the RX partial FIFO timeout interrupt can occur but there is no RX data (DR not set in the LSR register). In this case the driver will not read the Receive Buffer Register, which clears the interrupt, and the system will get continuous UART interrupts until the next RX character arrives. The fix originally suggested by Synopsis was to read the Receive Buffer Register and discard the character when the DR bit in the LSR was not set, to clear the interrupt. The problem was that occasionally a character would arrive just after the DR bit check and a valid character would be discarded. The fix that was added will clear receive interrupts to stop the interrupt, deassert RTS to insure that no new data can arrive, wait for 1.5 character times for the sender to react to RTS and then check for data and either do a dummy read or a valid read. Sysfs error counters were also added and were used to help create test software that would cause the error condition. The counters can be found at:
/sys/devices/platform/rdb/*serial/rx_bad_timeout_late_char /sys/devices/platform/rdb/*serial/rx_bad_timeout_no_char

---
 MAINTAINERS                            |    8 +
 drivers/tty/serial/8250/8250_bcm7271.c | 1131 ++++++++++++++++++++++++
 drivers/tty/serial/8250/Kconfig        |   11 +
 drivers/tty/serial/8250/Makefile       |    1 +
 drivers/tty/serial/8250/bcm7271_uart.h |  158 ++++
 5 files changed, 1309 insertions(+)
 create mode 100644 drivers/tty/serial/8250/8250_bcm7271.c
 create mode 100644 drivers/tty/serial/8250/bcm7271_uart.h
MAINTAINERS +8 -0
index 5cc595ac7b28..58f88d630d4e 100644
@@ -3551,6 +3551,14 @@ S:	Supported
 F:	Documentation/devicetree/bindings/i2c/brcm,brcmstb-i2c.yaml
 F:	drivers/i2c/busses/i2c-brcmstb.c
 
+BROADCOM BRCMSTB UART DRIVER
+M:	Al Cooper <[email protected]>
+L:	[email protected]
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/serial/brcm,bcm7271-uart.yaml
+F:	drivers/tty/serial/8250/8250_bcm7271.c
+
 BROADCOM BRCMSTB USB EHCI DRIVER
 M:	Al Cooper <[email protected]>
 L:	[email protected]
drivers/tty/serial/8250/8250_bcm7271.c new file +1131 -0

1,131 lines not on this page · raw message

drivers/tty/serial/8250/Kconfig +11 -0
index 603137da4736..436a686bf7fd 100644
@@ -501,6 +501,7 @@ config SERIAL_8250_PXA
 	  applicable to both devicetree and legacy boards, and early console is
 	  part of its support.
 
+
 config SERIAL_8250_TEGRA
 	tristate "8250 support for Tegra serial ports"
 	default SERIAL_8250
@@ -510,6 +511,16 @@ config SERIAL_8250_TEGRA
 	  Select this option if you have machine with an NVIDIA Tegra SoC and
 	  wish to enable 8250 serial driver for the Tegra serial interfaces.
 
+config SERIAL_8250_BCM7271
+	bool "Broadcom 8250 based serial port"
+	depends on SERIAL_8250 && (ARCH_BRCMSTB || COMPILE_TEST)
+	default ARCH_BRCMSTB
+	help
+	  If you have a Broadcom STB based board and want to use the
+	  enhanced features of the Broadcom 8250 based serial port,
+	  including DMA support and high accuracy BAUD rates, say
+	  Y to this option. If unsure, say N.
+
 config SERIAL_OF_PLATFORM
 	tristate "Devicetree based probing for 8250 ports"
 	depends on SERIAL_8250 && OF
drivers/tty/serial/8250/Makefile +1 -0
index a8bfb654d490..b9bcd73c8997 100644
@@ -38,6 +38,7 @@ obj-$(CONFIG_SERIAL_8250_LPSS)		+= 8250_lpss.o
 obj-$(CONFIG_SERIAL_8250_MID)		+= 8250_mid.o
 obj-$(CONFIG_SERIAL_8250_PXA)		+= 8250_pxa.o
 obj-$(CONFIG_SERIAL_8250_TEGRA)		+= 8250_tegra.o
+obj-$(CONFIG_SERIAL_8250_BCM7271)	+= 8250_bcm7271.o
 obj-$(CONFIG_SERIAL_OF_PLATFORM)	+= 8250_of.o
 
 CFLAGS_8250_ingenic.o += -I$(srctree)/scripts/dtc/libfdt
drivers/tty/serial/8250/bcm7271_uart.h new file +158 -0

158 lines not on this page · raw message

Signature · 1 line
2.17.1