summaryrefslogtreecommitdiff
path: root/packages/linux/linux-omap2-git/beagleboard/06-omappm-opp-resource-modeling.eml
blob: 69ed0f748c4e12737cbc21b5a033b61490a928fe (plain)
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
Adds OPP/Frequency resources to SRF

Signed-off-by: Rajendra Nayak <rnayak@ti.com>
---
 arch/arm/mach-omap2/resource34xx.c |  101 +++++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/resource34xx.h |   74 +++++++++++++++++++++++++++
 2 files changed, 175 insertions(+)

Index: linux-omap-2.6/arch/arm/mach-omap2/resource34xx.c
===================================================================
--- linux-omap-2.6.orig/arch/arm/mach-omap2/resource34xx.c	2008-08-07
15:07:08.000000000 +0530
+++ linux-omap-2.6/arch/arm/mach-omap2/resource34xx.c	2008-08-07
15:09:01.000000000 +0530
@@ -146,3 +146,104 @@ int set_pd_latency(struct shared_resourc
 	}
 	return 0;
 }
+
+static struct clk *vdd1_clk;
+static struct clk *vdd2_clk;
+static struct device dummy_srf_dev;
+
+/**
+ * init_opp - Initialize the OPP resource
+ */
+void init_opp(struct shared_resource *resp)
+{
+	resp->no_of_users = 0;
+	/* Initialize the current level of the OPP resource
+	* to the  opp set by u-boot.
+	*/
+	if (strcmp(resp->name, "vdd1_opp") == 0) {
+		resp->curr_level = curr_vdd1_prcm_set->opp;
+		vdd1_clk = clk_get(NULL, "virt_vdd1_prcm_set");
+	} else if (strcmp(resp->name, "vdd2_opp") == 0) {
+		resp->curr_level = curr_vdd2_prcm_set->opp;
+		vdd2_clk = clk_get(NULL, "virt_vdd2_prcm_set");
+	}
+	return;
+}
+
+int set_opp(struct shared_resource *resp, u32 target_level)
+{
+#ifdef CONFIG_MACH_OMAP_3430SDP
+	unsigned long mpu_freq;
+	if (strcmp(resp->name, "vdd1_opp") == 0) {
+		mpu_freq = get_freq(vdd1_rate_table + MAX_VDD1_OPP,
+					target_level);
+		clk_set_rate(vdd1_clk, mpu_freq);
+		resp->curr_level = curr_vdd1_prcm_set->opp;
+	} else if (strcmp(resp->name, "vdd2_opp") == 0) {
+		/* Not supported yet */
+	}
+#endif
+	return 0;
+}
+
+/**
+ * validate_opp - Validates if valid VDD1 OPP's are passed as the
+ * target_level.
+ * VDD2 OPP levels are passed as L3 throughput, which are then mapped
+ * to an appropriate OPP.
+ */
+int validate_opp(struct shared_resource *resp, u32 target_level)
+{
+	return 0;
+}
+
+/**
+ * init_freq - Initialize the frequency resource.
+ */
+void init_freq(struct shared_resource *resp)
+{
+#ifdef CONFIG_MACH_OMAP_3430SDP
+	char *linked_res_name;
+	resp->no_of_users = 0;
+
+	linked_res_name = (char *)resp->resource_data;
+	/* Initialize the current level of the Freq resource
+	* to the frequency set by u-boot.
+	*/
+	if (strcmp(resp->name, "mpu_freq") == 0)
+		/* MPU freq in Mhz */
+		resp->curr_level = curr_vdd1_prcm_set->speed;
+	else if (strcmp(resp->name, "dsp_freq") == 0)
+		/* DSP freq in Mhz */
+		resp->curr_level = get_freq(iva2_rate_table + MAX_VDD2_OPP,
+						curr_vdd1_prcm_set->opp);
+#endif
+	return;
+}
+
+int set_freq(struct shared_resource *resp, u32 target_level)
+{
+#ifdef CONFIG_MACH_OMAP_3430SDP
+	unsigned int vdd1_opp;
+
+	if (strcmp(resp->name, "mpu_freq") == 0)
+		vdd1_opp = get_opp(vdd1_rate_table + MAX_VDD1_OPP,
+							target_level);
+	else if (strcmp(resp->name, "dsp_freq") == 0)
+		vdd1_opp = get_opp(iva2_rate_table + MAX_VDD1_OPP,
+							target_level);
+
+	if (vdd1_opp == MIN_VDD1_OPP)
+		resource_release("vdd1_opp", &dummy_srf_dev);
+	else
+		resource_request("vdd1_opp", &dummy_srf_dev, vdd1_opp);
+
+	resp->curr_level = target_level;
+#endif
+	return 0;
+}
+
+int validate_freq(struct shared_resource *resp, u32 target_level)
+{
+	return 0;
+}
Index: linux-omap-2.6/arch/arm/mach-omap2/resource34xx.h
===================================================================
--- linux-omap-2.6.orig/arch/arm/mach-omap2/resource34xx.h	2008-08-07
15:07:02.000000000 +0530
+++ linux-omap-2.6/arch/arm/mach-omap2/resource34xx.h	2008-08-07
15:31:42.000000000 +0530
@@ -22,8 +22,17 @@
 #define __ARCH_ARM_MACH_OMAP2_RESOURCE_H

 #include <asm/arch/resource.h>
+#include <linux/clk.h>
+#include <asm/arch/clock.h>
 #include <asm/arch/powerdomain.h>

+extern struct vdd_prcm_config *curr_vdd1_prcm_set;
+extern struct vdd_prcm_config *curr_vdd2_prcm_set;
+extern unsigned int get_freq(struct  vdd_prcm_config *, unsigned long);
+extern unsigned int get_opp(struct vdd_prcm_config *, unsigned long);
+extern struct vdd_prcm_config vdd1_rate_table[];
+extern struct vdd_prcm_config vdd2_rate_table[];
+extern struct vdd_prcm_config iva2_rate_table[];
 /**
  * mpu_latency/core_latency are used to control the cpuidle C state.
  */
@@ -207,6 +216,66 @@ static struct shared_resource emu_pwrdm_
 	.ops		= &pd_lat_res_ops,
 };

+void init_opp(struct shared_resource *resp);
+int set_opp(struct shared_resource *resp, u32 target_level);
+int validate_opp(struct shared_resource *resp, u32 target_level);
+void init_freq(struct shared_resource *resp);
+int set_freq(struct shared_resource *resp, u32 target_level);
+int validate_freq(struct shared_resource *resp, u32 target_level);
+
+struct bus_throughput_db {
+	/* Throughput for each OPP/Freq of the bus */
+	unsigned long throughput[3];
+};
+
+static struct shared_resource_ops opp_res_ops = {
+	.init           = init_opp,
+	.change_level   = set_opp,
+	.validate_level = validate_opp,
+};
+
+static struct shared_resource vdd1_opp = {
+	.name           = "vdd1_opp",
+	.omap_chip      = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
+	.ops            = &opp_res_ops,
+};
+
+/* Throughput in KiB/s */
+static struct bus_throughput_db l3_throughput_db = {
+	.throughput[0] = 0,
+	.throughput[1] = 100,
+	.throughput[2] = 250,
+};
+
+static struct shared_resource vdd2_opp = {
+	.name           = "vdd2_opp",
+	.omap_chip      = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
+	.resource_data  = &l3_throughput_db,
+	.ops            = &opp_res_ops,
+};
+
+static char linked_res[] = "vdd1_opp";
+
+static struct shared_resource_ops freq_res_ops = {
+	.init           = init_freq,
+	.change_level   = set_freq,
+	.validate_level = validate_freq,
+};
+
+static struct shared_resource mpu_freq = {
+	.name           = "mpu_freq",
+	.omap_chip      = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
+	.resource_data  = &linked_res,
+	.ops            = &freq_res_ops,
+};
+
+static struct shared_resource dsp_freq = {
+	.name           = "dsp_freq",
+	.omap_chip      = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
+	.resource_data  = &linked_res,
+	.ops            = &freq_res_ops,
+};
+
 struct shared_resource *resources_omap[] __initdata = {
 	&mpu_latency,
 	&core_latency,
@@ -220,6 +289,11 @@ struct shared_resource *resources_omap[]
 	&neon_pwrdm_latency,
 	&usbhost_pwrdm_latency,
 	&emu_pwrdm_latency,
+	/* OPP/frequency resources */
+	&vdd1_opp,
+	&vdd2_opp,
+	&mpu_freq,
+	&dsp_freq,
 	NULL
 };



--
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