Skip to content

Commit e4c23e1

Browse files
WeiyiLu-MediaTekbebarino
authored andcommitted
clk: mediatek: Register clock gate with device
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>
1 parent f9e55ac commit e4c23e1

4 files changed

Lines changed: 23 additions & 6 deletions

File tree

‎drivers/clk/mediatek/clk-gate.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ struct clk *mtk_clk_register_gate(
150150
int sta_ofs,
151151
u8 bit,
152152
const struct clk_ops *ops,
153-
unsigned long flags)
153+
unsigned long flags,
154+
struct device *dev)
154155
{
155156
struct mtk_clk_gate *cg;
156157
struct clk *clk;
@@ -174,7 +175,7 @@ struct clk *mtk_clk_register_gate(
174175

175176
cg->hw.init = &init;
176177

177-
clk = clk_register(NULL, &cg->hw);
178+
clk = clk_register(dev, &cg->hw);
178179
if (IS_ERR(clk))
179180
kfree(cg);
180181

‎drivers/clk/mediatek/clk-gate.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ struct clk *mtk_clk_register_gate(
4040
int sta_ofs,
4141
u8 bit,
4242
const struct clk_ops *ops,
43-
unsigned long flags);
43+
unsigned long flags,
44+
struct device *dev);
4445

4546
#define GATE_MTK_FLAGS(_id, _name, _parent, _regs, _shift, \
4647
_ops, _flags) { \

‎drivers/clk/mediatek/clk-mtk.c‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/delay.h>
1313
#include <linux/clkdev.h>
1414
#include <linux/mfd/syscon.h>
15+
#include <linux/device.h>
1516

1617
#include "clk-mtk.h"
1718
#include "clk-gate.h"
@@ -93,9 +94,10 @@ void mtk_clk_register_factors(const struct mtk_fixed_factor *clks,
9394
}
9495
}
9596

96-
int mtk_clk_register_gates(struct device_node *node,
97+
int mtk_clk_register_gates_with_dev(struct device_node *node,
9798
const struct mtk_gate *clks,
98-
int num, struct clk_onecell_data *clk_data)
99+
int num, struct clk_onecell_data *clk_data,
100+
struct device *dev)
99101
{
100102
int i;
101103
struct clk *clk;
@@ -122,7 +124,7 @@ int mtk_clk_register_gates(struct device_node *node,
122124
gate->regs->set_ofs,
123125
gate->regs->clr_ofs,
124126
gate->regs->sta_ofs,
125-
gate->shift, gate->ops, gate->flags);
127+
gate->shift, gate->ops, gate->flags, dev);
126128

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

141+
int mtk_clk_register_gates(struct device_node *node,
142+
const struct mtk_gate *clks,
143+
int num, struct clk_onecell_data *clk_data)
144+
{
145+
return mtk_clk_register_gates_with_dev(node,
146+
clks, num, clk_data, NULL);
147+
}
148+
139149
struct clk *mtk_clk_register_composite(const struct mtk_composite *mc,
140150
void __iomem *base, spinlock_t *lock)
141151
{

‎drivers/clk/mediatek/clk-mtk.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ int mtk_clk_register_gates(struct device_node *node,
169169
const struct mtk_gate *clks, int num,
170170
struct clk_onecell_data *clk_data);
171171

172+
int mtk_clk_register_gates_with_dev(struct device_node *node,
173+
const struct mtk_gate *clks,
174+
int num, struct clk_onecell_data *clk_data,
175+
struct device *dev);
176+
172177
struct mtk_clk_divider {
173178
int id;
174179
const char *name;

0 commit comments

Comments
 (0)