STRUCT GPIO_REGMAP_CONFIG(9)
β¨ struct gpio_regmap_config(9) β¨
Okay so bestie, grab your emotional support iced coffee because we're diving into struct gpio_regmap_config β the Description of a generic regmap gpio_chip. This is from the Kernel API Manual and it's lowkey iconic. π
πΈ SYNOPSIS πΈ
struct gpio_regmap_config {
struct device *parent;
struct regmap *regmap;
struct fwnode_handle *fwnode;
const char *label;
int ngpio;
const char *const *names;
unsigned int reg_dat_base;
unsigned int reg_set_base;
unsigned int reg_clr_base;
unsigned int reg_dir_in_base;
unsigned int reg_dir_out_base;
int reg_stride;
int ngpio_per_reg;
struct irq_domain *irq_domain;
unsigned long *fixed_direction_mask;
unsigned long *fixed_direction_output;
#ifdef CONFIG_REGMAP_IRQ;
struct regmap_irq_chip *regmap_irq_chip;
int regmap_irq_line;
unsigned long regmap_irq_flags;
#endif;
int (*reg_mask_xlate)(struct gpio_regmap *gpio, enum
gpio_regmap_operation, unsigned int base, unsigned int offset, unsigned
int *reg, unsigned int *mask);
int (*init_valid_mask)(struct gpio_chip *gc, unsigned long
*valid_mask, unsigned int ngpios);
int (*value_xlate)(struct gpio_regmap *gpio, enum
gpio_regmap_operation, unsigned int base, unsigned int offset, unsigned
int reg, unsigned int *mask, unsigned int *val);
int (*set_config)(struct gpio_regmap *gpio, struct gpio_chip *chip,
unsigned int offset, unsigned long config);
void *drvdata;
};
π Members π
So here's the whole cast of characters β every single field, no skips, periodt:
parentβ The parent device. The main character's parent, if you will. πregmapβ The regmap used to access the registers given; the name of the device is used.fwnodeβ (Optional) The firmware node. If not given, the fwnode of the parent is used. It inherits from its parent, relatable tbh.labelβ (Optional) Descriptive name for the GPIO controller. If not given, the name of the device is used.ngpioβ (Optional) Number of GPIOs. Count 'em.namesβ (Optional) Array of names for gpios. Everybody gets a name tag, slay.reg_dat_baseβ (Optional) (in) register base address.reg_set_baseβ (Optional) set register base address.reg_clr_baseβ (Optional) clear register base address.reg_dir_in_baseβ (Optional) in setting register base address.reg_dir_out_baseβ (Optional) out setting register base address. Direction count: two. And they're mutually exclusive, iykyk.reg_strideβ (Optional) May be set if the registers (of the same type, dat, set, etc) are not consecutive.ngpio_per_regβ (Optional) Number of GPIOs per register.irq_domainβ (Optional) IRQ domain if the controller is interrupt-capable.fixed_direction_maskβ (Optional) Bitmap representing the GPIO lines that make use of thefixed_direction_outputlist to enforce direction of the GPIO. If this isNULLandfixed_direction_outputis defined, ALL GPIOs are assumed to be fixed direction (out or in). No cap, it commits to the bit.fixed_direction_outputβ (Optional) Bitmap representing the fixed direction of the GPIO lines. Useful when there are GPIO lines with a fixed direction mixed together in the same register. So like, when they're all up in the same register and you gotta tell them apart.regmap_irq_chipβ (Optional) Pointer on anregmap_irq_chipstructure. If set, a regmap-irq device will be created and the IRQ domain will be set accordingly.regmap_irq_lineβ (Optional) The IRQ the device uses to signal interrupts.regmap_irq_flagsβ (Optional) TheIRQF_flags to use for the interrupt.reg_mask_xlateβ (Optional) Translates base address and GPIO offset to a register/bitmask pair. If not given the defaultgpio_regmap_simple_xlateis used. The default just works, bestie.init_valid_maskβ (Optional) Routine to initializevalid_mask, to be used if not all GPIOs are valid.value_xlateβ (Optional) Routine to translate the register value and mask before writing. This allows driver-specific logic to append additional bits (like write-enable masks) dynamically based on the current operation (GPIO_REGMAP_SET_OPandGPIO_REGMAP_SET_DIR_OP). Fancy β¨.set_configβ (Optional) Callback for setting GPIO configuration such as debounce, drive strength, or other hardware specific settings.drvdataβ (Optional) Pointer to driver specific data which is not used by gpio-remap but is provided "as is" to the driver callback(s). It's giving plus-one energy.
π Description π
Okay so the ->reg_mask_xlate translates a given base address and GPIO offset to register and mask pair. The base address is one of the given register base addresses in this structure.
Although all register base addresses are marked as optional, there are several rules β and bestie, you gotta respect the rules:
- if you only have
reg_dat_baseset, then it is input-only. - if you only have
reg_set_baseset, then it is output-only. - if you have either
reg_dir_in_baseorreg_dir_out_baseset, then you have to set bothreg_dat_baseandreg_set_base. - if you have
reg_set_baseset, you may also setreg_clr_baseto have two different registers for setting and clearing the output. This is also valid for the output-only case. reg_dir_in_baseandreg_dir_out_baseare exclusive; is there really hardware which has redundant registers? Genuinely asking. π
π¨ Note time, bestie: All base addresses may have the special value GPIO_REGMAP_ADDR_ZERO which forces the address to the value 0. Don't sleep on this.
π¦ SEE ALSO π¦
- Kernel file
./include/linux/gpio/regmap.h - enum
gpio_regmap_operation(9)
Go touch grass and read the kernel headers, bestie. This manual page lives in ./include/linux/gpio, dated October 2026, and this struct is a whole vibe. Stay slay, stay compiled. π
β¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms