I recently started playing around with robots from arexx - a friend introduced me to the asuro, and - impressed by the steep learning curve - i got myself an RP6.

having toyed around with it, i remembered i had an old soekris net4801 lying around... which, unfortunately, does not have i2c ports pinned out - but it has 12 GPIO pins ... i quickly found i2c-gpio in the linux kernel, but that uses the arch-independent gpio layer called gpiolib. the soekris pc8736x gpio driver does not support this layer :(

i'm by far not a kernel developer, but i managed to insert a small wrapping layer that seems to work. it basically registers the pc8736x as generic gpio chip, additionally to the character device(s).

i repeat: i am not a kernel developer. this is a hack so ugly it will most likely not work for you. if you have a soekris net4801 (no, a net4501 will not work! it has lesser gpio pins! go count!) your chances are indefinitely higher it may work, but i don't guarantee anything. also, even the most basic cleanup code is missing - i am not removing the gpio chip on unload, i just dont' care for now.

included in the patch below is a i2c-gpio-generic module i found in the openwrt subversion by pure coincidence, it works very well. i just patched it so it hardcodes sda and scl to open drain, which is the default on the soekris.

to get i2c up and running on the gpio pins 0 and 1 (jp5 pins 3 and 4 on the connector!) with 0 being sda and 1 being scl, you have to

  • modprobe pc8736x_gpio
  • read dmesg and note the assigned lowest pin nr (244 for me)
  • modprobe i2c-generic-custom bus0=245,244,245 (the latter two being the number from above 1st, and 1 added to it 2nd. the first nr. is the i2c bus id. choose it to your liking.)
  • modprobe i2c-dev
that should enable you to run i2cdetect on the newly appeared bus.

a little warning: i wouldn't mess around with the character device while using this, especially not for the pins in use for i2c. you have been warned.

i also wrote a small test program that reads out the current light sensor value (left) of the rp6 running the IC2_Slave example program that it has been shipped with.

also, the *actual* pinout-to-minor-device-nr for the gpio character device might be of interest here:

SoekrisPC8736xMinor Device #
GPIO 0GPIO 20, 11716
GPIO 1GPIO 21, 11817
GPIO 2GPIO 22, 11918
GPIO 3GPIO 23, 12019
GPIO 4GPIO 24, 12120
GPIO 5GPIO 24, 12221
GPIO 6GPIO 26, 12322
GPIO 7GPIO 26, 12423
GPIO 8GPIO 4, 64
GPIO 9GPIO 5, 75
GPIO 10GPIO 13, 5511
GPIO 11GPIO 12, 5410

kudos to the guy who found this out, it cost me 2 days to figure out the straightforward approach (GPIO 20 = minor 20?) was wrong.

here is the patch. handle with care. it's against linux- i used this .config to build the kernel.