From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: Niklas Cassel <Niklas.Cassel@wdc.com>,
Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <brgl@bgdev.pl>,
Palmer Dabbelt <palmer@dabbelt.com>,
Paul Walmsley <paul.walmsley@sifive.com>
Cc: "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: Sat, 5 Feb 2022 08:33:51 +0900 [thread overview]
Message-ID: <aa6f85f3-1146-e857-148c-7a314b21e647@opensource.wdc.com> (raw)
In-Reply-To: <20220204130142.21727-1-Niklas.Cassel@wdc.com>
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.
> ---
> 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
next prev parent reply other threads:[~2022-02-04 23:33 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 [this message]
2022-02-08 9:44 ` Bartosz Golaszewski
2022-02-08 10:00 ` Niklas Cassel
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=aa6f85f3-1146-e857-148c-7a314b21e647@opensource.wdc.com \
--to=damien.lemoal@opensource.wdc.com \
--cc=Niklas.Cassel@wdc.com \
--cc=brgl@bgdev.pl \
--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