lkml.org 
[lkml]   [2010]   [Jan]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC,PATCH 1/7 v2] Add a common struct clk
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


\
 
 \ /
  Last update: 2010-01-12 10:21    [W:0.123 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site