blob: e7d84e5050a5e0f7d04d48f2a17c78d45a146bbb [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
33#define CLK_FIRST_AVAILABLE_FLAG 0x00000100
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070034#define CLKFLAG_SKIP_AUTO_OFF 0x00000200
Daniel Walker5e96da52010-05-12 13:43:28 -070035#define CLKFLAG_MIN 0x00000400
36#define CLKFLAG_MAX 0x00000800
37
38struct clk_ops {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070039 int (*enable)(struct clk *clk);
40 void (*disable)(struct clk *clk);
41 void (*auto_off)(struct clk *clk);
42 int (*reset)(struct clk *clk, enum clk_reset_action action);
43 int (*set_rate)(struct clk *clk, unsigned rate);
44 int (*set_min_rate)(struct clk *clk, unsigned rate);
45 int (*set_max_rate)(struct clk *clk, unsigned rate);
46 int (*set_flags)(struct clk *clk, unsigned flags);
47 unsigned (*get_rate)(struct clk *clk);
48 int (*list_rate)(struct clk *clk, unsigned n);
49 int (*is_enabled)(struct clk *clk);
50 long (*round_rate)(struct clk *clk, unsigned rate);
51 int (*set_parent)(struct clk *clk, struct clk *parent);
52 struct clk *(*get_parent)(struct clk *clk);
53 bool (*is_local)(struct clk *clk);
Daniel Walker5e96da52010-05-12 13:43:28 -070054};
Brian Swetland600f7cf2008-09-09 11:04:14 -070055
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070056/**
57 * struct clk
58 * @count: enable refcount
59 * @lock: protects clk_enable()/clk_disable() path and @count
60 */
Brian Swetland600f7cf2008-09-09 11:04:14 -070061struct clk {
Brian Swetland600f7cf2008-09-09 11:04:14 -070062 uint32_t flags;
Daniel Walker5e96da52010-05-12 13:43:28 -070063 struct clk_ops *ops;
64 const char *dbg_name;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070065
66 struct list_head children;
67 struct list_head siblings;
68
69 unsigned count;
70 spinlock_t lock;
Brian Swetland600f7cf2008-09-09 11:04:14 -070071};
72
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070073#define CLK_INIT(name) \
74 .lock = __SPIN_LOCK_UNLOCKED((name).lock), \
75 .children = LIST_HEAD_INIT((name).children), \
76 .siblings = LIST_HEAD_INIT((name).siblings)
77
78void msm_clock_init(struct clk_lookup *clock_tbl, size_t num_clocks);
79void msm7x30_clock_init(void);
80void msm8660_clock_init(void);
81void msm8960_clock_init(void);
82void msm8960_clock_init_dummy(void);
Brian Swetland600f7cf2008-09-09 11:04:14 -070083
Matt Wagantalld64560fe2011-01-26 16:20:54 -080084#ifdef CONFIG_DEBUG_FS
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070085int __init clock_debug_init(struct clk_lookup *clocks, unsigned num_clocks);
Matt Wagantalld64560fe2011-01-26 16:20:54 -080086int __init clock_debug_add(struct clk *clock);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070087void clock_debug_print_enabled(void);
Matt Wagantalld64560fe2011-01-26 16:20:54 -080088#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070089static inline int __init clock_debug_init(struct clk_lookup *clocks,
90 unsigned num_clocks) { return 0; }
Matt Wagantalld64560fe2011-01-26 16:20:54 -080091static inline int __init clock_debug_add(struct clk *clock) { return 0; }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070092static inline void clock_debug_print_enabled(void) { return; }
Matt Wagantalld64560fe2011-01-26 16:20:54 -080093#endif
94
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070095extern struct clk dummy_clk;
96
97#define CLK_DUMMY(clk_name, clk_id, clk_dev, flags) { \
98 .con_id = clk_name, \
99 .dev_id = clk_dev, \
100 .clk = &dummy_clk, \
101 }
102
103#define CLK_LOOKUP(con, c, dev) { .con_id = con, .clk = &c, .dev_id = dev }
104
Brian Swetland600f7cf2008-09-09 11:04:14 -0700105#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700106