diff options
Diffstat (limited to 'drivers/clk/clk-gate.c')
-rw-r--r-- | drivers/clk/clk-gate.c | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/drivers/clk/clk-gate.c b/drivers/clk/clk-gate.c index b2b160555e..d31920fd0b 100644 --- a/drivers/clk/clk-gate.c +++ b/drivers/clk/clk-gate.c @@ -1,18 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * clk-gate.c - generic barebox clock support. Based on Linux clk support * * Copyright (c) 2012 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #include <common.h> #include <io.h> @@ -20,10 +10,10 @@ #include <linux/clk.h> #include <linux/err.h> -static void clk_gate_endisable(struct clk *clk, int enable) +static void clk_gate_endisable(struct clk_hw *hw, int enable) { - struct clk_gate *gate = container_of(clk, struct clk_gate, clk); - int set = gate->flags & CLK_GATE_INVERTED ? 1 : 0; + struct clk_gate *gate = container_of(hw, struct clk_gate, hw); + int set = gate->flags & CLK_GATE_SET_TO_DISABLE ? 1 : 0; u32 val; set ^= enable; @@ -44,29 +34,29 @@ static void clk_gate_endisable(struct clk *clk, int enable) writel(val, gate->reg); } -static int clk_gate_enable(struct clk *clk) +static int clk_gate_enable(struct clk_hw *hw) { - clk_gate_endisable(clk, 1); + clk_gate_endisable(hw, 1); return 0; } -static void clk_gate_disable(struct clk *clk) +static void clk_gate_disable(struct clk_hw *hw) { - clk_gate_endisable(clk, 0); + clk_gate_endisable(hw, 0); } -int clk_gate_is_enabled(struct clk *clk) +int clk_gate_is_enabled(struct clk_hw *hw) { - struct clk_gate *g = container_of(clk, struct clk_gate, clk); + struct clk_gate *g = container_of(hw, struct clk_gate, hw); u32 val; val = readl(g->reg); if (val & (1 << g->shift)) - return g->flags & CLK_GATE_INVERTED ? 0 : 1; + return g->flags & CLK_GATE_SET_TO_DISABLE ? 0 : 1; else - return g->flags & CLK_GATE_INVERTED ? 1 : 0; + return g->flags & CLK_GATE_SET_TO_DISABLE ? 1 : 0; } struct clk_ops clk_gate_ops = { @@ -85,19 +75,20 @@ struct clk *clk_gate_alloc(const char *name, const char *parent, g->parent = parent; g->reg = reg; g->shift = shift; - g->clk.ops = &clk_gate_ops; - g->clk.name = name; - g->clk.flags = flags; - g->clk.parent_names = &g->parent; - g->clk.num_parents = 1; + g->hw.clk.ops = &clk_gate_ops; + g->hw.clk.name = name; + g->hw.clk.flags = flags; + g->hw.clk.parent_names = &g->parent; + g->hw.clk.num_parents = 1; g->flags = clk_gate_flags; - return &g->clk; + return &g->hw.clk; } void clk_gate_free(struct clk *clk_gate) { - struct clk_gate *g = to_clk_gate(clk_gate); + struct clk_hw *hw = clk_to_clk_hw(clk_gate); + struct clk_gate *g = to_clk_gate(hw); free(g); } @@ -110,9 +101,10 @@ struct clk *clk_gate(const char *name, const char *parent, void __iomem *reg, g = clk_gate_alloc(name , parent, reg, shift, flags, clk_gate_flags); - ret = clk_register(g); + ret = bclk_register(g); if (ret) { - free(to_clk_gate(g)); + struct clk_hw *hw = clk_to_clk_hw(g); + free(to_clk_gate(hw)); return ERR_PTR(ret); } @@ -122,5 +114,13 @@ struct clk *clk_gate(const char *name, const char *parent, void __iomem *reg, struct clk *clk_gate_inverted(const char *name, const char *parent, void __iomem *reg, u8 shift, unsigned flags) { - return clk_gate(name, parent, reg, shift, flags, CLK_GATE_INVERTED); + return clk_gate(name, parent, reg, shift, flags, CLK_GATE_SET_TO_DISABLE); +} + +struct clk *clk_register_gate(struct device *dev, const char *name, + const char *parent_name, unsigned long flags, + void __iomem *reg, u8 bit_idx, + u8 clk_gate_flags, spinlock_t *lock) +{ + return clk_gate(name, parent_name, reg, bit_idx, flags, clk_gate_flags); } |