From: "Cédric Le Goater" <clg@kaod.org>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Andrew Jeffery" <andrew@aj.id.au>,
"Cédric Le Goater" <clg@kaod.org>,
qemu-arm@nongnu.org, qemu-devel@nongnu.org,
"Joel Stanley" <joel@jms.id.au>
Subject: [Qemu-devel] [RFC PATCH 03/15] aspeed/timer: Add support for control register 3
Date: Wed, 4 Sep 2019 22:46:47 +0200 [thread overview]
Message-ID: <20190904204659.13878-4-clg@kaod.org> (raw)
In-Reply-To: <20190904204659.13878-1-clg@kaod.org>
The AST2500 timer has a third control register that is used to
implement a set-to-clear feature for the main control register.
This models the behaviour expected by the AST2500 while maintaining
the same behaviour for the AST2400.
Based on previous work from Joel Stanley.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
include/hw/timer/aspeed_timer.h | 1 +
hw/timer/aspeed_timer.c | 19 +++++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/include/hw/timer/aspeed_timer.h b/include/hw/timer/aspeed_timer.h
index a791fee276f4..1e0288ebc49f 100644
--- a/include/hw/timer/aspeed_timer.h
+++ b/include/hw/timer/aspeed_timer.h
@@ -58,6 +58,7 @@ typedef struct AspeedTimerCtrlState {
uint32_t ctrl;
uint32_t ctrl2;
+ uint32_t ctrl3;
AspeedTimer timers[ASPEED_TIMER_NR_TIMERS];
AspeedSCUState *scu;
diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c
index c78bc1bd2d25..d70e78a0293e 100644
--- a/hw/timer/aspeed_timer.c
+++ b/hw/timer/aspeed_timer.c
@@ -498,6 +498,8 @@ static uint64_t aspeed_2500_timer_read(AspeedTimerCtrlState *s, hwaddr offset)
switch (offset) {
case 0x38:
+ value = s->ctrl3 & BIT(0);
+ break;
case 0x3C:
default:
qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n",
@@ -511,9 +513,24 @@ static uint64_t aspeed_2500_timer_read(AspeedTimerCtrlState *s, hwaddr offset)
static void aspeed_2500_timer_write(AspeedTimerCtrlState *s, hwaddr offset,
uint64_t value)
{
+ const uint32_t tv = (uint32_t)(value & 0xFFFFFFFF);
+ uint8_t command;
+
switch (offset) {
case 0x38:
+ command = (value >> 1) & 0xFF;
+ if (command == 0xAE) {
+ s->ctrl3 = 0x1;
+ } else if (command == 0xEA) {
+ s->ctrl3 = 0x0;
+ }
+ break;
case 0x3C:
+ if (s->ctrl3 & BIT(0)) {
+ aspeed_timer_set_ctrl(s, s->ctrl & ~tv);
+ }
+ break;
+
default:
qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n",
__func__, offset);
@@ -574,6 +591,7 @@ static void aspeed_timer_reset(DeviceState *dev)
}
s->ctrl = 0;
s->ctrl2 = 0;
+ s->ctrl3 = 0;
}
static const VMStateDescription vmstate_aspeed_timer = {
@@ -597,6 +615,7 @@ static const VMStateDescription vmstate_aspeed_timer_state = {
.fields = (VMStateField[]) {
VMSTATE_UINT32(ctrl, AspeedTimerCtrlState),
VMSTATE_UINT32(ctrl2, AspeedTimerCtrlState),
+ VMSTATE_UINT32(ctrl3, AspeedTimerCtrlState),
VMSTATE_STRUCT_ARRAY(timers, AspeedTimerCtrlState,
ASPEED_TIMER_NR_TIMERS, 1, vmstate_aspeed_timer,
AspeedTimer),
--
2.21.0
next prev parent reply other threads:[~2019-09-04 21:29 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-04 20:46 [Qemu-devel] [RFC PATCH 00/15] aspeed: Add support for the AST2600 SoC Cédric Le Goater
2019-09-04 20:46 ` [Qemu-devel] [RFC PATCH 01/15] hw: aspeed_scu: Add AST2600 support Cédric Le Goater
2019-09-04 20:46 ` [Qemu-devel] [RFC PATCH 02/15] aspeed/timer: Introduce an object class per SoC Cédric Le Goater
2019-09-04 20:46 ` Cédric Le Goater [this message]
2019-09-04 20:46 ` [Qemu-devel] [RFC PATCH 04/15] aspeed/timer: Add support for AST2600 Cédric Le Goater
2019-09-04 20:46 ` [Qemu-devel] [RFC PATCH 05/15] aspeed/timer: Add support for IRQ status register on the AST2600 Cédric Le Goater
2019-09-04 20:46 ` [Qemu-devel] [RFC PATCH 06/15] aspeed/sdmc: Introduce an object class per SoC Cédric Le Goater
2019-09-04 20:46 ` [Qemu-devel] [RFC PATCH 07/15] aspeed/sdmc: Add AST2600 support Cédric Le Goater
2019-09-04 20:46 ` [Qemu-devel] [RFC PATCH 08/15] watchdog/aspeed: Introduce an object class per SoC Cédric Le Goater
2019-09-04 20:46 ` [Qemu-devel] [RFC PATCH 09/15] hw: wdt_aspeed: Add AST2600 support Cédric Le Goater
2019-09-04 20:46 ` [Qemu-devel] [RFC PATCH 10/15] aspeed/smc: Add support for the AST2600 SoC Cédric Le Goater
2019-09-04 20:46 ` [Qemu-devel] [RFC PATCH 11/15] hw/gpio: Add in AST2600 specific implementation Cédric Le Goater
2019-09-04 20:46 ` [Qemu-devel] [RFC PATCH 12/15] aspeed: add support for the AST2600 eval board Cédric Le Goater
2019-09-04 20:46 ` [Qemu-devel] [RFC PATCH 13/15] aspeed: Parameterise number of MACs Cédric Le Goater
2019-09-04 20:46 ` [Qemu-devel] [RFC PATCH 14/15] aspeed: add support for the Aspeed MII controller of the AST2600 Cédric Le Goater
2019-09-04 20:46 ` [Qemu-devel] [RFC PATCH 15/15] aspeed/soc: Add ASPEED Video stub Cédric Le Goater
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=20190904204659.13878-4-clg@kaod.org \
--to=clg@kaod.org \
--cc=andrew@aj.id.au \
--cc=joel@jms.id.au \
--cc=peter.maydell@linaro.org \
--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 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).