diff mbox series

[v1,3/3] hw/arm/sbsa-ref: use bsa.h for PPI definitions

Message ID 20230915115535.129834-4-quic_llindhol@quicinc.com
State New
Headers show
Series Refactor PPI logic/definitions for virt/sbsa-ref | expand

Commit Message

Leif Lindholm Sept. 15, 2023, 11:55 a.m. UTC
Use the private peripheral interrupt definitions from bsa.h instead of
defining them locally. Refactor to use PPI() to convert from INTID macro
where necessary.

Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com>
---
 hw/arm/sbsa-ref.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

Comments

Peter Maydell Sept. 18, 2023, 10:45 a.m. UTC | #1
On Fri, 15 Sept 2023 at 12:55, Leif Lindholm <quic_llindhol@quicinc.com> wrote:
>
> Use the private peripheral interrupt definitions from bsa.h instead of
> defining them locally. Refactor to use PPI() to convert from INTID macro
> where necessary.
>
> Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com>
> ---
>  hw/arm/sbsa-ref.c | 23 +++++++++++------------
>  1 file changed, 11 insertions(+), 12 deletions(-)
>
> diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
> index bc89eb4806..3a4ea4dfdd 100644
> --- a/hw/arm/sbsa-ref.c
> +++ b/hw/arm/sbsa-ref.c
> @@ -2,6 +2,7 @@
>   * ARM SBSA Reference Platform emulation
>   *
>   * Copyright (c) 2018 Linaro Limited
> + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
>   * Written by Hongbo Zhang <hongbo.zhang@linaro.org>
>   *
>   * This program is free software; you can redistribute it and/or modify it
> @@ -30,6 +31,7 @@
>  #include "exec/hwaddr.h"
>  #include "kvm_arm.h"
>  #include "hw/arm/boot.h"
> +#include "hw/arm/bsa.h"
>  #include "hw/arm/fdt.h"
>  #include "hw/arm/smmuv3.h"
>  #include "hw/block/flash.h"
> @@ -55,13 +57,6 @@
>  #define NUM_SMMU_IRQS   4
>  #define NUM_SATA_PORTS  6
>
> -#define VIRTUAL_PMU_IRQ        7
> -#define ARCH_GIC_MAINT_IRQ     9
> -#define ARCH_TIMER_VIRT_IRQ    11
> -#define ARCH_TIMER_S_EL1_IRQ   13
> -#define ARCH_TIMER_NS_EL1_IRQ  14
> -#define ARCH_TIMER_NS_EL2_IRQ  10
> -
>  enum {
>      SBSA_FLASH,
>      SBSA_MEM,
> @@ -494,15 +489,19 @@ static void create_gic(SBSAMachineState *sms, MemoryRegion *mem)
>          for (irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) {
>              qdev_connect_gpio_out(cpudev, irq,
>                                    qdev_get_gpio_in(sms->gic,
> -                                                   ppibase + timer_irq[irq]));
> +                                                   ppibase
> +                                                   + PPI(timer_irq[irq])));
>          }
>
>          qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interrupt", 0,
> -                                    qdev_get_gpio_in(sms->gic, ppibase
> -                                                     + ARCH_GIC_MAINT_IRQ));
> +                                    qdev_get_gpio_in(sms->gic,
> +                                                     ppibase
> +                                                     + PPI(ARCH_GIC_MAINT_IRQ)));
> +
>          qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0,
> -                                    qdev_get_gpio_in(sms->gic, ppibase
> -                                                     + VIRTUAL_PMU_IRQ));
> +                                    qdev_get_gpio_in(sms->gic,
> +                                                     ppibase
> +                                                     + PPI(VIRTUAL_PMU_IRQ)));
>
>          sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ));
>          sysbus_connect_irq(gicbusdev, i + smp_cpus,

You could also change the definition of ppibase not to add GIC_NR_SGIS
(perhaps renaming it) and then you wouldn't need to use the PPI() macro here...

-- PMM
diff mbox series

Patch

diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
index bc89eb4806..3a4ea4dfdd 100644
--- a/hw/arm/sbsa-ref.c
+++ b/hw/arm/sbsa-ref.c
@@ -2,6 +2,7 @@ 
  * ARM SBSA Reference Platform emulation
  *
  * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  * Written by Hongbo Zhang <hongbo.zhang@linaro.org>
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -30,6 +31,7 @@ 
 #include "exec/hwaddr.h"
 #include "kvm_arm.h"
 #include "hw/arm/boot.h"
+#include "hw/arm/bsa.h"
 #include "hw/arm/fdt.h"
 #include "hw/arm/smmuv3.h"
 #include "hw/block/flash.h"
@@ -55,13 +57,6 @@ 
 #define NUM_SMMU_IRQS   4
 #define NUM_SATA_PORTS  6
 
-#define VIRTUAL_PMU_IRQ        7
-#define ARCH_GIC_MAINT_IRQ     9
-#define ARCH_TIMER_VIRT_IRQ    11
-#define ARCH_TIMER_S_EL1_IRQ   13
-#define ARCH_TIMER_NS_EL1_IRQ  14
-#define ARCH_TIMER_NS_EL2_IRQ  10
-
 enum {
     SBSA_FLASH,
     SBSA_MEM,
@@ -494,15 +489,19 @@  static void create_gic(SBSAMachineState *sms, MemoryRegion *mem)
         for (irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) {
             qdev_connect_gpio_out(cpudev, irq,
                                   qdev_get_gpio_in(sms->gic,
-                                                   ppibase + timer_irq[irq]));
+                                                   ppibase
+                                                   + PPI(timer_irq[irq])));
         }
 
         qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interrupt", 0,
-                                    qdev_get_gpio_in(sms->gic, ppibase
-                                                     + ARCH_GIC_MAINT_IRQ));
+                                    qdev_get_gpio_in(sms->gic,
+                                                     ppibase
+                                                     + PPI(ARCH_GIC_MAINT_IRQ)));
+
         qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0,
-                                    qdev_get_gpio_in(sms->gic, ppibase
-                                                     + VIRTUAL_PMU_IRQ));
+                                    qdev_get_gpio_in(sms->gic,
+                                                     ppibase
+                                                     + PPI(VIRTUAL_PMU_IRQ)));
 
         sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ));
         sysbus_connect_irq(gicbusdev, i + smp_cpus,