1 /* arch/arm/mach-msm/clock.h
2  *
3  * Copyright (C) 2007 Google, Inc.
4  * Copyright (c) 2007-2010, Code Aurora Forum. All rights reserved.
5  *
6  * This software is licensed under the terms of the GNU General Public
7  * License version 2, as published by the Free Software Foundation, and
8  * may be copied, distributed, and modified under those terms.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  */
16 
17 #ifndef __ARCH_ARM_MACH_MSM_CLOCK_H
18 #define __ARCH_ARM_MACH_MSM_CLOCK_H
19 
20 #include <linux/init.h>
21 #include <linux/list.h>
22 #include <mach/clk.h>
23 
24 #define CLKFLAG_INVERT			0x00000001
25 #define CLKFLAG_NOINVERT		0x00000002
26 #define CLKFLAG_NONEST			0x00000004
27 #define CLKFLAG_NORESET			0x00000008
28 
29 #define CLK_FIRST_AVAILABLE_FLAG	0x00000100
30 #define CLKFLAG_AUTO_OFF		0x00000200
31 #define CLKFLAG_MIN			0x00000400
32 #define CLKFLAG_MAX			0x00000800
33 
34 struct clk_ops {
35 	int (*enable)(unsigned id);
36 	void (*disable)(unsigned id);
37 	void (*auto_off)(unsigned id);
38 	int (*reset)(unsigned id, enum clk_reset_action action);
39 	int (*set_rate)(unsigned id, unsigned rate);
40 	int (*set_min_rate)(unsigned id, unsigned rate);
41 	int (*set_max_rate)(unsigned id, unsigned rate);
42 	int (*set_flags)(unsigned id, unsigned flags);
43 	unsigned (*get_rate)(unsigned id);
44 	unsigned (*is_enabled)(unsigned id);
45 	long (*round_rate)(unsigned id, unsigned rate);
46 	bool (*is_local)(unsigned id);
47 };
48 
49 struct clk {
50 	uint32_t id;
51 	uint32_t remote_id;
52 	uint32_t count;
53 	uint32_t flags;
54 	struct clk_ops *ops;
55 	const char *dbg_name;
56 	struct list_head list;
57 };
58 
59 #define OFF CLKFLAG_AUTO_OFF
60 #define CLK_MIN CLKFLAG_MIN
61 #define CLK_MAX CLKFLAG_MAX
62 #define CLK_MINMAX (CLK_MIN | CLK_MAX)
63 
64 #ifdef CONFIG_DEBUG_FS
65 int __init clock_debug_init(void);
66 int __init clock_debug_add(struct clk *clock);
67 #else
clock_debug_init(void)68 static inline int __init clock_debug_init(void) { return 0; }
clock_debug_add(struct clk * clock)69 static inline int __init clock_debug_add(struct clk *clock) { return 0; }
70 #endif
71 
72 #endif
73