All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4] timer: Add High Precision Event Timers (HPET) support
Date: Fri, 06 Apr 2018 20:56:42 +0300	[thread overview]
Message-ID: <1523037402.21176.381.camel@linux.intel.com> (raw)
In-Reply-To: <bb0b62d9ceb30467dcc0deeddcd5b55a1ea36311.1523035915.git.ivan.gorinov@intel.com>

On Fri, 2018-04-06 at 10:38 -0700, Ivan Gorinov wrote:
> Add HPET driver as an alternative timer for x86 (default is TSC).
> HPET counter has constant frequency and does not need calibration.
> This change also makes TSC timer driver optional on x86.
> New HPET driver can also be selected as the early timer on x86.

> +/* Reset and start the main counter. */
> +static void start_main_counter(void *regs)
> +{
> +	volatile u64 *main_counter = regs + HPET_MAIN_COUNT;
> +	u32 config;
> +
> +	config = readl(regs + HPET_CONFIG_REG);
> +	config &= ~ENABLE_CNF;
> +	writel(config, regs + HPET_CONFIG_REG);

> +	*main_counter = 0;

It needs to be done as writeq() / readq().

Please, define them first in arch/x86/include/asm/io.h
(as an example you can use arch/arm/include/asm/io.h).

> +	config |= ENABLE_CNF;
> +	writel(config, regs + HPET_CONFIG_REG);
> +}
> +
> +/* Read the main counter, repeat if 32-bit rollover happens. */
> +static u64 read_main_counter(void *regs)
> +{
> +	volatile u64 *main_counter = regs + HPET_MAIN_COUNT;
> +	u64 t, t0;
> +
> +	t = *main_counter;
> +	do {
> +		t0 = t;

> +		t = *main_counter;

Ditto.

> +	} while ((t >> 32) != (t0 >> 32));
> +
> +	return t;
> +}

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

      reply	other threads:[~2018-04-06 17:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-06 17:37 [U-Boot] [PATCH v4] timer: Add High Precision Event Timers (HPET) support Ivan Gorinov
2018-04-06 17:38 ` Ivan Gorinov
2018-04-06 17:56   ` Andy Shevchenko [this message]

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=1523037402.21176.381.camel@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=u-boot@lists.denx.de \
    /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 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.