Commit 6b8858a9 authored by Paul Walmsley's avatar Paul Walmsley Committed by Tony Lindgren

ARM: OMAP2: Change 24xx to use shared clock code and new reg access

This patch changes 24xx to use shared clock code and new register
access.

Note that patch adds some temporary OLD_CK defines to keep patch
more readable. These temporary defines will be removed in the next
patch. Also not all clocks are changed in this patch to limit the
size.

Also, the patch fixes few incorrect clock defines in clock24xx.h.
Signed-off-by: default avatarPaul Walmsley <paul@pwsan.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent 543d9378
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# #
# Common support # Common support
obj-y := irq.o id.o io.o sram-fn.o memory.o control.o prcm.o mux.o \ obj-y := irq.o id.o io.o sram-fn.o memory.o control.o prcm.o clock.o mux.o \
devices.o serial.o gpmc.o timer-gp.o devices.o serial.o gpmc.o timer-gp.o
# Power Management # Power Management
......
...@@ -122,7 +122,7 @@ u32 omap2_get_dpll_rate(struct clk *clk) ...@@ -122,7 +122,7 @@ u32 omap2_get_dpll_rate(struct clk *clk)
if (dd->div2_reg) { if (dd->div2_reg) {
dpll = __raw_readl(dd->div2_reg); dpll = __raw_readl(dd->div2_reg);
dpll_div = dpll & dd->div2_mask; dpll_div = dpll & dd->div2_mask;
dpll_div >>= __fss(dd->div2_mask); dpll_div >>= __ffs(dd->div2_mask);
do_div(dpll_clk, dpll_div + 1); do_div(dpll_clk, dpll_div + 1);
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -53,6 +53,54 @@ u32 omap2_memory_get_type(void) ...@@ -53,6 +53,54 @@ u32 omap2_memory_get_type(void)
return mem_timings.m_type; return mem_timings.m_type;
} }
/*
* Check the DLL lock state, and return tue if running in unlock mode.
* This is needed to compensate for the shifted DLL value in unlock mode.
*/
u32 omap2_dll_force_needed(void)
{
/* dlla and dllb are a set */
u32 dll_state = sdrc_read_reg(SDRC_DLLA_CTRL);
if ((dll_state & (1 << 2)) == (1 << 2))
return 1;
else
return 0;
}
/*
* 'level' is the value to store to CM_CLKSEL2_PLL.CORE_CLK_SRC.
* Practical values are CORE_CLK_SRC_DPLL (for CORE_CLK = DPLL_CLK) or
* CORE_CLK_SRC_DPLL_X2 (for CORE_CLK = * DPLL_CLK * 2)
*/
u32 omap2_reprogram_sdrc(u32 level, u32 force)
{
u32 dll_ctrl, m_type;
u32 prev = curr_perf_level;
unsigned long flags;
if ((curr_perf_level == level) && !force)
return prev;
if (level == CORE_CLK_SRC_DPLL) {
dll_ctrl = omap2_memory_get_slow_dll_ctrl();
} else if (level == CORE_CLK_SRC_DPLL_X2) {
dll_ctrl = omap2_memory_get_fast_dll_ctrl();
} else {
return prev;
}
m_type = omap2_memory_get_type();
local_irq_save(flags);
__raw_writel(0xffff, OMAP24XX_PRCM_VOLTSETUP);
omap2_sram_reprogram_sdrc(level, dll_ctrl, m_type);
curr_perf_level = level;
local_irq_restore(flags);
return prev;
}
void omap2_init_memory_params(u32 force_lock_to_unlock_mode) void omap2_init_memory_params(u32 force_lock_to_unlock_mode)
{ {
unsigned long dll_cnt; unsigned long dll_cnt;
......
...@@ -32,3 +32,5 @@ extern void omap2_init_memory_params(u32 force_lock_to_unlock_mode); ...@@ -32,3 +32,5 @@ extern void omap2_init_memory_params(u32 force_lock_to_unlock_mode);
extern u32 omap2_memory_get_slow_dll_ctrl(void); extern u32 omap2_memory_get_slow_dll_ctrl(void);
extern u32 omap2_memory_get_fast_dll_ctrl(void); extern u32 omap2_memory_get_fast_dll_ctrl(void);
extern u32 omap2_memory_get_type(void); extern u32 omap2_memory_get_type(void);
u32 omap2_dll_force_needed(void);
u32 omap2_reprogram_sdrc(u32 level, u32 force);
...@@ -304,6 +304,23 @@ void propagate_rate(struct clk * tclk) ...@@ -304,6 +304,23 @@ void propagate_rate(struct clk * tclk)
} }
} }
/**
* recalculate_root_clocks - recalculate and propagate all root clocks
*
* Recalculates all root clocks (clocks with no parent), which if the
* clock's .recalc is set correctly, should also propagate their rates.
* Called at init.
*/
void recalculate_root_clocks(void)
{
struct clk *clkp;
list_for_each_entry(clkp, &clocks, node) {
if (unlikely(!clkp->parent) && likely((u32)clkp->recalc))
clkp->recalc(clkp);
}
}
int clk_register(struct clk *clk) int clk_register(struct clk *clk)
{ {
if (clk == NULL || IS_ERR(clk)) if (clk == NULL || IS_ERR(clk))
...@@ -358,6 +375,30 @@ void clk_allow_idle(struct clk *clk) ...@@ -358,6 +375,30 @@ void clk_allow_idle(struct clk *clk)
} }
EXPORT_SYMBOL(clk_allow_idle); EXPORT_SYMBOL(clk_allow_idle);
void clk_enable_init_clocks(void)
{
struct clk *clkp;
list_for_each_entry(clkp, &clocks, node) {
if (clkp->flags & ENABLE_ON_INIT)
clk_enable(clkp);
}
}
EXPORT_SYMBOL(clk_enable_init_clocks);
#ifdef CONFIG_CPU_FREQ
void clk_init_cpufreq_table(struct cpufreq_frequency_table **table)
{
unsigned long flags;
spin_lock_irqsave(&clockfw_lock, flags);
if (arch_clock->clk_init_cpufreq_table)
arch_clock->clk_init_cpufreq_table(table);
spin_unlock_irqrestore(&clockfw_lock, flags);
}
EXPORT_SYMBOL(clk_init_cpufreq_table);
#endif
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
#ifdef CONFIG_OMAP_RESET_CLOCKS #ifdef CONFIG_OMAP_RESET_CLOCKS
...@@ -396,3 +437,4 @@ int __init clk_init(struct clk_functions * custom_clocks) ...@@ -396,3 +437,4 @@ int __init clk_init(struct clk_functions * custom_clocks)
return 0; return 0;
} }
...@@ -14,6 +14,30 @@ ...@@ -14,6 +14,30 @@
#define __ARCH_ARM_OMAP_CLOCK_H #define __ARCH_ARM_OMAP_CLOCK_H
struct module; struct module;
struct clk;
#if defined(CONFIG_ARCH_OMAP2)
struct clksel_rate {
u8 div;
u32 val;
u8 flags;
};
struct clksel {
struct clk *parent;
const struct clksel_rate *rates;
};
struct dpll_data {
void __iomem *mult_div1_reg;
u32 mult_mask;
u32 div1_mask;
void __iomem *div2_reg;
u32 div2_mask;
};
#endif
struct clk { struct clk {
struct list_head node; struct list_head node;
...@@ -25,8 +49,6 @@ struct clk { ...@@ -25,8 +49,6 @@ struct clk {
__u32 flags; __u32 flags;
void __iomem *enable_reg; void __iomem *enable_reg;
__u8 enable_bit; __u8 enable_bit;
__u8 rate_offset;
__u8 src_offset;
__s8 usecount; __s8 usecount;
void (*recalc)(struct clk *); void (*recalc)(struct clk *);
int (*set_rate)(struct clk *, unsigned long); int (*set_rate)(struct clk *, unsigned long);
...@@ -34,6 +56,16 @@ struct clk { ...@@ -34,6 +56,16 @@ struct clk {
void (*init)(struct clk *); void (*init)(struct clk *);
int (*enable)(struct clk *); int (*enable)(struct clk *);
void (*disable)(struct clk *); void (*disable)(struct clk *);
#if defined(CONFIG_ARCH_OMAP2)
u8 fixed_div;
void __iomem *clksel_reg;
u32 clksel_mask;
const struct clksel *clksel;
const struct dpll_data *dpll_data;
#else
__u8 rate_offset;
__u8 src_offset;
#endif
}; };
struct clk_functions { struct clk_functions {
...@@ -54,10 +86,12 @@ extern int clk_init(struct clk_functions * custom_clocks); ...@@ -54,10 +86,12 @@ 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 recalculate_root_clocks(void);
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_allow_idle(struct clk *clk);
extern void clk_deny_idle(struct clk *clk); extern void clk_deny_idle(struct clk *clk);
extern int clk_get_usecount(struct clk *clk); extern int clk_get_usecount(struct clk *clk);
extern void clk_enable_init_clocks(void);
/* Clock flags */ /* Clock flags */
#define RATE_CKCTL (1 << 0) /* Main fixed ratio clocks */ #define RATE_CKCTL (1 << 0) /* Main fixed ratio clocks */
...@@ -71,22 +105,29 @@ extern int clk_get_usecount(struct clk *clk); ...@@ -71,22 +105,29 @@ extern int clk_get_usecount(struct clk *clk);
#define CLOCK_NO_IDLE_PARENT (1 << 8) #define CLOCK_NO_IDLE_PARENT (1 << 8)
#define DELAYED_APP (1 << 9) /* Delay application of clock */ #define DELAYED_APP (1 << 9) /* Delay application of clock */
#define CONFIG_PARTICIPANT (1 << 10) /* Fundamental clock */ #define CONFIG_PARTICIPANT (1 << 10) /* Fundamental clock */
#define CM_MPU_SEL1 (1 << 11) /* Domain divider/source */ #define ENABLE_ON_INIT (1 << 11) /* Enable upon framework init */
#define CM_DSP_SEL1 (1 << 12) #define INVERT_ENABLE (1 << 12) /* 0 enables, 1 disables */
#define CM_GFX_SEL1 (1 << 13) /* bits 13-20 are currently free */
#define CM_MODEM_SEL1 (1 << 14)
#define CM_CORE_SEL1 (1 << 15) /* Sets divider for many */
#define CM_CORE_SEL2 (1 << 16) /* sets parent for GPT */
#define CM_WKUP_SEL1 (1 << 17)
#define CM_PLL_SEL1 (1 << 18)
#define CM_PLL_SEL2 (1 << 19)
#define CM_SYSCLKOUT_SEL1 (1 << 20)
#define CLOCK_IN_OMAP310 (1 << 21) #define CLOCK_IN_OMAP310 (1 << 21)
#define CLOCK_IN_OMAP730 (1 << 22) #define CLOCK_IN_OMAP730 (1 << 22)
#define CLOCK_IN_OMAP1510 (1 << 23) #define CLOCK_IN_OMAP1510 (1 << 23)
#define CLOCK_IN_OMAP16XX (1 << 24) #define CLOCK_IN_OMAP16XX (1 << 24)
#define CLOCK_IN_OMAP242X (1 << 25) #define CLOCK_IN_OMAP242X (1 << 25)
#define CLOCK_IN_OMAP243X (1 << 26) #define CLOCK_IN_OMAP243X (1 << 26)
#define CLOCK_IN_OMAP343X (1 << 27) /* clocks common to all 343X */
#define PARENT_CONTROLS_CLOCK (1 << 28)
#define CLOCK_IN_OMAP3430ES1 (1 << 29) /* 3430ES1 clocks only */
#define CLOCK_IN_OMAP3430ES2 (1 << 30) /* 3430ES2 clocks only */
/* Clksel_rate flags */
#define DEFAULT_RATE (1 << 0)
#define RATE_IN_242X (1 << 1)
#define RATE_IN_243X (1 << 2)
#define RATE_IN_343X (1 << 3) /* rates common to all 343X */
#define RATE_IN_3430ES2 (1 << 4) /* 3430ES2 rates only */
#define RATE_IN_24XX (RATE_IN_242X | RATE_IN_243X)
/* CM_CLKSEL2_PLL.CORE_CLK_SRC options (24XX) */ /* CM_CLKSEL2_PLL.CORE_CLK_SRC options (24XX) */
#define CORE_CLK_SRC_32K 0 #define CORE_CLK_SRC_32K 0
......
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