drivers/pinctrl/pinctrl-amd.c
Source file repositories/reference/linux-study-clean/drivers/pinctrl/pinctrl-amd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pinctrl/pinctrl-amd.c- Extension
.c- Size
- 34888 bytes
- Lines
- 1299
- Domain
- Driver Families
- Bucket
- drivers/pinctrl
- 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.
- 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/err.hlinux/bug.hlinux/kernel.hlinux/module.hlinux/spinlock.hlinux/compiler.hlinux/types.hlinux/errno.hlinux/log2.hlinux/io.hlinux/gpio/driver.hlinux/slab.hlinux/platform_device.hlinux/acpi.hlinux/seq_file.hlinux/interrupt.hlinux/bitops.hlinux/pinctrl/pinconf.hlinux/pinctrl/pinconf-generic.hlinux/pinctrl/pinmux.hlinux/string_choices.hlinux/suspend.hcore.hpinctrl-utils.hpinctrl-amd.h
Detected Declarations
function amd_gpio_get_directionfunction amd_gpio_direction_inputfunction amd_gpio_direction_outputfunction amd_gpio_get_valuefunction amd_gpio_set_valuefunction amd_gpio_set_debouncefunction usecfunction amd_gpio_dbg_showfunction amd_gpio_irq_enablefunction amd_gpio_irq_disablefunction amd_gpio_irq_maskfunction amd_gpio_irq_unmaskfunction amd_gpio_irq_set_wakefunction amd_gpio_irq_eoifunction amd_gpio_irq_set_typefunction amd_irq_ackfunction do_amd_gpio_irq_handlerfunction amd_gpio_irq_handlerfunction amd_gpio_check_wakefunction amd_get_groups_countfunction amd_get_group_pinsfunction amd_pinconf_getfunction amd_pinconf_setfunction amd_pinconf_group_getfunction amd_pinconf_group_setfunction amd_gpio_set_configfunction amd_gpio_irq_initfunction amd_gpio_check_pendingfunction amd_gpio_register_s2idle_opsfunction amd_gpio_unregister_s2idle_opsfunction amd_gpio_register_s2idle_opsfunction amd_gpio_suspend_hibernate_commonfunction amd_gpio_suspendfunction amd_gpio_hibernatefunction amd_gpio_resumefunction amd_get_functions_countfunction amd_get_groupsfunction amd_set_muxfunction amd_get_iomux_resfunction amd_gpio_probefunction amd_gpio_remove
Annotated Snippet
if (debounce < 61) {
pin_reg |= 1;
pin_reg &= ~BIT(DB_TMR_OUT_UNIT_OFF);
pin_reg &= ~BIT(DB_TMR_LARGE_OFF);
} else if (debounce < 976) {
time = debounce / 61;
pin_reg |= time & DB_TMR_OUT_MASK;
pin_reg &= ~BIT(DB_TMR_OUT_UNIT_OFF);
pin_reg &= ~BIT(DB_TMR_LARGE_OFF);
} else if (debounce < 3900) {
time = debounce / 244;
pin_reg |= time & DB_TMR_OUT_MASK;
pin_reg |= BIT(DB_TMR_OUT_UNIT_OFF);
pin_reg &= ~BIT(DB_TMR_LARGE_OFF);
} else if (debounce < 250000) {
time = debounce / 15625;
pin_reg |= time & DB_TMR_OUT_MASK;
pin_reg &= ~BIT(DB_TMR_OUT_UNIT_OFF);
pin_reg |= BIT(DB_TMR_LARGE_OFF);
} else if (debounce < 1000000) {
time = debounce / 62500;
pin_reg |= time & DB_TMR_OUT_MASK;
pin_reg |= BIT(DB_TMR_OUT_UNIT_OFF);
pin_reg |= BIT(DB_TMR_LARGE_OFF);
} else {
pin_reg &= ~(DB_CNTRl_MASK << DB_CNTRL_OFF);
ret = -EINVAL;
}
} else {
pin_reg &= ~BIT(DB_TMR_OUT_UNIT_OFF);
pin_reg &= ~BIT(DB_TMR_LARGE_OFF);
pin_reg &= ~DB_TMR_OUT_MASK;
pin_reg &= ~(DB_CNTRl_MASK << DB_CNTRL_OFF);
}
writel(pin_reg, gpio_dev->base + offset * 4);
return ret;
}
#ifdef CONFIG_DEBUG_FS
static void amd_gpio_dbg_show(struct seq_file *s, struct gpio_chip *gc)
{
u32 pin_reg;
u32 db_cntrl;
unsigned long flags;
unsigned int bank, i, pin_num;
struct amd_gpio *gpio_dev = gpiochip_get_data(gc);
bool tmr_out_unit;
bool tmr_large;
char *level_trig;
char *active_level;
char *interrupt_mask;
char *wake_cntrl0;
char *wake_cntrl1;
char *wake_cntrl2;
char *pin_sts;
char *interrupt_sts;
char *wake_sts;
char *orientation;
char debounce_value[40];
char *debounce_enable;
char *wake_cntrlz;
seq_printf(s, "WAKE_INT_MASTER_REG: 0x%08x\n", readl(gpio_dev->base + WAKE_INT_MASTER_REG));
for (bank = 0; bank < gpio_dev->hwbank_num; bank++) {
unsigned int time = 0;
unsigned int unit = 0;
switch (bank) {
case 0:
i = 0;
pin_num = AMD_GPIO_PINS_BANK0;
break;
case 1:
i = 64;
pin_num = AMD_GPIO_PINS_BANK1 + i;
break;
case 2:
i = 128;
pin_num = AMD_GPIO_PINS_BANK2 + i;
break;
case 3:
i = 192;
pin_num = AMD_GPIO_PINS_BANK3 + i;
break;
default:
/* Illegal bank number, ignore */
continue;
Annotation
- Immediate include surface: `linux/err.h`, `linux/bug.h`, `linux/kernel.h`, `linux/module.h`, `linux/spinlock.h`, `linux/compiler.h`, `linux/types.h`, `linux/errno.h`.
- Detected declarations: `function amd_gpio_get_direction`, `function amd_gpio_direction_input`, `function amd_gpio_direction_output`, `function amd_gpio_get_value`, `function amd_gpio_set_value`, `function amd_gpio_set_debounce`, `function usec`, `function amd_gpio_dbg_show`, `function amd_gpio_irq_enable`, `function amd_gpio_irq_disable`.
- Atlas domain: Driver Families / drivers/pinctrl.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.