All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] serial: mps2-uart: Initialize early console
@ 2018-06-19  4:54 ` Guenter Roeck
  0 siblings, 0 replies; 6+ messages in thread
From: Guenter Roeck @ 2018-06-19  4:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, Vladimir Murzin, linux-serial, linux-arm-kernel,
	linux-kernel, Liviu Dudau, Sudeep Holla, Lorenzo Pieralisi,
	Guenter Roeck

The early console code for mps2-uart assumes that the serial hardware is
enabled for transmit when the system boots. However, this is not the case
after reset. This results in a hang in mps2_early_putchar() if the serial
transmitter is not enabled by a boot loader or ROM monitor.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/tty/serial/mps2-uart.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/tty/serial/mps2-uart.c b/drivers/tty/serial/mps2-uart.c
index 9f8f63719126..0743a0551ce1 100644
--- a/drivers/tty/serial/mps2-uart.c
+++ b/drivers/tty/serial/mps2-uart.c
@@ -448,6 +448,14 @@ static struct console mps2_uart_console = {
 
 #define MPS2_SERIAL_CONSOLE (&mps2_uart_console)
 
+static void mps2_early_init(struct uart_port *port)
+{
+	u8 control = readb(port->membase + UARTn_CTRL);
+
+	control |= UARTn_CTRL_TX_ENABLE;
+	writeb(control, port->membase + UARTn_CTRL);
+}
+
 static void mps2_early_putchar(struct uart_port *port, int ch)
 {
 	while (readb(port->membase + UARTn_STATE) & UARTn_STATE_TX_FULL)
@@ -469,6 +477,7 @@ static int __init mps2_early_console_setup(struct earlycon_device *device,
 	if (!device->port.membase)
 		return -ENODEV;
 
+	mps2_early_init(&device->port);
 	device->con->write = mps2_early_write;
 
 	return 0;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] serial: mps2-uart: Initialize early console
@ 2018-06-19  4:54 ` Guenter Roeck
  0 siblings, 0 replies; 6+ messages in thread
From: Guenter Roeck @ 2018-06-19  4:54 UTC (permalink / raw)
  To: linux-arm-kernel

The early console code for mps2-uart assumes that the serial hardware is
enabled for transmit when the system boots. However, this is not the case
after reset. This results in a hang in mps2_early_putchar() if the serial
transmitter is not enabled by a boot loader or ROM monitor.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/tty/serial/mps2-uart.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/tty/serial/mps2-uart.c b/drivers/tty/serial/mps2-uart.c
index 9f8f63719126..0743a0551ce1 100644
--- a/drivers/tty/serial/mps2-uart.c
+++ b/drivers/tty/serial/mps2-uart.c
@@ -448,6 +448,14 @@ static struct console mps2_uart_console = {
 
 #define MPS2_SERIAL_CONSOLE (&mps2_uart_console)
 
+static void mps2_early_init(struct uart_port *port)
+{
+	u8 control = readb(port->membase + UARTn_CTRL);
+
+	control |= UARTn_CTRL_TX_ENABLE;
+	writeb(control, port->membase + UARTn_CTRL);
+}
+
 static void mps2_early_putchar(struct uart_port *port, int ch)
 {
 	while (readb(port->membase + UARTn_STATE) & UARTn_STATE_TX_FULL)
@@ -469,6 +477,7 @@ static int __init mps2_early_console_setup(struct earlycon_device *device,
 	if (!device->port.membase)
 		return -ENODEV;
 
+	mps2_early_init(&device->port);
 	device->con->write = mps2_early_write;
 
 	return 0;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] serial: mps2-uart: Initialize early console
  2018-06-19  4:54 ` Guenter Roeck
@ 2018-06-19  9:07   ` Vladimir Murzin
  -1 siblings, 0 replies; 6+ messages in thread
From: Vladimir Murzin @ 2018-06-19  9:07 UTC (permalink / raw)
  To: Guenter Roeck, Greg Kroah-Hartman
  Cc: Jiri Slaby, linux-serial, linux-arm-kernel, linux-kernel,
	Liviu Dudau, Sudeep Holla, Lorenzo Pieralisi

Hi Guenter,

On 19/06/18 05:54, Guenter Roeck wrote:
> The early console code for mps2-uart assumes that the serial hardware is
> enabled for transmit when the system boots. However, this is not the case
> after reset. This results in a hang in mps2_early_putchar() if the serial
> transmitter is not enabled by a boot loader or ROM monitor.

I was under impression that for earlycon there is an assumption/requirement
that the serial port must already be setup and configured. For instance, I 
see such requirement for pl011. So it looks like boot code's fault not to
enable serial (for mps2 it needs to setup BAUDDIV as well).

I'm not against the patch per se, but I'd like to hear if my understanding of
earlycon requirements is correct or not.

Cheers
Vladimir

> 
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  drivers/tty/serial/mps2-uart.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/tty/serial/mps2-uart.c b/drivers/tty/serial/mps2-uart.c
> index 9f8f63719126..0743a0551ce1 100644
> --- a/drivers/tty/serial/mps2-uart.c
> +++ b/drivers/tty/serial/mps2-uart.c
> @@ -448,6 +448,14 @@ static struct console mps2_uart_console = {
>  
>  #define MPS2_SERIAL_CONSOLE (&mps2_uart_console)
>  
> +static void mps2_early_init(struct uart_port *port)
> +{
> +	u8 control = readb(port->membase + UARTn_CTRL);
> +
> +	control |= UARTn_CTRL_TX_ENABLE;
> +	writeb(control, port->membase + UARTn_CTRL);
> +}
> +
>  static void mps2_early_putchar(struct uart_port *port, int ch)
>  {
>  	while (readb(port->membase + UARTn_STATE) & UARTn_STATE_TX_FULL)
> @@ -469,6 +477,7 @@ static int __init mps2_early_console_setup(struct earlycon_device *device,
>  	if (!device->port.membase)
>  		return -ENODEV;
>  
> +	mps2_early_init(&device->port);
>  	device->con->write = mps2_early_write;
>  
>  	return 0;
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] serial: mps2-uart: Initialize early console
@ 2018-06-19  9:07   ` Vladimir Murzin
  0 siblings, 0 replies; 6+ messages in thread
From: Vladimir Murzin @ 2018-06-19  9:07 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Guenter,

On 19/06/18 05:54, Guenter Roeck wrote:
> The early console code for mps2-uart assumes that the serial hardware is
> enabled for transmit when the system boots. However, this is not the case
> after reset. This results in a hang in mps2_early_putchar() if the serial
> transmitter is not enabled by a boot loader or ROM monitor.

I was under impression that for earlycon there is an assumption/requirement
that the serial port must already be setup and configured. For instance, I 
see such requirement for pl011. So it looks like boot code's fault not to
enable serial (for mps2 it needs to setup BAUDDIV as well).

I'm not against the patch per se, but I'd like to hear if my understanding of
earlycon requirements is correct or not.

Cheers
Vladimir

> 
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  drivers/tty/serial/mps2-uart.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/tty/serial/mps2-uart.c b/drivers/tty/serial/mps2-uart.c
> index 9f8f63719126..0743a0551ce1 100644
> --- a/drivers/tty/serial/mps2-uart.c
> +++ b/drivers/tty/serial/mps2-uart.c
> @@ -448,6 +448,14 @@ static struct console mps2_uart_console = {
>  
>  #define MPS2_SERIAL_CONSOLE (&mps2_uart_console)
>  
> +static void mps2_early_init(struct uart_port *port)
> +{
> +	u8 control = readb(port->membase + UARTn_CTRL);
> +
> +	control |= UARTn_CTRL_TX_ENABLE;
> +	writeb(control, port->membase + UARTn_CTRL);
> +}
> +
>  static void mps2_early_putchar(struct uart_port *port, int ch)
>  {
>  	while (readb(port->membase + UARTn_STATE) & UARTn_STATE_TX_FULL)
> @@ -469,6 +477,7 @@ static int __init mps2_early_console_setup(struct earlycon_device *device,
>  	if (!device->port.membase)
>  		return -ENODEV;
>  
> +	mps2_early_init(&device->port);
>  	device->con->write = mps2_early_write;
>  
>  	return 0;
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] serial: mps2-uart: Initialize early console
  2018-06-19  9:07   ` Vladimir Murzin
@ 2018-06-19 13:01     ` Guenter Roeck
  -1 siblings, 0 replies; 6+ messages in thread
From: Guenter Roeck @ 2018-06-19 13:01 UTC (permalink / raw)
  To: Vladimir Murzin, Greg Kroah-Hartman
  Cc: Jiri Slaby, linux-serial, linux-arm-kernel, linux-kernel,
	Liviu Dudau, Sudeep Holla, Lorenzo Pieralisi

On 06/19/2018 02:07 AM, Vladimir Murzin wrote:
> Hi Guenter,
> 
> On 19/06/18 05:54, Guenter Roeck wrote:
>> The early console code for mps2-uart assumes that the serial hardware is
>> enabled for transmit when the system boots. However, this is not the case
>> after reset. This results in a hang in mps2_early_putchar() if the serial
>> transmitter is not enabled by a boot loader or ROM monitor.
> 
> I was under impression that for earlycon there is an assumption/requirement
> that the serial port must already be setup and configured. For instance, I
> see such requirement for pl011. So it looks like boot code's fault not to
> enable serial (for mps2 it needs to setup BAUDDIV as well).
> 

Good to know. Fine with me as well; I wasn't aware that such a requirement
existed.

Guenter

> I'm not against the patch per se, but I'd like to hear if my understanding of
> earlycon requirements is correct or not.
> 
> Cheers
> Vladimir
> 
>>
>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>> ---
>>   drivers/tty/serial/mps2-uart.c | 9 +++++++++
>>   1 file changed, 9 insertions(+)
>>
>> diff --git a/drivers/tty/serial/mps2-uart.c b/drivers/tty/serial/mps2-uart.c
>> index 9f8f63719126..0743a0551ce1 100644
>> --- a/drivers/tty/serial/mps2-uart.c
>> +++ b/drivers/tty/serial/mps2-uart.c
>> @@ -448,6 +448,14 @@ static struct console mps2_uart_console = {
>>   
>>   #define MPS2_SERIAL_CONSOLE (&mps2_uart_console)
>>   
>> +static void mps2_early_init(struct uart_port *port)
>> +{
>> +	u8 control = readb(port->membase + UARTn_CTRL);
>> +
>> +	control |= UARTn_CTRL_TX_ENABLE;
>> +	writeb(control, port->membase + UARTn_CTRL);
>> +}
>> +
>>   static void mps2_early_putchar(struct uart_port *port, int ch)
>>   {
>>   	while (readb(port->membase + UARTn_STATE) & UARTn_STATE_TX_FULL)
>> @@ -469,6 +477,7 @@ static int __init mps2_early_console_setup(struct earlycon_device *device,
>>   	if (!device->port.membase)
>>   		return -ENODEV;
>>   
>> +	mps2_early_init(&device->port);
>>   	device->con->write = mps2_early_write;
>>   
>>   	return 0;
>>
> 
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] serial: mps2-uart: Initialize early console
@ 2018-06-19 13:01     ` Guenter Roeck
  0 siblings, 0 replies; 6+ messages in thread
From: Guenter Roeck @ 2018-06-19 13:01 UTC (permalink / raw)
  To: linux-arm-kernel

On 06/19/2018 02:07 AM, Vladimir Murzin wrote:
> Hi Guenter,
> 
> On 19/06/18 05:54, Guenter Roeck wrote:
>> The early console code for mps2-uart assumes that the serial hardware is
>> enabled for transmit when the system boots. However, this is not the case
>> after reset. This results in a hang in mps2_early_putchar() if the serial
>> transmitter is not enabled by a boot loader or ROM monitor.
> 
> I was under impression that for earlycon there is an assumption/requirement
> that the serial port must already be setup and configured. For instance, I
> see such requirement for pl011. So it looks like boot code's fault not to
> enable serial (for mps2 it needs to setup BAUDDIV as well).
> 

Good to know. Fine with me as well; I wasn't aware that such a requirement
existed.

Guenter

> I'm not against the patch per se, but I'd like to hear if my understanding of
> earlycon requirements is correct or not.
> 
> Cheers
> Vladimir
> 
>>
>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>> ---
>>   drivers/tty/serial/mps2-uart.c | 9 +++++++++
>>   1 file changed, 9 insertions(+)
>>
>> diff --git a/drivers/tty/serial/mps2-uart.c b/drivers/tty/serial/mps2-uart.c
>> index 9f8f63719126..0743a0551ce1 100644
>> --- a/drivers/tty/serial/mps2-uart.c
>> +++ b/drivers/tty/serial/mps2-uart.c
>> @@ -448,6 +448,14 @@ static struct console mps2_uart_console = {
>>   
>>   #define MPS2_SERIAL_CONSOLE (&mps2_uart_console)
>>   
>> +static void mps2_early_init(struct uart_port *port)
>> +{
>> +	u8 control = readb(port->membase + UARTn_CTRL);
>> +
>> +	control |= UARTn_CTRL_TX_ENABLE;
>> +	writeb(control, port->membase + UARTn_CTRL);
>> +}
>> +
>>   static void mps2_early_putchar(struct uart_port *port, int ch)
>>   {
>>   	while (readb(port->membase + UARTn_STATE) & UARTn_STATE_TX_FULL)
>> @@ -469,6 +477,7 @@ static int __init mps2_early_console_setup(struct earlycon_device *device,
>>   	if (!device->port.membase)
>>   		return -ENODEV;
>>   
>> +	mps2_early_init(&device->port);
>>   	device->con->write = mps2_early_write;
>>   
>>   	return 0;
>>
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-06-19 13:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-19  4:54 [PATCH] serial: mps2-uart: Initialize early console Guenter Roeck
2018-06-19  4:54 ` Guenter Roeck
2018-06-19  9:07 ` Vladimir Murzin
2018-06-19  9:07   ` Vladimir Murzin
2018-06-19 13:01   ` Guenter Roeck
2018-06-19 13:01     ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.