[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 06/21] i.MX: Allow GPT timer to rollover.
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PULL 06/21] i.MX: Allow GPT timer to rollover. |
Date: |
Wed, 16 Mar 2016 17:18:20 +0000 |
From: Jean-Christophe Dubois <address@hidden>
GPT timer need to rollover when it reaches 0xffffffff.
It also need to reset to 0 when in "restart mode" and crossing the
compare 1 register.
Reviewed-by: Peter Maydell <address@hidden>
Signed-off-by: Jean-Christophe Dubois <address@hidden>
Message-id: address@hidden
Signed-off-by: Peter Maydell <address@hidden>
---
hw/timer/imx_gpt.c | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/hw/timer/imx_gpt.c b/hw/timer/imx_gpt.c
index 5cdc3b3..916577b 100644
--- a/hw/timer/imx_gpt.c
+++ b/hw/timer/imx_gpt.c
@@ -134,7 +134,7 @@ static inline uint32_t imx_gpt_find_limit(uint32_t count,
uint32_t reg,
static void imx_gpt_compute_next_timeout(IMXGPTState *s, bool event)
{
uint32_t timeout = GPT_TIMER_MAX;
- uint32_t count = 0;
+ uint32_t count;
long long limit;
if (!(s->cr & GPT_CR_EN)) {
@@ -142,20 +142,23 @@ static void imx_gpt_compute_next_timeout(IMXGPTState *s,
bool event)
return;
}
- if (event) {
- /* This is a timer event */
+ /* update the count */
+ count = imx_gpt_update_count(s);
- if ((s->cr & GPT_CR_FRR) && (s->next_timeout != GPT_TIMER_MAX)) {
- /*
- * if we are in free running mode and we have not reached
- * the GPT_TIMER_MAX limit, then update the count
+ if (event) {
+ /*
+ * This is an event (the ptimer reached 0 and stopped), and the
+ * timer counter is now equal to s->next_timeout.
+ */
+ if (!(s->cr & GPT_CR_FRR) && (count == s->ocr1)) {
+ /* We are in restart mode and we crossed the compare channel 1
+ * value. We need to reset the counter to 0.
*/
- count = imx_gpt_update_count(s);
+ count = s->cnt = s->next_timeout = 0;
+ } else if (count == GPT_TIMER_MAX) {
+ /* We reached GPT_TIMER_MAX so we need to rollover */
+ count = s->cnt = s->next_timeout = 0;
}
- } else {
- /* not a timer event, then just update the count */
-
- count = imx_gpt_update_count(s);
}
/* now, find the next timeout related to count */
--
1.9.1
- [Qemu-devel] [PULL 07/21] i.MX: Rename CCM NOCLK to CLK_NONE for naming consistency., (continued)
- [Qemu-devel] [PULL 07/21] i.MX: Rename CCM NOCLK to CLK_NONE for naming consistency., Peter Maydell, 2016/03/16
- [Qemu-devel] [PULL 05/21] arm: virt: Move machine class init code to the abstract machine type, Peter Maydell, 2016/03/16
- [Qemu-devel] [PULL 08/21] i.MX: Remove CCM useless clock computation handling., Peter Maydell, 2016/03/16
- [Qemu-devel] [PULL 11/21] i.MX: Add missing descriptions in devices., Peter Maydell, 2016/03/16
- [Qemu-devel] [PULL 21/21] sd: Fix "info qtree" on boards with SD cards, Peter Maydell, 2016/03/16
- [Qemu-devel] [PULL 17/21] bcm2835_aux: add emulation of BCM2835 AUX (aka UART1) block, Peter Maydell, 2016/03/16
- [Qemu-devel] [PULL 19/21] bcm2835_property: implement framebuffer control/configuration properties, Peter Maydell, 2016/03/16
- [Qemu-devel] [PULL 02/21] target-arm: Implement MRS (banked) and MSR (banked) instructions, Peter Maydell, 2016/03/16
- [Qemu-devel] [PULL 12/21] hw/timer: Add ASPEED timer device model, Peter Maydell, 2016/03/16
- [Qemu-devel] [PULL 04/21] arm: virt: Add an abstract ARM virt machine type, Peter Maydell, 2016/03/16
- [Qemu-devel] [PULL 06/21] i.MX: Allow GPT timer to rollover.,
Peter Maydell <=
- [Qemu-devel] [PULL 01/21] loader: Fix incorrect parameter name in load_image_mr() macro, Peter Maydell, 2016/03/16
- [Qemu-devel] [PULL 20/21] bcm2835_dma: add emulation of Raspberry Pi DMA controller, Peter Maydell, 2016/03/16
- [Qemu-devel] [PULL 10/21] i.MX: Add i.MX6 CCM and ANALOG device., Peter Maydell, 2016/03/16
- [Qemu-devel] [PULL 13/21] hw/intc: Add (new) ASPEED VIC device model, Peter Maydell, 2016/03/16
- [Qemu-devel] [PULL 18/21] bcm2835_fb: add framebuffer device for Raspberry Pi, Peter Maydell, 2016/03/16
- Re: [Qemu-devel] [PULL 00/21] target-arm queue, Peter Maydell, 2016/03/16
- Re: [Qemu-devel] [PULL 00/21] target-arm queue, Peter Maydell, 2016/03/16