gpio_reg_init(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ¦‹ gpio_reg_init(9) πŸ¦‹

okay so this is a page from the Kernel API Manual, and the whole vibe is: you're turning one single fixed register into a whole lil gpio chip, and honestly? iconic. let's get into it bestie πŸ’…


✨ NAME ✨

gpio_reg_init β€” add a fixed in/out register as gpio

like literally, this is the function that says "hey, this register? it's a gpio now. periodt." πŸŽ€


✨ SYNOPSIS ✨

struct gpio_chip * gpio_reg_init (struct device *dev , void __iomem *reg
, int base , int num , const char *label , u32 direction , u32 def_out ,
const char *const *names , struct irq_domain *irqdom , const int *irqs
);

look at all those args, she's serving range πŸ’€ but don't panic, we're going through every single one, fr fr.


✨ ARGUMENTS ✨

  • dev β€” optional struct device associated with this register. optional!! she doesn't need a device, she's independent like that πŸ¦‹
  • reg β€” the original page literally just says -- undescribed -- and that's all we get, ngl 😭 no cap, whoever wrote this left it blank. moving on before it gets awkward πŸ™ˆ
  • base β€” start gpio number, or -1 to allocate. so you either hand her a starting number or you're like "girl, you pick" and -1 makes it allocate ✨
  • num β€” number of GPIOs, maximum 32. that's the ceiling, bestie, 32 and not one more πŸ‘‘
  • label β€” GPIO chip label. her name tag at the party πŸŽ€
  • direction β€” bitmask of fixed direction, one per GPIO signal, 1 = in. so each signal gets its own bit and 1 means input, iykyk
  • def_out β€” initial GPIO output value. the starting fit before she changes into anything else πŸ’œ
  • names β€” array of num strings describing each GPIO signal, or NULL. one cute name per signal, or just NULL if you can't be bothered 🌸
  • irqdom β€” irq domain or NULL. your interrupt domain, or NULL if there isn't one, lowkey simple
  • irqs β€” array of num ints describing the interrupt mapping for each GPIO signal, or NULL. and here's the important bit: if irqdom is NULL, then this describes the Linux interrupt number; otherwise it describes the hardware interrupt number in the specified irq domain. two totally different meanings depending on irqdom, so don't mix them up bestie, I'm begging 😭πŸ”₯

✨ DESCRIPTION ✨

okay so what this actually does: it adds a single-register GPIO device containing up to 32 GPIO signals, where each GPIO has a fixed input or output configuration. fixed! she's not out here being flexible, she's committed to her configuration and honestly same πŸ’…

now the important caveats, and please read these because they're the whole vibe check:

  • Only input GPIOs are assumed to be readable from the register β€” and only then after a double-read. double-read!! that's the rule, don't skip it or you'll be out here reading nonsense πŸ’€
  • Output values are assumed not to be readable. so don't go reading outputs expecting answers, she's not giving them πŸ™ˆ
⚠️ these are assumptions the code makes, not suggestions β€” if you're counting on anything else, that's on you, bestie 😭

✨ SEE ALSO ✨

  • Kernel file ./drivers/gpio/gpio-reg.c β€” go read the source, that's where the real lore lives πŸ“–βœ¨

and that's the whole page, you ate that 🫢

source: ./drivers/gpio 🌈 β€” dated October 2026, signed off as gpio_reg_init(9), and that's the tea girlie, mwah πŸ’–πŸŽ€πŸ’…

πŸ“¦ where this page comes from