blob: 8f60b137f21c0c3b38dbff6efde355347fdf9a46 [file] [log] [blame]
Brian Swetland600f7cf2008-09-09 11:04:14 -07001/* arch/arm/mach-msm/clock.h
2 *
3 * Copyright (C) 2007 Google, Inc.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004 * Copyright (c) 2007-2011, 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>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070021#include <linux/types.h>
Brian Swetland600f7cf2008-09-09 11:04:14 -070022#include <linux/list.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070023#include <linux/clkdev.h>
24#include <linux/spinlock.h>
25
Daniel Walker5e96da52010-05-12 13:43:28 -070026#include <mach/clk.h>
27
Brian Swetland600f7cf2008-09-09 11:04:14 -070028#define CLKFLAG_INVERT 0x00000001
29#define CLKFLAG_NOINVERT 0x00000002
30#define CLKFLAG_NONEST 0x00000004
31#define CLKFLAG_NORESET 0x00000008
32
Matt Wagantall22b0a792011-08-01 16:39:48 -070033#define CLKFLAG_SKIP_AUTO_OFF 0x00000200
Daniel Walker5e96da52010-05-12 13:43:28 -070034#define CLKFLAG_MIN 0x00000400
35#define CLKFLAG_MAX 0x00000800
36
37struct clk_ops {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070038 int (*enable)(struct clk *clk);
39 void (*disable)(struct clk *clk);
40 void (*auto_off)(struct clk *clk);
41 int (*reset)(struct clk *clk, enum clk_reset_action action);
42 int (*set_rate)(struct clk *clk, unsigned rate);
43 int (*set_min_rate)(struct clk *clk, unsigned rate);
44 int (*set_max_rate)(struct clk *clk, unsigned rate);
45 int (*set_flags)(struct clk *clk, unsigned flags);
46 unsigned (*get_rate)(struct clk *clk);
47 int (*list_rate)(struct clk *clk, unsigned n);
48 int (*is_enabled)(struct clk *clk);
49 long (*round_rate)(struct clk *clk, unsigned rate);
50 int (*set_parent)(struct clk *clk, struct clk *parent);
51 struct clk *(*get_parent)(struct clk *clk);
52 bool (*is_local)(struct clk *clk);
Daniel Walker5e96da52010-05-12 13:43:28 -070053};
Brian Swetland600f7cf2008-09-09 11:04:14 -070054
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070055/**
56 * struct clk
57 * @count: enable refcount
58 * @lock: protects clk_enable()/clk_disable() path and @count
59 */
Brian Swetland600f7cf2008-09-09 11:04:14 -070060struct clk {
Brian Swetland600f7cf2008-09-09 11:04:14 -070061 uint32_t flags;
Daniel Walker5e96da52010-05-12 13:43:28 -070062 struct clk_ops *ops;
63 const char *dbg_name;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070064
65 struct list_head children;
66 struct list_head siblings;
67
68 unsigned count;
69 spinlock_t lock;
Brian Swetland600f7cf2008-09-09 11:04:14 -070070};
71
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070072#define CLK_INIT(name) \
73 .lock = __SPIN_LOCK_UNLOCKED((name).lock), \
74 .children = LIST_HEAD_INIT((name).children), \
75 .siblings = LIST_HEAD_INIT((name).siblings)
76
77void msm_clock_init(struct clk_lookup *clock_tbl, size_t num_clocks);
78void msm7x30_clock_init(void);
79void msm8660_clock_init(void);
80void msm8960_clock_init(void);
81void msm8960_clock_init_dummy(void);
Brian Swetland600f7cf2008-09-09 11:04:14 -070082
Matt Wagantalld64560fe2011-01-26 16:20:54 -080083#ifdef CONFIG_DEBUG_FS
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070084int __init clock_debug_init(struct clk_lookup *clocks, unsigned num_clocks);
Matt Wagantalld64560fe2011-01-26 16:20:54 -080085int __init clock_debug_add(struct clk *clock);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070086void clock_debug_print_enabled(void);
Matt Wagantalld64560fe2011-01-26 16:20:54 -080087#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070088static inline int __init clock_debug_init(struct clk_lookup *clocks,
89 unsigned num_clocks) { return 0; }
Matt Wagantalld64560fe2011-01-26 16:20:54 -080090static inline int __init clock_debug_add(struct clk *clock) { return 0; }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070091static inline void clock_debug_print_enabled(void) { return; }
Matt Wagantalld64560fe2011-01-26 16:20:54 -080092#endif
93
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070094extern struct clk dummy_clk;
95
96#define CLK_DUMMY(clk_name, clk_id, clk_dev, flags) { \
97 .con_id = clk_name, \
98 .dev_id = clk_dev, \
99 .clk = &dummy_clk, \
100 }
101
102#define CLK_LOOKUP(con, c, dev) { .con_id = con, .clk = &c, .dev_id = dev }
103
Brian Swetland600f7cf2008-09-09 11:04:14 -0700104#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700105