I would like to use the I2C bus on the Beagle Bone Black in slave mode. From searching around, the question gets asked in the comment section of random posts, but never answered as to whether it's possible or not.
It appears using slave mode I2C isn't a common need in Linux, however I found this example in an Android release: https://android.googlesource.com/kernel/tegra/+/android-tegra-flounder-3.10-lollipop-release/drivers/i2c/i2c-slave.c and this document on the linux kernal site: https://www.kernel.org/doc/Documentation/i2c/slave-interface.
I'm using the Debian Wheezy distro and can't find the referenced in the Android file or i2c-slave-eeprom driver referenced in the linux kernel document. Am I just using too old a kernel? How would one go about generating a slave mode driver?
The i2c bus driver (i2c-omap.c) that is used by the beaglebone in the mainline kernel only supports master mode, but you can use this patch to add slave support. After patching the driver, rebuilding the kernel with CONFIG_I2C_SLAVE
, and deploying it to your BBB, you should be in a good position to follow any of the existing resources on i2c slave in linux.
With support from the bus driver, all that's needed is a backend i2c driver that responds to reads and writes from the master. The kernel documentation for the i2c slave interface (which you already found) describes the callback interface that you need to implement in your backend driver, and you can also look at the i2c-slave-eeprom.c driver as an example.