clk: mediatek: Register clock gate with device
authorWeiyi Lu <weiyi.lu@mediatek.com>
Mon, 2 Sep 2019 09:00:57 +0000 (17:00 +0800)
committerStephen Boyd <sboyd@kernel.org>
Tue, 17 Sep 2019 17:22:49 +0000 (10:22 -0700)
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>
drivers/clk/mediatek/clk-gate.c
drivers/clk/mediatek/clk-gate.h
drivers/clk/mediatek/clk-mtk.c
drivers/clk/mediatek/clk-mtk.h

index 803bf0ae1fd65a5b3a1770c12d458a6a4e4dbe1f..a35cf0b221501197ca5ccd980183209494f1aaa3 100644 (file)
@@ -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;
@@ -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);
 
index e05c736974859d807e299b26017e4b21f4e74ded..3c3329ec54b7afc9ca7aaac38a4e8e18a5ac3f57 100644 (file)
@@ -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) {                         \
index d28790c7491920b0b77a468fe2b041b671173af3..cec1c8a27211352a215d00319c807133aea3465a 100644 (file)
@@ -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"
@@ -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;
@@ -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",
@@ -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)
 {
index 2e9e260847989ada914a4880f101e66c231cc506..c3d6756b0c7e758f503ec8c107d04ae91458b817 100644 (file)
@@ -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;