blob: 2c007f606d2921e61d8692bd7a3e288cf08d588b [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;
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;
Brian Swetland600f7cf2008-09-09 11:04:14 -070057};
58
Daniel Walker5e96da52010-05-12 13:43:28 -070059#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)
Brian Swetland600f7cf2008-09-09 11:04:14 -070063
Matt Wagantalld64560fe2011-01-26 16:20:54 -080064#ifdef CONFIG_DEBUG_FS
65int __init clock_debug_init(void);
66int __init clock_debug_add(struct clk *clock);
67#else
68static inline int __init clock_debug_init(void) { return 0; }
69static inline int __init clock_debug_add(struct clk *clock) { return 0; }
70#endif
71
Brian Swetland600f7cf2008-09-09 11:04:14 -070072#endif