blob: 27afd6fa3109b5987f45dffe37491b8900e246b1 [file] [log] [blame]
Stephen Boyda6835112012-01-26 14:40:05 -08001/* Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13
14#ifndef __ARCH_ARM_MACH_MSM_CLOCK_RPM_H
15#define __ARCH_ARM_MACH_MSM_CLOCK_RPM_H
16
17#include <mach/rpm.h>
18
19struct clk_ops;
20extern struct clk_ops clk_ops_rpm;
Stephen Boyda6835112012-01-26 14:40:05 -080021extern struct clk_ops clk_ops_rpm_branch;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070022
23struct rpm_clk {
24 const int rpm_clk_id;
25 const int rpm_status_id;
26 const bool active_only;
27 unsigned last_set_khz;
28 /* 0 if active_only. Otherwise, same as last_set_khz. */
29 unsigned last_set_sleep_khz;
30 bool enabled;
Stephen Boyda6835112012-01-26 14:40:05 -080031 bool branch; /* true: RPM only accepts 1 for ON and 0 for OFF */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070032
33 struct rpm_clk *peer;
34 struct clk c;
35};
36
37static inline struct rpm_clk *to_rpm_clk(struct clk *clk)
38{
39 return container_of(clk, struct rpm_clk, c);
40}
41
Matt Wagantall735f01a2011-08-12 12:40:28 -070042#define DEFINE_CLK_RPM(name, active, r_id, dep) \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070043 static struct rpm_clk active; \
44 static struct rpm_clk name = { \
45 .rpm_clk_id = MSM_RPM_ID_##r_id##_CLK, \
46 .rpm_status_id = MSM_RPM_STATUS_ID_##r_id##_CLK, \
47 .peer = &active, \
48 .c = { \
49 .ops = &clk_ops_rpm, \
Matt Wagantall77952c42011-11-08 18:45:48 -080050 .flags = CLKFLAG_SKIP_AUTO_OFF, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070051 .dbg_name = #name, \
52 CLK_INIT(name.c), \
Matt Wagantall735f01a2011-08-12 12:40:28 -070053 .depends = dep, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070054 }, \
55 }; \
56 static struct rpm_clk active = { \
57 .rpm_clk_id = MSM_RPM_ID_##r_id##_CLK, \
58 .rpm_status_id = MSM_RPM_STATUS_ID_##r_id##_CLK, \
59 .peer = &name, \
60 .active_only = true, \
61 .c = { \
62 .ops = &clk_ops_rpm, \
Matt Wagantall77952c42011-11-08 18:45:48 -080063 .flags = CLKFLAG_SKIP_AUTO_OFF, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070064 .dbg_name = #active, \
65 CLK_INIT(active.c), \
Matt Wagantall735f01a2011-08-12 12:40:28 -070066 .depends = dep, \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070067 }, \
68 };
69
Stephen Boyda6835112012-01-26 14:40:05 -080070#define DEFINE_CLK_RPM_BRANCH(name, active, r_id, rate) \
71 static struct rpm_clk active; \
72 static struct rpm_clk name = { \
73 .rpm_clk_id = MSM_RPM_ID_##r_id##_CLK, \
74 .rpm_status_id = MSM_RPM_STATUS_ID_##r_id##_CLK, \
75 .peer = &active, \
76 .last_set_khz = ((rate) / 1000), \
77 .last_set_sleep_khz = ((rate) / 1000), \
78 .branch = true, \
79 .c = { \
80 .ops = &clk_ops_rpm_branch, \
81 .flags = CLKFLAG_SKIP_AUTO_OFF, \
82 .dbg_name = #name, \
83 CLK_INIT(name.c), \
84 }, \
85 }; \
86 static struct rpm_clk active = { \
87 .rpm_clk_id = MSM_RPM_ID_##r_id##_CLK, \
88 .rpm_status_id = MSM_RPM_STATUS_ID_##r_id##_CLK, \
89 .peer = &name, \
90 .last_set_khz = ((rate) / 1000), \
91 .active_only = true, \
92 .branch = true, \
93 .c = { \
94 .ops = &clk_ops_rpm_branch, \
95 .flags = CLKFLAG_SKIP_AUTO_OFF, \
96 .dbg_name = #active, \
97 CLK_INIT(active.c), \
98 }, \
99 };
100
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700101#endif