Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: Niklas Cassel <Niklas.Cassel@wdc.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Damien Le Moal <damien.lemoal@opensource.wdc.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	"linux-riscv@lists.infradead.org"
	<linux-riscv@lists.infradead.org>
Subject: Re: [PATCH] gpio: sifive: use the correct register to read output values
Date: Tue, 8 Feb 2022 10:00:04 +0000	[thread overview]
Message-ID: <YgI/I3DAcPSnlOGX@x1-carbon> (raw)
In-Reply-To: <CAMRc=MfrQYSOu+6ZPgLqxek2RfvmCVzS64rKRp_rsq+Hk1QYxg@mail.gmail.com>

On Tue, Feb 08, 2022 at 10:44:41AM +0100, Bartosz Golaszewski wrote:
> On Sat, Feb 5, 2022 at 12:33 AM Damien Le Moal
> <damien.lemoal@opensource.wdc.com> wrote:
> >
> > On 2/4/22 22:02, Niklas Cassel wrote:
> > > From: Niklas Cassel <niklas.cassel@wdc.com>
> > >
> > > Setting the output of a GPIO to 1 using gpiod_set_value(), followed by
> > > reading the same GPIO using gpiod_get_value(), will currently yield an
> > > incorrect result.
> > >
> > > This is because the SiFive GPIO device stores the output values in reg_set,
> > > not reg_dat.
> > >
> > > Supply the flag BGPIOF_READ_OUTPUT_REG_SET to bgpio_init() so that the
> > > generic driver reads the correct register.
> > >
> > > Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
> >
> > This probably needs a Fixes tag. I have not checked which patch though.
> >
> 
> I added the tag and queued this for fixes, thanks!

Hello Bart,

Thank you for queueing and amending the Fixes tag!


Kind regards,
Niklas


> 
> Bart
> 
> > > ---
> > > The patch was tested on a canaan,k210 board (canaan,k210-gpiohs compatible
> > > string). It would be nice with a Tested-by from someone with a SiFive board.
> > >
> > > However, the u-boot driver for this device already behaves exactly the same
> > > as this driver does after my patch, for all platforms using the driver.
> > >
> > >  drivers/gpio/gpio-sifive.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/gpio/gpio-sifive.c b/drivers/gpio/gpio-sifive.c
> > > index 403f9e833d6a..7d82388b4ab7 100644
> > > --- a/drivers/gpio/gpio-sifive.c
> > > +++ b/drivers/gpio/gpio-sifive.c
> > > @@ -223,7 +223,7 @@ static int sifive_gpio_probe(struct platform_device *pdev)
> > >                        NULL,
> > >                        chip->base + SIFIVE_GPIO_OUTPUT_EN,
> > >                        chip->base + SIFIVE_GPIO_INPUT_EN,
> > > -                      0);
> > > +                      BGPIOF_READ_OUTPUT_REG_SET);
> > >       if (ret) {
> > >               dev_err(dev, "unable to init generic GPIO\n");
> > >               return ret;
> >
> >
> > --
> > Damien Le Moal
> > Western Digital Research

  reply	other threads:[~2022-02-08 11:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-04 13:02 [PATCH] gpio: sifive: use the correct register to read output values Niklas Cassel
2022-02-04 23:33 ` Damien Le Moal
2022-02-08  9:44   ` Bartosz Golaszewski
2022-02-08 10:00     ` Niklas Cassel [this message]
2022-02-05 16:39 ` Linus Walleij
2022-02-08 10:13   ` Niklas Cassel

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=YgI/I3DAcPSnlOGX@x1-carbon \
    --to=niklas.cassel@wdc.com \
    --cc=brgl@bgdev.pl \
    --cc=damien.lemoal@opensource.wdc.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    /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