drivers/gpio/gpiolib-acpi-core.c
Source file repositories/reference/linux-study-clean/drivers/gpio/gpiolib-acpi-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpio/gpiolib-acpi-core.c- Extension
.c- Size
- 36631 bytes
- Lines
- 1368
- Domain
- Driver Families
- Bucket
- drivers/gpio
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/acpi.hlinux/dmi.hlinux/errno.hlinux/export.hlinux/interrupt.hlinux/irq.hlinux/mutex.hlinux/pinctrl/pinctrl.hlinux/gpio/consumer.hlinux/gpio/driver.hlinux/gpio/machine.hgpiolib.hgpiolib-acpi.h
Detected Declarations
struct acpi_gpio_eventstruct acpi_gpio_connectionstruct acpi_gpio_chipstruct acpi_gpio_infostruct acpi_gpio_lookupfunction acpi_gpiochip_findfunction acpi_get_gpiodfunction acpi_gpio_irq_handlerfunction acpi_gpio_irq_handler_evtfunction acpi_gpio_chip_dhfunction acpi_gpio_get_io_resourcefunction acpi_gpiochip_request_irqfunction acpi_gpiochip_request_irqsfunction acpi_gpio_to_gpiod_flagsfunction acpi_gpio_set_debounce_timeoutfunction acpi_gpio_irq_is_wakefunction acpi_gpiochip_alloc_eventfunction acpi_gpiochip_request_interruptsfunction acpi_gpiochip_free_interruptsfunction list_for_each_entry_safe_reversefunction acpi_gpio_process_deferred_listfunction acpi_dev_add_driver_gpiosfunction acpi_dev_remove_driver_gpiosfunction acpi_dev_release_driver_gpiosfunction devm_acpi_dev_add_driver_gpiosfunction acpi_get_driver_gpio_datafunction __acpi_gpio_update_gpiod_flagsfunction acpi_gpio_update_gpiod_flagsfunction acpi_gpio_update_gpiod_lookup_flagsfunction acpi_populate_gpio_lookupfunction acpi_gpio_resource_lookupfunction acpi_gpio_property_lookupfunction acpi_get_gpiod_by_indexfunction acpi_get_gpiod_from_datafunction acpi_can_fallback_to_crsfunction __acpi_find_gpiofunction acpi_dev_gpio_irq_wake_get_byfunction acpi_gpio_adr_space_handlerfunction list_for_each_entryfunction list_for_each_entryfunction acpi_gpiochip_request_regionsfunction acpi_gpiochip_free_regionsfunction list_for_each_entry_safe_reversefunction acpi_gpiochip_addfunction acpi_gpiochip_removefunction acpi_gpio_package_countfunction acpi_find_gpio_countfunction acpi_gpio_count
Annotated Snippet
struct acpi_gpio_event {
struct list_head node;
acpi_handle handle;
irq_handler_t handler;
unsigned int pin;
unsigned int irq;
unsigned long irqflags;
bool irq_is_wake;
bool irq_requested;
struct gpio_desc *desc;
};
struct acpi_gpio_connection {
struct list_head node;
unsigned int pin;
struct gpio_desc *desc;
};
struct acpi_gpio_chip {
/*
* ACPICA requires that the first field of the context parameter
* passed to acpi_install_address_space_handler() is large enough
* to hold struct acpi_connection_info.
*/
struct acpi_connection_info conn_info;
struct list_head conns;
struct mutex conn_lock;
struct gpio_chip *chip;
struct list_head events;
struct list_head deferred_req_irqs_list_entry;
};
/**
* struct acpi_gpio_info - ACPI GPIO specific information
* @adev: reference to ACPI device which consumes GPIO resource
* @flags: GPIO initialization flags
* @gpioint: if %true this GPIO is of type GpioInt otherwise type is GpioIo
* @wake_capable: wake capability as provided by ACPI
* @pin_config: pin bias as provided by ACPI
* @polarity: interrupt polarity as provided by ACPI
* @triggering: triggering type as provided by ACPI
* @debounce: debounce timeout as provided by ACPI
* @quirks: Linux specific quirks as provided by struct acpi_gpio_mapping
*/
struct acpi_gpio_info {
struct acpi_device *adev;
enum gpiod_flags flags;
bool gpioint;
bool wake_capable;
int pin_config;
int polarity;
int triggering;
unsigned int debounce;
unsigned int quirks;
};
static int acpi_gpiochip_find(struct gpio_chip *gc, const void *data)
{
/* First check the actual GPIO device */
if (device_match_acpi_handle(&gc->gpiodev->dev, data))
return true;
/*
* When the ACPI device is artificially split to the banks of GPIOs,
* where each of them is represented by a separate GPIO device,
* the firmware node of the physical device may not be shared among
* the banks as they may require different values for the same property,
* e.g., number of GPIOs in a certain bank. In such case the ACPI handle
* of a GPIO device is NULL and can not be used. Hence we have to check
* the parent device to be sure that there is no match before bailing
* out.
*/
if (gc->parent)
return device_match_acpi_handle(gc->parent, data);
return false;
}
/**
* acpi_get_gpiod() - Translate ACPI GPIO pin to GPIO descriptor usable with GPIO API
* @path: ACPI GPIO controller full path name, (e.g. "\\_SB.GPO1")
* @pin: ACPI GPIO pin number (0-based, controller-relative)
*
* Returns:
* GPIO descriptor to use with Linux generic GPIO API.
* If the GPIO cannot be translated or there is an error an ERR_PTR is
* returned.
*
* Specifically returns %-EPROBE_DEFER if the referenced GPIO
* controller does not have GPIO chip registered at the moment. This is to
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/dmi.h`, `linux/errno.h`, `linux/export.h`, `linux/interrupt.h`, `linux/irq.h`, `linux/mutex.h`, `linux/pinctrl/pinctrl.h`.
- Detected declarations: `struct acpi_gpio_event`, `struct acpi_gpio_connection`, `struct acpi_gpio_chip`, `struct acpi_gpio_info`, `struct acpi_gpio_lookup`, `function acpi_gpiochip_find`, `function acpi_get_gpiod`, `function acpi_gpio_irq_handler`, `function acpi_gpio_irq_handler_evt`, `function acpi_gpio_chip_dh`.
- Atlas domain: Driver Families / drivers/gpio.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.