drivers/gpio/gpio-xgene-sb.c
Source file repositories/reference/linux-study-clean/drivers/gpio/gpio-xgene-sb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpio/gpio-xgene-sb.c- Extension
.c- Size
- 9878 bytes
- Lines
- 362
- 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.
- 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/device.hlinux/err.hlinux/io.hlinux/irq.hlinux/irqdomain.hlinux/mod_devicetable.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/property.hlinux/types.hlinux/gpio/driver.hlinux/gpio/generic.hgpiolib-acpi.h
Detected Declarations
struct xgene_gpio_sbfunction xgene_gpio_set_bitfunction xgene_gpio_sb_irq_set_typefunction xgene_gpio_sb_irq_maskfunction xgene_gpio_sb_irq_unmaskfunction xgene_gpio_sb_to_irqfunction xgene_gpio_sb_domain_activatefunction xgene_gpio_sb_domain_deactivatefunction xgene_gpio_sb_domain_translatefunction xgene_gpio_sb_domain_allocfunction xgene_gpio_sb_probefunction xgene_gpio_sb_remove
Annotated Snippet
struct xgene_gpio_sb {
struct gpio_generic_chip chip;
void __iomem *regs;
struct irq_domain *irq_domain;
u16 irq_start;
u16 nirq;
u16 parent_irq_base;
};
#define HWIRQ_TO_GPIO(priv, hwirq) ((hwirq) + (priv)->irq_start)
#define GPIO_TO_HWIRQ(priv, gpio) ((gpio) - (priv)->irq_start)
static void xgene_gpio_set_bit(struct gpio_chip *gc,
void __iomem *reg, u32 gpio, int val)
{
struct gpio_generic_chip *chip = to_gpio_generic_chip(gc);
u32 data;
data = gpio_generic_read_reg(chip, reg);
if (val)
data |= GPIO_MASK(gpio);
else
data &= ~GPIO_MASK(gpio);
gpio_generic_write_reg(chip, reg, data);
}
static int xgene_gpio_sb_irq_set_type(struct irq_data *d, unsigned int type)
{
struct xgene_gpio_sb *priv = irq_data_get_irq_chip_data(d);
int gpio = HWIRQ_TO_GPIO(priv, d->hwirq);
int lvl_type = GPIO_INT_LEVEL_H;
switch (type & IRQ_TYPE_SENSE_MASK) {
case IRQ_TYPE_EDGE_RISING:
case IRQ_TYPE_LEVEL_HIGH:
lvl_type = GPIO_INT_LEVEL_H;
break;
case IRQ_TYPE_EDGE_FALLING:
case IRQ_TYPE_LEVEL_LOW:
lvl_type = GPIO_INT_LEVEL_L;
break;
default:
break;
}
xgene_gpio_set_bit(&priv->chip.gc, priv->regs + MPA_GPIO_SEL_LO,
gpio * 2, 1);
xgene_gpio_set_bit(&priv->chip.gc, priv->regs + MPA_GPIO_INT_LVL,
d->hwirq, lvl_type);
/* Propagate IRQ type setting to parent */
if (type & IRQ_TYPE_EDGE_BOTH)
return irq_chip_set_type_parent(d, IRQ_TYPE_EDGE_RISING);
else
return irq_chip_set_type_parent(d, IRQ_TYPE_LEVEL_HIGH);
}
static void xgene_gpio_sb_irq_mask(struct irq_data *d)
{
struct xgene_gpio_sb *priv = irq_data_get_irq_chip_data(d);
irq_chip_mask_parent(d);
gpiochip_disable_irq(&priv->chip.gc, d->hwirq);
}
static void xgene_gpio_sb_irq_unmask(struct irq_data *d)
{
struct xgene_gpio_sb *priv = irq_data_get_irq_chip_data(d);
gpiochip_enable_irq(&priv->chip.gc, d->hwirq);
irq_chip_unmask_parent(d);
}
static const struct irq_chip xgene_gpio_sb_irq_chip = {
.name = "sbgpio",
.irq_eoi = irq_chip_eoi_parent,
.irq_mask = xgene_gpio_sb_irq_mask,
.irq_unmask = xgene_gpio_sb_irq_unmask,
.irq_set_type = xgene_gpio_sb_irq_set_type,
.flags = IRQCHIP_IMMUTABLE,
GPIOCHIP_IRQ_RESOURCE_HELPERS,
};
static int xgene_gpio_sb_to_irq(struct gpio_chip *gc, u32 gpio)
{
struct xgene_gpio_sb *priv = gpiochip_get_data(gc);
struct irq_fwspec fwspec;
Annotation
- Immediate include surface: `linux/device.h`, `linux/err.h`, `linux/io.h`, `linux/irq.h`, `linux/irqdomain.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct xgene_gpio_sb`, `function xgene_gpio_set_bit`, `function xgene_gpio_sb_irq_set_type`, `function xgene_gpio_sb_irq_mask`, `function xgene_gpio_sb_irq_unmask`, `function xgene_gpio_sb_to_irq`, `function xgene_gpio_sb_domain_activate`, `function xgene_gpio_sb_domain_deactivate`, `function xgene_gpio_sb_domain_translate`, `function xgene_gpio_sb_domain_alloc`.
- Atlas domain: Driver Families / drivers/gpio.
- Implementation status: source implementation candidate.
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.