Loading drivers/clk/clk.c +12 −0 Original line number Diff line number Diff line Loading @@ -2604,6 +2604,18 @@ bool clk_is_match(const struct clk *p, const struct clk *q) } EXPORT_SYMBOL_GPL(clk_is_match); int clk_set_flags(struct clk *clk, unsigned long flags) { if (!clk) return 0; if (!clk->core->ops->set_flags) return -EINVAL; return clk->core->ops->set_flags(clk->core->hw, flags); } EXPORT_SYMBOL_GPL(clk_set_flags); /*** debugfs support ***/ #ifdef CONFIG_DEBUG_FS Loading drivers/clk/qcom/clk-branch.c +49 −1 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2013, The Linux Foundation. All rights reserved. * Copyright (c) 2013, 2017, The Linux Foundation. All rights reserved. */ #include <linux/kernel.h> Loading Loading @@ -117,15 +117,62 @@ static int clk_branch_enable(struct clk_hw *hw) return clk_branch_toggle(hw, true, clk_branch_check_halt); } static int clk_cbcr_set_flags(struct regmap *regmap, unsigned int reg, unsigned long flags) { u32 cbcr_val; regmap_read(regmap, reg, &cbcr_val); switch (flags) { case CLKFLAG_PERIPH_OFF_SET: cbcr_val |= BIT(12); break; case CLKFLAG_PERIPH_OFF_CLEAR: cbcr_val &= ~BIT(12); break; case CLKFLAG_RETAIN_PERIPH: cbcr_val |= BIT(13); break; case CLKFLAG_NORETAIN_PERIPH: cbcr_val &= ~BIT(13); break; case CLKFLAG_RETAIN_MEM: cbcr_val |= BIT(14); break; case CLKFLAG_NORETAIN_MEM: cbcr_val &= ~BIT(14); break; default: return -EINVAL; } regmap_write(regmap, reg, cbcr_val); /* Make sure power is enabled/disabled before returning. */ mb(); udelay(1); return 0; } static void clk_branch_disable(struct clk_hw *hw) { clk_branch_toggle(hw, false, clk_branch_check_halt); } static int clk_branch_set_flags(struct clk_hw *hw, unsigned int flags) { struct clk_branch *br = to_clk_branch(hw); return clk_cbcr_set_flags(br->clkr.regmap, br->halt_reg, flags); } const struct clk_ops clk_branch_ops = { .enable = clk_branch_enable, .disable = clk_branch_disable, .is_enabled = clk_is_enabled_regmap, .set_flags = clk_branch_set_flags, }; EXPORT_SYMBOL_GPL(clk_branch_ops); Loading @@ -143,6 +190,7 @@ const struct clk_ops clk_branch2_ops = { .enable = clk_branch2_enable, .disable = clk_branch2_disable, .is_enabled = clk_is_enabled_regmap, .set_flags = clk_branch_set_flags, }; EXPORT_SYMBOL_GPL(clk_branch2_ops); Loading drivers/clk/qcom/clk-branch.h +10 −1 Original line number Diff line number Diff line /* SPDX-License-Identifier: GPL-2.0 */ /* Copyright (c) 2013, The Linux Foundation. All rights reserved. */ /* Copyright (c) 2013, 2017, The Linux Foundation. All rights reserved. */ #ifndef __QCOM_CLK_BRANCH_H__ #define __QCOM_CLK_BRANCH_H__ Loading Loading @@ -44,4 +44,13 @@ extern const struct clk_ops clk_branch_simple_ops; #define to_clk_branch(_hw) \ container_of(to_clk_regmap(_hw), struct clk_branch, clkr) enum branch_mem_flags { CLKFLAG_RETAIN_PERIPH, CLKFLAG_NORETAIN_PERIPH, CLKFLAG_RETAIN_MEM, CLKFLAG_NORETAIN_MEM, CLKFLAG_PERIPH_OFF_SET, CLKFLAG_PERIPH_OFF_CLEAR, }; #endif drivers/clk/qcom/clk-dummy.c +6 −0 Original line number Diff line number Diff line Loading @@ -43,10 +43,16 @@ static unsigned long dummy_clk_recalc_rate(struct clk_hw *hw, return dummy->rrate; } static int dummy_clk_set_flags(struct clk_hw *hw, unsigned int flags) { return 0; } const struct clk_ops clk_dummy_ops = { .set_rate = dummy_clk_set_rate, .round_rate = dummy_clk_round_rate, .recalc_rate = dummy_clk_recalc_rate, .set_flags = dummy_clk_set_flags, }; EXPORT_SYMBOL(clk_dummy_ops); Loading include/linux/clk-provider.h +3 −0 Original line number Diff line number Diff line Loading @@ -202,6 +202,8 @@ struct clk_duty { * directory is provided as an argument. Called with * prepare_lock held. Returns 0 on success, -EERROR otherwise. * * @set_flags: Set custom flags which deal with hardware specifics. Returns 0 * on success, -EERROR otherwise. * * The clk_enable/clk_disable and clk_prepare/clk_unprepare pairs allow * implementations to split any work between atomic (enable) and sleepable Loading Loading @@ -246,6 +248,7 @@ struct clk_ops { struct clk_duty *duty); void (*init)(struct clk_hw *hw); void (*debug_init)(struct clk_hw *hw, struct dentry *dentry); int (*set_flags)(struct clk_hw *hw, unsigned int flags); }; /** Loading Loading
drivers/clk/clk.c +12 −0 Original line number Diff line number Diff line Loading @@ -2604,6 +2604,18 @@ bool clk_is_match(const struct clk *p, const struct clk *q) } EXPORT_SYMBOL_GPL(clk_is_match); int clk_set_flags(struct clk *clk, unsigned long flags) { if (!clk) return 0; if (!clk->core->ops->set_flags) return -EINVAL; return clk->core->ops->set_flags(clk->core->hw, flags); } EXPORT_SYMBOL_GPL(clk_set_flags); /*** debugfs support ***/ #ifdef CONFIG_DEBUG_FS Loading
drivers/clk/qcom/clk-branch.c +49 −1 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2013, The Linux Foundation. All rights reserved. * Copyright (c) 2013, 2017, The Linux Foundation. All rights reserved. */ #include <linux/kernel.h> Loading Loading @@ -117,15 +117,62 @@ static int clk_branch_enable(struct clk_hw *hw) return clk_branch_toggle(hw, true, clk_branch_check_halt); } static int clk_cbcr_set_flags(struct regmap *regmap, unsigned int reg, unsigned long flags) { u32 cbcr_val; regmap_read(regmap, reg, &cbcr_val); switch (flags) { case CLKFLAG_PERIPH_OFF_SET: cbcr_val |= BIT(12); break; case CLKFLAG_PERIPH_OFF_CLEAR: cbcr_val &= ~BIT(12); break; case CLKFLAG_RETAIN_PERIPH: cbcr_val |= BIT(13); break; case CLKFLAG_NORETAIN_PERIPH: cbcr_val &= ~BIT(13); break; case CLKFLAG_RETAIN_MEM: cbcr_val |= BIT(14); break; case CLKFLAG_NORETAIN_MEM: cbcr_val &= ~BIT(14); break; default: return -EINVAL; } regmap_write(regmap, reg, cbcr_val); /* Make sure power is enabled/disabled before returning. */ mb(); udelay(1); return 0; } static void clk_branch_disable(struct clk_hw *hw) { clk_branch_toggle(hw, false, clk_branch_check_halt); } static int clk_branch_set_flags(struct clk_hw *hw, unsigned int flags) { struct clk_branch *br = to_clk_branch(hw); return clk_cbcr_set_flags(br->clkr.regmap, br->halt_reg, flags); } const struct clk_ops clk_branch_ops = { .enable = clk_branch_enable, .disable = clk_branch_disable, .is_enabled = clk_is_enabled_regmap, .set_flags = clk_branch_set_flags, }; EXPORT_SYMBOL_GPL(clk_branch_ops); Loading @@ -143,6 +190,7 @@ const struct clk_ops clk_branch2_ops = { .enable = clk_branch2_enable, .disable = clk_branch2_disable, .is_enabled = clk_is_enabled_regmap, .set_flags = clk_branch_set_flags, }; EXPORT_SYMBOL_GPL(clk_branch2_ops); Loading
drivers/clk/qcom/clk-branch.h +10 −1 Original line number Diff line number Diff line /* SPDX-License-Identifier: GPL-2.0 */ /* Copyright (c) 2013, The Linux Foundation. All rights reserved. */ /* Copyright (c) 2013, 2017, The Linux Foundation. All rights reserved. */ #ifndef __QCOM_CLK_BRANCH_H__ #define __QCOM_CLK_BRANCH_H__ Loading Loading @@ -44,4 +44,13 @@ extern const struct clk_ops clk_branch_simple_ops; #define to_clk_branch(_hw) \ container_of(to_clk_regmap(_hw), struct clk_branch, clkr) enum branch_mem_flags { CLKFLAG_RETAIN_PERIPH, CLKFLAG_NORETAIN_PERIPH, CLKFLAG_RETAIN_MEM, CLKFLAG_NORETAIN_MEM, CLKFLAG_PERIPH_OFF_SET, CLKFLAG_PERIPH_OFF_CLEAR, }; #endif
drivers/clk/qcom/clk-dummy.c +6 −0 Original line number Diff line number Diff line Loading @@ -43,10 +43,16 @@ static unsigned long dummy_clk_recalc_rate(struct clk_hw *hw, return dummy->rrate; } static int dummy_clk_set_flags(struct clk_hw *hw, unsigned int flags) { return 0; } const struct clk_ops clk_dummy_ops = { .set_rate = dummy_clk_set_rate, .round_rate = dummy_clk_round_rate, .recalc_rate = dummy_clk_recalc_rate, .set_flags = dummy_clk_set_flags, }; EXPORT_SYMBOL(clk_dummy_ops); Loading
include/linux/clk-provider.h +3 −0 Original line number Diff line number Diff line Loading @@ -202,6 +202,8 @@ struct clk_duty { * directory is provided as an argument. Called with * prepare_lock held. Returns 0 on success, -EERROR otherwise. * * @set_flags: Set custom flags which deal with hardware specifics. Returns 0 * on success, -EERROR otherwise. * * The clk_enable/clk_disable and clk_prepare/clk_unprepare pairs allow * implementations to split any work between atomic (enable) and sleepable Loading Loading @@ -246,6 +248,7 @@ struct clk_ops { struct clk_duty *duty); void (*init)(struct clk_hw *hw); void (*debug_init)(struct clk_hw *hw, struct dentry *dentry); int (*set_flags)(struct clk_hw *hw, unsigned int flags); }; /** Loading