blob: 572fb34919bfeaf34df1ec56291aeb43e448bf04 [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
Praveen Chidambaram9dfa8712011-09-14 16:25:01 -060045enum {
46 MSM_RPMRS_MASK_RPM_CTL_CPU_HALT = 1,
47 MSM_RPMRS_MASK_RPM_CTL_MULTI_TIER = 2,
48};
49
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070050#define MSM_RPMRS_LIMITS(_pxo, _l2, _vdd_upper_b, _vdd) { \
51 MSM_RPMRS_PXO_##_pxo, \
52 MSM_RPMRS_L2_CACHE_##_l2, \
53 MSM_RPMRS_VDD_MEM_##_vdd_upper_b, \
54 MSM_RPMRS_VDD_MEM_##_vdd, \
55 MSM_RPMRS_VDD_DIG_##_vdd_upper_b, \
56 MSM_RPMRS_VDD_DIG_##_vdd, \
57 {0}, {0}, \
58}
59
60struct msm_rpmrs_level {
61 enum msm_pm_sleep_mode sleep_mode;
62 struct msm_rpmrs_limits rs_limits;
63 bool available;
64 uint32_t latency_us;
65 uint32_t steady_state_power;
66 uint32_t energy_overhead;
67 uint32_t time_overhead_us;
68};
69
70int msm_rpmrs_set(int ctx, struct msm_rpm_iv_pair *req, int count);
71int msm_rpmrs_set_noirq(int ctx, struct msm_rpm_iv_pair *req, int count);
Praveen Chidambaram9dfa8712011-09-14 16:25:01 -060072int msm_rpmrs_set_bits_noirq(int ctx, struct msm_rpm_iv_pair *req, int count,
73 int *mask);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070074
75static inline int msm_rpmrs_set_nosleep(
76 int ctx, struct msm_rpm_iv_pair *req, int count)
77{
78 unsigned long flags;
79 int rc;
80
81 local_irq_save(flags);
82 rc = msm_rpmrs_set_noirq(ctx, req, count);
83 local_irq_restore(flags);
84
85 return rc;
86}
87
88int msm_rpmrs_clear(int ctx, struct msm_rpm_iv_pair *req, int count);
89int msm_rpmrs_clear_noirq(int ctx, struct msm_rpm_iv_pair *req, int count);
90
91static inline int msm_rpmrs_clear_nosleep(
92 int ctx, struct msm_rpm_iv_pair *req, int count)
93{
94 unsigned long flags;
95 int rc;
96
97 local_irq_save(flags);
98 rc = msm_rpmrs_clear_noirq(ctx, req, count);
99 local_irq_restore(flags);
100
101 return rc;
102}
103
104void msm_rpmrs_show_resources(void);
105
106struct msm_rpmrs_limits *msm_rpmrs_lowest_limits(
107 bool from_idle, enum msm_pm_sleep_mode sleep_mode, uint32_t latency_us,
108 uint32_t sleep_us);
109
110int msm_rpmrs_enter_sleep(uint32_t sclk_count, struct msm_rpmrs_limits *limits,
111 bool from_idle, bool notify_rpm);
Maheshkumar Sivasubramaniandd93ecf2011-09-15 19:39:14 -0600112void msm_rpmrs_exit_sleep(struct msm_rpmrs_limits *limits, bool from_idle,
113 bool notify_rpm, bool collapsed);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700114
115int msm_rpmrs_levels_init(struct msm_rpmrs_level *levels, int size);
116
117#endif /* __ARCH_ARM_MACH_MSM_RPM_RESOURCES_H */