serial: a37xx: Use CONFIG_BAUDRATE for initializing early debug UART
PATCH 1/2 serial: a37xx: Use CONFIG_BAUDRATE for initializing early debug UART
CONFIG_BAUDRATE should be used for setting the baudrate for the early debug UART. This replaces current hardcoded 115200 value.
--- drivers/serial/serial_mvebu_a3700.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/serial/serial_mvebu_a3700.c +2 -3
@@ -309,7 +309,7 @@ U_BOOT_DRIVER(serial_mvebu) = {static inline void _debug_uart_init (void ) {void __iomem *base = (void __iomem *)CONFIG_DEBUG_UART_BASE ; -u32 baudrate, parent_rate, divider; +u32 parent_rate, divider;/* reset FIFOs */ writel(UART_CTRL_RXFIFO_RESET | UART_CTRL_TXFIFO_RESET,
@@ -322,9 +322,8 @@ static inline void _debug_uart_init(void)* Calculate divider * baudrate = clock / 16 / divider */ - baudrate =115200 ; parent_rate =get_ref_clk () *1000000 ; - divider =DIV_ROUND_CLOSEST (parent_rate, baudrate *16 ); + divider =DIV_ROUND_CLOSEST (parent_rate,CONFIG_BAUDRATE *16 );writel (divider, base +UART_BAUD_REG );/*
Signature · 1 line
2.20.1
PATCH 2/2 serial: a37xx: Do not call get_ref_clk() in _debug_uart_init()
Static inline function _debug_uart_init() should avoid calling external (non-inline) functions. Therefore do not call get_ref_clk() in _debug_uart_init() and reimplement its functionality without external function calls.
--- drivers/serial/serial_mvebu_a3700.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/serial/serial_mvebu_a3700.c +3 -1
@@ -305,6 +305,7 @@ U_BOOT_DRIVER(serial_mvebu) = {#ifdef CONFIG_DEBUG_MVEBU_A3700_UART #include <debug_uart.h> +#include <mach/soc.h> static inline void _debug_uart_init (void ) {
@@ -322,7 +323,8 @@ static inline void _debug_uart_init(void)* Calculate divider * baudrate = clock / 16 / divider */ - parent_rate =get_ref_clk () *1000000 ; + parent_rate = (readl (MVEBU_REGISTER (0x13808 )) &BIT (9 )) ? +40000000 :25000000 ; divider =DIV_ROUND_CLOSEST (parent_rate,CONFIG_BAUDRATE *16 );writel (divider, base +UART_BAUD_REG );
Signature · 1 line
2.20.1
Re: [PATCH 2/2] serial: a37xx: Do not call get_ref_clk() in _debug_uart_init()
Quoted 2 lines · On Mon, 26 Jul 2021 14:58:59 +0200 Pali Rohár <[email protected]> wrote:
Static inline function
_debug_uart_init()should avoid calling external (non-inline) functions.
Why?
Re: [PATCH 2/2] serial: a37xx: Do not call get_ref_clk() in _debug_uart_init()
Quoted 7 lines · On Monday 26 July 2021 16:55:22 Marek Behun wrote:
Quoted 2 lines · On Mon, 26 Jul 2021 14:58:59 +0200 Pali Rohár <[email protected]> wrote:
Static inline function
_debug_uart_init()should avoid calling external (non-inline) functions.Why?
Function is called in stage when stack is not fully initialized and documentation suggest to avoid stack usage and other functions.
Re: [PATCH 2/2] serial: a37xx: Do not call get_ref_clk() in _debug_uart_init()
Quoted 11 lines · On Mon, 26 Jul 2021 16:58:04 +0200 Pali Rohár <[email protected]> wrote:
Quoted 7 lines · On Monday 26 July 2021 16:55:22 Marek Behun wrote:
Quoted 2 lines · On Mon, 26 Jul 2021 14:58:59 +0200 Pali Rohár <[email protected]> wrote:
Static inline function
_debug_uart_init()should avoid calling external (non-inline) functions.Why?
Function is called in stage when stack is not fully initialized and documentation suggest to avoid stack usage and other functions.
OK, but maybe we should use the macro names for register constants.
Could you move (in a separate patch) the corresponding macros from arch/arm/mach-mvebu/armada3700/cpu.c to arch/arm/mach-mvebu/include/mach/soc.h and then in this patch include <asm/arch/soc.h> in the serial driver and use the constant names?
Thanks.
Marek
Re: [PATCH 2/2] serial: a37xx: Do not call get_ref_clk() in _debug_uart_init()
Quoted 15 lines · On Monday 26 July 2021 17:24:26 Marek Behun wrote:
Quoted 11 lines · On Mon, 26 Jul 2021 16:58:04 +0200 Pali Rohár <[email protected]> wrote:
Quoted 7 lines · On Monday 26 July 2021 16:55:22 Marek Behun wrote:
Quoted 2 lines · On Mon, 26 Jul 2021 14:58:59 +0200 Pali Rohár <[email protected]> wrote:
Static inline function
_debug_uart_init()should avoid calling external (non-inline) functions.Why?
Function is called in stage when stack is not fully initialized and documentation suggest to avoid stack usage and other functions.
Quoted 7 lines
OK, but maybe we should use the macro names for register constants.
Could you move (in a separate patch) the corresponding macros from
arch/arm/mach-mvebu/armada3700/cpu.ctoarch/arm/mach-mvebu/include/mach/soc.hand then in this patch include <asm/arch/soc.h> in the serial driver and use the constant names?
Implemented in separate patch as Stefan wanted:
http://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
Quoted 3 lines
Thanks.
Marek
Re: [PATCH 2/2] serial: a37xx: Do not call get_ref_clk() in _debug_uart_init()
Hi Pali,
Quoted 18 lines · Pali Rohár
Quoted 17 lines · On Monday 26 July 2021 17:24:26 Marek Behun wrote:
Quoted 11 lines · On Mon, 26 Jul 2021 16:58:04 +0200 Pali Rohár <[email protected]> wrote:
Quoted 7 lines · On Monday 26 July 2021 16:55:22 Marek Behun wrote:
Quoted 2 lines · On Mon, 26 Jul 2021 14:58:59 +0200 Pali Rohár <[email protected]> wrote:
Static inline function
_debug_uart_init()should avoid calling external (non-inline) functions.Why?
Function is called in stage when stack is not fully initialized and documentation suggest to avoid stack usage and other functions.
OK, but maybe we should use the macro names for register constants.
Quoted 8 lines
Quoted 5 lines
Could you move (in a separate patch) the corresponding macros from
arch/arm/mach-mvebu/armada3700/cpu.ctoarch/arm/mach-mvebu/include/mach/soc.hand then in this patch include <asm/arch/soc.h> in the serial driver and use the constant names?Implemented in separate patch as Stefan wanted:
http://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
Did I really want this? You're removing the macro names with this patch, and I would prefer using the defines/names instead of register numbers like here:
+#elif defined(CONFIG_ARMADA_3700)
+/* SAR values for Armada 3700 */
+#define CONFIG_SYS_REF_CLK ((readl(MVEBU_REGISTER(0x13808)) & BIT(9)) ? \
+ 40000000 : 25000000)
#endif
Or did I miss something?
Thanks,
Stefan
Re: [PATCH 2/2] serial: a37xx: Do not call get_ref_clk() in _debug_uart_init()
Quoted 39 lines · On Monday 16 August 2021 10:04:39 Stefan Roese wrote:
Hi Pali,
Quoted 17 lines · Pali Rohár
Quoted 16 lines · On Monday 26 July 2021 17:24:26 Marek Behun wrote:
Quoted 10 lines · On Mon, 26 Jul 2021 16:58:04 +0200 Pali Rohár <[email protected]> wrote:
Quoted 6 lines · On Monday 26 July 2021 16:55:22 Marek Behun wrote:
Quoted 2 lines · On Mon, 26 Jul 2021 14:58:59 +0200 Pali Rohár <[email protected]> wrote:
Static inline function
_debug_uart_init()should avoid calling external (non-inline) functions.Why?
Function is called in stage when stack is not fully initialized and documentation suggest to avoid stack usage and other functions.
OK, but maybe we should use the macro names for register constants.
Quoted 8 lines
Quoted 5 lines
Could you move (in a separate patch) the corresponding macros from
arch/arm/mach-mvebu/armada3700/cpu.ctoarch/arm/mach-mvebu/include/mach/soc.hand then in this patch include <asm/arch/soc.h> in the serial driver and use the constant names?Implemented in separate patch as Stefan wanted:
http://patchwork.ozlabs.org/project/uboot/patch/[email protected]/Did I really want this? You're removing the macro names with this patch, and I would prefer using the defines/names instead of register numbers like here:
(quoted diff) +4
-0+#elif defined(CONFIG_ARMADA_3700) +/* SAR values for Armada 3700 */ +#define CONFIG_SYS_REF_CLK ((readl(MVEBU_REGISTER(0x13808)) & BIT(9)) ? \ + 40000000 : 25000000) #endif
Quoted 4 lines
Or did I miss something?
Thanks,
Stefan
It is global include header file, so I though it would be better to not export lot of other macros which are relevant only for CONFIG_SYS_REF_CLK
But if you want to see names, I can change it e.g. to:
+#elif defined(CONFIG_ARMADA_3700)
+/* SAR values for Armada 3700 */
+#define MVEBU_TEST_PIN_LATCH_N MVEBU_REGISTER(0x13808)
+#define MVEBU_XTAL_MODE_MASK BIT(9)
+#define CONFIG_SYS_REF_CLK ((readl(MVEBU_TEST_PIN_LATCH_N) & MVEBU_XTAL_MODE_MASK) ? \
+ 40000000 : 25000000)
Re: [PATCH 2/2] serial: a37xx: Do not call get_ref_clk() in _debug_uart_init()
Quoted 51 lines · Pali Rohár
Quoted 39 lines · On Monday 16 August 2021 10:04:39 Stefan Roese wrote:
Hi Pali,
Quoted 17 lines · Pali Rohár
Quoted 16 lines · On Monday 26 July 2021 17:24:26 Marek Behun wrote:
Quoted 10 lines · On Mon, 26 Jul 2021 16:58:04 +0200 Pali Rohár <[email protected]> wrote:
Quoted 6 lines · On Monday 26 July 2021 16:55:22 Marek Behun wrote:
Quoted 2 lines · On Mon, 26 Jul 2021 14:58:59 +0200 Pali Rohár <[email protected]> wrote:
Static inline function
_debug_uart_init()should avoid calling external (non-inline) functions.Why?
Function is called in stage when stack is not fully initialized and documentation suggest to avoid stack usage and other functions.
OK, but maybe we should use the macro names for register constants.
Quoted 8 lines
Quoted 5 lines
Could you move (in a separate patch) the corresponding macros from
arch/arm/mach-mvebu/armada3700/cpu.ctoarch/arm/mach-mvebu/include/mach/soc.hand then in this patch include <asm/arch/soc.h> in the serial driver and use the constant names?Implemented in separate patch as Stefan wanted:
http://patchwork.ozlabs.org/project/uboot/patch/[email protected]/Did I really want this? You're removing the macro names with this patch, and I would prefer using the defines/names instead of register numbers like here:
(quoted diff) +4
-0+#elif defined(CONFIG_ARMADA_3700) +/* SAR values for Armada 3700 */ +#define CONFIG_SYS_REF_CLK ((readl(MVEBU_REGISTER(0x13808)) & BIT(9)) ? \ + 40000000 : 25000000) #endifQuoted 4 lines
Or did I miss something?
Thanks,
StefanIt is global include header file, so I though it would be better to not export lot of other macros which are relevant only for
CONFIG_SYS_REF_CLKBut if you want to see names, I can change it e.g. to:
Review
Quoted 6 lines
(quoted diff) +6
-0+#elif defined(CONFIG_ARMADA_3700) +/* SAR values for Armada 3700 */ +#define MVEBU_TEST_PIN_LATCH_N MVEBU_REGISTER(0x13808) +#define MVEBU_XTAL_MODE_MASK BIT(9) +#define CONFIG_SYS_REF_CLK ((readl(MVEBU_TEST_PIN_LATCH_N) & MVEBU_XTAL_MODE_MASK) ? \ + 40000000 : 25000000)
IMHO, this version is a bit better, as the names (hopefully) reflect the register description in the datasheet.
Thanks,
Stefan
Re: [PATCH 2/2] serial: a37xx: Do not call get_ref_clk() in _debug_uart_init()
In reply to Pali RohárQuoted 6 lines · Pali Rohár
Static inline function
_debug_uart_init()should avoid calling external (non-inline) functions. Therefore do not callget_ref_clk()in_debug_uart_init()and reimplement its functionality without external function calls.Signed-off-by Pali Rohár <[email protected]>
Apart from the comments from Marek (please in a separate patch):
Thanks,
Stefan
Quoted 18 lines
--- drivers/serial/serial_mvebu_a3700.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/serial/serial_mvebu_a3700.c +1
-0@@ -305,6 +305,7 @@ U_BOOT_DRIVER(serial_mvebu) = {#ifdef CONFIG_DEBUG_MVEBU_A3700_UART #include <debug_uart.h> +#include <mach/soc.h> static inline void _debug_uart_init (void ) {
drivers/serial/serial_mvebu_a3700.c static inline void _debug_uart_init(void) · line 330
Quoted 9 lines
drivers/serial/serial_mvebu_a3700.c +2
-1@@ -322,7 +323,8 @@ static inline void _debug_uart_init(void)* Calculate divider * baudrate = clock / 16 / divider */ - parent_rate =get_ref_clk () *1000000 ; + parent_rate = (readl (MVEBU_REGISTER (0x13808 )) &BIT (9 )) ? +40000000 :25000000 ; divider =DIV_ROUND_CLOSEST (parent_rate,CONFIG_BAUDRATE *16 );writel (divider, base +UART_BAUD_REG );
Viele Grüße,
Stefan
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
Re: [PATCH 2/2] serial: a37xx: Do not call get_ref_clk() in _debug_uart_init()
In reply to Pali RohárQuoted 6 lines · Pali Rohár
Static inline function
_debug_uart_init()should avoid calling external (non-inline) functions. Therefore do not callget_ref_clk()in_debug_uart_init()and reimplement its functionality without external function calls.Signed-off-by Pali Rohár <[email protected]>
Applied to u-boot-marvell/master
Thanks,
Stefan
Quoted 18 lines
--- drivers/serial/serial_mvebu_a3700.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/serial/serial_mvebu_a3700.c +1
-0@@ -305,6 +305,7 @@ U_BOOT_DRIVER(serial_mvebu) = {#ifdef CONFIG_DEBUG_MVEBU_A3700_UART #include <debug_uart.h> +#include <mach/soc.h> static inline void _debug_uart_init (void ) {
drivers/serial/serial_mvebu_a3700.c static inline void _debug_uart_init(void) · line 330
Quoted 9 lines
drivers/serial/serial_mvebu_a3700.c +2
-1@@ -322,7 +323,8 @@ static inline void _debug_uart_init(void)* Calculate divider * baudrate = clock / 16 / divider */ - parent_rate =get_ref_clk () *1000000 ; + parent_rate = (readl (MVEBU_REGISTER (0x13808 )) &BIT (9 )) ? +40000000 :25000000 ; divider =DIV_ROUND_CLOSEST (parent_rate,CONFIG_BAUDRATE *16 );writel (divider, base +UART_BAUD_REG );
Viele Grüße,
Stefan
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
Quoted 4 lines · On Mon, 26 Jul 2021 14:58:58 +0200 Pali Rohár <[email protected]> wrote:
CONFIG_BAUDRATEshould be used for setting the baudrate for the early debug UART. This replaces current hardcoded 115200 value.Signed-off-by Pali Rohár <[email protected]>
Quoted 4 lines · Pali Rohár
CONFIG_BAUDRATEshould be used for setting the baudrate for the early debug UART. This replaces current hardcoded 115200 value.Signed-off-by Pali Rohár <[email protected]>
Thanks,
Stefan
Quoted 19 lines
--- drivers/serial/serial_mvebu_a3700.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/serial/serial_mvebu_a3700.c +1
-1@@ -309,7 +309,7 @@ U_BOOT_DRIVER(serial_mvebu) = {static inline void _debug_uart_init (void ) {void __iomem *base = (void __iomem *)CONFIG_DEBUG_UART_BASE ; -u32 baudrate, parent_rate, divider; +u32 parent_rate, divider;/* reset FIFOs */ writel(UART_CTRL_RXFIFO_RESET | UART_CTRL_TXFIFO_RESET,
drivers/serial/serial_mvebu_a3700.c static inline void _debug_uart_init(void) · line 329
Quoted 10 lines
drivers/serial/serial_mvebu_a3700.c +1
-2@@ -322,9 +322,8 @@ static inline void _debug_uart_init(void)* Calculate divider * baudrate = clock / 16 / divider */ - baudrate =115200 ; parent_rate =get_ref_clk () *1000000 ; - divider =DIV_ROUND_CLOSEST (parent_rate, baudrate *16 ); + divider =DIV_ROUND_CLOSEST (parent_rate,CONFIG_BAUDRATE *16 );writel (divider, base +UART_BAUD_REG );/*
Viele Grüße,
Stefan
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
Quoted 4 lines · Pali Rohár
CONFIG_BAUDRATEshould be used for setting the baudrate for the early debug UART. This replaces current hardcoded 115200 value.Signed-off-by Pali Rohár <[email protected]>
Applied to u-boot-marvell/master
Thanks,
Stefan
Quoted 19 lines
--- drivers/serial/serial_mvebu_a3700.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/serial/serial_mvebu_a3700.c +1
-1@@ -309,7 +309,7 @@ U_BOOT_DRIVER(serial_mvebu) = {static inline void _debug_uart_init (void ) {void __iomem *base = (void __iomem *)CONFIG_DEBUG_UART_BASE ; -u32 baudrate, parent_rate, divider; +u32 parent_rate, divider;/* reset FIFOs */ writel(UART_CTRL_RXFIFO_RESET | UART_CTRL_TXFIFO_RESET,
drivers/serial/serial_mvebu_a3700.c static inline void _debug_uart_init(void) · line 329
Quoted 10 lines
drivers/serial/serial_mvebu_a3700.c +1
-2@@ -322,9 +322,8 @@ static inline void _debug_uart_init(void)* Calculate divider * baudrate = clock / 16 / divider */ - baudrate =115200 ; parent_rate =get_ref_clk () *1000000 ; - divider =DIV_ROUND_CLOSEST (parent_rate, baudrate *16 ); + divider =DIV_ROUND_CLOSEST (parent_rate,CONFIG_BAUDRATE *16 );writel (divider, base +UART_BAUD_REG );/*
Viele Grüße,
Stefan
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]