drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c
Source file repositories/reference/linux-study-clean/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c- Extension
.c- Size
- 74239 bytes
- Lines
- 2008
- 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.
- 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/device.hlinux/gpio/driver.hlinux/gpio/generic.hlinux/interrupt.hlinux/irq.hlinux/mfd/syscon.hlinux/mod_devicetable.hlinux/module.hlinux/platform_device.hlinux/property.hlinux/regmap.hlinux/seq_file.hlinux/pinctrl/consumer.hlinux/pinctrl/machine.hlinux/pinctrl/pinconf-generic.hlinux/pinctrl/pinconf.hlinux/pinctrl/pinctrl.hlinux/pinctrl/pinmux.h
Detected Declarations
struct npcm7xx_gpiostruct npcm7xx_pinctrlstruct npcm7xx_pincfgfunction npcm_gpio_setfunction npcm_gpio_clrfunction npcmgpio_dbg_showfunction npcmgpio_direction_inputfunction npcmgpio_direction_outputfunction npcmgpio_gpio_requestfunction npcmgpio_irq_handlerfunction npcmgpio_set_irq_typefunction npcmgpio_irq_ackfunction npcmgpio_irq_maskfunction npcmgpio_irq_unmaskfunction npcmgpio_irq_startupfunction npcm7xx_setfuncfunction npcm7xx_get_slew_ratefunction npcm7xx_set_slew_ratefunction npcm7xx_get_drive_strengthfunction npcm7xx_set_drive_strengthfunction npcm7xx_pin_dbg_showfunction npcm7xx_get_groups_countfunction npcm7xx_get_group_pinsfunction npcm7xx_dt_free_mapfunction npcm7xx_get_functions_countfunction npcm7xx_get_function_groupsfunction npcm7xx_pinmux_set_muxfunction npcm7xx_gpio_request_enablefunction npcm7xx_gpio_request_freefunction npcm_gpio_set_directionfunction npcm7xx_config_getfunction npcm7xx_config_set_onefunction npcm7xx_config_setfunction npcm7xx_gpio_offunction for_each_gpiochip_nodefunction npcm7xx_gpio_registerfunction npcm7xx_pinctrl_probefunction npcm7xx_pinctrl_register
Annotated Snippet
struct npcm7xx_gpio {
void __iomem *base;
struct gpio_generic_chip chip;
int irqbase;
int irq;
u32 pinctrl_id;
int (*direction_input)(struct gpio_chip *chip, unsigned int offset);
int (*direction_output)(struct gpio_chip *chip, unsigned int offset,
int value);
int (*request)(struct gpio_chip *chip, unsigned int offset);
void (*free)(struct gpio_chip *chip, unsigned int offset);
};
struct npcm7xx_pinctrl {
struct pinctrl_dev *pctldev;
struct device *dev;
struct npcm7xx_gpio gpio_bank[NPCM7XX_GPIO_BANK_NUM];
struct irq_domain *domain;
struct regmap *gcr_regmap;
void __iomem *regs;
u32 bank_num;
};
/* GPIO handling in the pinctrl driver */
static void npcm_gpio_set(struct gpio_generic_chip *chip, void __iomem *reg,
unsigned int pinmask)
{
unsigned long val;
guard(gpio_generic_lock_irqsave)(chip);
val = ioread32(reg) | pinmask;
iowrite32(val, reg);
}
static void npcm_gpio_clr(struct gpio_generic_chip *chip, void __iomem *reg,
unsigned int pinmask)
{
unsigned long val;
guard(gpio_generic_lock_irqsave)(chip);
val = ioread32(reg) & ~pinmask;
iowrite32(val, reg);
}
static void npcmgpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
{
struct npcm7xx_gpio *bank = gpiochip_get_data(chip);
seq_printf(s, "-- module %d [gpio%d - %d]\n",
bank->chip.gc.base / bank->chip.gc.ngpio,
bank->chip.gc.base,
bank->chip.gc.base + bank->chip.gc.ngpio);
seq_printf(s, "DIN :%.8x DOUT:%.8x IE :%.8x OE :%.8x\n",
ioread32(bank->base + NPCM7XX_GP_N_DIN),
ioread32(bank->base + NPCM7XX_GP_N_DOUT),
ioread32(bank->base + NPCM7XX_GP_N_IEM),
ioread32(bank->base + NPCM7XX_GP_N_OE));
seq_printf(s, "PU :%.8x PD :%.8x DB :%.8x POL :%.8x\n",
ioread32(bank->base + NPCM7XX_GP_N_PU),
ioread32(bank->base + NPCM7XX_GP_N_PD),
ioread32(bank->base + NPCM7XX_GP_N_DBNC),
ioread32(bank->base + NPCM7XX_GP_N_POL));
seq_printf(s, "ETYP:%.8x EVBE:%.8x EVEN:%.8x EVST:%.8x\n",
ioread32(bank->base + NPCM7XX_GP_N_EVTYP),
ioread32(bank->base + NPCM7XX_GP_N_EVBE),
ioread32(bank->base + NPCM7XX_GP_N_EVEN),
ioread32(bank->base + NPCM7XX_GP_N_EVST));
seq_printf(s, "OTYP:%.8x OSRC:%.8x ODSC:%.8x\n",
ioread32(bank->base + NPCM7XX_GP_N_OTYP),
ioread32(bank->base + NPCM7XX_GP_N_OSRC),
ioread32(bank->base + NPCM7XX_GP_N_ODSC));
seq_printf(s, "OBL0:%.8x OBL1:%.8x OBL2:%.8x OBL3:%.8x\n",
ioread32(bank->base + NPCM7XX_GP_N_OBL0),
ioread32(bank->base + NPCM7XX_GP_N_OBL1),
ioread32(bank->base + NPCM7XX_GP_N_OBL2),
ioread32(bank->base + NPCM7XX_GP_N_OBL3));
seq_printf(s, "SLCK:%.8x MLCK:%.8x\n",
ioread32(bank->base + NPCM7XX_GP_N_SPLCK),
ioread32(bank->base + NPCM7XX_GP_N_MPLCK));
}
static int npcmgpio_direction_input(struct gpio_chip *chip, unsigned int offset)
{
struct npcm7xx_gpio *bank = gpiochip_get_data(chip);
int ret;
ret = pinctrl_gpio_direction_input(chip, offset);
if (ret)
Annotation
- Immediate include surface: `linux/device.h`, `linux/gpio/driver.h`, `linux/gpio/generic.h`, `linux/interrupt.h`, `linux/irq.h`, `linux/mfd/syscon.h`, `linux/mod_devicetable.h`, `linux/module.h`.
- Detected declarations: `struct npcm7xx_gpio`, `struct npcm7xx_pinctrl`, `struct npcm7xx_pincfg`, `function npcm_gpio_set`, `function npcm_gpio_clr`, `function npcmgpio_dbg_show`, `function npcmgpio_direction_input`, `function npcmgpio_direction_output`, `function npcmgpio_gpio_request`, `function npcmgpio_irq_handler`.
- Atlas domain: Driver Families / drivers/pinctrl.
- Implementation status: source implementation candidate.
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.