clk_rate_table_build(clk, clk->freq_table, table->nr_divisors,
table, NULL);
- idx = sh_clk_read(clk) & 0x003f;
+ idx = sh_clk_read(clk) & clk->div_mask;
return clk->freq_table[idx].frequency;
}
return idx;
value = sh_clk_read(clk);
- value &= ~0x3f;
+ value &= ~clk->div_mask;
value |= idx;
sh_clk_write(value, clk);
return 0;
value = sh_clk_read(clk);
value |= 0x100; /* stop clock */
- value |= 0x3f; /* VDIV bits must be non-zero, overwrite divider */
+ value |= clk->div_mask; /* VDIV bits must be non-zero, overwrite divider */
sh_clk_write(value, clk);
}
clk_rate_table_build(clk, clk->freq_table, table->nr_divisors,
table, &clk->arch_flags);
- idx = (sh_clk_read(clk) >> clk->enable_bit) & 0x000f;
+ idx = (sh_clk_read(clk) >> clk->enable_bit) & clk->div_mask;
return clk->freq_table[idx].frequency;
}
return idx;
value = sh_clk_read(clk);
- value &= ~(0xf << clk->enable_bit);
+ value &= ~(clk->div_mask << clk->enable_bit);
value |= (idx << clk->enable_bit);
sh_clk_write(value, clk);
long (*round_rate)(struct clk *clk, unsigned long rate);
};
+#define SH_CLK_DIV_MSK(div) ((1 << (div)) - 1)
+#define SH_CLK_DIV4_MSK SH_CLK_DIV_MSK(4)
+#define SH_CLK_DIV6_MSK SH_CLK_DIV_MSK(6)
+
struct clk {
struct list_head node;
struct clk *parent;
unsigned int enable_bit;
void __iomem *mapped_reg;
+ unsigned int div_mask;
unsigned long arch_flags;
void *priv;
struct clk_mapping *mapping;
.enable_reg = (void __iomem *)_reg, \
.enable_bit = _shift, \
.arch_flags = _div_bitmap, \
+ .div_mask = SH_CLK_DIV4_MSK, \
.flags = _flags, \
}
{ \
.enable_reg = (void __iomem *)_reg, \
.flags = _flags, \
+ .div_mask = SH_CLK_DIV6_MSK, \
.parent_table = _parents, \
.parent_num = _num_parents, \
.src_shift = _src_shift, \
{ \
.parent = _parent, \
.enable_reg = (void __iomem *)_reg, \
+ .div_mask = SH_CLK_DIV6_MSK, \
.flags = _flags, \
}