blob: 8d302c7403a82a8b517f18796dfc7e37bd8280a4 [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);
Stephen Boyd2a522202011-02-23 09:37:41 -080046 bool (*is_local)(unsigned id);
Daniel Walker5e96da52010-05-12 13:43:28 -070047};
Brian Swetland600f7cf2008-09-09 11:04:14 -070048
49struct clk {
50 uint32_t id;
Daniel Walker5e96da52010-05-12 13:43:28 -070051 uint32_t remote_id;
Brian Swetland600f7cf2008-09-09 11:04:14 -070052 uint32_t count;
53 uint32_t flags;
54 const char *name;
Daniel Walker5e96da52010-05-12 13:43:28 -070055 struct clk_ops *ops;
56 const char *dbg_name;
Brian Swetland600f7cf2008-09-09 11:04:14 -070057 struct list_head list;
58 struct device *dev;
59};
60
Daniel Walker5e96da52010-05-12 13:43:28 -070061#define OFF CLKFLAG_AUTO_OFF
62#define CLK_MIN CLKFLAG_MIN
63#define CLK_MAX CLKFLAG_MAX
64#define CLK_MINMAX (CLK_MIN | CLK_MAX)
Brian Swetland600f7cf2008-09-09 11:04:14 -070065
Matt Wagantalld64560fe2011-01-26 16:20:54 -080066#ifdef CONFIG_DEBUG_FS
67int __init clock_debug_init(void);
68int __init clock_debug_add(struct clk *clock);
69#else
70static inline int __init clock_debug_init(void) { return 0; }
71static inline int __init clock_debug_add(struct clk *clock) { return 0; }
72#endif
73
Brian Swetland600f7cf2008-09-09 11:04:14 -070074#endif