gpio: Add driver for ACPI INT0002 Virtual GPIO device
PATCH v5 1/1 gpio: Add driver for ACPI INT0002 Virtual GPIO device
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.
---
Changes in v2:
-Remove dev_err after malloc failure
-Remove unused empty runtime pm callbacks -s/GPE0A_PME_/GPE0A_PME_B0_/
-Fixed some checkpatch warnings (I forgot to run checkpatch on v1) Changes in v3:
-Rewrite as gpiochip driver letting gpiolib-acpi deal with claiming the pin
0x0002 and calling the _L02 event handler when the virtual gpio-irq triggers
-Rebase on 4.12-rc1
Changes in v4:
-Drop device_init_wakeup() from _probe(), use pm_system_wakeup() instead
of pm_wakeup_hard_event(chip->parent)
-Improve commit message
Changes in v5:
-Use BIT() macro for FOO_BIT defines
-Drop unneeded ACPI_PTR macro usage
--- drivers/gpio/Kconfig | 14 +++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-int0002.c | 210 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 225 insertions(+) create mode 100644 drivers/gpio/gpio-int0002.c
drivers/gpio/Kconfig +14 -0
@@ -608,6 +608,20 @@ config GPIO_GPIO_MM The base port addresses for the devices may be configured via the base array module parameter. +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 + 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. + + To compile this driver as a module, choose M here: the module will + be called gpio_int0002. + config GPIO_IT87 tristate "IT87xx GPIO support" help
drivers/gpio/Makefile +1 -0
@@ -55,6 +55,7 @@ obj-$(CONFIG_GPIO_GPIO_MM) += gpio-gpio-mm.o obj-$(CONFIG_GPIO_GRGPIO) += gpio-grgpio.o obj-$(CONFIG_HTC_EGPIO) += gpio-htc-egpio.o obj-$(CONFIG_GPIO_ICH) += gpio-ich.o +obj-$(CONFIG_GPIO_INT0002) += gpio-int0002.o obj-$(CONFIG_GPIO_IOP) += gpio-iop.o obj-$(CONFIG_GPIO_IT87) += gpio-it87.o obj-$(CONFIG_GPIO_JANZ_TTL) += gpio-janz-ttl.o
drivers/gpio/gpio-int0002.c new file +210 -0
210 lines not on this page · raw message
Signature · 1 line
2.13.0
Quoted 14 lines · Hans de Goede
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 thePME_B0_STSbit in theGPE0a_STSregister 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
_L02handler as it would for a real GPIO controller.
Quoted 4 lines
Cc joeyli <[email protected]>Cc Takashi Iwai <[email protected]>Signed-off-by Hans de Goede <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>
In addition to my comment to v4 (if you are going to apply it) couple of nits below. (I'm fine with current version, as tag says, though consider them anyway)
drivers/gpio/gpio-int0002.c line 50
Quoted 4 lines
drivers/gpio/gpio-int0002.c new file +4
-0+#define GPE0A_PME_B0_STS_BIT BIT(13) +#define GPE0A_PME_B0_EN_BIT BIT(13) +#define GPE0A_STS_PORT 0x420 +#define GPE0A_EN_PORT 0x428
Perhaps squeeze bits after actual ports like
ADDRESSaADDRa_BITa
ADDRESSbADDRb_BITa
drivers/gpio/gpio-int0002.c line 167
Quoted 2 lines
drivers/gpio/gpio-int0002.c new file +2
-0+for (i =0 ; i <GPE0A_PME_B0_VIRT_GPIO_PIN ; i++) +clear_bit (i, chip->irq_valid_mask);
bitmap_zero() ?
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Hi,
Quoted 15 lines · Andy Shevchenko
Quoted 14 lines · Hans de Goede
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 thePME_B0_STSbit in theGPE0a_STSregister 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
_L02handler as it would for a real GPIO controller.
Quoted 8 lines
Quoted 4 lines
Cc joeyli <[email protected]>Cc Takashi Iwai <[email protected]>Signed-off-by Hans de Goede <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>In addition to my comment to v4 (if you are going to apply it) couple of nits below. (I'm fine with current version, as tag says, though consider them anyway)
I prefer to stick with the current version (v5) unless something bigger comes up.
Regards,
Hans
Quoted 19 lines
drivers/gpio/gpio-int0002.c line 50
Quoted 5 lines
drivers/gpio/gpio-int0002.c new file +4
-0+#define GPE0A_PME_B0_STS_BIT BIT(13) +#define GPE0A_PME_B0_EN_BIT BIT(13) +#define GPE0A_STS_PORT 0x420 +#define GPE0A_EN_PORT 0x428Perhaps squeeze bits after actual ports like
ADDRESSa
ADDRa_BITaADDRESSb
ADDRb_BITadrivers/gpio/gpio-int0002.c line 167
Quoted 2 lines
drivers/gpio/gpio-int0002.c new file +2
-0+for (i =0 ; i <GPE0A_PME_B0_VIRT_GPIO_PIN ; i++) +clear_bit (i, chip->irq_valid_mask);
bitmap_zero()?
Quoted 30 lines · Hans de Goede
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_STSbit in theGPE0a_STSregister 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
_L02handler as it would for a real GPIO controller.Cc joeyli <[email protected]>Cc Takashi Iwai <[email protected]>Signed-off-by Hans de Goede <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>---
Changes in v2:(quoted diff) +0
-4-Remove dev_err after malloc failure -Remove unused empty runtime pm callbacks -s/GPE0A_PME_/GPE0A_PME_B0_/ -Fixed some checkpatch warnings (I forgot to run checkpatch on v1)Changes in v3:
(quoted diff) +0
-2-Rewrite as gpiochip driver letting gpiolib-acpi deal with claiming the pin 0x0002 and calling the _L02 event handler when the virtual gpio-irq triggers -Rebase on 4.12-rc1Changes in v4:
(quoted diff) +0
-2-Drop device_init_wakeup() from _probe(), use pm_system_wakeup() instead of pm_wakeup_hard_event(chip->parent) -Improve commit messageChanges in v5:
Review
Quoted 2 lines
(quoted diff) +0
-2-Use BIT() macro for FOO_BIT defines -Drop unneeded ACPI_PTR macro usage
LGTM
Quoted 36 lines · Rafael J. Wysocki
Quoted 30 lines · Hans de Goede
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_STSbit in theGPE0a_STSregister 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
_L02handler as it would for a real GPIO controller.Cc joeyli <[email protected]>Cc Takashi Iwai <[email protected]>Signed-off-by Hans de Goede <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>---
Changes in v2:(quoted diff) +0
-4-Remove dev_err after malloc failure -Remove unused empty runtime pm callbacks -s/GPE0A_PME_/GPE0A_PME_B0_/ -Fixed some checkpatch warnings (I forgot to run checkpatch on v1)Changes in v3:
(quoted diff) +0
-2-Rewrite as gpiochip driver letting gpiolib-acpi deal with claiming the pin 0x0002 and calling the _L02 event handler when the virtual gpio-irq triggers -Rebase on 4.12-rc1Changes in v4:
(quoted diff) +0
-2-Drop device_init_wakeup() from _probe(), use pm_system_wakeup() instead of pm_wakeup_hard_event(chip->parent) -Improve commit messageChanges in v5:
Review
Quoted 2 lines
(quoted diff) +0
-2-Use BIT() macro for FOO_BIT defines -Drop unneeded ACPI_PTR macro usageLGTM
Quoted 1 line
Linus,
This would be nice to have in 4.12 to unbreak things in there after some recent ACPI changes (the feature in question have never worked entirely correctly to be precise, but with this patch on top of the current -rc it actually does work).
I can queue it up if that's not a problem, but need your ACK for that.
Thanks,
Rafael
Quoted 3 lines · Hans de Goede
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_STSbit in theGPE0a_STSregister to avoid an IRQ storm on IRQ 9.
Spell out these acronyms so I have at least a faint chance of understanding what is going on here.
Quoted 1 line
This is modeled in ACPI through the INT0002 ACPI Virtual GPIO device.
So are you saying that some firmware dork has modeled something that *is* *actually* a port to a PMC (I guess power management controller) to send a PME (I guess power managment enable signal?) by shoehorning that into something purporting to be a GPIO (general purpose input/output) controller?
Well I've been approached before by people all over that just wanna stick something quick and dirty into the GPIO subsystem because it's so convenient. ("Come on, just take it", etc.)
I usually just say no. General purpose I/O is not special-purpose I/O. I bet a million to one these are just a few bits in a register, right? And someone chose to model that as a "GPIO"?
This takes the price.
Now we have not just lazy kernel programmers but lazy ACPI firmware authors having to have their sloppy stuff cleaned up by Hans in kernelspace.
And I bet the resource resolution for this thing is completely dependent on dirvers/gpio/gpiolib-acpi.c so it must be a using GPIO for that reason?
I guess that just force me to not NACK this because I don't want to screw up all the worlds Intel cherryviews etc.
:(
drivers/gpio/gpio-int0002.c line 194
Quoted 3 lines
drivers/gpio/gpio-int0002.c new file +3
-0+static const struct acpi_device_id int0002_acpi_ids[] = { + {"INT0002" ,0 }, + { },
So again, the reason this - which is not a GPIO controller at all - should anyways
be in drivers/gpio/ is that some firmware person think it's convenient?
Shouldn't this rather be in drivers/platform/x86?
You can still use the gpio driver abstraction.
I have some small comments on the code as well, will send in a separate mail, otherwise good work as always Hans.
Yours,
Linus Walleij
Hi,
Quoted 8 lines · Linus Walleij
Quoted 3 lines · Hans de Goede
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_STSbit in theGPE0a_STSregister to avoid an IRQ storm on IRQ 9.Spell out these acronyms so I have at least a faint chance of understanding what is going on here.
Sorry, I cannot spell them out without guessing myself, there is no documentation this commit message is based on the explanation found in the patches from here:
https://github.com/01org/ProductionKernelQuilts/tree/master/uefi/cht-m1stable/patches
Warning there are over 5000 patches there (yes really that seems to be how android on x86 gets shipped).
Well I guess I could go over the PDF with the register documentation that may if we're lucky explain the acronyms, but often it just uses the acronyms and that's it.
Quoted 7 lines
Quoted 1 line
This is modeled in ACPI through the INT0002 ACPI Virtual GPIO device.
So are you saying that some firmware dork has modeled something that *is* *actually* a port to a PMC (I guess power management controller) to send a PME (I guess power managment enable signal?) by shoehorning that into something purporting to be a GPIO (general purpose input/output) controller?
Yes, you've got the gist of it right this has nothing to do with GPIOs at all, but the ACPI firmware representation of the AML event handler which needs to be called when the PME_B0 interrupt fires is in the form of a GpioInt and the ACPI node has _AEI and _L02 methods to match.
Quoted 6 lines
Well I've been approached before by people all over that just wanna stick something quick and dirty into the GPIO subsystem because it's so convenient. ("Come on, just take it", etc.)
I usually just say no. General purpose I/O is not special-purpose I/O. I bet a million to one these are just a few bits in a register, right?
Right.
Quoted 1 line
And someone chose to model that as a "GPIO"?
Right.
Quoted 7 lines
This takes the price.
Now we have not just lazy kernel programmers but lazy ACPI firmware authors having to have their sloppy stuff cleaned up by Hans in kernelspace. > And I bet the resource resolution for this thing is completely dependent on
dirvers/gpio/gpiolib-acpi.cso it must be a using GPIO for that reason?
Actually I started out with a stand-alone platform driver which duplicated some code from gpiolib-acpi.c (not copy pasted but I ended up writing more or less the same code) you never saw that version as it was not send to you but to the platform/x86 maintainers.
That version got review comments asking me to redo it in a way which avoided the duplication and the version you are seeing now is the result of that.
Quoted 5 lines
I guess that just force me to not NACK this because I don't want to screw up all the worlds Intel cherryviews etc.
:(
Quoted 8 lines
drivers/gpio/gpio-int0002.c line 194
Quoted 3 lines
drivers/gpio/gpio-int0002.c new file +3
-0+static const struct acpi_device_id int0002_acpi_ids[] = { + {"INT0002" ,0 }, + { },So again, the reason this - which is not a GPIO controller at all - should anyways
be indrivers/gpio/is that some firmware person think it's convenien > Shouldn't this rather be indrivers/platform/x86?
That is where it started, I'm fine with putting it back there.
Quoted 1 line
You can still use the gpio driver abstraction.
Ack, if you're ok with using the gpio driver abstraction while putting the driver in drivers/platform/x86 that might be the best way to deal with this.
Regards,
Hans
drivers/gpio/Kconfig
Quoted 17 lines · Hans de Goede
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_STSbit in theGPE0a_STSregister 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
_L02handler as it would for a real GPIO controller.Cc joeyli <[email protected]>Cc Takashi Iwai <[email protected]>Signed-off-by Hans de Goede <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>drivers/gpio/Kconfig +0
-0
Please move this thing to drivers/platform/x86.
drivers/gpio/Kconfig config GPIO_GPIO_MM · line 617
Quoted 7 lines
drivers/gpio/Kconfig +7
-0+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.
drivers/gpio/Kconfig config GPIO_GPIO_MM · line 620
Quoted 3 lines
drivers/gpio/Kconfig +3
-0+ 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.
Quoted 1 line
+++
b/drivers/gpio/gpio-int0002.c
(...)
Quoted 3 lines
+ * 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_STSbit in theGPE0a_STSregister to avoid an IRQ storm on IRQ 9.
Spell out acronyms.
drivers/gpio/Kconfig
Quoted 4 lines
drivers/gpio/Kconfig +4
-0+#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.
drivers/gpio/Kconfig
Quoted 2 lines
drivers/gpio/Kconfig +2
-0+/* 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.
Quoted 5 lines
drivers/gpio/Kconfig +5
-0+static int int0002_gpio_get(struct gpio_chip *chip, unsigned int offset) +{ + return 0; +} +
drivers/gpio/Kconfig
Quoted 10 lines
drivers/gpio/Kconfig +10
-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.
drivers/gpio/Kconfig
Quoted 8 lines
drivers/gpio/Kconfig +8
-0+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.
drivers/gpio/Kconfig
Quoted 2 lines
drivers/gpio/Kconfig +2
-0+ for (i = 0; i < GPE0A_PME_B0_VIRT_GPIO_PIN; i++) + clear_bit(i, chip->irq_valid_mask);
That's neat.
Yours,
Linus Walleij
Quoted 6 lines · Hans de Goede
Quoted 4 lines
So again, the reason this - which is not a GPIO controller at all - should anyways
be indrivers/gpio/is that some firmware person think it's convenien > Shouldn't this rather be indrivers/platform/x86?
Quoted 7 lines
That is where it started, I'm fine with putting it back there.
Quoted 1 line
You can still use the gpio driver abstraction.
Ack, if you're ok with using the gpio driver abstraction while putting the driver in
drivers/platform/x86that might be the best way to deal with this.
OK let's proceed like that.
I guess I could be hopeless and require that it reimplement the ACPI parser and whatnot just because it's not GPIO but code duplication is a greater evil and thus modelling this as a "GPIO" is the lesser evil, so I just have to accept it as such.
Yours,
Linus Walleij
Rafael J. Wysocki
maintainerQuoted 10 lines · Linus Walleij
Quoted 8 lines · Hans de Goede
Quoted 4 lines
So again, the reason this - which is not a GPIO controller at all - should anyways
be indrivers/gpio/is that some firmware person think it's convenien > Shouldn't this rather be indrivers/platform/x86?That is where it started, I'm fine with putting it back there.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
You can still use the gpio driver abstraction.
Ack, if you're ok with using the gpio driver abstraction while putting the driver in
drivers/platform/x86that might be the best way to deal with this.OK let's proceed like that.
Cool.
Well, I actually overlooked the "virtual" part somehow, sorry about that.
Yes, it totally should be platform/x86.
Quoted 4 lines
I guess I could be hopeless and require that it reimplement the ACPI parser and whatnot just because it's not GPIO but code duplication is a greater evil and thus modelling this as a "GPIO" is the lesser evil, so I just have to accept it as such.
Thanks for looking into this!
Cheers,
Rafael
Quoted 4 lines · Linus Walleij
On Wed, May 24, 2017 at 12:42 PM, Hans de Goede <[email protected]> wrote:
Please move this thing to
drivers/platform/x86.
I'm fine to take it as long it has your Ack.
Quoted 6 lines
Quoted 4 lines
+ Some peripherals on Baytrail and Cherrytrail platforms signal
+ PME to the PMC to wakeup the system. When this happens softwareSpell out the acronyms.
PME is standard of PCI, Power Management Event.
PMC — Power Management Controller
PME_B0 — PME Bus 0
STS — status (obviously :-) )
GPE — General Purpose Event (in ACPI terms)
Quoted 9 lines
(...)
Quoted 6 lines
+ * 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_STSbit in theGPE0a_STSregister to avoid an IRQ storm on IRQ 9.Spell out acronyms.
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Hi,
Quoted 58 lines · Linus Walleij
drivers/gpio/Kconfig
Quoted 17 lines · Hans de Goede
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_STSbit in theGPE0a_STSregister 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
_L02handler as it would for a real GPIO controller.Cc joeyli <[email protected]>Cc Takashi Iwai <[email protected]>Signed-off-by Hans de Goede <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>drivers/gpio/Kconfig +0
-0Please move this thing to
drivers/platform/x86.drivers/gpio/Kconfig config GPIO_GPIO_MM · line 617
Quoted 7 lines
drivers/gpio/Kconfig +7
-0+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 softwareSpell out the acronyms.
drivers/gpio/Kconfig config GPIO_GPIO_MM · line 620
Quoted 3 lines
drivers/gpio/Kconfig +3
-0+ 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.
Quoted 1 line
+++
b/drivers/gpio/gpio-int0002.c(...)
Quoted 3 lines
+ * 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_STSbit in theGPE0a_STSregister to avoid an IRQ storm on IRQ 9.Spell out acronyms.
drivers/gpio/Kconfig
Quoted 4 lines
drivers/gpio/Kconfig +4
-0+#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>
Quoted 1 line
in drivers.
The above is all fixed for the next version.
Quoted 6 lines
drivers/gpio/Kconfig
Quoted 2 lines
drivers/gpio/Kconfig +2
-0+/* For some reason the virtual GPIO pin tied to the GPE is numbered pin 2 */ +#define GPE0A_PME_B0_VIRT_GPIO_PIN 2I 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 ...
Quoted 13 lines
Quoted 13 lines
drivers/gpio/Kconfig +12
-0+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)
Quoted 8 lines
drivers/gpio/Kconfig
Quoted 3 lines
drivers/gpio/Kconfig +3
-0+{ + 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.
Quoted 13 lines
drivers/gpio/Kconfig
Quoted 9 lines
drivers/gpio/Kconfig +8
-0+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.
Quoted 8 lines
drivers/gpio/Kconfig
Quoted 2 lines
drivers/gpio/Kconfig +2
-0+ 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