From patchwork Thu Nov 26 00:22:49 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishanth Menon X-Patchwork-Id: 63034 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nAQ0Mue8016777 for ; Thu, 26 Nov 2009 00:22:56 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759817AbZKZAWt (ORCPT ); Wed, 25 Nov 2009 19:22:49 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1759730AbZKZAWt (ORCPT ); Wed, 25 Nov 2009 19:22:49 -0500 Received: from arroyo.ext.ti.com ([192.94.94.40]:48764 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759662AbZKZAWs convert rfc822-to-8bit (ORCPT ); Wed, 25 Nov 2009 19:22:48 -0500 Received: from dlep35.itg.ti.com ([157.170.170.118]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id nAQ0Mrjv005410 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 25 Nov 2009 18:22:53 -0600 Received: from dlep26.itg.ti.com (localhost [127.0.0.1]) by dlep35.itg.ti.com (8.13.7/8.13.7) with ESMTP id nAQ0MrMX001060; Wed, 25 Nov 2009 18:22:53 -0600 (CST) Received: from dlee74.ent.ti.com (localhost [127.0.0.1]) by dlep26.itg.ti.com (8.13.8/8.13.8) with ESMTP id nAQ0Mof0002689; Wed, 25 Nov 2009 18:22:50 -0600 (CST) Received: from dlee02.ent.ti.com ([157.170.170.17]) by dlee74.ent.ti.com ([157.170.170.8]) with mapi; Wed, 25 Nov 2009 18:22:50 -0600 From: "Menon, Nishanth" To: Kevin Hilman CC: linux-omap , "Cousson, Benoit" , "Chikkature Rajashekar, Madhusudhan" , Paul Walmsley , "Dasgupta, Romit" , "Shilimkar, Santosh" , "Aguirre, Sergio" , "Gopinath, Thara" , "Sripathy, Vishwanath" , "Premi, Sanjeev" Date: Wed, 25 Nov 2009 18:22:49 -0600 Subject: RE: [PATCH 02/10 V3] omap3: pm: introduce opp accessor functions Thread-Topic: [PATCH 02/10 V3] omap3: pm: introduce opp accessor functions Thread-Index: AcpuKZaigj98aEgQSOat/eMfz9zXMwAA9+UQ Message-ID: <7A436F7769CA33409C6B44B358BFFF0C012B595348@dlee02.ent.ti.com> References: <1259122159-1583-1-git-send-email-nm@ti.com> <1259122159-1583-2-git-send-email-nm@ti.com> <1259122159-1583-3-git-send-email-nm@ti.com> <87einmin29.fsf@deeprootsystems.com> <4B0D9432.3040104@ti.com> <878wdukw0n.fsf@deeprootsystems.com> In-Reply-To: <878wdukw0n.fsf@deeprootsystems.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org diff --git a/arch/arm/plat-omap/include/plat/opp.h b/arch/arm/plat-omap/include/plat/opp.h new file mode 100644 index 0000000..4a00685 --- /dev/null +++ b/arch/arm/plat-omap/include/plat/opp.h @@ -0,0 +1,184 @@ +/* + * OMAP OPP Interface + * + * Copyright (C) 2009 Texas Instruments Incorporated. + * Nishanth Menon + * Copyright (C) 2009 Deep Root Systems, LLC. + * 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 + * published by the Free Software Foundation. + */ +#ifndef __ASM_ARM_OMAP_OPP_H +#define __ASM_ARM_OMAP_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 + * @vsel: Voltage in volt processor level(this usage is + * DEPRECATED to use Voltage in microvolts in future) + * uV = ((vsel * 12.5) + 600) * 1000 + * + * 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; + u8 opp_id __deprecated; + u16 vsel; +}; + +/** + * 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 + */ +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); + +/** + * 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(const struct omap_opp *oppl); + +#define OPP_SEARCH_HIGH (0 << 1) +#define OPP_SEARCH_LOW (1 << 1) +/** + * opp_find_freq_approx() - Search for an approximate freq + * @oppl: starting list + * @freq: start frequency + * @dir_flags: search direction + * OPP_SEARCH_HIGH - search for next highest freq + * OPP_SEARCH_LOW - search for next lowest freq + * + * Search for the higher/lower *enabled* OPP than a starting freq + * from a start opp list. + + * Returns *opp and *freq is populated with the next match, + * else returns NULL + * + * Example usages: + * * print all frequencies in descending order * + * unsigned long freq; + * struct omap_opp *opp; + * for(opp = oppl, freq = ULONG_MAX; opp; + * opp = opp_find_freq_approx(opp, &freq, OPP_SEARCH_LOW)) + * pr_info("%ld ", freq); + * + * * print all frequencies in ascending order * + * unsigned long freq = 0; + * struct omap_opp *opp; + * for(opp = oppl, freq = 0; opp; + * opp = opp_find_freq_approx(opp, &freq, OPP_SEARCH_HIGH)) + * pr_info("%ld ", freq); + * NOTE: if we set freq as ULONG_MAX, we get the highest enabled frequency + * + */ +struct omap_opp *opp_find_freq_approx(struct omap_opp *oppl, + unsigned long *freq, u8 dir_flags); + +/** + * 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 NULL. + * + * 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); + + +/** + * 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; + u32 u_volt; +}; + +/** + * opp_add - Add/initialize an OPP table from a table definitions + * @oppl: Returned back to caller as the opp list to reference the OPP + * @opp_defs: Array of omap_opp_def to describe the OPP. This list should be + * 0 terminated. + * + * This function adds the opp definition to an internal opp list and returns + * a handle representing the OPP list. This handle is then used for further + * validation, search, modification operations on the OPP list. + * + * This function returns 0 and the pointer to the allocated list through oppl if + * success, else corresponding error 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 + */ +int opp_add(struct omap_opp **oppl, const struct omap_opp_def *opp_defs); + +/** + * 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); + +/** + * 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 + */ +int opp_disable(struct omap_opp *opp); + +#endif /* __ASM_ARM_OMAP_OPP_H *