Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1307777 > unrolled thread

[PATCH v4 00/11] Earlycon cleanup

Started byPeter Hurley <peter@hurleysoftware.com>
First post2016-01-12 20:50 +0100
Last post2016-01-13 01:00 +0100
Articles 19 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v4 00/11] Earlycon cleanup Peter Hurley <peter@hurleysoftware.com> - 2016-01-12 20:50 +0100
    [PATCH v4 08/11] serial: earlycon: Show the earlycon "driver" in banner Peter Hurley <peter@hurleysoftware.com> - 2016-01-12 20:50 +0100
    [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon Peter Hurley <peter@hurleysoftware.com> - 2016-01-12 20:50 +0100
      Re: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon Peter Hurley <peter@hurleysoftware.com> - 2016-01-12 21:00 +0100
        Re: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon Jon Hunter <jonathanh@nvidia.com> - 2016-01-13 10:30 +0100
          Re: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon Jon Hunter <jonathanh@nvidia.com> - 2016-01-13 11:00 +0100
          Re: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon Jon Hunter <jonathanh@nvidia.com> - 2016-01-13 11:20 +0100
            Re: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon Peter Hurley <peter@hurleysoftware.com> - 2016-01-13 18:10 +0100
              Re: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon Jon Hunter <jonathanh@nvidia.com> - 2016-01-13 18:20 +0100
    [PATCH v4 10/11] of: earlycon: Log more helpful message if stdout-path node not found Peter Hurley <peter@hurleysoftware.com> - 2016-01-12 20:50 +0100
      Re: [PATCH v4 10/11] of: earlycon: Log more helpful message if  stdout-path node not found Rob Herring <robh+dt@kernel.org> - 2016-01-13 00:40 +0100
    [PATCH v4 02/11] serial: earlycon: Fixup earlycon console name and index Peter Hurley <peter@hurleysoftware.com> - 2016-01-12 20:50 +0100
    [PATCH v4 05/11] of: earlycon: Initialize port fields from DT properties Peter Hurley <peter@hurleysoftware.com> - 2016-01-12 20:50 +0100
      Re: [PATCH v4 05/11] of: earlycon: Initialize port fields from DT properties Rob Herring <robh+dt@kernel.org> - 2016-01-13 01:00 +0100
        Re: [PATCH v4 05/11] of: earlycon: Initialize port fields from DT  properties Peter Hurley <peter@hurleysoftware.com> - 2016-01-13 17:40 +0100
    [PATCH v4 06/11] of: earlycon: Move address translation to of_setup_earlycon() Peter Hurley <peter@hurleysoftware.com> - 2016-01-12 20:50 +0100
    [PATCH v4 07/11] serial: earlycon: Common log banner for command line and DT Peter Hurley <peter@hurleysoftware.com> - 2016-01-12 20:50 +0100
    [PATCH v4 09/11] serial: 8250_early: Use port->regshift Peter Hurley <peter@hurleysoftware.com> - 2016-01-12 20:50 +0100
    Re: [PATCH v4 00/11] Earlycon cleanup Rob Herring <robh+dt@kernel.org> - 2016-01-13 01:00 +0100

#1307777 — [PATCH v4 00/11] Earlycon cleanup

FromPeter Hurley <peter@hurleysoftware.com>
Date2016-01-12 20:50 +0100
Subject[PATCH v4 00/11] Earlycon cleanup
Message-ID<qQd74-5xe-7@gated-at.bofh.it>
Hi Greg, Grant & Rob,

This patch series is a rebase of the v3 from April last year.

This patch series builds on my earlier "Extensible console matching &
direct earlycon" to add several useful features to earlycon:
* Proper port i/o configuration from DT node with of_serial properties
  (such as reg-io-width, reg-shift and reg-offset, and endianness)
* Proper console name & index initialization from earlycon name
  (for both command line and DT-defined earlycons)
* Support for DT 'stdout-path' options pass-through to earlycon setup
* Improved log messages for troubleshooting
* Support for multiple OF earlycon declarations so different
  compatible strings can specify the same OF earlycon

* Changes from v3
  - Added 32-bit big-endian support
  - Removed the omap8250 earlycon (will follow later)


Rob has expressed a desire to have the DT parts live in drivers/of/fdt.c
The problem with this approach is two-fold. Firstly, the number of required
parameters quickly becomes ugly (base address, io reg width, io reg offset,
io reg stride, endianness, earlycon name). Secondly, drivers are already
requiring access to alternate DT properties, like clocks, to initialize
earlycons, and this requirement will continue.

Regards,

Peter Hurley (11):
  earlycon: Use common framework for earlycon declarations
  serial: earlycon: Fixup earlycon console name and index
  of: earlycon: Fixup earlycon console name and index
  of: earlycon: Add options string handling
  of: earlycon: Initialize port fields from DT properties
  of: earlycon: Move address translation to of_setup_earlycon()
  serial: earlycon: Common log banner for command line and DT
  serial: earlycon: Show the earlycon "driver" in banner
  serial: 8250_early: Use port->regshift
  of: earlycon: Log more helpful message if stdout-path node not found
  serial: 8250_omap: Add omap8250 earlycon

 drivers/of/fdt.c                     |  32 +++++-----
 drivers/of/fdt_address.c             |  11 +++-
 drivers/tty/serial/8250/8250_early.c |  36 +++++++++--
 drivers/tty/serial/amba-pl011.c      |   1 -
 drivers/tty/serial/arc_uart.c        |   1 -
 drivers/tty/serial/earlycon.c        | 117 ++++++++++++++++++++++++++---------
 drivers/tty/serial/msm_serial.c      |   2 -
 drivers/tty/serial/samsung.c         |   6 --
 drivers/tty/serial/sprd_serial.c     |   2 -
 include/asm-generic/vmlinux.lds.h    |   6 +-
 include/linux/of_fdt.h               |   2 +-
 include/linux/serial_core.h          |  25 +++++---
 12 files changed, 160 insertions(+), 81 deletions(-)

-- 
2.7.0

[toc] | [next] | [standalone]


#1307779 — [PATCH v4 08/11] serial: earlycon: Show the earlycon "driver" in banner

FromPeter Hurley <peter@hurleysoftware.com>
Date2016-01-12 20:50 +0100
Subject[PATCH v4 08/11] serial: earlycon: Show the earlycon "driver" in banner
Message-ID<qQd74-5xe-21@gated-at.bofh.it>
In reply to#1307777
Output the earlycon "driver" from the just-parsed console 'name'
and 'index' fields.

NB: ->mapbase is a resource_size_t so use %pa format specifier
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/earlycon.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 10a2ae3..0acb60d 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -79,16 +79,16 @@ static void __init earlycon_init(struct earlycon_device *device,
 
 	if (port->iotype == UPIO_MEM || port->iotype == UPIO_MEM16 ||
 	    port->iotype == UPIO_MEM32 || port->iotype == UPIO_MEM32BE)
-		pr_info("Early serial console at MMIO%s 0x%llx (options '%s')\n",
+		pr_info("%s%d at MMIO%s %pa (options '%s')\n",
+			earlycon->name, earlycon->index,
 			(port->iotype == UPIO_MEM) ? "" :
 			(port->iotype == UPIO_MEM16) ? "16" :
 			(port->iotype == UPIO_MEM32) ? "32" : "32be",
-			(unsigned long long)port->mapbase,
-			device->options);
+			&port->mapbase, device->options);
 	else
-		pr_info("Early serial console at I/O port 0x%lx (options '%s')\n",
-			port->iobase,
-			device->options);
+		pr_info("%s%d at I/O port 0x%lx (options '%s')\n",
+			earlycon->name, earlycon->index,
+			port->iobase, device->options);
 }
 
 static int __init parse_options(struct earlycon_device *device, char *options)
-- 
2.7.0

[toc] | [prev] | [next] | [standalone]


#1307781 — [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon

FromPeter Hurley <peter@hurleysoftware.com>
Date2016-01-12 20:50 +0100
Subject[PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon
Message-ID<qQd75-5xe-23@gated-at.bofh.it>
In reply to#1307777
Add DT earlycon for 8250_omap driver. This boot console is included
for kernels built with CONFIG_SERIAL_EARLYCON=y, CONFIG_OF=y,
CONFIG_SERIAL_8250_OMAP=y, and CONFIG_OF_EARLY_FLATTREE=y.

This boot console is enabled with the command line option "earlycon"
(without "=<name>...") when the DT 'stdout-path' property matches a
compatible uart. For example,

/ {
   chosen {
        stdout-path = "serial0:115200";
   };

   ....

   aliases {
        serial0 = &uart0;
   };

   ....

   ocp : ocp {
        uart0 : serial@44e09000 {
             compatible = "ti,omap3-uart";
        }
   };
};

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/8250/8250_early.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index e7cdc0c..d1f6310 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -201,3 +201,23 @@ EARLYCON_DECLARE(rt288x, early_rt288x_setup);
 OF_EARLYCON_DECLARE(rt288x, "ralink,rt2880-uart", early_rt288x_setup);
 
 #endif /* CONFIG_SERIAL_8250_RT288X */
+
+#ifdef CONFIG_SERIAL_8250_OMAP
+
+static int __init early_omap8250_setup(struct earlycon_device *device,
+				       const char *options)
+{
+	struct uart_port *port = &device->port;
+
+	if (!(device->port.membase || device->port.iobase))
+		return -ENODEV;
+
+	port->regshift = 2;
+	device->con->write = early_serial8250_write;
+	return 0;
+}
+
+OF_EARLYCON_DECLARE(omap8250, "ti,omap2-uart", early_omap8250_setup);
+OF_EARLYCON_DECLARE(omap8250, "ti,omap3-uart", early_omap8250_setup);
+OF_EARLYCON_DECLARE(omap8250, "ti,omap4-uart", early_omap8250_setup);
+#endif
-- 
2.7.0

[toc] | [prev] | [next] | [standalone]


#1307792 — Re: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon

FromPeter Hurley <peter@hurleysoftware.com>
Date2016-01-12 21:00 +0100
SubjectRe: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon
Message-ID<qQdgK-5AE-19@gated-at.bofh.it>
In reply to#1307781
Wasn't planning on sending this patch just yet, but oh well.

On 01/12/2016 11:41 AM, Peter Hurley wrote:
> Add DT earlycon for 8250_omap driver. This boot console is included
> for kernels built with CONFIG_SERIAL_EARLYCON=y, CONFIG_OF=y,
> CONFIG_SERIAL_8250_OMAP=y, and CONFIG_OF_EARLY_FLATTREE=y.
> 
> This boot console is enabled with the command line option "earlycon"
> (without "=<name>...") when the DT 'stdout-path' property matches a
> compatible uart. For example,
> 
> / {
>    chosen {
>         stdout-path = "serial0:115200";
>    };
> 
>    ....
> 
>    aliases {
>         serial0 = &uart0;
>    };
> 
>    ....
> 
>    ocp : ocp {
>         uart0 : serial@44e09000 {
>              compatible = "ti,omap3-uart";
>         }
>    };
> };
> 
> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
> ---
>  drivers/tty/serial/8250/8250_early.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
> index e7cdc0c..d1f6310 100644
> --- a/drivers/tty/serial/8250/8250_early.c
> +++ b/drivers/tty/serial/8250/8250_early.c
> @@ -201,3 +201,23 @@ EARLYCON_DECLARE(rt288x, early_rt288x_setup);
>  OF_EARLYCON_DECLARE(rt288x, "ralink,rt2880-uart", early_rt288x_setup);
>  
>  #endif /* CONFIG_SERIAL_8250_RT288X */

This patch may not apply because the context is sitting on top of
unsubmitted code. Sorry.

Regards,
Peter Hurley

> +
> +#ifdef CONFIG_SERIAL_8250_OMAP
> +
> +static int __init early_omap8250_setup(struct earlycon_device *device,
> +				       const char *options)
> +{
> +	struct uart_port *port = &device->port;
> +
> +	if (!(device->port.membase || device->port.iobase))
> +		return -ENODEV;
> +
> +	port->regshift = 2;
> +	device->con->write = early_serial8250_write;
> +	return 0;
> +}
> +
> +OF_EARLYCON_DECLARE(omap8250, "ti,omap2-uart", early_omap8250_setup);
> +OF_EARLYCON_DECLARE(omap8250, "ti,omap3-uart", early_omap8250_setup);
> +OF_EARLYCON_DECLARE(omap8250, "ti,omap4-uart", early_omap8250_setup);
> +#endif
> 

[toc] | [prev] | [next] | [standalone]


#1308206 — Re: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon

FromJon Hunter <jonathanh@nvidia.com>
Date2016-01-13 10:30 +0100
SubjectRe: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon
Message-ID<qQpUD-63W-19@gated-at.bofh.it>
In reply to#1307792
On 12/01/16 19:51, Peter Hurley wrote:
> Wasn't planning on sending this patch just yet, but oh well.
> 
> On 01/12/2016 11:41 AM, Peter Hurley wrote:
>> Add DT earlycon for 8250_omap driver. This boot console is included
>> for kernels built with CONFIG_SERIAL_EARLYCON=y, CONFIG_OF=y,
>> CONFIG_SERIAL_8250_OMAP=y, and CONFIG_OF_EARLY_FLATTREE=y.
>>
>> This boot console is enabled with the command line option "earlycon"
>> (without "=<name>...") when the DT 'stdout-path' property matches a
>> compatible uart. For example,
>>
>> / {
>>    chosen {
>>         stdout-path = "serial0:115200";
>>    };
>>
>>    ....
>>
>>    aliases {
>>         serial0 = &uart0;
>>    };
>>
>>    ....
>>
>>    ocp : ocp {
>>         uart0 : serial@44e09000 {
>>              compatible = "ti,omap3-uart";
>>         }
>>    };
>> };
>>
>> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
>> ---
>>  drivers/tty/serial/8250/8250_early.c | 20 ++++++++++++++++++++
>>  1 file changed, 20 insertions(+)
>>
>> diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
>> index e7cdc0c..d1f6310 100644
>> --- a/drivers/tty/serial/8250/8250_early.c
>> +++ b/drivers/tty/serial/8250/8250_early.c
>> @@ -201,3 +201,23 @@ EARLYCON_DECLARE(rt288x, early_rt288x_setup);
>>  OF_EARLYCON_DECLARE(rt288x, "ralink,rt2880-uart", early_rt288x_setup);
>>  
>>  #endif /* CONFIG_SERIAL_8250_RT288X */
> 
> This patch may not apply because the context is sitting on top of
> unsubmitted code. Sorry.
> 
> Regards,
> Peter Hurley
> 
>> +
>> +#ifdef CONFIG_SERIAL_8250_OMAP
>> +
>> +static int __init early_omap8250_setup(struct earlycon_device *device,
>> +				       const char *options)
>> +{
>> +	struct uart_port *port = &device->port;
>> +
>> +	if (!(device->port.membase || device->port.iobase))
>> +		return -ENODEV;
>> +
>> +	port->regshift = 2;
>> +	device->con->write = early_serial8250_write;
>> +	return 0;
>> +}

I see you did not mean to send this out, but would the above still be
necessary with my patch [0]? I am wondering if with my patch you can
just add the below OF_EARLYCON_DECLARE() for OMAP?

>> +OF_EARLYCON_DECLARE(omap8250, "ti,omap2-uart", early_omap8250_setup);
>> +OF_EARLYCON_DECLARE(omap8250, "ti,omap3-uart", early_omap8250_setup);
>> +OF_EARLYCON_DECLARE(omap8250, "ti,omap4-uart", early_omap8250_setup);
>> +#endif

If so, would it make sense to include my patches [0] and [1] with this
series, or would you prefer that I just rebase on top of this? I see
that you have already made the same change that I made in patch 2 of my
series.

Cheers
Jon

[0] http://marc.info/?l=linux-serial&m=145259482325332&w=2
[1] http://marc.info/?l=linux-serial&m=145259482825342&w=2

[toc] | [prev] | [next] | [standalone]


#1308239 — Re: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon

FromJon Hunter <jonathanh@nvidia.com>
Date2016-01-13 11:00 +0100
SubjectRe: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon
Message-ID<qQqnF-6iI-13@gated-at.bofh.it>
In reply to#1308206
On 13/01/16 09:19, Jon Hunter wrote:
> 
> On 12/01/16 19:51, Peter Hurley wrote:
>> Wasn't planning on sending this patch just yet, but oh well.
>>
>> On 01/12/2016 11:41 AM, Peter Hurley wrote:
>>> Add DT earlycon for 8250_omap driver. This boot console is included
>>> for kernels built with CONFIG_SERIAL_EARLYCON=y, CONFIG_OF=y,
>>> CONFIG_SERIAL_8250_OMAP=y, and CONFIG_OF_EARLY_FLATTREE=y.
>>>
>>> This boot console is enabled with the command line option "earlycon"
>>> (without "=<name>...") when the DT 'stdout-path' property matches a
>>> compatible uart. For example,
>>>
>>> / {
>>>    chosen {
>>>         stdout-path = "serial0:115200";
>>>    };
>>>
>>>    ....
>>>
>>>    aliases {
>>>         serial0 = &uart0;
>>>    };
>>>
>>>    ....
>>>
>>>    ocp : ocp {
>>>         uart0 : serial@44e09000 {
>>>              compatible = "ti,omap3-uart";
>>>         }
>>>    };
>>> };
>>>
>>> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
>>> ---
>>>  drivers/tty/serial/8250/8250_early.c | 20 ++++++++++++++++++++
>>>  1 file changed, 20 insertions(+)
>>>
>>> diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
>>> index e7cdc0c..d1f6310 100644
>>> --- a/drivers/tty/serial/8250/8250_early.c
>>> +++ b/drivers/tty/serial/8250/8250_early.c
>>> @@ -201,3 +201,23 @@ EARLYCON_DECLARE(rt288x, early_rt288x_setup);
>>>  OF_EARLYCON_DECLARE(rt288x, "ralink,rt2880-uart", early_rt288x_setup);
>>>  
>>>  #endif /* CONFIG_SERIAL_8250_RT288X */
>>
>> This patch may not apply because the context is sitting on top of
>> unsubmitted code. Sorry.
>>
>> Regards,
>> Peter Hurley
>>
>>> +
>>> +#ifdef CONFIG_SERIAL_8250_OMAP
>>> +
>>> +static int __init early_omap8250_setup(struct earlycon_device *device,
>>> +				       const char *options)
>>> +{
>>> +	struct uart_port *port = &device->port;
>>> +
>>> +	if (!(device->port.membase || device->port.iobase))
>>> +		return -ENODEV;
>>> +
>>> +	port->regshift = 2;
>>> +	device->con->write = early_serial8250_write;
>>> +	return 0;
>>> +}
> 
> I see you did not mean to send this out, but would the above still be
> necessary with my patch [0]? I am wondering if with my patch you can
> just add the below OF_EARLYCON_DECLARE() for OMAP?

And replace early_omap8250_setup with early_serial8250_setup, in the
below that is.

>>> +OF_EARLYCON_DECLARE(omap8250, "ti,omap2-uart", early_omap8250_setup);
>>> +OF_EARLYCON_DECLARE(omap8250, "ti,omap3-uart", early_omap8250_setup);
>>> +OF_EARLYCON_DECLARE(omap8250, "ti,omap4-uart", early_omap8250_setup);
>>> +#endif

Jon

[toc] | [prev] | [next] | [standalone]


#1308250 — Re: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon

FromJon Hunter <jonathanh@nvidia.com>
Date2016-01-13 11:20 +0100
SubjectRe: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon
Message-ID<qQqGZ-6FS-13@gated-at.bofh.it>
In reply to#1308206
On 13/01/16 09:19, Jon Hunter wrote:
> 
> On 12/01/16 19:51, Peter Hurley wrote:
>> Wasn't planning on sending this patch just yet, but oh well.
>>
>> On 01/12/2016 11:41 AM, Peter Hurley wrote:
>>> Add DT earlycon for 8250_omap driver. This boot console is included
>>> for kernels built with CONFIG_SERIAL_EARLYCON=y, CONFIG_OF=y,
>>> CONFIG_SERIAL_8250_OMAP=y, and CONFIG_OF_EARLY_FLATTREE=y.
>>>
>>> This boot console is enabled with the command line option "earlycon"
>>> (without "=<name>...") when the DT 'stdout-path' property matches a
>>> compatible uart. For example,
>>>
>>> / {
>>>    chosen {
>>>         stdout-path = "serial0:115200";
>>>    };
>>>
>>>    ....
>>>
>>>    aliases {
>>>         serial0 = &uart0;
>>>    };
>>>
>>>    ....
>>>
>>>    ocp : ocp {
>>>         uart0 : serial@44e09000 {
>>>              compatible = "ti,omap3-uart";
>>>         }
>>>    };
>>> };
>>>
>>> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
>>> ---
>>>  drivers/tty/serial/8250/8250_early.c | 20 ++++++++++++++++++++
>>>  1 file changed, 20 insertions(+)
>>>
>>> diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
>>> index e7cdc0c..d1f6310 100644
>>> --- a/drivers/tty/serial/8250/8250_early.c
>>> +++ b/drivers/tty/serial/8250/8250_early.c
>>> @@ -201,3 +201,23 @@ EARLYCON_DECLARE(rt288x, early_rt288x_setup);
>>>  OF_EARLYCON_DECLARE(rt288x, "ralink,rt2880-uart", early_rt288x_setup);
>>>  
>>>  #endif /* CONFIG_SERIAL_8250_RT288X */
>>
>> This patch may not apply because the context is sitting on top of
>> unsubmitted code. Sorry.
>>
>> Regards,
>> Peter Hurley
>>
>>> +
>>> +#ifdef CONFIG_SERIAL_8250_OMAP
>>> +
>>> +static int __init early_omap8250_setup(struct earlycon_device *device,
>>> +				       const char *options)
>>> +{
>>> +	struct uart_port *port = &device->port;
>>> +
>>> +	if (!(device->port.membase || device->port.iobase))
>>> +		return -ENODEV;
>>> +
>>> +	port->regshift = 2;
>>> +	device->con->write = early_serial8250_write;
>>> +	return 0;
>>> +}
> 
> I see you did not mean to send this out, but would the above still be
> necessary with my patch [0]? I am wondering if with my patch you can
> just add the below OF_EARLYCON_DECLARE() for OMAP?

Sorry, I see that you have also already made the changes I have in patch
[0]. However, still curious why you need the above for OMAP?

Jon

[0] http://marc.info/?l=linux-serial&m=145259482325332&w=2

[toc] | [prev] | [next] | [standalone]


#1308630 — Re: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon

FromPeter Hurley <peter@hurleysoftware.com>
Date2016-01-13 18:10 +0100
SubjectRe: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon
Message-ID<qQx5M-2Pq-17@gated-at.bofh.it>
In reply to#1308250
Hi Jon,

On 01/13/2016 02:09 AM, Jon Hunter wrote:
> On 13/01/16 09:19, Jon Hunter wrote:
>> On 12/01/16 19:51, Peter Hurley wrote:
>>> Wasn't planning on sending this patch just yet, but oh well.
>>>
>>> On 01/12/2016 11:41 AM, Peter Hurley wrote:
>>>> Add DT earlycon for 8250_omap driver. This boot console is included
>>>> for kernels built with CONFIG_SERIAL_EARLYCON=y, CONFIG_OF=y,
>>>> CONFIG_SERIAL_8250_OMAP=y, and CONFIG_OF_EARLY_FLATTREE=y.
>>>>
>>>> This boot console is enabled with the command line option "earlycon"
>>>> (without "=<name>...") when the DT 'stdout-path' property matches a
>>>> compatible uart. For example,
>>>>
>>>> / {
>>>>    chosen {
>>>>         stdout-path = "serial0:115200";
>>>>    };
>>>>
>>>>    ....
>>>>
>>>>    aliases {
>>>>         serial0 = &uart0;
>>>>    };
>>>>
>>>>    ....
>>>>
>>>>    ocp : ocp {
>>>>         uart0 : serial@44e09000 {
>>>>              compatible = "ti,omap3-uart";
>>>>         }
>>>>    };
>>>> };
>>>>
>>>> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
>>>> ---
>>>>  drivers/tty/serial/8250/8250_early.c | 20 ++++++++++++++++++++
>>>>  1 file changed, 20 insertions(+)
>>>>
>>>> diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
>>>> index e7cdc0c..d1f6310 100644
>>>> --- a/drivers/tty/serial/8250/8250_early.c
>>>> +++ b/drivers/tty/serial/8250/8250_early.c
>>>> @@ -201,3 +201,23 @@ EARLYCON_DECLARE(rt288x, early_rt288x_setup);
>>>>  OF_EARLYCON_DECLARE(rt288x, "ralink,rt2880-uart", early_rt288x_setup);
>>>>  
>>>>  #endif /* CONFIG_SERIAL_8250_RT288X */
>>>
>>> This patch may not apply because the context is sitting on top of
>>> unsubmitted code. Sorry.
>>>
>>> Regards,
>>> Peter Hurley
>>>
>>>> +
>>>> +#ifdef CONFIG_SERIAL_8250_OMAP
>>>> +
>>>> +static int __init early_omap8250_setup(struct earlycon_device *device,
>>>> +				       const char *options)
>>>> +{
>>>> +	struct uart_port *port = &device->port;
>>>> +
>>>> +	if (!(device->port.membase || device->port.iobase))
>>>> +		return -ENODEV;
>>>> +
>>>> +	port->regshift = 2;
>>>> +	device->con->write = early_serial8250_write;
>>>> +	return 0;
>>>> +}
>>
>> I see you did not mean to send this out, but would the above still be
>> necessary with my patch [0]? I am wondering if with my patch you can
>> just add the below OF_EARLYCON_DECLARE() for OMAP?
> 
> Sorry, I see that you have also already made the changes I have in patch
> [0]. However, still curious why you need the above for OMAP?

Yeah, sorry about trouncing your patches.

I let that series from the beginning of last year stall after writing the
dtc compiler patch waiting for the kernel libfdt copy to catch up, and
then forgot about it, until the flood of recent earlycon patches.

Since it rebased (and retested) fairly trivially, I thought I'd just
push it out again.

The reason the omap8250 earlycon needs the regshift init is that the
omap uart DT nodes don't adequately describe the register layout; the
8250_omap sub-driver handles the uart port initialization (iow, it
doesn't use the 8250_of properties to describe i/o register access).
This situation is an artifact of the original omap uart driver,
omap-serial.c

For regular 8250 DT nodes, the only requirement should be the
OF_EARLYCON_DECLARE() to associate the compatible string with
early_serial8250_setup() (and a unique earlycon name such as the one
you already used).

NB: You should be able to re-use the earlycon name itself when
declaring new OF earlycons now. IOW,

OF_EARLYCON_DECLARE(uart, "nvidia,tegra20-uart", early_serial8250_setup);

should work. And this will keep the proliferation of command line
options to a minimum.

Please let me know if that doesn't work.

Regards,
Peter Hurley


> Jon
> 
> [0] http://marc.info/?l=linux-serial&m=145259482325332&w=2
> 

[toc] | [prev] | [next] | [standalone]


#1308643 — Re: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon

FromJon Hunter <jonathanh@nvidia.com>
Date2016-01-13 18:20 +0100
SubjectRe: [PATCH v4 11/11] serial: 8250_omap: Add omap8250 earlycon
Message-ID<qQxft-2SP-13@gated-at.bofh.it>
In reply to#1308630
Hi Peter,

On 13/01/16 17:06, Peter Hurley wrote:
> Hi Jon,
> 
> On 01/13/2016 02:09 AM, Jon Hunter wrote:
>> On 13/01/16 09:19, Jon Hunter wrote:
>>> On 12/01/16 19:51, Peter Hurley wrote:
>>>> Wasn't planning on sending this patch just yet, but oh well.
>>>>
>>>> On 01/12/2016 11:41 AM, Peter Hurley wrote:
>>>>> Add DT earlycon for 8250_omap driver. This boot console is included
>>>>> for kernels built with CONFIG_SERIAL_EARLYCON=y, CONFIG_OF=y,
>>>>> CONFIG_SERIAL_8250_OMAP=y, and CONFIG_OF_EARLY_FLATTREE=y.
>>>>>
>>>>> This boot console is enabled with the command line option "earlycon"
>>>>> (without "=<name>...") when the DT 'stdout-path' property matches a
>>>>> compatible uart. For example,
>>>>>
>>>>> / {
>>>>>    chosen {
>>>>>         stdout-path = "serial0:115200";
>>>>>    };
>>>>>
>>>>>    ....
>>>>>
>>>>>    aliases {
>>>>>         serial0 = &uart0;
>>>>>    };
>>>>>
>>>>>    ....
>>>>>
>>>>>    ocp : ocp {
>>>>>         uart0 : serial@44e09000 {
>>>>>              compatible = "ti,omap3-uart";
>>>>>         }
>>>>>    };
>>>>> };
>>>>>
>>>>> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
>>>>> ---
>>>>>  drivers/tty/serial/8250/8250_early.c | 20 ++++++++++++++++++++
>>>>>  1 file changed, 20 insertions(+)
>>>>>
>>>>> diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
>>>>> index e7cdc0c..d1f6310 100644
>>>>> --- a/drivers/tty/serial/8250/8250_early.c
>>>>> +++ b/drivers/tty/serial/8250/8250_early.c
>>>>> @@ -201,3 +201,23 @@ EARLYCON_DECLARE(rt288x, early_rt288x_setup);
>>>>>  OF_EARLYCON_DECLARE(rt288x, "ralink,rt2880-uart", early_rt288x_setup);
>>>>>  
>>>>>  #endif /* CONFIG_SERIAL_8250_RT288X */
>>>>
>>>> This patch may not apply because the context is sitting on top of
>>>> unsubmitted code. Sorry.
>>>>
>>>> Regards,
>>>> Peter Hurley
>>>>
>>>>> +
>>>>> +#ifdef CONFIG_SERIAL_8250_OMAP
>>>>> +
>>>>> +static int __init early_omap8250_setup(struct earlycon_device *device,
>>>>> +				       const char *options)
>>>>> +{
>>>>> +	struct uart_port *port = &device->port;
>>>>> +
>>>>> +	if (!(device->port.membase || device->port.iobase))
>>>>> +		return -ENODEV;
>>>>> +
>>>>> +	port->regshift = 2;
>>>>> +	device->con->write = early_serial8250_write;
>>>>> +	return 0;
>>>>> +}
>>>
>>> I see you did not mean to send this out, but would the above still be
>>> necessary with my patch [0]? I am wondering if with my patch you can
>>> just add the below OF_EARLYCON_DECLARE() for OMAP?
>>
>> Sorry, I see that you have also already made the changes I have in patch
>> [0]. However, still curious why you need the above for OMAP?
> 
> Yeah, sorry about trouncing your patches.

No problem, it is fine with me.

> I let that series from the beginning of last year stall after writing the
> dtc compiler patch waiting for the kernel libfdt copy to catch up, and
> then forgot about it, until the flood of recent earlycon patches.
> 
> Since it rebased (and retested) fairly trivially, I thought I'd just
> push it out again.
> 
> The reason the omap8250 earlycon needs the regshift init is that the
> omap uart DT nodes don't adequately describe the register layout; the
> 8250_omap sub-driver handles the uart port initialization (iow, it
> doesn't use the 8250_of properties to describe i/o register access).
> This situation is an artifact of the original omap uart driver,
> omap-serial.c
> 
> For regular 8250 DT nodes, the only requirement should be the
> OF_EARLYCON_DECLARE() to associate the compatible string with
> early_serial8250_setup() (and a unique earlycon name such as the one
> you already used).
> 
> NB: You should be able to re-use the earlycon name itself when
> declaring new OF earlycons now. IOW,
> 
> OF_EARLYCON_DECLARE(uart, "nvidia,tegra20-uart", early_serial8250_setup);
> 
> should work. And this will keep the proliferation of command line
> options to a minimum.

Ok.

> Please let me know if that doesn't work.

I am sure it will. I will re-send a patch for this, once this series is
merged.

Cheers
Jon

[toc] | [prev] | [next] | [standalone]


#1307782 — [PATCH v4 10/11] of: earlycon: Log more helpful message if stdout-path node not found

FromPeter Hurley <peter@hurleysoftware.com>
Date2016-01-12 20:50 +0100
Subject[PATCH v4 10/11] of: earlycon: Log more helpful message if stdout-path node not found
Message-ID<qQd75-5xe-27@gated-at.bofh.it>
In reply to#1307777
Earlycon may fail to initialize for a variety of reasons, most of
which log the default early param message. If the stdout-path node is
not found, log the path which was not found (and suppress the
default early param message).

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 918809e..e2295b2 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -820,11 +820,14 @@ static int __init early_init_dt_scan_chosen_serial(void)
 	q = strchrnul(p, ':');
 	if (*q != '\0')
 		options = q + 1;
+	l = q - p;
 
 	/* Get the node specified by stdout-path */
-	offset = fdt_path_offset_namelen(fdt, p, q - p);
-	if (offset < 0)
-		return -ENODEV;
+	offset = fdt_path_offset_namelen(fdt, p, l);
+	if (offset < 0) {
+		pr_warn("earlycon: stdout-path %.*s not found\n", l, p);
+		return 0;
+	}
 
 	for (match = __earlycon_table; match < __earlycon_table_end; match++) {
 		if (!match->compatible[0])
-- 
2.7.0

[toc] | [prev] | [next] | [standalone]


#1307917 — Re: [PATCH v4 10/11] of: earlycon: Log more helpful message if stdout-path node not found

FromRob Herring <robh+dt@kernel.org>
Date2016-01-13 00:40 +0100
SubjectRe: [PATCH v4 10/11] of: earlycon: Log more helpful message if stdout-path node not found
Message-ID<qQgHE-80F-21@gated-at.bofh.it>
In reply to#1307782
On Tue, Jan 12, 2016 at 1:41 PM, Peter Hurley <peter@hurleysoftware.com> wrote:
> Earlycon may fail to initialize for a variety of reasons, most of
> which log the default early param message. If the stdout-path node is
> not found, log the path which was not found (and suppress the
> default early param message).
>
> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
> ---
>  drivers/of/fdt.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)

Acked-by: Rob Herring <robh@kernel.org>

[toc] | [prev] | [next] | [standalone]


#1307783 — [PATCH v4 02/11] serial: earlycon: Fixup earlycon console name and index

FromPeter Hurley <peter@hurleysoftware.com>
Date2016-01-12 20:50 +0100
Subject[PATCH v4 02/11] serial: earlycon: Fixup earlycon console name and index
Message-ID<qQd75-5xe-29@gated-at.bofh.it>
In reply to#1307777
Properly initialize the struct console 'name' and 'index' fields for
the registering earlycon. For earlycons w/o trailing numerals, the
index is set to 0; otherwise, the index is set to the value of the
trailing numeral. For example, the 'exynos4210' earlycon name == "exynos"
and index == 4210. Earlycons with embedded numerals will have all
non-trailing numerals as part of the name; for example, the 's3c2412'
earlycon name == "s3c" and index == 2412.

This ackward scheme was initially added for the uart8250 earlycon;
adopt this scheme for the other earlycon "drivers".

Introduce earlycon_init() which performs the string scanning and
initializes the name and index fields; encapsulate the other console
field initializations within.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/earlycon.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index d50b700..90b064f 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -27,9 +27,9 @@
 #include <asm/serial.h>
 
 static struct console early_con = {
-	.name =		"uart", /* 8250 console switch requires this name */
+	.name =		"uart",		/* fixed up at earlycon registration */
 	.flags =	CON_PRINTBUFFER | CON_BOOT,
-	.index =	-1,
+	.index =	0,
 };
 
 static struct earlycon_device early_console_dev = {
@@ -53,6 +53,25 @@ static void __iomem * __init earlycon_map(unsigned long paddr, size_t size)
 	return base;
 }
 
+static void __init earlycon_init(struct earlycon_device *device,
+				 const char *name)
+{
+	struct console *earlycon = device->con;
+	const char *s;
+	size_t len;
+
+	/* scan backwards from end of string for first non-numeral */
+	for (s = name + strlen(name);
+	     s > name && s[-1] >= '0' && s[-1] <= '9';
+	     s--)
+		;
+	if (*s)
+		earlycon->index = simple_strtoul(s, NULL, 10);
+	len = s - name;
+	strlcpy(earlycon->name, name, min(len + 1, sizeof(earlycon->name)));
+	earlycon->data = &early_console_dev;
+}
+
 static int __init parse_options(struct earlycon_device *device, char *options)
 {
 	struct uart_port *port = &device->port;
@@ -119,7 +138,7 @@ static int __init register_earlycon(char *buf, const struct earlycon_id *match)
 	if (port->mapbase)
 		port->membase = earlycon_map(port->mapbase, 64);
 
-	early_console_dev.con->data = &early_console_dev;
+	earlycon_init(&early_console_dev, match->name);
 	err = match->setup(&early_console_dev, buf);
 	if (err < 0)
 		return err;
-- 
2.7.0

[toc] | [prev] | [next] | [standalone]


#1307785 — [PATCH v4 05/11] of: earlycon: Initialize port fields from DT properties

FromPeter Hurley <peter@hurleysoftware.com>
Date2016-01-12 20:50 +0100
Subject[PATCH v4 05/11] of: earlycon: Initialize port fields from DT properties
Message-ID<qQd75-5xe-39@gated-at.bofh.it>
In reply to#1307777
Read the optional "reg-offset", "reg-shift", "reg-io-width" and endianness
properties and initialize the respective struct uart_port field if found.

NB: These bindings are common to several drivers and the values merely
indicate the default value; the registering earlycon setup() method can
simply override the values if required.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c              |  2 +-
 drivers/tty/serial/earlycon.c | 34 ++++++++++++++++++++++++++++++++++
 include/linux/serial_core.h   |  1 +
 3 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index cfd3b35..e8fd54a 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -839,7 +839,7 @@ static int __init early_init_dt_scan_chosen_serial(void)
 		if (addr == OF_BAD_ADDR)
 			return -ENXIO;
 
-		of_setup_earlycon(addr, match, options);
+		of_setup_earlycon(addr, match, offset, options);
 		return 0;
 	}
 	return -ENODEV;
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 7509ee34d..03eac4a 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -20,6 +20,10 @@
 #include <linux/serial_core.h>
 #include <linux/sizes.h>
 
+#ifdef CONFIG_OF_EARLY_FLATTREE
+#include <linux/of_fdt.h>
+#endif
+
 #ifdef CONFIG_FIX_EARLYCON_MEM
 #include <asm/fixmap.h>
 #endif
@@ -219,10 +223,13 @@ early_param("earlycon", param_setup_earlycon);
 
 int __init of_setup_earlycon(unsigned long addr,
 			     const struct earlycon_id *match,
+			     unsigned long node,
 			     const char *options)
 {
 	int err;
 	struct uart_port *port = &early_console_dev.port;
+	const __be32 *val;
+	bool big_endian;
 
 	spin_lock_init(&port->lock);
 	port->iotype = UPIO_MEM;
@@ -230,6 +237,33 @@ int __init of_setup_earlycon(unsigned long addr,
 	port->uartclk = BASE_BAUD * 16;
 	port->membase = earlycon_map(addr, SZ_4K);
 
+	val = of_get_flat_dt_prop(node, "reg-offset", NULL);
+	if (val)
+		port->mapbase += be32_to_cpu(*val);
+	val = of_get_flat_dt_prop(node, "reg-shift", NULL);
+	if (val)
+		port->regshift = be32_to_cpu(*val);
+	big_endian = of_get_flat_dt_prop(node, "big-endian", NULL) != NULL ||
+		(IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) &&
+		 of_get_flat_dt_prop(node, "native-endian", NULL) != NULL);
+	val = of_get_flat_dt_prop(node, "reg-io-width", NULL);
+	if (val) {
+		switch (be32_to_cpu(*val)) {
+		case 1:
+			port->iotype = UPIO_MEM;
+			break;
+		case 2:
+			port->iotype = UPIO_MEM16;
+			break;
+		case 4:
+			port->iotype = (big_endian) ? UPIO_MEM32BE : UPIO_MEM32;
+			break;
+		default:
+			pr_warn("[%s] unsupported reg-io-width\n", match->name);
+			return -EINVAL;
+		}
+	}
+
 	if (options) {
 		strlcpy(early_console_dev.options, options,
 			sizeof(early_console_dev.options));
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 62a4df0..6d1bed8 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -360,6 +360,7 @@ extern const struct earlycon_id __earlycon_table_end[];
 
 extern int setup_earlycon(char *buf);
 extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match,
+			     unsigned long node,
 			     const char *options);
 
 struct uart_port *uart_get_console(struct uart_port *ports, int nr,
-- 
2.7.0

[toc] | [prev] | [next] | [standalone]


#1307925 — Re: [PATCH v4 05/11] of: earlycon: Initialize port fields from DT properties

FromRob Herring <robh+dt@kernel.org>
Date2016-01-13 01:00 +0100
SubjectRe: [PATCH v4 05/11] of: earlycon: Initialize port fields from DT properties
Message-ID<qQh10-88E-15@gated-at.bofh.it>
In reply to#1307785
On Tue, Jan 12, 2016 at 1:41 PM, Peter Hurley <peter@hurleysoftware.com> wrote:
> Read the optional "reg-offset", "reg-shift", "reg-io-width" and endianness
> properties and initialize the respective struct uart_port field if found.
>
> NB: These bindings are common to several drivers and the values merely
> indicate the default value; the registering earlycon setup() method can
> simply override the values if required.
>
> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
> ---

> diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
> index 7509ee34d..03eac4a 100644
> --- a/drivers/tty/serial/earlycon.c
> +++ b/drivers/tty/serial/earlycon.c
> @@ -20,6 +20,10 @@
>  #include <linux/serial_core.h>
>  #include <linux/sizes.h>
>
> +#ifdef CONFIG_OF_EARLY_FLATTREE
> +#include <linux/of_fdt.h>
> +#endif

I think you don't need the ifdef around this.

> +
>  #ifdef CONFIG_FIX_EARLYCON_MEM
>  #include <asm/fixmap.h>
>  #endif

[toc] | [prev] | [next] | [standalone]


#1308583 — Re: [PATCH v4 05/11] of: earlycon: Initialize port fields from DT properties

FromPeter Hurley <peter@hurleysoftware.com>
Date2016-01-13 17:40 +0100
SubjectRe: [PATCH v4 05/11] of: earlycon: Initialize port fields from DT properties
Message-ID<qQwCL-2o0-43@gated-at.bofh.it>
In reply to#1307925
On 01/12/2016 03:49 PM, Rob Herring wrote:
> On Tue, Jan 12, 2016 at 1:41 PM, Peter Hurley <peter@hurleysoftware.com> wrote:
>> Read the optional "reg-offset", "reg-shift", "reg-io-width" and endianness
>> properties and initialize the respective struct uart_port field if found.
>>
>> NB: These bindings are common to several drivers and the values merely
>> indicate the default value; the registering earlycon setup() method can
>> simply override the values if required.
>>
>> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
>> ---
> 
>> diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
>> index 7509ee34d..03eac4a 100644
>> --- a/drivers/tty/serial/earlycon.c
>> +++ b/drivers/tty/serial/earlycon.c
>> @@ -20,6 +20,10 @@
>>  #include <linux/serial_core.h>
>>  #include <linux/sizes.h>
>>
>> +#ifdef CONFIG_OF_EARLY_FLATTREE
>> +#include <linux/of_fdt.h>
>> +#endif
> 
> I think you don't need the ifdef around this.
> 
>> +
>>  #ifdef CONFIG_FIX_EARLYCON_MEM
>>  #include <asm/fixmap.h>
>>  #endif

Ok, will take care of that.

[toc] | [prev] | [next] | [standalone]


#1307786 — [PATCH v4 06/11] of: earlycon: Move address translation to of_setup_earlycon()

FromPeter Hurley <peter@hurleysoftware.com>
Date2016-01-12 20:50 +0100
Subject[PATCH v4 06/11] of: earlycon: Move address translation to of_setup_earlycon()
Message-ID<qQd75-5xe-33@gated-at.bofh.it>
In reply to#1307777
Cleanup the early DT/earlycon separation; remove the 'addr' parameter
from of_setup_earlycon() and get the uart phys addr directly with a
new wrapper function, of_flat_dt_translate_addr(). Limit
fdt_translate_address() to file scope.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/of/fdt.c              |  8 +-------
 drivers/of/fdt_address.c      | 11 ++++++++++-
 drivers/tty/serial/earlycon.c | 12 +++++++++---
 include/linux/of_fdt.h        |  2 +-
 include/linux/serial_core.h   |  2 +-
 5 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index e8fd54a..918809e 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -827,19 +827,13 @@ static int __init early_init_dt_scan_chosen_serial(void)
 		return -ENODEV;
 
 	for (match = __earlycon_table; match < __earlycon_table_end; match++) {
-		u64 addr;
-
 		if (!match->compatible[0])
 			continue;
 
 		if (fdt_node_check_compatible(fdt, offset, match->compatible))
 			continue;
 
-		addr = fdt_translate_address(fdt, offset);
-		if (addr == OF_BAD_ADDR)
-			return -ENXIO;
-
-		of_setup_earlycon(addr, match, offset, options);
+		of_setup_earlycon(match, offset, options);
 		return 0;
 	}
 	return -ENODEV;
diff --git a/drivers/of/fdt_address.c b/drivers/of/fdt_address.c
index 8d3dc6f..dca8f9b 100644
--- a/drivers/of/fdt_address.c
+++ b/drivers/of/fdt_address.c
@@ -161,7 +161,7 @@ static int __init fdt_translate_one(const void *blob, int parent,
  * that can be mapped to a cpu physical address). This is not really specified
  * that way, but this is traditionally the way IBM at least do things
  */
-u64 __init fdt_translate_address(const void *blob, int node_offset)
+static u64 __init fdt_translate_address(const void *blob, int node_offset)
 {
 	int parent, len;
 	const struct of_bus *bus, *pbus;
@@ -239,3 +239,12 @@ u64 __init fdt_translate_address(const void *blob, int node_offset)
  bail:
 	return result;
 }
+
+/**
+ * of_flat_dt_translate_address - translate DT addr into CPU phys addr
+ * @node: node in the flat blob
+ */
+u64 __init of_flat_dt_translate_address(unsigned long node)
+{
+	return fdt_translate_address(initial_boot_params, node);
+}
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 03eac4a..4182185 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -21,6 +21,7 @@
 #include <linux/sizes.h>
 
 #ifdef CONFIG_OF_EARLY_FLATTREE
+#include <linux/of.h>
 #include <linux/of_fdt.h>
 #endif
 
@@ -221,8 +222,7 @@ early_param("earlycon", param_setup_earlycon);
 
 #ifdef CONFIG_OF_EARLY_FLATTREE
 
-int __init of_setup_earlycon(unsigned long addr,
-			     const struct earlycon_id *match,
+int __init of_setup_earlycon(const struct earlycon_id *match,
 			     unsigned long node,
 			     const char *options)
 {
@@ -230,12 +230,18 @@ int __init of_setup_earlycon(unsigned long addr,
 	struct uart_port *port = &early_console_dev.port;
 	const __be32 *val;
 	bool big_endian;
+	u64 addr;
 
 	spin_lock_init(&port->lock);
 	port->iotype = UPIO_MEM;
+	addr = of_flat_dt_translate_address(node);
+	if (addr == OF_BAD_ADDR) {
+		pr_warn("[%s] bad address\n", match->name);
+		return -ENXIO;
+	}
 	port->mapbase = addr;
 	port->uartclk = BASE_BAUD * 16;
-	port->membase = earlycon_map(addr, SZ_4K);
+	port->membase = earlycon_map(port->mapbase, SZ_4K);
 
 	val = of_get_flat_dt_prop(node, "reg-offset", NULL);
 	if (val)
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index df9ef38..2fbe868 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -88,7 +88,7 @@ extern void unflatten_device_tree(void);
 extern void unflatten_and_copy_device_tree(void);
 extern void early_init_devtree(void *);
 extern void early_get_first_memblock_info(void *, phys_addr_t *);
-extern u64 fdt_translate_address(const void *blob, int node_offset);
+extern u64 of_flat_dt_translate_address(unsigned long node);
 extern void of_fdt_limit_memory(int limit);
 #else /* CONFIG_OF_FLATTREE */
 static inline void early_init_fdt_scan_reserved_mem(void) {}
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 6d1bed8..cbfcf38 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -359,7 +359,7 @@ extern const struct earlycon_id __earlycon_table_end[];
 #define EARLYCON_DECLARE(_name, fn)	OF_EARLYCON_DECLARE(_name, "", fn)
 
 extern int setup_earlycon(char *buf);
-extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match,
+extern int of_setup_earlycon(const struct earlycon_id *match,
 			     unsigned long node,
 			     const char *options);
 
-- 
2.7.0

[toc] | [prev] | [next] | [standalone]


#1307787 — [PATCH v4 07/11] serial: earlycon: Common log banner for command line and DT

FromPeter Hurley <peter@hurleysoftware.com>
Date2016-01-12 20:50 +0100
Subject[PATCH v4 07/11] serial: earlycon: Common log banner for command line and DT
Message-ID<qQd75-5xe-37@gated-at.bofh.it>
In reply to#1307777
Refactor the command line earlycon banner into earlycon_init() so
both earlycon startup methods output an info banner.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/earlycon.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 4182185..10a2ae3 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -62,6 +62,7 @@ static void __init earlycon_init(struct earlycon_device *device,
 				 const char *name)
 {
 	struct console *earlycon = device->con;
+	struct uart_port *port = &device->port;
 	const char *s;
 	size_t len;
 
@@ -75,6 +76,19 @@ static void __init earlycon_init(struct earlycon_device *device,
 	len = s - name;
 	strlcpy(earlycon->name, name, min(len + 1, sizeof(earlycon->name)));
 	earlycon->data = &early_console_dev;
+
+	if (port->iotype == UPIO_MEM || port->iotype == UPIO_MEM16 ||
+	    port->iotype == UPIO_MEM32 || port->iotype == UPIO_MEM32BE)
+		pr_info("Early serial console at MMIO%s 0x%llx (options '%s')\n",
+			(port->iotype == UPIO_MEM) ? "" :
+			(port->iotype == UPIO_MEM16) ? "16" :
+			(port->iotype == UPIO_MEM32) ? "32" : "32be",
+			(unsigned long long)port->mapbase,
+			device->options);
+	else
+		pr_info("Early serial console at I/O port 0x%lx (options '%s')\n",
+			port->iobase,
+			device->options);
 }
 
 static int __init parse_options(struct earlycon_device *device, char *options)
@@ -113,19 +127,6 @@ static int __init parse_options(struct earlycon_device *device, char *options)
 		strlcpy(device->options, options, length);
 	}
 
-	if (port->iotype == UPIO_MEM || port->iotype == UPIO_MEM16 ||
-	    port->iotype == UPIO_MEM32 || port->iotype == UPIO_MEM32BE)
-		pr_info("Early serial console at MMIO%s 0x%llx (options '%s')\n",
-			(port->iotype == UPIO_MEM) ? "" :
-			(port->iotype == UPIO_MEM16) ? "16" :
-			(port->iotype == UPIO_MEM32) ? "32" : "32be",
-			(unsigned long long)port->mapbase,
-			device->options);
-	else
-		pr_info("Early serial console at I/O port 0x%lx (options '%s')\n",
-			port->iobase,
-			device->options);
-
 	return 0;
 }
 
-- 
2.7.0

[toc] | [prev] | [next] | [standalone]


#1307788 — [PATCH v4 09/11] serial: 8250_early: Use port->regshift

FromPeter Hurley <peter@hurleysoftware.com>
Date2016-01-12 20:50 +0100
Subject[PATCH v4 09/11] serial: 8250_early: Use port->regshift
Message-ID<qQd75-5xe-45@gated-at.bofh.it>
In reply to#1307777
earlycon initializes struct uart_port::regshift to the correct
value for UPIO_MEM32 already. Use the port field rather than
hard-coded value.

This enables broader support for various i/o access methods in
8250 earlycon (eg., omap8250 earlycon).

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/serial/8250/8250_early.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index 307fb23..e7cdc0c 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -39,15 +39,17 @@
 
 static unsigned int __init serial8250_early_in(struct uart_port *port, int offset)
 {
+	offset <<= port->regshift;
+
 	switch (port->iotype) {
 	case UPIO_MEM:
 		return readb(port->membase + offset);
 	case UPIO_MEM16:
-		return readw(port->membase + (offset << 1));
+		return readw(port->membase + offset);
 	case UPIO_MEM32:
-		return readl(port->membase + (offset << 2));
+		return readl(port->membase + offset);
 	case UPIO_MEM32BE:
-		return ioread32be(port->membase + (offset << 2));
+		return ioread32be(port->membase + offset);
 	case UPIO_PORT:
 		return inb(port->iobase + offset);
 	default:
@@ -57,18 +59,20 @@ static unsigned int __init serial8250_early_in(struct uart_port *port, int offse
 
 static void __init serial8250_early_out(struct uart_port *port, int offset, int value)
 {
+	offset <<= port->regshift;
+
 	switch (port->iotype) {
 	case UPIO_MEM:
 		writeb(value, port->membase + offset);
 		break;
 	case UPIO_MEM16:
-		writew(value, port->membase + (offset << 1));
+		writew(value, port->membase + offset);
 		break;
 	case UPIO_MEM32:
-		writel(value, port->membase + (offset << 2));
+		writel(value, port->membase + offset);
 		break;
 	case UPIO_MEM32BE:
-		iowrite32be(value, port->membase + (offset << 2));
+		iowrite32be(value, port->membase + offset);
 		break;
 	case UPIO_PORT:
 		outb(value, port->iobase + offset);
-- 
2.7.0

[toc] | [prev] | [next] | [standalone]


#1307923

FromRob Herring <robh+dt@kernel.org>
Date2016-01-13 01:00 +0100
Message-ID<qQh10-88E-3@gated-at.bofh.it>
In reply to#1307777
On Tue, Jan 12, 2016 at 1:41 PM, Peter Hurley <peter@hurleysoftware.com> wrote:
> Hi Greg, Grant & Rob,
>
> This patch series is a rebase of the v3 from April last year.
>
> This patch series builds on my earlier "Extensible console matching &
> direct earlycon" to add several useful features to earlycon:
> * Proper port i/o configuration from DT node with of_serial properties
>   (such as reg-io-width, reg-shift and reg-offset, and endianness)
> * Proper console name & index initialization from earlycon name
>   (for both command line and DT-defined earlycons)
> * Support for DT 'stdout-path' options pass-through to earlycon setup
> * Improved log messages for troubleshooting
> * Support for multiple OF earlycon declarations so different
>   compatible strings can specify the same OF earlycon
>
> * Changes from v3
>   - Added 32-bit big-endian support
>   - Removed the omap8250 earlycon (will follow later)
>
>
> Rob has expressed a desire to have the DT parts live in drivers/of/fdt.c
> The problem with this approach is two-fold. Firstly, the number of required
> parameters quickly becomes ugly (base address, io reg width, io reg offset,
> io reg stride, endianness, earlycon name). Secondly, drivers are already
> requiring access to alternate DT properties, like clocks, to initialize
> earlycons, and this requirement will continue.

I dislike ugliness more. So other than my one nit, for the series:

Acked-by: Rob Herring <robh@kernel.org>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web