linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: ithamar.adema@team-embedded.nl (Ithamar R. Adema)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 3/9] lpc2k: clk API
Date: Tue, 22 Mar 2011 02:13:26 +0100	[thread overview]
Message-ID: <1300756406.2648.25.camel@team-embedded-2> (raw)
In-Reply-To: <083DF309106F364B939360100EC290F80B15C9C579@eu1rdcrdc1wx030.exi.nxp.com>

On Tue, 2011-03-22 at 01:16 +0100, Kevin Wells wrote:
> > +struct clk {
> > +	int		refcount;
> > +	struct clk	*parent;
> > +	unsigned long	rate;
> 
> It looks like this rate field is only used in 3 clock
> descriptors. It might save some space to get rid of this field
> and associated code and have those 3 clocks just use functions
> for get_rate() that return the direct value.

Fair enough, I can update that....

> > +static unsigned long pclkdiv[] = { 4, 1, 2, 8 };
> > +
> > +#define PERCLK(name, pnum)	\
> > +	static unsigned long name ## _get_rate(struct clk *clk) \
> > +	{	\
> > +		unsigned long rate = clk_get_rate(clk->parent);	\
> > +		u32 val = clk_readl((pnum < 16) ? PCLKSEL0 : PCLKSEL1); \
> > +		val >>= (pnum < 16) ? pnum * 2 : (pnum - 16) * 2;	\
> > +		return rate / pclkdiv[val & 3];	\
> > +	}	\
> > +	struct clk clk_ ## name = {	\
> > +		.parent = &clk_cpu,	\
> > +		.enable_mask = (1 << pnum),	\
> > +		.get_rate = name ## _get_rate,	\
> > +	}
> > +
> 
> This macro will generate multiple functions with different names but the same
> code. Can the function be made common to the supported clocks and the macro
> just handle clock descriptor setup?

I could add a field to the clk struct to store it, since the peripheral
clock is the most common type of clk in the system, so it wouldn't waste
too much.

Regards,

Ithamar.

  reply	other threads:[~2011-03-22  1:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-20 20:30 [PATCH v3 0/9] Support for NXP LPC2K SoCs Ithamar R. Adema
2011-03-20 20:30 ` [PATCH v3 1/9] lpc2k: Core support Ithamar R. Adema
2011-03-20 20:30 ` [PATCH v3 2/9] lpc2k: Exception vector handling Ithamar R. Adema
2011-03-20 20:30 ` [PATCH v3 3/9] lpc2k: clk API Ithamar R. Adema
2011-03-22  0:16   ` Kevin Wells
2011-03-22  1:13     ` Ithamar R. Adema [this message]
2011-03-20 20:30 ` [PATCH v3 4/9] lpc2k: generic time and clockevents Ithamar R. Adema
2011-03-20 20:30 ` [PATCH v3 5/9] lpc2k: gpiolib Ithamar R. Adema
2011-03-20 20:30 ` [PATCH v3 6/9] lpc2k: multifunction pin configuration Ithamar R. Adema
2011-03-20 20:30 ` [PATCH v3 7/9] lpc2k: Add EmbeddedArtists LPC2478 Developer's Kit board Ithamar R. Adema
2011-03-20 20:30 ` [PATCH v3 8/9] lpc2k: Add UART, SSP, and MCI devices Ithamar R. Adema
2011-03-20 20:30 ` [PATCH v3 9/9] lpc2k: defconfig for NXP LPC2K platform Ithamar R. Adema

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=1300756406.2648.25.camel@team-embedded-2 \
    --to=ithamar.adema@team-embedded.nl \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).