[coreboot] New interface for I2C in coreboot

Alexandru Gagniuc mr.nuke.me at gmail.com
Tue Feb 10 08:56:50 CET 2015


On Tuesday, February 10, 2015 07:29:33 AM Werner Zeh wrote:
> Hi coreboot community.
> 
Hi back at you.

> 1.	Store the offset we need (in this case 20) into a buffer
> 2.	Call i2c_write_raw(bus, chip_adr, &buffer, 1);
> 3.	Call i2c_read_raw(bus, chip_adr, &buffer,10);
> 

That's actually the way I2C is designed to work, and this sort of API models 
it more accurately. Linux uses it. libeopencm uses it. spidev uses it.

> Here are my personal problems with this kind of interface:

Then provide utility functions to do i2c_reg_(read|write) which wrap 
i2c_transfer() directly. Construct the complete I2c transaction as an array of 
i2c_seg and pass that to i2c_transfer().
> 1.	Where we earlier had one simple call to i2c_read(), we now have to 
fill
> one variable with the length we need and call two different functions
> (i2c_write_raw and i2c_read_raw). 2.	Though the read transfer is one
> logical access to the slave, we have split it into two (without any benefit
> I can see now) 3.	We have added two wrapper layers where we earlier had
> none!
> 
Not quite so. The i2c read/write of the past actually squashed together 
several steps, which ended up being more code as you had to fully model every 
sort of transaction you could think of doing. There's no extra wrapping. The 
code was just reorganized.

Alex



More information about the coreboot mailing list