rk3x_i2c_v1_calc_timings(9)

๐Ÿ“ฆ version 7.3.1, in nixpkgs unstable

๐Ÿ’… rk3x_i2c_v1_calc_timings โœจ

okay so bestie, welcome to the Kernel API Manual page for rk3x_i2c_v1_calc_timings โ€” yes we are doing kernel I2C timing math and honestly it is giving "niche but iconic" ๐ŸŽ€. This one calculates timing values for the SCL frequency you want, and it is lowkey a whole moment. Slay. ๐Ÿ’–


โœจ NAME โœจ

rk3x_i2c_v1_calc_timings โ€” calculate timing values for desired SCL frequency. That is literally the whole point, bestie. ๐Ÿ’…


๐ŸŒธ SYNOPSIS ๐ŸŒธ

int rk3x_i2c_v1_calc_timings (unsigned long clk_rate , struct
       i2c_timings *t , struct rk3x_i2c_calced_timings *t_calc );

๐ŸŽ€ ARGUMENTS ๐ŸŽ€

  • clk_rate โ€” I2C input clock rate. That is the clock rate coming in, bestie. โฐ
  • t โ€” Known I2C timing information. You bring the timing tea. ๐Ÿซ–
  • t_calc โ€” Caculated rk3x private timings that would be written into regs. Yes, "Caculated" is literally how it is spelled here ๐Ÿ˜ญ. These are the private rk3x values that would be written into the registers. ๐Ÿ’พ

๐Ÿ”ฅ RETURN ๐Ÿ”ฅ

It returns 0 on success. If the goal SCL rate is too slow, it returns -EINVAL, and in that case a best-effort divider value is returned in divs. If the target rate is too high, it silently uses the highest possible rate โ€” no drama, just maxed out. โšก

And just so you know: the following formulas are v1's method to calculate timings. ๐Ÿงฎ


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

okay, formula time โ€” keep these exact, no freestyling:

l = divl + 1; h = divh + 1; s = sda_update_config + 1; u =
start_setup_config + 1; p = stop_setup_config + 1; T = Tclk_i2c;

tHigh = 8 * h * T; tLow = 8 * l * T;

tHD;sda = (l * s + 1) * T; tSU;sda = [(8 - s) * l + 1] * T; tI2C = 8 *
(l + h) * T;

tSU;sta = (8h * u + 1) * T; tHD;sta = [8h * (u + 1) - 1] * T; tSU;sto =
(8h * p + 1) * T;

๐ŸŒˆ SEE ALSO ๐ŸŒˆ

Kernel file ./drivers/i2c/busses/i2c-rk3x.c โ€” and here is the whole friend group:


mwah ๐Ÿ’‹ and that is the page! Source/version: ./drivers/i2c/busses ยท date: October 2026 ยท page: rk3x_i2c_v1_calc_timings(9). Go calculate those timings, queen ๐Ÿ‘‘โœจ

๐Ÿ“ฆ where this page comes from