2008-03-18 09:22:06 +01:00
|
|
|
/*
|
|
|
|
* linux/arch/arm/mach-omap2/clock.h
|
|
|
|
*
|
2009-12-09 00:21:29 +01:00
|
|
|
* Copyright (C) 2005-2009 Texas Instruments, Inc.
|
2011-02-25 23:39:28 +01:00
|
|
|
* Copyright (C) 2004-2011 Nokia Corporation
|
2008-03-18 09:22:06 +01:00
|
|
|
*
|
2008-03-18 10:56:39 +01:00
|
|
|
* Contacts:
|
|
|
|
* Richard Woodruff <r-woodruff2@ti.com>
|
2008-03-18 09:22:06 +01: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
|
|
|
|
|
2011-07-10 13:57:06 +02:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
|
2009-10-20 18:40:47 +02:00
|
|
|
#include <plat/clock.h>
|
2008-03-18 09:22:06 +01:00
|
|
|
|
[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 14:29:22 +01: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
|
|
|
|
|
2009-12-09 02:47:16 +01:00
|
|
|
/* OMAP4xxx CM_CLKMODE_DPLL*.EN_*_DPLL bits - for omap2_get_dpll_rate() */
|
|
|
|
#define OMAP4XXX_EN_DPLL_MNBYPASS 0x4
|
|
|
|
#define OMAP4XXX_EN_DPLL_LPBYPASS 0x5
|
|
|
|
#define OMAP4XXX_EN_DPLL_FRBYPASS 0x6
|
|
|
|
#define OMAP4XXX_EN_DPLL_LOCKED 0x7
|
|
|
|
|
2009-12-09 02:47:16 +01:00
|
|
|
/* CM_CLKEN_PLL*.EN* bit values - not all are available for every DPLL */
|
|
|
|
#define DPLL_LOW_POWER_STOP 0x1
|
|
|
|
#define DPLL_LOW_POWER_BYPASS 0x5
|
|
|
|
#define DPLL_LOCKED 0x7
|
|
|
|
|
2010-02-23 06:09:08 +01:00
|
|
|
/* DPLL Type and DCO Selection Flags */
|
|
|
|
#define DPLL_J_TYPE 0x1
|
|
|
|
|
2008-03-18 09:22:06 +01: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);
|
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 11:24:46 +02:00
|
|
|
long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate);
|
2009-12-09 02:47:16 +01:00
|
|
|
unsigned long omap3_dpll_recalc(struct clk *clk);
|
|
|
|
unsigned long omap3_clkoutx2_recalc(struct clk *clk);
|
|
|
|
void omap3_dpll_allow_idle(struct clk *clk);
|
|
|
|
void omap3_dpll_deny_idle(struct clk *clk);
|
|
|
|
u32 omap3_dpll_autoidle_read(struct clk *clk);
|
|
|
|
int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate);
|
|
|
|
int omap3_noncore_dpll_enable(struct clk *clk);
|
|
|
|
void omap3_noncore_dpll_disable(struct clk *clk);
|
2011-02-25 23:49:01 +01:00
|
|
|
int omap4_dpllmx_gatectrl_read(struct clk *clk);
|
|
|
|
void omap4_dpllmx_allow_gatectrl(struct clk *clk);
|
|
|
|
void omap4_dpllmx_deny_gatectrl(struct clk *clk);
|
2011-10-07 08:52:58 +02:00
|
|
|
long omap4_dpll_regm4xen_round_rate(struct clk *clk, unsigned long target_rate);
|
|
|
|
unsigned long omap4_dpll_regm4xen_recalc(struct clk *clk);
|
2008-03-18 09:22:06 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_OMAP_RESET_CLOCKS
|
|
|
|
void omap2_clk_disable_unused(struct clk *clk);
|
|
|
|
#else
|
|
|
|
#define omap2_clk_disable_unused NULL
|
|
|
|
#endif
|
|
|
|
|
2008-08-19 10:08:45 +02:00
|
|
|
void omap2_init_clk_clkdm(struct clk *clk);
|
2011-07-10 13:57:06 +02:00
|
|
|
void __init omap2_clk_disable_clkdm_control(void);
|
2010-05-19 02:40:24 +02:00
|
|
|
|
|
|
|
/* clkt_clksel.c public functions */
|
2008-03-18 09:22:06 +01:00
|
|
|
u32 omap2_clksel_round_rate_div(struct clk *clk, unsigned long target_rate,
|
|
|
|
u32 *new_div);
|
2010-05-19 02:40:24 +02:00
|
|
|
void omap2_init_clksel_parent(struct clk *clk);
|
|
|
|
unsigned long omap2_clksel_recalc(struct clk *clk);
|
2008-03-18 09:22:06 +01:00
|
|
|
long omap2_clksel_round_rate(struct clk *clk, unsigned long target_rate);
|
|
|
|
int omap2_clksel_set_rate(struct clk *clk, unsigned long rate);
|
2010-01-27 04:13:04 +01:00
|
|
|
int omap2_clksel_set_parent(struct clk *clk, struct clk *new_parent);
|
2010-05-19 02:40:24 +02:00
|
|
|
|
2011-02-25 23:39:28 +01:00
|
|
|
/* clkt_iclk.c public functions */
|
|
|
|
extern void omap2_clkt_iclk_allow_idle(struct clk *clk);
|
|
|
|
extern void omap2_clkt_iclk_deny_idle(struct clk *clk);
|
|
|
|
|
2008-03-18 09:22:06 +01:00
|
|
|
u32 omap2_get_dpll_rate(struct clk *clk);
|
2009-12-09 02:47:17 +01:00
|
|
|
void omap2_init_dpll_parent(struct clk *clk);
|
2010-05-19 02:40:24 +02:00
|
|
|
|
2008-03-18 09:22:06 +01:00
|
|
|
int omap2_wait_clock_ready(void __iomem *reg, u32 cval, const char *name);
|
2010-02-12 21:26:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_ARCH_OMAP2
|
|
|
|
void omap2xxx_clk_prepare_for_reboot(void);
|
|
|
|
#else
|
|
|
|
static inline void omap2xxx_clk_prepare_for_reboot(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_ARCH_OMAP3
|
|
|
|
void omap3_clk_prepare_for_reboot(void);
|
|
|
|
#else
|
|
|
|
static inline void omap3_clk_prepare_for_reboot(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_ARCH_OMAP4
|
|
|
|
void omap4_clk_prepare_for_reboot(void);
|
|
|
|
#else
|
|
|
|
static inline void omap4_clk_prepare_for_reboot(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-07-25 03:44:03 +02:00
|
|
|
int omap2_dflt_clk_enable(struct clk *clk);
|
|
|
|
void omap2_dflt_clk_disable(struct clk *clk);
|
|
|
|
void omap2_clk_dflt_find_companion(struct clk *clk, void __iomem **other_reg,
|
|
|
|
u8 *other_bit);
|
|
|
|
void omap2_clk_dflt_find_idlest(struct clk *clk, void __iomem **idlest_reg,
|
2010-02-24 20:05:54 +01:00
|
|
|
u8 *idlest_bit, u8 *idlest_val);
|
2010-02-23 06:09:36 +01:00
|
|
|
int omap2_clk_switch_mpurate_at_boot(const char *mpurate_ck_name);
|
|
|
|
void omap2_clk_print_new_rates(const char *hfclkin_ck_name,
|
|
|
|
const char *core_ck_name,
|
|
|
|
const char *mpu_ck_name);
|
2008-03-18 09:22:06 +01:00
|
|
|
|
2011-12-13 19:46:43 +01:00
|
|
|
extern u16 cpu_mask;
|
2009-12-09 00:21:29 +01:00
|
|
|
|
2008-11-04 18:59:52 +01:00
|
|
|
extern const struct clkops clkops_omap2_dflt_wait;
|
2010-02-23 06:09:40 +01:00
|
|
|
extern const struct clkops clkops_dummy;
|
2008-11-04 19:59:32 +01:00
|
|
|
extern const struct clkops clkops_omap2_dflt;
|
2008-11-04 18:59:52 +01:00
|
|
|
|
2009-12-09 00:18:47 +01:00
|
|
|
extern struct clk_functions omap2_clk_functions;
|
2009-12-09 00:21:29 +01:00
|
|
|
extern struct clk *vclk, *sclk;
|
2009-12-09 00:18:47 +01:00
|
|
|
|
2009-12-09 00:21:29 +01:00
|
|
|
extern const struct clksel_rate gpt_32k_rates[];
|
|
|
|
extern const struct clksel_rate gpt_sys_rates[];
|
|
|
|
extern const struct clksel_rate gfx_l3_rates[];
|
2011-02-25 23:52:04 +01:00
|
|
|
extern const struct clksel_rate dsp_ick_rates[];
|
2008-03-18 09:22:06 +01:00
|
|
|
|
2011-02-25 23:39:28 +01:00
|
|
|
extern const struct clkops clkops_omap2_iclk_dflt_wait;
|
|
|
|
extern const struct clkops clkops_omap2_iclk_dflt;
|
|
|
|
extern const struct clkops clkops_omap2_iclk_idle_only;
|
2011-02-25 23:39:29 +01:00
|
|
|
extern const struct clkops clkops_omap2_mdmclk_dflt_wait;
|
2011-02-25 23:49:53 +01:00
|
|
|
extern const struct clkops clkops_omap2xxx_dpll_ops;
|
OMAP3/4 clock: split into per-chip family files
clock34xx_data.c now contains data for the OMAP34xx family, the
OMAP36xx family, and the OMAP3517 family, so rename it to
clock3xxx_data.c. Rename clock34xx.c to clock3xxx.c, and move the
chip family-specific clock functions to clock34xx.c, clock36xx.c, or
clock3517.c, as appropriate. So now "clock3xxx.*" refers to the OMAP3
superset.
The main goal here is to prepare to compile chip family-specific clock
functions only for kernel builds that target that chip family. To get to
that point, we also need to add CONFIG_SOC_* options for those other
chip families; that will be done in future patches, planned for 2.6.35.
OMAP4 is also affected by this. It duplicated the OMAP3 non-CORE DPLL
clkops structure. The OMAP4 variant of this clkops structure has been
removed, and since there was nothing else currently in clock44xx.c, it
too has been removed -- it can always be added back later when there
is some content for it. (The OMAP4 clock autogeneration scripts have been
updated accordingly.)
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Cc: Benoît Cousson <b-cousson@ti.com>
Cc: Rajendra Nayak <rnayak@ti.com>
Cc: Ranjith Lohithakshan <ranjithl@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
2010-02-23 06:09:20 +01:00
|
|
|
extern const struct clkops clkops_omap3_noncore_dpll_ops;
|
2011-02-25 23:49:00 +01:00
|
|
|
extern const struct clkops clkops_omap3_core_dpll_ops;
|
2011-02-25 23:49:02 +01:00
|
|
|
extern const struct clkops clkops_omap4_dpllmx_ops;
|
OMAP3/4 clock: split into per-chip family files
clock34xx_data.c now contains data for the OMAP34xx family, the
OMAP36xx family, and the OMAP3517 family, so rename it to
clock3xxx_data.c. Rename clock34xx.c to clock3xxx.c, and move the
chip family-specific clock functions to clock34xx.c, clock36xx.c, or
clock3517.c, as appropriate. So now "clock3xxx.*" refers to the OMAP3
superset.
The main goal here is to prepare to compile chip family-specific clock
functions only for kernel builds that target that chip family. To get to
that point, we also need to add CONFIG_SOC_* options for those other
chip families; that will be done in future patches, planned for 2.6.35.
OMAP4 is also affected by this. It duplicated the OMAP3 non-CORE DPLL
clkops structure. The OMAP4 variant of this clkops structure has been
removed, and since there was nothing else currently in clock44xx.c, it
too has been removed -- it can always be added back later when there
is some content for it. (The OMAP4 clock autogeneration scripts have been
updated accordingly.)
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Cc: Benoît Cousson <b-cousson@ti.com>
Cc: Rajendra Nayak <rnayak@ti.com>
Cc: Ranjith Lohithakshan <ranjithl@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
2010-02-23 06:09:20 +01:00
|
|
|
|
2012-05-29 11:56:40 +02:00
|
|
|
/* clksel_rate blocks shared between OMAP44xx and AM33xx */
|
|
|
|
extern const struct clksel_rate div_1_0_rates[];
|
|
|
|
extern const struct clksel_rate div_1_1_rates[];
|
|
|
|
extern const struct clksel_rate div_1_2_rates[];
|
|
|
|
extern const struct clksel_rate div_1_3_rates[];
|
|
|
|
extern const struct clksel_rate div_1_4_rates[];
|
|
|
|
extern const struct clksel_rate div31_1to31_rates[];
|
|
|
|
|
|
|
|
/* clocks shared between various OMAP SoCs */
|
|
|
|
extern struct clk virt_19200000_ck;
|
|
|
|
extern struct clk virt_26000000_ck;
|
|
|
|
|
2012-05-29 11:56:41 +02:00
|
|
|
extern int am33xx_clk_init(void);
|
|
|
|
|
2008-03-18 09:22:06 +01:00
|
|
|
#endif
|