2008-03-18 08:22:06 +00:00
|
|
|
/*
|
|
|
|
* linux/arch/arm/mach-omap2/clock.h
|
|
|
|
*
|
2008-03-18 09:56:39 +00:00
|
|
|
* Copyright (C) 2005-2008 Texas Instruments, Inc.
|
|
|
|
* Copyright (C) 2004-2008 Nokia Corporation
|
2008-03-18 08:22:06 +00:00
|
|
|
*
|
2008-03-18 09:56:39 +00:00
|
|
|
* Contacts:
|
|
|
|
* Richard Woodruff <r-woodruff2@ti.com>
|
2008-03-18 08:22:06 +00:00
|
|
|
* Paul Walmsley
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __ARCH_ARM_MACH_OMAP2_CLOCK_H
|
|
|
|
#define __ARCH_ARM_MACH_OMAP2_CLOCK_H
|
|
|
|
|
2008-08-05 15:14:15 +00:00
|
|
|
#include <mach/clock.h>
|
2008-03-18 08:22:06 +00:00
|
|
|
|
ARM: OMAP2: Clock: New OMAP2/3 DPLL rate rounding algorithm
This patch adds a new rate rounding algorithm for DPLL clocks on the
OMAP2/3 architecture.
For a desired DPLL target rate, there may be several
multiplier/divider (M, N) values which will generate a sufficiently
close rate. Lower N values result in greater power economy. However,
lower N values can cause the difference between the rounded rate and
the target rate ("rate error") to be larger than it would be with a
higher N. This can cause downstream devices to run more slowly than
they otherwise would.
This DPLL rate rounding algorithm:
- attempts to find the lowest possible N (DPLL divider) to reach the
target_rate (since, according to Richard Woodruff <r-woodruff@ti.com>,
lower N values save more power than higher N values).
- allows developers to set an upper bound on the error between the
rounded rate and the desired target rate ("rate tolerance"), so an
appropriate balance between rate fidelity and power savings can be
set. This maximum rate error tolerance is set via
omap2_set_dpll_rate_tolerance().
- never returns a rounded rate higher than the target rate.
The rate rounding algorithm caches the last rounded M, N, and rate
computation to avoid rounding the rate twice for each clk_set_rate()
call. (This patch does not yet implement set_rate for DPLLs; that
follows in a future patch.)
The algorithm trades execution speed for rate accuracy. It will find
the (M, N) set that results in the least rate error, within a
specified rate tolerance. It does this by evaluating each divider
setting - on OMAP3, this involves 128 steps. Another approach to DPLL
rate rounding would be to bail out as soon as a valid rate is found
within the rate tolerance, which would trade rate accuracy for
execution speed. Alternate implementations welcome.
This code is not yet used by the OMAP24XX DPLL clock, since it
is currently defined as a composite clock, fusing the DPLL M,N and the
M2 output divider. This patch also renames the existing OMAP24xx DPLL
programming functions to highlight that they program both the DPLL and
the DPLL's output multiplier.
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
2008-07-03 09:24:46 +00:00
|
|
|
/* The maximum error between a target DPLL rate and the rounded rate in Hz */
|
|
|
|
#define DEFAULT_DPLL_RATE_TOLERANCE 50000
|
|
|
|
|
[ARM] omap: add support for bypassing DPLLs
This roughly corresponds with OMAP commits: 7d06c48, 3241b19,
88b5d9b, 18a5500, 9c909ac, 5c6497b, 8b1f0bd, 2ac1da8.
For both OMAP2 and OMAP3, we note the reference and bypass clocks in
the DPLL data structure. Whenever we modify the DPLL rate, we first
ensure that both the reference and bypass clocks are enabled. Then,
we decide whether to use the reference and DPLL, or the bypass clock
if the desired rate is identical to the bypass rate, and program the
DPLL appropriately. Finally, we update the clock's parent, and then
disable the unused clocks.
This keeps the parents correctly balanced, and more importantly ensures
that the bypass clock is running whenever we reprogram the DPLL. This
is especially important because the procedure for reprogramming the DPLL
involves switching to the bypass clock.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2009-02-19 13:29:22 +00:00
|
|
|
/* CM_CLKSEL2_PLL.CORE_CLK_SRC bits (2XXX) */
|
|
|
|
#define CORE_CLK_SRC_32K 0x0
|
|
|
|
#define CORE_CLK_SRC_DPLL 0x1
|
|
|
|
#define CORE_CLK_SRC_DPLL_X2 0x2
|
|
|
|
|
|
|
|
/* OMAP2xxx CM_CLKEN_PLL.EN_DPLL bits - for omap2_get_dpll_rate() */
|
|
|
|
#define OMAP2XXX_EN_DPLL_LPBYPASS 0x1
|
|
|
|
#define OMAP2XXX_EN_DPLL_FRBYPASS 0x2
|
|
|
|
#define OMAP2XXX_EN_DPLL_LOCKED 0x3
|
|
|
|
|
|
|
|
/* OMAP3xxx CM_CLKEN_PLL*.EN_*_DPLL bits - for omap2_get_dpll_rate() */
|
|
|
|
#define OMAP3XXX_EN_DPLL_LPBYPASS 0x5
|
|
|
|
#define OMAP3XXX_EN_DPLL_FRBYPASS 0x6
|
|
|
|
#define OMAP3XXX_EN_DPLL_LOCKED 0x7
|
|
|
|
|
2008-10-06 12:49:36 +00:00
|
|
|
int omap2_clk_init(void);
|
2008-03-18 08:22:06 +00:00
|
|
|
int omap2_clk_enable(struct clk *clk);
|
|
|
|
void omap2_clk_disable(struct clk *clk);
|
|
|
|
long omap2_clk_round_rate(struct clk *clk, unsigned long rate);
|
|
|
|
int omap2_clk_set_rate(struct clk *clk, unsigned long rate);
|
|
|
|
int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent);
|
2009-01-28 02:12:50 +00:00
|
|
|
int omap2_dpll_set_rate_tolerance(struct clk *clk, unsigned int tolerance);
|
ARM: OMAP2: Clock: New OMAP2/3 DPLL rate rounding algorithm
This patch adds a new rate rounding algorithm for DPLL clocks on the
OMAP2/3 architecture.
For a desired DPLL target rate, there may be several
multiplier/divider (M, N) values which will generate a sufficiently
close rate. Lower N values result in greater power economy. However,
lower N values can cause the difference between the rounded rate and
the target rate ("rate error") to be larger than it would be with a
higher N. This can cause downstream devices to run more slowly than
they otherwise would.
This DPLL rate rounding algorithm:
- attempts to find the lowest possible N (DPLL divider) to reach the
target_rate (since, according to Richard Woodruff <r-woodruff@ti.com>,
lower N values save more power than higher N values).
- allows developers to set an upper bound on the error between the
rounded rate and the desired target rate ("rate tolerance"), so an
appropriate balance between rate fidelity and power savings can be
set. This maximum rate error tolerance is set via
omap2_set_dpll_rate_tolerance().
- never returns a rounded rate higher than the target rate.
The rate rounding algorithm caches the last rounded M, N, and rate
computation to avoid rounding the rate twice for each clk_set_rate()
call. (This patch does not yet implement set_rate for DPLLs; that
follows in a future patch.)
The algorithm trades execution speed for rate accuracy. It will find
the (M, N) set that results in the least rate error, within a
specified rate tolerance. It does this by evaluating each divider
setting - on OMAP3, this involves 128 steps. Another approach to DPLL
rate rounding would be to bail out as soon as a valid rate is found
within the rate tolerance, which would trade rate accuracy for
execution speed. Alternate implementations welcome.
This code is not yet used by the OMAP24XX DPLL clock, since it
is currently defined as a composite clock, fusing the DPLL M,N and the
M2 output divider. This patch also renames the existing OMAP24xx DPLL
programming functions to highlight that they program both the DPLL and
the DPLL's output multiplier.
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
2008-07-03 09:24:46 +00:00
|
|
|
long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate);
|
2008-03-18 08:22:06 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_OMAP_RESET_CLOCKS
|
|
|
|
void omap2_clk_disable_unused(struct clk *clk);
|
|
|
|
#else
|
|
|
|
#define omap2_clk_disable_unused NULL
|
|
|
|
#endif
|
|
|
|
|
2009-02-12 10:12:59 +00:00
|
|
|
unsigned long omap2_clksel_recalc(struct clk *clk);
|
2008-08-19 08:08:45 +00:00
|
|
|
void omap2_init_clk_clkdm(struct clk *clk);
|
2008-03-18 08:22:06 +00:00
|
|
|
void omap2_init_clksel_parent(struct clk *clk);
|
|
|
|
u32 omap2_clksel_get_divisor(struct clk *clk);
|
|
|
|
u32 omap2_clksel_round_rate_div(struct clk *clk, unsigned long target_rate,
|
|
|
|
u32 *new_div);
|
|
|
|
u32 omap2_clksel_to_divisor(struct clk *clk, u32 field_val);
|
|
|
|
u32 omap2_divisor_to_clksel(struct clk *clk, u32 div);
|
2009-02-12 10:12:59 +00:00
|
|
|
unsigned long omap2_fixed_divisor_recalc(struct clk *clk);
|
2008-03-18 08:22:06 +00:00
|
|
|
long omap2_clksel_round_rate(struct clk *clk, unsigned long target_rate);
|
|
|
|
int omap2_clksel_set_rate(struct clk *clk, unsigned long rate);
|
|
|
|
u32 omap2_get_dpll_rate(struct clk *clk);
|
|
|
|
int omap2_wait_clock_ready(void __iomem *reg, u32 cval, const char *name);
|
2008-07-03 09:24:44 +00:00
|
|
|
void omap2_clk_prepare_for_reboot(void);
|
2008-03-18 08:22:06 +00:00
|
|
|
|
2008-11-04 17:59:52 +00:00
|
|
|
extern const struct clkops clkops_omap2_dflt_wait;
|
2008-11-04 18:59:32 +00:00
|
|
|
extern const struct clkops clkops_omap2_dflt;
|
2008-11-04 17:59:52 +00:00
|
|
|
|
2008-03-18 08:22:06 +00:00
|
|
|
extern u8 cpu_mask;
|
|
|
|
|
|
|
|
/* clksel_rate data common to 24xx/343x */
|
|
|
|
static const struct clksel_rate gpt_32k_rates[] = {
|
|
|
|
{ .div = 1, .val = 0, .flags = RATE_IN_24XX | RATE_IN_343X | DEFAULT_RATE },
|
|
|
|
{ .div = 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct clksel_rate gpt_sys_rates[] = {
|
|
|
|
{ .div = 1, .val = 1, .flags = RATE_IN_24XX | RATE_IN_343X | DEFAULT_RATE },
|
|
|
|
{ .div = 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct clksel_rate gfx_l3_rates[] = {
|
|
|
|
{ .div = 1, .val = 1, .flags = RATE_IN_24XX | RATE_IN_343X },
|
|
|
|
{ .div = 2, .val = 2, .flags = RATE_IN_24XX | RATE_IN_343X | DEFAULT_RATE },
|
|
|
|
{ .div = 3, .val = 3, .flags = RATE_IN_243X | RATE_IN_343X },
|
|
|
|
{ .div = 4, .val = 4, .flags = RATE_IN_243X | RATE_IN_343X },
|
|
|
|
{ .div = 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|