clk: Add option to restrict clk-gate2 to one bit toggle
PATCH 2/2 clk: Add option to restrict clk-gate2 to one bit toggle
Currently clk-gate2 only works on clocks with a 2-bit enable/disable state. This patch adds an option to work with clocks with a 1-bit enable.
Signed-off-by Sean Anderson <[email protected]>
--- drivers/clk/clk-gate2.c | 13 ++++++++++--- include/linux/clk-provider.h | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-)
drivers/clk/clk-gate2.c +10 -3
@@ -29,8 +29,12 @@ static int clk_gate2_enable(struct clk *clk)u32 reg; reg =readl (gate->reg); - reg &= ~(3 << gate->bit_idx); - reg |= gate->cgr_val << gate->bit_idx; +if (gate->flags &CLK_GATE2_SINGLE_BIT ) { + reg |=BIT (gate->bit_idx); + }else { + reg &= ~(3 << gate->bit_idx); + reg |= gate->cgr_val << gate->bit_idx; + }writel (reg, gate->reg);return 0 ;
@@ -42,7 +46,10 @@ static int clk_gate2_disable(struct clk *clk)u32 reg; reg =readl (gate->reg); - reg &= ~(3 << gate->bit_idx); +if (gate->flags &CLK_GATE2_SINGLE_BIT ) + reg &= ~BIT (gate->bit_idx); +else + reg &= ~(3 << gate->bit_idx);writel (reg, gate->reg);return 0 ;
include/linux/clk-provider.h +2 -0
@@ -155,6 +155,8 @@ struct clk_composite {#define to_clk_composite (_clk) container_of(_clk, struct clk_composite, clk) +#define CLK_GATE2_SINGLE_BIT BIT(0) +struct clk_gate2 {struct clk clk;void __iomem *reg;
Signature · 1 line
2.24.1