Skip to content

Commit

Permalink
picoxcell: add a binding for the fixed clock type
Browse files Browse the repository at this point in the history
Populate all fixed clocks in the system from the device tree.  This is a
simple clock that cannot be disabled and runs at a fixed rate.

Signed-off-by: Jamie Iles <jamie@jamieiles.com>
  • Loading branch information
jamieiles committed Aug 25, 2011
1 parent 99b93be commit 08b2457
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Documentation/devicetree/bindings/arm/picoxcell.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,15 @@ VIC required properties:
bank of the VIC that generates IRQ's 0->31 and the second tuple handles
IRQ's 32->63.
- #interrupt-cells : Must be 1.

Fixed Clocks
------------

Fixed clock required properties:
- compatible = "fixed-clock".
- clock-outputs : Comma separated list of names of clock outputs.
- clock-frequency : The rate of the clock output in Hz.

Fixed clock optional properties:
- ref-clock : The parent of the clock. Must be in the form of <&phandle>,
"output name".
47 changes: 47 additions & 0 deletions arch/arm/mach-picoxcell/clk.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,49 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
}
EXPORT_SYMBOL_GPL(clk_set_parent);

struct fixed_clk {
struct clk clk;
unsigned long rate;
};

static inline struct fixed_clk *to_fixed_clk(struct clk *clk)
{
return container_of(clk, struct fixed_clk, clk);
}

static unsigned long fixed_clk_get_rate(struct clk *clk)
{
struct fixed_clk *fixed = to_fixed_clk(clk);

return fixed->rate;
}

static const struct clk_ops fixed_clk_ops = {
.get_rate = fixed_clk_get_rate,
};

static void __init picoxcell_add_fixed_clk(struct device_node *np)
{
struct fixed_clk *clk;
u32 rate;

if (of_property_read_u32(np, "clock-frequency", &rate)) {
pr_err("no clock-frequency for %s\n", np->full_name);
return;
}

clk = kzalloc(sizeof(*clk), GFP_KERNEL);
if (!clk)
panic("unable to allocate clk for %s\n", np->full_name);

clk->clk.ops = &fixed_clk_ops;
clk->clk.name = np->name;
clk->clk.of_node = np;
clk->rate = rate;

picoxcell_clk_add(&clk->clk);
}

static struct clk *picoxcell_find_clk(struct device_node *np)
{
struct clk *clk;
Expand Down Expand Up @@ -202,6 +245,10 @@ static void picoxcell_build_clk_tree(void)
}

static const struct of_device_id picoxcell_clk_match[] = {
{
.compatible = "fixed-clock",
.data = picoxcell_add_fixed_clk,
},
{ /* Sentinel */ }
};

Expand Down

0 comments on commit 08b2457

Please sign in to comment.