linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcos Del Sol Vives <marcos@orca.pet>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: William Breathitt Gray <wbg@kernel.org>,
	linux-kernel@vger.kernel.org,
	Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>,
	linux-gpio@vger.kernel.org
Subject: Re: [PATCH v2] gpio: vortex: add new GPIO device driver
Date: Tue, 19 Aug 2025 22:17:14 +0200	[thread overview]
Message-ID: <a36a853d-5f32-409e-8add-c60b7f5d2fa9@orca.pet> (raw)
In-Reply-To: <aHElavFTptu0q4Kj@smile.fi.intel.com>

El 11/07/2025 a las 16:53, Andy Shevchenko escribió:
>> Again, I am not an expert on the Linux kernel, but I did not see any code
>> or examples using neither gpio-mmio nor gpio-regmap for I/O-mapped registers.
> 
> $ git grep -lw '\.io_port[[:space:]]\+= true,'
> drivers/counter/104-quad-8.c
> drivers/gpio/gpio-104-dio-48e.c
> drivers/gpio/gpio-104-idi-48.c
> drivers/gpio/gpio-104-idio-16.c
> drivers/gpio/gpio-exar.c
> drivers/gpio/gpio-gpio-mm.c
> drivers/gpio/gpio-pci-idio-16.c
> drivers/gpio/gpio-pcie-idio-24.c
> drivers/gpio/gpio-ws16c48.c
> drivers/iio/addac/stx104.c
> drivers/iio/dac/cio-dac.c
> 
> Take a look.

I've already made a third version of the patch, using gpio-regmap this time.
This time I'm also using a Southbridge driver that pulls it as a platform
device, much like the rdc321x-southbridge.c does. It's not yet ready for
merging, but it's available for now at
https://github.com/socram8888/linux/tree/vortex-gpio

I have found a small issue though regarding gpio-regmap, and before making
a third version of the patch, I'd prefer to know the way to approach it.

The Vortex86 SoCs require the direction of the GPIO pin to be set before
writing the pin's value. Otherwise, writes to the data ports are ignored.

Currently gpio-regmap does it in the opposite order:

> static int gpio_regmap_direction_output(struct gpio_chip *chip,
> 					unsigned int offset, int value)
> {
>	gpio_regmap_set(chip, offset, value);
>
> 	return gpio_regmap_set_direction(chip, offset, true);
> }

(I have also noticed that it does not properly check the return value of
gpio_regmap_set, but that's another thing)

So there are IMO three different approaches:

1. Add a boolean flag that allows changing the behaviour. If set, invert
the order of operations. Else do as before.
2. Same, but with a "flags" bitfield, in case more flags need to be added
in the future.
3. Do an additional "gpio_regmap_set" after setting the direction. This
means no new fields need to be added to the structures but causes an extra
write that may not be needed on other drivers.

>> IRQ is only available for the first two ports out of the five available.
> Would  it be a problem to support them?

I cannot test that on my platform: as mentioned before, only ports 0 and 1
have IRQs, and in my mini PC I only have two pins available, and they're
both on port 4. 

Any code I'd write would be completely untested and IMHO sounds like a
terrible idea to have such code merged.

Thanks,
Marcos


  reply	other threads:[~2025-08-19 20:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-09  9:15 [PATCH v2] gpio: vortex: add new GPIO device driver Marcos Del Sol Vives
2025-07-11 10:19 ` Bartosz Golaszewski
2025-07-11 14:24   ` Marcos Del Sol Vives
2025-07-11 15:01     ` Andy Shevchenko
2025-07-11 21:58       ` Marcos Del Sol Vives
2025-07-11 11:43 ` Andy Shevchenko
2025-07-11 11:56   ` Bartosz Golaszewski
2025-07-11 12:06     ` Andy Shevchenko
2025-07-11 13:52   ` Marcos Del Sol Vives
2025-07-11 14:53     ` Andy Shevchenko
2025-08-19 20:17       ` Marcos Del Sol Vives [this message]
2025-08-20 11:34         ` Andy Shevchenko
2025-08-20 12:00   ` William Breathitt Gray
2025-08-21  9:44     ` Andy Shevchenko

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=a36a853d-5f32-409e-8add-c60b7f5d2fa9@orca.pet \
    --to=marcos@orca.pet \
    --cc=andriy.shevchenko@intel.com \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wbg@kernel.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).