clk: allow to instanciate clk mux without registering it
Allows to reuse clk mux code within other clocks. Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
98a2fe8f95
commit
10a06ed554
|
@ -27,6 +27,8 @@ struct clk_mux {
|
||||||
int width;
|
int width;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define to_clk_mux(_clk) container_of(_clk, struct clk_mux, clk)
|
||||||
|
|
||||||
static int clk_mux_get_parent(struct clk *clk)
|
static int clk_mux_get_parent(struct clk *clk)
|
||||||
{
|
{
|
||||||
struct clk_mux *m = container_of(clk, struct clk_mux, clk);
|
struct clk_mux *m = container_of(clk, struct clk_mux, clk);
|
||||||
|
@ -53,11 +55,10 @@ struct clk_ops clk_mux_ops = {
|
||||||
.set_parent = clk_mux_set_parent,
|
.set_parent = clk_mux_set_parent,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct clk *clk_mux(const char *name, void __iomem *reg,
|
struct clk *clk_mux_alloc(const char *name, void __iomem *reg,
|
||||||
u8 shift, u8 width, const char **parents, u8 num_parents)
|
u8 shift, u8 width, const char **parents, u8 num_parents)
|
||||||
{
|
{
|
||||||
struct clk_mux *m = xzalloc(sizeof(*m));
|
struct clk_mux *m = xzalloc(sizeof(*m));
|
||||||
int ret;
|
|
||||||
|
|
||||||
m->reg = reg;
|
m->reg = reg;
|
||||||
m->shift = shift;
|
m->shift = shift;
|
||||||
|
@ -67,11 +68,29 @@ struct clk *clk_mux(const char *name, void __iomem *reg,
|
||||||
m->clk.parent_names = parents;
|
m->clk.parent_names = parents;
|
||||||
m->clk.num_parents = num_parents;
|
m->clk.num_parents = num_parents;
|
||||||
|
|
||||||
ret = clk_register(&m->clk);
|
return &m->clk;
|
||||||
|
}
|
||||||
|
|
||||||
|
void clk_mux_free(struct clk *clk_mux)
|
||||||
|
{
|
||||||
|
struct clk_mux *m = to_clk_mux(clk_mux);
|
||||||
|
|
||||||
|
free(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct clk *clk_mux(const char *name, void __iomem *reg,
|
||||||
|
u8 shift, u8 width, const char **parents, u8 num_parents)
|
||||||
|
{
|
||||||
|
struct clk *m;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
m = clk_mux_alloc(name, reg, shift, width, parents, num_parents);
|
||||||
|
|
||||||
|
ret = clk_register(m);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
free(m);
|
free(to_clk_mux(m));
|
||||||
return ERR_PTR(ret);
|
return ERR_PTR(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
return &m->clk;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,6 +212,10 @@ struct clk *clk_divider_table(const char *name,
|
||||||
const struct clk_div_table *table);
|
const struct clk_div_table *table);
|
||||||
struct clk *clk_fixed_factor(const char *name,
|
struct clk *clk_fixed_factor(const char *name,
|
||||||
const char *parent, unsigned int mult, unsigned int div);
|
const char *parent, unsigned int mult, unsigned int div);
|
||||||
|
|
||||||
|
struct clk *clk_mux_alloc(const char *name, void __iomem *reg,
|
||||||
|
u8 shift, u8 width, const char **parents, u8 num_parents);
|
||||||
|
void clk_mux_free(struct clk *clk_mux);
|
||||||
struct clk *clk_mux(const char *name, void __iomem *reg,
|
struct clk *clk_mux(const char *name, void __iomem *reg,
|
||||||
u8 shift, u8 width, const char **parents, u8 num_parents);
|
u8 shift, u8 width, const char **parents, u8 num_parents);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue