linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: Graeme Gregory <gg@slimlogic.co.uk>
Cc: linux-kernel@vger.kernel.org, sameo@linux.intel.com, lrg@ti.com,
	b-cousson@ti.com, linux-omap@vger.kernel.org
Subject: Re: [PATCH 3/4] REGULATOR: regulator driver for Palmas series chips
Date: Mon, 14 May 2012 09:52:24 +0100	[thread overview]
Message-ID: <20120514085223.GH31985@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1336960712-2812-4-git-send-email-gg@slimlogic.co.uk>

[-- Attachment #1: Type: text/plain, Size: 2999 bytes --]

On Mon, May 14, 2012 at 10:58:31AM +0900, Graeme Gregory wrote:

Looks good, quite a few of the things below are updates for very
recently introduced APIs.

> +static int palmas_smps_read(struct palmas *palmas, unsigned int reg,
> +		unsigned int *dest)
> +{
> +	int slave;
> +	unsigned int addr;
> +
> +	slave = PALMAS_BASE_TO_SLAVE(PALMAS_SMPS_BASE);
> +	addr = PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE, reg);
> +
> +	return regmap_read(palmas->regmap[slave], addr, dest);
> +}

Looks like the LDO and SPMS regulators both use the same regmap?

> +	.get_voltage		= palmas_get_voltage_smps,

Why not get_voltage_sel?

> +	.set_voltage_sel	= palmas_set_voltage_smps_sel,
> +	.list_voltage		= palmas_list_voltage_smps,

Implementing map_voltage() too would be nice.

> +static int palmas_is_enabled_smps10(struct regulator_dev *dev)
> +{
> +	struct palmas_pmic *pmic = rdev_get_drvdata(dev);
> +	unsigned int reg;
> +
> +	palmas_smps_read(pmic->palmas, PALMAS_SMPS10_STATUS, &reg);
> +
> +	reg &= SMPS10_BOOST_EN;
> +

Should be able to use regulator_is_enabled_regmap() and friends.

> +static int palmas_list_voltage_smps10(struct regulator_dev *dev,
> +					unsigned selector)
> +{
> +	if (selector)
> +		return 5000000;
> +
> +	return 3750000;

This could be written a little more transparently!

> +static int palmas_get_voltage_smps10(struct regulator_dev *dev)
> +{
> +	struct palmas_pmic *pmic = rdev_get_drvdata(dev);
> +	int selector;
> +	unsigned int reg;
> +
> +	palmas_smps_read(pmic->palmas, PALMAS_SMPS10_CTRL, &reg);
> +
> +	selector = (reg & SMPS10_VSEL) >> 3;
> +
> +	return palmas_list_voltage_smps10(dev, selector);

Should be get_voltage_sel() really, or beter still should be using
regulator_set_voltage_sel_regmap().  Similarly for the set (which is
already using _sel()).

> +static int palmas_enable_ldo(struct regulator_dev *dev)
> +{
> +	struct palmas_pmic *pmic = rdev_get_drvdata(dev);
> +	int id = rdev_get_id(dev);
> +	unsigned int reg;
> +
> +	palmas_ldo_read(pmic->palmas, palmas_regs_info[id].ctrl_addr, &reg);
> +
> +	reg |= LDO1_CTRL_MODE_ACTIVE;
> +
> +	palmas_ldo_write(pmic->palmas, palmas_regs_info[id].ctrl_addr, reg);

Could use the core regmap stuff for the LDOs too.

> +	/* Adjust selector to match list_voltage ranges */
> +	if (selector > 49)
> +		selector = 49;
> +
> +	return palmas_list_voltage_ldo(dev, selector);

get_voltage_sel().

> +	if (!pdata)
> +		return -EINVAL;
> +	if (!pdata->reg_data)
> +		return -EINVAL;

I'd expect the driver to be able to register the regulators with no
platform data at all.

> +	pmic = kzalloc(sizeof(*pmic), GFP_KERNEL);
> +	if (!pmic)
> +		return -ENOMEM;

devm_kzalloc()

> +	pmic->desc = kcalloc(PALMAS_NUM_REGS,
> +			sizeof(struct regulator_desc), GFP_KERNEL);
> +	if (!pmic->desc) {
> +		ret = -ENOMEM;
> +		goto err_free_pmic;
> +	}

Just embed this in the pmic struct?  It's always the same size.

> +	pmic->rdev = kcalloc(PALMAS_NUM_REGS,
> +			sizeof(struct regulator_dev *), GFP_KERNEL);

Similarly heere.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2012-05-14  8:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-14  1:58 [PATCH 0/4] Adding support for Palmas PMIC Graeme Gregory
2012-05-14  1:58 ` [PATCH 1/4] MFD: palmas PMIC device support Graeme Gregory
2012-05-14  8:28   ` Mark Brown
2012-05-14 10:26     ` Graeme Gregory
2012-05-14 10:33       ` Mark Brown
2012-05-14  1:58 ` [PATCH 2/4] MFD: palmas PMIC device support Kconfig Graeme Gregory
2012-05-14  1:58 ` [PATCH 3/4] REGULATOR: regulator driver for Palmas series chips Graeme Gregory
2012-05-14  8:52   ` Mark Brown [this message]
2012-05-15  6:12     ` Graeme Gregory
2012-05-15 18:11       ` Mark Brown
2012-05-14  1:58 ` [PATCH 4/4] REGULATOR: regulator for Palmas Kconfig Graeme Gregory

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=20120514085223.GH31985@opensource.wolfsonmicro.com \
    --to=broonie@opensource.wolfsonmicro.com \
    --cc=b-cousson@ti.com \
    --cc=gg@slimlogic.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=lrg@ti.com \
    --cc=sameo@linux.intel.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;
as well as URLs for NNTP newsgroup(s).