STRUCT I2C_GPIO_PLATFORM_DATA(9)
π 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_valuemust 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 forsda_is_open_drainapply β 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
- 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