Raspberry Pi 4 support
v2 cover Raspberry Pi 4 support
This is a series to enable UART console for Raspberry Pi 4. Note that I'm relying on the firmware to initialize the UART (i.e. enable_uart=1 in config.txt), since full UART initialization on this platform requires accessing some registers outside the range specified in the brcm,bcm2835-aux-uart node.
I have been able to get Xen+dom0+domUs booting. Tested with Xen 4.12 and 4.13-unstable (b4c8a27d5b) and Linux 4.19.y (Raspberry Pi linux tree + a couple of patches). Please see [1] for build instructions and limitations.
New in v2:
* Drop early printk alias
* Set reg-shift and reg-io-width in the Xen driver
* Blacklist other aux peripherals in platform settings (spi1, spi2, and a couple of base aux registers)
Thanks,
Stewart Hildebrand
DornerWorks, Ltd
[1] https://github.com/dornerworks/xen-rpi4-builder
Stewart Hildebrand (2):
ns16550: Add compatible string for Raspberry Pi 4 xen/arm: platform: Add Raspberry Pi platform
xen/arch/arm/platforms/Makefile | 1 + xen/arch/arm/platforms/brcm-raspberry-pi.c | 55 ++++++++++++++++++++++ xen/drivers/char/ns16550.c | 7 +++ 3 files changed, 63 insertions(+) create mode 100644 xen/arch/arm/platforms/brcm-raspberry-pi.c
Signature · 7 lines
2.22.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 1/2 ns16550: Add compatible string for Raspberry Pi 4
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
--- xen/drivers/char/ns16550.c | 7 +++++++ 1 file changed, 7 insertions(+)
xen/drivers/char/ns16550.c +7 -0
@@ -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 */ }, };
Signature · 7 lines
2.22.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v2 1/2] ns16550: Add compatible string for Raspberry Pi 4
On Mon, 29 Jul 2019 09:19:19 -0400
Stewart Hildebrand <[email protected]> wrote:
Hi,
Quoted 21 lines
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.
Quoted 5 lines
[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.txtSigned-off-by Stewart Hildebrand <[email protected]>
Cheers,
Andre.
Quoted 22 lines
--- xen/drivers/char/ns16550.c | 7 +++++++ 1 file changed, 7 insertions(+)xen/drivers/char/ns16550.c +6
-0@@ -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 ;
xen/drivers/char/ns16550.c static const struct dt_device_match ns16550_dt_match[] __initconst = · line 1623
Quoted 7 lines
xen/drivers/char/ns16550.c +1
-0@@ -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 */ }, };
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Julien Grall
Acked-byRe: [Xen-devel] [PATCH v2 1/2] ns16550: Add compatible string for Raspberry Pi 4
Hi,
Quoted 26 lines · Andre Przywara
On Mon, 29 Jul 2019 09:19:19 -0400
Stewart Hildebrand <[email protected]> wrote:Hi,
Quoted 21 lines
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.
Quoted 8 lines
Quoted 5 lines
[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.txtSigned-off-by Stewart Hildebrand <[email protected]>Reviewed-by Andre Przywara <[email protected]>Tested-by Andre Przywara <[email protected]>
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 2/2 xen/arm: platform: Add Raspberry Pi platform
In reply to Stewart HildebrandThe aux peripherals (uart1, spi1, and spi2) share an IRQ and a page of memory. For debugging, it is helpful to use the aux UART in Xen. In this case, Xen would try to assign spi1 and spi2 to dom0, but this results in an error since the shared IRQ was already assigned to Xen. Blacklist aux devices other than the UART to prevent mapping the shared IRQ and memory range to dom0.
--- xen/arch/arm/platforms/Makefile | 1 + xen/arch/arm/platforms/brcm-raspberry-pi.c | 55 ++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 xen/arch/arm/platforms/brcm-raspberry-pi.c
xen/arch/arm/platforms/Makefile +1 -0
@@ -8,5 +8,6 @@ obj-$(CONFIG_ALL64_PLAT) += seattle.o obj-$(CONFIG_ALL_PLAT) += sunxi.o obj-$(CONFIG_ALL64_PLAT) += thunderx.o obj-$(CONFIG_ALL64_PLAT) += xgene-storm.o +obj-$(CONFIG_ALL64_PLAT) += brcm-raspberry-pi.o obj-$(CONFIG_MPSOC_PLATFORM) += xilinx-zynqmp.o obj-$(CONFIG_MPSOC_PLATFORM) += xilinx-zynqmp-eemi.o
xen/arch/arm/platforms/brcm-raspberry-pi.c new file +55 -0
55 lines not on this page · raw message
Signature · 7 lines
2.22.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v2 2/2] xen/arm: platform: Add Raspberry Pi platform
Hi Stewart,
Quoted 6 lines · Stewart Hildebrand
The aux peripherals (uart1, spi1, and spi2) share an IRQ and a page of memory. For debugging, it is helpful to use the aux UART in Xen. In this case, Xen would try to assign spi1 and spi2 to dom0, but this results in an error since the shared IRQ was already assigned to Xen. Blacklist aux devices other than the UART to prevent mapping the shared IRQ and memory range to dom0.
Reading the commit message, it is unclear what's the impact on blacklist spi1 and spi2. Could you expand it?
The rest of the patch looks good.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v2 2/2] xen/arm: platform: Add Raspberry Pi platform
Quoted 1 line · Julien Grall
Hi Stewart,
Hi Julien
Quoted 10 lines · Stewart Hildebrand
Quoted 6 lines
The aux peripherals (uart1, spi1, and spi2) share an IRQ and a page of memory. For debugging, it is helpful to use the aux UART in Xen. In this case, Xen would try to assign spi1 and spi2 to dom0, but this results in an error since the shared IRQ was already assigned to Xen. Blacklist aux devices other than the UART to prevent mapping the shared IRQ and memory range to dom0.
Reading the commit message, it is unclear what's the impact on blacklist spi1 and spi2. Could you expand it?
Yes, good thinking. What do you think about the following (the first paragraph is unchanged, just copied for completeness):
"The aux peripherals (uart1, spi1, and spi2) share an IRQ and a page of memory. For debugging, it is helpful to use the aux UART in Xen. In this case, Xen would try to assign spi1 and spi2 to dom0, but this results in an error since the shared IRQ was already assigned to Xen. Blacklist aux devices other than the UART to prevent mapping the shared IRQ and memory range to dom0.
Blacklisting spi1 and spi2 unfortunately makes those peripherals unavailable for use in the system. Future work could include forwarding the IRQ for spi1 and spi2, and trap and mediate access to the memory range for spi1 and spi2."
Would you like me to re-send the patch, or can the message be updated on commit?
Stew
Quoted 6 lines
The rest of the patch looks good.
Cheers,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Julien Grall
Acked-byRe: [Xen-devel] [PATCH v2 2/2] xen/arm: platform: Add Raspberry Pi platform
Hi,
Quoted 25 lines · Stewart Hildebrand
Quoted 1 line · Julien Grall
Hi Stewart,
Hi Julien
Quoted 10 lines · Stewart Hildebrand
Quoted 6 lines
The aux peripherals (uart1, spi1, and spi2) share an IRQ and a page of memory. For debugging, it is helpful to use the aux UART in Xen. In this case, Xen would try to assign spi1 and spi2 to dom0, but this results in an error since the shared IRQ was already assigned to Xen. Blacklist aux devices other than the UART to prevent mapping the shared IRQ and memory range to dom0.
Reading the commit message, it is unclear what's the impact on blacklist spi1 and spi2. Could you expand it?
Yes, good thinking. What do you think about the following (the first paragraph is unchanged, just copied for completeness):
"The aux peripherals (uart1, spi1, and spi2) share an IRQ and a page of memory. For debugging, it is helpful to use the aux UART in Xen. In this case, Xen would try to assign spi1 and spi2 to dom0, but this results in an error since the shared IRQ was already assigned to Xen. Blacklist aux devices other than the UART to prevent mapping the shared IRQ and memory range to dom0.
Quoted 4 lines
Blacklisting spi1 and spi2 unfortunately makes those peripherals unavailable for use in the system. Future work could include forwarding the IRQ for spi1 and spi2, and trap and mediate access to the memory range for spi1 and spi2."
Ok, so they are not critical to boot Dom0. Good :).
Hopefully they will learn the lesson for the next generation!
Quoted 2 lines
Would you like me to re-send the patch, or can the message be updated on commit?
No, I will update the commit message and commit it later on today.
With the new commit message:
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi Stewart,
Quoted 9 lines · Stewart Hildebrand
This is a series to enable UART console for Raspberry Pi 4. Note that I'm relying on the firmware to initialize the UART (i.e. enable_uart=1 in config.txt), since full UART initialization on this platform requires accessing some registers outside the range specified in the brcm,bcm2835-aux-uart node.
I have been able to get Xen+dom0+domUs booting. Tested with Xen 4.12 and 4.13-unstable (
b4c8a27d5b) and Linux 4.19.y (Raspberry Pi linux tree + a couple of patches). Please see [1] for build instructions and limitations.New in v2:
* Drop early printk alias
* Set reg-shift and reg-io-width in the Xen driver
* Blacklist other aux peripherals in platform settings (spi1, spi2, and a couple of base aux registers)
Quoted 8 lines
Thanks,
Stewart Hildebrand
DornerWorks, Ltd[1] https://github.com/dornerworks/xen-rpi4-builder
Stewart Hildebrand (2):
ns16550: Add compatible string for Raspberry Pi 4
I have committed this patch...
Quoted 1 line
xen/arm: platform: Add Raspberry Pi platform
... this one need an answer regarding the impact on blacklist spi1 and spi2.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi,
Quoted 16 lines · Julien Grall
Quoted 15 lines · Stewart Hildebrand
This is a series to enable UART console for Raspberry Pi 4. Note that I'm relying on the firmware to initialize the UART (i.e. enable_uart=1 in config.txt), since full UART initialization on this platform requires accessing some registers outside the range specified in the brcm,bcm2835-aux-uart node.
I have been able to get Xen+dom0+domUs booting. Tested with Xen 4.12 and 4.13-unstable (
b4c8a27d5b) and Linux 4.19.y (Raspberry Pi linux tree + a couple of patches). Please see [1] for build instructions and limitations.New in v2:
* Drop early printk alias
* Set reg-shift and reg-io-width in the Xen driver
* Blacklist other aux peripherals in platform settings (spi1, spi2, and a couple of base aux registers)Thanks,
Stewart Hildebrand
DornerWorks, Ltd
Quoted 7 lines
Quoted 2 lines
Stewart Hildebrand (2):
ns16550: Add compatible string for Raspberry Pi 4I have committed this patch...
Quoted 1 line
xen/arm: platform: Add Raspberry Pi platform
... this one need an answer regarding the impact on blacklist spi1 and spi2.
This patch is now merged as well. Thank you for adding support for the RPI4!
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
On Mon, 29 Jul 2019 09:19:18 -0400
Stewart Hildebrand <[email protected]> wrote:
Hi,
Quoted 3 lines
This is a series to enable UART console for Raspberry Pi 4. Note that I'm relying on the firmware to initialize the UART (i.e. enable_uart=1 in config.txt), since full UART initialization on this platform requires accessing some registers outside the range specified in the brcm,bcm2835-aux-uart node.
I have been able to get Xen+dom0+domUs booting. Tested with Xen 4.12 and 4.13-unstable (
b4c8a27d5b)
Mmmh, did that really work for you? I needed the next commit in staging as well:
commit ead6b9f78355e8d366e0c80c4a73fa7fbd6d26cc
Author: Andrii Anisov <[email protected]> Date: Thu Jul 18 16:22:20 2019 +0300
xen/arm: cpuerrata: Align a virtual address before unmap
Otherwise Xen would crash before even considering Dom0.
With Andrii's patch, your two patches and Stefano's resmem series I was able to at least run Xen till it was looking for Dom0, from U-Boot, with ATF (providing PSCI). There seems to be some hiccup in the reserved-memory code in U-Boot, where U-Boot tries to use the already region, but that's an independent matter.
Cheers,
Andre.
Quoted 17 lines
and Linux 4.19.y (Raspberry Pi linux tree + a couple of patches). Please see [1] for build instructions and limitations.
New in v2:
* Drop early printk alias
* Set reg-shift and reg-io-width in the Xen driver
* Blacklist other aux peripherals in platform settings (spi1, spi2, and a couple of base aux registers)Thanks,
Stewart Hildebrand
DornerWorks, Ltd[1] https://github.com/dornerworks/xen-rpi4-builder
Stewart Hildebrand (2):
ns16550: Add compatible string for Raspberry Pi 4 xen/arm: platform: Add Raspberry Pi platform
Quoted 6 lines
xen/arch/arm/platforms/Makefile | 1 + xen/arch/arm/platforms/brcm-raspberry-pi.c | 55 ++++++++++++++++++++++ xen/drivers/char/ns16550.c | 7 +++ 3 files changed, 63 insertions(+) create mode 100644 xen/arch/arm/platforms/brcm-raspberry-pi.c
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 9 lines · Andre Przywara
On Mon, 29 Jul 2019 09:19:18 -0400
Stewart Hildebrand <[email protected]> wrote:Hi,
Quoted 3 lines
This is a series to enable UART console for Raspberry Pi 4. Note that I'm relying on the firmware to initialize the UART (i.e. enable_uart=1 in config.txt), since full UART initialization on this platform requires accessing some registers outside the range specified in the brcm,bcm2835-aux-uart node.
I have been able to get Xen+dom0+domUs booting. Tested with Xen 4.12 and 4.13-unstable (
b4c8a27d5b)
Quoted 8 lines
Mmmh, did that really work for you? I needed the next commit in staging as well:
commitead6b9f78355e8d366e0c80c4a73fa7fbd6d26ccAuthor: Andrii Anisov <[email protected]> Date: Thu Jul 18 16:22:20 2019 +0300xen/arm: cpuerrata: Align a virtual address before unmap
Otherwise Xen would crash before even considering Dom0.
Hmm... Yes. I did not have Andrii's patch included in my tests. I tested in 4.13-unstable (b4c8a27d5b) and on 4.12 (604ee1116d3e), it booted into Xen+dom0. Now that I'm thinking about it, the domU test may have only been on 4.12, not on 4.13-unstable.
Quoted 2 lines
With Andrii's patch, your two patches and Stefano's resmem series I was able to at least run Xen till it was looking for Dom0, from U- Boot, with ATF (providing PSCI).
I'm not using ATF/U-Boot, and I've limited system RAM to total_mem=1024 in config.txt (even though I have the 4GB model) due to some DMA/driver issues (SD card, PCIe, etc) with the 64-bit RPi kernel. I also did not have Stefano's reserved-memory series applied in any test.
The following logs are a from couple of test runs from 4.13-unstable on Sun Jul 28:
(XEN) RAM: 0000000000000000 - 000000003b3fffff
(XEN)
(XEN) MODULE[0]: 000000002eff5f00 - 000000002effff49 Device Tree (XEN) MODULE[1]: 0000000000480000 - 0000000001400000 Kernel (XEN) RESVD[0]: 0000000000000000 - 0000000000001000
...
(XEN) Allocating 1:1 mappings totalling 512MB for dom0:
(XEN) BANK[0] 0x00000010000000-0x00000028000000 (384MB) (XEN) BANK[1] 0x00000030000000-0x00000038000000 (128MB)
Curiously, in another test with total_mem=1536, Xen happened to allocate memory for dom0 in a different way. I am noticing that the RPi firmware carved out a hole in RAM for me in this case.
(XEN) RAM: 0000000000000000 - 000000003b3fffff
(XEN) RAM: 0000000040000000 - 000000005fffffff
(XEN)
(XEN) MODULE[0]: 000000002eff5f00 - 000000002effff55 Device Tree (XEN) MODULE[1]: 0000000000480000 - 0000000001400000 Kernel (XEN) RESVD[0]: 0000000000000000 - 0000000000001000
...
(XEN) Allocating 1:1 mappings totalling 512MB for dom0:
(XEN) BANK[0] 0x00000010000000-0x00000020000000 (256MB) (XEN) BANK[1] 0x00000040000000-0x00000050000000 (256MB)
Stew
Quoted 29 lines
There seems to be some hiccup in the reserved-memory code in U-Boot, where U-Boot tries to use the already region, but that's an independent matter.
Cheers,
Andre.Quoted 23 lines
and Linux 4.19.y (Raspberry Pi linux tree + a couple of patches). Please see [1] for build instructions and limitations.
New in v2:
* Drop early printk alias
* Set reg-shift and reg-io-width in the Xen driver
* Blacklist other aux peripherals in platform settings (spi1, spi2, and a couple of base aux registers)Thanks,
Stewart Hildebrand
DornerWorks, Ltd[1] https://github.com/dornerworks/xen-rpi4-builder
Stewart Hildebrand (2):
ns16550: Add compatible string for Raspberry Pi 4 xen/arm: platform: Add Raspberry Pi platformxen/arch/arm/platforms/Makefile | 1 + xen/arch/arm/platforms/brcm-raspberry-pi.c | 55 ++++++++++++++++++++++ xen/drivers/char/ns16550.c | 7 +++ 3 files changed, 63 insertions(+) create mode 100644 xen/arch/arm/platforms/brcm-raspberry-pi.c
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel