mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: linux-m68k@vger.kernel.org
Cc: Thorsten Glaser <tg@mirbsd.de>, "Theodore Ts'o" <tytso@mit.edu>,
	linux-kernel@vger.kernel.org,
	Geert Uytterhoeven <geert@linux-m68k.org>
Subject: [PATCH/RFC 2/2] m68k/amiga: Provide mach_get_cycles()
Date: Mon,  9 Sep 2013 21:26:14 +0200	[thread overview]
Message-ID: <1378754774-25804-2-git-send-email-geert@linux-m68k.org> (raw)
In-Reply-To: <1378754774-25804-1-git-send-email-geert@linux-m68k.org>

Use the 24-bit Time-Of-Day clock in CIA B, which is clocked by HSYNC.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
  1. Completely untested! It does compile ;-)

  2. Is a 24-bit counter running at 15-31 kHz good enough?
     Two cascaded 16-bit CIA timers running from the 700 kHz E-clock would
     be better, but as jiffies use CIA B Timer A and the floppy driver uses
     CIA A Timer B, we don't have two available timers in the same CIA
     without some code shuffling.

  3. What are the semantics of get_cycles()?
     Does it have to be a "nice" counter, or can there be some
     irregularities?
     I.e. can I add one more line
     
	x = (x << 8) | ciab.talo;	// low byte of 700 kHz timer
	
     to get 32 bits?

 arch/m68k/amiga/config.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/arch/m68k/amiga/config.c b/arch/m68k/amiga/config.c
index acd9c16..914e056 100644
--- a/arch/m68k/amiga/config.c
+++ b/arch/m68k/amiga/config.c
@@ -358,6 +358,20 @@ static void __init amiga_identify(void)
 #undef AMIGAHW_ANNOUNCE
 }
 
+
+static cycles_t amiga_get_cycles(void)
+{
+	cycles_t x;
+
+	/* CIA B 24-bit TOD is clocked by HSYNC */
+	x = ciab.todhi;
+	x = (x << 8) | ciab.todmid;
+	x = (x << 8) | ciab.todlo;
+
+	return x;
+}
+
+
     /*
      *  Setup the Amiga configuration info
      */
@@ -395,6 +409,8 @@ void __init config_amiga(void)
 	mach_heartbeat = amiga_heartbeat;
 #endif
 
+	mach_get_cycles = amiga_get_cycles;
+
 	/* Fill in the clock value (based on the 700 kHz E-Clock) */
 	amiga_colorclock = 5*amiga_eclock;	/* 3.5 MHz */
 
-- 
1.7.9.5


  reply	other threads:[~2013-09-09 19:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-09 19:26 [PATCH 1/2] m68k: Add infrastructure for machine-specific get_cycles() Geert Uytterhoeven
2013-09-09 19:26 ` Geert Uytterhoeven [this message]
2013-09-09 20:35 ` Thorsten Glaser

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=1378754774-25804-2-git-send-email-geert@linux-m68k.org \
    --to=geert@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@vger.kernel.org \
    --cc=tg@mirbsd.de \
    --cc=tytso@mit.edu \
    /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

all inboxes | Powered by JetHome®