What is? spi and i2c in linux? What do I need it for?

Hi!

I want to know :slight_smile:

What is? spi and i2c in linux? What do I need it for?

Can someone explain this to me simply?

simply ...

I2C is a half-duplex communication protocol. SPI is a full-duplex communication protocol.

Let me try to explain them as simply as possible, based on what I know.

I2C (it's actually I²C, but only snobs write it that way) is a very simple communications protocol for transmitting digital data from one place to another. Its main advantage is that it's cheap to implement: Transmitting data using I2C requires only three wires, and the protocol is very simple, so a manufacturer of a device can add I2C capabilities for only a few (Euro-) cents. The main disadvantage of I2C is that it generally can transfer data only at a really...slow...pace compared to other communications standards; the speed of data transfer from an I2C-connected device is less like that of USB than of RS-232C, the "serial" or "communications" port standard that took 50 years to die out of mainstream existence.

I2C is actually not an "official" standard -- no international body such as the ISO, AFAIK, has ratified I2C as a standard. Instead, I2C is a so-called "de facto" standard -- that means that it's standard just because a manufacturer, in this case Philips, created I2C, made it popular, and people and other electronics manufacturers started building products around I2C until it became a standard as a matter of fact -- hence the "facto" part.

The fact that I2C is merely a de facto standard means that many other manufacturers have come up with their own derivatives of I2C, and a few have become official standards as opposed to just being de facto. Some examples of I2C derivatives include ACCESS.bus, SPI, and SMBus.

You may be very surprised to find out that a typical PC contains some very unlikely devices which communicate over at least ACCESS.bus and SPI -- and many Intel-based PCs use SMBus, either as well as the other two, or in place of them. Here's some examples:

  • Your monitor carries out a two-way "conversation" with your computer -- the computer's video card doesn't just send video data to the monitor, the monitor talks back sometimes. This is how the computer knows what your monitor's resolution is! Your video card communicates with the monitor to get the monitor's EDID (resolution, refresh rate, and other video parameters) data, using ACCESS.bus.

  • Every RAM module you install in almost any modern computer contains some permanent memory intended to identify the memory module and its size, speed, and other specifications. In ye olden days, you'd have to type these numbers in yourself (or worse, move jumpers to make things work!), but today memory modules advertise themselves using an extra flash memory chip on the RAM module that communicates with the computer over the SPI bus. (If you don't believe me about this, look at a RAM module from about 1996 to the present day, and look on both sides for a very tiny chip -- maybe 5mm by 5mm or less -- that looks totally different from all the other chips on the module. This chip is a tiny, usually 1KB flash chip that stores information about the RAM module. Notice that the chip has only 8 legs -- if the chip used a non-I2C-based protocol, it'd be more expensive and would need more wires!)

  • If you have a laptop, the battery communicates its charge level, temperature, and other such statistics to the computer using ACCESS.bus.

As you can see, all of these users of I2C-based communications protocols only have to transfer a few bytes (or kilobytes) at most, so a bus as cheap yet slow as I2C is sufficient for the purposes.


Due to the above uses (especially the uses for detecting RAM modules, but also other components I haven't mentioned), Linux usually requires some level of support for I2C, and as such it's usually not advisable to remove I2C support unless you know what you're doing.


Maybe @pavlos_kairis's explanation suffices, but I started typing mine first, and I don't want to scrap it just because he hit Reply first! :slight_smile:

8 Likes

Now I understand :slight_smile: Thanks for the info. Already wanted to test "i2c" remove from my system for the purpose of system tweaking :wink: