linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v2] PCI: dra7xx: Fix reset behaviour
       [not found]                   ` <20210624233448.ouvczfbogmtnbrye@pali>
@ 2021-06-25  0:09                     ` Linus Walleij
  2021-06-25  8:05                       ` Luca Ceresoli
  0 siblings, 1 reply; 2+ messages in thread
From: Linus Walleij @ 2021-06-25  0:09 UTC (permalink / raw)
  To: Pali Rohár, Bartosz Golaszewski
  Cc: Luca Ceresoli, Kishon Vijay Abraham I, Lorenzo Pieralisi,
	linux-pci, Linux-OMAP, Linux ARM, linux-kernel, Rob Herring,
	Bjorn Helgaas, open list:GPIO SUBSYSTEM

On Fri, Jun 25, 2021 at 1:34 AM Pali Rohár <pali@kernel.org> wrote:

> > gpiod_set_value(gpiod, 1) == assert the line
> > gpiod_set_value(gpiod, 0) == de-assert the line
>
> Problem is that some pci controller drivers (e.g. pci-j721e.c or
> pcie-rockchip-host.c) expects that gpiod_set_value_cansleep(gpiod, 1)
> de-asserts the line and it is already used in this way.
>
> Which is opposite of the behavior which you wrote above.

I sketched a way out of the problem using a quirk in
gpiolib in another response. We have a few of these
cases where we have to code our way out of mistakes,
such things happen.

The problem is common, and due to the fact that device tree
authors ignores the flag GPIO_ACTIVE_HIGH (which has
been around since the early days of device tree on PowerPC)
instead they opt to do the inversion in code. Which violates the
contract that the DT should describe the hardware.

The ambition of the DT specifications/schemas are to be operating
system independent, and this kind of stuff creates a situation
where other operating systems can't use the specification without
also going and looking at how Linux has implemented stuff.
Which is against the ambition of the device tree work.

> I would suggest to define enum/macro with word ASSERT and DEASSERT in
> its name instead of just true/false boolean or 0/1 int.
>
> In case of this PERST# misunderstanding, having assert/deassert in name
> should really help.

Hm that looks useful, Bart &co what do you think?

#define GPIOD_ASSERTED 1
#define GPIOD_DEASSERTED 0

in consumer.h, would that be helpful for users?

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] PCI: dra7xx: Fix reset behaviour
  2021-06-25  0:09                     ` [PATCH v2] PCI: dra7xx: Fix reset behaviour Linus Walleij
@ 2021-06-25  8:05                       ` Luca Ceresoli
  0 siblings, 0 replies; 2+ messages in thread
From: Luca Ceresoli @ 2021-06-25  8:05 UTC (permalink / raw)
  To: Linus Walleij, Pali Rohár, Bartosz Golaszewski
  Cc: Kishon Vijay Abraham I, Lorenzo Pieralisi, linux-pci, Linux-OMAP,
	Linux ARM, linux-kernel, Rob Herring, Bjorn Helgaas,
	open list:GPIO SUBSYSTEM

Hi,

On 25/06/21 02:09, Linus Walleij wrote:
> On Fri, Jun 25, 2021 at 1:34 AM Pali Rohár <pali@kernel.org> wrote:
> 
>>> gpiod_set_value(gpiod, 1) == assert the line
>>> gpiod_set_value(gpiod, 0) == de-assert the line
>>
>> Problem is that some pci controller drivers (e.g. pci-j721e.c or
>> pcie-rockchip-host.c) expects that gpiod_set_value_cansleep(gpiod, 1)
>> de-asserts the line and it is already used in this way.
>>
>> Which is opposite of the behavior which you wrote above.
> 
> I sketched a way out of the problem using a quirk in
> gpiolib in another response. We have a few of these
> cases where we have to code our way out of mistakes,
> such things happen.
> 
> The problem is common, and due to the fact that device tree
> authors ignores the flag GPIO_ACTIVE_HIGH (which has
> been around since the early days of device tree on PowerPC)
> instead they opt to do the inversion in code. Which violates the
> contract that the DT should describe the hardware.
> 
> The ambition of the DT specifications/schemas are to be operating
> system independent, and this kind of stuff creates a situation
> where other operating systems can't use the specification without
> also going and looking at how Linux has implemented stuff.
> Which is against the ambition of the device tree work.
> 
>> I would suggest to define enum/macro with word ASSERT and DEASSERT in
>> its name instead of just true/false boolean or 0/1 int.
>>
>> In case of this PERST# misunderstanding, having assert/deassert in name
>> should really help.
> 
> Hm that looks useful, Bart &co what do you think?
> 
> #define GPIOD_ASSERTED 1
> #define GPIOD_DEASSERTED 0
> 
> in consumer.h, would that be helpful for users?

Looks like a good idea to me. It would help making people aware that
gpiod_set_value() & co do _not_ take a physical line value. It's done
that way since ages, it's documented, yet many developers are still
unaware of that...

-- 
Luca


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-25  8:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20210622115604.GA25503@lpieralisi>
     [not found] ` <20210622121649.ouiaecdvwutgdyy5@pali>
     [not found]   ` <18a104a9-2cb8-7535-a5b2-f5f049adff47@lucaceresoli.net>
     [not found]     ` <4d4c0d4d-41b4-4756-5189-bffa15f88406@ti.com>
     [not found]       ` <20210622205220.ypu22tuxhpdn2jwz@pali>
     [not found]         ` <2873969e-ac56-a41f-0cc9-38e387542aa1@lucaceresoli.net>
     [not found]           ` <20210622211901.ikulpy32d6qlr4yw@pali>
     [not found]             ` <588741e4-b085-8ae2-3311-27037c040a57@lucaceresoli.net>
     [not found]               ` <20210622222328.3lfgkrhsdy6izedv@pali>
     [not found]                 ` <CACRpkdai2cvoNFR8yH2MHP+R27nQm1HZNK4-mJ50mE7DHrBmXw@mail.gmail.com>
     [not found]                   ` <20210624233448.ouvczfbogmtnbrye@pali>
2021-06-25  0:09                     ` [PATCH v2] PCI: dra7xx: Fix reset behaviour Linus Walleij
2021-06-25  8:05                       ` Luca Ceresoli

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).