From: Linus Walleij <linus.walleij@linaro.org>
To: Joey Gouly <joey.gouly@arm.com>, Mark Brown <broonie@kernel.org>
Cc: "open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
Hector Martin <marcan@marcan.st>, Marc Zyngier <maz@kernel.org>,
Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>,
Sven Peter <sven@svenpeter.dev>,
"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
<devicetree@vger.kernel.org>, Rob Herring <robh+dt@kernel.org>,
Mark Kettenis <kettenis@openbsd.org>, nd <nd@arm.com>,
Stan Skowronek <stan@corellium.com>
Subject: Re: [PATCH v2 3/3] pinctrl: add pinctrl/GPIO driver for Apple SoCs
Date: Mon, 4 Oct 2021 00:35:26 +0200 [thread overview]
Message-ID: <CACRpkdYC0js+++Q4dFL4P0WiMfPOJthaH3kkf8T31UUb3OBDqQ@mail.gmail.com> (raw)
In-Reply-To: <20211001191209.29988-4-joey.gouly@arm.com>
Hi Joey!
over all this driver is much improved and using a lot of stock functions
in the pin control core and getting really clean and compact.
I have one major nit below:
On Fri, Oct 1, 2021 at 9:12 PM Joey Gouly <joey.gouly@arm.com> wrote:
> +struct apple_gpio_pinctrl {
> + // Shadow the pin values, the REG_GPIOx_DATA bit can read back stale values.
> + u32 *pin_shadow;
(...)
> +// No locking needed to mask/unmask IRQs as the interrupt mode is per pin-register.
> +static void apple_gpio_set_reg(struct apple_gpio_pinctrl *pctl,
> + unsigned int pin, uint32_t clr, uint32_t set)
> +{
> + void __iomem *ppin = pctl->base + REG_GPIO(pin);
> + uint32_t prev, cfg;
> +
> + prev = pctl->pin_shadow[pin];
> + cfg = (prev & ~clr) | set;
> +
> + if (!(prev & REG_GPIOx_CFG_DONE))
> + writel_relaxed(cfg & ~REG_GPIOx_CFG_DONE, ppin);
> + writel_relaxed(cfg, ppin);
> + pctl->pin_shadow[pin] = cfg;
> +}
Are you not simply reinventing regmap-mmio here?
Keeping shadows of registers including write-only registers
is exactly what regmap does.
Check it out, if in doubt consult Mark Brown, I'm pretty
sure we can add what you need to regmap if it is missing.
> +static uint32_t apple_gpio_get_reg(struct apple_gpio_pinctrl *pctl,
> + unsigned int pin)
> +{
> + return readl_relaxed(pctl->base + REG_GPIO(pin));
> +}
If you use regmap-mmio I am pretty sure this will also
return the right value for the shadowed registers which it
currently does not IIUC.
> + apple_gpio_set_reg(pctl, group, 0,
> + REG_GPIOx_PERIPH | REG_GPIOx_CFG_DONE);
> + else
> + apple_gpio_set_reg(pctl, group, REG_GPIOx_PERIPH,
> + REG_GPIOx_CFG_DONE);
I think all calls to apple_gpio_set_reg() could be replaced with
regmap_update_bits() or similar.
Yours,
Linus Walleij
next prev parent reply other threads:[~2021-10-03 22:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-01 19:12 [PATCH v2 0/3] pinctrl/GPIO driver for Apple SoCs Joey Gouly
2021-10-01 19:12 ` [PATCH v2 1/3] gpio: Allow per-parent interrupt data Joey Gouly
2021-10-03 22:21 ` Linus Walleij
2021-10-01 19:12 ` [PATCH v2 2/3] dt-bindings: pinctrl: Add apple,npins property to apple,pinctrl Joey Gouly
2021-10-01 20:01 ` Mark Kettenis
2021-10-01 23:02 ` Rob Herring
2021-10-03 22:23 ` Linus Walleij
2021-10-01 19:12 ` [PATCH v2 3/3] pinctrl: add pinctrl/GPIO driver for Apple SoCs Joey Gouly
2021-10-03 22:35 ` Linus Walleij [this message]
2021-10-04 3:33 ` Hector Martin
2021-10-14 20:24 ` Joey Gouly
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=CACRpkdYC0js+++Q4dFL4P0WiMfPOJthaH3kkf8T31UUb3OBDqQ@mail.gmail.com \
--to=linus.walleij@linaro.org \
--cc=alyssa.rosenzweig@collabora.com \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=joey.gouly@arm.com \
--cc=kettenis@openbsd.org \
--cc=linux-gpio@vger.kernel.org \
--cc=marcan@marcan.st \
--cc=maz@kernel.org \
--cc=nd@arm.com \
--cc=robh+dt@kernel.org \
--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).