Commit 139bd95f authored by Paul Walmsley's avatar Paul Walmsley Committed by Tony Lindgren

omap2 clock: add clksel and clksel_rate data

Many OMAP2 clocks are either source- or divisor-selectable by twiddling
various register bits; these are 'clksel' clocks.  The table of rate divisors
and source clock settings was previously embedded in the clock.c source code.
Encode this data in two data structures:

1) struct clksel_rate for divisor-selection, mapping divisor values to
register bit field values, along with a flags field indicating which
chips the rate is available for -- one for each parent-rate combination; and:

2) struct clksel for source-selection, mapping parent struct clk pointers
to struct clksel_rate array pointers; one for each parent.

Also, add several fields to the clk structure:

1) clksel: pointer to the struct clksel array

2) clksel_reg: pointer to the clksel register

3) clksel_mask: mask for the clksel bitfield

Add this data to each clksel clock.  All this data is not yet used by the clock
framework; that functionality is in the following patches.

N.B. Two clocks, sys_clkout and sys_clkout2, could not be converted to
this setup without splitting source selection and divisor selection.
This is because these clocks use separate registers for each
selector.  So, create two new clocks, sys_clkout_src and
sys_clkout2_src, and locate source-selection there, and keep divisor
selection in sys_clkout/sys_clkout2.  This entailed modifying
board-n800-audio.c.
Signed-off-by: default avatarPaul Walmsley <paul@pwsan.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent 0a187e08
......@@ -35,6 +35,7 @@
#define AUDIO_ENABLED
static struct clk *sys_clkout2;
static struct clk *sys_clkout2_src;
static struct clk *func96m_clk;
static struct device *eac_device;
static struct device *tsc2301_device;
......@@ -186,9 +187,15 @@ static void n800_eac_cleanup(struct device *dev)
static int n800_codec_get_clocks(struct device *dev)
{
sys_clkout2_src = clk_get(dev, "sys_clkout2_src");
if (IS_ERR(sys_clkout2_src)) {
dev_err(dev, "Could not get sys_clkout2_src clock\n");
return -ENODEV;
}
sys_clkout2 = clk_get(dev, "sys_clkout2");
if (IS_ERR(sys_clkout2)) {
dev_err(dev, "Could not get sys_clkout2\n");
dev_err(dev, "Could not get sys_clkout2 clock\n");
clk_put(sys_clkout2_src);
return -ENODEV;
}
/* configure 12 MHz output on SYS_CLKOUT2. Therefore we must use
......@@ -197,10 +204,11 @@ static int n800_codec_get_clocks(struct device *dev)
if (IS_ERR(func96m_clk)) {
dev_err(dev, "Could not get func 96M clock\n");
clk_put(sys_clkout2);
clk_put(sys_clkout2_src);
return -ENODEV;
}
clk_set_parent(sys_clkout2, func96m_clk);
clk_set_parent(sys_clkout2_src, func96m_clk);
clk_set_rate(sys_clkout2, 12000000);
return 0;
......@@ -210,6 +218,7 @@ static void n800_codec_put_clocks(struct device *dev)
{
clk_put(func96m_clk);
clk_put(sys_clkout2);
clk_put(sys_clkout2_src);
}
static int n800_codec_enable_clock(struct device *dev)
......
This diff is collapsed.
......@@ -14,6 +14,22 @@
#define __ARCH_ARM_OMAP_CLOCK_H
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;
};
#endif
struct clk {
struct list_head node;
......@@ -36,6 +52,9 @@ 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;
#endif
};
......@@ -94,6 +113,12 @@ extern int clk_get_usecount(struct clk *clk);
#define CLOCK_IN_OMAP343X (1 << 27)
#define PARENT_CONTROLS_CLOCK (1 << 28)
/* 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)
#define RATE_IN_24XX (RATE_IN_242X | RATE_IN_243X)
/* CM_CLKSEL2_PLL.CORE_CLK_SRC options (24XX) */
......
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