STRUCT GPIO_GENERIC_CHIP(9)
πΈ NAME πΈ
okay so bestie, welcome to the Kernel API Manual (yes, that one β the fancy section 9 energy π) β this page is all about struct gpio_generic_chip, which is literally the Generic GPIO chip implementation. no cap, that's the whole vibe of the struct. π
β¨ SYNOPSIS β¨
like, here's the whole shape of it, bestie β copy it exactly, don't come for me about the spacing π«Ά
struct gpio_generic_chip {
struct gpio_chip gc;
unsigned long (*read_reg)(void __iomem *reg);
void (*write_reg)(void __iomem *reg, unsigned long data);
bool be_bits;
void __iomem *reg_dat;
void __iomem *reg_set;
void __iomem *reg_clr;
void __iomem *reg_dir_out;
void __iomem *reg_dir_in;
bool dir_unreadable;
bool pinctrl;
int bits;
raw_spinlock_t lock;
unsigned long sdata;
unsigned long sdir;
};
π Members π
so every field has main character energy of its own, let me introduce u to the whole friend group π
gcβ the underlyingstruct gpio_chipobject, and it's the one actually implementing the low-level GPIO chip routines. it's giving foundation. it's giving who even am i without u.read_regβ the reader function for generic GPIO. reads the tea. βwrite_regβ the writer function for generic GPIO. writes the tea. βοΈbe_bitsβ set totrueby the generic GPIO core if the generic GPIO has big endian bit order (and bestie, that means bit 31 represents line 0, bit 30 is line 1 β¦ bit 0 is line 31 π). it is for internal housekeeping only β so don't be out here touching it, k? πreg_datβ data (in) register for generic GPIO.reg_setβ output set register (out=high) for generic GPIO. high energy only π₯reg_clrβ output clear register (out=low) for generic GPIO. lowkey mood.reg_dir_outβ direction out setting register for generic GPIO.reg_dir_inβ direction in setting register for generic GPIO.dir_unreadableβ indicates that the direction register(s) cannot be read and we need to rely on our internal state tracking. so like, we can't see the truth so we keep our own receipts π§Ύpinctrlβ the generic GPIO uses a pin control backend. collab era π€bitsβ number of register bits used for a generic GPIO, i.e.<register width> * 8. the math is mathing, periodt.lockβ used to lockchip->sdata. also β and this is the important part β this is needed to keep shadowed and real data register writes together. no letting them drift apart, we're a package deal π«Άsdataβ shadowed data register for generic GPIO, there so we can clear/set bits safely.sdirβ shadowed direction register for generic GPIO, there so we can clear/set direction safely. and a"1"in this word means the line is set as output. iconic behavior honestly π
fr fr tho β the lock field isn't decorative, it's literally the thing keeping shadowed + real register writes in sync. respect it.
π¦ SEE ALSO π¦
go read these next, bestie, they're the rest of the lore β¨
- Kernel file
./include/linux/gpio/generic.hstruct gpio_generic_chip_config(9)gpio_generic_chip_set(9)gpio_generic_read_reg(9)gpio_generic_write_reg(9)
and that's the whole page!! π source is ./include/linux/gpio, dated October 2026 β so like, from the future, obviously, slay. mwah, go write some GPIO drivers bestie πΈππ
π¦ 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