Skip to content

Commit

Permalink
clk: sunxi-ng: Allow muxes to have keys
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel Holland <samuel@sholland.org>
  • Loading branch information
smaeul committed Jun 1, 2021
1 parent 4382ecf commit 5859dcb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/clk/sunxi-ng/ccu_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#define CCU_FEATURE_LOCK_REG BIT(5)
#define CCU_FEATURE_MMC_TIMING_SWITCH BIT(6)
#define CCU_FEATURE_SIGMA_DELTA_MOD BIT(7)
#define CCU_FEATURE_KEY_FIELD BIT(8)

/* MMC timing mode switch bit */
#define CCU_MMC_NEW_TIMING_MODE BIT(30)
Expand Down
7 changes: 7 additions & 0 deletions drivers/clk/sunxi-ng/ccu_mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "ccu_gate.h"
#include "ccu_mux.h"

#define CCU_MUX_KEY_VALUE 0x16aa0000

static u16 ccu_mux_get_prediv(struct ccu_common *common,
struct ccu_mux_internal *cm,
int parent_index)
Expand Down Expand Up @@ -188,6 +190,11 @@ int ccu_mux_helper_set_parent(struct ccu_common *common,
spin_lock_irqsave(common->lock, flags);

reg = readl(common->base + common->reg);

/* The key field always reads as zero. */
if (common->features & CCU_FEATURE_KEY_FIELD)
reg |= CCU_MUX_KEY_VALUE;

reg &= ~GENMASK(cm->width + cm->shift - 1, cm->shift);
writel(reg | (index << cm->shift), common->base + common->reg);

Expand Down
14 changes: 14 additions & 0 deletions drivers/clk/sunxi-ng/ccu_mux.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,20 @@ struct ccu_mux {
SUNXI_CCU_MUX_TABLE_WITH_GATE(_struct, _name, _parents, NULL, \
_reg, _shift, _width, 0, _flags)

#define SUNXI_CCU_MUX_HW_WITH_KEY(_struct, _name, _parents, _reg, \
_shift, _width, _key, _flags) \
struct ccu_mux _struct = { \
.mux = _SUNXI_CCU_MUX(_shift, _width), \
.common = { \
.reg = _reg, \
.features = CCU_FEATURE_KEY_FIELD, \
.hw.init = CLK_HW_INIT_PARENTS_HW(_name, \
_parents, \
&ccu_mux_ops, \
_flags), \
} \
}

static inline struct ccu_mux *hw_to_ccu_mux(struct clk_hw *hw)
{
struct ccu_common *common = hw_to_ccu_common(hw);
Expand Down

0 comments on commit 5859dcb

Please sign in to comment.