blob: 00310f21e84fe86109a39eb7204d355db5c68e19 [file] [log] [blame]
Russell Kinga09e64f2008-08-05 16:14:15 +01001/*
2 * arch/arm/plat-omap/include/mach/clock.h
3 *
4 * Copyright (C) 2004 - 2005 Nokia corporation
5 * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>
6 * Based on clocks.h by Tony Lindgren, Gordon McNutt and RidgeRun, Inc
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#ifndef __ARCH_ARM_OMAP_CLOCK_H
14#define __ARCH_ARM_OMAP_CLOCK_H
15
Paul Walmsleyd8a94452009-12-08 16:21:29 -070016#include <linux/list.h>
17
Russell Kinga09e64f2008-08-05 16:14:15 +010018struct module;
19struct clk;
Paul Walmsleyd1b03f62008-08-19 11:08:44 +030020struct clockdomain;
Russell Kinga09e64f2008-08-05 16:14:15 +010021
Russell King548d8492008-11-04 14:02:46 +000022struct clkops {
23 int (*enable)(struct clk *);
24 void (*disable)(struct clk *);
Paul Walmsley72350b22009-07-24 19:44:03 -060025 void (*find_idlest)(struct clk *, void __iomem **, u8 *);
26 void (*find_companion)(struct clk *, void __iomem **, u8 *);
Russell King548d8492008-11-04 14:02:46 +000027};
28
Santosh Shilimkar44169072009-05-28 14:16:04 -070029#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) || \
30 defined(CONFIG_ARCH_OMAP4)
Russell Kinga09e64f2008-08-05 16:14:15 +010031
32struct clksel_rate {
Russell Kinga09e64f2008-08-05 16:14:15 +010033 u32 val;
Russell Kingebb8dca2008-11-04 21:50:46 +000034 u8 div;
Russell Kinga09e64f2008-08-05 16:14:15 +010035 u8 flags;
36};
37
38struct clksel {
39 struct clk *parent;
40 const struct clksel_rate *rates;
41};
42
43struct dpll_data {
44 void __iomem *mult_div1_reg;
45 u32 mult_mask;
46 u32 div1_mask;
Russell Kingc0bf3132009-02-19 13:29:22 +000047 struct clk *clk_bypass;
48 struct clk *clk_ref;
49 void __iomem *control_reg;
50 u32 enable_mask;
Russell Kingebb8dca2008-11-04 21:50:46 +000051 unsigned int rate_tolerance;
52 unsigned long last_rounded_rate;
Russell Kinga09e64f2008-08-05 16:14:15 +010053 u16 last_rounded_m;
54 u8 last_rounded_n;
Paul Walmsley95f538a2009-01-28 12:08:44 -070055 u8 min_divider;
Russell Kinga09e64f2008-08-05 16:14:15 +010056 u8 max_divider;
57 u32 max_tolerance;
Russell Kingebb8dca2008-11-04 21:50:46 +000058 u16 max_multiplier;
Santosh Shilimkar44169072009-05-28 14:16:04 -070059#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
Russell Kinga09e64f2008-08-05 16:14:15 +010060 u8 modes;
Russell Kingebb8dca2008-11-04 21:50:46 +000061 void __iomem *autoidle_reg;
62 void __iomem *idlest_reg;
Russell Kingebb8dca2008-11-04 21:50:46 +000063 u32 autoidle_mask;
Paul Walmsley16c90f02009-01-27 19:12:47 -070064 u32 freqsel_mask;
Paul Walmsleyc1bd7aa2009-01-28 12:08:17 -070065 u32 idlest_mask;
Russell Kinga09e64f2008-08-05 16:14:15 +010066 u8 auto_recal_bit;
67 u8 recal_en_bit;
68 u8 recal_st_bit;
Russell Kinga09e64f2008-08-05 16:14:15 +010069# endif
70};
71
72#endif
73
74struct clk {
75 struct list_head node;
Russell King548d8492008-11-04 14:02:46 +000076 const struct clkops *ops;
Russell Kinga09e64f2008-08-05 16:14:15 +010077 const char *name;
78 int id;
79 struct clk *parent;
Russell King3f0a8202009-01-31 10:05:51 +000080 struct list_head children;
81 struct list_head sibling; /* node for children */
Russell Kinga09e64f2008-08-05 16:14:15 +010082 unsigned long rate;
83 __u32 flags;
84 void __iomem *enable_reg;
Russell King8b9dbc12009-02-12 10:12:59 +000085 unsigned long (*recalc)(struct clk *);
Russell Kinga09e64f2008-08-05 16:14:15 +010086 int (*set_rate)(struct clk *, unsigned long);
87 long (*round_rate)(struct clk *, unsigned long);
88 void (*init)(struct clk *);
Russell Kingebb8dca2008-11-04 21:50:46 +000089 __u8 enable_bit;
90 __s8 usecount;
Santosh Shilimkar44169072009-05-28 14:16:04 -070091#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) || \
92 defined(CONFIG_ARCH_OMAP4)
Russell Kinga09e64f2008-08-05 16:14:15 +010093 u8 fixed_div;
94 void __iomem *clksel_reg;
95 u32 clksel_mask;
96 const struct clksel *clksel;
97 struct dpll_data *dpll_data;
Paul Walmsleyd1b03f62008-08-19 11:08:44 +030098 const char *clkdm_name;
99 struct clockdomain *clkdm;
Russell Kinga09e64f2008-08-05 16:14:15 +0100100#else
101 __u8 rate_offset;
102 __u8 src_offset;
103#endif
104#if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)
105 struct dentry *dent; /* For visible tree hierarchy */
106#endif
107};
108
109struct cpufreq_frequency_table;
110
111struct clk_functions {
112 int (*clk_enable)(struct clk *clk);
113 void (*clk_disable)(struct clk *clk);
114 long (*clk_round_rate)(struct clk *clk, unsigned long rate);
115 int (*clk_set_rate)(struct clk *clk, unsigned long rate);
116 int (*clk_set_parent)(struct clk *clk, struct clk *parent);
Russell Kinga09e64f2008-08-05 16:14:15 +0100117 void (*clk_allow_idle)(struct clk *clk);
118 void (*clk_deny_idle)(struct clk *clk);
119 void (*clk_disable_unused)(struct clk *clk);
120#ifdef CONFIG_CPU_FREQ
121 void (*clk_init_cpufreq_table)(struct cpufreq_frequency_table **);
122#endif
123};
124
125extern unsigned int mpurate;
126
Paul Walmsleyfecb4942009-01-27 19:12:50 -0700127extern int clk_init(struct clk_functions *custom_clocks);
Paul Walmsley79716872009-05-12 17:50:30 -0600128extern void clk_preinit(struct clk *clk);
Russell Kinga09e64f2008-08-05 16:14:15 +0100129extern int clk_register(struct clk *clk);
Russell King3f0a8202009-01-31 10:05:51 +0000130extern void clk_reparent(struct clk *child, struct clk *parent);
Russell Kinga09e64f2008-08-05 16:14:15 +0100131extern void clk_unregister(struct clk *clk);
132extern void propagate_rate(struct clk *clk);
133extern void recalculate_root_clocks(void);
Russell King8b9dbc12009-02-12 10:12:59 +0000134extern unsigned long followparent_recalc(struct clk *clk);
Russell Kinga09e64f2008-08-05 16:14:15 +0100135extern void clk_enable_init_clocks(void);
Kevin Hilmanaeec2992009-01-27 19:13:38 -0700136#ifdef CONFIG_CPU_FREQ
137extern void clk_init_cpufreq_table(struct cpufreq_frequency_table **table);
138#endif
Russell Kinga09e64f2008-08-05 16:14:15 +0100139
Russell King897dcde2008-11-04 16:35:03 +0000140extern const struct clkops clkops_null;
141
Russell Kinga09e64f2008-08-05 16:14:15 +0100142/* Clock flags */
Russell Kingd5e60722009-02-08 16:07:46 +0000143/* bit 0 is free */
Russell Kinga09e64f2008-08-05 16:14:15 +0100144#define RATE_FIXED (1 << 1) /* Fixed clock rate */
Russell King3f0a8202009-01-31 10:05:51 +0000145/* bits 2-4 are free */
Russell Kinga09e64f2008-08-05 16:14:15 +0100146#define ENABLE_REG_32BIT (1 << 5) /* Use 32-bit access */
Russell Kinga09e64f2008-08-05 16:14:15 +0100147#define CLOCK_IDLE_CONTROL (1 << 7)
148#define CLOCK_NO_IDLE_PARENT (1 << 8)
149#define DELAYED_APP (1 << 9) /* Delay application of clock */
150#define CONFIG_PARTICIPANT (1 << 10) /* Fundamental clock */
151#define ENABLE_ON_INIT (1 << 11) /* Enable upon framework init */
152#define INVERT_ENABLE (1 << 12) /* 0 enables, 1 disables */
Russell King44dc9d02009-01-19 15:51:11 +0000153/* bits 13-31 are currently free */
Russell Kinga09e64f2008-08-05 16:14:15 +0100154
155/* Clksel_rate flags */
156#define DEFAULT_RATE (1 << 0)
157#define RATE_IN_242X (1 << 1)
158#define RATE_IN_243X (1 << 2)
159#define RATE_IN_343X (1 << 3) /* rates common to all 343X */
160#define RATE_IN_3430ES2 (1 << 4) /* 3430ES2 rates only */
161
162#define RATE_IN_24XX (RATE_IN_242X | RATE_IN_243X)
163
164
Russell Kinga09e64f2008-08-05 16:14:15 +0100165#endif