Commit cc2b1490 authored by Tony Lindgren's avatar Tony Lindgren

ARM: OMAP: Clock framework fixes to allow adding omap2 clocks

Clock framework fixes to allow adding omap2 clocks
parent d513a6e3
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
* Copyright (C) 2004 - 2005 Nokia corporation * Copyright (C) 2004 - 2005 Nokia corporation
* Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com> * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>
* *
* Modified to use omap shared clock framework by
* Tony Lindgren <tony@atomide.com>
*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
......
This diff is collapsed.
...@@ -4,12 +4,17 @@ ...@@ -4,12 +4,17 @@
* Copyright (C) 2004 - 2005 Nokia corporation * Copyright (C) 2004 - 2005 Nokia corporation
* Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com> * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>
* *
* Modified for omap shared clock framework by Tony Lindgren <tony@atomide.com>
*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
#include <linux/module.h> #include <linux/version.h>
#include <linux/config.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/err.h> #include <linux/err.h>
...@@ -22,7 +27,7 @@ ...@@ -22,7 +27,7 @@
LIST_HEAD(clocks); LIST_HEAD(clocks);
static DECLARE_MUTEX(clocks_sem); static DECLARE_MUTEX(clocks_sem);
static DEFINE_SPINLOCK(clockfw_lock); DEFINE_SPINLOCK(clockfw_lock);
static struct clk_functions *arch_clock; static struct clk_functions *arch_clock;
...@@ -50,10 +55,15 @@ EXPORT_SYMBOL(clk_get); ...@@ -50,10 +55,15 @@ EXPORT_SYMBOL(clk_get);
int clk_enable(struct clk *clk) int clk_enable(struct clk *clk)
{ {
unsigned long flags; unsigned long flags;
int ret; int ret = 0;
spin_lock_irqsave(&clockfw_lock, flags); spin_lock_irqsave(&clockfw_lock, flags);
if (clk->enable)
ret = clk->enable(clk); ret = clk->enable(clk);
else if (arch_clock->clk_enable)
ret = arch_clock->clk_enable(clk);
else
printk(KERN_ERR "Could not enable clock %s\n", clk->name);
spin_unlock_irqrestore(&clockfw_lock, flags); spin_unlock_irqrestore(&clockfw_lock, flags);
return ret; return ret;
...@@ -65,7 +75,12 @@ void clk_disable(struct clk *clk) ...@@ -65,7 +75,12 @@ void clk_disable(struct clk *clk)
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&clockfw_lock, flags); spin_lock_irqsave(&clockfw_lock, flags);
if (clk->disable)
clk->disable(clk); clk->disable(clk);
else if (arch_clock->clk_disable)
arch_clock->clk_disable(clk);
else
printk(KERN_ERR "Could not disable clock %s\n", clk->name);
spin_unlock_irqrestore(&clockfw_lock, flags); spin_unlock_irqrestore(&clockfw_lock, flags);
} }
EXPORT_SYMBOL(clk_disable); EXPORT_SYMBOL(clk_disable);
...@@ -192,12 +207,33 @@ EXPORT_SYMBOL(clk_get_parent); ...@@ -192,12 +207,33 @@ EXPORT_SYMBOL(clk_get_parent);
* OMAP specific clock functions shared between omap1 and omap2 * OMAP specific clock functions shared between omap1 and omap2
*-------------------------------------------------------------------------*/ *-------------------------------------------------------------------------*/
unsigned int __initdata mpurate;
/*
* By default we use the rate set by the bootloader.
* You can override this with mpurate= cmdline option.
*/
static int __init omap_clk_setup(char *str)
{
get_option(&str, &mpurate);
if (!mpurate)
return 1;
if (mpurate < 1000)
mpurate *= 1000000;
return 1;
}
__setup("mpurate=", omap_clk_setup);
/* Used for clocks that always have same value as the parent clock */ /* Used for clocks that always have same value as the parent clock */
void followparent_recalc(struct clk * clk) void followparent_recalc(struct clk *clk)
{ {
clk->rate = clk->parent->rate; clk->rate = clk->parent->rate;
} }
/* Propagate rate to children */
void propagate_rate(struct clk * tclk) void propagate_rate(struct clk * tclk)
{ {
struct clk *clkp; struct clk *clkp;
......
...@@ -22,7 +22,7 @@ struct clk { ...@@ -22,7 +22,7 @@ struct clk {
struct clk *parent; struct clk *parent;
unsigned long rate; unsigned long rate;
__u32 flags; __u32 flags;
__u32 enable_reg; void __iomem *enable_reg;
__u8 enable_bit; __u8 enable_bit;
__u8 rate_offset; __u8 rate_offset;
__u8 src_offset; __u8 src_offset;
...@@ -36,6 +36,8 @@ struct clk { ...@@ -36,6 +36,8 @@ struct clk {
}; };
struct clk_functions { struct clk_functions {
int (*clk_enable)(struct clk *clk);
void (*clk_disable)(struct clk *clk);
int (*clk_use)(struct clk *clk); int (*clk_use)(struct clk *clk);
void (*clk_unuse)(struct clk *clk); void (*clk_unuse)(struct clk *clk);
long (*clk_round_rate)(struct clk *clk, unsigned long rate); long (*clk_round_rate)(struct clk *clk, unsigned long rate);
...@@ -46,14 +48,17 @@ struct clk_functions { ...@@ -46,14 +48,17 @@ struct clk_functions {
void (*clk_deny_idle)(struct clk *clk); void (*clk_deny_idle)(struct clk *clk);
}; };
extern spinlock_t clockfw_lock; extern unsigned int mpurate;
extern struct list_head clocks; extern struct list_head clocks;
extern spinlock_t clockfw_lock;
extern int clk_init(struct clk_functions * custom_clocks); extern int clk_init(struct clk_functions * custom_clocks);
extern int clk_register(struct clk *clk); extern int clk_register(struct clk *clk);
extern void clk_unregister(struct clk *clk); extern void clk_unregister(struct clk *clk);
extern void propagate_rate(struct clk *clk); extern void propagate_rate(struct clk *clk);
extern void followparent_recalc(struct clk * clk); extern void followparent_recalc(struct clk * clk);
extern void clk_allow_idle(struct clk *clk);
extern void clk_deny_idle(struct clk *clk);
/* Clock flags */ /* Clock flags */
#define RATE_CKCTL (1 << 0) /* Main fixed ratio clocks */ #define RATE_CKCTL (1 << 0) /* Main fixed ratio clocks */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment