[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/16] hw/arm/musicpal: Don't connect two qemu_irqs directly to th
From: |
Peter Maydell |
Subject: |
[PULL 12/16] hw/arm/musicpal: Don't connect two qemu_irqs directly to the same input |
Date: |
Tue, 10 Nov 2020 11:19:13 +0000 |
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
The MusicPal board code connects both of the IRQ outputs of the UART
to the same INTC qemu_irq. Connecting two qemu_irqs outputs directly
to the same input is not valid as it produces subtly wrong behaviour
(for instance if both the IRQ lines are high, and then one goes
low, the INTC input will see this as a high-to-low transition
even though the second IRQ line should still be holding it high).
This kind of wiring needs an explicitly created OR gate; add one.
Inspired-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20201107193403.436146-5-f4bug@amsat.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/arm/musicpal.c | 17 +++++++++++++----
hw/arm/Kconfig | 1 +
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index 5eb3f969fb4..ebc3ec24ef7 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -27,6 +27,7 @@
#include "ui/console.h"
#include "hw/i2c/i2c.h"
#include "hw/irq.h"
+#include "hw/or-irq.h"
#include "hw/audio/wm8750.h"
#include "sysemu/block-backend.h"
#include "sysemu/runstate.h"
@@ -77,8 +78,7 @@
#define MP_TIMER4_IRQ 7
#define MP_EHCI_IRQ 8
#define MP_ETH_IRQ 9
-#define MP_UART1_IRQ 11
-#define MP_UART2_IRQ 11
+#define MP_UART_SHARED_IRQ 11
#define MP_GPIO_IRQ 12
#define MP_RTC_IRQ 28
#define MP_AUDIO_IRQ 30
@@ -1589,6 +1589,7 @@ static void musicpal_init(MachineState *machine)
ARMCPU *cpu;
qemu_irq pic[32];
DeviceState *dev;
+ DeviceState *uart_orgate;
DeviceState *i2c_dev;
DeviceState *lcd_dev;
DeviceState *key_dev;
@@ -1627,9 +1628,17 @@ static void musicpal_init(MachineState *machine)
pic[MP_TIMER2_IRQ], pic[MP_TIMER3_IRQ],
pic[MP_TIMER4_IRQ], NULL);
- serial_mm_init(address_space_mem, MP_UART1_BASE, 2, pic[MP_UART1_IRQ],
+ /* Logically OR both UART IRQs together */
+ uart_orgate = DEVICE(object_new(TYPE_OR_IRQ));
+ object_property_set_int(OBJECT(uart_orgate), "num-lines", 2, &error_fatal);
+ qdev_realize_and_unref(uart_orgate, NULL, &error_fatal);
+ qdev_connect_gpio_out(DEVICE(uart_orgate), 0, pic[MP_UART_SHARED_IRQ]);
+
+ serial_mm_init(address_space_mem, MP_UART1_BASE, 2,
+ qdev_get_gpio_in(uart_orgate, 0),
1825000, serial_hd(0), DEVICE_NATIVE_ENDIAN);
- serial_mm_init(address_space_mem, MP_UART2_BASE, 2, pic[MP_UART2_IRQ],
+ serial_mm_init(address_space_mem, MP_UART2_BASE, 2,
+ qdev_get_gpio_in(uart_orgate, 1),
1825000, serial_hd(1), DEVICE_NATIVE_ENDIAN);
/* Register flash */
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
index c9f60e82516..7d022eeefdb 100644
--- a/hw/arm/Kconfig
+++ b/hw/arm/Kconfig
@@ -93,6 +93,7 @@ config MUSCA
config MUSICPAL
bool
+ select OR_IRQ
select BITBANG_I2C
select MARVELL_88W8618
select PTIMER
--
2.20.1
- [PULL 02/16] ssi: Fix bad printf format specifiers, (continued)
- [PULL 02/16] ssi: Fix bad printf format specifiers, Peter Maydell, 2020/11/10
- [PULL 05/16] target/arm: add space before the open parenthesis '(', Peter Maydell, 2020/11/10
- [PULL 06/16] docs: add some notes on the sbsa-ref machine, Peter Maydell, 2020/11/10
- [PULL 07/16] hw/arm/virt: Remove dependency on Cortex-A15 MPCore peripherals, Peter Maydell, 2020/11/10
- [PULL 08/16] target/arm: Fix neon VTBL/VTBX for len > 1, Peter Maydell, 2020/11/10
- [PULL 10/16] hw/misc/stm32f2xx_syscfg: Remove extraneous IRQ, Peter Maydell, 2020/11/10
- [PULL 11/16] hw/arm/nseries: Remove invalid/unnecessary n8x0_uart_setup(), Peter Maydell, 2020/11/10
- [PULL 09/16] hw/arm/armsse: Correct expansion MPC interrupt lines, Peter Maydell, 2020/11/10
- [PULL 14/16] hw/arm/nseries: Check return value from load_image_targphys(), Peter Maydell, 2020/11/10
- [PULL 13/16] hw/arm/musicpal: Only use qdev_get_gpio_in() when necessary, Peter Maydell, 2020/11/10
- [PULL 12/16] hw/arm/musicpal: Don't connect two qemu_irqs directly to the same input,
Peter Maydell <=
- [PULL 15/16] tests/qtest/npcm7xx_rng-test: count runs properly, Peter Maydell, 2020/11/10
- [PULL 16/16] target/arm/translate-neon.c: Handle VTBL UNDEF case before VFP access check, Peter Maydell, 2020/11/10
- Re: [PULL 00/16] target-arm queue, Peter Maydell, 2020/11/10