Skip to contentSkip to conversation

OPP layer: hide OPP implementation details

PATCH Superseded Kevin Hilman 1 participant 5 messages Dec 18, 2009

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover OPP layer: hide OPP implementation details

This series continues on top of Paul's OPP cleanup series and aims to completly hide the OPP layer implementation details.

To do this, a couple more temporary (a.k.a already deprecated) helper functions have been added so current SR/SRF code can still function.

The goal here is to allow continued OPP layer cleanup and possibly alternate implementations to be done in parallel with the ongoing SR/SRF rework efforts.

Unless I hear some objections, this series will be added onto my pm-wip-opp branch after some more thorough testing.

Kevin Hilman (4):
OMAP OPP: Add accessor function for getting OPP ID.
OMAP OPP: add helper function to find OPP by index
OMAP SR/SRF: use OPP API for OPP ID, find by index
OMAP OPP: hide struct omap_opp internals in OPP layer implementation

 arch/arm/mach-omap2/resource34xx.c    |   14 ++++++++--
 arch/arm/mach-omap2/smartreflex.c     |    4 +-
 arch/arm/plat-omap/include/plat/opp.h |   23 ++++-------------
 arch/arm/plat-omap/opp.c              |   43 +++++++++++++++++++++++++++++++++
 4 files changed, 61 insertions(+), 23 deletions(-)
#1 lore raw

PATCH 1/4 OMAP OPP: Add accessor function for getting OPP ID.

Add new function opp_get_opp_id() for finding the OPP ID of a given OPP. This allows us to further hide OPP layer details.

NOTE: OPP IDs are deprecated, and this function will eventually
be removed after all users of OPP IDs are removed.

---
 arch/arm/plat-omap/include/plat/opp.h |    1 +
 arch/arm/plat-omap/opp.c              |    5 +++++
 2 files changed, 6 insertions(+), 0 deletions(-)
arch/arm/plat-omap/include/plat/opp.h +1 -0
index cdadf67..6fe574c 100644
@@ -243,6 +243,7 @@ int opp_disable(struct omap_opp *opp);
 
 struct omap_opp * __deprecated opp_find_by_opp_id(struct omap_opp *opps,
 						  u8 opp_id);
+u8 __deprecated opp_get_opp_id(struct omap_opp *opp);
 
 void opp_init_cpufreq_table(struct omap_opp *opps,
 			    struct cpufreq_frequency_table **table);
arch/arm/plat-omap/opp.c +5 -0
index aaafc10..106ad92 100644
@@ -69,6 +69,11 @@ struct omap_opp * __deprecated opp_find_by_opp_id(struct omap_opp *opps,
 	return NULL;
 }
 
+u8 __deprecated opp_get_opp_id(struct omap_opp *opp)
+{
+	return opp->opp_id;
+}
+
 int opp_get_opp_count(struct omap_opp *oppl)
 {
 	u8 n = 0;
Signature · 1 line
1.6.6.rc2.1.g42108
#2 lore raw

PATCH 2/4 OMAP OPP: add helper function to find OPP by index

Current SRF code indexes directly into OPP array, add opp_find_by_index() to do equivalent so OPP layer details can be further hidden.

NOTE: This is temporary patch until SRF removal can be completed.

---
 arch/arm/plat-omap/include/plat/opp.h |    3 +++
 arch/arm/plat-omap/opp.c              |   19 +++++++++++++++++++
 2 files changed, 22 insertions(+), 0 deletions(-)
arch/arm/plat-omap/include/plat/opp.h +3 -0
index 6fe574c..038a5c0 100644
@@ -245,6 +245,9 @@ struct omap_opp * __deprecated opp_find_by_opp_id(struct omap_opp *opps,
 						  u8 opp_id);
 u8 __deprecated opp_get_opp_id(struct omap_opp *opp);
 
+struct omap_opp *__deprecated opp_find_by_index(struct omap_opp *opps,
+						u8 index);
+
 void opp_init_cpufreq_table(struct omap_opp *opps,
 			    struct cpufreq_frequency_table **table);
 
arch/arm/plat-omap/opp.c +19 -0
index 106ad92..71b021b 100644
@@ -90,6 +90,25 @@ int opp_get_opp_count(struct omap_opp *oppl)
 	return n;
 }
 
+/**
+ * opp_find_by_opp_index - look up OPP by OPP ID (deprecated)
+ * @opps: pointer to an array of struct omap_opp
+ *
+ * Returns the struct omap_opp pointer corresponding to the given
+ * array index.
+ */
+struct omap_opp *__deprecated opp_find_by_index(struct omap_opp *opps,
+						u8 index)
+{
+	if (!opps)
+		return NULL;
+
+	if (index >= opp_get_opp_count(opps))
+		return NULL;
+
+	return &opps[index];
+}
+
 struct omap_opp *opp_find_freq_exact(struct omap_opp *oppl,
 				     unsigned long freq, bool enabled)
 {
Signature · 1 line
1.6.6.rc2.1.g42108
#3 lore raw

PATCH 3/4 OMAP SR/SRF: use OPP API for OPP ID, find by index

SR and SRF currenly direclty access OPP struct internals. Use new accessor functions so OPP layer details can be further hidden.

---
 arch/arm/mach-omap2/resource34xx.c |   14 +++++++++++---
 arch/arm/mach-omap2/smartreflex.c  |    4 ++--
 2 files changed, 13 insertions(+), 5 deletions(-)
arch/arm/mach-omap2/resource34xx.c +11 -3
index 05e70b7..b80ee88 100644
@@ -204,7 +204,7 @@ static int __deprecated freq_to_opp(u8 *opp_id, struct omap_opp *opps,
 	opp = opp_find_freq_ceil(opps, &freq);
 	if (IS_ERR(opp))
 		return -EINVAL;
-	*opp_id = opp->opp_id;
+	*opp_id = opp_get_opp_id(opp);
 	return 0;
 }
 
@@ -336,9 +336,17 @@ static int program_opp(int res, struct omap_opp *opp, int target_level,
 	unsigned long freq;
 #ifdef CONFIG_OMAP_SMARTREFLEX
 	unsigned long t_opp, c_opp;
+	int t_id, c_id;
+	struct omap_opp *opp_target, *opp_current;
 
-	t_opp = ID_VDD(res) | ID_OPP_NO(opp[target_level].opp_id);
-	c_opp = ID_VDD(res) | ID_OPP_NO(opp[current_level].opp_id);
+	opp_target = opp_find_by_index(opp, target_level);
+	t_id = opp_get_opp_id(opp_target);
+
+	opp_current = opp_find_by_index(opp, current_level);
+	c_id = opp_get_opp_id(opp_current);
+
+	t_opp = ID_VDD(res) | ID_OPP_NO(t_id);
+	c_opp = ID_VDD(res) | ID_OPP_NO(c_id);
 #endif
 
 	/* See if have a freq associated, if not, invalid opp */
arch/arm/mach-omap2/smartreflex.c +2 -2
index 9c0d5bf..d341857 100644
@@ -159,7 +159,7 @@ static u8 get_vdd1_opp(void)
 	if (IS_ERR(opp))
 		return 0;
 
-	return opp->opp_id;
+	return opp_get_opp_id(opp);
 }
 
 static u8 get_vdd2_opp(void)
@@ -174,7 +174,7 @@ static u8 get_vdd2_opp(void)
 	if (IS_ERR(opp))
 		return 0;
 
-	return opp->opp_id;
+	return opp_get_opp_id(opp);
 }
 
 
Signature · 1 line
1.6.6.rc2.1.g42108
#4 lore raw

PATCH 4/4 OMAP OPP: hide struct omap_opp internals in OPP layer implementation

Now that we have accessor/helper functions for all the OPP layer details, move 'struct omap_opp' into the OPP layer so no direct accesses to OPP internals can be done.

---
 arch/arm/plat-omap/include/plat/opp.h |   19 +------------------
 arch/arm/plat-omap/opp.c              |   19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 18 deletions(-)
arch/arm/plat-omap/include/plat/opp.h +1 -18
index 038a5c0..f049033 100644
@@ -17,24 +17,7 @@ extern struct omap_opp *mpu_opps;
 extern struct omap_opp *dsp_opps;
 extern struct omap_opp *l3_opps;
 
-/**
- * struct omap_opp - OMAP OPP description structure
- * @enabled:	true/false - marking this OPP as enabled/disabled
- * @rate:	Frequency in hertz
- * @opp_id:	(DEPRECATED) opp identifier
- * @u_volt:     minimum microvolts DC required for this OPP to function
- *
- * This structure stores the OPP information for a given domain.
- * Due to legacy reasons, this structure is currently exposed and
- * will soon be removed elsewhere and will only be used as a handle
- * from the OPP internal referencing mechanism
- */
-struct omap_opp {
-	bool enabled;
-	unsigned long rate;
-	unsigned long u_volt;
-	u8 __deprecated opp_id;
-};
+struct omap_opp;
 
 /**
  * opp_get_voltage() - Gets the voltage corresponding to an opp
arch/arm/plat-omap/opp.c +19 -0
index 71b021b..8e0df5d 100644
@@ -19,6 +19,25 @@
 #include <plat/opp_twl_tps.h>
 #include <plat/opp.h>
 
+/**
+ * struct omap_opp - OMAP OPP description structure
+ * @enabled:	true/false - marking this OPP as enabled/disabled
+ * @rate:	Frequency in hertz
+ * @opp_id:	(DEPRECATED) opp identifier
+ * @u_volt:     minimum microvolts DC required for this OPP to function
+ *
+ * This structure stores the OPP information for a given domain.
+ * Due to legacy reasons, this structure is currently exposed and
+ * will soon be removed elsewhere and will only be used as a handle
+ * from the OPP internal referencing mechanism
+ */
+struct omap_opp {
+	bool enabled;
+	unsigned long rate;
+	unsigned long u_volt;
+	u8 opp_id;
+};
+
 /*
  * DEPRECATED: Meant to detect end of opp array
  * This is meant to help co-exist with current SRF etc
Signature · 1 line
1.6.6.rc2.1.g42108