From: Linus Walleij <linus.walleij@linaro.org>
To: Barry Song <baohua@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Barry Song <Baohua.Song@csr.com>,
Linux GPIO List <linux-gpio@vger.kernel.org>,
Guoying Zhang <Guoying.Zhang@csr.com>,
Wei Chen <Wei.Chen@csr.com>
Subject: Re: [PATCH] pinctrl: sirf/atlas7: stop poking around in GPIO internals
Date: Thu, 18 Feb 2016 21:42:18 +0100 [thread overview]
Message-ID: <CACRpkdb8SVGdwhY9zsYxZQ5H2R-qd1v7iFek3SwdtAnWr41DaA@mail.gmail.com> (raw)
In-Reply-To: <CAGsJ_4zHEtmHmxbprnc=1qOXgk3G_pqyueHke8PusMKNP_rmmg@mail.gmail.com>
On Thu, Feb 18, 2016 at 3:50 AM, Barry Song <baohua@kernel.org> wrote:
> gpiochip_add(chip will call this automatically since range is set in dtsi:
> gpio_0: gpio_mediam@17040000 {
> #gpio-cells = <2>;
> #interrupt-cells = <2>;
> compatible = "sirf,atlas7-gpio";
> reg = <0x17040000 0x1000>;
> interrupts = <0 13 0>, <0 14 0>;
> clocks = <&car 98>;
> clock-names = "gpio0_io";
> gpio-controller;
> interrupt-controller;
>
> gpio-banks = <2>;
> gpio-ranges = <&pinctrl 0 0 0>,
> <&pinctrl 32 0 0>;
> gpio-ranges-group-names = "lvds_gpio_grp",
> "jtag_uart_nand_gpio_grp";
Aha I see.
>> -
>> - /* Records gpio_pin_range to a7gc */
>> - list_for_each_entry(pin_range, &chip->pin_ranges, node) {
>> - struct pinctrl_gpio_range *range;
>> -
>> - range = &pin_range->range;
>> - if (range->id == NGPIO_OF_BANK * idx) {
>> - bank->gpio_offset = range->id;
>> - bank->ngpio = range->npins;
>> - bank->gpio_pins = range->pins;
>> - bank->pctldev = pin_range->pctldev;
>> - break;
>> - }
>> - }
>> -
>> - BUG_ON(!bank->pctldev);
>
> this doesn't work. my pin range is not continuous and linear, so we
> need the "if (range->id == NGPIO_OF_BANK * idx)" to calculate the
> gpio_offset.
> and gpio_offset is used in many places:
Can't you use:
struct pinctrl_gpio_range *range =
pinctrl_find_gpio_range_from_pin(pctldev, pin);
In these places instead?
?
That is what most drivers do.
Yours,
Linus Walleij
next prev parent reply other threads:[~2016-02-18 20:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-12 8:31 [PATCH] pinctrl: sirf/atlas7: stop poking around in GPIO internals Linus Walleij
2016-02-18 2:50 ` Barry Song
2016-02-18 20:42 ` Linus Walleij [this message]
2016-02-19 3:21 ` Barry Song
2016-02-19 8:21 ` 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=CACRpkdb8SVGdwhY9zsYxZQ5H2R-qd1v7iFek3SwdtAnWr41DaA@mail.gmail.com \
--to=linus.walleij@linaro.org \
--cc=Baohua.Song@csr.com \
--cc=Guoying.Zhang@csr.com \
--cc=Wei.Chen@csr.com \
--cc=baohua@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.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).