drivers/gpio/gpio-dwapb.c
Source file repositories/reference/linux-study-clean/drivers/gpio/gpio-dwapb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpio/gpio-dwapb.c- Extension
.c- Size
- 21655 bytes
- Lines
- 850
- 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.
- 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/clk.hlinux/err.hlinux/gpio/driver.hlinux/gpio/generic.hlinux/init.hlinux/interrupt.hlinux/io.hlinux/ioport.hlinux/irq.hlinux/mod_devicetable.hlinux/module.hlinux/platform_device.hlinux/property.hlinux/reset.hlinux/slab.hlinux/spinlock.hgpiolib-acpi.h
Detected Declarations
struct dwapb_gpiostruct dwapb_port_propertystruct dwapb_platform_datastruct dwapb_contextstruct dwapb_gpio_port_irqchipstruct dwapb_gpio_portstruct dwapb_gpiofunction gpio_reg_v2_convertfunction gpio_reg_convertfunction dwapb_readfunction dwapb_writefunction dwapb_toggle_triggerfunction dwapb_do_irqfunction dwapb_irq_handlerfunction dwapb_irq_handler_mfdfunction dwapb_irq_ackfunction dwapb_irq_maskfunction scoped_guardfunction dwapb_irq_unmaskfunction dwapb_irq_enablefunction dwapb_irq_disablefunction dwapb_irq_set_typefunction dwapb_irq_set_wakefunction dwapb_gpio_set_debouncefunction dwapb_gpio_set_configfunction dwapb_convert_irqsfunction dwapb_configure_irqsfunction dwapb_gpio_add_portfunction dwapb_get_irqfunction dwapb_assert_resetfunction dwapb_get_resetfunction dwapb_disable_clksfunction dwapb_get_clksfunction dwapb_gpio_probefunction dwapb_gpio_suspendfunction scoped_guardfunction dwapb_gpio_resume
Annotated Snippet
struct dwapb_port_property {
struct fwnode_handle *fwnode;
unsigned int idx;
unsigned int ngpio;
unsigned int gpio_base;
int irq[DWAPB_MAX_GPIOS];
};
struct dwapb_platform_data {
unsigned int nports;
struct dwapb_port_property properties[] __counted_by(nports);
};
/* Store GPIO context across system-wide suspend/resume transitions */
struct dwapb_context {
u32 data;
u32 dir;
u32 ext;
u32 int_en;
u32 int_mask;
u32 int_type;
u32 int_pol;
u32 int_deb;
u32 wake_en;
};
struct dwapb_gpio_port_irqchip {
unsigned int nr_irqs;
unsigned int irq[DWAPB_MAX_GPIOS];
};
struct dwapb_gpio_port {
struct gpio_generic_chip chip;
struct dwapb_gpio_port_irqchip *pirq;
struct dwapb_gpio *gpio;
struct dwapb_context *ctx;
unsigned int idx;
};
static inline struct dwapb_gpio *to_dwapb_gpio(struct gpio_chip *gc)
{
return container_of(to_gpio_generic_chip(gc),
struct dwapb_gpio_port, chip)->gpio;
}
struct dwapb_gpio {
struct device *dev;
void __iomem *regs;
unsigned int nr_ports;
unsigned int flags;
struct reset_control *rst;
struct clk_bulk_data clks[DWAPB_NR_CLOCKS];
struct dwapb_gpio_port ports[] __counted_by(nr_ports);
};
static inline u32 gpio_reg_v2_convert(unsigned int offset)
{
switch (offset) {
case GPIO_INTMASK:
return GPIO_INTMASK_V2;
case GPIO_INTTYPE_LEVEL:
return GPIO_INTTYPE_LEVEL_V2;
case GPIO_INT_POLARITY:
return GPIO_INT_POLARITY_V2;
case GPIO_INTSTATUS:
return GPIO_INTSTATUS_V2;
case GPIO_PORTA_EOI:
return GPIO_PORTA_EOI_V2;
}
return offset;
}
static inline u32 gpio_reg_convert(struct dwapb_gpio *gpio, unsigned int offset)
{
if ((gpio->flags & GPIO_REG_OFFSET_MASK) == GPIO_REG_OFFSET_V2)
return gpio_reg_v2_convert(offset);
return offset;
}
static inline u32 dwapb_read(struct dwapb_gpio *gpio, unsigned int offset)
{
struct gpio_generic_chip *chip = &gpio->ports[0].chip;
void __iomem *reg_base = gpio->regs;
return gpio_generic_read_reg(chip, reg_base + gpio_reg_convert(gpio, offset));
}
static inline void dwapb_write(struct dwapb_gpio *gpio, unsigned int offset,
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/clk.h`, `linux/err.h`, `linux/gpio/driver.h`, `linux/gpio/generic.h`, `linux/init.h`, `linux/interrupt.h`, `linux/io.h`.
- Detected declarations: `struct dwapb_gpio`, `struct dwapb_port_property`, `struct dwapb_platform_data`, `struct dwapb_context`, `struct dwapb_gpio_port_irqchip`, `struct dwapb_gpio_port`, `struct dwapb_gpio`, `function gpio_reg_v2_convert`, `function gpio_reg_convert`, `function dwapb_read`.
- Atlas domain: Driver Families / drivers/gpio.
- Implementation status: source implementation candidate.
- 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.