From: Mike Turquette <mturquette@ti.com>
To: "Gopinath, Thara" <thara@ti.com>
Cc: "linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
"khilman@deeprootsystems.com" <khilman@deeprootsystems.com>,
"paul@pwsan.com" <paul@pwsan.com>, "Menon, Nishanth" <nm@ti.com>,
"Cousson, Benoit" <b-cousson@ti.com>,
"Sripathy, Vishwanath" <vishwanath.bs@ti.com>,
"Sawant, Anand" <sawant@ti.com>
Subject: Re: [PATCH 02/16] OMAP3: PM: Create list to keep track of various smartreflex instances.
Date: Fri, 26 Feb 2010 17:21:13 -0600 [thread overview]
Message-ID: <4B885769.2090505@ti.com> (raw)
In-Reply-To: <1267003757-22456-3-git-send-email-thara@ti.com>
Gopinath, Thara wrote:
> 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..4a9c2e2 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);
Why has the list implementation been chosen over individually registered
platform devices? There seems to be a trend lately in device drivers to
have a single platform device with either an array of pointers or a list
implementation to track the multiple instances of the same device on a
board. McBSP is another example of this approach.
Why is that? Is it a bad idea to have each SR instance be a separate
platform device? Please let me know if my question is nuts.
Mike
>
> - 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;
> }
next prev parent reply other threads:[~2010-02-26 23:21 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-24 9:29 [PATCH 00/16] OMAP3: PM: Smartreflex and voltage revamp Thara Gopinath
2010-02-24 9:29 ` [PATCH 01/16] OMAP3: PM: Adding hwmod data for Smartreflex Thara Gopinath
2010-02-24 9:29 ` [PATCH 02/16] OMAP3: PM: Create list to keep track of various smartreflex instances Thara Gopinath
2010-02-24 9:29 ` [PATCH 03/16] OMAP3: PM: Convert smartreflex driver into a platform driver using hwmods and omap-device layer Thara Gopinath
2010-02-24 9:29 ` [PATCH 04/16] OMAP3: PM: Move smartreflex autocompensation enable disable hooks to PM debugfs Thara Gopinath
2010-02-24 9:29 ` [PATCH 05/16] OMAP3: PM: Export get_vdd1_opp and get_vdd2_opp from shared resource framework Thara Gopinath
2010-02-24 9:29 ` [PATCH 06/16] OMAP3: PM: Smartreflex class related changes for smartreflex.c Thara Gopinath
2010-02-24 9:29 ` [PATCH 07/16] OMAP3: PM: Adding smartreflex class 3 driver Thara Gopinath
2010-02-24 9:29 ` [PATCH 08/16] OMAP3: PM: Disabling Smartreflex across both frequency and voltage scaling during DVFS Thara Gopinath
2010-02-24 9:29 ` [PATCH 09/16] OMAP3: PM: Creating separate files for handling OMAP3 voltage related operations Thara Gopinath
2010-02-24 9:29 ` [PATCH 10/16] OMAP3: PM: Cleaning up of smartreflex header file Thara Gopinath
2010-02-24 9:29 ` [PATCH 11/16] OMAP3: PM: Configurations for Smartreflex Class 2 and Smartreflex Class 3 Thara Gopinath
2010-02-24 9:29 ` [PATCH 12/16] OMAP3: PM: Support for enabling smartreflex autocompensation by default Thara Gopinath
2010-02-24 9:29 ` [PATCH 13/16] OMAP3: PM: Correcting accessing of ERRCONFIG register in smartreflex.c Thara Gopinath
2010-02-24 9:29 ` [PATCH 14/16] OMAP3: PM: Implement latest h/w recommendations for SR and VP registers and SR VP enable disable sequence Thara Gopinath
2010-02-24 9:29 ` [PATCH 15/16] OMAP3: PM: VP force update method of voltage scaling Thara Gopinath
2010-02-24 9:29 ` [PATCH 16/16] OMAP3: PM: Enabling Smartreflex Class 3 driver by default in pm defconfig Thara Gopinath
2010-03-03 0:58 ` [PATCH 15/16] OMAP3: PM: VP force update method of voltage scaling Kevin Hilman
2010-03-05 15:22 ` Gopinath, Thara
2010-03-05 15:26 ` Felipe Contreras
2010-03-05 15:30 ` Gopinath, Thara
2010-03-05 16:22 ` Felipe Contreras
2010-03-05 18:17 ` Snipping irrelevant text from a discussion (was: "RE: [PATCH 15/16] OMAP3: PM: VP force update method of voltage scaling") Aguirre, Sergio
2010-03-05 21:18 ` Felipe Contreras
2010-03-09 1:42 ` Tony Lindgren
2010-03-09 6:51 ` Felipe Balbi
2010-03-09 15:21 ` Aguirre, Sergio
2010-03-09 18:21 ` Tony Lindgren
2010-03-03 0:54 ` [PATCH 14/16] OMAP3: PM: Implement latest h/w recommendations for SR and VP registers and SR VP enable disable sequence Kevin Hilman
2010-03-03 0:48 ` [PATCH 12/16] OMAP3: PM: Support for enabling smartreflex autocompensation by default Kevin Hilman
2010-03-05 15:20 ` Gopinath, Thara
2010-03-03 0:37 ` [PATCH 11/16] OMAP3: PM: Configurations for Smartreflex Class 2 and Smartreflex Class 3 Kevin Hilman
2010-03-05 15:12 ` Gopinath, Thara
2010-03-05 19:20 ` Kevin Hilman
2010-03-02 20:02 ` [PATCH 09/16] OMAP3: PM: Creating separate files for handling OMAP3 voltage related operations Kevin Hilman
2010-03-05 15:17 ` Gopinath, Thara
2010-03-02 19:36 ` [PATCH 07/16] OMAP3: PM: Adding smartreflex class 3 driver Kevin Hilman
2010-03-05 15:03 ` Gopinath, Thara
2010-03-05 19:12 ` Kevin Hilman
2010-03-02 18:44 ` [PATCH 06/16] OMAP3: PM: Smartreflex class related changes for smartreflex.c Kevin Hilman
2010-03-05 15:00 ` Gopinath, Thara
2010-03-05 18:29 ` Kevin Hilman
2010-03-02 23:37 ` Kevin Hilman
2010-03-02 23:52 ` Kevin Hilman
2010-03-05 15:18 ` Gopinath, Thara
2010-03-05 18:30 ` Kevin Hilman
2010-03-02 18:28 ` [PATCH 04/16] OMAP3: PM: Move smartreflex autocompensation enable disable hooks to PM debugfs Kevin Hilman
2010-02-25 2:39 ` [PATCH 03/16] OMAP3: PM: Convert smartreflex driver into a platform driver using hwmods and omap-device layer ambresh
2010-03-02 18:28 ` Kevin Hilman
2010-03-05 14:26 ` Gopinath, Thara
2010-03-12 9:48 ` Gopinath, Thara
2010-03-13 0:36 ` Kevin Hilman
2010-03-15 19:00 ` Tony Lindgren
2010-03-03 0:02 ` Kevin Hilman
2010-02-25 1:42 ` [PATCH 02/16] OMAP3: PM: Create list to keep track of various smartreflex instances ambresh
2010-03-02 17:40 ` Kevin Hilman
2010-02-26 23:21 ` Mike Turquette [this message]
2010-03-02 17:39 ` Kevin Hilman
2010-02-24 16:52 ` [PATCH 01/16] OMAP3: PM: Adding hwmod data for Smartreflex Mike Turquette
2010-03-06 0:45 ` Kevin Hilman
2010-03-06 0:58 ` [PATCH 00/16] OMAP3: PM: Smartreflex and voltage revamp Kevin Hilman
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=4B885769.2090505@ti.com \
--to=mturquette@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=thara@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