cdns_i2c_setclk(9)
π cdns_i2c_setclk β the Kernel API Manual, bestie edition β¨
okay so you're looking at cdns_i2c_setclk(9)</p>, straight out of the Kernel API Manual, and honestly? it's a little icon. it does exactly one job and it does it cute: it sets the serial clock rate for the I2C device. that's the whole personality. π
β¨ SYNOPSIS β¨
int cdns_i2c_setclk (unsigned long clk_in , struct cdns_i2c *id );
yes she returns an int, yes she takes two args, no we will not be normal about it π«Ά
π ARGUMENTS π
clk_inβ the I2C clock input frequency, in Hz. that's her. that's the number you're feeding in πidβ a pointer to the I2C device structure (struct cdns_i2c). your main character struct, fr fr.
πΈ DESCRIPTION πΈ
okay so before you even think about setting these device options, the device has to be idle, not busy transferring data. not me stressing this β it's literally in the doc. read the room (and the hardware state) first, bestie π
the data rate? set by the values in the control register. and the formula for figuring out the correct register values is:
Fscl = Fpclk/(22 x (divisor_a+1) x (divisor_b+1))
copy that exactly, i don't make the rules, the hardware does. π
for a full explanation of setting the serial clock rate, go check the hardware data sheet β it's giving required reading, i know, but slay.
β οΈ important vibe check: the clock can not be faster than the input clock divided by 22. no cap. that's the ceiling.
the two most common clock rates are 100KHz and 400KHz β the classics, the icons, the ones everyone actually uses β
π RETURN π
0on success π- negative error otherwise π
basically: zero means she ate, negative means something went sideways.
π SEE ALSO π
start with the kernel file itself: ./drivers/i2c/busses/i2c-cadence.c β that's where the magic lives π§
and then the whole friend group, all of them, no one left out:
enum cdns_i2c_mode(9)enum cdns_i2c_slave_state(9)struct cdns_i2c(9)cdns_i2c_init(9)cdns_i2c_runtime_suspend(9)cdns_i2c_runtime_resume(9)cdns_i2c_clear_bus_hold(9)cdns_i2c_slave_isr(9)cdns_i2c_master_isr(9)cdns_i2c_isr(9)cdns_i2c_mrecv(9)cdns_i2c_msend(9)cdns_i2c_master_reset(9)cdns_i2c_master_xfer(9)cdns_i2c_master_xfer_atomic(9)cdns_i2c_func(9)cdns_i2c_calc_divs(9)cdns_i2c_clk_notifier_cb(9)cdns_i2c_detect_transfer_size(9)cdns_i2c_probe(9)cdns_i2c_remove(9)cdns_i2c_shutdown(9)
and that's the page, bestie!! π this little beauty lives over in ./drivers/i2c/busses, stamped October 2026 β go forth, set those clocks, stay idle before you configure, and remember: divide by 22 or perish πβ¨
π¦ 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