drivers/gpio/gpio-lpc18xx.c
Source file repositories/reference/linux-study-clean/drivers/gpio/gpio-lpc18xx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpio/gpio-lpc18xx.c- Extension
.c- Size
- 10239 bytes
- Lines
- 414
- Domain
- Driver Families
- Bucket
- drivers/gpio
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/clk.hlinux/gpio/driver.hlinux/io.hlinux/irqdomain.hlinux/module.hlinux/of.hlinux/of_address.hlinux/of_irq.hlinux/pinctrl/consumer.hlinux/platform_device.h
Detected Declarations
struct lpc18xx_gpio_pin_icstruct lpc18xx_gpio_chipfunction lpc18xx_gpio_pin_ic_iselfunction lpc18xx_gpio_pin_ic_setfunction lpc18xx_gpio_pin_ic_maskfunction lpc18xx_gpio_pin_ic_unmaskfunction lpc18xx_gpio_pin_ic_eoifunction lpc18xx_gpio_pin_ic_set_typefunction lpc18xx_gpio_pin_ic_domain_allocfunction lpc18xx_gpio_pin_ic_probefunction lpc18xx_gpio_setfunction lpc18xx_gpio_getfunction lpc18xx_gpio_directionfunction lpc18xx_gpio_direction_inputfunction lpc18xx_gpio_direction_outputfunction lpc18xx_gpio_probefunction lpc18xx_gpio_remove
Annotated Snippet
struct lpc18xx_gpio_pin_ic {
void __iomem *base;
struct irq_domain *domain;
struct raw_spinlock lock;
struct gpio_chip *gpio;
};
struct lpc18xx_gpio_chip {
struct gpio_chip gpio;
void __iomem *base;
struct lpc18xx_gpio_pin_ic *pin_ic;
spinlock_t lock;
};
static inline void lpc18xx_gpio_pin_ic_isel(struct lpc18xx_gpio_pin_ic *ic,
u32 pin, bool set)
{
u32 val = readl_relaxed(ic->base + LPC18XX_GPIO_PIN_IC_ISEL);
if (set)
val &= ~BIT(pin);
else
val |= BIT(pin);
writel_relaxed(val, ic->base + LPC18XX_GPIO_PIN_IC_ISEL);
}
static inline void lpc18xx_gpio_pin_ic_set(struct lpc18xx_gpio_pin_ic *ic,
u32 pin, u32 reg)
{
writel_relaxed(BIT(pin), ic->base + reg);
}
static void lpc18xx_gpio_pin_ic_mask(struct irq_data *d)
{
struct lpc18xx_gpio_pin_ic *ic = d->chip_data;
u32 type = irqd_get_trigger_type(d);
irq_hw_number_t hwirq = irqd_to_hwirq(d);
raw_spin_lock(&ic->lock);
if (type & IRQ_TYPE_LEVEL_MASK || type & IRQ_TYPE_EDGE_RISING)
lpc18xx_gpio_pin_ic_set(ic, d->hwirq,
LPC18XX_GPIO_PIN_IC_CIENR);
if (type & IRQ_TYPE_EDGE_FALLING)
lpc18xx_gpio_pin_ic_set(ic, d->hwirq,
LPC18XX_GPIO_PIN_IC_CIENF);
raw_spin_unlock(&ic->lock);
irq_chip_mask_parent(d);
gpiochip_disable_irq(ic->gpio, hwirq);
}
static void lpc18xx_gpio_pin_ic_unmask(struct irq_data *d)
{
struct lpc18xx_gpio_pin_ic *ic = d->chip_data;
u32 type = irqd_get_trigger_type(d);
irq_hw_number_t hwirq = irqd_to_hwirq(d);
gpiochip_enable_irq(ic->gpio, hwirq);
raw_spin_lock(&ic->lock);
if (type & IRQ_TYPE_LEVEL_MASK || type & IRQ_TYPE_EDGE_RISING)
lpc18xx_gpio_pin_ic_set(ic, d->hwirq,
LPC18XX_GPIO_PIN_IC_SIENR);
if (type & IRQ_TYPE_EDGE_FALLING)
lpc18xx_gpio_pin_ic_set(ic, d->hwirq,
LPC18XX_GPIO_PIN_IC_SIENF);
raw_spin_unlock(&ic->lock);
irq_chip_unmask_parent(d);
}
static void lpc18xx_gpio_pin_ic_eoi(struct irq_data *d)
{
struct lpc18xx_gpio_pin_ic *ic = d->chip_data;
u32 type = irqd_get_trigger_type(d);
raw_spin_lock(&ic->lock);
if (type & IRQ_TYPE_EDGE_BOTH)
lpc18xx_gpio_pin_ic_set(ic, d->hwirq,
LPC18XX_GPIO_PIN_IC_IST);
Annotation
- Immediate include surface: `linux/clk.h`, `linux/gpio/driver.h`, `linux/io.h`, `linux/irqdomain.h`, `linux/module.h`, `linux/of.h`, `linux/of_address.h`, `linux/of_irq.h`.
- Detected declarations: `struct lpc18xx_gpio_pin_ic`, `struct lpc18xx_gpio_chip`, `function lpc18xx_gpio_pin_ic_isel`, `function lpc18xx_gpio_pin_ic_set`, `function lpc18xx_gpio_pin_ic_mask`, `function lpc18xx_gpio_pin_ic_unmask`, `function lpc18xx_gpio_pin_ic_eoi`, `function lpc18xx_gpio_pin_ic_set_type`, `function lpc18xx_gpio_pin_ic_domain_alloc`, `function lpc18xx_gpio_pin_ic_probe`.
- Atlas domain: Driver Families / drivers/gpio.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.