Skip to contentSkip to conversation

OPP and Frequency resource modeling

PATCH In review Rajendra Nayak 1 participant 1 message Jul 8, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 7/9 OPP and Frequency resource modeling

Adds OPP/Frequency resources to Shared Resource F/w

---
 arch/arm/mach-omap2/resource34xx.c |  101 +++++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/resource34xx.h |   75 +++++++++++++++++++++++++++
 2 files changed, 176 insertions(+)
arch/arm/mach-omap2/resource34xx.c +101 -0
Index: linux-omap-2.6/arch/arm/mach-omap2/resource34xx.c
===================================================================
@@ -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;
+}
arch/arm/mach-omap2/resource34xx.h +75 -0

96 lines not on this page · raw message