From: Kuan-Jui Chiu <kchiu@axiado.com>
Cc: Kuan-Jui Chiu <kchiu@axiado.com>,
mark.caveayland@nutanix.com, philmd@oss.qualcomm.com,
163wangjack@gmail.com, peter.maydell@linaro.org,
qemu-devel@nongnu.org, qemu-arm@nongnu.org
Subject: [PATCH v8 02/13] hw/char/cadence_uart: Add BXRS register definition
Date: Wed, 18 Nov 2026 23:13:42 -0800 [thread overview]
Message-ID: <20261119071355.3520249-3-kchiu@axiado.com> (raw)
In-Reply-To: <20261119071355.3520249-1-kchiu@axiado.com>
The RXBS (RX FIFO Byte Status) register at 0x48 is only exposed to
the guest when the brk_support property is set, so the accessible size
should be CADENCE_UART_R_MAX_BRK in that case and CADENCE_UART_R_MAX
otherwise.
Signed-off-by: Kuan-Jui Chiu <kchiu@axiado.com>
---
hw/char/cadence_uart.c | 15 ++++++++++++---
include/hw/char/cadence_uart.h | 4 +++-
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c
index 8e23a378c4..8746a96619 100644
--- a/hw/char/cadence_uart.c
+++ b/hw/char/cadence_uart.c
@@ -120,6 +120,13 @@
#define R_PMIN (0x3C/4)
#define R_PWID (0x40/4)
#define R_TTRIG (0x44/4)
+#define R_RXBS (0x48/4)
+
+/* Number of registers reachable by the guest, depending on brk_support */
+static inline unsigned int uart_r_max(const CadenceUARTState *s)
+{
+ return s->brk_support ? CADENCE_UART_R_MAX_BRK : CADENCE_UART_R_MAX;
+}
static void uart_update_status(CadenceUARTState *s)
@@ -424,7 +431,7 @@ static MemTxResult uart_write(void *opaque, hwaddr offset,
DB_PRINT(" offset:%x data:%08x\n", (unsigned)offset, (unsigned)value);
offset >>= 2;
- if (offset >= CADENCE_UART_R_MAX) {
+ if (offset >= uart_r_max(s)) {
return MEMTX_DECODE_ERROR;
}
switch (offset) {
@@ -492,7 +499,7 @@ static MemTxResult uart_read(void *opaque, hwaddr offset,
}
offset >>= 2;
- if (offset >= CADENCE_UART_R_MAX) {
+ if (offset >= uart_r_max(s)) {
return MEMTX_DECODE_ERROR;
}
if (offset == R_TX_RX) {
@@ -523,6 +530,7 @@ static void cadence_uart_reset_init(Object *obj, ResetType type)
s->r[R_BRGR] = 0x0000028B;
s->r[R_BDIV] = 0x0000000F;
s->r[R_TTRIG] = 0x00000020;
+ s->r[R_RXBS] = 0;
}
static void cadence_uart_reset_hold(Object *obj, ResetType type)
@@ -603,7 +611,7 @@ static const VMStateDescription vmstate_cadence_uart = {
.pre_load = cadence_uart_pre_load,
.post_load = cadence_uart_post_load,
.fields = (const VMStateField[]) {
- VMSTATE_UINT32_ARRAY(r, CadenceUARTState, CADENCE_UART_R_MAX),
+ VMSTATE_UINT32_ARRAY(r, CadenceUARTState, CADENCE_UART_R_MAX_BRK),
VMSTATE_UINT8_ARRAY(rx_fifo, CadenceUARTState,
CADENCE_UART_RX_FIFO_SIZE),
VMSTATE_UINT8_ARRAY(tx_fifo, CadenceUARTState,
@@ -619,6 +627,7 @@ static const VMStateDescription vmstate_cadence_uart = {
static const Property cadence_uart_properties[] = {
DEFINE_PROP_CHR("chardev", CadenceUARTState, chr),
+ DEFINE_PROP_BOOL("brk-support", CadenceUARTState, brk_support, false),
};
static void cadence_uart_class_init(ObjectClass *klass, const void *data)
diff --git a/include/hw/char/cadence_uart.h b/include/hw/char/cadence_uart.h
index 751a751248..1d5fc7f328 100644
--- a/include/hw/char/cadence_uart.h
+++ b/include/hw/char/cadence_uart.h
@@ -30,6 +30,7 @@
#define CADENCE_UART_TX_FIFO_SIZE 16
#define CADENCE_UART_R_MAX (0x48/4)
+#define CADENCE_UART_R_MAX_BRK (0x4C/4)
#define TYPE_CADENCE_UART "cadence_uart"
OBJECT_DECLARE_SIMPLE_TYPE(CadenceUARTState, CADENCE_UART)
@@ -40,7 +41,7 @@ struct CadenceUARTState {
/*< public >*/
MemoryRegion iomem;
- uint32_t r[CADENCE_UART_R_MAX];
+ uint32_t r[CADENCE_UART_R_MAX_BRK];
uint8_t rx_fifo[CADENCE_UART_RX_FIFO_SIZE];
uint8_t tx_fifo[CADENCE_UART_TX_FIFO_SIZE];
uint32_t rx_wpos;
@@ -51,6 +52,7 @@ struct CadenceUARTState {
qemu_irq irq;
QEMUTimer *fifo_trigger_handle;
Clock *refclk;
+ bool brk_support;
};
#endif
--
2.34.1
next prev parent reply other threads:[~2026-11-19 7:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 7:13 [PATCH v8 00/13] Add Axiado SoC AX3005 and EVB Kuan-Jui Chiu
2026-11-19 7:13 ` [PATCH v8 01/13] hw/char/cadence_uart: Reduce the size of MMIO to 0x80 Kuan-Jui Chiu
2026-11-19 7:13 ` Kuan-Jui Chiu [this message]
2026-11-19 7:13 ` [PATCH v8 03/13] hw/arm/ax3000-soc: Enable BXRS support of CADENCE UART Kuan-Jui Chiu
2026-11-19 7:13 ` [PATCH v8 04/13] hw/arm: Rename ax3000-boards as axiado-boards Kuan-Jui Chiu
2026-11-19 7:13 ` [PATCH v8 05/13] hw/arm/ax3000: Specify SoC name in header and variable Kuan-Jui Chiu
2026-11-19 7:13 ` [PATCH v8 06/13] hw/arm/ax3000-boards: Add memory guard Kuan-Jui Chiu
2026-11-19 7:13 ` [PATCH v8 07/13] hw/arm/ax3000-boards: Add modify_dtb for discontiguous memory Kuan-Jui Chiu
2026-11-19 7:13 ` [PATCH v8 08/13] hw/arm/ax3000-boards: Remove redundant pointer from struct Kuan-Jui Chiu
2026-11-19 7:13 ` [PATCH v8 09/13] hw/arm/ax3000-soc: Revise variables accodring to QEMU idioms Kuan-Jui Chiu
2026-11-19 7:13 ` [PATCH v8 10/13] hw/arm: Add Axiado SoC AX3005 Kuan-Jui Chiu
2026-11-19 7:13 ` [PATCH v8 11/13] hw/arm: Add Axiado Ax3005 EVB Kuan-Jui Chiu
2026-11-19 7:13 ` [PATCH v8 12/13] docs/system/arm: Document Axiado boards Kuan-Jui Chiu
2026-11-19 7:13 ` [PATCH v8 13/13] tests/functional/aarch64: Add functional test for Axiado EVKs Kuan-Jui Chiu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261119071355.3520249-3-kchiu@axiado.com \
--to=kchiu@axiado.com \
--cc=163wangjack@gmail.com \
--cc=mark.caveayland@nutanix.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@oss.qualcomm.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.