diff mbox series

[v2,1/2] ns16550: Add compatible string for Raspberry Pi 4

Message ID 6f94e7b0f1cfe98a640d7f9ff59f18f299fd0d7d.1564371527.git.stewart.hildebrand@dornerworks.com (mailing list archive)
State New, archived
Headers show
Series Raspberry Pi 4 support | expand

Commit Message

Stewart Hildebrand July 29, 2019, 1:19 p.m. UTC
Per the BCM2835 peripherals datasheet [1] page 10:
"The UART core is build to emulate 16550 behaviour ... The implemented
UART is not a 16650 compatible UART However as far as possible the
first 8 control and status registers are laid out like a 16550 UART. Al
16550 register bits which are not supported can be written but will be
ignored and read back as 0. All control bits for simple UART receive/
transmit operations are available."

Additionally, Linux uses the 8250/16550 driver for the aux UART [2].

Unfortunately the brcm,bcm2835-aux-uart device tree binding doesn't
have the reg-shift and reg-io-width properties [3]. Thus, the reg-shift
and reg-io-width properties are inherent properties of this UART.

Thanks to Andre Przywara for contributing the reg-shift and
reg-io-width setting snippet.

In my testing, I have relied on enable_uart=1 being set in config.txt,
a configuration file read by the Raspberry Pi's firmware. With
enable_uart=1, the firmware performs UART initialization.

[1] https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2835/BCM2835-ARM-Peripherals.pdf
[2] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/tty/serial/8250/8250_bcm2835aux.c
[3] https://www.kernel.org/doc/Documentation/devicetree/bindings/serial/brcm,bcm2835-aux-uart.txt

Signed-off-by: Stewart Hildebrand <stewart.hildebrand@dornerworks.com>
---
 xen/drivers/char/ns16550.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Andre Przywara July 29, 2019, 4:06 p.m. UTC | #1
On Mon, 29 Jul 2019 09:19:19 -0400
Stewart Hildebrand <stewart.hildebrand@dornerworks.com> wrote:

Hi,

> Per the BCM2835 peripherals datasheet [1] page 10:
> "The UART core is build to emulate 16550 behaviour ... The implemented
> UART is not a 16650 compatible UART However as far as possible the
> first 8 control and status registers are laid out like a 16550 UART. Al
> 16550 register bits which are not supported can be written but will be
> ignored and read back as 0. All control bits for simple UART receive/
> transmit operations are available."
> 
> Additionally, Linux uses the 8250/16550 driver for the aux UART [2].
> 
> Unfortunately the brcm,bcm2835-aux-uart device tree binding doesn't
> have the reg-shift and reg-io-width properties [3]. Thus, the reg-shift
> and reg-io-width properties are inherent properties of this UART.
> 
> Thanks to Andre Przywara for contributing the reg-shift and
> reg-io-width setting snippet.
> 
> In my testing, I have relied on enable_uart=1 being set in config.txt,
> a configuration file read by the Raspberry Pi's firmware. With
> enable_uart=1, the firmware performs UART initialization.
> 
> [1] https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2835/BCM2835-ARM-Peripherals.pdf
> [2] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/tty/serial/8250/8250_bcm2835aux.c
> [3] https://www.kernel.org/doc/Documentation/devicetree/bindings/serial/brcm,bcm2835-aux-uart.txt
> 
> Signed-off-by: Stewart Hildebrand <stewart.hildebrand@dornerworks.com>

Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Tested-by: Andre Przywara <andre.przywara@arm.com>

Cheers,
Andre.

> ---
>  xen/drivers/char/ns16550.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
> index e518f2d790..8667de6d67 100644
> --- a/xen/drivers/char/ns16550.c
> +++ b/xen/drivers/char/ns16550.c
> @@ -1585,6 +1585,12 @@ static int __init ns16550_uart_dt_init(struct dt_device_node *dev,
>      if ( uart->reg_width != 1 && uart->reg_width != 4 )
>          return -EINVAL;
>  
> +    if ( dt_device_is_compatible(dev, "brcm,bcm2835-aux-uart") )
> +    {
> +        uart->reg_width = 4;
> +        uart->reg_shift = 2;
> +    }
> +
>      res = platform_get_irq(dev, 0);
>      if ( ! res )
>          return -EINVAL;
> @@ -1611,6 +1617,7 @@ static const struct dt_device_match ns16550_dt_match[] __initconst =
>      DT_MATCH_COMPATIBLE("ns16550"),
>      DT_MATCH_COMPATIBLE("ns16550a"),
>      DT_MATCH_COMPATIBLE("snps,dw-apb-uart"),
> +    DT_MATCH_COMPATIBLE("brcm,bcm2835-aux-uart"),
>      { /* sentinel */ },
>  };
>
Julien Grall July 31, 2019, noon UTC | #2
Hi,

On 29/07/2019 17:06, Andre Przywara wrote:
> On Mon, 29 Jul 2019 09:19:19 -0400
> Stewart Hildebrand <stewart.hildebrand@dornerworks.com> wrote:
> 
> Hi,
> 
>> Per the BCM2835 peripherals datasheet [1] page 10:
>> "The UART core is build to emulate 16550 behaviour ... The implemented
>> UART is not a 16650 compatible UART However as far as possible the
>> first 8 control and status registers are laid out like a 16550 UART. Al
>> 16550 register bits which are not supported can be written but will be
>> ignored and read back as 0. All control bits for simple UART receive/
>> transmit operations are available."
>>
>> Additionally, Linux uses the 8250/16550 driver for the aux UART [2].
>>
>> Unfortunately the brcm,bcm2835-aux-uart device tree binding doesn't
>> have the reg-shift and reg-io-width properties [3]. Thus, the reg-shift
>> and reg-io-width properties are inherent properties of this UART.
>>
>> Thanks to Andre Przywara for contributing the reg-shift and
>> reg-io-width setting snippet.
>>
>> In my testing, I have relied on enable_uart=1 being set in config.txt,
>> a configuration file read by the Raspberry Pi's firmware. With
>> enable_uart=1, the firmware performs UART initialization.
>>
>> [1] https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2835/BCM2835-ARM-Peripherals.pdf
>> [2] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/tty/serial/8250/8250_bcm2835aux.c
>> [3] https://www.kernel.org/doc/Documentation/devicetree/bindings/serial/brcm,bcm2835-aux-uart.txt
>>
>> Signed-off-by: Stewart Hildebrand <stewart.hildebrand@dornerworks.com>
> 
> Reviewed-by: Andre Przywara <andre.przywara@arm.com>
> Tested-by: Andre Przywara <andre.przywara@arm.com>

Acked-by: Julien Grall <julien.grall@arm.com>

Cheers,
diff mbox series

Patch

diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index e518f2d790..8667de6d67 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -1585,6 +1585,12 @@  static int __init ns16550_uart_dt_init(struct dt_device_node *dev,
     if ( uart->reg_width != 1 && uart->reg_width != 4 )
         return -EINVAL;
 
+    if ( dt_device_is_compatible(dev, "brcm,bcm2835-aux-uart") )
+    {
+        uart->reg_width = 4;
+        uart->reg_shift = 2;
+    }
+
     res = platform_get_irq(dev, 0);
     if ( ! res )
         return -EINVAL;
@@ -1611,6 +1617,7 @@  static const struct dt_device_match ns16550_dt_match[] __initconst =
     DT_MATCH_COMPATIBLE("ns16550"),
     DT_MATCH_COMPATIBLE("ns16550a"),
     DT_MATCH_COMPATIBLE("snps,dw-apb-uart"),
+    DT_MATCH_COMPATIBLE("brcm,bcm2835-aux-uart"),
     { /* sentinel */ },
 };