drivers/gpio/gpio-cadence.c
Source file repositories/reference/linux-study-clean/drivers/gpio/gpio-cadence.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpio/gpio-cadence.c- Extension
.c- Size
- 8790 bytes
- Lines
- 329
- 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/cleanup.hlinux/clk.hlinux/gpio/driver.hlinux/interrupt.hlinux/gpio/generic.hlinux/kernel.hlinux/module.hlinux/platform_device.hlinux/spinlock.h
Detected Declarations
struct cdns_gpio_quirksstruct cdns_gpio_chipfunction cdns_gpio_requestfunction cdns_gpio_freefunction cdns_gpio_irq_maskfunction cdns_gpio_irq_unmaskfunction cdns_gpio_irq_set_typefunction cdns_gpio_irq_handlerfunction cdns_gpio_probefunction cdns_gpio_remove
Annotated Snippet
struct cdns_gpio_quirks {
bool skip_init;
};
struct cdns_gpio_chip {
struct gpio_generic_chip gen_gc;
void __iomem *regs;
u32 bypass_orig;
const struct cdns_gpio_quirks *quirks;
};
static const struct cdns_gpio_quirks cdns_default_quirks = {
.skip_init = false,
};
static const struct cdns_gpio_quirks ax3000_gpio_quirks = {
.skip_init = true,
};
static int cdns_gpio_request(struct gpio_chip *chip, unsigned int offset)
{
struct cdns_gpio_chip *cgpio = gpiochip_get_data(chip);
guard(gpio_generic_lock)(&cgpio->gen_gc);
iowrite32(ioread32(cgpio->regs + CDNS_GPIO_BYPASS_MODE) & ~BIT(offset),
cgpio->regs + CDNS_GPIO_BYPASS_MODE);
return 0;
}
static void cdns_gpio_free(struct gpio_chip *chip, unsigned int offset)
{
struct cdns_gpio_chip *cgpio = gpiochip_get_data(chip);
guard(gpio_generic_lock)(&cgpio->gen_gc);
iowrite32(ioread32(cgpio->regs + CDNS_GPIO_BYPASS_MODE) |
(BIT(offset) & cgpio->bypass_orig),
cgpio->regs + CDNS_GPIO_BYPASS_MODE);
}
static void cdns_gpio_irq_mask(struct irq_data *d)
{
struct gpio_chip *chip = irq_data_get_irq_chip_data(d);
struct cdns_gpio_chip *cgpio = gpiochip_get_data(chip);
iowrite32(BIT(d->hwirq), cgpio->regs + CDNS_GPIO_IRQ_DIS);
gpiochip_disable_irq(chip, irqd_to_hwirq(d));
}
static void cdns_gpio_irq_unmask(struct irq_data *d)
{
struct gpio_chip *chip = irq_data_get_irq_chip_data(d);
struct cdns_gpio_chip *cgpio = gpiochip_get_data(chip);
gpiochip_enable_irq(chip, irqd_to_hwirq(d));
iowrite32(BIT(d->hwirq), cgpio->regs + CDNS_GPIO_IRQ_EN);
}
static int cdns_gpio_irq_set_type(struct irq_data *d, unsigned int type)
{
struct gpio_chip *chip = irq_data_get_irq_chip_data(d);
struct cdns_gpio_chip *cgpio = gpiochip_get_data(chip);
u32 int_value;
u32 int_type;
u32 int_any;
u32 mask = BIT(d->hwirq);
int ret = 0;
guard(gpio_generic_lock)(&cgpio->gen_gc);
int_value = ioread32(cgpio->regs + CDNS_GPIO_IRQ_VALUE) & ~mask;
int_type = ioread32(cgpio->regs + CDNS_GPIO_IRQ_TYPE) & ~mask;
/*
* Interrupt polarity and trigger behaviour is configured like this:
*
* (type, value)
* (0, 0) = Falling edge triggered
* (0, 1) = Rising edge triggered
* (1, 0) = Low level triggered
* (1, 1) = High level triggered
*/
int_any = ioread32(cgpio->regs + CDNS_GPIO_IRQ_ANY_EDGE) & ~mask;
if (type == IRQ_TYPE_LEVEL_HIGH) {
int_type |= mask;
int_value |= mask;
} else if (type == IRQ_TYPE_LEVEL_LOW) {
int_type |= mask;
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/clk.h`, `linux/gpio/driver.h`, `linux/interrupt.h`, `linux/gpio/generic.h`, `linux/kernel.h`, `linux/module.h`, `linux/platform_device.h`.
- Detected declarations: `struct cdns_gpio_quirks`, `struct cdns_gpio_chip`, `function cdns_gpio_request`, `function cdns_gpio_free`, `function cdns_gpio_irq_mask`, `function cdns_gpio_irq_unmask`, `function cdns_gpio_irq_set_type`, `function cdns_gpio_irq_handler`, `function cdns_gpio_probe`, `function cdns_gpio_remove`.
- 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.