blob: d90aa4ceda9a6244ac452d0e2ebdbc2678219133 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* 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_RPM_RESOURCES_H
15#define __ARCH_ARM_MACH_MSM_RPM_RESOURCES_H
16
17#include <mach/rpm.h>
18#include "pm.h"
19
20
21struct msm_rpmrs_limits {
22 uint32_t pxo;
23 uint32_t l2_cache;
24 uint32_t vdd_mem_upper_bound;
25 uint32_t vdd_mem;
26 uint32_t vdd_dig_upper_bound;
27 uint32_t vdd_dig;
28
29 uint32_t latency_us[NR_CPUS];
30 uint32_t power[NR_CPUS];
31};
32
33enum {
34 MSM_RPMRS_PXO_OFF = 0,
35 MSM_RPMRS_PXO_ON = 1,
36};
37
38enum {
39 MSM_RPMRS_L2_CACHE_HSFS_OPEN = 0,
40 MSM_RPMRS_L2_CACHE_GDHS = 1,
41 MSM_RPMRS_L2_CACHE_RETENTION = 2,
42 MSM_RPMRS_L2_CACHE_ACTIVE = 3,
43};
44
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070045#define MSM_RPMRS_LIMITS(_pxo, _l2, _vdd_upper_b, _vdd) { \
46 MSM_RPMRS_PXO_##_pxo, \
47 MSM_RPMRS_L2_CACHE_##_l2, \
48 MSM_RPMRS_VDD_MEM_##_vdd_upper_b, \
49 MSM_RPMRS_VDD_MEM_##_vdd, \
50 MSM_RPMRS_VDD_DIG_##_vdd_upper_b, \
51 MSM_RPMRS_VDD_DIG_##_vdd, \
52 {0}, {0}, \
53}
54
55struct msm_rpmrs_level {
56 enum msm_pm_sleep_mode sleep_mode;
57 struct msm_rpmrs_limits rs_limits;
58 bool available;
59 uint32_t latency_us;
60 uint32_t steady_state_power;
61 uint32_t energy_overhead;
62 uint32_t time_overhead_us;
63};
64
65int msm_rpmrs_set(int ctx, struct msm_rpm_iv_pair *req, int count);
66int msm_rpmrs_set_noirq(int ctx, struct msm_rpm_iv_pair *req, int count);
67
68static inline int msm_rpmrs_set_nosleep(
69 int ctx, struct msm_rpm_iv_pair *req, int count)
70{
71 unsigned long flags;
72 int rc;
73
74 local_irq_save(flags);
75 rc = msm_rpmrs_set_noirq(ctx, req, count);
76 local_irq_restore(flags);
77
78 return rc;
79}
80
81int msm_rpmrs_clear(int ctx, struct msm_rpm_iv_pair *req, int count);
82int msm_rpmrs_clear_noirq(int ctx, struct msm_rpm_iv_pair *req, int count);
83
84static inline int msm_rpmrs_clear_nosleep(
85 int ctx, struct msm_rpm_iv_pair *req, int count)
86{
87 unsigned long flags;
88 int rc;
89
90 local_irq_save(flags);
91 rc = msm_rpmrs_clear_noirq(ctx, req, count);
92 local_irq_restore(flags);
93
94 return rc;
95}
96
97void msm_rpmrs_show_resources(void);
98
99struct msm_rpmrs_limits *msm_rpmrs_lowest_limits(
100 bool from_idle, enum msm_pm_sleep_mode sleep_mode, uint32_t latency_us,
101 uint32_t sleep_us);
102
103int msm_rpmrs_enter_sleep(uint32_t sclk_count, struct msm_rpmrs_limits *limits,
104 bool from_idle, bool notify_rpm);
Maheshkumar Sivasubramaniandd93ecf2011-09-15 19:39:14 -0600105void msm_rpmrs_exit_sleep(struct msm_rpmrs_limits *limits, bool from_idle,
106 bool notify_rpm, bool collapsed);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700107
108int msm_rpmrs_levels_init(struct msm_rpmrs_level *levels, int size);
109
110#endif /* __ARCH_ARM_MACH_MSM_RPM_RESOURCES_H */