blob: 70216b0e96811484fb5310e4dfc3d3b6d527a9d9 [file] [log] [blame]
Brian Swetland600f7cf2008-09-09 11:04:14 -07001/* arch/arm/mach-msm/clock.h
2 *
3 * Copyright (C) 2007 Google, Inc.
Daniel Walker5e96da52010-05-12 13:43:28 -07004 * Copyright (c) 2007-2010, Code Aurora Forum. All rights reserved.
Brian Swetland600f7cf2008-09-09 11:04:14 -07005 *
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
Matt Wagantalld64560fe2011-01-26 16:20:54 -080020#include <linux/init.h>
Brian Swetland600f7cf2008-09-09 11:04:14 -070021#include <linux/list.h>
Daniel Walker5e96da52010-05-12 13:43:28 -070022#include <mach/clk.h>
23
Brian Swetland600f7cf2008-09-09 11:04:14 -070024#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
Daniel Walker5e96da52010-05-12 13:43:28 -070030#define CLKFLAG_AUTO_OFF 0x00000200
31#define CLKFLAG_MIN 0x00000400
32#define CLKFLAG_MAX 0x00000800
33
34struct 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};
Brian Swetland600f7cf2008-09-09 11:04:14 -070047
48struct clk {
49 uint32_t id;
Daniel Walker5e96da52010-05-12 13:43:28 -070050 uint32_t remote_id;
Brian Swetland600f7cf2008-09-09 11:04:14 -070051 uint32_t count;
52 uint32_t flags;
53 const char *name;
Daniel Walker5e96da52010-05-12 13:43:28 -070054 struct clk_ops *ops;
55 const char *dbg_name;
Brian Swetland600f7cf2008-09-09 11:04:14 -070056 struct list_head list;
57 struct device *dev;
58};
59
Daniel Walker5e96da52010-05-12 13:43:28 -070060#define OFF CLKFLAG_AUTO_OFF
61#define CLK_MIN CLKFLAG_MIN
62#define CLK_MAX CLKFLAG_MAX
63#define CLK_MINMAX (CLK_MIN | CLK_MAX)
Brian Swetland600f7cf2008-09-09 11:04:14 -070064
Matt Wagantalld64560fe2011-01-26 16:20:54 -080065#ifdef CONFIG_DEBUG_FS
66int __init clock_debug_init(void);
67int __init clock_debug_add(struct clk *clock);
68#else
69static inline int __init clock_debug_init(void) { return 0; }
70static inline int __init clock_debug_add(struct clk *clock) { return 0; }
71#endif
72
Brian Swetland600f7cf2008-09-09 11:04:14 -070073#endif