I2C and SPI


Hi Guys

I’ve looked at all the links I can possibly find on the topic, but I’m not a 100% clear about how to use I2C and SPI on these boards. I can only see an “/dev/i2c-0” device and there is no output when using that (also there appear to be two I2C busses broken out on the daughter board, so it seems like there should also be a /dev/i2c-1).

Am I suppose to write my own kernel modules to drive I2C and SPI?



You can take a look at the guides below from the 96boards blog. They contain detailed step-by-step guide to help get started easily.

If your I2C and SPI device already have a driver supported in the linux kernel, then you don’t to write your own, but you might have to recompile the kernel to enable/activate it if it’s not already.


Thanks vchong, I’ve already worked through that. From what you’ve said, I think that perhaps I misunderstood how the I2C drivers work on Linux. I.e. I thought there would be a generic driver for the I2C controller on the SOC, similar to the UART driver. Is this not the case?


There is perhaps sort of a generic driver you can use. See https://www.kernel.org/doc/Documentation/i2c/dev-interface for more details. Some sample codes: http://elinux.org/Interfacing_with_I2C_Devices. It’s what libraries like libsoc and libmraa use as well under the hood to interface to I2C devices.


I also tried that without success :S

But as I mentioned before, per the schematic (http://mirror.lemaker.org/LeMaker%20Hikey%20Schematic.pdf) and the breakout header, I would expect to see 3x dev entries for the i2C hosts, i.e.:


However I can only see /dev/i2c-0. I also noticed that I2C2_SCL and I2C2_SDA are hooked up to HDMI controller so not sure if that (/dev/i2c-0) is actually interfacing with that instead of being mapped to I2C0 and I2C1.

Right now, I have the I2C interface hooked up to a DSO and for testing purpose do not have anything on the bus. The Hikey board seem to have the required pull-up resistors so if anything gets written to the bus I should see the capture on the DSO. I don’t get anything out.

If this is supposed to work, I’ll check the Kernel build options tonight.