STRUCT I2C_GPIO_PLATFORM_DATA(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– NAME πŸ’–

struct i2c_gpio_platform_data β€” the platform-dependent data for i2c-gpio, aka the little bundle of settings that tells the bit-banged I2C driver how your particular pins actually behave πŸ’…

(and yes bestie, this is from the Kernel API Manual, section 9, we love a kernel reference page πŸŽ€)


✨ SYNOPSIS ✨

struct i2c_gpio_platform_data {
    int udelay;
    int timeout;
    unsigned int    sda_is_open_drain:1;
    unsigned int    sda_is_output_only:1;
    unsigned int    sda_has_no_pullup:1;
    unsigned int    scl_is_open_drain:1;
    unsigned int    scl_is_output_only:1;
    unsigned int    scl_has_no_pullup:1;
 };

okay so it's literally one int, another int, and then six single-bit flags β€” the bitfields are doing main character energy here 🫢


πŸ‘‘ Members πŸ‘‘

  • udelay β€” the signal toggle delay ⏱️. the SCL frequency is (500 / udelay) kHz, so yeah, that's the whole vibe: pick your delay, get your clock speed. math is mathing πŸ”₯
  • timeout β€” clock stretching timeout, measured in jiffies πŸ•°οΈ. if the slave keeps SCL low for longer than this, the transfer will time out. no cap, it will just give up on you 😭
  • sda_is_open_drain β€” SDA is configured as open drain, i.e. the pin isn't actively driven high when setting the output value high. gpio_get_value must return the actual pin state even if the pin is configured as an output πŸ‘€. so like… you can't just lie to yourself about the pin state, the read has to be honest fr fr.
  • sda_is_output_only β€” SDA output drivers can't be turned off 🚫. this one's for clients that can only read SDA/SCL β€” they're not doing bidirectional, they're just reading, and that's valid πŸ’…
  • sda_has_no_pullup β€” SDA is used in a non-compliant way and has no pull-up πŸ™ˆ. therefore disable open-drain. yes it's sketchy, yes the flag exists for exactly this, no we're not judging you (we're judging a little).
  • scl_is_open_drain β€” SCL is set up as open drain ⚑. same requirements as for sda_is_open_drain apply β€” so re-read that one, bestie, it's a package deal πŸ‘‘
  • scl_is_output_only β€” SCL output drivers cannot be turned off πŸ”’. that's it, that's the flag.
  • scl_has_no_pullup β€” SCL is used in a non-compliant way and has no pull-up 🌸. therefore disable open-drain. twin of the SDA one, matching set, iconic πŸŽ€

🌈 SEE ALSO 🌈

  • Kernel file ./include/linux/platform_data/i2c-gpio.h β€” go read the actual header, it's right there, iykyk πŸ“–βœ¨

real talk: those *_has_no_pullup flags are literally the code admitting the hardware is non-compliant. keep that in mind before you ship it 🫢

okay that's the whole page, you ate that πŸ“ this gem lives in ./include/linux/platform_data and the version stamp on it is October 2026 β€” so go forth, configure your GPIO I2C pins, and slay πŸ’œβœ¨

πŸ“¦ where this page comes from