Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. |
| 2 | * |
| 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 | |
| 19 | struct clk_ops; |
| 20 | extern struct clk_ops clk_ops_rpm; |
| 21 | |
| 22 | struct rpm_clk { |
| 23 | const int rpm_clk_id; |
| 24 | const int rpm_status_id; |
| 25 | const bool active_only; |
| 26 | unsigned last_set_khz; |
| 27 | /* 0 if active_only. Otherwise, same as last_set_khz. */ |
| 28 | unsigned last_set_sleep_khz; |
| 29 | bool enabled; |
| 30 | |
| 31 | struct rpm_clk *peer; |
| 32 | struct clk c; |
| 33 | }; |
| 34 | |
| 35 | static inline struct rpm_clk *to_rpm_clk(struct clk *clk) |
| 36 | { |
| 37 | return container_of(clk, struct rpm_clk, c); |
| 38 | } |
| 39 | |
Matt Wagantall | 735f01a | 2011-08-12 12:40:28 -0700 | [diff] [blame^] | 40 | #define DEFINE_CLK_RPM(name, active, r_id, dep) \ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 41 | static struct rpm_clk active; \ |
| 42 | static struct rpm_clk name = { \ |
| 43 | .rpm_clk_id = MSM_RPM_ID_##r_id##_CLK, \ |
| 44 | .rpm_status_id = MSM_RPM_STATUS_ID_##r_id##_CLK, \ |
| 45 | .peer = &active, \ |
| 46 | .c = { \ |
| 47 | .ops = &clk_ops_rpm, \ |
| 48 | .flags = CLKFLAG_SKIP_AUTO_OFF | CLKFLAG_MIN, \ |
| 49 | .dbg_name = #name, \ |
| 50 | CLK_INIT(name.c), \ |
Matt Wagantall | 735f01a | 2011-08-12 12:40:28 -0700 | [diff] [blame^] | 51 | .depends = dep, \ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 52 | }, \ |
| 53 | }; \ |
| 54 | static struct rpm_clk active = { \ |
| 55 | .rpm_clk_id = MSM_RPM_ID_##r_id##_CLK, \ |
| 56 | .rpm_status_id = MSM_RPM_STATUS_ID_##r_id##_CLK, \ |
| 57 | .peer = &name, \ |
| 58 | .active_only = true, \ |
| 59 | .c = { \ |
| 60 | .ops = &clk_ops_rpm, \ |
| 61 | .flags = CLKFLAG_SKIP_AUTO_OFF | CLKFLAG_MIN, \ |
| 62 | .dbg_name = #active, \ |
| 63 | CLK_INIT(active.c), \ |
Matt Wagantall | 735f01a | 2011-08-12 12:40:28 -0700 | [diff] [blame^] | 64 | .depends = dep, \ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 65 | }, \ |
| 66 | }; |
| 67 | |
| 68 | #endif |