Skip to content

Commit

Permalink
clk: mediatek: Register clock gate with device
Browse files Browse the repository at this point in the history
Allow those clocks under a power domain to do the runtime pm operation
by forwarding the struct device pointer from clock provider.

Signed-off-by: Weiyi Lu <weiyi.lu@mediatek.com>
Link: https://lkml.kernel.org/r/1567414859-3244-2-git-send-email-weiyi.lu@mediatek.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
  • Loading branch information
Weiyi Lu authored and Stephen Boyd committed Sep 17, 2019
1 parent f9e55ac commit e4c23e1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
5 changes: 3 additions & 2 deletions drivers/clk/mediatek/clk-gate.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ struct clk *mtk_clk_register_gate(
int sta_ofs,
u8 bit,
const struct clk_ops *ops,
unsigned long flags)
unsigned long flags,
struct device *dev)
{
struct mtk_clk_gate *cg;
struct clk *clk;
Expand All @@ -174,7 +175,7 @@ struct clk *mtk_clk_register_gate(

cg->hw.init = &init;

clk = clk_register(NULL, &cg->hw);
clk = clk_register(dev, &cg->hw);
if (IS_ERR(clk))
kfree(cg);

Expand Down
3 changes: 2 additions & 1 deletion drivers/clk/mediatek/clk-gate.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ struct clk *mtk_clk_register_gate(
int sta_ofs,
u8 bit,
const struct clk_ops *ops,
unsigned long flags);
unsigned long flags,
struct device *dev);

#define GATE_MTK_FLAGS(_id, _name, _parent, _regs, _shift, \
_ops, _flags) { \
Expand Down
16 changes: 13 additions & 3 deletions drivers/clk/mediatek/clk-mtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <linux/delay.h>
#include <linux/clkdev.h>
#include <linux/mfd/syscon.h>
#include <linux/device.h>

#include "clk-mtk.h"
#include "clk-gate.h"
Expand Down Expand Up @@ -93,9 +94,10 @@ void mtk_clk_register_factors(const struct mtk_fixed_factor *clks,
}
}

int mtk_clk_register_gates(struct device_node *node,
int mtk_clk_register_gates_with_dev(struct device_node *node,
const struct mtk_gate *clks,
int num, struct clk_onecell_data *clk_data)
int num, struct clk_onecell_data *clk_data,
struct device *dev)
{
int i;
struct clk *clk;
Expand All @@ -122,7 +124,7 @@ int mtk_clk_register_gates(struct device_node *node,
gate->regs->set_ofs,
gate->regs->clr_ofs,
gate->regs->sta_ofs,
gate->shift, gate->ops, gate->flags);
gate->shift, gate->ops, gate->flags, dev);

if (IS_ERR(clk)) {
pr_err("Failed to register clk %s: %ld\n",
Expand All @@ -136,6 +138,14 @@ int mtk_clk_register_gates(struct device_node *node,
return 0;
}

int mtk_clk_register_gates(struct device_node *node,
const struct mtk_gate *clks,
int num, struct clk_onecell_data *clk_data)
{
return mtk_clk_register_gates_with_dev(node,
clks, num, clk_data, NULL);
}

struct clk *mtk_clk_register_composite(const struct mtk_composite *mc,
void __iomem *base, spinlock_t *lock)
{
Expand Down
5 changes: 5 additions & 0 deletions drivers/clk/mediatek/clk-mtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ int mtk_clk_register_gates(struct device_node *node,
const struct mtk_gate *clks, int num,
struct clk_onecell_data *clk_data);

int mtk_clk_register_gates_with_dev(struct device_node *node,
const struct mtk_gate *clks,
int num, struct clk_onecell_data *clk_data,
struct device *dev);

struct mtk_clk_divider {
int id;
const char *name;
Expand Down

0 comments on commit e4c23e1

Please sign in to comment.