Gilles Grimaud <[email protected]> writes: > From: gilles grimaud <[email protected]> > > Replace the TBMAN and VREG/chip-reset placeholders with the RP2040 register > models from the development tree. Expose the ASIC platform indication, > documented reset values, write masks, regulator status, and APB atomic > aliases.\n\nAdd focused qtests for both blocks. > > Signed-off-by: gilles grimaud <[email protected]> > --- > hw/arm/Kconfig | 2 + > hw/arm/rp2040.c | 14 ++- > hw/misc/Kconfig | 6 ++ > hw/misc/meson.build | 2 + > hw/misc/rp2040_tbman.c | 92 +++++++++++++++++ > hw/misc/rp2040_vreg.c | 178 ++++++++++++++++++++++++++++++++ > include/hw/arm/rp2040.h | 4 + > include/hw/misc/rp2040_tbman.h | 25 +++++ > include/hw/misc/rp2040_vreg.h | 28 +++++ > tests/qtest/meson.build | 4 +- > tests/qtest/rp2040-tbman-test.c | 32 ++++++ > tests/qtest/rp2040-vreg-test.c | 79 ++++++++++++++ > 12 files changed, 463 insertions(+), 3 deletions(-) > create mode 100644 hw/misc/rp2040_tbman.c > create mode 100644 hw/misc/rp2040_vreg.c > create mode 100644 include/hw/misc/rp2040_tbman.h > create mode 100644 include/hw/misc/rp2040_vreg.h > create mode 100644 tests/qtest/rp2040-tbman-test.c > create mode 100644 tests/qtest/rp2040-vreg-test.c > <snip> > new file mode 100644 > index 0000000000..e8480fc258 > --- /dev/null > +++ b/hw/misc/rp2040_vreg.c > @@ -0,0 +1,178 @@ > +/* > + * RP2040 voltage regulator and chip reset emulation > + * > + * SPDX-License-Identifier: GPL-2.0-or-later > + */ > + > +#include "qemu/osdep.h" > +#include "hw/misc/rp2040_nyi.h" > +#include "hw/misc/rp2040_vreg.h" > +#include "migration/vmstate.h" > +#include "qemu/module.h" > + > +#define VREG_VREG 0x00 > +#define VREG_BOD 0x04 > +#define VREG_CHIP_RESET 0x08 > + > +#define VREG_ROK BIT(12) > +#define VREG_VSEL_MASK 0x000000f0 > +#define VREG_HIZ BIT(1) > +#define VREG_EN BIT(0) > +#define VREG_RW_MASK (VREG_VSEL_MASK | VREG_HIZ | VREG_EN) > +#define VREG_RESET 0x000000b1 > + > +#define BOD_VSEL_MASK 0x000000f0 > +#define BOD_EN BIT(0) > +#define BOD_RW_MASK (BOD_VSEL_MASK | BOD_EN) > +#define BOD_RESET 0x00000091 > + > +#define CHIP_RESET_RW_MASK 0x01000000 > + > +#define ATOMIC_ALIAS_MASK 0x3000 > +#define ATOMIC_XOR 0x1000 > +#define ATOMIC_SET 0x2000 > +#define ATOMIC_CLR 0x3000 > + <snip> > diff --git a/tests/qtest/rp2040-vreg-test.c b/tests/qtest/rp2040-vreg-test.c > new file mode 100644 > index 0000000000..b08bb16765 > --- /dev/null > +++ b/tests/qtest/rp2040-vreg-test.c > @@ -0,0 +1,79 @@ > +/* > + * QTest testcase for the RP2040 vreg_and_chip_reset block. > + * > + * SPDX-License-Identifier: GPL-2.0-or-later > + */ > + > +#include "qemu/osdep.h" > +#include "libqtest.h" > +#include "qemu/bitops.h" > + > +#define VREG_BASE 0x40064000 > +#define VREG_VREG 0x00 > +#define VREG_BOD 0x04 > +#define VREG_CHIP_RESET 0x08 > + > +#define VREG_ROK BIT(12) > +#define VREG_RESET 0x000000b1 > +#define BOD_RESET 0x00000091 > +#define CHIP_RESET_RESCUE BIT(24) > + > +#define ATOMIC_SET_ALIAS 0x2000 > +#define ATOMIC_CLR_ALIAS 0x3000
You don't need this duplication. qtest's can include QEMU headers. As an aside you might want to look at the hw/core/registerfields.h helpers which are good for defining registers and their fields and generate the helpers for you. -- Alex Bennée Virtualisation Tech Lead @ Linaro
