From: Hans de Goede <hdegoede@redhat.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: "Rafael J . Wysocki" <rjw@rjwysocki.net>,
Alexandre Courbot <gnurou@gmail.com>,
ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
joeyli <jlee@suse.com>, Takashi Iwai <tiwai@suse.de>
Subject: Re: [PATCH v5] gpio: Add driver for ACPI INT0002 Virtual GPIO device
Date: Fri, 2 Jun 2017 16:01:11 +0200 [thread overview]
Message-ID: <43d9ef7b-265d-44ed-b1ba-ed5ffaad48c4@redhat.com> (raw)
In-Reply-To: <CACRpkdb9C0+3SLm9guYqHA_e+F4Tt3mbJJA00+d5PsjeuwzrpA@mail.gmail.com>
Hi,
On 06/01/2017 05:23 PM, Linus Walleij wrote:
> On Wed, May 24, 2017 at 12:42 PM, Hans de Goede <hdegoede@redhat.com> wrote:
>
>> Some peripherals on Bay Trail and Cherry Trail platforms signal PME to the
>> PMC to wakeup the system. When this happens software needs to clear the
>> PME_B0_STS bit in the GPE0a_STS register to avoid an IRQ storm on IRQ 9.
>>
>> This is modeled in ACPI through the INT0002 ACPI Virtual GPIO device.
>>
>> This commit adds a driver which registers the Virtual GPIOs expected
>> by the DSDT on these devices, letting gpiolib-acpi claim the
>> virtual GPIO and install a GPIO-interrupt handler which call the _L02
>> handler as it would for a real GPIO controller.
>>
>> Cc: joeyli <jlee@suse.com>
>> Cc: Takashi Iwai <tiwai@suse.de>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
>> diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
>
> Please move this thing to drivers/platform/x86.
>
>> +config GPIO_INT0002
>> + tristate "Intel ACPI INT0002 Virtual GPIO"
>> + depends on ACPI
>> + select GPIOLIB_IRQCHIP
>> + ---help---
>> + Some peripherals on Baytrail and Cherrytrail platforms signal
>> + PME to the PMC to wakeup the system. When this happens software
>
> Spell out the acronyms.
>
>> + needs to explicitly clear the interrupt source to avoid an IRQ
>> + storm on IRQ 9. This is modelled in ACPI through the INT0002
>> + Virtual GPIO ACPI device.
>
> I.e. it is not really GPIO.
>
> Virtual GPIO == not GPIO at all, obviously.
>
> Please write something about this weird newspeak here.
>
>> +++ b/drivers/gpio/gpio-int0002.c
> (...)
>> + * Some peripherals on Bay Trail and Cherry Trail platforms signal PME to the
>> + * PMC to wakeup the system. When this happens software needs to clear the
>> + * PME_B0_STS bit in the GPE0a_STS register to avoid an IRQ storm on IRQ 9.
>
> Spell out acronyms.
>
>> +#include <asm/cpu_device_id.h>
>> +#include <asm/intel-family.h>
>> +#include <linux/acpi.h>
>> +#include <linux/gpio.h>
>
> No <linux/gpio.h>, only:
> #include <linux/gpio/driver.h>
>
> in drivers.
The above is all fixed for the next version.
>> +/* For some reason the virtual GPIO pin tied to the GPE is numbered pin 2 */
>> +#define GPE0A_PME_B0_VIRT_GPIO_PIN 2
>
> I think it's not weird at all, it is a 32bit word which is not a GPIO
> register at all, but
> misc IPC register, where bits 0 and 1 does something else.
That is not true the bus 0 status bit we're reacting to and which we're
clearing in this driver is bit 13 ...
>
>> +static int int0002_gpio_get(struct gpio_chip *chip, unsigned int offset)
>> +{
>> + return 0;
>> +}
>> +
>> +static void int0002_gpio_set(struct gpio_chip *chip, unsigned int offset,
>> + int value)
>> +{
>> +}
>> +
>> +static int int0002_gpio_direction_output(struct gpio_chip *chip,
>> + unsigned int offset, int value)
>> +{
>> + return 0;
>> +}
>
> If you're anyways pretending to be a GPIO chip, then you could implement
> these. But I guess you're not implementing them, because this is not
> a GPIO chip, so let's add a big fat comment above these stating clearly
> why they are not implemented proper.
Done for v6.
>
>> +static irqreturn_t int0002_irq(int irq, void *data)
>> +{
>> + struct gpio_chip *chip = data;
>> + u32 gpe_sts_reg;
>> +
>> + gpe_sts_reg = inl(GPE0A_STS_PORT);
>> + if (!(gpe_sts_reg & GPE0A_PME_B0_STS_BIT))
>> + return IRQ_NONE;
>
> I wonder what happens the day an IRQ start arriving on the other
> bits. Oh well, that day we handle that.
>
>> + for (i = 0; i < GPE0A_PME_B0_VIRT_GPIO_PIN; i++)
>> + clear_bit(i, chip->irq_valid_mask);
>
> That's neat.
>
> Yours,
> Linus Walleij
>
Regards,
Hans
prev parent reply other threads:[~2017-06-02 14:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-24 10:42 [PATCH v5] gpio: Add driver for ACPI INT0002 Virtual GPIO device Hans de Goede
2017-05-24 11:23 ` Andy Shevchenko
2017-05-24 12:10 ` Hans de Goede
2017-05-24 23:12 ` Rafael J. Wysocki
2017-05-27 19:28 ` Rafael J. Wysocki
2017-06-01 15:11 ` Linus Walleij
2017-06-01 15:20 ` Hans de Goede
2017-06-01 15:29 ` Linus Walleij
2017-06-01 16:35 ` Rafael J. Wysocki
2017-06-01 15:23 ` Linus Walleij
2017-06-02 11:10 ` Andy Shevchenko
2017-06-02 14:01 ` Hans de Goede [this message]
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=43d9ef7b-265d-44ed-b1ba-ed5ffaad48c4@redhat.com \
--to=hdegoede@redhat.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=gnurou@gmail.com \
--cc=jlee@suse.com \
--cc=linus.walleij@linaro.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=tiwai@suse.de \
/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).