serial: 8250: Add driver for Broadcom UART
Al Cooper
maintainerv2 cover serial: 8250: Add driver for Broadcom UART
v2 - remove the patch that modified 8250_of.c to keep it from
registering before this driver when this driver was deferred as it was getting it's "clocks". This was fixed by changing the Device Tree entry to remove "clock-frequency". This results in both drivers getting "clocks" and getting same deferral.
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
.../bindings/serial/brcm,bcm7271-uart.yaml | 94 ++ 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 +++ 6 files changed, 1403 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
Al Cooper
maintainerPATCH v2 1/2 dt-bindings: Add support for the Broadcom UART driver
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
@@ -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
Rob Herring
maintainerRe: [PATCH v2 1/2] 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
Signed-off-by Al Cooper <[email protected]>--- .../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/1427364
This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.
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.
Al Cooper
maintainerPATCH v2 2/2 serial: 8250: Add new 8250-core based Broadcom STB driver
In reply to Al CooperAdd 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
@@ -3581,6 +3581,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
@@ -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
@@ -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
Greg Kroah-Hartman
maintainerRe: [PATCH v2 2/2] serial: 8250: Add new 8250-core based Broadcom STB driver
Quoted 10 lines · 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.
Quoted 4 lines
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".
Shouldn't that be on a per-device basis, and not a per-driver basis?
And why would you want to disable this, if you have support for this in the DT? Why not just rely on the DT setting?
thanks,
greg k-h
Re: [PATCH v2 2/2] serial: 8250: Add new 8250-core based Broadcom STB driver
Quoted 12 lines · Greg Kroah-Hartman
Quoted 10 lines · 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.
Quoted 6 lines
Quoted 4 lines
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".Shouldn't that be on a per-device basis, and not a per-driver basis?
There is only one instance of the UART DMA hardware and it gets muxed to just one of the possible UARTS.
Quoted 3 lines
And why would you want to disable this, if you have support for this in the DT? Why not just rely on the DT setting?
The DMA feature is used when the UART is connected to a Bluetooth controller and the BAUD rate is typically 2-3Mbs. The ability to easily disable DMA is very useful when debugging BT communication problems in the field. DT settings could also be used to disable DMA, but knowing the correct modifications to the "reg" and "reg-names" properties is a lot more complicated.
Thanks
Al
Quoted 4 lines
thanks,
greg k-h
Greg Kroah-Hartman
maintainerRe: [PATCH v2 2/2] serial: 8250: Add new 8250-core based Broadcom STB driver
Quoted 19 lines · Al Cooper
Quoted 17 lines · Greg Kroah-Hartman
Quoted 14 lines · 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".
Quoted 4 lines
Quoted 1 line
Shouldn't that be on a per-device basis, and not a per-driver basis?
There is only one instance of the UART DMA hardware and it gets muxed to just one of the possible UARTS.
But the driver doesn't know/care about that, it binds to any device that matches it. per-module/driver flags are not a good idea.
Quoted 9 lines
Quoted 2 lines
And why would you want to disable this, if you have support for this in the DT? Why not just rely on the DT setting?
The DMA feature is used when the UART is connected to a Bluetooth controller and the BAUD rate is typically 2-3Mbs. The ability to easily disable DMA is very useful when debugging BT communication problems in the field. DT settings could also be used to disable DMA, but knowing the correct modifications to the "reg" and "reg-names" properties is a lot more complicated.
So this is a debug-only option? If so, why not just make it a debugfs file then? No need to clutter up a module parameter for this mess.
thanks,
greg k-h
Re: [PATCH v2 2/2] serial: 8250: Add new 8250-core based Broadcom STB driver
In reply to Al CooperQuoted 32 lines · 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_AUTOCTSflag 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
Quoted 8 lines
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
Brief looking into the code raises several questions:
- is it driver from the last decade?
- why it's not using what kernel provides?
- we have a lot of nice helpers:
- DMA Engine API
- BIT() and GENMASK() macros
- tons of different helpers like regmap API (if you wish to dump
registers via debugfs)
Can you shrink this driver by 20-30% (I truly believe it's possible) and split DMA driver to drivers/dma (which may already have something similar there)?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 2/2] serial: 8250: Add new 8250-core based Broadcom STB driver
Quoted 42 lines · Andy Shevchenko
Quoted 32 lines · 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_AUTOCTSflag 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
Quoted 8 lines
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
Quoted 2 lines
Brief looking into the code raises several questions:
- is it driver from the last decade?
Work on this driver started back in 2018, that was indeed the last decade.
Quoted 3 lines
- why it's not using what kernel provides?
- we have a lot of nice helpers:
- DMA Engine API
Not sure this makes sense, given that the DMA hardware that was added to this UART block is only used by the UART block and no other pieces of HW in the system, nor will they ever be. Not sure it makes sense to pay the cost of an extra indirection and subsystem unless there are at least two consumers of that DMA hardware to warrant modeling it after a dmaengine driver. I also remember that Al researched before whether 8250_dma.c could work, and came to the conclusion that it would not, but I will let him comment on the specifics.
Quoted 7 lines
-
BIT()andGENMASK()macros
- tons of different helpers like regmap API (if you wish to dump
registers via debugfs)Can you shrink this driver by 20-30% (I truly believe it's possible) and split DMA driver to
drivers/dma(which may already have something similar there)?
See previous response.
Signature · 1 line
Florian
Re: [PATCH v2 2/2] serial: 8250: Add new 8250-core based Broadcom STB driver
Quoted 52 lines · Florian Fainelli
Quoted 42 lines · Andy Shevchenko
Quoted 32 lines · 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_AUTOCTSflag 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
Quoted 8 lines
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_charQuoted 2 lines
Brief looking into the code raises several questions:
- is it driver from the last decade?Work on this driver started back in 2018, that was indeed the last decade.
Quoted 3 lines
- why it's not using what kernel provides?
- we have a lot of nice helpers:
- DMA Engine API
Quoted 8 lines
Not sure this makes sense, given that the DMA hardware that was added to this UART block is only used by the UART block and no other pieces of HW in the system, nor will they ever be. Not sure it makes sense to pay the cost of an extra indirection and subsystem unless there are at least two consumers of that DMA hardware to warrant modeling it after a dmaengine driver. I also remember that Al researched before whether
8250_dma.ccould work, and came to the conclusion that it would not, but I will let him comment on the specifics.
I see. In any case I still believe that the driver can be shrinked by a notable amount of lines.
Quoted 9 lines
Quoted 7 lines
-
BIT()andGENMASK()macros
- tons of different helpers like regmap API (if you wish to dump
registers via debugfs)Can you shrink this driver by 20-30% (I truly believe it's possible) and split DMA driver to
drivers/dma(which may already have something similar there)?See previous response.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Greg Kroah-Hartman
maintainerRe: [PATCH v2 2/2] serial: 8250: Add new 8250-core based Broadcom STB driver
Quoted 62 lines · Andy Shevchenko
Quoted 52 lines · Florian Fainelli
Quoted 42 lines · Andy Shevchenko
Quoted 32 lines · 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_AUTOCTSflag 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
Quoted 8 lines
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_charQuoted 2 lines
Brief looking into the code raises several questions:
- is it driver from the last decade?Work on this driver started back in 2018, that was indeed the last decade.
Quoted 3 lines
- why it's not using what kernel provides?
- we have a lot of nice helpers:
- DMA Engine APIQuoted 8 lines
Not sure this makes sense, given that the DMA hardware that was added to this UART block is only used by the UART block and no other pieces of HW in the system, nor will they ever be. Not sure it makes sense to pay the cost of an extra indirection and subsystem unless there are at least two consumers of that DMA hardware to warrant modeling it after a dmaengine driver. I also remember that Al researched before whether
8250_dma.ccould work, and came to the conclusion that it would not, but I will let him comment on the specifics.
Quoted 2 lines
I see. In any case I still believe that the driver can be shrinked by a notable amount of lines.
Patches always gladly accepted :)
Re: [PATCH v2 2/2] serial: 8250: Add new 8250-core based Broadcom STB driver
Quoted 4 lines · Greg Kroah-Hartman
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Florian Fainelli
Quoted 1 line · Andy Shevchenko
On Fri, Jan 15, 2021 at 11:19 PM Al Cooper <[email protected]> wrote:
...
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Not sure this makes sense, given that the DMA hardware that was added to this UART block is only used by the UART block and no other pieces of HW in the system, nor will they ever be. Not sure it makes sense to pay the cost of an extra indirection and subsystem unless there are at least two consumers of that DMA hardware to warrant modeling it after a dmaengine driver. I also remember that Al researched before whether
8250_dma.ccould work, and came to the conclusion that it would not, but I will let him comment on the specifics.
Quoted 4 lines
Quoted 2 lines
I see. In any case I still believe that the driver can be shrinked by a notable amount of lines.
Patches always gladly accepted :)
Or a good review... :-)
Signature · 2 lines
With Best Regards, Andy Shevchenko
Greg Kroah-Hartman
maintainerRe: [PATCH v2 2/2] serial: 8250: Add new 8250-core based Broadcom STB driver
Quoted 18 lines · Andy Shevchenko
Quoted 4 lines · Greg Kroah-Hartman
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Florian Fainelli
Quoted 1 line · Andy Shevchenko
On Fri, Jan 15, 2021 at 11:19 PM Al Cooper <[email protected]> wrote:
...
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Not sure this makes sense, given that the DMA hardware that was added to this UART block is only used by the UART block and no other pieces of HW in the system, nor will they ever be. Not sure it makes sense to pay the cost of an extra indirection and subsystem unless there are at least two consumers of that DMA hardware to warrant modeling it after a dmaengine driver. I also remember that Al researched before whether
8250_dma.ccould work, and came to the conclusion that it would not, but I will let him comment on the specifics.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
I see. In any case I still believe that the driver can be shrinked by a notable amount of lines.
Patches always gladly accepted :)
Or a good review... :-)
Please do so!
Re: [PATCH v2 2/2] serial: 8250: Add new 8250-core based Broadcom STB driver
In reply to Andy ShevchenkoI took another look at using the DMA framework for this and I still don't think it fits. The problem is that the DMA hardware is so tightly coupled to the 8250 UART hardware that a generic DMA model where a DMA engine will read the data from the UART data register when Data Ready is asserted and transfer it to memory, doesn't fit. For example:
- The flush timeout, parity error, framing error and overrun errors are kept separately in the DMA hardware.
- The DMA hardware expects to be enabled before receiving input data and it will continually write the data to ping pong data buffers as long as a buffer empty bit is set on the next buffer.
- When DMA is enabled it bypasses some of the normal 8250 control and data registers.
I think that trying to force this hardware into the current 8250 DMA model using the DMA framework would not be a good approach. I'll look at the other suggestions.
Thanks
Al
Quoted 80 lines · Andy Shevchenko
Quoted 52 lines · Florian Fainelli
Quoted 42 lines · Andy Shevchenko
Quoted 32 lines · 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_AUTOCTSflag 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
Quoted 8 lines
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_charQuoted 2 lines
Brief looking into the code raises several questions:
- is it driver from the last decade?Work on this driver started back in 2018, that was indeed the last decade.
Quoted 3 lines
- why it's not using what kernel provides?
- we have a lot of nice helpers:
- DMA Engine APIQuoted 8 lines
Not sure this makes sense, given that the DMA hardware that was added to this UART block is only used by the UART block and no other pieces of HW in the system, nor will they ever be. Not sure it makes sense to pay the cost of an extra indirection and subsystem unless there are at least two consumers of that DMA hardware to warrant modeling it after a dmaengine driver. I also remember that Al researched before whether
8250_dma.ccould work, and came to the conclusion that it would not, but I will let him comment on the specifics.I see. In any case I still believe that the driver can be shrinked by a notable amount of lines.
Quoted 9 lines
Quoted 7 lines
-
BIT()andGENMASK()macros
- tons of different helpers like regmap API (if you wish to dump
registers via debugfs)Can you shrink this driver by 20-30% (I truly believe it's possible) and split DMA driver to
drivers/dma(which may already have something similar there)?See previous response.
--
With Best Regards,
Andy Shevchenko