public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ezequiel Garcia <ezequiel.garcia@imgtec.com>
To: Andrew Bresticker <abrestic@chromium.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Alexandre Courbot <gnurou@gmail.com>,
	"Ralf Baechle" <ralf@linux-mips.org>
Cc: <devicetree@vger.kernel.org>, <linux-gpio@vger.kernel.org>,
	<linux-mips@linux-mips.org>, <linux-kernel@vger.kernel.org>,
	James Hartley <james.hartley@imgtec.com>,
	James Hogan <james.hogan@imgtec.com>,
	"Damien Horsley" <Damien.Horsley@imgtec.com>,
	Govindraj Raja <govindraj.raja@imgtec.com>,
	Kevin Cernekee <cernekee@chromium.org>,
	"Paul Bolle" <pebolle@tiscali.nl>
Subject: Re: [PATCH V3 2/2] pinctrl: Add Pistachio SoC pin control driver
Date: Tue, 28 Apr 2015 20:24:21 -0300	[thread overview]
Message-ID: <554016A5.7040209@imgtec.com> (raw)
In-Reply-To: <1428435862-14354-3-git-send-email-abrestic@chromium.org>

Andrew,

On 04/07/2015 04:44 PM, Andrew Bresticker wrote:
[..]
> +static int pistachio_pinmux_enable(struct pinctrl_dev *pctldev,
> +				   unsigned func, unsigned group)
> +{
> +	struct pistachio_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
> +	const struct pistachio_pin_group *pg = &pctl->groups[group];
> +	const struct pistachio_function *pf = &pctl->functions[func];
> +	struct pinctrl_gpio_range *range;
> +	unsigned int i;
> +	u32 val;
> +
> +	if (pg->mux_reg > 0) {
> +		for (i = 0; i < ARRAY_SIZE(pg->mux_option); i++) {
> +			if (pg->mux_option[i] == func)
> +				break;
> +		}
> +		if (i == ARRAY_SIZE(pg->mux_option)) {
> +			dev_err(pctl->dev, "Cannot mux pin %u to function %u\n",
> +				group, func);
> +			return -EINVAL;
> +		}
> +
> +		val = pctl_readl(pctl, pg->mux_reg);
> +		val &= ~(pg->mux_mask << pg->mux_shift);
> +		val |= i << pg->mux_shift;
> +		pctl_writel(pctl, val, pg->mux_reg);
> +
> +		if (pf->scenarios) {
> +			for (i = 0; i < pf->nscenarios; i++) {
> +				if (pf->scenarios[i] == group)
> +					break;
> +			}
> +			if (WARN_ON(i == pf->nscenarios))
> +				return -EINVAL;
> +
> +			val = pctl_readl(pctl, pf->scenario_reg);
> +			val &= ~(pf->scenario_mask << pf->scenario_shift);
> +			val |= i << pf->scenario_shift;
> +			pctl_writel(pctl, val, pf->scenario_reg);
> +		}
> +	}
> +
> +	range = pinctrl_find_gpio_range_from_pin(pctl->pctldev, group);
> +	if (range)
> +		gpio_disable(gc_to_bank(range->gc), group - range->pin_base);
> +

If you plan to submit a v4, how about using "pg->pins" here instead of "group"?

Using "group" relies on having the same numberspace for the group and the pin,
and it'll break when introducing the RPU pinctrl.

Thanks!
-- 
Ezequiel

  parent reply	other threads:[~2015-04-28 23:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-07 19:44 [PATCH V3 0/2] pinctrl: Support for IMG Pistachio Andrew Bresticker
2015-04-07 19:44 ` [PATCH V3 1/2] pinctrl: Add Pistachio SoC pin control binding document Andrew Bresticker
2015-04-07 19:44 ` [PATCH V3 2/2] pinctrl: Add Pistachio SoC pin control driver Andrew Bresticker
2015-04-17  5:27   ` Ezequiel Garcia
2015-04-17 16:39     ` Andrew Bresticker
2015-04-28 22:40   ` Ezequiel Garcia
2015-04-28 22:56     ` Andrew Bresticker
2015-04-28 23:24   ` Ezequiel Garcia [this message]
2015-04-29  0:49     ` Andrew Bresticker

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=554016A5.7040209@imgtec.com \
    --to=ezequiel.garcia@imgtec.com \
    --cc=Damien.Horsley@imgtec.com \
    --cc=abrestic@chromium.org \
    --cc=cernekee@chromium.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gnurou@gmail.com \
    --cc=govindraj.raja@imgtec.com \
    --cc=james.hartley@imgtec.com \
    --cc=james.hogan@imgtec.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=pebolle@tiscali.nl \
    --cc=ralf@linux-mips.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