From: Laurent Pinchart <laurentp@cse-semaphore.com>
To: linuxppc-dev@ozlabs.org, avorontsov@ru.mvista.com
Cc: Scott Wood <scottwood@freescale.com>
Subject: Re: [PATCH 6/8] [POWERPC] sysdev,qe_lib: implement FSL GTM support
Date: Thu, 17 Apr 2008 16:23:56 +0200 [thread overview]
Message-ID: <200804171624.02769.laurentp@cse-semaphore.com> (raw)
In-Reply-To: <20080416183904.GA23512@polina.dev.rtsoft.ru>
[-- Attachment #1: Type: text/plain, Size: 3745 bytes --]
On Wednesday 16 April 2008 20:39, Anton Vorontsov wrote:
> On Tue, Mar 18, 2008 at 03:48:12PM -0500, Scott Wood wrote:
> [...]
> > How about:
> >
> > struct gtm_timer *gtm_get_specific_timer(struct gtm *gtm, int timer,
> > int width);
> >
> > ...with np->data used by the caller to figure out which gtm pointer to
> > pass in.
>
> Thanks for the comments, I've tried to address them all.
>
> Updated patch below (not for applying, still waiting for further
> comments, if any).
>
> - - - -
> From: Anton Vorontsov <avorontsov@ru.mvista.com>
> Subject: [POWERPC] sysdev,qe_lib: implement FSL GTM support
>
> GTM stands for General-purpose Timers Module and able to generate
> timer{1,2,3,4} interrupts.
>
> There are several limitations in this support:
> 1. Cascaded (32 bit) timers unimplemented (1-2, 3-4).
> This is straightforward to implement when needed, two timers should
> be marked as "requested" and configured as appropriate.
> 2. Super-cascaded (64 bit) timers unimplemented (1-2-3-4).
> This is also straightforward to implement when needed, all timers
> should be marked as "requested" and configured as appropriate.
>
> Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
> ---
> Documentation/powerpc/booting-without-of.txt | 32 +++-
> arch/powerpc/Kconfig | 5 +
> arch/powerpc/sysdev/Makefile | 1 +
> arch/powerpc/sysdev/fsl_gtm.c | 322 ++++++++++++++++++++++++++
> include/asm-powerpc/fsl_gtm.h | 106 +++++++++
> 5 files changed, 465 insertions(+), 1 deletions(-)
> create mode 100644 arch/powerpc/sysdev/fsl_gtm.c
> create mode 100644 include/asm-powerpc/fsl_gtm.h
[snip]
> +/*
> + * This is back-end for the exported functions, it's used to reset single
> + * timer in reference mode.
> + */
> +static int gtm_reset_ref_timer16(struct gtm_timer *tmr, int frequency,
> + int reference_value, bool free_run)
> +{
> + struct gtm *gtm = tmr->gtm;
> + int num = tmr - >m->timers[0];
> + unsigned int prescaler;
> + u8 iclk = GTMDR_ICLK_ICLK;
> + u8 psr;
> + u8 sps;
> + unsigned long flags;
> +
> + prescaler = gtm->clock / frequency;
> + /*
> + * We have two 8 bit prescalers -- primary and secondary (psr, sps),
> + * plus "slow go" mode (clk / 16). So, total prescale value is
> + * 16 * (psr + 1) * (sps + 1).
> + */
> + if (prescaler > 256 * 256 * 16)
> + return -EINVAL;
> +
> + if (prescaler > 256 * 256) {
> + iclk = GTMDR_ICLK_SLGO;
> + prescaler /= 16;
> + }
> +
> + if (prescaler > 256) {
> + psr = 256 - 1;
> + sps = prescaler / 256 - 1;
> + } else {
> + psr = prescaler - 1;
> + sps = 1 - 1;
> + }
Don't forget that the CPM2 doesn't support the primary prescaler.
> + spin_lock_irqsave(>m->lock, flags);
> +
> + /*
> + * Properly reset timers: stop, reset, set up prescalers, reference
> + * value and clear event register.
> + */
> + clrsetbits_8(tmr->gtcfr, ~(GTCFR_STP(num) | GTCFR_RST(num)),
> + GTCFR_STP(num) | GTCFR_RST(num));
> +
> + setbits8(tmr->gtcfr, GTCFR_STP(num));
> +
> + out_be16(tmr->gtpsr, psr);
> + clrsetbits_be16(tmr->gtmdr, 0xFFFF, iclk | GTMDR_SPS(sps) |
> + GTMDR_ORI | (free_run ? GTMDR_FFR : 0));
> + out_be16(tmr->gtcnr, 0);
> + out_be16(tmr->gtrfr, reference_value);
> + out_be16(tmr->gtevr, 0xFFFF);
> +
> + /* Let it be. */
> + clrbits8(tmr->gtcfr, GTCFR_STP(num));
> +
> + spin_unlock_irqrestore(>m->lock, flags);
> +
> + return 0;
> +}
--
Laurent Pinchart
CSE Semaphore Belgium
Chaussee de Bruxelles, 732A
B-1410 Waterloo
Belgium
T +32 (2) 387 42 59
F +32 (2) 387 42 75
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2008-04-17 14:24 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-11 17:21 [PATCH 0/8] A bit of new code and sparse cleanups along the way Anton Vorontsov
2008-03-11 17:23 ` [PATCH 1/8] [POWERPC] fsl_elbc_nand: factor out localbus defines Anton Vorontsov
2008-04-11 14:06 ` Kumar Gala
2008-04-13 12:53 ` David Woodhouse
2008-04-14 15:10 ` Kumar Gala
2008-03-11 17:24 ` [PATCH 2/8] [POWERPC] fsl_lbc: implement few routines to manage FSL UPMs Anton Vorontsov
2008-04-11 14:09 ` Kumar Gala
2008-04-11 16:13 ` Anton Vorontsov
2008-04-11 16:18 ` Scott Wood
2008-04-11 17:03 ` Anton Vorontsov
2008-04-12 4:09 ` Paul Mackerras
2008-04-14 15:11 ` Kumar Gala
2008-03-11 17:24 ` [PATCH 3/8] [POWERPC] qe_lib: implement qe_muram_offset Anton Vorontsov
2008-03-18 17:48 ` Scott Wood
2008-04-14 15:11 ` Kumar Gala
2008-03-11 17:24 ` [PATCH 4/8] [POWERPC] immap_qe.h should include asm/io.h Anton Vorontsov
2008-04-14 15:11 ` Kumar Gala
2008-03-11 17:24 ` [PATCH 5/8] [POWERPC] qe_lib: export qe_get_brg_clk() Anton Vorontsov
2008-03-11 18:36 ` Kumar Gala
2008-03-11 18:44 ` Anton Vorontsov
2008-04-14 15:11 ` Kumar Gala
2008-03-11 17:24 ` [PATCH 6/8] [POWERPC] sysdev,qe_lib: implement FSL GTM support Anton Vorontsov
2008-03-18 17:43 ` Scott Wood
2008-03-18 19:21 ` Anton Vorontsov
2008-03-18 19:55 ` Scott Wood
2008-03-18 20:27 ` Anton Vorontsov
2008-03-18 20:48 ` Scott Wood
2008-04-16 18:39 ` Anton Vorontsov
2008-04-16 18:44 ` Scott Wood
2008-04-16 21:00 ` Anton Vorontsov
2008-04-16 21:58 ` Scott Wood
2008-04-17 12:52 ` Anton Vorontsov
2008-04-17 14:19 ` Scott Wood
2008-04-17 15:07 ` Anton Vorontsov
2008-04-17 16:14 ` Scott Wood
2008-04-17 16:43 ` Anton Vorontsov
2008-04-17 14:23 ` Laurent Pinchart [this message]
2008-04-17 15:13 ` Anton Vorontsov
2008-04-17 16:12 ` Anton Vorontsov
2008-04-08 9:01 ` Laurent Pinchart
2008-04-08 11:48 ` Anton Vorontsov
2008-03-11 17:24 ` [PATCH 7/8] [POWERPC] qe_lib: add support for QE USB Anton Vorontsov
2008-04-14 20:29 ` Kumar Gala
2008-03-11 17:24 ` [PATCH 8/8] [POWERPC] qe_io: fix sparse warnings Anton Vorontsov
2008-04-14 15:12 ` Kumar Gala
2008-04-14 15:14 ` [PATCH 0/8] A bit of new code and sparse cleanups along the way Kumar Gala
2008-04-14 17:49 ` Anton Vorontsov
-- strict thread matches above, loose matches on Subject: below --
2008-04-17 16:22 [PATCH 6/8] [POWERPC] sysdev,qe_lib: implement FSL GTM support Scott Wood
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=200804171624.02769.laurentp@cse-semaphore.com \
--to=laurentp@cse-semaphore.com \
--cc=avorontsov@ru.mvista.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=scottwood@freescale.com \
/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;
as well as URLs for NNTP newsgroup(s).