Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 308221
b: refs/heads/master
c: 7560e3f
h: refs/heads/master
i:
  308219: f762b46
v: v3
  • Loading branch information
Sascha Hauer committed Apr 25, 2012
1 parent f6dd18a commit 277f194
Show file tree
Hide file tree
Showing 17 changed files with 362 additions and 721 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e12ff34402bd3a6cbeab0423012066874bb10f4b
refs/heads/master: 7560e3f3581ed415828d3f431b8622fa38c2d133
4 changes: 0 additions & 4 deletions trunk/Documentation/driver-model/devres.txt
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,3 @@ REGULATOR
devm_regulator_get()
devm_regulator_put()
devm_regulator_bulk_get()

CLOCK
devm_clk_get()
devm_clk_put()
10 changes: 0 additions & 10 deletions trunk/MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -1882,16 +1882,6 @@ F: Documentation/filesystems/coda.txt
F: fs/coda/
F: include/linux/coda*.h

COMMON CLK FRAMEWORK
M: Mike Turquette <mturquette@ti.com>
M: Mike Turquette <mturquette@linaro.org>
L: linux-arm-kernel@lists.infradead.org (same as CLK API & CLKDEV)
T: git git://git.linaro.org/people/mturquette/linux.git
S: Maintained
F: drivers/clk/clk.c
F: drivers/clk/clk-*
F: include/linux/clk-pr*

COMMON INTERNET FILE SYSTEM (CIFS)
M: Steve French <sfrench@samba.org>
L: linux-cifs@vger.kernel.org
Expand Down
12 changes: 11 additions & 1 deletion trunk/drivers/clk/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ config HAVE_MACH_CLKDEV
config COMMON_CLK
bool
select HAVE_CLK_PREPARE
select CLKDEV_LOOKUP
---help---
The common clock framework is a single definition of struct
clk, useful across many platforms, as well as an
Expand All @@ -23,6 +22,17 @@ config COMMON_CLK
menu "Common Clock Framework"
depends on COMMON_CLK

config COMMON_CLK_DISABLE_UNUSED
bool "Disabled unused clocks at boot"
depends on COMMON_CLK
---help---
Traverses the entire clock tree and disables any clocks that are
enabled in hardware but have not been enabled by any device drivers.
This saves power and keeps the software model of the clock in line
with reality.

If in doubt, say "N".

config COMMON_CLK_DEBUG
bool "DebugFS representation of clock tree"
depends on COMMON_CLK
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/clk/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

obj-$(CONFIG_CLKDEV_LOOKUP) += clkdev.o
obj-$(CONFIG_COMMON_CLK) += clk.o clk-fixed-rate.o clk-gate.o \
clk-mux.o clk-divider.o clk-fixed-factor.o
clk-mux.o clk-divider.o
68 changes: 34 additions & 34 deletions trunk/drivers/clk/clk-divider.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ static unsigned long clk_divider_recalc_rate(struct clk_hw *hw,

return parent_rate / div;
}
EXPORT_SYMBOL_GPL(clk_divider_recalc_rate);

/*
* The reverse of DIV_ROUND_UP: The maximum number which
Expand All @@ -67,8 +68,8 @@ static int clk_divider_bestdiv(struct clk_hw *hw, unsigned long rate,
if (divider->flags & CLK_DIVIDER_ONE_BASED)
maxdiv--;

if (!(__clk_get_flags(hw->clk) & CLK_SET_RATE_PARENT)) {
parent_rate = *best_parent_rate;
if (!best_parent_rate) {
parent_rate = __clk_get_rate(__clk_get_parent(hw->clk));
bestdiv = DIV_ROUND_UP(parent_rate, rate);
bestdiv = bestdiv == 0 ? 1 : bestdiv;
bestdiv = bestdiv > maxdiv ? maxdiv : bestdiv;
Expand Down Expand Up @@ -108,18 +109,24 @@ static long clk_divider_round_rate(struct clk_hw *hw, unsigned long rate,
int div;
div = clk_divider_bestdiv(hw, rate, prate);

return *prate / div;
if (prate)
return *prate / div;
else {
unsigned long r;
r = __clk_get_rate(__clk_get_parent(hw->clk));
return r / div;
}
}
EXPORT_SYMBOL_GPL(clk_divider_round_rate);

static int clk_divider_set_rate(struct clk_hw *hw, unsigned long rate,
unsigned long parent_rate)
static int clk_divider_set_rate(struct clk_hw *hw, unsigned long rate)
{
struct clk_divider *divider = to_clk_divider(hw);
unsigned int div;
unsigned long flags = 0;
u32 val;

div = parent_rate / rate;
div = __clk_get_rate(__clk_get_parent(hw->clk)) / rate;

if (!(divider->flags & CLK_DIVIDER_ONE_BASED))
div--;
Expand All @@ -140,61 +147,54 @@ static int clk_divider_set_rate(struct clk_hw *hw, unsigned long rate,

return 0;
}
EXPORT_SYMBOL_GPL(clk_divider_set_rate);

const struct clk_ops clk_divider_ops = {
struct clk_ops clk_divider_ops = {
.recalc_rate = clk_divider_recalc_rate,
.round_rate = clk_divider_round_rate,
.set_rate = clk_divider_set_rate,
};
EXPORT_SYMBOL_GPL(clk_divider_ops);

/**
* clk_register_divider - register a divider clock with the clock framework
* @dev: device registering this clock
* @name: name of this clock
* @parent_name: name of clock's parent
* @flags: framework-specific flags
* @reg: register address to adjust divider
* @shift: number of bits to shift the bitfield
* @width: width of the bitfield
* @clk_divider_flags: divider-specific flags for this clock
* @lock: shared register lock for this clock
*/
struct clk *clk_register_divider(struct device *dev, const char *name,
const char *parent_name, unsigned long flags,
void __iomem *reg, u8 shift, u8 width,
u8 clk_divider_flags, spinlock_t *lock)
{
struct clk_divider *div;
struct clk *clk;
struct clk_init_data init;

/* allocate the divider */
div = kzalloc(sizeof(struct clk_divider), GFP_KERNEL);

if (!div) {
pr_err("%s: could not allocate divider clk\n", __func__);
return ERR_PTR(-ENOMEM);
return NULL;
}

init.name = name;
init.ops = &clk_divider_ops;
init.flags = flags;
init.parent_names = (parent_name ? &parent_name: NULL);
init.num_parents = (parent_name ? 1 : 0);

/* struct clk_divider assignments */
div->reg = reg;
div->shift = shift;
div->width = width;
div->flags = clk_divider_flags;
div->lock = lock;
div->hw.init = &init;

/* register the clock */
clk = clk_register(dev, &div->hw);
if (parent_name) {
div->parent[0] = kstrdup(parent_name, GFP_KERNEL);
if (!div->parent[0])
goto out;
}

clk = clk_register(dev, name,
&clk_divider_ops, &div->hw,
div->parent,
(parent_name ? 1 : 0),
flags);
if (clk)
return clk;

if (IS_ERR(clk))
kfree(div);
out:
kfree(div->parent[0]);
kfree(div);

return clk;
return NULL;
}
95 changes: 0 additions & 95 deletions trunk/drivers/clk/clk-fixed-factor.c

This file was deleted.

49 changes: 25 additions & 24 deletions trunk/drivers/clk/clk-fixed-rate.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,50 +32,51 @@ static unsigned long clk_fixed_rate_recalc_rate(struct clk_hw *hw,
{
return to_clk_fixed_rate(hw)->fixed_rate;
}
EXPORT_SYMBOL_GPL(clk_fixed_rate_recalc_rate);

const struct clk_ops clk_fixed_rate_ops = {
struct clk_ops clk_fixed_rate_ops = {
.recalc_rate = clk_fixed_rate_recalc_rate,
};
EXPORT_SYMBOL_GPL(clk_fixed_rate_ops);

/**
* clk_register_fixed_rate - register fixed-rate clock with the clock framework
* @dev: device that is registering this clock
* @name: name of this clock
* @parent_name: name of clock's parent
* @flags: framework-specific flags
* @fixed_rate: non-adjustable clock rate
*/
struct clk *clk_register_fixed_rate(struct device *dev, const char *name,
const char *parent_name, unsigned long flags,
unsigned long fixed_rate)
{
struct clk_fixed_rate *fixed;
struct clk *clk;
struct clk_init_data init;
char **parent_names = NULL;
u8 len;

/* allocate fixed-rate clock */
fixed = kzalloc(sizeof(struct clk_fixed_rate), GFP_KERNEL);

if (!fixed) {
pr_err("%s: could not allocate fixed clk\n", __func__);
return ERR_PTR(-ENOMEM);
}

init.name = name;
init.ops = &clk_fixed_rate_ops;
init.flags = flags;
init.parent_names = (parent_name ? &parent_name: NULL);
init.num_parents = (parent_name ? 1 : 0);

/* struct clk_fixed_rate assignments */
fixed->fixed_rate = fixed_rate;
fixed->hw.init = &init;

/* register the clock */
clk = clk_register(dev, &fixed->hw);
if (parent_name) {
parent_names = kmalloc(sizeof(char *), GFP_KERNEL);

if (! parent_names)
goto out;

if (IS_ERR(clk))
kfree(fixed);
len = sizeof(char) * strlen(parent_name);

parent_names[0] = kmalloc(len, GFP_KERNEL);

if (!parent_names[0])
goto out;

strncpy(parent_names[0], parent_name, len);
}

return clk;
out:
return clk_register(dev, name,
&clk_fixed_rate_ops, &fixed->hw,
parent_names,
(parent_name ? 1 : 0),
flags);
}
Loading

0 comments on commit 277f194

Please sign in to comment.