drivers/gpio/gpio-tangier.c
Source file repositories/reference/linux-study-clean/drivers/gpio/gpio-tangier.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpio/gpio-tangier.c- Extension
.c- Size
- 13328 bytes
- Lines
- 519
- 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.
- 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitops.hlinux/cleanup.hlinux/device.hlinux/errno.hlinux/export.hlinux/interrupt.hlinux/io.hlinux/irq.hlinux/math.hlinux/module.hlinux/pinctrl/pinconf-generic.hlinux/pm.hlinux/spinlock.hlinux/string_helpers.hlinux/types.hlinux/gpio/driver.hgpio-tangier.h
Detected Declarations
struct tng_gpio_contextfunction tng_gpio_getfunction tng_gpio_setfunction tng_gpio_direction_inputfunction tng_gpio_direction_outputfunction tng_gpio_get_directionfunction tng_gpio_set_debouncefunction tng_gpio_set_configfunction tng_irq_ackfunction tng_irq_unmask_maskfunction tng_irq_maskfunction tng_irq_unmaskfunction tng_irq_set_typefunction tng_irq_set_wakefunction tng_irq_handlerfunction tng_irq_init_hwfunction tng_gpio_add_pin_rangesfunction devm_tng_gpio_probefunction tng_gpio_suspendfunction tng_gpio_resume
Annotated Snippet
struct tng_gpio_context {
u32 level;
u32 gpdr;
u32 grer;
u32 gfer;
u32 gimr;
u32 gwmr;
};
static void __iomem *gpio_reg(struct gpio_chip *chip, unsigned int offset,
unsigned int reg)
{
struct tng_gpio *priv = gpiochip_get_data(chip);
u8 reg_offset = offset / 32;
return priv->reg_base + reg + reg_offset * 4;
}
static void __iomem *gpio_reg_and_bit(struct gpio_chip *chip, unsigned int offset,
unsigned int reg, u8 *bit)
{
struct tng_gpio *priv = gpiochip_get_data(chip);
u8 reg_offset = offset / 32;
u8 shift = offset % 32;
*bit = shift;
return priv->reg_base + reg + reg_offset * 4;
}
static int tng_gpio_get(struct gpio_chip *chip, unsigned int offset)
{
void __iomem *gplr;
u8 shift;
gplr = gpio_reg_and_bit(chip, offset, GPLR, &shift);
return !!(readl(gplr) & BIT(shift));
}
static int tng_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
{
struct tng_gpio *priv = gpiochip_get_data(chip);
void __iomem *reg;
u8 shift;
reg = gpio_reg_and_bit(chip, offset, value ? GPSR : GPCR, &shift);
guard(raw_spinlock_irqsave)(&priv->lock);
writel(BIT(shift), reg);
return 0;
}
static int tng_gpio_direction_input(struct gpio_chip *chip, unsigned int offset)
{
struct tng_gpio *priv = gpiochip_get_data(chip);
void __iomem *gpdr;
u32 value;
u8 shift;
gpdr = gpio_reg_and_bit(chip, offset, GPDR, &shift);
guard(raw_spinlock_irqsave)(&priv->lock);
value = readl(gpdr);
value &= ~BIT(shift);
writel(value, gpdr);
return 0;
}
static int tng_gpio_direction_output(struct gpio_chip *chip, unsigned int offset,
int value)
{
struct tng_gpio *priv = gpiochip_get_data(chip);
void __iomem *gpdr;
u8 shift;
gpdr = gpio_reg_and_bit(chip, offset, GPDR, &shift);
tng_gpio_set(chip, offset, value);
guard(raw_spinlock_irqsave)(&priv->lock);
value = readl(gpdr);
value |= BIT(shift);
writel(value, gpdr);
return 0;
}
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/cleanup.h`, `linux/device.h`, `linux/errno.h`, `linux/export.h`, `linux/interrupt.h`, `linux/io.h`, `linux/irq.h`.
- Detected declarations: `struct tng_gpio_context`, `function tng_gpio_get`, `function tng_gpio_set`, `function tng_gpio_direction_input`, `function tng_gpio_direction_output`, `function tng_gpio_get_direction`, `function tng_gpio_set_debounce`, `function tng_gpio_set_config`, `function tng_irq_ack`, `function tng_irq_unmask_mask`.
- Atlas domain: Driver Families / drivers/gpio.
- Implementation status: integration 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.