Skip to contentSkip to conversation

Adding interrupt support to gpio-ich driver (possibly via SCI)

DISCUSSION Guenter Roeck 2 participants 5 messages Apr 4, 2014 – Apr 8, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi all,

I have an application where I would need interrupt support for the gpio-ich driver. More specifically, in my application some of the GPIO pins are used to report interrupt status from a couple of connected chips. This is with a Panther Point PCH (QM77).

I see that the gpio pins in question (in the 0..15 range) do support interrupts, but it looks like the only configuration options are to generate SMI, SCI, or NMI.

Is there a clean way to use any of those to implement interrupt support for this driver ? I thought about hijacking the SCI interrupt by registering an interrupt handler with acpi_install_sci_handler(), but that would restrict the driver to kernel only (or the acpi function would have to be exported), and I have no idea if it would work or, more importantly, if it would be the best approach to solve the problem, or if the result would be acceptable. I can figure out the "working" part, but that would not help much if I would have to carry the patch locally because it is not acceptable for upstream integration.

Side note: gpio-ich is not currently enabled for Panther Point; that will be a one-line separate patch for the mfd/lpc_ich driver.

Thanks,
Guenter

#1 lore raw
Quoted 9 lines · Guenter Roeck

Is there a clean way to use any of those to implement interrupt support for this driver ? I thought about hijacking the SCI interrupt by registering an interrupt handler with acpi_install_sci_handler(), but that would restrict the driver to kernel only (or the acpi function would have to be exported), and I have no idea if it would work or, more importantly, if it would be the best approach to solve the problem, or if the result would be acceptable. I can figure out the "working" part, but that would not help much if I would have to carry the patch locally because it is not acceptable for upstream integration.

You shouldn't need to install an SCI handler - the way the hardware will generate an SCI is to raise a GPE. If you know which GPE the device raises (my recollection is that for most Intel chipsets it's GPIO number
+ 0x10) then you can just call acpi_install_gpe_handler(). The problem is that the firmware may well already be using some of those GPIOs, and there's no easy way to tell. Checking the interrupt configuration isn't sufficient, since some of them may just be used as outputs.

Signature · 1 line
Matthew Garrett | [email protected]
#2 lore raw
Quoted 12 lines · Matthew Garrett
Quoted 9 lines · Guenter Roeck

Is there a clean way to use any of those to implement interrupt support for this driver ? I thought about hijacking the SCI interrupt by registering an interrupt handler with acpi_install_sci_handler(), but that would restrict the driver to kernel only (or the acpi function would have to be exported), and I have no idea if it would work or, more importantly, if it would be the best approach to solve the problem, or if the result would be acceptable. I can figure out the "working" part, but that would not help much if I would have to carry the patch locally because it is not acceptable for upstream integration.

Quoted 4 lines

You shouldn't need to install an SCI handler - the way the hardware will generate an SCI is to raise a GPE. If you know which GPE the device raises (my recollection is that for most Intel chipsets it's GPIO number
+ 0x10) then you can just call acpi_install_gpe_handler(). The problem

Sounds good. Do you by any chance have a pointer to some documentation explaining this in some more detail ?

Quoted 4 lines

is that the firmware may well already be using some of those GPIOs, and there's no easy way to tell. Checking the interrupt configuration isn't sufficient, since some of them may just be used as outputs.

The gpio-ich driver already has some magic to detect that condition - I noticed that I can not request all GPIO pins on all hardware. Either case, the gpio pins I am interested in are well defined on the hardware I am dealing with, so I can be sure I won't step on some unexpected use.

Thanks!

Guenter

#3 lore raw
Quoted 8 lines · Guenter Roeck
Quoted 4 lines · Matthew Garrett

You shouldn't need to install an SCI handler - the way the hardware will generate an SCI is to raise a GPE. If you know which GPE the device raises (my recollection is that for most Intel chipsets it's GPIO number
+ 0x10) then you can just call acpi_install_gpe_handler(). The problem

Sounds good. Do you by any chance have a pointer to some documentation explaining this in some more detail ?

The SCI is just IRQ 9 - it tells the OS that there's a firmware event, but in itself doesn't say what that event was. This is handled by the platform setting bits in the GPE*_STS registers. The ACPI code reads that and then dispatches the event to the appropriate handler. This will typically be some ACPI code (declared by _Lxx and _Exx methods in the ACPI tables - xx corresponds to the GPE number, L and E whether it's level or edge triggered), but in some cases you want to install a hardcoded event handler.

I've only got the 5-series docs to hand, and I can't remember whether that's Panther Point, but you want to look at the definition of GPE0_STS to figure out which hardware events cause which GPEs. GPEs 16 to 31 appear to correspond to GPIO 0 to 15, which is easy enough to handle.

Quoted 8 lines
Quoted 4 lines

is that the firmware may well already be using some of those GPIOs, and there's no easy way to tell. Checking the interrupt configuration isn't sufficient, since some of them may just be used as outputs.

The gpio-ich driver already has some magic to detect that condition - I noticed that I can not request all GPIO pins on all hardware. Either case, the gpio pins I am interested in are well defined on the hardware I am dealing with, so I can be sure I won't step on some unexpected use.

Ok. As long as you don't reprogram anything by default, I think this should be fine.

Signature · 1 line
Matthew Garrett | [email protected]
#4 lore raw
Quoted 19 lines · Matthew Garrett
Quoted 8 lines · Guenter Roeck
Quoted 4 lines · Matthew Garrett

You shouldn't need to install an SCI handler - the way the hardware will generate an SCI is to raise a GPE. If you know which GPE the device raises (my recollection is that for most Intel chipsets it's GPIO number
+ 0x10) then you can just call acpi_install_gpe_handler(). The problem

Sounds good. Do you by any chance have a pointer to some documentation explaining this in some more detail ?

The SCI is just IRQ 9 - it tells the OS that there's a firmware event, but in itself doesn't say what that event was. This is handled by the platform setting bits in the GPE*_STS registers. The ACPI code reads that and then dispatches the event to the appropriate handler. This will typically be some ACPI code (declared by _Lxx and _Exx methods in the ACPI tables - xx corresponds to the GPE number, L and E whether it's level or edge triggered), but in some cases you want to install a hardcoded event handler.

Quoted 5 lines

I've only got the 5-series docs to hand, and I can't remember whether that's Panther Point, but you want to look at the definition of GPE0_STS to figure out which hardware events cause which GPEs. GPEs 16 to 31 appear to correspond to GPIO 0 to 15, which is easy enough to handle.

Panther Point is Series 7 if I understand correctly, but the GPE0_STS definition is the same.

That should get me started - thanks again!

Guenter

Quoted 12 lines
Quoted 8 lines
Quoted 4 lines

is that the firmware may well already be using some of those GPIOs, and there's no easy way to tell. Checking the interrupt configuration isn't sufficient, since some of them may just be used as outputs.

The gpio-ich driver already has some magic to detect that condition - I noticed that I can not request all GPIO pins on all hardware. Either case, the gpio pins I am interested in are well defined on the hardware I am dealing with, so I can be sure I won't step on some unexpected use.

Ok. As long as you don't reprogram anything by default, I think this should be fine.