serial: mvebu-uart: Support for higher baudrates
Subsystems (6)
Pali Rohár
maintainerv5 cover serial: mvebu-uart: Support for higher baudrates
Per Greg's request I'm resending this patch series, please review it:
https://lore.kernel.org/linux-serial/YUmMli6LA%[email protected]/
This patch series add support for baudrates higher than 230400 on Marvell Armada 37xx boards.
Pali Rohár (6):
math64: New DIV_U64_ROUND_CLOSEST helper
serial: mvebu-uart: implement UART clock driver for configuring UART
base clock
dt-bindings: mvebu-uart: document DT bindings for
marvell,armada-3700-uart-clock
dt-bindings: mvebu-uart: update information about UART clock
arm64: dts: marvell: armada-37xx: add device node for UART clock and
use it
serial: mvebu-uart: implement support for baudrates higher than 230400
.../bindings/clock/armada3700-uart-clock.yaml | 57 ++ .../devicetree/bindings/serial/mvebu-uart.txt | 9 +- .../arm64/boot/dts/marvell/armada-3720-db.dts | 4 + .../dts/marvell/armada-3720-espressobin.dtsi | 4 + .../dts/marvell/armada-3720-turris-mox.dts | 4 + .../boot/dts/marvell/armada-3720-uDPU.dts | 4 + arch/arm64/boot/dts/marvell/armada-37xx.dtsi | 15 +- drivers/tty/serial/Kconfig | 1 + drivers/tty/serial/mvebu-uart.c | 592 +++++++++++++++++- include/linux/math64.h | 13 + 10 files changed, 682 insertions(+), 21 deletions(-) create mode 100644 Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml
Signature · 1 line
2.20.1
Pali Rohár
maintainerPATCH RESEND v5 1/6 math64: New DIV_U64_ROUND_CLOSEST helper
Provide DIV_U64_ROUND_CLOSEST helper which uses div_u64 to perform division rounded to the closest integer using unsigned 64bit dividend and unsigned 32bit divisor.
--- include/linux/math64.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)
include/linux/math64.h +13 -0
@@ -300,6 +300,19 @@ u64 mul_u64_u64_div_u64(u64 a, u64 mul, u64 div);#define DIV64_U64_ROUND_CLOSEST (dividend, divisor) \ ({ u64 _tmp = (divisor); div64_u64((dividend) + _tmp / 2, _tmp); }) +/* +* DIV_U64_ROUND_CLOSEST - unsigned 64bit divide with 32bit divisor rounded to nearest integer +* @dividend: unsigned 64bit dividend +* @divisor: unsigned 32bit divisor +* +* Divide unsigned 64bit dividend by unsigned 32bit divisor +* and round to closest integer. +* +* Return: dividend / divisor rounded to nearest integer +*/ +#define DIV_U64_ROUND_CLOSEST (dividend, divisor) \ + ({ u32 _tmp = (divisor); div_u64((u64)(dividend) + _tmp / 2, _tmp); }) +/* * DIV_S64_ROUND_CLOSEST - signed 64bit divide with 32bit divisor rounded to nearest integer * @dividend: signed 64bit dividend
Signature · 1 line
2.20.1
Pali Rohár
maintainerPATCH RESEND v5 3/6 dt-bindings: mvebu-uart: document DT bindings for marvell,armada-3700-uart-clock
In reply to Pali RohárThis change adds DT bindings documentation for device nodes with compatible string "marvell,armada-3700-uart-clock".
--- .../bindings/clock/armada3700-uart-clock.yaml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml new file +57 -0
@@ -0,0 +1,57 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/marvell,armada-3700-uart-clock# +$schema: http://devicetree.org/meta-schemas/core.yaml# +title: Marvell Armada 3720 UART clocks + +properties: + compatible: + const: marvell,armada-3700-uart-clock + + reg: + items: + - description: UART Clock Control Register + - description: UART 2 Baud Rate Divisor Register + + clocks: + description: | + List of parent clocks suitable for UART from following set: + "TBG-A-P", "TBG-B-P", "TBG-A-S", "TBG-B-S", "xtal" + UART clock can use one from this set and when more are provided + then kernel would choose and configure the most suitable one. + It is suggest to specify at least one TBG clock to achieve + baudrates above 230400 and also to specify clock which bootloader + used for UART (most probably xtal) for smooth boot log on UART. + + clock-names: + items: + - const: TBG-A-P + - const: TBG-B-P + - const: TBG-A-S + - const: TBG-B-S + - const: xtal + minItems: 1 + maxItems: 5 + + '#clock-cells': + const: 1 + +required: + - compatible + - reg + - clocks + - clock-names + - '#clock-cells' + +additionalProperties: false + +examples: + - | + uartclk: uartclk@12000 { + compatible = "marvell,armada-3700-uart-clock"; + reg = <0x12010 0x4>, <0x12210 0x4>; + clocks = <&tbg 0>, <&tbg 1>, <&tbg 2>, <&tbg 3>, <&xtalclk>; + clock-names = "TBG-A-P", "TBG-B-P", "TBG-A-S", "TBG-B-S", "xtal"; + #clock-cells = <1>; + };
Signature · 1 line
2.20.1
Pali Rohár
maintainerPATCH RESEND v5 2/6 serial: mvebu-uart: implement UART clock driver for configuring UART base clock
In reply to Pali RohárThis patch implements a new device driver for controlling UART clocks on Marvell Armada 3700 SoC. This device driver is loaded for devices which match compatible string "marvell,armada-3700-uart-clock".
There are more pitfalls related to UART clocks. Both UARTs use same base clock source. Also divisors for TBG base clock are shared between both UARTs and are configured only from UART1 address space. Clocks can be enabled / disabled separately for UART1 and UART2, but they are controlled only from UART1 address space. Moreover Marvell Armada 3700 Functional Specifications has swapped bits for enabling/disabling UART1 and UART2 clocks.
So driver for controlling UART2 needs to have access to UART1 address space as UART1 address space contains some bits exclusively used by UART2 and also bits which are shared for both UART1 and UART2.
For changing UART base clock (which controls both UARTs) during boot when UART driver is not ready and only early console is active, is not simple operation as it is required to also recalculate divisors to not change UART baudrate used by early console. So for this operation UART1 clock driver needs to access also into address space of UART2 where are registers for UART2 divisors.
For these reasons, this new device driver for UART clocks does not use ioremap_resource(), but only ioremap() to prevent resource conflicts between UART clock driver and UART driver.
Shared between drivers are only two 4-bytes registers: UART Clock Control and UART 2 Baud Rate Divisor. Access to these two registers are protected by one spinlock to prevent any conflicts. Access is required only during probe time, changing baudrate and during suspend/resume.
Hardware can be configured to use one of following clocks as UART base
clock: TBG-A-P, TBG-B-P, TBG-A-S, TBG-B-S, xtal. Not every clock is usable for higher buadrates. In DT node can be specified any subset and kernel choose the best one, which still supports required baudrate 9600. For smooth boot log output it is needed to specify clock used by early console otherwise garbage would be put on UART during probing for UART clock driver and transitioning from early console to normal console.
This change is required to enable and configure TBG clock as a base clock for UART. TBG clock is required to achieve higher baudrates than 230400.
--- drivers/tty/serial/Kconfig | 1 + drivers/tty/serial/mvebu-uart.c | 519 +++++++++++++++++++++++++++++++- 2 files changed, 518 insertions(+), 2 deletions(-)
drivers/tty/serial/Kconfig +1 -0
@@ -1444,6 +1444,7 @@ config SERIAL_STM32_CONSOLE config SERIAL_MVEBU_UART bool "Marvell EBU serial port support" depends on ARCH_MVEBU || COMPILE_TEST + depends on COMMON_CLK select SERIAL_CORE help This driver is for Marvell EBU SoC's UART. If you have a machine
drivers/tty/serial/mvebu-uart.c +517 -2
601 lines not on this page · raw message
Signature · 1 line
2.20.1
Pali Rohár
maintainerPATCH RESEND v5 4/6 dt-bindings: mvebu-uart: update information about UART clock
In reply to Pali RohárDevice "marvell,armada-3700-uart" should use "marvell,armada-3700-uart-clock" compatible clock.
--- Documentation/devicetree/bindings/serial/mvebu-uart.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/serial/mvebu-uart.txt +6 -3
@@ -14,7 +14,10 @@ Required properties: is provided (possible only with the "marvell,armada-3700-uart" compatible string for backward compatibility), it will only work if the baudrate was initialized by the bootloader and no baudrate - change will then be possible. + change will then be possible. When provided it should be UART1-clk + for standard variant of UART and UART2-clk for extended variant + of UART. TBG clock (with UART TBG divisors d1=d2=1) or xtal clock + should not be used and are supported only for backward compatibility. - interrupts: - Must contain three elements for the standard variant of the IP (marvell,armada-3700-uart): "uart-sum", "uart-tx" and "uart-rx",
@@ -34,7 +37,7 @@ Example: uart0: serial@12000 { compatible = "marvell,armada-3700-uart"; reg = <0x12000 0x18>; - clocks = <&xtalclk>; + clocks = <&uartclk 0>; interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>,
@@ -45,7 +48,7 @@ Example: uart1: serial@12200 { compatible = "marvell,armada-3700-uart-ext"; reg = <0x12200 0x30>; - clocks = <&xtalclk>; + clocks = <&uartclk 1>; interrupts = <GIC_SPI 30 IRQ_TYPE_EDGE_RISING>, <GIC_SPI 31 IRQ_TYPE_EDGE_RISING>;
Signature · 1 line
2.20.1
Pali Rohár
maintainerPATCH RESEND v5 5/6 arm64: dts: marvell: armada-37xx: add device node for UART clock and use it
In reply to Pali RohárThis change defines DT node for UART clock "marvell,armada-3700-uart-clock" and use this UART clock as a base clock for all UART devices.
--- arch/arm64/boot/dts/marvell/armada-3720-db.dts | 4 ++++ .../boot/dts/marvell/armada-3720-espressobin.dtsi | 4 ++++ .../boot/dts/marvell/armada-3720-turris-mox.dts | 4 ++++ arch/arm64/boot/dts/marvell/armada-3720-uDPU.dts | 4 ++++ arch/arm64/boot/dts/marvell/armada-37xx.dtsi | 15 +++++++++++++-- 5 files changed, 29 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/marvell/armada-3720-db.dts +4 -0
@@ -191,6 +191,10 @@ }; }; +&uartclk { + status = "okay"; +}; + /* * Exported on the micro USB connector CON30(V2.0)/CON32(V1.4) through * an FTDI (also on CON24(V2.0)/CON26(V1.4)).
arch/arm64/boot/dts/marvell/armada-3720-espressobin.dtsi +4 -0
@@ -117,6 +117,10 @@ }; }; +&uartclk { + status = "okay"; +}; + /* Exported on the micro USB connector J5 through an FTDI */ &uart0 { pinctrl-names = "default";
arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts +4 -0
@@ -157,6 +157,10 @@ status = "disabled"; }; +&uartclk { + status = "okay"; +}; + &uart0 { status = "okay"; };
arch/arm64/boot/dts/marvell/armada-3720-uDPU.dts +4 -0
@@ -183,6 +183,10 @@ phy-names = "usb2-utmi-otg-phy"; }; +&uartclk { + status = "okay"; +}; + &uart0 { status = "okay"; };
arch/arm64/boot/dts/marvell/armada-37xx.dtsi +13 -2
@@ -132,10 +132,21 @@ reg = <0x11500 0x40>; }; + uartclk: uartclk@12000 { + compatible = "marvell,armada-3700-uart-clock"; + reg = <0x12010 0x4>, <0x12210 0x4>; + clocks = <&tbg 0>, <&tbg 1>, <&tbg 2>, + <&tbg 3>, <&xtalclk>; + clock-names = "TBG-A-P", "TBG-B-P", "TBG-A-S", + "TBG-B-S", "xtal"; + #clock-cells = <1>; + status = "disabled"; + }; + uart0: serial@12000 { compatible = "marvell,armada-3700-uart"; reg = <0x12000 0x18>; - clocks = <&xtalclk>; + clocks = <&uartclk 0>; interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>,
@@ -147,7 +158,7 @@ uart1: serial@12200 { compatible = "marvell,armada-3700-uart-ext"; reg = <0x12200 0x30>; - clocks = <&xtalclk>; + clocks = <&uartclk 1>; interrupts = <GIC_SPI 30 IRQ_TYPE_EDGE_RISING>, <GIC_SPI 31 IRQ_TYPE_EDGE_RISING>;
Signature · 1 line
2.20.1
Pali Rohár
maintainerPATCH RESEND v5 6/6 serial: mvebu-uart: implement support for baudrates higher than 230400
In reply to Pali RohárThis change implements simple usage of fractional divisor. When main divisor D is too large to represent requested baudrate then use divisor M from fractional divisor feature. All the M prescalers are set to same and maximal value 63, so fractional part is not used at all.
Tests showed that UART at 1500000 baudrate via this configuration is stable and usable. So there is no need to implement complicated calculation of fractional coefficients yet.
To use this feature with higher baudrates, it is required to use UART clock provided by UART clock driver. Default boot xtal clock is not capable of higher baudrates and this change also contains code for determining upper limit of possible baudrate.
--- drivers/tty/serial/mvebu-uart.c | 79 ++++++++++++++++++++++++++------- 1 file changed, 62 insertions(+), 17 deletions(-)
drivers/tty/serial/mvebu-uart.c +62 -17
@@ -99,6 +99,7 @@#define UART_OSAMP 0x14#define OSAMP_DEFAULT_DIVISOR 16#define OSAMP_DIVISORS_MASK 0x3F3F3F3F +#define OSAMP_MAX_DIVISOR 63#define MVEBU_NR_UARTS 2
@@ -479,18 +480,59 @@ static int mvebu_uart_baud_rate_set(struct uart_port *port, unsigned int baud)return -EOPNOTSUPP ;/* -* The baudrate is derived from the UART clock thanks to two divisors: -* > D ("baud generator"): can divide the clock from 2 to 2^10 - 1. -* > M ("fractional divisor"): allows a better accuracy for -* baudrates higher than 230400. +* The baudrate is derived from the UART clock thanks to divisors: +* > d1 * d2 ("TBG divisors"): can divide only TBG clock from 1 to 6 +* > D ("baud generator"): can divide the clock from 1 to 1023 +* > M ("fractional divisor"): allows a better accuracy (from 1 to 63) * -* As the derivation of M is rather complicated, the code sticks to its -* default value (x16) when all the prescalers are zeroed, and only -* makes use of D to configure the desired baudrate. +* Exact formulas for calculating baudrate: +* +* with default x16 scheme: +* baudrate = xtal / (d * 16) +* baudrate = tbg / (d1 * d2 * d * 16) +* +* with fractional divisor: +* baudrate = 10 * xtal / (d * (3 * (m1 + m2) + 2 * (m3 + m4))) +* baudrate = 10 * tbg / (d1*d2 * d * (3 * (m1 + m2) + 2 * (m3 + m4))) +* +* Oversampling value: +* osamp = (m1 << 0) | (m2 << 8) | (m3 << 16) | (m4 << 24); +* +* Where m1 controls number of clock cycles per bit for bits 1,2,3; +* m2 for bits 4,5,6; m3 for bits 7,8 and m4 for bits 9,10. +* +* To simplify baudrate setup set all the M prescalers to same value. +* For 9600 baudrate and higher it is enough to use just default (x16) +* divisor or fractional divisor with M = 63, so there is no need to +* use real fractional support (when the M prescalers are not equal). +* +* When all the M prescalers are zeroed then default (x16) divisor is +* used. Default x16 scheme is more stable than M (fractional divisor), +* so use M only when D divisor is not enough to derivate baudrate. +* +* Member port->uartclk is either xtal clock rate or TBG clock rate +* divided by (d1 * d2). So UART clock driver already sets d1 and d2 +* divisors and UART driver cannot change them. Moreover they are +* shared with both UARTs. */ + m_divisor =OSAMP_DEFAULT_DIVISOR ; d_divisor =DIV_ROUND_CLOSEST (port->uartclk, baud * m_divisor); +if (d_divisor >BRDV_BAUD_MAX ) { +/* +* Experiments showed that small M divisors are unstable. +* So use maximal possible M = 63 and calculate D divisor. +*/ + m_divisor =OSAMP_MAX_DIVISOR ; + d_divisor =DIV_ROUND_CLOSEST (port->uartclk, baud * m_divisor); + } + +if (d_divisor <1 ) + d_divisor =1 ; +else if (d_divisor >BRDV_BAUD_MAX ) + d_divisor =BRDV_BAUD_MAX ; +spin_lock_irqsave (&mvebu_uart_lock, flags); brdv =readl (port->membase +UART_BRDV ); brdv &= ~BRDV_BAUD_MASK ;
@@ -500,6 +542,9 @@ static int mvebu_uart_baud_rate_set(struct uart_port *port, unsigned int baud) osamp =readl (port->membase +UART_OSAMP ); osamp &= ~OSAMP_DIVISORS_MASK ; +if (m_divisor !=OSAMP_DEFAULT_DIVISOR ) + osamp |= (m_divisor <<0 ) | (m_divisor <<8 ) | + (m_divisor <<16 ) | (m_divisor <<24 );writel (osamp, port->membase +UART_OSAMP );return 0 ;
@@ -529,14 +574,14 @@ static void mvebu_uart_set_termios(struct uart_port *port, port->ignore_status_mask |=STAT_RX_RDY (port) |STAT_BRK_ERR ;/* -* Maximal divisor is 1023 * 16 when using default (x16) scheme. -* Maximum achievable frequency with simple baudrate divisor is 230400. -* Since the error per bit frame would be of more than 15%, achieving -* higher frequencies would require to implement the fractional divisor -* feature. +* Maximal divisor is 1023 and maximal fractional divisor is 63. And +* experiments showed that baudrates above 1/80 of base clock are not +* stable and usable. So disallow baudrate above 1/80 of the base clock. +* When port->uartclk is not available then mvebu_uart_baud_rate_set() +* fails so values min_baud and max_baud in this case does not matter. */ - min_baud =DIV_ROUND_UP (port->uartclk,1023 *16 ); - max_baud =230400 ; + min_baud =DIV_ROUND_UP (port->uartclk,BRDV_BAUD_MAX *OSAMP_MAX_DIVISOR ); + max_baud = port->uartclk /80 ; baud =uart_get_baud_rate (port, termios, old, min_baud, max_baud);if (mvebu_uart_baud_rate_set (port, baud)) {
@@ -1394,14 +1439,14 @@ static int mvebu_uart_clock_probe(struct platform_device *pdev)* Calculate the smallest TBG d1 and d2 divisors that * still can provide 9600 baudrate. */ - d1 =DIV_ROUND_UP (rate,9600 *OSAMP_DEFAULT_DIVISOR * + d1 =DIV_ROUND_UP (rate,9600 *OSAMP_MAX_DIVISOR *BRDV_BAUD_MAX );if (d1 <1 ) d1 =1 ;else if (d1 >CLK_TBG_DIV1_MAX ) d1 =CLK_TBG_DIV1_MAX ; - d2 =DIV_ROUND_UP (rate,9600 *OSAMP_DEFAULT_DIVISOR * + d2 =DIV_ROUND_UP (rate,9600 *OSAMP_MAX_DIVISOR *BRDV_BAUD_MAX * d1);if (d2 <1 ) d2 =1 ;
@@ -1416,7 +1461,7 @@ static int mvebu_uart_clock_probe(struct platform_device *pdev) }/* Skip clock source which cannot provide 9600 baudrate */ -if (rate >9600 *OSAMP_DEFAULT_DIVISOR *BRDV_BAUD_MAX * d1 * d2) +if (rate >9600 *OSAMP_MAX_DIVISOR *BRDV_BAUD_MAX * d1 * d2)continue ;/*
Signature · 1 line
2.20.1
Gregory CLEMENT
maintainerRe: [RESEND PATCH v5 5/6] arm64: dts: marvell: armada-37xx: add device node for UART clock and use it
In reply to Pali RohárHello Pali,
Quoted 2 lines
This change defines DT node for UART clock "marvell,armada-3700-uart-clock" and use this UART clock as a base clock for all UART devices.
Sorry to not have pointed this earlier but I found something a little unusual, see below:
Quoted 15 lines
Signed-off-by Pali Rohár <[email protected]>--- arch/arm64/boot/dts/marvell/armada-3720-db.dts | 4 ++++ .../boot/dts/marvell/armada-3720-espressobin.dtsi | 4 ++++ .../boot/dts/marvell/armada-3720-turris-mox.dts | 4 ++++ arch/arm64/boot/dts/marvell/armada-3720-uDPU.dts | 4 ++++ arch/arm64/boot/dts/marvell/armada-37xx.dtsi | 15 +++++++++++++-- 5 files changed, 29 insertions(+), 2 deletions(-)arch/arm64/boot/dts/marvell/armada-3720-db.dts +0
-0
arch/arm64/boot/dts/marvell/armada-3720-db.dts line 195
Quoted 5 lines
arch/arm64/boot/dts/marvell/armada-3720-db.dts +2
-0@@ -191,6 +191,10 @@ }; }; +&uartclk { + status = "okay";
I found unusual to have to enable the clock at device tree level. Usually the clock driver is always loaded and then the clock is really enabled or disabled through the clock framework.
[...]
Quoted 6 lines
arch/arm64/boot/dts/marvell/armada-37xx.dtsi +0
-0@@ -132,10 +132,21 @@ reg = <0x11500 0x40>;
arch/arm64/boot/dts/marvell/armada-37xx.dtsi line 142
Quoted 10 lines
arch/arm64/boot/dts/marvell/armada-37xx.dtsi +8
-0}; + uartclk: uartclk@12000 { + compatible = "marvell,armada-3700-uart-clock"; + reg = <0x12010 0x4>, <0x12210 0x4>; + clocks = <&tbg 0>, <&tbg 1>, <&tbg 2>, + <&tbg 3>, <&xtalclk>; + clock-names = "TBG-A-P", "TBG-B-P", "TBG-A-S", + "TBG-B-S", "xtal"; + #clock-cells = <1>;
I think you could remove the following line and thanks to this there won't be any change in the dts of the board:
arch/arm64/boot/dts/marvell/armada-37xx.dtsi line 145
Quoted 3 lines
arch/arm64/boot/dts/marvell/armada-37xx.dtsi +3
-0+ status = "disabled"; + }; +
Gregory
Quoted 20 lines
arch/arm64/boot/dts/marvell/armada-37xx.dtsi +2
-2uart0: serial@12000 { compatible = "marvell,armada-3700-uart"; reg = <0x12000 0x18>; - clocks = <&xtalclk>; + clocks = <&uartclk 0>; interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>,@@ -147,7 +158,7 @@ uart1: serial@12200 { compatible = "marvell,armada-3700-uart-ext"; reg = <0x12200 0x30>; - clocks = <&xtalclk>; + clocks = <&uartclk 1>; interrupts = <GIC_SPI 30 IRQ_TYPE_EDGE_RISING>, <GIC_SPI 31 IRQ_TYPE_EDGE_RISING>;Signature · 1 line
2.20.1
Signature · 3 lines
Gregory Clement, Bootlin Embedded Linux and Kernel engineering http://bootlin.com
Pali Rohár
maintainerRe: [RESEND PATCH v5 5/6] arm64: dts: marvell: armada-37xx: add device node for UART clock and use it
Quoted 54 lines · On Wednesday 22 September 2021 17:16:22 Gregory CLEMENT wrote:
Hello Pali,
Quoted 2 lines
This change defines DT node for UART clock "marvell,armada-3700-uart-clock" and use this UART clock as a base clock for all UART devices.
Sorry to not have pointed this earlier but I found something a little unusual, see below:
Quoted 15 lines
Signed-off-by Pali Rohár <[email protected]>--- arch/arm64/boot/dts/marvell/armada-3720-db.dts | 4 ++++ .../boot/dts/marvell/armada-3720-espressobin.dtsi | 4 ++++ .../boot/dts/marvell/armada-3720-turris-mox.dts | 4 ++++ arch/arm64/boot/dts/marvell/armada-3720-uDPU.dts | 4 ++++ arch/arm64/boot/dts/marvell/armada-37xx.dtsi | 15 +++++++++++++-- 5 files changed, 29 insertions(+), 2 deletions(-)arch/arm64/boot/dts/marvell/armada-3720-db.dts +0
-0arch/arm64/boot/dts/marvell/armada-3720-db.dts line 195
Quoted 5 lines
arch/arm64/boot/dts/marvell/armada-3720-db.dts +2
-0@@ -191,6 +191,10 @@ }; }; +&uartclk { + status = "okay";I found unusual to have to enable the clock at device tree level. Usually the clock driver is always loaded and then the clock is really enabled or disabled through the clock framework.
[...]
Quoted 6 lines
arch/arm64/boot/dts/marvell/armada-37xx.dtsi +0
-0@@ -132,10 +132,21 @@ reg = <0x11500 0x40>;arch/arm64/boot/dts/marvell/armada-37xx.dtsi line 142
Quoted 10 lines
arch/arm64/boot/dts/marvell/armada-37xx.dtsi +8
-0}; + uartclk: uartclk@12000 { + compatible = "marvell,armada-3700-uart-clock"; + reg = <0x12010 0x4>, <0x12210 0x4>; + clocks = <&tbg 0>, <&tbg 1>, <&tbg 2>, + <&tbg 3>, <&xtalclk>; + clock-names = "TBG-A-P", "TBG-B-P", "TBG-A-S", + "TBG-B-S", "xtal"; + #clock-cells = <1>;I think you could remove the following line and thanks to this there won't be any change in the dts of the board:
Quoted 1 line
arch/arm64/boot/dts/marvell/armada-37xx.dtsi line 143
Quoted 1 line
arch/arm64/boot/dts/marvell/armada-37xx.dtsi +1
-0+ status = "disabled";
After removing "status" from dtsi and then also from board bts files, UART is still working fine.
So I will include this change into V6.
Is there anything else?
Quoted 31 lines
arch/arm64/boot/dts/marvell/armada-37xx.dtsi line 145
Quoted 2 lines
arch/arm64/boot/dts/marvell/armada-37xx.dtsi +2
-0+ }; +Gregory
Quoted 20 lines
arch/arm64/boot/dts/marvell/armada-37xx.dtsi +2
-2uart0: serial@12000 { compatible = "marvell,armada-3700-uart"; reg = <0x12000 0x18>; - clocks = <&xtalclk>; + clocks = <&uartclk 0>; interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>,@@ -147,7 +158,7 @@ uart1: serial@12200 { compatible = "marvell,armada-3700-uart-ext"; reg = <0x12200 0x30>; - clocks = <&xtalclk>; + clocks = <&uartclk 1>; interrupts = <GIC_SPI 30 IRQ_TYPE_EDGE_RISING>, <GIC_SPI 31 IRQ_TYPE_EDGE_RISING>;Signature · 1 line
2.20.1Signature · 3 lines
Gregory Clement, Bootlin Embedded Linux and Kernel engineering http://bootlin.com
Re: [RESEND PATCH v5 3/6] dt-bindings: mvebu-uart: document DT bindings for marvell,armada-3700-uart-clock
In reply to Pali RohárQuoted 3 lines · Pali Rohár
This change adds DT bindings documentation for device nodes with compatible string "marvell,armada-3700-uart-clock".
Please resend to the DT list so that checks run and this gets reviewed in a timely manner.
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml line 1
Quoted 13 lines
Signed-off-by Pali Rohár <[email protected]>--- .../bindings/clock/armada3700-uart-clock.yaml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/armada3700-uart-clock.yamlDocumentation/devicetree/bindings/clock/armada3700-uart-clock.yaml new file +1
-0@@ -0,0 +1,57 @@ +# SPDX-License-Identifier: GPL-2.0
Dual license. checkpatch will tell you which ones.
Quoted 24 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml new file +24
-0+%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/marvell,armada-3700-uart-clock# +$schema: http://devicetree.org/meta-schemas/core.yaml# +title: Marvell Armada 3720 UART clocks + +properties: + compatible: + const: marvell,armada-3700-uart-clock + + reg: + items: + - description: UART Clock Control Register + - description: UART 2 Baud Rate Divisor Register + + clocks: + description: | + List of parent clocks suitable for UART from following set: + "TBG-A-P", "TBG-B-P", "TBG-A-S", "TBG-B-S", "xtal" + UART clock can use one from this set and when more are provided + then kernel would choose and configure the most suitable one. + It is suggest to specify at least one TBG clock to achieve + baudrates above 230400 and also to specify clock which bootloader + used for UART (most probably xtal) for smooth boot log on UART.
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml line 35
Quoted 10 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml new file +10
-0+ + clock-names: + items: + - const: TBG-A-P + - const: TBG-B-P + - const: TBG-A-S + - const: TBG-B-S + - const: xtal + minItems: 1 + maxItems: 5
Don't need maxItems equal to length of 'items'.
Quoted 6 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml new file +6
-0+ + '#clock-cells': + const: 1 + +required: + - compatible
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml line 51
Quoted 10 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml new file +10
-0+ - reg + - clocks + - clock-names + - '#clock-cells' + +additionalProperties: false + +examples: + - | + uartclk: uartclk@12000 {
clock-controller@12010
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml line 53
Quoted 2 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml new file +2
-0+ compatible = "marvell,armada-3700-uart-clock"; + reg = <0x12010 0x4>, <0x12210 0x4>;
However, looks like this is part of some other block. The whole block needs a binding (or at least the parent and whatever sub-functions you know about).
Quoted 7 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml new file +4
-1+ clocks = <&tbg 0>, <&tbg 1>, <&tbg 2>, <&tbg 3>, <&xtalclk>; + clock-names = "TBG-A-P", "TBG-B-P", "TBG-A-S", "TBG-B-S", "xtal"; + #clock-cells = <1>; + }; --2.20.1
Pali Rohár
maintainerRe: [RESEND PATCH v5 3/6] dt-bindings: mvebu-uart: document DT bindings for marvell,armada-3700-uart-clock
Quoted 7 lines · On Monday 27 September 2021 15:17:59 Rob Herring wrote:
Quoted 3 lines · Pali Rohár
This change adds DT bindings documentation for device nodes with compatible string "marvell,armada-3700-uart-clock".
Please resend to the DT list so that checks run and this gets reviewed in a timely manner.
OK
Quoted 6 lines
Quoted 6 lines
Signed-off-by Pali Rohár <[email protected]>--- .../bindings/clock/armada3700-uart-clock.yaml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml
Quoted 9 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml line 1
Quoted 7 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml new file +1
-0@@ -0,0 +1,57 @@ +# SPDX-License-Identifier: GPL-2.0Dual license. checkpatch will tell you which ones.
OK
Quoted 28 lines
Quoted 28 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml new file +28
-0+%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/marvell,armada-3700-uart-clock# +$schema: http://devicetree.org/meta-schemas/core.yaml# +title: Marvell Armada 3720 UART clocks + +properties: + compatible: + const: marvell,armada-3700-uart-clock + + reg: + items: + - description: UART Clock Control Register + - description: UART 2 Baud Rate Divisor Register + + clocks: + description: | + List of parent clocks suitable for UART from following set: + "TBG-A-P", "TBG-B-P", "TBG-A-S", "TBG-B-S", "xtal" + UART clock can use one from this set and when more are provided + then kernel would choose and configure the most suitable one. + It is suggest to specify at least one TBG clock to achieve + baudrates above 230400 and also to specify clock which bootloader + used for UART (most probably xtal) for smooth boot log on UART. + + clock-names: + items: + - const: TBG-A-P
Quoted 8 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml line 35
Quoted 6 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml new file +6
-0+ - const: TBG-B-P + - const: TBG-A-S + - const: TBG-B-S + - const: xtal + minItems: 1 + maxItems: 5Don't need maxItems equal to length of 'items'.
OK
Quoted 19 lines
Quoted 6 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml new file +6
-0+ + '#clock-cells': + const: 1 + +required: + - compatibleDocumentation/devicetree/bindings/clock/armada3700-uart-clock.yaml line 51
Quoted 10 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml new file +10
-0+ - reg + - clocks + - clock-names + - '#clock-cells' + +additionalProperties: false + +examples: + - | + uartclk: uartclk@12000 {clock-controller@12010
Quoted 4 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml line 53
Quoted 2 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml new file +2
-0+ compatible = "marvell,armada-3700-uart-clock"; + reg = <0x12010 0x4>, <0x12210 0x4>;However, looks like this is part of some other block.
Yes, it is part of UART block.
Explanation is in commit message of patch 2/6.
And also discussed here:
https://lore.kernel.org/linux-serial/20210812200804.i4kbcs6ut27mapd3@pali/
Quoted 3 lines
The whole block
needs a binding (or at least the parent and whatever sub-functions you know about).
Whole UART block has already binding. Clock driver just needs access to these clock bits of these two registers which are in UART block. HW designers decided that clock which drives UART2 has configuration in UART1 address space. As explained in commit message of patch 2/6 there is no easy way how to deal with it in DTS backward compatible way. So clock and UART driver shares mutex for accessing these two shared registers, and these two registers are defined in all 3 DT nodes: UART1, UART2 and UART-clock.
Quoted 7 lines
Quoted 7 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml new file +4
-1+ clocks = <&tbg 0>, <&tbg 1>, <&tbg 2>, <&tbg 3>, <&xtalclk>; + clock-names = "TBG-A-P", "TBG-B-P", "TBG-A-S", "TBG-B-S", "xtal"; + #clock-cells = <1>; + }; --2.20.1
Pali Rohár
maintainerRe: [RESEND PATCH v5 3/6] dt-bindings: mvebu-uart: document DT bindings for marvell,armada-3700-uart-clock
In reply to Rob HerringQuoted 14 lines · On Monday 27 September 2021 15:17:59 Rob Herring wrote:
Quoted 3 lines · Pali Rohár
This change adds DT bindings documentation for device nodes with compatible string "marvell,armada-3700-uart-clock".
Please resend to the DT list so that checks run and this gets reviewed in a timely manner.
Quoted 6 lines
Signed-off-by Pali Rohár <[email protected]>--- .../bindings/clock/armada3700-uart-clock.yaml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml
Quoted 9 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml line 1
Quoted 7 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml new file +1
-0@@ -0,0 +1,57 @@ +# SPDX-License-Identifier: GPL-2.0Dual license. checkpatch will tell you which ones.
Did not tell me :-(
$ ./scripts/checkpatch.pl -f Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml
Traceback (most recent call last):
File "scripts/spdxcheck.py", line 6, in <module>
from ply import lex, yacc
ModuleNotFoundError: No module named 'ply'
total: 0 errors, 0 warnings, 57 lines checkedDocumentation/devicetree/bindings/clock/armada3700-uart-clock.yaml has no obvious style problems and is ready for submission.
Huh, Perl needs Python?? Anyway...
$ sudo apt install python3-ply ...
$ ./scripts/checkpatch.pl -f Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml
Traceback (most recent call last):
File "scripts/spdxcheck.py", line 10, in <module>
import git
ModuleNotFoundError: No module named 'git'
total: 0 errors, 0 warnings, 57 lines checkedDocumentation/devicetree/bindings/clock/armada3700-uart-clock.yaml has no obvious style problems and is ready for submission.
Second attempt...
$ sudo apt install python3-git ...
$ ./scripts/checkpatch.pl -f Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml total: 0 errors, 0 warnings, 57 lines checked
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml has no obvious style problems and is ready for submission.
And no error :-(
Re: [RESEND PATCH v5 3/6] dt-bindings: mvebu-uart: document DT bindings for marvell,armada-3700-uart-clock
Quoted 56 lines · Pali Rohár
Quoted 14 lines · On Monday 27 September 2021 15:17:59 Rob Herring wrote:
Quoted 3 lines · Pali Rohár
This change adds DT bindings documentation for device nodes with compatible string "marvell,armada-3700-uart-clock".
Please resend to the DT list so that checks run and this gets reviewed in a timely manner.
Quoted 6 lines
Signed-off-by Pali Rohár <[email protected]>--- .../bindings/clock/armada3700-uart-clock.yaml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/armada3700-uart-clock.yamlQuoted 9 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml line 1
Quoted 7 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml new file +1
-0@@ -0,0 +1,57 @@ +# SPDX-License-Identifier: GPL-2.0Dual license. checkpatch will tell you which ones.
Did not tell me :-(
$ ./scripts/checkpatch.pl -f Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml Traceback (most recent call last): File "scripts/spdxcheck.py", line 6, in <module> from ply import lex, yacc ModuleNotFoundError: No module named 'ply' total: 0 errors, 0 warnings, 57 lines checked
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yamlhas no obvious style problems and is ready for submission.Huh, Perl needs Python?? Anyway...
$ sudo apt install python3-ply ...$ ./scripts/checkpatch.pl -f Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml Traceback (most recent call last): File "scripts/spdxcheck.py", line 10, in <module> import git ModuleNotFoundError: No module named 'git' total: 0 errors, 0 warnings, 57 lines checked
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yamlhas no obvious style problems and is ready for submission.Second attempt...
$ sudo apt install python3-git ...
Quoted 6 lines
$ ./scripts/checkpatch.pl -f Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml total: 0 errors, 0 warnings, 57 lines checked
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yamlhas no obvious style problems and is ready for submission.And no error :-(
Looks like file mode requires '--strict' to enable while patch mode doesn't.
Rob
Re: [RESEND PATCH v5 3/6] dt-bindings: mvebu-uart: document DT bindings for marvell,armada-3700-uart-clock
In reply to Pali RohárQuoted 104 lines · Pali Rohár
Quoted 7 lines · On Monday 27 September 2021 15:17:59 Rob Herring wrote:
Quoted 3 lines · Pali Rohár
This change adds DT bindings documentation for device nodes with compatible string "marvell,armada-3700-uart-clock".
Please resend to the DT list so that checks run and this gets reviewed in a timely manner.
OK
Quoted 6 lines
Quoted 6 lines
Signed-off-by Pali Rohár <[email protected]>--- .../bindings/clock/armada3700-uart-clock.yaml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/armada3700-uart-clock.yamlQuoted 9 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml line 1
Quoted 7 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml new file +1
-0@@ -0,0 +1,57 @@ +# SPDX-License-Identifier: GPL-2.0Dual license. checkpatch will tell you which ones.
OK
Quoted 28 lines
Quoted 28 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml new file +28
-0+%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/marvell,armada-3700-uart-clock# +$schema: http://devicetree.org/meta-schemas/core.yaml# +title: Marvell Armada 3720 UART clocks + +properties: + compatible: + const: marvell,armada-3700-uart-clock + + reg: + items: + - description: UART Clock Control Register + - description: UART 2 Baud Rate Divisor Register + + clocks: + description: | + List of parent clocks suitable for UART from following set: + "TBG-A-P", "TBG-B-P", "TBG-A-S", "TBG-B-S", "xtal" + UART clock can use one from this set and when more are provided + then kernel would choose and configure the most suitable one. + It is suggest to specify at least one TBG clock to achieve + baudrates above 230400 and also to specify clock which bootloader + used for UART (most probably xtal) for smooth boot log on UART. + + clock-names: + items: + - const: TBG-A-PQuoted 8 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml line 35
Quoted 6 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml new file +6
-0+ - const: TBG-B-P + - const: TBG-A-S + - const: TBG-B-S + - const: xtal + minItems: 1 + maxItems: 5Don't need maxItems equal to length of 'items'.
OK
Quoted 19 lines
Quoted 6 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml new file +6
-0+ + '#clock-cells': + const: 1 + +required: + - compatibleDocumentation/devicetree/bindings/clock/armada3700-uart-clock.yaml line 51
Quoted 10 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml new file +10
-0+ - reg + - clocks + - clock-names + - '#clock-cells' + +additionalProperties: false + +examples: + - | + uartclk: uartclk@12000 {clock-controller@12010
Quoted 4 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml line 53
Quoted 2 lines
Documentation/devicetree/bindings/clock/armada3700-uart-clock.yaml new file +2
-0+ compatible = "marvell,armada-3700-uart-clock"; + reg = <0x12010 0x4>, <0x12210 0x4>;However, looks like this is part of some other block.
Yes, it is part of UART block.
Explanation is in commit message of patch 2/6.
And also discussed here:
https://lore.kernel.org/linux-serial/20210812200804.i4kbcs6ut27mapd3@pali/Quoted 3 lines
The whole block
needs a binding (or at least the parent and whatever sub-functions you know about).
Quoted 8 lines
Whole UART block has already binding. Clock driver just needs access to these clock bits of these two registers which are in UART block. HW designers decided that clock which drives UART2 has configuration in UART1 address space. As explained in commit message of patch 2/6 there is no easy way how to deal with it in DTS backward compatible way. So clock and UART driver shares mutex for accessing these two shared registers, and these two registers are defined in all 3 DT nodes: UART1, UART2 and UART-clock.
That's awful. I guess I don't have a better suggestion.
Rob