blob: da9d3ff42d35748c777a3dc629b1bae83d4d681f [file] [log] [blame]
Praveen Chidambaram78499012011-11-01 17:15:17 -06001/* 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_RPM_RESOURCES_H
15#define __ARCH_ARM_MACH_MSM_RPM_RESOURCES_H
16
17#include <mach/rpm.h>
Abhijeet Dharmapurikarefaca4f2011-12-27 16:24:07 -080018#include <mach/pm.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070019
Praveen Chidambaram78499012011-11-01 17:15:17 -060020enum {
21 MSM_RPMRS_ID_PXO_CLK = 0,
22 MSM_RPMRS_ID_L2_CACHE_CTL = 1,
23 MSM_RPMRS_ID_VDD_DIG_0 = 2,
24 MSM_RPMRS_ID_VDD_DIG_1 = 3,
25 MSM_RPMRS_ID_VDD_MEM_0 = 4,
26 MSM_RPMRS_ID_VDD_MEM_1 = 5,
27 MSM_RPMRS_ID_RPM_CTL = 6,
28 MSM_RPMRS_ID_LAST,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070029};
30
31enum {
32 MSM_RPMRS_PXO_OFF = 0,
33 MSM_RPMRS_PXO_ON = 1,
34};
35
36enum {
37 MSM_RPMRS_L2_CACHE_HSFS_OPEN = 0,
38 MSM_RPMRS_L2_CACHE_GDHS = 1,
39 MSM_RPMRS_L2_CACHE_RETENTION = 2,
40 MSM_RPMRS_L2_CACHE_ACTIVE = 3,
41};
42
Praveen Chidambaram9dfa8712011-09-14 16:25:01 -060043enum {
44 MSM_RPMRS_MASK_RPM_CTL_CPU_HALT = 1,
45 MSM_RPMRS_MASK_RPM_CTL_MULTI_TIER = 2,
46};
47
Praveen Chidambaram78499012011-11-01 17:15:17 -060048enum {
49 MSM_RPMRS_VDD_MEM_RET_LOW = 0,
50 MSM_RPMRS_VDD_MEM_RET_HIGH = 1,
51 MSM_RPMRS_VDD_MEM_ACTIVE = 2,
52 MSM_RPMRS_VDD_MEM_MAX = 3,
53 MSM_RPMRS_VDD_MEM_LAST,
54};
55
56enum {
57 MSM_RPMRS_VDD_DIG_RET_LOW = 0,
58 MSM_RPMRS_VDD_DIG_RET_HIGH = 1,
59 MSM_RPMRS_VDD_DIG_ACTIVE = 2,
60 MSM_RPMRS_VDD_DIG_MAX = 3,
61 MSM_RPMRS_VDD_DIG_LAST,
62};
63
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070064#define MSM_RPMRS_LIMITS(_pxo, _l2, _vdd_upper_b, _vdd) { \
65 MSM_RPMRS_PXO_##_pxo, \
66 MSM_RPMRS_L2_CACHE_##_l2, \
67 MSM_RPMRS_VDD_MEM_##_vdd_upper_b, \
68 MSM_RPMRS_VDD_MEM_##_vdd, \
69 MSM_RPMRS_VDD_DIG_##_vdd_upper_b, \
70 MSM_RPMRS_VDD_DIG_##_vdd, \
71 {0}, {0}, \
72}
73
Praveen Chidambaram78499012011-11-01 17:15:17 -060074struct msm_rpmrs_limits {
75 uint32_t pxo;
76 uint32_t l2_cache;
77 uint32_t vdd_mem_upper_bound;
78 uint32_t vdd_mem;
79 uint32_t vdd_dig_upper_bound;
80 uint32_t vdd_dig;
81
82 uint32_t latency_us[NR_CPUS];
83 uint32_t power[NR_CPUS];
84};
85
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070086struct msm_rpmrs_level {
87 enum msm_pm_sleep_mode sleep_mode;
88 struct msm_rpmrs_limits rs_limits;
89 bool available;
90 uint32_t latency_us;
91 uint32_t steady_state_power;
92 uint32_t energy_overhead;
93 uint32_t time_overhead_us;
94};
95
Praveen Chidambaram78499012011-11-01 17:15:17 -060096struct msm_rpmrs_platform_data {
97 struct msm_rpmrs_level *levels;
98 unsigned int num_levels;
99 unsigned int vdd_mem_levels[MSM_RPMRS_VDD_MEM_LAST];
100 unsigned int vdd_dig_levels[MSM_RPMRS_VDD_DIG_LAST];
101 unsigned int vdd_mask;
102 unsigned int rpmrs_target_id[MSM_RPMRS_ID_LAST];
103};
104
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700105int msm_rpmrs_set(int ctx, struct msm_rpm_iv_pair *req, int count);
106int msm_rpmrs_set_noirq(int ctx, struct msm_rpm_iv_pair *req, int count);
Praveen Chidambaram9dfa8712011-09-14 16:25:01 -0600107int msm_rpmrs_set_bits_noirq(int ctx, struct msm_rpm_iv_pair *req, int count,
108 int *mask);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700109
110static inline int msm_rpmrs_set_nosleep(
111 int ctx, struct msm_rpm_iv_pair *req, int count)
112{
113 unsigned long flags;
114 int rc;
115
116 local_irq_save(flags);
117 rc = msm_rpmrs_set_noirq(ctx, req, count);
118 local_irq_restore(flags);
119
120 return rc;
121}
122
123int msm_rpmrs_clear(int ctx, struct msm_rpm_iv_pair *req, int count);
124int msm_rpmrs_clear_noirq(int ctx, struct msm_rpm_iv_pair *req, int count);
125
126static inline int msm_rpmrs_clear_nosleep(
127 int ctx, struct msm_rpm_iv_pair *req, int count)
128{
129 unsigned long flags;
130 int rc;
131
132 local_irq_save(flags);
133 rc = msm_rpmrs_clear_noirq(ctx, req, count);
134 local_irq_restore(flags);
135
136 return rc;
137}
138
139void msm_rpmrs_show_resources(void);
140
141struct msm_rpmrs_limits *msm_rpmrs_lowest_limits(
142 bool from_idle, enum msm_pm_sleep_mode sleep_mode, uint32_t latency_us,
143 uint32_t sleep_us);
144
145int msm_rpmrs_enter_sleep(uint32_t sclk_count, struct msm_rpmrs_limits *limits,
146 bool from_idle, bool notify_rpm);
Maheshkumar Sivasubramaniandd93ecf2011-09-15 19:39:14 -0600147void msm_rpmrs_exit_sleep(struct msm_rpmrs_limits *limits, bool from_idle,
148 bool notify_rpm, bool collapsed);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700149
Praveen Chidambaram78499012011-11-01 17:15:17 -0600150int msm_rpmrs_levels_init(struct msm_rpmrs_platform_data *data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700151
152#endif /* __ARCH_ARM_MACH_MSM_RPM_RESOURCES_H */