Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 316616
b: refs/heads/master
c: 91b87a4
h: refs/heads/master
v: v3
  • Loading branch information
Linus Walleij authored and Mike Turquette committed Jul 12, 2012
1 parent 2d4b55f commit f5ea796
Show file tree
Hide file tree
Showing 5 changed files with 114 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: d59fdcfc63a2d15b11dde10a85233b95cee0ad2e
refs/heads/master: 91b87a4795c42b97b8d18c3757eff352458ecef4
1 change: 1 addition & 0 deletions trunk/drivers/clk/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ obj-$(CONFIG_COMMON_CLK) += clk.o clk-fixed-rate.o clk-gate.o \
obj-$(CONFIG_ARCH_MXS) += mxs/
obj-$(CONFIG_PLAT_SPEAR) += spear/
obj-$(CONFIG_ARCH_U300) += clk-u300.o
obj-$(CONFIG_ARCH_INTEGRATOR) += versatile/

# Chip specific
obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
2 changes: 2 additions & 0 deletions trunk/drivers/clk/versatile/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Makefile for Versatile-specific clocks
obj-$(CONFIG_ICST) += clk-icst.o
100 changes: 100 additions & 0 deletions trunk/drivers/clk/versatile/clk-icst.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* Driver for the ICST307 VCO clock found in the ARM Reference designs.
* We wrap the custom interface from <asm/hardware/icst.h> into the generic
* clock framework.
*
* TODO: when all ARM reference designs are migrated to generic clocks, the
* ICST clock code from the ARM tree should probably be merged into this
* file.
*/
#include <linux/clk.h>
#include <linux/clkdev.h>
#include <linux/err.h>
#include <linux/clk-provider.h>

#include "clk-icst.h"

/**
* struct clk_icst - ICST VCO clock wrapper
* @hw: corresponding clock hardware entry
* @params: parameters for this ICST instance
* @rate: current rate
* @setvco: function to commit ICST settings to hardware
*/
struct clk_icst {
struct clk_hw hw;
const struct icst_params *params;
unsigned long rate;
struct icst_vco (*getvco)(void);
void (*setvco)(struct icst_vco);
};

#define to_icst(_hw) container_of(_hw, struct clk_icst, hw)

static unsigned long icst_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
struct clk_icst *icst = to_icst(hw);
struct icst_vco vco;

vco = icst->getvco();
icst->rate = icst_hz(icst->params, vco);
return icst->rate;
}

static long icst_round_rate(struct clk_hw *hw, unsigned long rate,
unsigned long *prate)
{
struct clk_icst *icst = to_icst(hw);
struct icst_vco vco;

vco = icst_hz_to_vco(icst->params, rate);
return icst_hz(icst->params, vco);
}

static int icst_set_rate(struct clk_hw *hw, unsigned long rate,
unsigned long parent_rate)
{
struct clk_icst *icst = to_icst(hw);
struct icst_vco vco;

vco = icst_hz_to_vco(icst->params, rate);
icst->rate = icst_hz(icst->params, vco);
icst->setvco(vco);
return 0;
}

static const struct clk_ops icst_ops = {
.recalc_rate = icst_recalc_rate,
.round_rate = icst_round_rate,
.set_rate = icst_set_rate,
};

struct clk * __init icst_clk_register(struct device *dev,
const struct clk_icst_desc *desc)
{
struct clk *clk;
struct clk_icst *icst;
struct clk_init_data init;

icst = kzalloc(sizeof(struct clk_icst), GFP_KERNEL);
if (!icst) {
pr_err("could not allocate ICST clock!\n");
return ERR_PTR(-ENOMEM);
}
init.name = "icst";
init.ops = &icst_ops;
init.flags = CLK_IS_ROOT;
init.parent_names = NULL;
init.num_parents = 0;
icst->hw.init = &init;
icst->params = desc->params;
icst->getvco = desc->getvco;
icst->setvco = desc->setvco;

clk = clk_register(dev, &icst->hw);
if (IS_ERR(clk))
kfree(icst);

return clk;
}
10 changes: 10 additions & 0 deletions trunk/drivers/clk/versatile/clk-icst.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <asm/hardware/icst.h>

struct clk_icst_desc {
const struct icst_params *params;
struct icst_vco (*getvco)(void);
void (*setvco)(struct icst_vco);
};

struct clk *icst_clk_register(struct device *dev,
const struct clk_icst_desc *desc);

0 comments on commit f5ea796

Please sign in to comment.