Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 146851
b: refs/heads/master
c: a1153e2
h: refs/heads/master
i:
  146849: 207fb4f
  146847: d51be14
v: v3
  • Loading branch information
Magnus Damm authored and Paul Mundt committed Jun 1, 2009
1 parent 8f8cebb commit a688151
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e89d53e60593ee7066e1d36ab5c1ccf2648f5f53
refs/heads/master: a1153e27eec25e9963f5843ba8932952bd9847ac
15 changes: 15 additions & 0 deletions trunk/arch/sh/include/asm/clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <linux/list.h>
#include <linux/seq_file.h>
#include <linux/cpufreq.h>
#include <linux/clk.h>
#include <linux/err.h>

Expand Down Expand Up @@ -41,6 +42,7 @@ struct clk {
unsigned long arch_flags;
void *priv;
struct dentry *dentry;
struct cpufreq_frequency_table *freq_table;
};

struct clk_lookup {
Expand Down Expand Up @@ -130,4 +132,17 @@ long clk_rate_table_round(struct clk *clk,

int sh_clk_mstp32_register(struct clk *clks, int nr);

#define SH_CLK_DIV4(_name, _parent, _reg, _shift, _div_bitmap, _flags) \
{ \
.name = _name, \
.parent = _parent, \
.enable_reg = (void __iomem *)_reg, \
.enable_bit = _shift, \
.arch_flags = _div_bitmap, \
.flags = _flags, \
}

int sh_clk_div4_register(struct clk *clks, int nr,
struct clk_div_mult_table *table);

#endif /* __ASM_SH_CLOCK_H */
55 changes: 55 additions & 0 deletions trunk/arch/sh/kernel/cpu/clock-cpg.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <linux/clk.h>
#include <linux/compiler.h>
#include <linux/bootmem.h>
#include <linux/io.h>
#include <asm/clock.h>

Expand Down Expand Up @@ -37,6 +38,60 @@ int __init sh_clk_mstp32_register(struct clk *clks, int nr)
return ret;
}

static unsigned long sh_clk_div4_recalc(struct clk *clk)
{
struct clk_div_mult_table *table = clk->priv;
unsigned int idx;

clk_rate_table_build(clk, clk->freq_table, table->nr_divisors,
table, &clk->arch_flags);

idx = (__raw_readl(clk->enable_reg) >> clk->enable_bit) & 0x000f;

return clk->freq_table[idx].frequency;
}

static long sh_clk_div4_round_rate(struct clk *clk, unsigned long rate)
{
return clk_rate_table_round(clk, clk->freq_table, rate);
}

static struct clk_ops sh_clk_div4_clk_ops = {
.recalc = sh_clk_div4_recalc,
.round_rate = sh_clk_div4_round_rate,
};

int __init sh_clk_div4_register(struct clk *clks, int nr,
struct clk_div_mult_table *table)
{
struct clk *clkp;
void *freq_table;
int nr_divs = table->nr_divisors;
int freq_table_size = sizeof(struct cpufreq_frequency_table);
int ret = 0;
int k;

k = nr_divs + 1;
freq_table = alloc_bootmem(freq_table_size * nr * (nr_divs + 1));
if (!freq_table)
return -ENOMEM;

for (k = 0; !ret && (k < nr); k++) {
clkp = clks + k;

clkp->ops = &sh_clk_div4_clk_ops;
clkp->id = -1;
clkp->priv = table;

clkp->freq_table = freq_table + (k * freq_table_size);
clkp->freq_table[nr_divs].frequency = CPUFREQ_TABLE_END;

ret = clk_register(clkp);
}

return ret;
}

#ifdef CONFIG_SH_CLK_CPG_LEGACY
static struct clk master_clk = {
.name = "master_clk",
Expand Down

0 comments on commit a688151

Please sign in to comment.