All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] [ARM] Fix sp804 dual-timer
@ 2011-09-29  2:34 Peter Chubb
  2011-09-29  9:58 ` Peter Maydell
  0 siblings, 1 reply; 45+ messages in thread
From: Peter Chubb @ 2011-09-29  2:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Paul Brook, philipo, davidm


This patch was written by David Mirabito.

Properly implement the dual-timer read/write for the sp804 dual timer module.
Based on ARM specs at
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0271d/index.html

Signed-off-by: Peter Chubb <peter.chubb@nicta.com.au>
Signed-off-by: David Mirabito <davidm@ok-labs.com>
Signed-off-by: Hans Jang <hsjang@ok-labs.com>
---
 hw/arm_timer.c |   52 +++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/hw/arm_timer.c b/hw/arm_timer.c
index 09a4b24..35f4bb5 100644
--- a/hw/arm_timer.c
+++ b/hw/arm_timer.c
@@ -196,12 +196,49 @@ static uint64_t sp804_read(void *opaque, target_phys_addr_t offset,
 {
     sp804_state *s = (sp804_state *)opaque;
 
-    /* ??? Don't know the PrimeCell ID for this device.  */
     if (offset < 0x20) {
         return arm_timer_read(s->timer[0], offset);
-    } else {
+    } 
+    if (offset < 0x40) {
         return arm_timer_read(s->timer[1], offset - 0x20);
     }
+
+    /* Is it one of the test or id registers */
+    switch(offset){
+    /* Integration Test control registers, which we won't support */
+    case 0xf00: /* TimerITCR */
+    case 0xf04: /* TimerITOP (strictly write only but..) */
+        return 0;
+
+    /* Timer Peripheral ID Registers, one byte per word:
+     * [11:0]  - Part number    = 0x804
+     * [19:12] - Designer Id    = 0x41   ('A')
+     * [23:20] - Revision       = 1
+     * [31:24] - Configurations = 0
+     */
+    case 0xfe0: /* TimerPeriphID0 */
+        return 0x04;
+    case 0xfe4: /* TimerPeriphID1 */
+        return 0x18;
+    case 0xfe8: /* TimerPeriphID2 */
+        return 0x14;
+    case 0xfec: /* TimerPeriphID3 */
+        return 0x00;
+
+    /* PrimeCell ID Registers = 0xB105F00D */
+    case 0xff0: /* TimerPCellID0 */
+        return 0x0d;
+    case 0xff4: /* TimerPCellID1 */
+        return 0xf0;
+    case 0xff8: /* TimerPCellID2 */
+        return 0x05;
+    case 0xffc: /* TimerPCellID3 */
+        return 0xb1;
+    }
+    cpu_abort (cpu_single_env, "sp804_read: Bad offset %x\n",
+               (int)offset);
+
+    return 0;
 }
 
 static void sp804_write(void *opaque, target_phys_addr_t offset,
@@ -211,8 +248,12 @@ static void sp804_write(void *opaque, target_phys_addr_t offset,
 
     if (offset < 0x20) {
         arm_timer_write(s->timer[0], offset, value);
-    } else {
+    } else if (offset < 0x40) {
         arm_timer_write(s->timer[1], offset - 0x20, value);
+    } else {
+        /* Technically we could be writing to the Test Registers, but not likely */
+        cpu_abort (cpu_single_env, "sp804_write: Bad offset %x\n",
+                   (int)offset);
     }
 }
 
@@ -269,8 +310,9 @@ static uint64_t icp_pit_read(void *opaque, target_phys_addr_t offset,
 
     /* ??? Don't know the PrimeCell ID for this device.  */
     n = offset >> 8;
+
     if (n > 3) {
-        hw_error("sp804_read: Bad timer %d\n", n);
+        hw_error("icp_pit_read: Bad timer %d\n", n);
     }
 
     return arm_timer_read(s->timer[n], offset & 0xff);
@@ -284,7 +326,7 @@ static void icp_pit_write(void *opaque, target_phys_addr_t offset,
 
     n = offset >> 8;
     if (n > 3) {
-        hw_error("sp804_write: Bad timer %d\n", n);
+        hw_error("icp_pit_write: Bad timer %d\n", n);
     }
 
     arm_timer_write(s->timer[n], offset & 0xff, value);
-- 
1.7.6.3


--
Dr Peter Chubb  http://www.gelato.unsw.edu.au  peterc AT gelato.unsw.edu.au
http://www.ertos.nicta.com.au           ERTOS within National ICT Australia

^ permalink raw reply related	[flat|nested] 45+ messages in thread

end of thread, other threads:[~2011-12-05 19:53 UTC | newest]

Thread overview: 45+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-29  2:34 [Qemu-devel] [PATCH] [ARM] Fix sp804 dual-timer Peter Chubb
2011-09-29  9:58 ` Peter Maydell
2011-09-30  0:20   ` Peter Chubb
2011-09-30  9:04     ` Peter Maydell
2011-09-30  9:23       ` Peter Chubb
2011-09-30 10:07         ` Peter Maydell
     [not found]   ` <w4y5x6g8gk.wl%peter@chubb.wattle.id.au>
     [not found]     ` <CAFEAcA8-iByH0xgjkMUo3hvkrLc8NV-Lq4GbHU-d7UoF8GSX-Q@mail.gmail.com>
2011-11-21 21:58       ` [Qemu-devel] [PATCH] imx.31 and KZM board support Peter Chubb
2011-11-21 22:45         ` Andreas Färber
2011-11-21 23:04           ` Peter Chubb
2011-11-21 23:10             ` Peter Maydell
2011-11-21 23:41         ` Peter Maydell
2011-11-21 23:54           ` Peter Chubb
2011-11-22  0:12             ` Peter Maydell
2011-11-22  0:27               ` Peter Chubb
2011-11-22  0:32                 ` Peter Maydell
2011-11-22  4:31           ` [Qemu-devel] [PATCH V2 0/4] " Peter Chubb
2011-11-22  4:32             ` [Qemu-devel] [PATCH V2 1/4] imx.31 and KZM board support: UART support Peter Chubb
2011-11-24 18:53               ` Peter Maydell
2011-11-24 22:18                 ` Peter Chubb
2011-11-22  4:33             ` [Qemu-devel] [PATCH V2 2/4] imx.31 and KZM board support: Timer support Peter Chubb
2011-11-24 17:01               ` Peter Maydell
2011-11-24 19:06               ` Peter Maydell
2011-11-22  4:34             ` [Qemu-devel] [PATCH V2 3/4] imx.31 and KZM board support: interrupt controller Peter Chubb
2011-11-24 19:37               ` Peter Maydell
2011-11-22  4:34             ` [Qemu-devel] [PATCH V2 4/4] imx.31 and KZM board support: Makefile and board Peter Chubb
2011-11-24 19:41               ` Peter Maydell
2011-11-24 20:19                 ` Andreas Färber
2011-11-24 21:31                   ` Peter Maydell
2011-11-24 21:46                     ` Andreas Färber
2011-11-24 21:52                       ` Peter Maydell
2011-11-23  0:51             ` [Qemu-devel] [PATCH V2 0/4] imx.31 and KZM board support Peter Chubb
2011-11-24 19:07               ` Andreas Färber
2011-11-26  5:21                 ` Peter Chubb
2011-11-26 19:35                   ` Peter Maydell
2011-11-22 11:06         ` [Qemu-devel] [PATCH] " Juan Quintela
2011-11-22 11:14           ` Peter Maydell
2011-11-23 14:24             ` Juan Quintela
2011-11-23  0:48           ` Peter Chubb
2011-11-21 22:05   ` [Qemu-devel] [PATCH] [ARM] Fix sp804 dual-timer Peter Chubb
2011-11-21 23:01     ` Andreas Färber
2011-11-22  0:20       ` [Qemu-devel] [PATCH] [ARM] fix function names in error messages in arm_timer.c Peter Chubb
2011-11-22  3:20       ` [Qemu-devel] [PATCH] [ARM] Fix hw_error messages from arm_timer.c Peter Chubb
2011-12-05 19:53         ` andrzej zaborowski
2011-11-22  3:25       ` [Qemu-devel] [PATCH] [ARM] Fix sp804 dual-timer Peter Chubb
2011-11-24 17:46         ` Peter Maydell

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.