public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: Stephen Warren <swarren@wwwdotorg.org>
Cc: Liam Girdwood <lrg@ti.com>,
	linux-kernel@vger.kernel.org,
	Laxman Dewangan <ldewangan@nvidia.com>,
	Gyungoh Yoo <jack.yoo@maxim-ic.com>,
	Stephen Warren <swarren@nvidia.com>
Subject: Re: [PATCH] regulator: add MAX8907 driver
Date: Sat, 4 Aug 2012 11:19:18 +0100	[thread overview]
Message-ID: <20120804101918.GD9248@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1343932033-911-1-git-send-email-swarren@wwwdotorg.org>

On Thu, Aug 02, 2012 at 12:27:13PM -0600, Stephen Warren wrote:

> The MAX8907 is an I2C-based power-management IC containing voltage
> regulators, a reset controller, a real-time clock, and a touch-screen
> controller.

> * Reworked the regulator driver to be represented as a single device that
>   provides multiple regulators, rather than as a device per regulator.  It
>   seems like this is more common?

This is mostly a reflection of the poor reuse available with most
hardware.  If you've got a bunch of regulators which can usefully
be instantiated and work out where they are by just getting a
register range or two, and especially if you've got a bunch of PMICs
with different arrangements of these things, then it's useful to
split into multiple drivers.  If each regulator needs a bunch of custom
data then there's not much point.

> +static int max8907_regulator_list_voltage(struct regulator_dev *rdev,
> +					  unsigned index)
> +{
> +	struct max8907_regulator *pmic = rdev_get_drvdata(rdev);
> +	int id = rdev_get_id(rdev);
> +	const struct max8907_regulator_info *info = &pmic->info[id];
> +
> +	return info->min_uV + info->step_uV * index;
> +}

regulator_list_voltage_linear().

> +static int max8907_regulator_ldo_set_voltage(struct regulator_dev *rdev,
> +					     int min_uV, int max_uV,
> +					     unsigned *selector)

Should use regulator_set_voltage_sel_regmap() and
regulator_map_voltage_linear().

> +static int max8907_regulator_bbat_set_voltage(struct regulator_dev *rdev,
> +					      int min_uV, int max_uV,
> +					      unsigned *selector)

Similarly for this regulator, use a linear mapping.

> +static int max8907_regulator_fixed_get_voltage(struct regulator_dev *rdev)

This one too.

> +static int max8907_regulator_wled_set_current_limit(struct regulator_dev *rdev,
> +						    int min_uA, int max_uA)

I'm really not convinced it makes much sense to represent the backlight
driver current regulators as regulators, they only get used as part of
the backlight and are usually tightly coupled to their boosts.

> +static int max8907_regulator_ldo_enable(struct regulator_dev *rdev)
> +{
> +	struct max8907_regulator *pmic = rdev_get_drvdata(rdev);
> +	int id = rdev_get_id(rdev);
> +	const struct max8907_regulator_info *info = &pmic->info[id];
> +	unsigned int reg = MAX8907_MASK_LDO_EN | MAX8907_MASK_LDO_SEQ;
> +
> +	return regmap_update_bits(rdev->regmap, info->reg_base + MAX8907_CTL,
> +				  reg, reg);

regulator_enable_regmap() and friends (and similarly for a bunch of the
others).

  reply	other threads:[~2012-08-04 10:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-02 18:27 [PATCH] regulator: add MAX8907 driver Stephen Warren
2012-08-04 10:19 ` Mark Brown [this message]
2012-08-06 21:22   ` Stephen Warren
2012-08-06 21:47     ` Mark Brown

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=20120804101918.GD9248@opensource.wolfsonmicro.com \
    --to=broonie@opensource.wolfsonmicro.com \
    --cc=jack.yoo@maxim-ic.com \
    --cc=ldewangan@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@ti.com \
    --cc=swarren@nvidia.com \
    --cc=swarren@wwwdotorg.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