drivers/gpio/gpio-aspeed-sgpio.c
Source file repositories/reference/linux-study-clean/drivers/gpio/gpio-aspeed-sgpio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpio/gpio-aspeed-sgpio.c- Extension
.c- Size
- 18711 bytes
- Lines
- 708
- 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/bitfield.hlinux/cleanup.hlinux/clk.hlinux/gpio/driver.hlinux/hashtable.hlinux/init.hlinux/io.hlinux/kernel.hlinux/module.hlinux/platform_device.hlinux/seq_file.hlinux/spinlock.hlinux/string.h
Detected Declarations
struct aspeed_sgpio_pdatastruct aspeed_sgpiostruct aspeed_sgpio_bankstruct aspeed_sgpio_llopsenum aspeed_sgpio_regfunction aspeed_sgpio_g7_reg_maskfunction aspeed_sgpio_init_valid_maskfunction aspeed_sgpio_irq_init_valid_maskfunction aspeed_sgpio_is_inputfunction aspeed_sgpio_getfunction sgpio_set_valuefunction aspeed_sgpio_setfunction aspeed_sgpio_dir_infunction aspeed_sgpio_dir_outfunction aspeed_sgpio_get_directionfunction aspeed_sgpio_irq_ackfunction aspeed_sgpio_irq_set_maskfunction aspeed_sgpio_irq_maskfunction aspeed_sgpio_irq_unmaskfunction aspeed_sgpio_set_typefunction scoped_guardfunction aspeed_sgpio_irq_handlerfunction aspeed_sgpio_irq_print_chipfunction aspeed_sgpio_setup_irqsfunction aspeed_sgpio_g4_reg_bit_setfunction aspeed_sgpio_g4_reg_bit_getfunction aspeed_sgpio_g4_reg_bank_getfunction aspeed_sgpio_reset_tolerancefunction aspeed_sgpio_set_configfunction aspeed_sgpio_g7_reg_bit_setfunction aspeed_sgpio_g7_reg_bit_getfunction aspeed_sgpio_g7_reg_bank_getfunction aspeed_sgpio_probe
Annotated Snippet
struct aspeed_sgpio_pdata {
const u32 pin_mask;
const struct aspeed_sgpio_llops *llops;
const u32 cfg_offset;
};
struct aspeed_sgpio {
struct gpio_chip chip;
struct device *dev;
struct clk *pclk;
raw_spinlock_t lock;
void __iomem *base;
int irq;
const struct aspeed_sgpio_pdata *pdata;
};
struct aspeed_sgpio_bank {
u16 val_regs;
u16 rdata_reg;
u16 irq_regs;
u16 tolerance_regs;
};
/*
* Note: The "value" register returns the input value when the GPIO is
* configured as an input.
*
* The "rdata" register returns the output value when the GPIO is
* configured as an output.
*/
static const struct aspeed_sgpio_bank aspeed_sgpio_banks[] = {
{
.val_regs = 0x0000,
.rdata_reg = 0x0070,
.irq_regs = 0x0004,
.tolerance_regs = 0x0018,
},
{
.val_regs = 0x001C,
.rdata_reg = 0x0074,
.irq_regs = 0x0020,
.tolerance_regs = 0x0034,
},
{
.val_regs = 0x0038,
.rdata_reg = 0x0078,
.irq_regs = 0x003C,
.tolerance_regs = 0x0050,
},
{
.val_regs = 0x0090,
.rdata_reg = 0x007C,
.irq_regs = 0x0094,
.tolerance_regs = 0x00A8,
},
};
enum aspeed_sgpio_reg {
reg_val,
reg_rdata,
reg_irq_enable,
reg_irq_type0,
reg_irq_type1,
reg_irq_type2,
reg_irq_status,
reg_tolerance,
};
struct aspeed_sgpio_llops {
void (*reg_bit_set)(struct aspeed_sgpio *gpio, unsigned int offset,
const enum aspeed_sgpio_reg reg, bool val);
bool (*reg_bit_get)(struct aspeed_sgpio *gpio, unsigned int offset,
const enum aspeed_sgpio_reg reg);
int (*reg_bank_get)(struct aspeed_sgpio *gpio, unsigned int offset,
const enum aspeed_sgpio_reg reg);
};
#define GPIO_VAL_VALUE 0x00
#define GPIO_IRQ_ENABLE 0x00
#define GPIO_IRQ_TYPE0 0x04
#define GPIO_IRQ_TYPE1 0x08
#define GPIO_IRQ_TYPE2 0x0C
#define GPIO_IRQ_STATUS 0x10
static void __iomem *aspeed_sgpio_g4_bank_reg(struct aspeed_sgpio *gpio,
const struct aspeed_sgpio_bank *bank,
const enum aspeed_sgpio_reg reg)
{
switch (reg) {
case reg_val:
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/cleanup.h`, `linux/clk.h`, `linux/gpio/driver.h`, `linux/hashtable.h`, `linux/init.h`, `linux/io.h`, `linux/kernel.h`.
- Detected declarations: `struct aspeed_sgpio_pdata`, `struct aspeed_sgpio`, `struct aspeed_sgpio_bank`, `struct aspeed_sgpio_llops`, `enum aspeed_sgpio_reg`, `function aspeed_sgpio_g7_reg_mask`, `function aspeed_sgpio_init_valid_mask`, `function aspeed_sgpio_irq_init_valid_mask`, `function aspeed_sgpio_is_input`, `function aspeed_sgpio_get`.
- 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.