I sent some patches at the end of June to get the temperature sensor
working on my Soekris net4826 and after a bit of discussion with Theo,
most of the pieces are now in CVS.
The only part missing is some way to allow gpioiic(4) to assign the SDA
and SCL pins in reverse to match the hardware, (currently it assumes of
the two pins that SDA is the lowest-numbered one, not true here).
Find attached is a patch to gpioiic(4) that adds a flag to allow the
order to be reversed. So for my net4826 kernel, I have the following
gpioiic0 at gpio0 offset 12 mask 0x3 flags 0x0001
which with the patched kernel, produces the following dmesg:
gpio0 at gscpcib0: 64 pins
gpioiic0 at gpio0 pins 12 13 (reversed): SDA open-drain pull-up, SCL open-drain pull-up
iic0 at gpioiic0
lmtemp0 at iic0 addr 0x48: lm75a
I spoke to grange@ about this problem a few weeks ago, where he
mentioned having an idea to fix this, but I haven't heard anything, so I
figured I'd send the patch I had, which is better than my previous fix
of just hardcoding the pin order!
Comments appreciated. It would be really great to get this all fixed for
the 4.0 release.
return (gpio_pin_read(sc->sc_gpio, &sc->sc_map,
- GPIOIIC_PIN_SDA) == GPIO_PIN_HIGH ? GPIOIIC_SDA : 0);
+ sc->sc_pin_sda) == GPIO_PIN_HIGH ? GPIOIIC_SDA : 0);
--- share/man/man4/gpioiic.4.orig Mon Oct 10 15:35:03 2005
+++ share/man/man4/gpioiic.4 Mon Oct 10 15:44:36 2005
@@ -14,21 +14,23 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-.Dd January 14, 2006
+.Dd August 19, 2006
.Dt GPIOIIC 4
.Nd I2C bus bit-banging through GPIO pins
-.Cd "gpioiic* at gpio? offset 0 mask 0x3"
+.Cd "gpioiic* at gpio? offset 0 mask 0x3 flags 0x0000"
.Cd "iic* at gpioiic?"
driver allows bit-banging an I2C bus as a master using two GPIO pins.
The first pin is used as a serial data (SDA) signal and the second as
-a serial clock (SCL).
+a serial clock (SCL), unless the value 0x0001 is passed in the
+in which case the order is reversed.
Both GPIO pins must be able to drive an output and the SDA pin must be
also able to read an input.