Skip to content

Commit 6881e8b

Browse files
Magnus Dammpmundt
authored andcommitted
sh: shared mstp32 clock code
Add shared 32-bit module stop bit clock support. Processor specific code can use SH_CLK_MSTP32() to initialize module stop bit clocks, and then use sh_clk_mstp32() for registration. Signed-off-by: Magnus Damm <damm@igel.co.jp> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
1 parent 98fbe45 commit 6881e8b

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

‎arch/sh/include/asm/clock.h‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,17 @@ long clk_rate_table_round(struct clk *clk,
117117
struct cpufreq_frequency_table *freq_table,
118118
unsigned long rate);
119119

120+
#define SH_CLK_MSTP32(_name, _id, _parent, _enable_reg, \
121+
_enable_bit, _flags) \
122+
{ \
123+
.name = _name, \
124+
.id = _id, \
125+
.parent = _parent, \
126+
.enable_reg = (void __iomem *)_enable_reg, \
127+
.enable_bit = _enable_bit, \
128+
.flags = _flags, \
129+
}
130+
131+
int sh_clk_mstp32_register(struct clk *clks, int nr);
132+
120133
#endif /* __ASM_SH_CLOCK_H */

‎arch/sh/kernel/cpu/clock-cpg.c‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,42 @@
11
#include <linux/clk.h>
22
#include <linux/compiler.h>
3+
#include <linux/io.h>
34
#include <asm/clock.h>
45

6+
static int sh_clk_mstp32_enable(struct clk *clk)
7+
{
8+
__raw_writel(__raw_readl(clk->enable_reg) & ~(1 << clk->enable_bit),
9+
clk->enable_reg);
10+
return 0;
11+
}
12+
13+
static void sh_clk_mstp32_disable(struct clk *clk)
14+
{
15+
__raw_writel(__raw_readl(clk->enable_reg) | (1 << clk->enable_bit),
16+
clk->enable_reg);
17+
}
18+
19+
static struct clk_ops sh_clk_mstp32_clk_ops = {
20+
.enable = sh_clk_mstp32_enable,
21+
.disable = sh_clk_mstp32_disable,
22+
.recalc = followparent_recalc,
23+
};
24+
25+
int __init sh_clk_mstp32_register(struct clk *clks, int nr)
26+
{
27+
struct clk *clkp;
28+
int ret = 0;
29+
int k;
30+
31+
for (k = 0; !ret && (k < nr); k++) {
32+
clkp = clks + k;
33+
clkp->ops = &sh_clk_mstp32_clk_ops;
34+
ret |= clk_register(clkp);
35+
}
36+
37+
return ret;
38+
}
39+
540
#ifdef CONFIG_SH_CLK_CPG_LEGACY
641
static struct clk master_clk = {
742
.name = "master_clk",

0 commit comments

Comments
 (0)