Skip to contentSkip to conversation

serial: add skipping init option

PATCH New Jun Nie 3 participants 10 messages Mar 22, 2019 – Apr 2, 2019

lore
Share & tools
lore

Jun Nie

author
#0 lore raw

PATCH 1/2 serial: add skipping init option

add skipping init option to avoid corrupt data in console if serial is already initilized when u-boot start its excution.

---
 drivers/serial/Kconfig | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/serial/Kconfig +6 -0
index 887cd68..7aeaffb 100644
@@ -459,6 +459,12 @@ config DEBUG_UART_NS16550_CHECK_ENABLED
 	  Note that this does not work for every ns16550-compatible UART and
 	  so has to be enabled carefully or you might notice lost characters.
 
+config UART_SKIP_INIT
+       bool "Skip UART initialization"
+       help
+         Select this if the UART you want to use for output is already
+         initialized by the time U-Boot starts its execution.
+
 config ALTERA_JTAG_UART
 	bool "Altera JTAG UART support"
 	depends on DM_SERIAL
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 2/2 imx: serial_mxc: skip uart initilization

Skip uart initilization if CONFIG_UART_SKIP_INIT is defined. That's means earlier firmware already initialized the uart.

---
 drivers/serial/serial_mxc.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/serial/serial_mxc.c +4 -0
index 476df25..01c97a4 100644
@@ -231,9 +231,11 @@ static int mxc_serial_tstc(void)
  */
 static int mxc_serial_init(void)
 {
+#ifndef CONFIG_UART_SKIP_INIT
 	_mxc_serial_init(mxc_base, false);
 
 	serial_setbrg();
+#endif
 
 	return 0;
 }
@@ -276,7 +278,9 @@ static int mxc_serial_probe(struct udevice *dev)
 {
 	struct mxc_serial_platdata *plat = dev->platdata;
 
+#ifndef CONFIG_UART_SKIP_INIT
 	_mxc_serial_init(plat->reg, plat->use_dte);
+#endif
 
 	return 0;
 }
Signature · 1 line
2.7.4
#2 lore raw

PATCH 1/2 serial: add skipping init option

In reply to Jun Nie

Hi Jun,

Quoted 8 lines · Jun Nie

add skipping init option to avoid corrupt data in console if serial is already initilized when u-boot start its excution.

---
 drivers/serial/Kconfig | 6 ++++++
 1 file changed, 6 insertions(+)

Could we use a device-tree property for this? Some UARTs have a 'skip-init' property.

Regards,
Simon

author
#3 lore raw

PATCH 1/2 serial: add skipping init option

Quoted 13 lines · Simon Glass <[email protected]> 于2019年3月22日周五 下午3:56写道:

Hi Jun,

Quoted 8 lines · Jun Nie

add skipping init option to avoid corrupt data in console if serial is already initilized when u-boot start its excution.

---
 drivers/serial/Kconfig | 6 ++++++
 1 file changed, 6 insertions(+)
Quoted 5 lines

Could we use a device-tree property for this? Some UARTs have a 'skip-init' property.

Regards,
Simon

Hi Simon,

It is a good suggestion. But device tree is board specific, while the config is boot flow specific. For ATF -> OPTEE -> U-BOOT case, initialization should be skipped. Without earlier initialization from firmware, U-boot should do it by itself. So I need find a solution that is defconfig specific, instead of device tree specific.

Regards.
Jun

#4 lore raw

PATCH 1/2 serial: add skipping init option

Hi Jun,

Quoted 21 lines · Jun Nie
Quoted 13 lines · Simon Glass <[email protected]> 于2019年3月22日周五 下午3:56写道:

Hi Jun,

Quoted 8 lines · Jun Nie

add skipping init option to avoid corrupt data in console if serial is already initilized when u-boot start its excution.

---
 drivers/serial/Kconfig | 6 ++++++
 1 file changed, 6 insertions(+)
Quoted 5 lines

Could we use a device-tree property for this? Some UARTs have a 'skip-init' property.

Regards,
Simon

Quoted 7 lines

Hi Simon,

It is a good suggestion. But device tree is board specific, while the config is boot flow specific. For ATF -> OPTEE -> U-BOOT case, initialization should be skipped. Without earlier initialization from firmware, U-boot should do it by itself. So I need find a solution that is defconfig specific, instead of device tree specific.

So you want something that is flow-specific, I think. Your thinking is that the defconfig specifies this. Is that because certain boards require ATF/Optee?

Should we consider having a way to tell U-Boot that it is running from Optee?

Could the UART driver detect that the UART is already inited?

Regards,
Simon

#5 lore raw

PATCH 1/2 serial: add skipping init option

Hi Simon, Jun,

Quoted 34 lines

Hi Jun,

Quoted 22 lines · Jun Nie
Quoted 14 lines · Simon Glass <[email protected]> 于2019年3月22日周五 下午3:56写道:

Hi Jun,

Quoted 8 lines · Jun Nie

add skipping init option to avoid corrupt data in console if serial is already initilized when u-boot start its excution.

---
 drivers/serial/Kconfig | 6 ++++++
 1 file changed, 6 insertions(+)  
Quoted 5 lines

Could we use a device-tree property for this? Some UARTs have a 'skip-init' property.

Regards,
Simon

Quoted 8 lines

Hi Simon,

It is a good suggestion. But device tree is board specific, while the config is boot flow specific. For ATF -> OPTEE -> U-BOOT case, initialization should be skipped. Without earlier initialization from firmware, U-boot should do it by itself. So I need find a solution that is defconfig specific, instead of device tree specific.

Quoted 8 lines

So you want something that is flow-specific, I think. Your thinking is that the defconfig specifies this. Is that because certain boards require ATF/Optee?

Should we consider having a way to tell U-Boot that it is running from Optee?

Could the UART driver detect that the UART is already inited?

Isn't this issue similar to:
http://patchwork.ozlabs.org/patch/820824/

and

http://patchwork.ozlabs.org/patch/865963/

Quoted 7 lines

Regards,
Simon
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190327/a0f278e7/attachment.sig>

author
#6 lore raw

PATCH 1/2 serial: add skipping init option

Quoted 44 lines · Lukasz Majewski <[email protected]> 于2019年3月27日周三 下午5:34写道:

Hi Simon, Jun,

Quoted 41 lines

Hi Jun,

Quoted 22 lines · Jun Nie
Quoted 14 lines · Simon Glass <[email protected]> 于2019年3月22日周五 下午3:56写道:

Hi Jun,

Quoted 8 lines · Jun Nie

add skipping init option to avoid corrupt data in console if serial is already initilized when u-boot start its excution.

---
 drivers/serial/Kconfig | 6 ++++++
 1 file changed, 6 insertions(+)
Quoted 5 lines

Could we use a device-tree property for this? Some UARTs have a 'skip-init' property.

Regards,
Simon

Quoted 8 lines

Hi Simon,

It is a good suggestion. But device tree is board specific, while the config is boot flow specific. For ATF -> OPTEE -> U-BOOT case, initialization should be skipped. Without earlier initialization from firmware, U-boot should do it by itself. So I need find a solution that is defconfig specific, instead of device tree specific.

So you want something that is flow-specific, I think. Your thinking is that the defconfig specifies this. Is that because certain boards require ATF/Optee?

Should we consider having a way to tell U-Boot that it is running from Optee?

Quoted 9 lines
Quoted 1 line

Could the UART driver detect that the UART is already inited?

Isn't this issue similar to:
http://patchwork.ozlabs.org/patch/820824/

and

http://patchwork.ozlabs.org/patch/865963/

My case is that console does not emit any log when OPTEE runs into u-boot. I already root caused that there is a bug in uart clock handling. UART1_CLK_ROOT
is hard coded in imx_get_uartclk() of arch/arm/mach-imx/mx7/clock.c If the console serial is not UART1, 0 may be returned and console does not work.

But when I add an IMX_UART_PORT config option in Kconfig to dynamic configure the CLK_ROOT ID as below, the expansion result is UARTCONFIG_IMX_UART_PORT_CLK_ROOT instead of UART1_CLK_ROOT.
It seems macro expansion happens before the inclusion of defconfig. Do you see any better idea other than add the definition in include/configs/pico-imx7d.h directly?

#define IMX_UART_CLK_ROOT UART##CONFIG_IMX_UART_PORT##_CLK_ROOT

Current plan is to add below change so that platform can define different clock root other
than UART1_CLK_ROOT.

+++ b/arch/arm/mach-imx/mx7/clock.c
@@ -51,9 +51,12 @@ static u32 get_ipg_clk(void)

        return get_ahb_clk() / 2;

}

+#ifndef UART_CLK_ROOT
+#define UART_CLK_ROOT UART1_CLK_ROOT
+#endif
u32 imx_get_uartclk(void)
{
- return get_root_clk(UART1_CLK_ROOT);
+ return get_root_clk(UART_CLK_ROOT);
}

Quoted 20 lines
Quoted 7 lines

Regards,
Simon
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de

#7 lore raw

PATCH 1/2 serial: add skipping init option

Hi Jun,

Quoted 78 lines · Jun Nie
Quoted 44 lines · Lukasz Majewski <[email protected]> 于2019年3月27日周三 下午5:34写道:

Hi Simon, Jun,

Quoted 41 lines

Hi Jun,

Quoted 22 lines · Jun Nie
Quoted 14 lines · Simon Glass <[email protected]> 于2019年3月22日周五 下午3:56写道:

Hi Jun,

Quoted 8 lines · Jun Nie

add skipping init option to avoid corrupt data in console if serial is already initilized when u-boot start its excution.

---
 drivers/serial/Kconfig | 6 ++++++
 1 file changed, 6 insertions(+)
Quoted 5 lines

Could we use a device-tree property for this? Some UARTs have a 'skip-init' property.

Regards,
Simon

Quoted 8 lines

Hi Simon,

It is a good suggestion. But device tree is board specific, while the config is boot flow specific. For ATF -> OPTEE -> U-BOOT case, initialization should be skipped. Without earlier initialization from firmware, U-boot should do it by itself. So I need find a solution that is defconfig specific, instead of device tree specific.

So you want something that is flow-specific, I think. Your thinking is that the defconfig specifies this. Is that because certain boards require ATF/Optee?

Should we consider having a way to tell U-Boot that it is running from Optee?

Quoted 9 lines
Quoted 1 line

Could the UART driver detect that the UART is already inited?

Isn't this issue similar to:
http://patchwork.ozlabs.org/patch/820824/

and

http://patchwork.ozlabs.org/patch/865963/

My case is that console does not emit any log when OPTEE runs into u-boot. I already root caused that there is a bug in uart clock handling. UART1_CLK_ROOT
is hard coded in imx_get_uartclk() of arch/arm/mach-imx/mx7/clock.c If the console serial is not UART1, 0 may be returned and console does not work.

But when I add an IMX_UART_PORT config option in Kconfig to dynamic configure the CLK_ROOT ID as below, the expansion result is UARTCONFIG_IMX_UART_PORT_CLK_ROOT instead of UART1_CLK_ROOT.
It seems macro expansion happens before the inclusion of defconfig. Do you see any better idea other than add the definition in include/configs/pico-imx7d.h directly?

#define IMX_UART_CLK_ROOT UART##CONFIG_IMX_UART_PORT##_CLK_ROOT

Current plan is to add below change so that platform can define different clock root other
than UART1_CLK_ROOT.

+++ b/arch/arm/mach-imx/mx7/clock.c

(quoted diff) +0 -0
@@ -51,9 +51,12 @@ static u32 get_ipg_clk(void)
        return get_ahb_clk() / 2;
 }

Review static u32 get_ipg_clk(void) · line 61

Quoted 10 lines
(quoted diff) +4 -1
 
+#ifndef UART_CLK_ROOT
+#define UART_CLK_ROOT UART1_CLK_ROOT
+#endif
 u32 imx_get_uartclk(void)
 {
-       return get_root_clk(UART1_CLK_ROOT);
+       return get_root_clk(UART_CLK_ROOT);
 }
 

I'm not very knowledgeable on this platform. This seems OK to me but you should send a patch for iMX people to review.

Regards,
Simon

#8 lore raw

PATCH 1/2 serial: add skipping init option

In reply to Lukasz Majewski

Hi Lukasz,

Quoted 44 lines · Lukasz Majewski

Hi Simon, Jun,

Quoted 41 lines

Hi Jun,

Quoted 22 lines · Jun Nie
Quoted 14 lines · Simon Glass <[email protected]> 于2019年3月22日周五 下午3:56写道:

Hi Jun,

Quoted 8 lines · Jun Nie

add skipping init option to avoid corrupt data in console if serial is already initilized when u-boot start its excution.

---
 drivers/serial/Kconfig | 6 ++++++
 1 file changed, 6 insertions(+)
Quoted 5 lines

Could we use a device-tree property for this? Some UARTs have a 'skip-init' property.

Regards,
Simon

Quoted 8 lines

Hi Simon,

It is a good suggestion. But device tree is board specific, while the config is boot flow specific. For ATF -> OPTEE -> U-BOOT case, initialization should be skipped. Without earlier initialization from firmware, U-boot should do it by itself. So I need find a solution that is defconfig specific, instead of device tree specific.

So you want something that is flow-specific, I think. Your thinking is that the defconfig specifies this. Is that because certain boards require ATF/Optee?

Should we consider having a way to tell U-Boot that it is running from Optee?

Quoted 9 lines
Quoted 1 line

Could the UART driver detect that the UART is already inited?

Isn't this issue similar to:
http://patchwork.ozlabs.org/patch/820824/

and

http://patchwork.ozlabs.org/patch/865963/

Yes. But in the case of this patch I'm hoping we don't need it.

Regards,
Simon

author
#9 lore raw

PATCH 1/2 serial: add skipping init option

Quoted 55 lines · Simon Glass <[email protected]> 于2019年3月31日周日 上午5:19写道:

Hi Lukasz,

Quoted 51 lines · Lukasz Majewski

Hi Simon, Jun,

Quoted 34 lines

Hi Jun,

Quoted 22 lines · Jun Nie
Quoted 14 lines · Simon Glass <[email protected]> 于2019年3月22日周五 下午3:56写道:

Hi Jun,

Quoted 8 lines · Jun Nie

add skipping init option to avoid corrupt data in console if serial is already initilized when u-boot start its excution.

---
 drivers/serial/Kconfig | 6 ++++++
 1 file changed, 6 insertions(+)
Quoted 5 lines

Could we use a device-tree property for this? Some UARTs have a 'skip-init' property.

Regards,
Simon

Quoted 8 lines

Hi Simon,

It is a good suggestion. But device tree is board specific, while the config is boot flow specific. For ATF -> OPTEE -> U-BOOT case, initialization should be skipped. Without earlier initialization from firmware, U-boot should do it by itself. So I need find a solution that is defconfig specific, instead of device tree specific.

Quoted 8 lines

So you want something that is flow-specific, I think. Your thinking is that the defconfig specifies this. Is that because certain boards require ATF/Optee?

Should we consider having a way to tell U-Boot that it is running from Optee?

Could the UART driver detect that the UART is already inited?

Isn't this issue similar to:
http://patchwork.ozlabs.org/patch/820824/

and

Quoted 7 lines
Quoted 2 lines

http://patchwork.ozlabs.org/patch/865963/

Yes. But in the case of this patch I'm hoping we don't need it.

Regards,
Simon

Right, we do not need patch here to skip the initialization. I already add the fix in imx clock side to imx patch set. Thank for suggestion!

Jun