drivers/gpio/gpio-npcm-sgpio.c
Source file repositories/reference/linux-study-clean/drivers/gpio/gpio-npcm-sgpio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpio/gpio-npcm-sgpio.c- Extension
.c- Size
- 14543 bytes
- Lines
- 618
- 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/clk.hlinux/gpio/driver.hlinux/hashtable.hlinux/init.hlinux/io.hlinux/module.hlinux/platform_device.hlinux/spinlock.hlinux/string.hlinux/units.h
Detected Declarations
struct npcm_clk_cfgstruct npcm_sgpiostruct npcm_sgpio_bankenum npcm_sgpio_regfunction npcm_sgpio_irqd_to_datafunction npcm_sgpio_init_portfunction npcm_sgpio_dir_infunction npcm_sgpio_dir_outfunction npcm_sgpio_get_directionfunction npcm_sgpio_setfunction npcm_sgpio_getfunction npcm_sgpio_setup_enablefunction npcm_sgpio_setup_clkfunction npcm_sgpio_irq_init_valid_maskfunction npcm_sgpio_irq_set_maskfunction npcm_sgpio_irq_ackfunction npcm_sgpio_irq_maskfunction npcm_sgpio_irq_unmaskfunction npcm_sgpio_set_typefunction npcm_sgpio_irq_handlerfunction npcm_sgpio_setup_irqsfunction npcm_sgpio_probe
Annotated Snippet
struct npcm_clk_cfg {
unsigned int *sft_clk;
unsigned int *clk_sel;
unsigned int cfg_opt;
};
struct npcm_sgpio {
struct gpio_chip chip;
struct clk *pclk;
struct irq_chip intc;
raw_spinlock_t lock;
void __iomem *base;
int irq;
u8 nin_sgpio;
u8 nout_sgpio;
u8 in_port;
u8 out_port;
u8 int_type[MAX_NR_HW_SGPIO];
};
struct npcm_sgpio_bank {
u8 rdata_reg;
u8 wdata_reg;
u8 event_config;
u8 event_status;
};
enum npcm_sgpio_reg {
READ_DATA,
WRITE_DATA,
EVENT_CFG,
EVENT_STS,
};
static const struct npcm_sgpio_bank npcm_sgpio_banks[] = {
{
.wdata_reg = 0x00,
.rdata_reg = 0x08,
.event_config = 0x10,
.event_status = 0x20,
},
{
.wdata_reg = 0x01,
.rdata_reg = 0x09,
.event_config = 0x12,
.event_status = 0x21,
},
{
.wdata_reg = 0x02,
.rdata_reg = 0x0a,
.event_config = 0x14,
.event_status = 0x22,
},
{
.wdata_reg = 0x03,
.rdata_reg = 0x0b,
.event_config = 0x16,
.event_status = 0x23,
},
{
.wdata_reg = 0x04,
.rdata_reg = 0x0c,
.event_config = 0x18,
.event_status = 0x24,
},
{
.wdata_reg = 0x05,
.rdata_reg = 0x0d,
.event_config = 0x1a,
.event_status = 0x25,
},
{
.wdata_reg = 0x06,
.rdata_reg = 0x0e,
.event_config = 0x1c,
.event_status = 0x26,
},
{
.wdata_reg = 0x07,
.rdata_reg = 0x0f,
.event_config = 0x1e,
.event_status = 0x27,
},
};
static void __iomem *bank_reg(struct npcm_sgpio *gpio,
const struct npcm_sgpio_bank *bank,
const enum npcm_sgpio_reg reg)
{
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/gpio/driver.h`, `linux/hashtable.h`, `linux/init.h`, `linux/io.h`, `linux/module.h`, `linux/platform_device.h`.
- Detected declarations: `struct npcm_clk_cfg`, `struct npcm_sgpio`, `struct npcm_sgpio_bank`, `enum npcm_sgpio_reg`, `function npcm_sgpio_irqd_to_data`, `function npcm_sgpio_init_port`, `function npcm_sgpio_dir_in`, `function npcm_sgpio_dir_out`, `function npcm_sgpio_get_direction`, `function npcm_sgpio_set`.
- 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.