From: andre.przywara@arm.com (Andre Przywara)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 10/11] drivers: PL011: add support for the ARM SBSA generic UART
Date: Thu, 21 May 2015 12:13:30 +0100 [thread overview]
Message-ID: <555DBDDA.6070908@arm.com> (raw)
In-Reply-To: <55536096.4020008@redhat.com>
Hi Mark,
(please keep the people on CC:, I almost missed that mail)
On 05/13/2015 03:32 PM, Mark Langsdorf wrote:
> On 05/12/2015 09:14 AM, Andre Przywara wrote:
>> The ARM Server Base System Architecture[1] document describes a
>> generic UART which is a subset of the PL011 UART.
>> It lacks DMA support, baud rate control and modem status line
>> control, among other things.
>> The idea is to move the UART initialization and setup into the
>> firmware (which does this job today already) and let the kernel just
>> use the UART for sending and receiving characters.
>>
>> We use the recent refactoring to build a new struct uart_ops
>> variable which points to some new functions avoiding access to the
>> missing registers. We reuse as much existing PL011 code as possible.
>>
>> In contrast to the PL011 the SBSA UART does not define any AMBA or
>> PrimeCell relations, so we go with a pretty generic probe function
>> which only uses platform device functions.
>> A DT binding is provided with this patch, ACPI support is added in a
>> separate one.
>>
>> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
>> ---
>> .../devicetree/bindings/serial/arm_sbsa_uart.txt | 10 ++
>> drivers/tty/serial/amba-pl011.c | 168
>> +++++++++++++++++++++
>> 2 files changed, 178 insertions(+)
>> create mode 100644
>> Documentation/devicetree/bindings/serial/arm_sbsa_uart.txt
>>
>> diff --git
>> a/Documentation/devicetree/bindings/serial/arm_sbsa_uart.txt
>> b/Documentation/devicetree/bindings/serial/arm_sbsa_uart.txt
>> new file mode 100644
>> index 0000000..4163e7e
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/serial/arm_sbsa_uart.txt
>> @@ -0,0 +1,10 @@
>> +* ARM SBSA defined generic UART
>> +This UART uses a subset of the PL011 registers and consequently lives
>> +in the PL011 driver. It's baudrate and other communication parameters
>> +cannot be adjusted at runtime, so it lacks a clock specifier here.
>> +
>> +Required properties:
>> +- compatible: must be "arm,sbsa-uart"
>> +- reg: exactly one register range
>> +- interrupts: exactly one interrupt specifier
>> +- current-speed: the (fixed) baud rate set by the firmware
>> diff --git a/drivers/tty/serial/amba-pl011.c
>> b/drivers/tty/serial/amba-pl011.c
>> index 70e2958..cca93d9 100644
>> --- a/drivers/tty/serial/amba-pl011.c
>> +++ b/drivers/tty/serial/amba-pl011.c
....
>> @@ -1872,6 +1915,24 @@ pl011_set_termios(struct uart_port *port,
>> struct ktermios *termios,
>> spin_unlock_irqrestore(&port->lock, flags);
>> }
>>
>> +static void
>> +sbsa_uart_set_termios(struct uart_port *port, struct ktermios *termios,
>> + struct ktermios *old)
>> +{
>> + struct uart_amba_port *uap =
>> + container_of(port, struct uart_amba_port, port);
>> + unsigned long flags;
>> +
>> + if (old)
>> + tty_termios_copy_hw(termios, old);
>
> This code prevented login via the serial console on our test hardware.
>
> Mark Salter suggested the following patch:
>
> - if (old)
> + /*
> + * The first call to set_termios() comes when the console is
> + * registered via uart_add_one_port(). The serial core will
> + * pass in a dummy old termios rather than NULL. Check to make
> + * sure the old termios has reasonable info before copying from
> + * it.
> + */
> + if (old && old->c_cflag)
> tty_termios_copy_hw(termios, old);
That seems like a kludge to me.
Regardless of the reason why uart_send_options() is passing a
dummy variable instead of a NULL pointer (which documentation explicitly
declares as legal) I saw that this unconditional copying of the old
value being common practise in various drivers, actually the default for
drivers not implementing set_termios at all.
Can you describe a setup where this issue shows up? I haven't observed
this issue in my testing.
But in fact I think we actually shouldn't care about the old value at
all. Instead we should filter the new termios settings to avoid userland
configuring for instance flow control or an differing byte format which
the SBSA UART does not support.
I will cook up a patch and send out a v5 ASAP.
Cheers,
Andre.
>
> which fixed the issue.
>
>> + tty_termios_encode_baud_rate(termios, uap->fixed_baud,
>> uap->fixed_baud);
>> +
>> + spin_lock_irqsave(&port->lock, flags);
>> + uart_update_timeout(port, CS8, uap->fixed_baud);
>> + pl011_setup_status_masks(port, termios);
>> + spin_unlock_irqrestore(&port->lock, flags);
>> +}
>> +
>> static const char *pl011_type(struct uart_port *port)
>> {
>> struct uart_amba_port *uap =
next prev parent reply other threads:[~2015-05-21 11:13 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-12 14:14 [PATCH v4 00/11] drivers: PL011: add ARM SBSA Generic UART support Andre Przywara
2015-05-12 14:14 ` [PATCH v4 01/11] drivers: PL011: avoid potential unregister_driver call Andre Przywara
2015-05-12 14:14 ` [PATCH v4 02/11] drivers: PL011: refactor pl011_startup() Andre Przywara
2015-05-12 14:14 ` [PATCH v4 03/11] drivers: PL011: refactor pl011_shutdown() Andre Przywara
2015-05-12 14:14 ` [PATCH v4 04/11] drivers: PL011: refactor pl011_set_termios() Andre Przywara
2015-05-12 14:14 ` [PATCH v4 05/11] drivers: PL011: refactor pl011_probe() Andre Przywara
2015-05-12 14:14 ` [PATCH v4 06/11] drivers: PL011: replace UART_MIS reading with _RIS & _IMSC Andre Przywara
2015-05-12 14:14 ` [PATCH v4 07/11] drivers: PL011: move cts_event workaround into separate function Andre Przywara
2015-05-12 14:14 ` [PATCH v4 08/11] drivers: PL011: allow avoiding UART enabling/disabling Andre Przywara
2015-05-12 14:14 ` [PATCH v4 09/11] drivers: PL011: allow to supply fixed option string Andre Przywara
2015-05-12 14:14 ` [PATCH v4 10/11] drivers: PL011: add support for the ARM SBSA generic UART Andre Przywara
2015-05-13 14:32 ` Mark Langsdorf
2015-05-13 15:03 ` Graeme Gregory
2015-05-21 11:13 ` Andre Przywara [this message]
2015-05-21 12:49 ` Naresh Bhat
2015-05-21 15:12 ` Mark Langsdorf
2015-05-12 14:14 ` [PATCH v4 11/11] drivers: PL011: add ACPI probing for SBSA UART Andre Przywara
2015-05-13 1:09 ` Hanjun Guo
2015-05-12 15:18 ` [PATCH v4 00/11] drivers: PL011: add ARM SBSA Generic UART support Jakub Kiciński
2015-05-12 16:42 ` Robert Richter
2015-05-13 9:17 ` Lorenzo Pieralisi
2015-05-15 3:31 ` Hanjun Guo
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=555DBDDA.6070908@arm.com \
--to=andre.przywara@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).