From: Francesco VIRLINZI <francesco.virlinzi@st.com>
To: Jeremy Kerr <jeremy.kerr@canonical.com>
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [RFC,PATCH 1/7 v2] Add a common struct clk
Date: Tue, 12 Jan 2010 09:48:44 +0100 [thread overview]
Message-ID: <4B4C376C.6080705@st.com> (raw)
In-Reply-To: <1263279511.160551.332624337260.1.gpush@pororo>
Hi Jeremy
In November I already sent a proposal on
a generic linux clk framework.
On that I would suggest:
>
> +struct clk {
> + const struct clk_operations *ops;
>
spinlock_t lock;
const char *name;
int id;
unsigned long rate;
> +};
> +
> +struct clk_operations {
>
int (*init)(struc clk *);
> + int (*enable)(struct clk *);
> + void (*disable)(struct clk *);
> + unsigned long (*get_rate)(struct clk *);
> + void (*put)(struct clk *);
> + long (*round_rate)(struct clk *, unsigned long);
> + int (*set_rate)(struct clk *, unsigned long);
> + int (*set_parent)(struct clk *, struct clk *);
> + struct clk* (*get_parent)(struct clk *);
> +};
>
+static inline int clk_enable(struct clk *clk)
+{
unsigned long flags;
int ret = 0;
+ if (clk->ops->enable) {
spinlock_irq_save(&clk->lock, flags);
+ ret = clk->ops->enable(clk);
spinlock_irq_restore(&clk->lock, flags);
}
+ return 0;
+}
Something similar in the other function...
> +
> +static inline unsigned long clk_get_rate(struct clk *clk)
> +{
> + if (clk->ops->get_rate)
> + return clk->ops->get_rate(clk);
>
> return clk->rate;
> +}
>
>
Moreover if you support .set_parent and .get_parent a .parent field in
the struct clk
is useful.
As
struct clk {
const struct clk_operations *ops;
spinlock_t lock;
const char *name;
int id;
unsigned long rate;
struct clk *parent;
};
Regards
Francesco
next prev parent reply other threads:[~2010-01-12 9:19 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-12 6:58 [RFC,PATCH 0/7 v2] Common struct clk implementation Jeremy Kerr
2010-01-12 6:58 ` [RFC,PATCH 5/7 v2] arm/realview: use generic struct clk Jeremy Kerr
2010-01-12 6:58 ` [RFC,PATCH 3/7 v2] arm/versatile: " Jeremy Kerr
2010-01-12 16:25 ` Russell King - ARM Linux
2010-01-25 0:35 ` Jeremy Kerr
2010-01-12 6:58 ` [RFC,PATCH 4/7 v2] arm/versatile: remove oscoff from clk_versatile Jeremy Kerr
2010-01-12 6:58 ` [RFC,PATCH 7/7 v2] arm/icst307: remove icst307_ps_to_vco Jeremy Kerr
2010-01-12 6:58 ` [RFC, PATCH 6/7 v2] arm/icst307: use common struct clk, unify realview and versatile clocks Jeremy Kerr
2010-01-12 6:58 ` [RFC,PATCH 2/7 v2] Generic support for fixed-rate clocks Jeremy Kerr
2010-01-12 6:58 ` [RFC,PATCH 1/7 v2] Add a common struct clk Jeremy Kerr
2010-01-12 8:48 ` Francesco VIRLINZI [this message]
2010-01-12 9:01 ` Russell King - ARM Linux
2010-01-12 14:24 ` Ben Dooks
2010-01-12 14:27 ` Ben Dooks
2010-01-12 14:30 ` Ben Dooks
2010-01-12 9:13 ` [RFC,PATCH 0/7 v2] Common struct clk implementation Russell King - ARM Linux
2010-01-13 1:17 ` Jeremy Kerr
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=4B4C376C.6080705@st.com \
--to=francesco.virlinzi@st.com \
--cc=jeremy.kerr@canonical.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.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).