All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Andersson <bjorn.andersson@sonymobile.com>
To: "Ivan T. Ivanov" <iivanov@mm-sol.com>,
	Linus Walleij <linus.walleij@linaro.org>
Cc: Grant Likely <grant.likely@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	David Collins <collinsd@codeaurora.org>,
	Wu Fenglin <fenglinw@qti.qualcomm.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>
Subject: Re: [PATCH v4 3/4] pinctrl: Qualcomm SPMI PMIC GPIO pin controller driver
Date: Tue, 30 Sep 2014 10:02:04 -0700	[thread overview]
Message-ID: <20140930170203.GR28481@sonymobile.com> (raw)
In-Reply-To: <1411564172.18580.69.camel@iivanov-dev>

On Wed 24 Sep 06:09 PDT 2014, Ivan T. Ivanov wrote:

> On Tue, 2014-09-23 at 21:18 -0700, Bjorn Andersson wrote:
> > On Mon 15 Sep 07:44 PDT 2014, Ivan T. Ivanov wrote:
> > 
> 
> <snip>
> 
> > > +static int pmic_gpio_of_xlate(struct gpio_chip *chip,
> > > +                             const struct of_phandle_args *gpio_desc,
> > > +                             u32 *flags)
> > > +{
> > > +       if (chip->of_gpio_n_cells < 2)
> > > +               return -EINVAL;
> > > +
> > > +       if (flags)
> > > +               *flags = gpio_desc->args[1];
> > > +
> > > +       return gpio_desc->args[0] - PMIC_GPIO_PHYSICAL_OFFSET;
> > > +}
> > 
> > If you change:
> >  gpiochip_add_pin_range(&state->chip, dev_name(dev), 0, 0, npins);
> > to:
> >  gpiochip_add_pin_range(&state->chip, dev_name(dev), 1, 0, npins);
> > 
> > And you treat the gpio functions as taking the gpio number instead of pinctrl
> > number (i.e. subtract 1 in those), then gpiolib will provide this function for
> > you.
> > 
> 
> I am unable to make this work. of_gpio_simple_xlate() didn't know that
> GPIO range is offset with 1. Requesting last GPIO return error. And
> debug output looks weird, for example:
> 
> # cat /sys/kernel/debug/gpio
> ...
> GPIOs 220-255, platform/0.c000.gpios, 0.c000.gpios:
> ...
> 
> # cat /sys/kernel/debug/pinctrl/0.c000.gpios/gpio-ranges 
> GPIO ranges handled:
> 1: 0.c000.gpios GPIOS [221 - 256] PINS [0 - 35]
> 
> Advice, please.
> 

Looking at of_gpio_simple_xlate() shows that you're right. It doesn't seem to
be possible to have a gpiochip that is not 0-based. Then I guess you have to
have your own "off-by-one-xlate".

@Linus, any comments on this? All documentation states that we have
gpio1-gpioXX in these chips, so we have to expose it as such or things will be
messy.

> > [..]
> > > +
> > > +static const struct of_device_id pmic_gpio_of_match[] = {
> > > +       { .compatible = "qcom,spmi-pmic-gpio" },
> > 
> > I think this should be more specific, because hopefully the spmi specification
> > will outlive the current pmic gpio block.
> > 
> > So I think you need to list the pmic blocks here (e.g. "qcom,pm8941-gpio").
> 
> I can rename this to lovely "qcom,qpnp-gpio" :-), in this way driver
> can outlive bus on which device is connected this time.
> 

If the mythical qpnp spec actually include a specification for how a gpio block
looks like then sure. Otherwise you would have to list all the pmics that
contain this block.

Regards,
Bjorn

  reply	other threads:[~2014-09-30 17:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-15 14:44 [PATCH v4 0/4] Qualcomm SPMI PMIC pin controller drivers Ivan T. Ivanov
2014-09-15 14:44 ` [PATCH v4 1/4] pinctrl: Device tree bindings for Qualcomm PMIC GPIO block Ivan T. Ivanov
2014-09-15 14:44 ` [PATCH v4 2/4] pinctrl: Device tree bindings for Qualcomm PMIC MPP block Ivan T. Ivanov
2014-09-15 14:44 ` [PATCH v4 3/4] pinctrl: Qualcomm SPMI PMIC GPIO pin controller driver Ivan T. Ivanov
2014-09-24  4:18   ` Bjorn Andersson
2014-09-24  8:14     ` Ivan T. Ivanov
2014-09-24 13:09     ` Ivan T. Ivanov
2014-09-30 17:02       ` Bjorn Andersson [this message]
2014-10-07 14:14         ` Linus Walleij
2014-09-15 14:44 ` [PATCH v4 4/4] pinctrl: Qualcomm SPMI PMIC MPP " Ivan T. Ivanov
2014-09-23 15:16 ` [PATCH v4 0/4] Qualcomm SPMI PMIC pin controller drivers Linus Walleij

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=20140930170203.GR28481@sonymobile.com \
    --to=bjorn.andersson@sonymobile.com \
    --cc=collinsd@codeaurora.org \
    --cc=devicetree@vger.kernel.org \
    --cc=fenglinw@qti.qualcomm.com \
    --cc=grant.likely@linaro.org \
    --cc=iivanov@mm-sol.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.