Skip to contentSkip to conversation

OPP layer: hide OPP implementation details

PATCH In review Kevin Hilman 3 participants 11 messages Dec 18, 2009 – Dec 22, 2009

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

v2 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 another accessor
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.

Tested on OMAP3EVM, RX51

Changes from v1:
- actually works
- Fix SRF indexing after initial terminators were removed
- dropped opp_find_by_index() in favor of changing SRF remove indexing.

Kevin Hilman (4):
OMAP OPP: Add accessor function for getting OPP ID.
OMAP SRF: adjust OPP array access
OMAP SR/SRF: use OPP API for OPP ID, remove direct access OMAP OPP: hide struct omap_opp internals in OPP layer implementation

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

PATCH v2 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 e7b6f2a..4f7fa22 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 v2 2/4 OMAP SRF: adjust OPP array access

With the initial terminators removed from the OPP struct arrarys, the direct indexing of the array needs to be adjusted by one.

---
 arch/arm/mach-omap2/resource34xx.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-omap2/resource34xx.c +2 -2
index 05e70b7..1fa8bb5 100644
@@ -337,8 +337,8 @@ static int program_opp(int res, struct omap_opp *opp, int target_level,
 #ifdef CONFIG_OMAP_SMARTREFLEX
 	unsigned long t_opp, c_opp;
 
-	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);
+	t_opp = ID_VDD(res) | ID_OPP_NO(opp[target_level - 1].opp_id);
+	c_opp = ID_VDD(res) | ID_OPP_NO(opp[current_level - 1].opp_id);
 #endif
 
 	/* See if have a freq associated, if not, invalid opp */
Signature · 1 line
1.6.6.rc2.1.g42108
#3 lore raw

PATCH v2 3/4 OMAP SR/SRF: use OPP API for OPP ID, remove direct access

SR and SRF currenly direclty access OPP struct internals. Use new accessor function to get OPP ID.

Also SRF was doing doing direct access of the OPP struct array using a convoluted conversion from a 'level' to an OPP ID, when they're actually the same thing.

---
 arch/arm/mach-omap2/resource34xx.c |    6 +++---
 arch/arm/mach-omap2/smartreflex.c  |    4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)
arch/arm/mach-omap2/resource34xx.c +3 -3
index 1fa8bb5..31b8af2 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;
 }
 
@@ -337,8 +337,8 @@ static int program_opp(int res, struct omap_opp *opp, int target_level,
 #ifdef CONFIG_OMAP_SMARTREFLEX
 	unsigned long t_opp, c_opp;
 
-	t_opp = ID_VDD(res) | ID_OPP_NO(opp[target_level - 1].opp_id);
-	c_opp = ID_VDD(res) | ID_OPP_NO(opp[current_level - 1].opp_id);
+	t_opp = ID_VDD(res) | ID_OPP_NO(target_level - 1);
+	c_opp = ID_VDD(res) | ID_OPP_NO(current_level - 1);
 #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 v2 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 6fe574c..9f91ad3 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 4f7fa22..4fe1933 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
Acked-by on v2 4/4
#5 lore raw

Re: [PATCH v2 4/4] OMAP OPP: hide struct omap_opp internals in OPP layer implementation

Kevin Hilman said the following on 12/19/2009 04:35 AM:

Quoted 61 lines

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 6fe574c..9f91ad3 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 +12 -0
index 4f7fa22..4fe1933 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
+ */

arch/arm/plat-omap/opp.c line 43

Quoted 10 lines
arch/arm/plat-omap/opp.c +7 -0
+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

big time ACK if we can fix the 2/3 patch

Thanks.

Regards,
Nishanth Menon

#6 lore raw

Re: [PATCH v2 3/4] OMAP SR/SRF: use OPP API for OPP ID, remove direct access

In reply to Kevin Hilman

Kevin Hilman said the following on 12/19/2009 04:35 AM:

Quoted 27 lines

SR and SRF currenly direclty access OPP struct internals. Use new accessor function to get OPP ID.

Also SRF was doing doing direct access of the OPP struct array using a convoluted conversion from a 'level' to an OPP ID, when they're actually the same thing.

---
 arch/arm/mach-omap2/resource34xx.c |    6 +++---
 arch/arm/mach-omap2/smartreflex.c  |    4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)
arch/arm/mach-omap2/resource34xx.c +1 -1
index 1fa8bb5..31b8af2 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;
 }
 

arch/arm/mach-omap2/resource34xx.c static int program_opp(int res, struct omap_opp *opp, int target_level, · line 342

Quoted 8 lines
arch/arm/mach-omap2/resource34xx.c +2 -2
@@ -337,8 +337,8 @@ static int program_opp(int res, struct omap_opp *opp, int target_level,
 #ifdef CONFIG_OMAP_SMARTREFLEX
 	unsigned long t_opp, c_opp;
 
-	t_opp = ID_VDD(res) | ID_OPP_NO(opp[target_level - 1].opp_id);
-	c_opp = ID_VDD(res) | ID_OPP_NO(opp[current_level - 1].opp_id);
+	t_opp = ID_VDD(res) | ID_OPP_NO(target_level - 1);
+	c_opp = ID_VDD(res) | ID_OPP_NO(current_level - 1);
 

not sure of this.
target_level = 3,
opp[target_level - 1].opp_id ==3
BUT,
target_level -1 = 2

these are not the same.

Quoted 26 lines
arch/arm/mach-omap2/resource34xx.c +0 -0
 #endif
 
arch/arm/mach-omap2/resource34xx.c +0 -0
 	/* 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);
 }
 
 
#7 lore raw

Re: [PATCH v2 3/4] OMAP SR/SRF: use OPP API for OPP ID, remove direct access

Quoted 33 lines · Nishanth

Kevin Hilman said the following on 12/19/2009 04:35 AM:

Quoted 32 lines

SR and SRF currenly direclty access OPP struct internals. Use new accessor function to get OPP ID.

Also SRF was doing doing direct access of the OPP struct array using a convoluted conversion from a 'level' to an OPP ID, when they're actually the same thing.

---
 arch/arm/mach-omap2/resource34xx.c |    6 +++---
 arch/arm/mach-omap2/smartreflex.c  |    4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)
arch/arm/mach-omap2/resource34xx.c +1 -1
index 1fa8bb5..31b8af2 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;
 }
 @@ -337,8 +337,8 @@ static int program_opp(int res, struct omap_opp

*opp, int target_level,
#ifdef CONFIG_OMAP_SMARTREFLEX

arch/arm/mach-omap2/resource34xx.c +1 -1
 	unsigned long t_opp, c_opp;
 -	t_opp = ID_VDD(res) | ID_OPP_NO(opp[target_level - 1].opp_id);
-	c_opp = ID_VDD(res) | ID_OPP_NO(opp[current_level - 1].opp_id);
+	t_opp = ID_VDD(res) | ID_OPP_NO(target_level - 1);
Quoted 8 lines

arch/arm/mach-omap2/resource34xx.c static int program_opp(int res, struct omap_opp *opp, int target_level, · line 341

Quoted 2 lines
arch/arm/mach-omap2/resource34xx.c +1 -0
+	c_opp = ID_VDD(res) | ID_OPP_NO(current_level - 1);

not sure of this.
target_level = 3,
opp[target_level - 1].opp_id ==3
BUT,
target_level -1 = 2
these are not the same.

Hmm, good catch.

Now that it's not being used as index into OPP array, I should be using target level directly.

Will update in pm-wip-opp.

Kevin

Quoted 25 lines
Quoted 14 lines

#endif
/* See if have a freq associated, if not, invalid opp */

arch/arm/mach-omap2/smartreflex.c +1 -0
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)

arch/arm/mach-omap2/smartreflex.c static u8 get_vdd2_opp(void) · line 179

Quoted 6 lines
arch/arm/mach-omap2/smartreflex.c +1 -0
@@ -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);
 }
 

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Acked-by on v2 2/4
#8 lore raw

Re: [PATCH v2 2/4] OMAP SRF: adjust OPP array access

In reply to Kevin Hilman

Kevin Hilman said the following on 12/19/2009 04:35 AM:

Quoted 13 lines

With the initial terminators removed from the OPP struct arrarys, the direct indexing of the array needs to be adjusted by one.

---
 arch/arm/mach-omap2/resource34xx.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-omap2/resource34xx.c +0 -0
index 05e70b7..1fa8bb5 100644

arch/arm/mach-omap2/resource34xx.c static int program_opp(int res, struct omap_opp *opp, int target_level, · line 343

Quoted 9 lines
arch/arm/mach-omap2/resource34xx.c +2 -2
@@ -337,8 +337,8 @@ static int program_opp(int res, struct omap_opp *opp, int target_level,
 #ifdef CONFIG_OMAP_SMARTREFLEX
 	unsigned long t_opp, c_opp;
 
-	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);
+	t_opp = ID_VDD(res) | ID_OPP_NO(opp[target_level - 1].opp_id);
+	c_opp = ID_VDD(res) | ID_OPP_NO(opp[current_level - 1].opp_id);
 #endif
 
Quoted 3 lines
arch/arm/mach-omap2/resource34xx.c +0 -0
 	/* See if have a freq associated, if not, invalid opp */
Acked-by on v2 1/4
#9 lore raw

Re: [PATCH v2 1/4] OMAP OPP: Add accessor function for getting OPP ID.

In reply to Kevin Hilman

Kevin Hilman said the following on 12/19/2009 04:35 AM:

Quoted 17 lines

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 +0 -0
index cdadf67..6fe574c 100644

arch/arm/plat-omap/include/plat/opp.h int opp_disable(struct omap_opp *opp); · line 247

Quoted 5 lines
arch/arm/plat-omap/include/plat/opp.h +1 -0
@@ -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);
 

Sigh.. ok... been trying to avoid this precisely :(

Quoted 20 lines
arch/arm/plat-omap/include/plat/opp.h +0 -0
 void opp_init_cpufreq_table(struct omap_opp *opps,
 			    struct cpufreq_frequency_table **table);
arch/arm/plat-omap/opp.c +5 -0
index e7b6f2a..4f7fa22 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;
#10 lore raw

Re: [PATCH v2 1/4] OMAP OPP: Add accessor function for getting OPP ID.

In reply to Kevin Hilman

Kevin,
Some comments below:

Quoted 5 lines · Kevin Hilman

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.

Let us not add a deprecated function. If we are fixing this let us fix it right the first time.

Quoted 9 lines
arch/arm/plat-omap/opp.c +5 -0
+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;