Skip to content

Commit

Permalink
ARM: davinci: clk: add set_parent callback for mux clocks
Browse files Browse the repository at this point in the history
Introduce a set_parent callback that will be used for mux clocks, such as
the USB PHY muxes and the async3 clock domain mux.

Signed-off-by: David Lechner <david@lechnology.com>
[nsekhar@ti.com: checkpatch fixes]
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
  • Loading branch information
David Lechner authored and Sekhar Nori committed Apr 14, 2016
1 parent 86cad16 commit 8a9d088
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
19 changes: 18 additions & 1 deletion arch/arm/mach-davinci/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
return -EINVAL;

mutex_lock(&clocks_mutex);
if (clk->set_parent) {
int ret = clk->set_parent(clk, parent);

if (ret) {
mutex_unlock(&clocks_mutex);
return ret;
}
}
clk->parent = parent;
list_del_init(&clk->childnode);
list_add(&clk->childnode, &clk->parent->children);
Expand Down Expand Up @@ -224,8 +232,17 @@ int clk_register(struct clk *clk)

mutex_lock(&clocks_mutex);
list_add_tail(&clk->node, &clocks);
if (clk->parent)
if (clk->parent) {
if (clk->set_parent) {
int ret = clk->set_parent(clk, clk->parent);

if (ret) {
mutex_unlock(&clocks_mutex);
return ret;
}
}
list_add_tail(&clk->childnode, &clk->parent->children);
}
mutex_unlock(&clocks_mutex);

/* If rate is already set, use it */
Expand Down
1 change: 1 addition & 0 deletions arch/arm/mach-davinci/clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ struct clk {
int (*reset) (struct clk *clk, bool reset);
void (*clk_enable) (struct clk *clk);
void (*clk_disable) (struct clk *clk);
int (*set_parent) (struct clk *clk, struct clk *parent);
};

/* Clock flags: SoC-specific flags start at BIT(16) */
Expand Down

0 comments on commit 8a9d088

Please sign in to comment.