From: Thara Gopinath <thara@ti.com>
To: linux-omap@vger.kernel.org
Cc: khilman@deeprootsystems.com, paul@pwsan.com, nm@ti.com,
b-cousson@ti.com, vishwanath.bs@ti.com, sawant@ti.com,
Thara Gopinath <thara@ti.com>
Subject: [PATCHv2 02/17] OMAP3: PM: Create list to keep track of various smartreflex instances.
Date: Thu, 18 Mar 2010 14:45:40 +0530 [thread overview]
Message-ID: <1268903755-4151-3-git-send-email-thara@ti.com> (raw)
In-Reply-To: <1268903755-4151-2-git-send-email-thara@ti.com>
This patch removes the pointer sr1, sr2 in smartreflex.c and
instead creatse a list for keeping track of multiple smartreflex
instances.. This makes it scalable for next gen OMAPs where there
are more than two smartreflex modules.
Signed-off-by: Thara Gopinath <thara@ti.com>
---
arch/arm/mach-omap2/smartreflex.c | 114 ++++++++++++++++++++++++------------
1 files changed, 76 insertions(+), 38 deletions(-)
diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
index 1c5ec37..dc8d6e1 100644
--- a/arch/arm/mach-omap2/smartreflex.c
+++ b/arch/arm/mach-omap2/smartreflex.c
@@ -26,6 +26,7 @@
#include <linux/kobject.h>
#include <linux/i2c/twl.h>
#include <linux/io.h>
+#include <linux/list.h>
#include <plat/omap34xx.h>
#include <plat/control.h>
@@ -51,9 +52,12 @@ struct omap_sr {
u32 opp5_nvalue;
u32 senp_mod, senn_mod;
void __iomem *srbase_addr;
- void __iomem *vpbase_addr;
+ struct list_head node;
};
+/* sr_list contains all the instances of smartreflex module */
+static LIST_HEAD(sr_list);
+
#define SR_REGADDR(offs) (sr->srbase_addr + offset)
static inline void sr_write_reg(struct omap_sr *sr, unsigned offset, u32 value)
@@ -78,6 +82,20 @@ static inline u32 sr_read_reg(struct omap_sr *sr, unsigned offset)
return __raw_readl(SR_REGADDR(offset));
}
+static struct omap_sr *_sr_lookup(int srid)
+{
+ struct omap_sr *sr_info, *temp_sr_info;
+
+ sr_info = NULL;
+ list_for_each_entry(temp_sr_info, &sr_list, node) {
+ if (srid == temp_sr_info->srid) {
+ sr_info = temp_sr_info;
+ break;
+ }
+ }
+ return sr_info;
+}
+
static int sr_clk_enable(struct omap_sr *sr)
{
if (clk_enable(sr->clk) != 0) {
@@ -151,11 +169,17 @@ static u8 get_vdd1_opp(void)
{
struct omap_opp *opp;
unsigned long freq;
+ struct omap_sr *sr_info = _sr_lookup(SR1);
- if (sr1.vdd_opp_clk == NULL || IS_ERR(sr1.vdd_opp_clk))
+ if (!sr_info) {
+ pr_warning("omap_sr struct corresponding to SR1 not found\n");
+ return 0;
+ }
+
+ if (sr_info->vdd_opp_clk == NULL || IS_ERR(sr_info->vdd_opp_clk))
return 0;
- freq = sr1.vdd_opp_clk->rate;
+ freq = sr_info->vdd_opp_clk->rate;
opp = opp_find_freq_ceil(OPP_MPU, &freq);
if (IS_ERR(opp))
return 0;
@@ -163,9 +187,9 @@ static u8 get_vdd1_opp(void)
* Use higher freq voltage even if an exact match is not available
* we are probably masking a clock framework bug, so warn
*/
- if (unlikely(freq != sr1.vdd_opp_clk->rate))
+ if (unlikely(freq != sr_info->vdd_opp_clk->rate))
pr_warning("%s: Available freq %ld != dpll freq %ld.\n",
- __func__, freq, sr1.vdd_opp_clk->rate);
+ __func__, freq, sr_info->vdd_opp_clk->rate);
return opp_get_opp_id(opp);
}
@@ -174,11 +198,17 @@ static u8 get_vdd2_opp(void)
{
struct omap_opp *opp;
unsigned long freq;
+ struct omap_sr *sr_info = _sr_lookup(SR2);
+
+ if (!sr_info) {
+ pr_warning("omap_sr struct corresponding to SR2 not found\n");
+ return 0;
+ }
- if (sr2.vdd_opp_clk == NULL || IS_ERR(sr2.vdd_opp_clk))
+ if (sr_info->vdd_opp_clk == NULL || IS_ERR(sr_info->vdd_opp_clk))
return 0;
- freq = sr2.vdd_opp_clk->rate;
+ freq = sr_info->vdd_opp_clk->rate;
opp = opp_find_freq_ceil(OPP_L3, &freq);
if (IS_ERR(opp))
return 0;
@@ -187,9 +217,9 @@ static u8 get_vdd2_opp(void)
* Use higher freq voltage even if an exact match is not available
* we are probably masking a clock framework bug, so warn
*/
- if (unlikely(freq != sr2.vdd_opp_clk->rate))
+ if (unlikely(freq != sr_info->vdd_opp_clk->rate))
pr_warning("%s: Available freq %ld != dpll freq %ld.\n",
- __func__, freq, sr2.vdd_opp_clk->rate);
+ __func__, freq, sr_info->vdd_opp_clk->rate);
return opp_get_opp_id(opp);
}
@@ -694,14 +724,13 @@ static void sr_disable(struct omap_sr *sr)
void sr_start_vddautocomap(int srid, u32 target_opp_no)
{
- struct omap_sr *sr = NULL;
+ struct omap_sr *sr = _sr_lookup(srid);
- if (srid == SR1)
- sr = &sr1;
- else if (srid == SR2)
- sr = &sr2;
- else
+ if (!sr) {
+ pr_warning("omap_sr struct corresponding to SR%d not found\n",
+ srid);
return;
+ }
if (sr->is_sr_reset == 1) {
sr_clk_enable(sr);
@@ -719,14 +748,13 @@ EXPORT_SYMBOL(sr_start_vddautocomap);
int sr_stop_vddautocomap(int srid)
{
- struct omap_sr *sr = NULL;
+ struct omap_sr *sr = _sr_lookup(srid);
- if (srid == SR1)
- sr = &sr1;
- else if (srid == SR2)
- sr = &sr2;
- else
- return -EINVAL;
+ if (!sr) {
+ pr_warning("omap_sr struct corresponding to SR%d not found\n",
+ srid);
+ return false;
+ }
if (sr->is_autocomp_active == 1) {
sr_disable(sr);
@@ -744,14 +772,13 @@ EXPORT_SYMBOL(sr_stop_vddautocomap);
void enable_smartreflex(int srid)
{
u32 target_opp_no = 0;
- struct omap_sr *sr = NULL;
+ struct omap_sr *sr = _sr_lookup(srid);
- if (srid == SR1)
- sr = &sr1;
- else if (srid == SR2)
- sr = &sr2;
- else
+ if (!sr) {
+ pr_warning("omap_sr struct corresponding to SR%d not found\n",
+ srid);
return;
+ }
if (sr->is_autocomp_active == 1) {
if (sr->is_sr_reset == 1) {
@@ -779,15 +806,13 @@ void enable_smartreflex(int srid)
void disable_smartreflex(int srid)
{
u32 i = 0;
+ struct omap_sr *sr = _sr_lookup(srid);
- struct omap_sr *sr = NULL;
-
- if (srid == SR1)
- sr = &sr1;
- else if (srid == SR2)
- sr = &sr2;
- else
+ if (!sr) {
+ pr_warning("omap_sr struct corresponding to SR%d not found\n",
+ srid);
return;
+ }
if (sr->is_autocomp_active == 1) {
if (sr->is_sr_reset == 0) {
@@ -920,7 +945,13 @@ int sr_voltagescale_vcbypass(u32 target_opp, u32 current_opp,
static ssize_t omap_sr_vdd1_autocomp_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
- return sprintf(buf, "%d\n", sr1.is_autocomp_active);
+ struct omap_sr *sr_info = _sr_lookup(SR1);
+
+ if (!sr_info) {
+ pr_warning("omap_sr struct corresponding to SR1 not found\n");
+ return 0;
+ }
+ return sprintf(buf, "%d\n", sr_info->is_autocomp_active);
}
static ssize_t omap_sr_vdd1_autocomp_store(struct kobject *kobj,
@@ -960,7 +991,13 @@ static struct kobj_attribute sr_vdd1_autocomp = {
static ssize_t omap_sr_vdd2_autocomp_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
- return sprintf(buf, "%d\n", sr2.is_autocomp_active);
+ struct omap_sr *sr_info = _sr_lookup(SR2);
+
+ if (!sr_info) {
+ pr_warning("omap_sr struct corresponding to SR2 not found\n");
+ return 0;
+ }
+ return sprintf(buf, "%d\n", sr_info->is_autocomp_active);
}
static ssize_t omap_sr_vdd2_autocomp_store(struct kobject *kobj,
@@ -1010,7 +1047,6 @@ static int __init omap3_sr_init(void)
RdReg |= DCDC_GLOBAL_CFG_ENABLE_SRFLX;
ret |= twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, RdReg,
R_DCDC_GLOBAL_CFG);
-
if (cpu_is_omap34xx()) {
sr1.clk = clk_get(NULL, "sr1_fck");
sr2.clk = clk_get(NULL, "sr2_fck");
@@ -1036,6 +1072,8 @@ static int __init omap3_sr_init(void)
ret = sysfs_create_file(power_kobj, &sr_vdd2_autocomp.attr);
if (ret)
pr_err("sysfs_create_file failed: %d\n", ret);
+ list_add(&sr1.node, &sr_list);
+ list_add(&sr2.node, &sr_list);
return 0;
}
--
1.7.0.rc1.33.g07cf0f
next prev parent reply other threads:[~2010-03-18 9:16 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-18 9:15 [PATCHv2 00/17] OMAP3: PM: Smartreflex and voltage revamp Thara Gopinath
2010-03-18 9:15 ` [PATCHv2 01/17] OMAP3: PM: Adding hwmod data for Smartreflex Thara Gopinath
2010-03-18 9:15 ` Thara Gopinath [this message]
2010-03-18 9:15 ` [PATCHv2 03/17] OMAP3: PM: Convert smartreflex driver into a platform driver using hwmods and omap-device layer Thara Gopinath
2010-03-18 9:15 ` [PATCHv2 04/17] OMAP3: PM: Move smartreflex autocompensation enable disable hooks to PM debugfs Thara Gopinath
2010-03-18 9:15 ` [PATCHv2 05/17] OMAP3: PM: Remove OPP id dependency from smartreflex driver Thara Gopinath
2010-03-18 9:15 ` [PATCHv2 06/17] OMAP3: PM: Correcting API names in samrtreflex driver Thara Gopinath
2010-03-18 9:15 ` [PATCHv2 07/17] OMAP3: PM: Smartreflex class related changes for smartreflex.c Thara Gopinath
2010-03-18 9:15 ` [PATCHv2 08/17] OMAP3: PM: Adding smartreflex class 3 driver Thara Gopinath
2010-03-18 9:15 ` [PATCHv2 09/17] OMAP3: PM: Creating separate files for handling OMAP3 voltage related operations Thara Gopinath
2010-03-18 9:15 ` [PATCHv2 10/17] OMAP3: PM: Disabling Smartreflex across both frequency and voltage scaling during DVFS Thara Gopinath
2010-03-18 9:15 ` [PATCHv2 11/17] OMAP3: PM: Cleaning up of smartreflex header file Thara Gopinath
2010-03-18 9:15 ` [PATCHv2 12/17] OMAP3: PM: Configurations for Smartreflex Class 2 and Smartreflex Class 3 Thara Gopinath
2010-03-18 9:15 ` [PATCHv2 13/17] OMAP3: PM: Support for enabling smartreflex autocompensation by default Thara Gopinath
2010-03-18 9:15 ` [PATCHv2 14/17] OMAP3: PM: Correcting accessing of ERRCONFIG register in smartreflex.c Thara Gopinath
2010-03-18 9:15 ` [PATCHv2 15/17] OMAP3: PM: Implement latest h/w recommendations for SR and VP registers and SR VP enable disable sequence Thara Gopinath
2010-03-18 9:15 ` [PATCHv2 16/17] OMAP3: PM: VP force update method of voltage scaling Thara Gopinath
2010-03-18 9:15 ` [PATCHv2 17/17] OMAP3: PM: Enabling Smartreflex Class 3 driver by default in pm defconfig Thara Gopinath
2010-03-22 18:28 ` [PATCHv2 03/17] OMAP3: PM: Convert smartreflex driver into a platform driver using hwmods and omap-device layer Nishanth Menon
2010-03-22 18:07 ` [PATCHv2 01/17] OMAP3: PM: Adding hwmod data for Smartreflex Paul Walmsley
2010-03-18 19:15 ` [PATCHv2 00/17] OMAP3: PM: Smartreflex and voltage revamp Nishanth Menon
2010-03-22 14:39 ` Gopinath, Thara
2010-03-22 15:41 ` Nishanth Menon
2010-03-22 16:50 ` Kevin Hilman
2010-03-22 16:54 ` Nishanth Menon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1268903755-4151-3-git-send-email-thara@ti.com \
--to=thara@ti.com \
--cc=b-cousson@ti.com \
--cc=khilman@deeprootsystems.com \
--cc=linux-omap@vger.kernel.org \
--cc=nm@ti.com \
--cc=paul@pwsan.com \
--cc=sawant@ti.com \
--cc=vishwanath.bs@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox