drivers/gpio/gpio-pxa.c

Source file repositories/reference/linux-study-clean/drivers/gpio/gpio-pxa.c

File Facts

System
Linux kernel
Corpus path
drivers/gpio/gpio-pxa.c
Extension
.c
Size
20412 bytes
Lines
810
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.

Dependency Surface

Detected Declarations

Annotated Snippet

device_initcall(pxa_gpio_dt_init);

#ifdef CONFIG_PM
static int pxa_gpio_suspend(void *data)
{
	struct pxa_gpio_chip *pchip = pxa_gpio_chip;
	struct pxa_gpio_bank *c;
	int gpio;

	if (!pchip)
		return 0;

	for_each_gpio_bank(gpio, c, pchip) {
		c->saved_gplr = readl_relaxed(c->regbase + GPLR_OFFSET);
		c->saved_gpdr = readl_relaxed(c->regbase + GPDR_OFFSET);
		c->saved_grer = readl_relaxed(c->regbase + GRER_OFFSET);
		c->saved_gfer = readl_relaxed(c->regbase + GFER_OFFSET);

		/* Clear GPIO transition detect bits */
		writel_relaxed(0xffffffff, c->regbase + GEDR_OFFSET);
	}
	return 0;
}

static void pxa_gpio_resume(void *data)
{
	struct pxa_gpio_chip *pchip = pxa_gpio_chip;
	struct pxa_gpio_bank *c;
	int gpio;

	if (!pchip)
		return;

	for_each_gpio_bank(gpio, c, pchip) {
		/* restore level with set/clear */
		writel_relaxed(c->saved_gplr, c->regbase + GPSR_OFFSET);
		writel_relaxed(~c->saved_gplr, c->regbase + GPCR_OFFSET);

		writel_relaxed(c->saved_grer, c->regbase + GRER_OFFSET);
		writel_relaxed(c->saved_gfer, c->regbase + GFER_OFFSET);
		writel_relaxed(c->saved_gpdr, c->regbase + GPDR_OFFSET);
	}
}
#else
#define pxa_gpio_suspend	NULL
#define pxa_gpio_resume		NULL
#endif

static const struct syscore_ops pxa_gpio_syscore_ops = {
	.suspend	= pxa_gpio_suspend,
	.resume		= pxa_gpio_resume,
};

static struct syscore pxa_gpio_syscore = {
	.ops = &pxa_gpio_syscore_ops,
};

static int __init pxa_gpio_sysinit(void)
{
	register_syscore(&pxa_gpio_syscore);
	return 0;
}
postcore_initcall(pxa_gpio_sysinit);

Annotation

Implementation Notes