From: Andy Shevchenko <andy.shevchenko@gmail.com> To: Ricardo Ribalda <ribalda@google.com> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>, ACPI Devel Maling List <linux-acpi@vger.kernel.org>, "Rafael J. Wysocki" <rjw@rjwysocki.net>, "open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>, Tomasz Figa <tfiga@google.com> Subject: Re: [PATCH v1 2/3] Documentation: firmware-guide: gpio-properties: active_low only for GpioIo() Date: Thu, 29 Oct 2020 21:11:53 +0200 Message-ID: <20201029191153.GI4077@smile.fi.intel.com> (raw) In-Reply-To: <CANiDSCvD3JqT8pZy7MtuCtGGSP8bUrkndCf6CK866MeH7Hk3sA@mail.gmail.com> On Thu, Oct 29, 2020 at 07:58:39PM +0100, Ricardo Ribalda wrote: > On Thu, Oct 29, 2020 at 7:13 PM Andy Shevchenko > <andy.shevchenko@gmail.com> wrote: > > On Thu, Oct 29, 2020 at 8:10 PM Ricardo Ribalda <ribalda@google.com> wrote: > > > On Thu, Oct 29, 2020 at 6:32 PM Ricardo Ribalda <ribalda@google.com> wrote: > > > > On Thu, Oct 29, 2020 at 6:26 PM Andy Shevchenko > > > > <andy.shevchenko@gmail.com> wrote: > > > > > On Thu, Oct 29, 2020 at 7:20 PM Andy Shevchenko > > > > > <andy.shevchenko@gmail.com> wrote: > > > > > > On Thu, Oct 29, 2020 at 7:17 PM Andy Shevchenko > > > > > > <andy.shevchenko@gmail.com> wrote: ... > > > > > > > > Let me try to explain myself again: > > > > > > > > > > > > > > > > I have a gpio pin that produces IRQs on both edges. so ActiveLevel is Both > > > > > > > > > > > > > > > > The problem is that the value of that pin is inverted: Low means 1 and > > > > > > > > high means 0. > > > > > > > > > > > > > > > > How can I describe that the pin "is inverted" without using the _DSD field? > > > > > > > > > > > > > > "Both edges" and "inverted" or "polarity low" in one sentence make no sense. > > > > > > > > > > > > To be on the constructive side, I can *imagine* so badly designed > > > > > > hardware that uses level and edge at the same time, but before I go to > > > > > > conclusions, can you share relevant (pieces of) datasheet? > > > > > > > > > > The [1] is a real example of how GPIO is being used to detect changing > > > > > of current level of the signal. > > > > > Note, ACPI tables for that device have problems [2], but I guess you > > > > > may get the idea. > > > > > > > > > > > > This is exactly what I need to do. Get an IRQ whenever the value > > > > changes. But the pin is "inverted" > > > > > > > > This is the "schematic" : https://ibb.co/f8GMBbP . I want to pass to > > > > userspace a "1" when the switch is closed and "0" when it is open. > > > > > > > And there are also other devices where the swith works the other way > > > around, so the acpi should be verbose enough to describe both > > > situations. > > > > > > With my proposal (use the same active_low field as with GpioIO) we > > > cover both usecases. > > > > Even without your proposal it's feasible. > > You see, the problem here is that if you describe GPIO as Interrupt, > > the edge and level together make complete nonsense. > > > > Solution: do *not* describe it as Interrupt. > > Now I get my mistake: > > I thought that gpiod_to_irq will not work unless it was a GpioInt() > but it works fine. So in this case I will just convert it to that. It's actually that gpio_to_irq() is solely for GPIOs which initially are not IRQs. > Could we say that doing gpiod_get_value() from a GpioInt() is always > wrong? But it's not wrong. Some cases simply make little or no sense, but in principal why not? Yes, it may be fragile or too much customized. > Can we modify the code to avoid it? GpioInt() is orthogonal to GPIO APIs in Linux kernel. It close to be impossible. Also see above. > Sorry for the confusion and thanks for your help. No problem, you're welcome, it's good that you started a discussion! > > > > > [1]: https://elixir.bootlin.com/linux/latest/source/drivers/extcon/extcon-intel-int3496.c#L138 > > > > > [2]: https://elixir.bootlin.com/linux/latest/source/drivers/extcon/extcon-intel-int3496.c#L45 -- With Best Regards, Andy Shevchenko
next prev parent reply index Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-10-28 20:50 [PATCH v1 1/3] Documentation: firmware-guide: gpio-properties: Fix factual mistakes Andy Shevchenko 2020-10-28 20:51 ` [PATCH v1 2/3] Documentation: firmware-guide: gpio-properties: active_low only for GpioIo() Andy Shevchenko 2020-10-28 21:10 ` Ricardo Ribalda 2020-10-29 14:46 ` Andy Shevchenko 2020-10-29 14:54 ` Ricardo Ribalda 2020-10-29 17:17 ` Andy Shevchenko 2020-10-29 17:20 ` Andy Shevchenko 2020-10-29 17:25 ` Andy Shevchenko 2020-10-29 17:32 ` Ricardo Ribalda 2020-10-29 18:09 ` Ricardo Ribalda 2020-10-29 18:13 ` Andy Shevchenko 2020-10-29 18:58 ` Ricardo Ribalda 2020-10-29 19:11 ` Andy Shevchenko [this message] 2020-10-29 18:10 ` Andy Shevchenko 2020-10-29 8:13 ` Mika Westerberg 2020-10-28 20:51 ` [PATCH v1 3/3] Documentation: firmware-guide: gpio-properties: Clarify initial output state Andy Shevchenko 2020-10-29 8:16 ` Mika Westerberg 2020-10-29 8:13 ` [PATCH v1 1/3] Documentation: firmware-guide: gpio-properties: Fix factual mistakes Mika Westerberg 2020-10-29 11:10 ` 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=20201029191153.GI4077@smile.fi.intel.com \ --to=andy.shevchenko@gmail.com \ --cc=linux-acpi@vger.kernel.org \ --cc=linux-gpio@vger.kernel.org \ --cc=mika.westerberg@linux.intel.com \ --cc=ribalda@google.com \ --cc=rjw@rjwysocki.net \ --cc=tfiga@google.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
Linux-ACPI Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/linux-acpi/0 linux-acpi/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 linux-acpi linux-acpi/ https://lore.kernel.org/linux-acpi \ linux-acpi@vger.kernel.org public-inbox-index linux-acpi Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.kernel.vger.linux-acpi AGPL code for this site: git clone https://public-inbox.org/public-inbox.git