LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Kumar Gala <galak@kernel.crashing.org>
To: Timur Tabi <timur@freescale.com>
Cc: linuxppc-dev@ozlabs.org
Subject: Re: qe: change qe_setbrg() to take an enum qe_clock instead of an integer
Date: Thu, 29 Nov 2007 16:45:26 -0600	[thread overview]
Message-ID: <67128081-C2EE-4FDB-A422-0C7075B01DB4@kernel.crashing.org> (raw)
In-Reply-To: <1196373406380-git-send-email-timur@freescale.com>


On Nov 29, 2007, at 3:56 PM, Timur Tabi wrote:

> qe_setbrg() currently takes an integer to indicate the BRG number.   
> Change that
> to take an enum qe_clock instead, since this enum is intended to  
> represent
> clock sources.
>
> Signed-off-by: Timur Tabi <timur@freescale.com>
> ---
>
> This patch applies to Kumar's for-2.6.25 branch.  You might need to  
> apply my
> other patch, "qe: fix device tree lookup code in qe_muram_init()",  
> first.
>
> It's safe to change the parameters to qe_setbrg() because no one is  
> using that
> function yet.
>
> arch/powerpc/sysdev/qe_lib/qe.c |   12 +++--
> include/asm-powerpc/qe.h        |   94 ++++++++++++++++++ 
> +-------------------
> 2 files changed, 54 insertions(+), 52 deletions(-)
>
> diff --git a/arch/powerpc/sysdev/qe_lib/qe.c b/arch/powerpc/sysdev/ 
> qe_lib/qe.c
> index 298e073..8ef4690 100644
> --- a/arch/powerpc/sysdev/qe_lib/qe.c
> +++ b/arch/powerpc/sysdev/qe_lib/qe.c
> @@ -167,19 +167,20 @@ unsigned int get_brg_clk(void)
>
> /* Program the BRG to the given sampling rate and multiplier
>  *
> - * @brg: the BRG, 1-16
> + * @brg: the BRG, QE_BRG1 - QE_BRG16
>  * @rate: the desired sampling rate
>  * @multiplier: corresponds to the value programmed in GUMR_L[RDCR] or
>  * GUMR_L[TDCR].  E.g., if this BRG is the RX clock, and  
> GUMR_L[RDCR]=01,
>  * then 'multiplier' should be 8.
> - *
> - * Also note that the value programmed into the BRGC register must  
> be even.
>  */
> -void qe_setbrg(unsigned int brg, unsigned int rate, unsigned int  
> multiplier)
> +void qe_setbrg(enum qe_clock brg, unsigned int rate, unsigned int  
> multiplier)
> {
> 	u32 divisor, tempval;
> 	u32 div16 = 0;
>
> +	if ((brg < QE_BRG1) || (brg > QE_BRG16))
> +		return;

seems like we should report some form of error like -EINVAL instead.

>
> +
> 	divisor = get_brg_clk() / (rate * multiplier);
>
> 	if (divisor > QE_BRGC_DIVISOR_MAX + 1) {
> @@ -196,8 +197,9 @@ void qe_setbrg(unsigned int brg, unsigned int  
> rate, unsigned int multiplier)
> 	tempval = ((divisor - 1) << QE_BRGC_DIVISOR_SHIFT) |
> 		QE_BRGC_ENABLE | div16;
>
> -	out_be32(&qe_immr->brg.brgc[brg - 1], tempval);
> +	out_be32(&qe_immr->brg.brgc[brg - QE_BRG1], tempval);
> }
> +EXPORT_SYMBOL(qe_setbrg);
>
> /* Initialize SNUMs (thread serial numbers) according to
>  * QE Module Control chapter, SNUM table

- k

      reply	other threads:[~2007-11-29 22:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-29 21:56 qe: change qe_setbrg() to take an enum qe_clock instead of an integer Timur Tabi
2007-11-29 22:45 ` Kumar Gala [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=67128081-C2EE-4FDB-A422-0C7075B01DB4@kernel.crashing.org \
    --to=galak@kernel.crashing.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=timur@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