linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: pawel.moll@arm.com (Pawel Moll)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 04/13] regulators: Versatile Express regulator driver
Date: Wed, 19 Sep 2012 17:58:25 +0100	[thread overview]
Message-ID: <1348073905.11116.80.camel@hornet> (raw)
In-Reply-To: <20120919022141.GA8832@opensource.wolfsonmicro.com>

On Wed, 2012-09-19 at 03:21 +0100, Mark Brown wrote:
> No, I mean discovering which regulators are present and what they can
> do.

Nope. This driver is supposed to work only on Device Tree "enabled"
platforms. Having said that, I should have added the bindings
documentation in the patch. Will do.

> > > So this is going to break interoperation with a bunch of consumer
> > > drivers that rely on being able to tell what voltages are supported.
> > > The key thing for them would be that regulator_is_supported_voltage()
> > > works, currently it relies on list_voltage() as that's the only way to
> > > do that right now.
> 
> > Ok, I guess I should use regulator_list_voltage_linear() and
> > regulator_map_voltage_linear() then? I'll just have to carefully think
> > what step to choose.
> 
> No, we should provide a way to describe this situation in the API - it's
> not unreasonable and having to pick step sizes is obviously suboptimal.

Actually before I finally got this mail (our mail system was playing
stupid today), I came up with idea of using the power supply specified
tolerance as a base to chose the step sizes. This comes down to such
code (with the regulator_*_voltage_linear in the ops):

8<---
                int range = init_data->constraints.max_uV -
                                init_data->constraints.min_uV;
                u32 tolerance;
                int avg_error;

                err = of_property_read_u32(pdev->dev.of_node,
                                "arm,vexpress-volt,tolerance", &tolerance);
                if (err)
                        goto error_property_read;

                reg->desc.min_uV = init_data->constraints.min_uV;
                avg_error = (range / 2 + reg->desc.min_uV) * tolerance / 100;
                reg->desc.n_voltages = range / avg_error + 1;
                reg->desc.uV_step = range / (reg->desc.n_voltages - 1);
8<---

so it doesn't look that bad to me. Now, if you are considering changing
the API, I would propose something like this:

8<---
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 4838531..a091719 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1948,8 +1948,14 @@ int regulator_is_supported_voltage(struct regulator *regulator,
        }
 
        ret = regulator_count_voltages(regulator);
-       if (ret < 0)
-               return ret;
+       if (ret < 0) {
+               /* No operating points defined, allow any value within range */
+               struct regulation_constraints *constraints =
+                               regulator->rdev->constraints;
+
+               return min_uV >= constraints->min_uV &&
+                               max_uV <= constraints->max_uV;
+       }
        voltages = ret;
 
        for (i = 0; i < voltages; i++) {
8<---

I originally assumed that if I provide no operating points (in the form
of list_voltage function) any voltage within the constraints range will
be allowed.

Both options are perfectly fine with me.

Thanks!

Pawel

  reply	other threads:[~2012-09-19 16:58 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-18 14:17 [PATCH v2 00/13] Versatile Express infrastructure Pawel Moll
2012-09-18 14:17 ` [PATCH v2 01/13] input: ambakmi: (Un)prepare clocks when (dis)enabling Pawel Moll
2012-09-18 14:17 ` [PATCH v2 02/13] video: Versatile Express display output driver Pawel Moll
2012-09-18 14:17 ` [PATCH v2 03/13] hwmon: Versatile Express hwmon driver Pawel Moll
2012-09-18 15:24   ` Guenter Roeck
2012-09-18 15:45     ` Jean Delvare
2012-09-18 20:59       ` Guenter Roeck
2012-09-19 17:04     ` Pawel Moll
2012-09-20  2:03       ` Guenter Roeck
2012-09-18 14:17 ` [PATCH v2 04/13] regulators: Versatile Express regulator driver Pawel Moll
2012-09-18 15:02   ` Mark Brown
2012-09-18 15:44     ` Pawel Moll
2012-09-18 16:09       ` Mark Brown
2012-09-18 17:03         ` Pawel Moll
2012-09-19  2:21           ` Mark Brown
2012-09-19 16:58             ` Pawel Moll [this message]
2012-09-20 13:01               ` Mark Brown
2012-09-20 17:34                 ` Pawel Moll
2012-09-20 18:15                   ` Mark Brown
2012-09-18 14:17 ` [PATCH v2 05/13] clk: Versatile Express clock generators ("osc") driver Pawel Moll
2012-10-29 17:44   ` Mike Turquette
2012-09-18 14:17 ` [PATCH v2 06/13] clk: Common clocks implementation for Versatile Express Pawel Moll
2012-09-18 14:17 ` [PATCH v2 07/13] misc: Versatile Express config infrastructure Pawel Moll
2012-09-19 13:08   ` Arnd Bergmann
2012-09-20 12:06     ` Pawel Moll
2012-09-20 12:36       ` Arnd Bergmann
2012-09-20 12:37         ` Pawel Moll
2012-09-18 14:17 ` [PATCH v2 08/13] mfd: Versatile Express system registers driver Pawel Moll
2012-09-18 15:24   ` Arnd Bergmann
2012-09-19 10:53     ` Pawel Moll
2012-09-19 11:17       ` Arnd Bergmann
2012-09-19 11:45         ` Pawel Moll
2012-09-18 14:17 ` [PATCH v2 09/13] ARM: vexpress: Reset driver Pawel Moll
2012-09-18 14:17 ` [PATCH v2 10/13] ARM: vexpress: Add config bus components and clocks to DTs Pawel Moll
2012-09-18 14:17 ` [PATCH v2 11/13] ARM: vexpress: Start using new Versatile Express infrastructure Pawel Moll
2012-09-18 14:17 ` [PATCH v2 12/13] ARM: vexpress: Remove motherboard dependencies in the DTS files Pawel Moll
2012-09-18 14:17 ` [PATCH v2 13/13] ARM: vexpress: Make the DEBUG_LL UART detection more specific Pawel Moll

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=1348073905.11116.80.camel@hornet \
    --to=pawel.moll@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).