STRUCT GPIO_GENERIC_CHIP(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 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 underlying struct gpio_chip object, 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 to true by 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 lock chip->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 ✨


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