diff mbox series

Align Raspberry Pi DMA interrupts with Linux DTS

Message ID 20220624195206.671993-1-andrey.makarov@auriga.com
State New
Headers show
Series Align Raspberry Pi DMA interrupts with Linux DTS | expand

Commit Message

Andrey Makarov June 24, 2022, 7:52 p.m. UTC
All Raspberry Pi models 1-3 (based on bcm2835) have
Linux device tree (arch/arm/boot/dts/bcm2835-common.dtsi +25):

    /* dma channel 11-14 share one irq */

which mismatched the Qemu model.
In this patch channels 0--10 and 11--14 are handled separately.

Signed-off-by: Andrey Makarov <andrey.makarov@auriga.com>
---
 hw/arm/bcm2835_peripherals.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Peter Maydell June 26, 2022, 10:16 a.m. UTC | #1
On Fri, 24 Jun 2022 at 21:54, Andrey Makarov <ph.makarov@gmail.com> wrote:
>
> All Raspberry Pi models 1-3 (based on bcm2835) have
> Linux device tree (arch/arm/boot/dts/bcm2835-common.dtsi +25):
>
>     /* dma channel 11-14 share one irq */
>
> which mismatched the Qemu model.
> In this patch channels 0--10 and 11--14 are handled separately.

Is there any hardware documentation that says whether QEMU or
the DTB is correct? The device tree is at best a secondary source...

> Signed-off-by: Andrey Makarov <andrey.makarov@auriga.com>
> ---
>  hw/arm/bcm2835_peripherals.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c
> index 48538c9360..3d808b0e31 100644
> --- a/hw/arm/bcm2835_peripherals.c
> +++ b/hw/arm/bcm2835_peripherals.c
> @@ -322,13 +322,21 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
>      memory_region_add_subregion(&s->peri_mr, DMA15_OFFSET,
>                  sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->dma), 1));
>
> -    for (n = 0; n <= 12; n++) {
> +    for (n = 0; n <= 10; n++) {
>          sysbus_connect_irq(SYS_BUS_DEVICE(&s->dma), n,
>                             qdev_get_gpio_in_named(DEVICE(&s->ic),
>                                                    BCM2835_IC_GPU_IRQ,
>                                                    INTERRUPT_DMA0 + n));
>      }
>
> +    /* According to DTS, dma channels 11-14 share one irq */
> +    for (n = 11; n <= 14; n++) {
> +        sysbus_connect_irq(SYS_BUS_DEVICE(&s->dma), n,
> +                           qdev_get_gpio_in_named(DEVICE(&s->ic),
> +                                                  BCM2835_IC_GPU_IRQ,
> +                                                  INTERRUPT_DMA0 + 11));

You can't connect multiple qemu_irq lines to one like this.
If the hardware behaves this way then you need to create
an OR gate, wire all the lines from the devices to the
OR gate inputs, and wire the OR gate output to the destination.

thanks
-- PMM
Makarov, Andrey June 30, 2022, 8:32 a.m. UTC | #2
> Is there any hardware documentation that says whether QEMU or
> the DTB is correct? The device tree is at best a secondary source...


No. It should have been in the "BCM2835 ARM Peripherals" datasheet but the appropriate "ARM peripherals interrupt table" there is nearly empty.


> You can't connect multiple qemu_irq lines to one like this.
> If the hardware behaves this way then you need to create
> an OR gate, wire all the lines from the devices to the
> OR gate inputs, and wire the OR gate output to the destination.


Thank you for this correction, I will send another version of patch.


Andrey Makarov,

Team Lead
diff mbox series

Patch

diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c
index 48538c9360..3d808b0e31 100644
--- a/hw/arm/bcm2835_peripherals.c
+++ b/hw/arm/bcm2835_peripherals.c
@@ -322,13 +322,21 @@  static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
     memory_region_add_subregion(&s->peri_mr, DMA15_OFFSET,
                 sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->dma), 1));
 
-    for (n = 0; n <= 12; n++) {
+    for (n = 0; n <= 10; n++) {
         sysbus_connect_irq(SYS_BUS_DEVICE(&s->dma), n,
                            qdev_get_gpio_in_named(DEVICE(&s->ic),
                                                   BCM2835_IC_GPU_IRQ,
                                                   INTERRUPT_DMA0 + n));
     }
 
+    /* According to DTS, dma channels 11-14 share one irq */
+    for (n = 11; n <= 14; n++) {
+        sysbus_connect_irq(SYS_BUS_DEVICE(&s->dma), n,
+                           qdev_get_gpio_in_named(DEVICE(&s->ic),
+                                                  BCM2835_IC_GPU_IRQ,
+                                                  INTERRUPT_DMA0 + 11));
+    }
+
     /* THERMAL */
     if (!sysbus_realize(SYS_BUS_DEVICE(&s->thermal), errp)) {
         return;