blob: b0d5693c70e012ab156a1885f698563ad30bca2b [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 Boyd72a80352012-01-26 15:57:38 -080070#define DEFINE_CLK_RPM_BRANCH(name, active, r_id, r) \
Stephen Boyda6835112012-01-26 14:40:05 -080071 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, \
Stephen Boyd72a80352012-01-26 15:57:38 -080076 .last_set_khz = ((r) / 1000), \
77 .last_set_sleep_khz = ((r) / 1000), \
Stephen Boyda6835112012-01-26 14:40:05 -080078 .branch = true, \
79 .c = { \
80 .ops = &clk_ops_rpm_branch, \
81 .flags = CLKFLAG_SKIP_AUTO_OFF, \
82 .dbg_name = #name, \
Stephen Boyd72a80352012-01-26 15:57:38 -080083 .rate = (r), \
Stephen Boyda6835112012-01-26 14:40:05 -080084 CLK_INIT(name.c), \
Stephen Boyd3bbf3462012-01-12 00:19:23 -080085 .warned = true, \
Stephen Boyda6835112012-01-26 14:40:05 -080086 }, \
87 }; \
88 static struct rpm_clk active = { \
89 .rpm_clk_id = MSM_RPM_ID_##r_id##_CLK, \
90 .rpm_status_id = MSM_RPM_STATUS_ID_##r_id##_CLK, \
91 .peer = &name, \
Stephen Boyd72a80352012-01-26 15:57:38 -080092 .last_set_khz = ((r) / 1000), \
Stephen Boyda6835112012-01-26 14:40:05 -080093 .active_only = true, \
94 .branch = true, \
95 .c = { \
96 .ops = &clk_ops_rpm_branch, \
97 .flags = CLKFLAG_SKIP_AUTO_OFF, \
98 .dbg_name = #active, \
Stephen Boyd72a80352012-01-26 15:57:38 -080099 .rate = (r), \
Stephen Boyda6835112012-01-26 14:40:05 -0800100 CLK_INIT(active.c), \
Stephen Boyd3bbf3462012-01-12 00:19:23 -0800101 .warned = true, \
Stephen Boyda6835112012-01-26 14:40:05 -0800102 }, \
103 };
104
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700105#endif