public inbox for linux-sh@vger.kernel.org
 help / color / mirror / Atom feed
From: Magnus Damm <magnus.damm@gmail.com>
To: linux-sh@vger.kernel.org
Subject: [PATCH] clocksource: sh_cmt: wait for CMCNT on init
Date: Thu, 30 Jun 2011 09:12:58 +0000	[thread overview]
Message-ID: <20110630091258.10263.21421.sendpatchset@t400s> (raw)

From: Magnus Damm <damm@opensource.se>

Add code to the CMT driver to wait for CMCNT to settle before
starting the timer channel. Makes the driver more robust.

Needed for CMT2 on sh7372 and certain CMT channels on sh73a0.

Signed-off-by: Magnus Damm <damm@opensource.se>
---

 drivers/clocksource/sh_cmt.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

--- 0001/drivers/clocksource/sh_cmt.c
+++ work/drivers/clocksource/sh_cmt.c	2011-06-29 20:41:22.000000000 +0900
@@ -174,6 +174,20 @@ static int sh_cmt_enable(struct sh_cmt_p
 	sh_cmt_write(p, CMCOR, 0xffffffff);
 	sh_cmt_write(p, CMCNT, 0);
 
+	/*
+	 * According to the user's manual, as CMCNT can be operated only
+	 * by the RCLK (Pseudo 32 KHz), there's one restrictions on
+	 * modifying CMCNT register; two RCLK cycles are necessary before
+	 * this register is either read or any modification of the value
+	 * it holds is reflected in the LSI's actual operation.
+	 *
+	 * While at it, we're supposed to clear out the CMCNT as of this
+	 * moment, so make sure it's processed properly here.  This will
+	 * take RCLKx2 at maximum.
+	 */
+	while (sh_cmt_read(p, CMCNT) != 0)
+		cpu_relax();
+
 	/* enable channel */
 	sh_cmt_start_stop_ch(p, 1);
 	return 0;

             reply	other threads:[~2011-06-30  9:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-30  9:12 Magnus Damm [this message]
2011-07-13  7:59 ` [PATCH] clocksource: sh_cmt: wait for CMCNT on init V2 Magnus Damm
2011-07-21  7:54 ` Paul Mundt

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=20110630091258.10263.21421.sendpatchset@t400s \
    --to=magnus.damm@gmail.com \
    --cc=linux-sh@vger.kernel.org \
    /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