* [PATCH v3 0/3] stm32f2xx_usart: implement TX interrupts
@ 2023-10-30 15:15 Hans-Erik Floryd
2023-10-30 15:15 ` [PATCH v3 1/3] hw/char/stm32f2xx_usart: Extract common IRQ update code to update_irq() Hans-Erik Floryd
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Hans-Erik Floryd @ 2023-10-30 15:15 UTC (permalink / raw)
To: alistair, peter.maydell, marcandre.lureau, pbonzini, qemu-arm,
qemu-devel, philmd
Cc: Hans-Erik Floryd
Generate interrupt if either of the TXE, TC or RXNE bits are active
and the corresponding interrupt enable bit is set.
v3:
- Drop patch "hw/char/stm32f2xx_usart: Update IRQ when SR is read" as
it is not required
Hans-Erik Floryd (3):
hw/char/stm32f2xx_usart: Extract common IRQ update code to
update_irq()
hw/char/stm32f2xx_usart: Update IRQ when DR is written
hw/char/stm32f2xx_usart: Add more definitions for CR1 register
hw/char/stm32f2xx_usart.c | 29 +++++++++++++++++------------
include/hw/char/stm32f2xx_usart.h | 10 ++++++----
2 files changed, 23 insertions(+), 16 deletions(-)
--
2.42.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3 1/3] hw/char/stm32f2xx_usart: Extract common IRQ update code to update_irq()
2023-10-30 15:15 [PATCH v3 0/3] stm32f2xx_usart: implement TX interrupts Hans-Erik Floryd
@ 2023-10-30 15:15 ` Hans-Erik Floryd
2023-10-30 15:15 ` [PATCH v3 2/3] hw/char/stm32f2xx_usart: Update IRQ when DR is written Hans-Erik Floryd
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Hans-Erik Floryd @ 2023-10-30 15:15 UTC (permalink / raw)
To: alistair, peter.maydell, marcandre.lureau, pbonzini, qemu-arm,
qemu-devel, philmd
Cc: Hans-Erik Floryd, Richard Henderson, Alistair Francis
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Hans-Erik Floryd <hans-erik.floryd@rt-labs.com>
---
hw/char/stm32f2xx_usart.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/hw/char/stm32f2xx_usart.c b/hw/char/stm32f2xx_usart.c
index fde67f4f03..519d3461a3 100644
--- a/hw/char/stm32f2xx_usart.c
+++ b/hw/char/stm32f2xx_usart.c
@@ -53,6 +53,17 @@ static int stm32f2xx_usart_can_receive(void *opaque)
return 0;
}
+static void stm32f2xx_update_irq(STM32F2XXUsartState *s)
+{
+ uint32_t mask = s->usart_sr & s->usart_cr1;
+
+ if (mask & (USART_SR_TXE | USART_SR_TC | USART_SR_RXNE)) {
+ qemu_set_irq(s->irq, 1);
+ } else {
+ qemu_set_irq(s->irq, 0);
+ }
+}
+
static void stm32f2xx_usart_receive(void *opaque, const uint8_t *buf, int size)
{
STM32F2XXUsartState *s = opaque;
@@ -66,9 +77,7 @@ static void stm32f2xx_usart_receive(void *opaque, const uint8_t *buf, int size)
s->usart_dr = *buf;
s->usart_sr |= USART_SR_RXNE;
- if (s->usart_cr1 & USART_CR1_RXNEIE) {
- qemu_set_irq(s->irq, 1);
- }
+ stm32f2xx_update_irq(s);
DB_PRINT("Receiving: %c\n", s->usart_dr);
}
@@ -85,7 +94,7 @@ static void stm32f2xx_usart_reset(DeviceState *dev)
s->usart_cr3 = 0x00000000;
s->usart_gtpr = 0x00000000;
- qemu_set_irq(s->irq, 0);
+ stm32f2xx_update_irq(s);
}
static uint64_t stm32f2xx_usart_read(void *opaque, hwaddr addr,
@@ -106,7 +115,7 @@ static uint64_t stm32f2xx_usart_read(void *opaque, hwaddr addr,
retvalue = s->usart_dr & 0x3FF;
s->usart_sr &= ~USART_SR_RXNE;
qemu_chr_fe_accept_input(&s->chr);
- qemu_set_irq(s->irq, 0);
+ stm32f2xx_update_irq(s);
return retvalue;
case USART_BRR:
return s->usart_brr;
@@ -145,9 +154,7 @@ static void stm32f2xx_usart_write(void *opaque, hwaddr addr,
} else {
s->usart_sr &= value;
}
- if (!(s->usart_sr & USART_SR_RXNE)) {
- qemu_set_irq(s->irq, 0);
- }
+ stm32f2xx_update_irq(s);
return;
case USART_DR:
if (value < 0xF000) {
@@ -168,10 +175,7 @@ static void stm32f2xx_usart_write(void *opaque, hwaddr addr,
return;
case USART_CR1:
s->usart_cr1 = value;
- if (s->usart_cr1 & USART_CR1_RXNEIE &&
- s->usart_sr & USART_SR_RXNE) {
- qemu_set_irq(s->irq, 1);
- }
+ stm32f2xx_update_irq(s);
return;
case USART_CR2:
s->usart_cr2 = value;
--
2.42.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 2/3] hw/char/stm32f2xx_usart: Update IRQ when DR is written
2023-10-30 15:15 [PATCH v3 0/3] stm32f2xx_usart: implement TX interrupts Hans-Erik Floryd
2023-10-30 15:15 ` [PATCH v3 1/3] hw/char/stm32f2xx_usart: Extract common IRQ update code to update_irq() Hans-Erik Floryd
@ 2023-10-30 15:15 ` Hans-Erik Floryd
2023-10-30 15:15 ` [PATCH v3 3/3] hw/char/stm32f2xx_usart: Add more definitions for CR1 register Hans-Erik Floryd
2023-11-02 11:18 ` [PATCH v3 0/3] stm32f2xx_usart: implement TX interrupts Peter Maydell
3 siblings, 0 replies; 5+ messages in thread
From: Hans-Erik Floryd @ 2023-10-30 15:15 UTC (permalink / raw)
To: alistair, peter.maydell, marcandre.lureau, pbonzini, qemu-arm,
qemu-devel, philmd
Cc: Hans-Erik Floryd, Richard Henderson, Alistair Francis
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Hans-Erik Floryd <hans-erik.floryd@rt-labs.com>
---
hw/char/stm32f2xx_usart.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/char/stm32f2xx_usart.c b/hw/char/stm32f2xx_usart.c
index 519d3461a3..8753afeb2b 100644
--- a/hw/char/stm32f2xx_usart.c
+++ b/hw/char/stm32f2xx_usart.c
@@ -168,6 +168,7 @@ static void stm32f2xx_usart_write(void *opaque, hwaddr addr,
clear TC by writing 0 to the SR register, so set it again
on each write. */
s->usart_sr |= USART_SR_TC;
+ stm32f2xx_update_irq(s);
}
return;
case USART_BRR:
--
2.42.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 3/3] hw/char/stm32f2xx_usart: Add more definitions for CR1 register
2023-10-30 15:15 [PATCH v3 0/3] stm32f2xx_usart: implement TX interrupts Hans-Erik Floryd
2023-10-30 15:15 ` [PATCH v3 1/3] hw/char/stm32f2xx_usart: Extract common IRQ update code to update_irq() Hans-Erik Floryd
2023-10-30 15:15 ` [PATCH v3 2/3] hw/char/stm32f2xx_usart: Update IRQ when DR is written Hans-Erik Floryd
@ 2023-10-30 15:15 ` Hans-Erik Floryd
2023-11-02 11:18 ` [PATCH v3 0/3] stm32f2xx_usart: implement TX interrupts Peter Maydell
3 siblings, 0 replies; 5+ messages in thread
From: Hans-Erik Floryd @ 2023-10-30 15:15 UTC (permalink / raw)
To: alistair, peter.maydell, marcandre.lureau, pbonzini, qemu-arm,
qemu-devel, philmd
Cc: Hans-Erik Floryd, Richard Henderson, Alistair Francis
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Hans-Erik Floryd <hans-erik.floryd@rt-labs.com>
---
include/hw/char/stm32f2xx_usart.h | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/include/hw/char/stm32f2xx_usart.h b/include/hw/char/stm32f2xx_usart.h
index 65bcc85470..fdfa7424a7 100644
--- a/include/hw/char/stm32f2xx_usart.h
+++ b/include/hw/char/stm32f2xx_usart.h
@@ -48,10 +48,12 @@
#define USART_SR_TC (1 << 6)
#define USART_SR_RXNE (1 << 5)
-#define USART_CR1_UE (1 << 13)
-#define USART_CR1_RXNEIE (1 << 5)
-#define USART_CR1_TE (1 << 3)
-#define USART_CR1_RE (1 << 2)
+#define USART_CR1_UE (1 << 13)
+#define USART_CR1_TXEIE (1 << 7)
+#define USART_CR1_TCEIE (1 << 6)
+#define USART_CR1_RXNEIE (1 << 5)
+#define USART_CR1_TE (1 << 3)
+#define USART_CR1_RE (1 << 2)
#define TYPE_STM32F2XX_USART "stm32f2xx-usart"
OBJECT_DECLARE_SIMPLE_TYPE(STM32F2XXUsartState, STM32F2XX_USART)
--
2.42.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3 0/3] stm32f2xx_usart: implement TX interrupts
2023-10-30 15:15 [PATCH v3 0/3] stm32f2xx_usart: implement TX interrupts Hans-Erik Floryd
` (2 preceding siblings ...)
2023-10-30 15:15 ` [PATCH v3 3/3] hw/char/stm32f2xx_usart: Add more definitions for CR1 register Hans-Erik Floryd
@ 2023-11-02 11:18 ` Peter Maydell
3 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2023-11-02 11:18 UTC (permalink / raw)
To: Hans-Erik Floryd
Cc: alistair, marcandre.lureau, pbonzini, qemu-arm, qemu-devel,
philmd
On Mon, 30 Oct 2023 at 15:15, Hans-Erik Floryd
<hans-erik.floryd@rt-labs.com> wrote:
>
> Generate interrupt if either of the TXE, TC or RXNE bits are active
> and the corresponding interrupt enable bit is set.
>
> v3:
> - Drop patch "hw/char/stm32f2xx_usart: Update IRQ when SR is read" as
> it is not required
Applied to target-arm.next. Thanks for this contribution!
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-11-02 11:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-30 15:15 [PATCH v3 0/3] stm32f2xx_usart: implement TX interrupts Hans-Erik Floryd
2023-10-30 15:15 ` [PATCH v3 1/3] hw/char/stm32f2xx_usart: Extract common IRQ update code to update_irq() Hans-Erik Floryd
2023-10-30 15:15 ` [PATCH v3 2/3] hw/char/stm32f2xx_usart: Update IRQ when DR is written Hans-Erik Floryd
2023-10-30 15:15 ` [PATCH v3 3/3] hw/char/stm32f2xx_usart: Add more definitions for CR1 register Hans-Erik Floryd
2023-11-02 11:18 ` [PATCH v3 0/3] stm32f2xx_usart: implement TX interrupts Peter Maydell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).