Skip to contentSkip to conversation

add a simple 24mhz clock for the versatile

PATCH In review Jason Wessel 4 participants 5 messages Mar 30, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add a simple 24mhz clock for the versatile

This patch implements a simple 24mhz clock for the versatile board such that functions in the linux kernel can make use of these stamps. An example user of this is the printk time stamps when using the "time" parameter on the kernel boot line.

Signed-off-by [email protected]

Cheers,
Jason.

hw/arm_sysctl.c +4 -2
Index: qemu/hw/arm_sysctl.c
===================================================================
@@ -71,8 +71,10 @@ static uint32_t arm_sysctl_read(void *op
     case 0x58: /* BOOTCS */
         return 0;
     case 0x5c: /* 24MHz */
-        /* ??? not implemented.  */
-        return 0;
+    {   
+        uint64_t now = qemu_get_clock(vm_clock);
+        return (uint32_t)(now*.024);
+    }
     case 0x60: /* MISC */
         return 0;
     case 0x84: /* PROCID0 */
#1 lore raw
Quoted 2 lines

+        uint64_t now = qemu_get_clock(vm_clock);
+        return (uint32_t)(now*.024);

We should be able to do this without resorting to floating point arithmetic.

Paul

#2 lore raw

If you're ok you can shift it left 4 bits, then add half that result then shift right 10 bits.

Of course, you'll only get 23.4Mhz that way :-)

jonathan

Quoted 11 lines · Paul Brook
Quoted 3 lines

+ uint64_t now = qemu_get_clock(vm_clock);
+ return (uint32_t)(now*.024);

We should be able to do this without resorting to floating point arithmetic.

Paul

Signature · 3 lines
--
Jonathan Kalbfeld
+1 323 620 6682
#3 lore raw

uint64_t now = qemu_get_clock(vm_clock);
return (uint32_t)((now*3)/125);

The optimizer should fix this up with no floating point ops.

Jason.

________________________________

From: [email protected]
[mailto:[email protected]] On Behalf Of Jonathan Kalbfeld

	Sent: Friday, March 30, 2007 12:50 PM
	To: [email protected]
	Subject: Re: [Qemu-devel] [PATCH] add a simple 24mhz clock for

the versatile

If you're ok you can shift it left 4 bits, then add half that
result then shift right 10 bits.

Of course, you'll only get 23.4Mhz that way :-)

jonathan

On 3/30/07, Paul Brook <[email protected]> wrote:

> + uint64_t now = qemu_get_clock(vm_clock); > + return (uint32_t)(now*.024);

We should be able to do this without resorting to
floating point arithmetic.

		Paul
		
		
		




	-- 
	--
	Jonathan Kalbfeld
	+1 323 620 6682 
#4 lore raw
Quoted 6 lines · Jason

uint64_t now = qemu_get_clock(vm_clock);
return (uint32_t)((now*3)/125);

The optimizer should fix this up with no floating point ops.

Adding to the bikeshed discussion (www.bikeshed.com) this is still not correct as vm_clock is to be used with ticks_per_sec.

return muldiv64(qemu_get_clock(vm_clock), 24000000, ticks_per_sec);

Regards,
Andrzej