blob: f4a7363d27f3d7f43e5cc2f6abe0758125ce428b [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
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070020#include <linux/types.h>
Brian Swetland600f7cf2008-09-09 11:04:14 -070021#include <linux/list.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070022#include <linux/clkdev.h>
23#include <linux/spinlock.h>
24
Daniel Walker5e96da52010-05-12 13:43:28 -070025#include <mach/clk.h>
26
Brian Swetland600f7cf2008-09-09 11:04:14 -070027#define CLKFLAG_INVERT 0x00000001
28#define CLKFLAG_NOINVERT 0x00000002
29#define CLKFLAG_NONEST 0x00000004
30#define CLKFLAG_NORESET 0x00000008
Matt Wagantall14dc2af2011-08-12 13:16:06 -070031#define CLKFLAG_HANDOFF_RATE 0x00000010
Matt Wagantall22b0a792011-08-01 16:39:48 -070032#define CLKFLAG_SKIP_AUTO_OFF 0x00000200
Daniel Walker5e96da52010-05-12 13:43:28 -070033#define CLKFLAG_MIN 0x00000400
34#define CLKFLAG_MAX 0x00000800
35
36struct clk_ops {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070037 int (*enable)(struct clk *clk);
38 void (*disable)(struct clk *clk);
39 void (*auto_off)(struct clk *clk);
Matt Wagantall271a6cd2011-09-20 16:06:31 -070040 int (*handoff)(struct clk *clk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070041 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
Stephen Boyd7fa26742011-08-11 23:22:29 -070059 * @depends: non-direct parent of clock to enable when this clock is enabled
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070060 */
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;
Stephen Boyd7fa26742011-08-11 23:22:29 -070065 struct clk *depends;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070066
67 struct list_head children;
68 struct list_head siblings;
69
70 unsigned count;
71 spinlock_t lock;
Brian Swetland600f7cf2008-09-09 11:04:14 -070072};
73
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070074#define CLK_INIT(name) \
75 .lock = __SPIN_LOCK_UNLOCKED((name).lock), \
76 .children = LIST_HEAD_INIT((name).children), \
77 .siblings = LIST_HEAD_INIT((name).siblings)
78
Stephen Boydbb600ae2011-08-02 20:11:40 -070079/**
80 * struct clock_init_data - SoC specific clock initialization data
81 * @table: table of lookups to add
82 * @size: size of @table
83 * @init: called before registering @table
84 * @late_init: called during late init
85 */
86struct clock_init_data {
87 struct clk_lookup *table;
88 size_t size;
89 void (*init)(void);
90 int (*late_init)(void);
91};
92
Vikram Mulukutla489e39e2011-08-31 18:04:05 -070093extern struct clock_init_data msm9615_clock_init_data;
Tianyi Gou41515e22011-09-01 19:37:43 -070094extern struct clock_init_data apq8064_clock_init_data;
Stephen Boydbb600ae2011-08-02 20:11:40 -070095extern struct clock_init_data apq8064_dummy_clock_init_data;
96extern struct clock_init_data fsm9xxx_clock_init_data;
97extern struct clock_init_data msm7x01a_clock_init_data;
98extern struct clock_init_data msm7x27_clock_init_data;
99extern struct clock_init_data msm7x27a_clock_init_data;
100extern struct clock_init_data msm7x30_clock_init_data;
101extern struct clock_init_data msm8960_clock_init_data;
102extern struct clock_init_data msm8960_dummy_clock_init_data;
103extern struct clock_init_data msm8x60_clock_init_data;
104extern struct clock_init_data qds8x50_clock_init_data;
105
106void msm_clock_init(struct clock_init_data *data);
Brian Swetland600f7cf2008-09-09 11:04:14 -0700107
Matt Wagantalld64560fe2011-01-26 16:20:54 -0800108#ifdef CONFIG_DEBUG_FS
Stephen Boydbb600ae2011-08-02 20:11:40 -0700109int clock_debug_init(struct clock_init_data *data);
110int clock_debug_add(struct clk *clock);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700111void clock_debug_print_enabled(void);
Matt Wagantalld64560fe2011-01-26 16:20:54 -0800112#else
Stephen Boydbb600ae2011-08-02 20:11:40 -0700113static inline int clock_debug_init(struct clk_init_data *data) { return 0; }
114static inline int clock_debug_add(struct clk *clock) { return 0; }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700115static inline void clock_debug_print_enabled(void) { return; }
Matt Wagantalld64560fe2011-01-26 16:20:54 -0800116#endif
117
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700118extern struct clk dummy_clk;
119
120#define CLK_DUMMY(clk_name, clk_id, clk_dev, flags) { \
121 .con_id = clk_name, \
122 .dev_id = clk_dev, \
123 .clk = &dummy_clk, \
124 }
125
126#define CLK_LOOKUP(con, c, dev) { .con_id = con, .clk = &c, .dev_id = dev }
127
Brian Swetland600f7cf2008-09-09 11:04:14 -0700128#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700129