From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Joey Gouly <joey.gouly@arm.com>
Cc: Andy Shevchenko <andriy.shevchenko@intel.com>,
"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
Linus Walleij <linus.walleij@linaro.org>,
Hector Martin <marcan@marcan.st>, Marc Zyngier <maz@kernel.org>,
Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>,
Sven Peter <sven@svenpeter.dev>,
nd@arm.com, Stan Skowronek <stan@corellium.com>
Subject: Re: [PATCH v1 1/1] pinctrl: add pinctrl/GPIO driver for Apple SoCs
Date: Sun, 26 Sep 2021 08:08:46 +0300 [thread overview]
Message-ID: <CAHp75VecEoUnNLx_tw3Fa=9jaDQaXbaaN=gGfFSXPkvpUOihoQ@mail.gmail.com> (raw)
In-Reply-To: <20210925134425.GA4681@e124191.cambridge.arm.com>
On Sat, Sep 25, 2021 at 4:45 PM Joey Gouly <joey.gouly@arm.com> wrote:
> On Wed, Sep 22, 2021 at 10:20:39AM +0300, Andy Shevchenko wrote:
...
> > > +F: drivers/pinctrl/pinctrl-apple-gpio.c
> >
> > Are you sure it's a good naming? Have you guaranteed that next Apple silicons
> > will use the same / compatible IP?
> We don't know what will be in future Apple SoCs, however this same GPIO
> HW has been in iPhones dating back to at least the iPhone 7 (2016). If
> there are minor changes we can add a new compatible, and if there is new
> HW in the future we can introduce a new file for it.
Do we have a chip name? For example, for M1 it's T8101 or something
like that. I would use a chip name/family rather than a broad brand
name.
...
> > > + prev = readl(ppin);
> > > + cfg = (prev & ~clr) | set;
> > > +
> > > + if(!(prev & REG_GPIOx_CFG_DONE))
> > > + writel(cfg & ~REG_GPIOx_CFG_DONE, ppin);
> > > + writel(cfg, ppin);
> >
> > Is it IP requirement to have sequential writes? Can it be done in one?
> We unfortunately don't have the documentation for this HW, so this behaviour is
> based on observing what macOS does.
So, then there are following remarks/questions:
1/ Have you tested when it does a single write?
2/ If it doesn't work, this piece deserves a good comment.
...
> > > + if(!of_find_property(node, "gpio-controller", NULL)) {
> > > + dev_err(pctl->dev, "Apple GPIO must have 'gpio-controller' property.\n");
> > > + return -ENODEV;
> > > + }
> >
> > How is it possible?
> This is possible if booted with an invalid DTB. "gpio-controller" is a
> required property according to Documentation/devicetree/bindings/pinctrl/apple,pinctrl.yaml.
No, we don't do silly checks. Compare to other pin control drivers. If
DTB is wrong, you will see it sooner or later.
...
> > > + if (of_find_property(node, "interrupt-controller", NULL)) {
> >
> > Are you sure you need this check and OF core doesn't provide a generic way for this?
> >
> I don't think so, and pinctrl-equilibrium.c does something similar in
> `gpiochip_setup`.
Linus? Do we really need this?
...
> > > + if (of_parse_phandle_with_fixed_args(pdev->dev.of_node, "gpio-ranges",
> > > + 3, 0, &pinspec)) {
> > > + dev_err(&pdev->dev, "gpio-ranges property not found\n");
> > > + return -EINVAL;
> > > + }
> > > +
> > > + pctl->npins = pinspec.args[2];
> > > + pin_base = pinspec.args[1];
> >
> >
> > Isn't this being provided by pin control?
> Not that I am aware of. It is a similar pattern to other pinctrl drivers
> like pinctrl-rza1.c and pinctrl-npcm7xx.c. The driver needs to get the
> number of pins/base from the DT to setup the internal data structures.
So, maybe you need to refactor the pin control core first and provide
some stubs that will serve your purposes, but to me it sounds weird to
have all these checks.
Linus, what is your opinion / input here?
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2021-09-26 5:09 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-21 22:29 [PATCH v1 0/1] pinctrl/GPIO driver for Apple SoCs Joey Gouly
2021-09-21 22:29 ` [PATCH v1 1/1] pinctrl: add " Joey Gouly
2021-09-22 7:20 ` Andy Shevchenko
2021-09-25 13:44 ` Joey Gouly
2021-09-26 5:08 ` Andy Shevchenko [this message]
2021-09-26 12:48 ` Linus Walleij
2021-09-26 12:56 ` Sven Peter
2021-09-26 13:10 ` Linus Walleij
2021-09-26 14:35 ` Sven Peter
2021-09-26 16:28 ` Andy Shevchenko
2021-09-27 5:45 ` Sven Peter
2021-09-27 9:00 ` Andy Shevchenko
2021-09-27 9:27 ` Hans de Goede
2021-09-27 9:43 ` Andy Shevchenko
2021-09-27 8:46 ` Alyssa Rosenzweig
2021-09-27 8:55 ` Andy Shevchenko
2021-09-27 23:34 ` Linus Walleij
2021-09-28 21:20 ` Joey Gouly
2021-09-28 18:21 ` Joey Gouly
2021-09-28 21:50 ` Linus Walleij
2021-09-22 13:09 ` Marc Zyngier
2021-09-22 23:58 ` Linus Walleij
2021-09-22 6:59 ` [PATCH v1 0/1] " Andy Shevchenko
2021-09-23 0:10 ` 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='CAHp75VecEoUnNLx_tw3Fa=9jaDQaXbaaN=gGfFSXPkvpUOihoQ@mail.gmail.com' \
--to=andy.shevchenko@gmail.com \
--cc=alyssa.rosenzweig@collabora.com \
--cc=andriy.shevchenko@intel.com \
--cc=joey.gouly@arm.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=marcan@marcan.st \
--cc=maz@kernel.org \
--cc=nd@arm.com \
--cc=stan@corellium.com \
--cc=sven@svenpeter.dev \
/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).