devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthias Kaehlcke <mka@chromium.org>
To: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>
Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	Douglas Anderson <dianders@chromium.org>,
	Brian Norris <briannorris@chromium.org>,
	Guenter Roeck <groeck@chromium.org>,
	Dmitry Torokhov <dtor@chromium.org>
Subject: Re: [PATCH v1] regulator: Add driver for voltage controlled regulators
Date: Fri, 10 Feb 2017 16:32:45 -0800	[thread overview]
Message-ID: <20170211003245.GA56005@google.com> (raw)
In-Reply-To: <20170210204348.107871-1-mka@chromium.org>

El Fri, Feb 10, 2017 at 12:43:48PM -0800 Matthias Kaehlcke ha dit:

> The output voltage of a voltage controlled regulator can be controlled
> through the voltage of another regulator. The current version of this
> driver assumes that the output voltage is a linear function of the control
> voltage.
> 
> ...
>
> +static int vctrl_probe(struct platform_device *pdev)
> +{
> ...
> +	/* determine if the voltage range of the control supply is continuous */
> +	if ((regulator_count_voltages(vctrl->ctrl_supply) == 1) &&
> +	    regulator_is_supported_voltage(vctrl->ctrl_supply,
> +					   vrange_ctrl->min_uV,
> +					   vrange_ctrl->min_uV) &&
> +	    regulator_is_supported_voltage(vctrl->ctrl_supply,
> +					   vrange_ctrl->max_uV,
> +					   vrange_ctrl->max_uV)) {
> +		rdesc->continuous_voltage_range = true;
> +		rdesc->ops = &vctrl_ops_cont;
> +	} else {
> +		rdesc->ops = &vctrl_ops_non_cont;
> +	}

This creature of indisputable beauty seemed to do the job on my
test systen, however I just realized that the condition is BS. It
turns out that on my system the voltage count of 1 stems from the
parent, since the voltage count of the control supply itself is zero.

int regulator_count_voltages(struct regulator *regulator)
{
	struct regulator_dev    *rdev = regulator->rdev;

	if (rdev->desc->n_voltages)
		return rdev->desc->n_voltages;

	if (!rdev->supply)
		return -EINVAL;

	return regulator_count_voltages(rdev->supply);
}

This certainly doesn't help to determine if the regulator has a
continous voltage range. It seems we need a function that evaluates
rdesc->continuous_voltage_range

--

Matthias

  reply	other threads:[~2017-02-11  0:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-10 20:43 [PATCH v1] regulator: Add driver for voltage controlled regulators Matthias Kaehlcke
2017-02-11  0:32 ` Matthias Kaehlcke [this message]
     [not found] ` <20170210204348.107871-1-mka-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2017-02-22  0:22   ` Rob Herring
2017-02-25  3:19     ` Matthias Kaehlcke
     [not found]       ` <20170225031919.GB56005-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2017-02-27 18:53         ` Matthias Kaehlcke

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=20170211003245.GA56005@google.com \
    --to=mka@chromium.org \
    --cc=briannorris@chromium.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dianders@chromium.org \
    --cc=dtor@chromium.org \
    --cc=groeck@chromium.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.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).