From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: linux-aspeed@lists.ozlabs.org
Subject: [PATCH 2/4] gpio: aspeed: Add "Read Data" register to read the write latch
Date: Tue, 12 Jun 2018 17:18:06 +1000 [thread overview]
Message-ID: <43f17984eb20fefc78189e4020d0abca36a90f8e.camel@kernel.crashing.org> (raw)
In-Reply-To: <CACPK8Xf6Z8AVxt8gHnjvD+hemzq-P5nZ0C30Q+biqZtUWFO1_A@mail.gmail.com>
On Tue, 2018-06-12 at 15:08 +0930, Joel Stanley wrote:
> On 12 June 2018 at 09:40, Benjamin Herrenschmidt
> <benh@kernel.crashing.org> wrote:
> > The Aspeed GPIO hardware has a quirk: the value register, for an
> > output GPIO, doesn't contain the last value written (the write
> > latch content) but the sampled input value.
> >
> > This means that when reading back shortly after writing, you can
> > get an incorrect value as the input value is delayed by a few
> > synchronizers.
> >
> > The HW supports a separate read-only register "Data Read Register"
> > which allows you to read the write latch instead.
> >
> > This adds the definition for it, and uses it for the initial
> > population of the GPIO value cache. It will be used more in
> > subsequent patches.
> > can be
> >
> > Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> > ---
> > drivers/gpio/gpio-aspeed.c | 17 +++++++++++++++--
> > 1 file changed, 15 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c
> > index 42aadd52f77d..210c3fcc7a40 100644
> > --- a/drivers/gpio/gpio-aspeed.c
> > +++ b/drivers/gpio/gpio-aspeed.c
> > @@ -59,7 +59,10 @@ struct aspeed_gpio {
> > };
> >
> > struct aspeed_gpio_bank {
> > - uint16_t val_regs;
> > + uint16_t val_regs; /* 0: Wr: set write latch, Rd: read input value (*)
> > + * 4: Direction (0=in, 1=out)
> > + */
> > + uint16_t rdata_reg; /* Wr: <none> Rd: read write latch */
>
> The numbers weren't immediately obvious to me.
>
> > uint16_t irq_regs;
> > uint16_t debounce_regs;
> > uint16_t tolerance_regs;
> > @@ -71,6 +74,7 @@ static const int debounce_timers[4] = { 0x00, 0x50, 0x54, 0x58 };
> > static const struct aspeed_gpio_bank aspeed_gpio_banks[] = {
> > {
> > .val_regs = 0x0000,
> > + .rdata_reg = 0x00c0,
> > .irq_regs = 0x0008,
> > .debounce_regs = 0x0040,
> > .tolerance_regs = 0x001c,
> > @@ -78,6 +82,7 @@ static const struct aspeed_gpio_bank aspeed_gpio_banks[] = {
> > },
> > {
> > .val_regs = 0x0020,
> > + .rdata_reg = 0x00c4,
> > .irq_regs = 0x0028,
> > .debounce_regs = 0x0048,
> > .tolerance_regs = 0x003c,
> > @@ -85,6 +90,7 @@ static const struct aspeed_gpio_bank aspeed_gpio_banks[] = {
> > },
> > {
> > .val_regs = 0x0070,
> > + .rdata_reg = 0x00c8,
> > .irq_regs = 0x0098,
> > .debounce_regs = 0x00b0,
> > .tolerance_regs = 0x00ac,
> > @@ -92,6 +98,7 @@ static const struct aspeed_gpio_bank aspeed_gpio_banks[] = {
> > },
> > {
> > .val_regs = 0x0078,
> > + .rdata_reg = 0x00d0,
>
> 0x00cc?
>
> I was really confused for a second, as I'd applied the series to my
> tree for testing, and my source as correct. It looks like you fixed
> these in patch 3.
Ah yes, patch splitting mistake. I'll fix that up, thanks.
> > .irq_regs = 0x00e8,
> > .debounce_regs = 0x0100,
> > .tolerance_regs = 0x00fc,
next prev parent reply other threads:[~2018-06-12 7:18 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-12 0:10 [PATCH 0/4] gpio: aspeed: Fixes and support for sharing with co-processor Benjamin Herrenschmidt
2018-06-12 0:10 ` [PATCH 1/4] gpio: aspeed: Rework register type accessors Benjamin Herrenschmidt
2018-06-12 4:49 ` Benjamin Herrenschmidt
2018-06-12 0:10 ` [PATCH 2/4] gpio: aspeed: Add "Read Data" register to read the write latch Benjamin Herrenschmidt
2018-06-12 5:38 ` Joel Stanley
2018-06-12 7:18 ` Benjamin Herrenschmidt [this message]
2018-06-12 0:10 ` [PATCH 3/4] gpio: aspeed: Add command source registers Benjamin Herrenschmidt
2018-06-12 5:38 ` Joel Stanley
2018-06-12 0:10 ` [PATCH 4/4] gpio: aspeed: Add interfaces for co-processor to grab GPIOs Benjamin Herrenschmidt
2018-06-12 5:37 ` Joel Stanley
2018-06-12 7:17 ` Benjamin Herrenschmidt
2018-06-15 6:04 ` Benjamin Herrenschmidt
2018-06-14 8:59 ` Linus Walleij
2018-06-14 23:40 ` Benjamin Herrenschmidt
2018-06-28 13:42 ` Linus Walleij
2018-06-28 23:53 ` Benjamin Herrenschmidt
2018-06-14 9:01 ` [PATCH 0/4] gpio: aspeed: Fixes and support for sharing with co-processor Linus Walleij
2018-06-14 23:42 ` Benjamin Herrenschmidt
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=43f17984eb20fefc78189e4020d0abca36a90f8e.camel@kernel.crashing.org \
--to=benh@kernel.crashing.org \
--cc=linux-aspeed@lists.ozlabs.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).