From: Jamin Lin via <qemu-devel@nongnu.org>
To: "Cédric Le Goater" <clg@kaod.org>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Steven Lee" <steven_lee@aspeedtech.com>,
"Troy Lee" <leetroy@gmail.com>,
"Andrew Jeffery" <andrew@codeconstruct.com.au>,
"Joel Stanley" <joel@jms.id.au>,
"open list:ASPEED BMCs" <qemu-arm@nongnu.org>,
"open list:All patches CC here" <qemu-devel@nongnu.org>
Cc: <jamin_lin@aspeedtech.com>, <troy_lee@aspeedtech.com>,
<yunlin.tang@aspeedtech.com>
Subject: [PATCH v1 1/3] hw/timer/aspeed: Support different memory region ops
Date: Mon, 16 Dec 2024 15:53:50 +0800 [thread overview]
Message-ID: <20241216075353.1308043-2-jamin_lin@aspeedtech.com> (raw)
In-Reply-To: <20241216075353.1308043-1-jamin_lin@aspeedtech.com>
It set "aspeed_timer_ops" struct which containing read and write callbacks
to be used when I/O is performed on the TIMER region.
Besides, in the previous design of ASPEED SOCs, the timer registers address
space are contiguous.
ex: TMC00-TMC0C are used for TIMER0.
ex: TMC10-TMC1C are used for TIMER1.
ex: TMC80-TMC8C are used for TIMER7.
The TMC30 is a control register and TMC34 is an interrupt status register for
TIMER0-TIMER7.
However, the register set have a significant change in AST2700. The TMC00-TMC3C
are used for TIMER0 and TMC40-TMC7C are used for TIMER1. In additional,
TMC20-TMC3C and TMC60-TMC7C are reserved registers for TIMER0 and TIMER1,
respectively.
Besides, each TIMER has their own control and interrupt status register.
In other words, users are able to set control and interrupt status for TIMER0
in one register. Both aspeed_timer_read and aspeed_timer_write callback
functions are not compatible AST2700.
Introduce a new "const MemoryRegionOps *" attribute in AspeedTIMERClass and use
it in aspeed_timer_realize function.
Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
---
hw/timer/aspeed_timer.c | 7 ++++++-
include/hw/timer/aspeed_timer.h | 1 +
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c
index 149f7cc5a6..970bf1d79d 100644
--- a/hw/timer/aspeed_timer.c
+++ b/hw/timer/aspeed_timer.c
@@ -606,6 +606,7 @@ static void aspeed_timer_realize(DeviceState *dev, Error **errp)
int i;
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
AspeedTimerCtrlState *s = ASPEED_TIMER(dev);
+ AspeedTimerClass *atc = ASPEED_TIMER_GET_CLASS(s);
assert(s->scu);
@@ -613,7 +614,7 @@ static void aspeed_timer_realize(DeviceState *dev, Error **errp)
aspeed_init_one_timer(s, i);
sysbus_init_irq(sbd, &s->timers[i].irq);
}
- memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_timer_ops, s,
+ memory_region_init_io(&s->iomem, OBJECT(s), atc->reg_ops, s,
TYPE_ASPEED_TIMER, 0x1000);
sysbus_init_mmio(sbd, &s->iomem);
}
@@ -708,6 +709,7 @@ static void aspeed_2400_timer_class_init(ObjectClass *klass, void *data)
dc->desc = "ASPEED 2400 Timer";
awc->read = aspeed_2400_timer_read;
awc->write = aspeed_2400_timer_write;
+ awc->reg_ops = &aspeed_timer_ops;
}
static const TypeInfo aspeed_2400_timer_info = {
@@ -724,6 +726,7 @@ static void aspeed_2500_timer_class_init(ObjectClass *klass, void *data)
dc->desc = "ASPEED 2500 Timer";
awc->read = aspeed_2500_timer_read;
awc->write = aspeed_2500_timer_write;
+ awc->reg_ops = &aspeed_timer_ops;
}
static const TypeInfo aspeed_2500_timer_info = {
@@ -740,6 +743,7 @@ static void aspeed_2600_timer_class_init(ObjectClass *klass, void *data)
dc->desc = "ASPEED 2600 Timer";
awc->read = aspeed_2600_timer_read;
awc->write = aspeed_2600_timer_write;
+ awc->reg_ops = &aspeed_timer_ops;
}
static const TypeInfo aspeed_2600_timer_info = {
@@ -756,6 +760,7 @@ static void aspeed_1030_timer_class_init(ObjectClass *klass, void *data)
dc->desc = "ASPEED 1030 Timer";
awc->read = aspeed_2600_timer_read;
awc->write = aspeed_2600_timer_write;
+ awc->reg_ops = &aspeed_timer_ops;
}
static const TypeInfo aspeed_1030_timer_info = {
diff --git a/include/hw/timer/aspeed_timer.h b/include/hw/timer/aspeed_timer.h
index 07dc6b6f2c..8d0b15f055 100644
--- a/include/hw/timer/aspeed_timer.h
+++ b/include/hw/timer/aspeed_timer.h
@@ -73,6 +73,7 @@ struct AspeedTimerClass {
uint64_t (*read)(AspeedTimerCtrlState *s, hwaddr offset);
void (*write)(AspeedTimerCtrlState *s, hwaddr offset, uint64_t value);
+ const MemoryRegionOps *reg_ops;
};
#endif /* ASPEED_TIMER_H */
--
2.25.1
next prev parent reply other threads:[~2024-12-16 7:54 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-16 7:53 [PATCH v1 0/3] Support timer for AST2700 Jamin Lin via
2024-12-16 7:53 ` Jamin Lin via
2024-12-16 7:53 ` Jamin Lin via [this message]
2024-12-24 9:04 ` [PATCH v1 1/3] hw/timer/aspeed: Support different memory region ops Philippe Mathieu-Daudé
2024-12-24 9:06 ` Jamin Lin
2025-01-09 1:58 ` Andrew Jeffery
2025-01-09 2:26 ` Jamin Lin
2025-01-09 7:01 ` Cédric Le Goater
2025-01-09 7:10 ` Jamin Lin
2024-12-16 7:53 ` [PATCH v1 2/3] hw/timer/aspeed: Add AST2700 Support Jamin Lin via
2024-12-16 7:53 ` Jamin Lin via
[not found] ` <e87208a6-bea4-48ec-a527-df02dac8f772@kaod.org>
2024-12-24 1:22 ` Jamin Lin
2024-12-16 7:53 ` [PATCH v1 3/3] aspeed/soc: Support Timer for AST2700 Jamin Lin via
2025-01-02 2:32 ` [PATCH v1 0/3] Support timer " Jamin Lin
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=20241216075353.1308043-2-jamin_lin@aspeedtech.com \
--to=qemu-devel@nongnu.org \
--cc=andrew@codeconstruct.com.au \
--cc=clg@kaod.org \
--cc=jamin_lin@aspeedtech.com \
--cc=joel@jms.id.au \
--cc=leetroy@gmail.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=steven_lee@aspeedtech.com \
--cc=troy_lee@aspeedtech.com \
--cc=yunlin.tang@aspeedtech.com \
/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.