Skip to content

Commit e16b9b7

Browse files
Andre-ARMwens
authored andcommitted
clk: sunxi-ng: Add support for update bit
Some clocks in the Allwinner A523 SoC contain an "update bit" (bit 27), which must be set to apply any register changes, namely the mux selector, the divider and the gate bit. Add a new CCU feature bit to mark those clocks, and set bit 27 whenever we are applying any changes. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com> Link: https://patch.msgid.link/20250307002628.10684-4-andre.przywara@arm.com Signed-off-by: Chen-Yu Tsai <wens@csie.org>
1 parent cdbb9d0 commit e16b9b7

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

drivers/clk/sunxi-ng/ccu_common.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@
2020
#define CCU_FEATURE_KEY_FIELD BIT(8)
2121
#define CCU_FEATURE_CLOSEST_RATE BIT(9)
2222
#define CCU_FEATURE_DUAL_DIV BIT(10)
23+
#define CCU_FEATURE_UPDATE_BIT BIT(11)
2324

2425
/* MMC timing mode switch bit */
2526
#define CCU_MMC_NEW_TIMING_MODE BIT(30)
2627

28+
/* Some clocks need this bit to actually apply register changes */
29+
#define CCU_SUNXI_UPDATE_BIT BIT(27)
30+
2731
struct device_node;
2832

2933
struct ccu_common {

drivers/clk/sunxi-ng/ccu_div.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ static int ccu_div_set_rate(struct clk_hw *hw, unsigned long rate,
106106

107107
reg = readl(cd->common.base + cd->common.reg);
108108
reg &= ~GENMASK(cd->div.width + cd->div.shift - 1, cd->div.shift);
109+
if (cd->common.features & CCU_FEATURE_UPDATE_BIT)
110+
reg |= CCU_SUNXI_UPDATE_BIT;
109111

110112
writel(reg | (val << cd->div.shift),
111113
cd->common.base + cd->common.reg);

drivers/clk/sunxi-ng/ccu_gate.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ void ccu_gate_helper_disable(struct ccu_common *common, u32 gate)
2020
spin_lock_irqsave(common->lock, flags);
2121

2222
reg = readl(common->base + common->reg);
23+
if (common->features & CCU_FEATURE_UPDATE_BIT)
24+
reg |= CCU_SUNXI_UPDATE_BIT;
2325
writel(reg & ~gate, common->base + common->reg);
2426

2527
spin_unlock_irqrestore(common->lock, flags);
@@ -44,6 +46,8 @@ int ccu_gate_helper_enable(struct ccu_common *common, u32 gate)
4446
spin_lock_irqsave(common->lock, flags);
4547

4648
reg = readl(common->base + common->reg);
49+
if (common->features & CCU_FEATURE_UPDATE_BIT)
50+
reg |= CCU_SUNXI_UPDATE_BIT;
4751
writel(reg | gate, common->base + common->reg);
4852

4953
spin_unlock_irqrestore(common->lock, flags);

drivers/clk/sunxi-ng/ccu_mux.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ int ccu_mux_helper_set_parent(struct ccu_common *common,
197197
/* The key field always reads as zero. */
198198
if (common->features & CCU_FEATURE_KEY_FIELD)
199199
reg |= CCU_MUX_KEY_VALUE;
200+
if (common->features & CCU_FEATURE_UPDATE_BIT)
201+
reg |= CCU_SUNXI_UPDATE_BIT;
200202

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

0 commit comments

Comments
 (0)