From: Peter Hurley <peter@hurleysoftware.com>
To: Timur Tabi <timur@codeaurora.org>,
Andre Przywara <andre.przywara@arm.com>,
Jun Nie <jun.nie@linaro.org>
Cc: "linux@arm.linux.org.uk" <linux@arm.linux.org.uk>,
"jason.liu@linaro.org" <jason.liu@linaro.org>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
Andrew Jackson <Andrew.Jackson@arm.com>,
"linux-serial@vger.kernel.org" <linux-serial@vger.kernel.org>,
"shawn.guo@linaro.org" <shawn.guo@linaro.org>,
"wan.zhijun@zte.com.cn" <wan.zhijun@zte.com.cn>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v13 2/5] uart: pl011: Introduce register accessor
Date: Wed, 28 Oct 2015 10:22:34 -0400 [thread overview]
Message-ID: <5630DA2A.4050803@hurleysoftware.com> (raw)
In-Reply-To: <CAOZdJXUZDTzEn4f4FGhmKfq7HeEFKPKp4BAbR6_=wXGVw5_0GQ@mail.gmail.com>
On 10/22/2015 07:36 PM, Timur Tabi wrote:
> On Fri, Sep 18, 2015 at 5:51 AM, Andre Przywara <andre.przywara@arm.com> wrote:
>>
>>> static void pl011_putc(struct uart_port *port, int c)
>>> {
>>> - while (readl(port->membase + REG_FR) & UART01x_FR_TXFF)
>>> + struct uart_amba_port *uap =
>>> + container_of(port, struct uart_amba_port, port);
>>> +
>>> + while (pl011_readw(uap, REG_FR) & UART01x_FR_TXFF)
>>> ;
>>> - writeb(c, port->membase + REG_DR);
>>> - while (readl(port->membase + REG_FR) & UART01x_FR_BUSY)
>>> + pl011_writeb(uap, c, REG_DR);
>>> + while (pl011_readw(uap, REG_FR) & UART01x_FR_BUSY)
>>> ;
>>> }
>>
>> Just for the records, as this has been discussed before: pl011_putc() is
>> called by the earlycon code, before the uart_port is actually
>> initialized. So we cannot rely on the accessors, but have to use the
>> old-fashioned director accessors for this.
>>
>> Which means you cannot use that approach to get earlycon support for the
>> ZTE UART, if I get this correctly. It shouldn't be to hard to introduce
>> another earlycon type specificly for that one, copying pl011_early_write
>> and pl011_early_console_setup and changing pl011_putc into
>> zte_uart_putc. But of course this belongs into the final patch (or a
>> separate one), not in this. So I guess you just leave that function
>> unchanged in this patch.
>
> How about something like this? It adds the "sbsa32" option to the
> earlycon command-line parameter.
>
> static void pl011_putc(struct uart_port *port, int c)
> {
> while (readl(port->membase + UART01x_FR) & UART01x_FR_TXFF)
> cpu_relax();
> writeb(c, port->membase + UART01x_DR);
> while (readl(port->membase + UART01x_FR) & UART01x_FR_BUSY)
> cpu_relax();
> }
>
> static void pl011_early_write(struct console *con, const char *s, unsigned n)
> {
> struct earlycon_device *dev = con->data;
>
> uart_console_write(&dev->port, s, n, pl011_putc);
> }
>
> static void pl011_putc_sbsa32(struct uart_port *port, int c)
> {
> while (readl(port->membase + UART01x_FR) & UART01x_FR_TXFF)
> cpu_relax();
> writel(c, port->membase + UART01x_DR);
> while (readl(port->membase + UART01x_FR) & UART01x_FR_BUSY)
> cpu_relax();
> }
>
> static void pl011_early_write_sbsa32(struct console *con, const char
> *s, unsigned n)
> {
> struct earlycon_device *dev = con->data;
>
> uart_console_write(&dev->port, s, n, pl011_putc_sbsa32);
> }
>
> static int __init pl011_early_console_setup(struct earlycon_device *device,
> const char *opt)
> {
> if (!device->port.membase)
> return -ENODEV;
>
> if (strcmp(device->options, "sbsa32"))
> device->con->write = pl011_early_write_sbsa32;
> else
> device->con->write = pl011_early_write;
>
> return 0;
> }
For earlycon support, I'd prefer to see different OF_EARLYCON_DECLARE()
(and EARLYCON_DECLARE()) declarations with alternate setup() functions
for zte and sbsa32. For example:
static int __init zte_early_console_setup(struct earlycon_device *device,
const char *opt)
{
if (!device->port.membase)
return -ENODEV;
device->con->write = zte_early_write;
return 0;
}
static int __init sbsa32_early_console_setup(struct earlycon_device *device,
const char *opt)
{
if (!device->port.membase)
return -ENODEV;
device->con->write = sbsa32_early_write;
return 0;
}
EARLYCON_DECLARE(zte, zte_early_console_setup);
OF_EARLYCON_DECLARE(zte, ".......", zte_early_console_setup);
EARLYCON_DECLARE(sbsa32, sbsa32_early_console_setup);
OF_EARLYCON_DECLARE(sbsa32, "arm,sbsa-uart", sbsa32_early_console_setup);
The above assumes that the sbsa32 maintains the equivalence of
earlycon and console; ie., that
/ {
chosen {
stdout-path = &uart0;
};
soc {
uart0: serial@xxxxxx {
compatible = "arm,sbsa-uart";
};
};
};
will start a sbsa32 earlycon and later replace that with
sbsa console.
Regards,
Peter Hurley
WARNING: multiple messages have this Message-ID (diff)
From: peter@hurleysoftware.com (Peter Hurley)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v13 2/5] uart: pl011: Introduce register accessor
Date: Wed, 28 Oct 2015 10:22:34 -0400 [thread overview]
Message-ID: <5630DA2A.4050803@hurleysoftware.com> (raw)
In-Reply-To: <CAOZdJXUZDTzEn4f4FGhmKfq7HeEFKPKp4BAbR6_=wXGVw5_0GQ@mail.gmail.com>
On 10/22/2015 07:36 PM, Timur Tabi wrote:
> On Fri, Sep 18, 2015 at 5:51 AM, Andre Przywara <andre.przywara@arm.com> wrote:
>>
>>> static void pl011_putc(struct uart_port *port, int c)
>>> {
>>> - while (readl(port->membase + REG_FR) & UART01x_FR_TXFF)
>>> + struct uart_amba_port *uap =
>>> + container_of(port, struct uart_amba_port, port);
>>> +
>>> + while (pl011_readw(uap, REG_FR) & UART01x_FR_TXFF)
>>> ;
>>> - writeb(c, port->membase + REG_DR);
>>> - while (readl(port->membase + REG_FR) & UART01x_FR_BUSY)
>>> + pl011_writeb(uap, c, REG_DR);
>>> + while (pl011_readw(uap, REG_FR) & UART01x_FR_BUSY)
>>> ;
>>> }
>>
>> Just for the records, as this has been discussed before: pl011_putc() is
>> called by the earlycon code, before the uart_port is actually
>> initialized. So we cannot rely on the accessors, but have to use the
>> old-fashioned director accessors for this.
>>
>> Which means you cannot use that approach to get earlycon support for the
>> ZTE UART, if I get this correctly. It shouldn't be to hard to introduce
>> another earlycon type specificly for that one, copying pl011_early_write
>> and pl011_early_console_setup and changing pl011_putc into
>> zte_uart_putc. But of course this belongs into the final patch (or a
>> separate one), not in this. So I guess you just leave that function
>> unchanged in this patch.
>
> How about something like this? It adds the "sbsa32" option to the
> earlycon command-line parameter.
>
> static void pl011_putc(struct uart_port *port, int c)
> {
> while (readl(port->membase + UART01x_FR) & UART01x_FR_TXFF)
> cpu_relax();
> writeb(c, port->membase + UART01x_DR);
> while (readl(port->membase + UART01x_FR) & UART01x_FR_BUSY)
> cpu_relax();
> }
>
> static void pl011_early_write(struct console *con, const char *s, unsigned n)
> {
> struct earlycon_device *dev = con->data;
>
> uart_console_write(&dev->port, s, n, pl011_putc);
> }
>
> static void pl011_putc_sbsa32(struct uart_port *port, int c)
> {
> while (readl(port->membase + UART01x_FR) & UART01x_FR_TXFF)
> cpu_relax();
> writel(c, port->membase + UART01x_DR);
> while (readl(port->membase + UART01x_FR) & UART01x_FR_BUSY)
> cpu_relax();
> }
>
> static void pl011_early_write_sbsa32(struct console *con, const char
> *s, unsigned n)
> {
> struct earlycon_device *dev = con->data;
>
> uart_console_write(&dev->port, s, n, pl011_putc_sbsa32);
> }
>
> static int __init pl011_early_console_setup(struct earlycon_device *device,
> const char *opt)
> {
> if (!device->port.membase)
> return -ENODEV;
>
> if (strcmp(device->options, "sbsa32"))
> device->con->write = pl011_early_write_sbsa32;
> else
> device->con->write = pl011_early_write;
>
> return 0;
> }
For earlycon support, I'd prefer to see different OF_EARLYCON_DECLARE()
(and EARLYCON_DECLARE()) declarations with alternate setup() functions
for zte and sbsa32. For example:
static int __init zte_early_console_setup(struct earlycon_device *device,
const char *opt)
{
if (!device->port.membase)
return -ENODEV;
device->con->write = zte_early_write;
return 0;
}
static int __init sbsa32_early_console_setup(struct earlycon_device *device,
const char *opt)
{
if (!device->port.membase)
return -ENODEV;
device->con->write = sbsa32_early_write;
return 0;
}
EARLYCON_DECLARE(zte, zte_early_console_setup);
OF_EARLYCON_DECLARE(zte, ".......", zte_early_console_setup);
EARLYCON_DECLARE(sbsa32, sbsa32_early_console_setup);
OF_EARLYCON_DECLARE(sbsa32, "arm,sbsa-uart", sbsa32_early_console_setup);
The above assumes that the sbsa32 maintains the equivalence of
earlycon and console; ie., that
/ {
chosen {
stdout-path = &uart0;
};
soc {
uart0: serial at xxxxxx {
compatible = "arm,sbsa-uart";
};
};
};
will start a sbsa32 earlycon and later replace that with
sbsa console.
Regards,
Peter Hurley
next prev parent reply other threads:[~2015-10-28 14:22 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1438328959-16177-1-git-send-email-jun.nie@linaro.org>
[not found] ` <1438328959-16177-3-git-send-email-jun.nie@linaro.org>
2015-09-18 10:51 ` [PATCH v13 2/5] uart: pl011: Introduce register accessor Andre Przywara
2015-09-18 10:51 ` Andre Przywara
2015-09-19 6:46 ` Jun Nie
2015-09-19 6:46 ` Jun Nie
2015-09-19 21:45 ` Andre Przywara
2015-09-19 21:45 ` Andre Przywara
2015-10-22 23:36 ` Timur Tabi
2015-10-22 23:36 ` Timur Tabi
2015-10-28 14:22 ` Peter Hurley [this message]
2015-10-28 14:22 ` Peter Hurley
2015-10-28 14:51 ` Timur Tabi
2015-10-28 14:51 ` Timur Tabi
2015-10-28 15:08 ` Peter Hurley
2015-10-28 15:08 ` Peter Hurley
[not found] ` <1438328959-16177-5-git-send-email-jun.nie@linaro.org>
2015-09-18 10:58 ` [PATCH v13 4/5] uart: pl011: Improve LCRH register access decision Andre Przywara
2015-09-18 10:58 ` Andre Przywara
[not found] ` <1438328959-16177-6-git-send-email-jun.nie@linaro.org>
2015-09-18 13:50 ` [PATCH v13 5/5] uart: pl011: Add support to ZTE ZX296702 uart Andre Przywara
2015-09-18 13:50 ` Andre Przywara
2015-09-18 13:59 ` Russell King - ARM Linux
2015-09-18 13:59 ` Russell King - ARM Linux
2015-09-19 6:47 ` Jun Nie
2015-09-19 6:47 ` Jun Nie
2015-09-19 6:54 ` Jun Nie
2015-09-19 6:54 ` Jun Nie
2015-10-23 21:54 ` Timur Tabi
2015-10-23 21:54 ` Timur Tabi
2015-10-24 3:23 ` Jun Nie
2015-10-24 3:23 ` Jun Nie
2015-10-24 3:32 ` Timur Tabi
2015-10-24 3:32 ` Timur Tabi
2015-10-26 1:27 ` Jun Nie
2015-10-26 1:27 ` Jun Nie
2015-10-27 13:31 ` Peter Hurley
2015-10-27 13:31 ` Peter Hurley
2015-10-26 9:59 ` Andre Przywara
2015-10-26 9:59 ` Andre Przywara
2015-10-26 12:46 ` Timur Tabi
2015-10-26 12:46 ` Timur Tabi
2015-10-26 14:00 ` Andre Przywara
2015-10-26 14:00 ` Andre Przywara
2015-10-26 14:07 ` Timur Tabi
2015-10-26 14:07 ` Timur Tabi
2015-10-26 14:42 ` Andre Przywara
2015-10-26 14:42 ` Andre Przywara
2015-10-26 14:47 ` Timur Tabi
2015-10-26 14:47 ` Timur Tabi
2015-10-26 15:19 ` Andre Przywara
2015-10-26 15:19 ` Andre Przywara
2015-10-26 15:31 ` Timur Tabi
2015-10-26 15:31 ` Timur Tabi
2015-10-27 22:54 ` Timur Tabi
2015-10-27 22:54 ` Timur Tabi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5630DA2A.4050803@hurleysoftware.com \
--to=peter@hurleysoftware.com \
--cc=Andrew.Jackson@arm.com \
--cc=andre.przywara@arm.com \
--cc=gregkh@linuxfoundation.org \
--cc=jason.liu@linaro.org \
--cc=jun.nie@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=shawn.guo@linaro.org \
--cc=timur@codeaurora.org \
--cc=wan.zhijun@zte.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.