drivers/gpio/gpio-tegra.c
Source file repositories/reference/linux-study-clean/drivers/gpio/gpio-tegra.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpio/gpio-tegra.c- Extension
.c- Size
- 22363 bytes
- Lines
- 845
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/err.hlinux/init.hlinux/irq.hlinux/interrupt.hlinux/io.hlinux/gpio/driver.hlinux/of.hlinux/platform_device.hlinux/module.hlinux/irqdomain.hlinux/irqchip/chained_irq.hlinux/pinctrl/consumer.hlinux/pm.hlinux/property.hlinux/seq_file.hlinux/debugfs.h
Detected Declarations
struct tegra_gpio_infostruct tegra_gpio_bankstruct tegra_gpio_soc_configstruct tegra_gpio_infofunction tegra_gpio_writelfunction tegra_gpio_readlfunction tegra_gpio_composefunction tegra_gpio_mask_writefunction tegra_gpio_enablefunction tegra_gpio_disablefunction tegra_gpio_freefunction tegra_gpio_setfunction tegra_gpio_getfunction tegra_gpio_direction_inputfunction tegra_gpio_direction_outputfunction tegra_gpio_get_directionfunction tegra_gpio_set_debouncefunction tegra_gpio_set_configfunction tegra_gpio_irq_ackfunction tegra_gpio_irq_maskfunction tegra_gpio_irq_unmaskfunction tegra_gpio_irq_set_typefunction tegra_gpio_irq_shutdownfunction tegra_gpio_irq_handlerfunction for_each_set_bitfunction tegra_gpio_child_to_parent_hwirqfunction tegra_gpio_populate_parent_fwspecfunction tegra_gpio_resumefunction tegra_gpio_suspendfunction tegra_gpio_irq_set_wakefunction tegra_gpio_irq_set_affinityfunction tegra_gpio_irq_request_resourcesfunction tegra_gpio_irq_release_resourcesfunction tegra_gpio_irq_print_chipfunction tegra_dbg_gpio_showfunction tegra_gpio_debuginitfunction tegra_gpio_debuginitfunction tegra_gpio_probe
Annotated Snippet
struct tegra_gpio_bank {
unsigned int bank;
/*
* IRQ-core code uses raw locking, and thus, nested locking also
* should be raw in order not to trip spinlock debug warnings.
*/
raw_spinlock_t lvl_lock[4];
/* Lock for updating debounce count register */
spinlock_t dbc_lock[4];
#ifdef CONFIG_PM_SLEEP
u32 cnf[4];
u32 out[4];
u32 oe[4];
u32 int_enb[4];
u32 int_lvl[4];
u32 wake_enb[4];
u32 dbc_enb[4];
#endif
u32 dbc_cnt[4];
};
struct tegra_gpio_soc_config {
bool debounce_supported;
u32 bank_stride;
u32 upper_offset;
};
struct tegra_gpio_info {
struct device *dev;
void __iomem *regs;
struct tegra_gpio_bank *bank_info;
const struct tegra_gpio_soc_config *soc;
struct gpio_chip gc;
u32 bank_count;
unsigned int *irqs;
};
static inline void tegra_gpio_writel(struct tegra_gpio_info *tgi,
u32 val, u32 reg)
{
writel_relaxed(val, tgi->regs + reg);
}
static inline u32 tegra_gpio_readl(struct tegra_gpio_info *tgi, u32 reg)
{
return readl_relaxed(tgi->regs + reg);
}
static unsigned int tegra_gpio_compose(unsigned int bank, unsigned int port,
unsigned int bit)
{
return (bank << 5) | ((port & 0x3) << 3) | (bit & 0x7);
}
static void tegra_gpio_mask_write(struct tegra_gpio_info *tgi, u32 reg,
unsigned int gpio, u32 value)
{
u32 val;
val = 0x100 << GPIO_BIT(gpio);
if (value)
val |= 1 << GPIO_BIT(gpio);
tegra_gpio_writel(tgi, val, reg);
}
static void tegra_gpio_enable(struct tegra_gpio_info *tgi, unsigned int gpio)
{
tegra_gpio_mask_write(tgi, GPIO_MSK_CNF(tgi, gpio), gpio, 1);
}
static void tegra_gpio_disable(struct tegra_gpio_info *tgi, unsigned int gpio)
{
tegra_gpio_mask_write(tgi, GPIO_MSK_CNF(tgi, gpio), gpio, 0);
}
static void tegra_gpio_free(struct gpio_chip *chip, unsigned int offset)
{
struct tegra_gpio_info *tgi = gpiochip_get_data(chip);
pinctrl_gpio_free(chip, offset);
tegra_gpio_disable(tgi, offset);
}
static int tegra_gpio_set(struct gpio_chip *chip, unsigned int offset,
int value)
{
struct tegra_gpio_info *tgi = gpiochip_get_data(chip);
Annotation
- Immediate include surface: `linux/err.h`, `linux/init.h`, `linux/irq.h`, `linux/interrupt.h`, `linux/io.h`, `linux/gpio/driver.h`, `linux/of.h`, `linux/platform_device.h`.
- Detected declarations: `struct tegra_gpio_info`, `struct tegra_gpio_bank`, `struct tegra_gpio_soc_config`, `struct tegra_gpio_info`, `function tegra_gpio_writel`, `function tegra_gpio_readl`, `function tegra_gpio_compose`, `function tegra_gpio_mask_write`, `function tegra_gpio_enable`, `function tegra_gpio_disable`.
- Atlas domain: Driver Families / drivers/gpio.
- Implementation status: source 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.