Skip to content

Commit

Permalink
ARM i.MX: Add common clock support for pllv1
Browse files Browse the repository at this point in the history
The pllv1 is found on i.MX1, i.M25, i.MX27, i.MX31 and i.MX35.
Currently only reading the rate is supported.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
  • Loading branch information
Sascha Hauer committed May 2, 2012
1 parent 6c7b068 commit 2af9e6d
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
2 changes: 2 additions & 0 deletions arch/arm/mach-imx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ obj-$(CONFIG_SOC_IMX35) += mm-imx3.o cpu-imx35.o clock-imx35.o ehci-imx35.o pm-i

obj-$(CONFIG_SOC_IMX5) += cpu-imx5.o mm-imx5.o clock-mx51-mx53.o ehci-imx5.o pm-imx5.o cpu_op-mx51.o

obj-$(CONFIG_COMMON_CLK) += clk-pllv1.o

# Support for CMOS sensor interface
obj-$(CONFIG_MX1_VIDEO) += mx1-camera-fiq.o mx1-camera-fiq-ksym.o

Expand Down
66 changes: 66 additions & 0 deletions arch/arm/mach-imx/clk-pllv1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/io.h>
#include <linux/slab.h>
#include <linux/kernel.h>
#include <linux/err.h>
#include <mach/common.h>
#include <mach/hardware.h>
#include <mach/clock.h>
#include "clk.h"

/**
* pll v1
*
* @clk_hw clock source
* @parent the parent clock name
* @base base address of pll registers
*
* PLL clock version 1, found on i.MX1/21/25/27/31/35
*/
struct clk_pllv1 {
struct clk_hw hw;
void __iomem *base;
};

#define to_clk_pllv1(clk) (container_of(clk, struct clk_pllv1, clk))

static unsigned long clk_pllv1_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
struct clk_pllv1 *pll = to_clk_pllv1(hw);

return mxc_decode_pll(readl(pll->base), parent_rate);
}

struct clk_ops clk_pllv1_ops = {
.recalc_rate = clk_pllv1_recalc_rate,
};

struct clk *imx_clk_pllv1(const char *name, const char *parent,
void __iomem *base)
{
struct clk_pllv1 *pll;
struct clk *clk;
struct clk_init_data init;

pll = kmalloc(sizeof(*pll), GFP_KERNEL);
if (!pll)
return ERR_PTR(-ENOMEM);

pll->base = base;

init.name = name;
init.ops = &clk_pllv1_ops;
init.flags = 0;
init.parent_names = &parent;
init.num_parents = 1;

pll->hw.init = &init;

clk = clk_register(NULL, &pll->hw);
if (IS_ERR(clk))
kfree(pll);

return clk;
}
2 changes: 1 addition & 1 deletion arch/arm/mach-imx/clk.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <linux/clk-provider.h>
#include <mach/clock.h>

struct clk *imx_clk_pllv1(const char *name, char *parent,
struct clk *imx_clk_pllv1(const char *name, const char *parent,
void __iomem *base);

static inline struct clk *imx_clk_fixed(const char *name, int rate)
Expand Down

0 comments on commit 2af9e6d

Please sign in to comment.