1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
Adds init/change_level/validate_level calls for OMAP3 resources
Signed-off-by: Rajendra Nayak <rnayak@ti.com>
---
arch/arm/mach-omap2/resource34xx.c | 148 +++++++++++++++++++++++++++++++++++++
1 files changed, 148 insertions(+)
Index: linux-omap-2.6/arch/arm/mach-omap2/resource34xx.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-omap-2.6/arch/arm/mach-omap2/resource34xx.c 2008-08-07
15:07:04.000000000 +0530
@@ -0,0 +1,148 @@
+/*
+ * linux/arch/arm/mach-omap2/resource34xx.c
+ * OMAP3 resource init/change_level/validate_level functions
+ *
+ * Copyright (C) 2007-2008 Texas Instruments, Inc.
+ * Written by Rajendra Nayak <rnayak@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * History:
+ *
+ */
+
+#include <linux/pm_qos_params.h>
+#include <asm/arch/powerdomain.h>
+#include <asm/arch/clockdomain.h>
+#include "resource34xx.h"
+
+/**
+ * init_latency - Initializes the mpu/core latency resource.
+ * @resp: Latency resource to be initalized
+ *
+ * No return value.
+ */
+void init_latency(struct shared_resource *resp)
+{
+ resp->no_of_users = 0;
+ resp->curr_level = RES_DEFAULTLEVEL;
+ *((u8 *)resp->resource_data) = 0;
+ return;
+}
+
+/**
+ * set_latency - Adds/Updates and removes the CPU_DMA_LATENCY in *pm_qos_params.
+ * @resp: resource pointer
+ * @latency: target latency to be set
+ *
+ * Returns 0 on success, or error values as returned by
+ * pm_qos_update_requirement/pm_qos_add_requirement.
+ */
+int set_latency(struct shared_resource *resp, u32 latency)
+{
+ u8 *pm_qos_req_added;
+
+ if (resp->curr_level == latency)
+ return 0;
+ else
+ /* Update the resources current level */
+ resp->curr_level = latency;
+
+ pm_qos_req_added = resp->resource_data;
+ if (latency == RES_DEFAULTLEVEL)
+ /* No more users left, remove the pm_qos_req if present */
+ if (*pm_qos_req_added) {
+ pm_qos_remove_requirement(PM_QOS_CPU_DMA_LATENCY,
+ resp->name);
+ *pm_qos_req_added = 0;
+ return 0;
+ }
+
+ if (*pm_qos_req_added) {
+ return pm_qos_update_requirement(PM_QOS_CPU_DMA_LATENCY,
+ resp->name, latency);
+ } else {
+ *pm_qos_req_added = 1;
+ return pm_qos_add_requirement(PM_QOS_CPU_DMA_LATENCY,
+ resp->name, latency);
+ }
+}
+
+/**
+ * init_pd_latency - Initializes the power domain latency resource.
+ * @resp: Power Domain Latency resource to be initialized.
+ *
+ * No return value.
+ */
+void init_pd_latency(struct shared_resource *resp)
+{
+ struct pd_latency_db *pd_lat_db;
+
+ resp->no_of_users = 0;
+ resp->curr_level = PD_LATENCY_OFF;
+ pd_lat_db = resp->resource_data;
+ /* Populate the power domain associated with the latency resource */
+ pd_lat_db->pd = pwrdm_lookup(pd_lat_db->pwrdm_name);
+ return;
+}
+
+/**
+ * set_pd_latency - Updates the curr_level of the power domain resource.
+ * @resp: Power domain latency resource.
+ * @latency: New latency value acceptable.
+ *
+ * This function maps the latency in microsecs to the acceptable
+ * Power domain state using the latency DB.
+ * It then programs the power domain to enter the target state.
+ * Always returns 0.
+ */
+int set_pd_latency(struct shared_resource *resp, u32 latency)
+{
+ u32 pd_lat_level, ind, i;
+ struct pd_latency_db *pd_lat_db;
+ struct powerdomain *pwrdm;
+
+ pd_lat_db = resp->resource_data;
+ pwrdm = pd_lat_db->pd;
+ pd_lat_level = PD_LATENCY_OFF;
+ /* using the latency db map to the appropriate PD state */
+ for (ind = 0; ind < PD_LATENCY_MAXLEVEL; ind++)
+ if (pd_lat_db->latency[ind] < latency)
+ pd_lat_level = ind;
+
+ resp->curr_level = pd_lat_level;
+ switch (pd_lat_level) {
+ case PWRDM_POWER_OFF:
+ case PWRDM_POWER_RET:
+ /* Errata 1.29: No transitions from INACTIVE to RET/OFF
+ * possible.
+ * Need to be taken care of here.
+ */
+ if (pwrdm_read_pwrst(pwrdm) != PWRDM_POWER_ON) {
+ /* Force the clock domains to ON */
+ for (i = 0; pwrdm->pwrdm_clkdms[i]; i++) {
+ omap2_clkdm_deny_idle(pwrdm->pwrdm_clkdms[i]);
+ omap2_clkdm_wakeup(pwrdm->pwrdm_clkdms[i]);
+ }
+ pwrdm_set_next_pwrst(pwrdm, PWRDM_POWER_ON);
+ pwrdm_set_next_pwrst(pwrdm, pd_lat_level);
+ for (i = 0; pwrdm->pwrdm_clkdms[i]; i++) {
+ omap2_clkdm_sleep(pwrdm->pwrdm_clkdms[i]);
+ omap2_clkdm_allow_idle(pwrdm->pwrdm_clkdms[i]);
+ }
+ } else
+ pwrdm_set_next_pwrst(pwrdm, pd_lat_level);
+ break;
+ case PWRDM_POWER_ON:
+ pwrdm_set_next_pwrst(pwrdm, PWRDM_POWER_ON);
+ break;
+ default:
+ break;
+ }
+ return 0;
+}
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
|