OPP layer and additional cleanups.
Subsystems (2)
PATCH 2/10 OPP layer and additional cleanups.
Moving to list based OPP layer and its new semantics.
arch/arm/plat-omap/include/plat/opp.h +65 -200
@@ -2,9 +2,9 @@* OMAP OPP Interface * * Copyright (C) 2009 Texas Instruments Incorporated. -* Nishanth Menon -* Copyright (C) 2009 Deep Root Systems, LLC. -* Kevin Hilman +* Romit Dasgupta <[email protected]> +* Derived from the original series of patches by Nishanth Menon & +* Kevin Hilman. * * 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
@@ -13,223 +13,88 @@#ifndef __ASM_ARM_OMAP_OPP_H#define __ASM_ARM_OMAP_OPP_H -extern struct omap_opp *mpu_opps; -extern struct omap_opp *dsp_opps; -extern struct omap_opp *l3_opps; +#ifdef CONFIG_CPU_FREQ +#include <linux/cpufreq.h> +#endif -struct omap_opp ; +#define OPP_ENABLED (1 << 0) +#define OPP_DISABLED (1 << 1) +#define OPP_H (1 << 2) +#define OPP_L (1 << 3) +#define OPP_EQ (1 << 4) +#define OPP_ALL (OPP_ENABLED | OPP_DISABLED) -/** -* opp_get_voltage() - Gets the voltage corresponding to an opp -* @opp: opp for which voltage has to be returned for -* -* Return voltage in micro volt corresponding to the opp, else -* return 0 +/* +* XXX: Pending documentation. */ -unsigned long opp_get_voltage (const struct omap_opp *opp); -/** -* opp_get_freq() - Gets the frequency corresponding to an opp -* @opp: opp for which frequency has to be returned for -* -* Return frequency in hertz corresponding to the opp, else -* return 0 -*/ -unsigned long opp_get_freq (const struct omap_opp *opp); +struct omap_opp { +struct list_head opp_node; +unsigned int enabled:1 ; +unsigned long rate; +unsigned long uvolt; +}; -/** -* opp_get_opp_count() - Get number of opps enabled in the opp list -* @num: returns the number of opps -* @oppl: opp list -* -* This functions returns the number of opps if there are any OPPs enabled, -* else returns corresponding error value. -*/ -int opp_get_opp_count (struct omap_opp *oppl); +enum opp_t { +OPP_NONE =0 , +OPP_MPU , +OPP_L3 , +OPP_DSP , +}; -/** -* opp_find_freq_exact() - search for an exact frequency -* @oppl: OPP list -* @freq: frequency to search for -* @enabled: enabled/disabled OPP to search for -* -* searches for the match in the opp list and returns handle to the matching -* opp if found, else returns ERR_PTR in case of error and should be handled -* using IS_ERR. -* -* Note enabled is a modifier for the search. if enabled=true, then the match is -* for exact matching frequency and is enabled. if true, the match is for exact -* frequency which is disabled. -*/ -struct omap_opp *opp_find_freq_exact (struct omap_opp *oppl, -unsigned long freq,bool enabled); +static inline long opp_to_volt (struct omap_opp *opp) +{ +return opp ? opp->uvolt :0 ; +} -/* XXX This documentation needs fixing */ +static inline long opp_to_freq (struct omap_opp *opp) +{ +return opp ? opp->rate :0 ; +} -/** -* opp_find_freq_floor() - Search for an rounded freq -* @oppl: Starting list -* @freq: Start frequency -* -* Search for the lower *enabled* OPP from a starting freq -* from a start opp list. -* -* Returns *opp and *freq is populated with the next match, else -* returns NULL opp if found, else returns ERR_PTR in case of error. -* -* Example usages: -* * find match/next lowest available frequency -* freq = 350000; -* opp = opp_find_freq_floor(oppl, &freq))) -* if (IS_ERR(opp)) -* pr_err ("unable to find a lower frequency\n"); -* else -* pr_info("match freq = %ld\n", freq); -* -* * print all supported frequencies in descending order * -* opp = oppl; -* freq = ULONG_MAX; -* while (!IS_ERR(opp = opp_find_freq_floor(opp, &freq)) { -* pr_info("freq = %ld\n", freq); -* freq--; * for next lower match * -* } -* -* NOTE: if we set freq as ULONG_MAX and search low, we get the -* highest enabled frequency -*/ -struct omap_opp *opp_find_freq_floor (struct omap_opp *oppl, -unsigned long *freq); +static inline unsigned int opp_is_valid (struct omap_opp *opp) +{ +return opp ? opp->enabled :0 ; +} -/* XXX This documentation needs fixing */ +extern struct omap_opp *find_opp_by_freq (enum opp_t ,unsigned long , +unsigned long ); -/** -* opp_find_freq_ceil() - Search for an rounded freq -* @oppl: Starting list -* @freq: Start frequency -* -* Search for the higher *enabled* OPP from a starting freq -* from a start opp list. -* -* Returns *opp and *freq is populated with the next match, else -* returns NULL opp if found, else returns ERR_PTR in case of error. -* -* Example usages: -* * find match/next highest available frequency -* freq = 350000; -* opp = opp_find_freq_ceil(oppl, &freq)) -* if (IS_ERR(opp)) -* pr_err ("unable to find a higher frequency\n"); -* else -* pr_info("match freq = %ld\n", freq); -* -* * print all supported frequencies in ascending order * -* opp = oppl; -* freq = 0; -* while (!IS_ERR(opp = opp_find_freq_ceil(opp, &freq)) { -* pr_info("freq = %ld\n", freq); -* freq++; * for next higher match * -* } -*/ -struct omap_opp *opp_find_freq_ceil (struct omap_opp *oppl,unsigned long *freq); +extern unsigned int get_opp_count (enum opp_t ,unsigned long ); +extern int opp_add (enum opp_t ,struct omap_opp *,unsigned long ); +extern int opp_del (enum opp_t ,struct omap_opp *); -/** -* struct omap_opp_def - OMAP OPP Definition -* @enabled: True/false - is this OPP enabled/disabled by default -* @freq: Frequency in hertz corresponding to this OPP -* @u_volt: Nominal voltage in microvolts corresponding to this OPP -* -* OMAP SOCs have a standard set of tuples consisting of frequency and voltage -* pairs that the device will support per voltage domain. This is called -* Operating Points or OPP. The actual definitions of OMAP Operating Points -* varies over silicon within the same family of devices. For a specific -* domain, you can have a set of {frequency, voltage} pairs and this is denoted -* by an array of omap_opp_def. As the kernel boots and more information is -* available, a set of these are activated based on the precise nature of -* device the kernel boots up on. It is interesting to remember that each IP -* which belongs to a voltage domain may define their own set of OPPs on top -* of this - but this is handled by the appropriate driver. -*/ -struct omap_opp_def { -bool enabled; -unsigned long freq; -unsigned long u_volt; -}; +extern int create_opp_list (enum opp_t ,struct omap_opp *); -/* -* Initialization wrapper used to define an OPP -* to point at the end of a terminator of a list of OPPs, -* use OMAP_OPP_DEF(0, 0, 0) -*/ -#define OMAP_OPP_DEF (_enabled, _freq, _uv) \ -{ \ - .enabled = _enabled, \ - .freq = _freq, \ - .u_volt = _uv, \ +static inline void opp_enable (struct omap_opp *opp) +{ + opp ? opp->enabled =1 :0 ; +return ; } -/** -* opp_init_list() - Initialize an opp list from the opp definitions -* @opp_defs: Initial opp definitions to create the list. -* -* This function creates a list of opp definitions and returns a handle. -* This list can be used to further validation/search/modifications. New -* opp entries can be added to this list by using opp_add(). -* -* In the case of error, ERR_PTR is returned to the caller and should be -* appropriately handled with IS_ERR. -*/ -struct omap_opp __init *opp_init_list (const struct omap_opp_def *opp_defs); - -/** -* opp_add() - Add an OPP table from a table definitions -* @oppl: List to add the OPP to -* @opp_def: omap_opp_def to describe the OPP which we want to add to list. -* -* This function adds an opp definition to the opp list and returns -* a handle representing the new OPP list. This handle is then used for further -* validation, search, modification operations on the OPP list. -* -* This function returns the pointer to the allocated list through oppl if -* success, else corresponding ERR_PTR value. Caller should NOT free the oppl. -* opps_defs can be freed after use. -* -* NOTE: caller should assume that on success, oppl is probably populated with -* a new handle and the new handle should be used for further referencing -*/ -struct omap_opp *opp_add (struct omap_opp *oppl, -const struct omap_opp_def *opp_def); +static inline void opp_disable (struct omap_opp *opp) +{ + opp ? opp->enabled =0 :0 ; +return ; +} -/** -* opp_enable() - Enable a specific OPP -* @opp: Pointer to opp -* -* Enables a provided opp. If the operation is valid, this returns 0, else the -* corresponding error value. -* -* OPP used here is from the the opp_is_valid/opp_has_freq or other search -* functions -*/ -int opp_enable (struct omap_opp *opp); +extern void dump_list (enum opp_t ); -/** -* opp_disable() - Disable a specific OPP -* @opp: Pointer to opp -* -* Disables a provided opp. If the operation is valid, this returns 0, else the -* corresponding error value. -* -* OPP used here is from the the opp_is_valid/opp_has_freq or other search -* functions +/* +* Initialization wrapper used to define an OPP. */ -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); +#define OMAP_OPP_DEF (_enabled, _freq, _uv) \ +{ \ + .enabled = _enabled, \ + .rate = _freq, \ + .uvolt = _uv, \ +} -void opp_init_cpufreq_table (struct omap_opp *opps, -struct cpufreq_frequency_table **table); +#ifdef CONFIG_CPU_FREQ +extern void opp_init_cpufreq_table (struct cpufreq_frequency_table **); +#endif #endif /* __ASM_ARM_OMAP_OPP_H */
arch/arm/plat-omap/opp.c +273 -224
612 lines not on this page · raw message
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 5 lines · Nishanth
Quoted 5 lines
Could you please start using git format-patch -s -M -o to generate patches?
And you exposed struct
omap_oppback to the public defeating the previous work :(
Exposing struct omap_opp is ok. In fact I need this for adding/deleting and getting a handle on a particular OPP. My actual intent is to have the book-keeping done only in OPP layer. Now you just need to search by saying find_opp_by_freq(OPP_MPU, required_freq, flags /* flag will define the search criteria */);
Quoted 3 lines
Quoted 3 lines
mostly I like what you are trying to do here, but just not exactly what you are doing :(
Please let me know how to improvise this.