i2c driver for RPi

Luiz Otavio O Souza loos.br at gmail.com
Thu Aug 15 16:50:34 UTC 2013


Hello guys,

I've written the I2C (BSC - broadcom serial controller) driver for RPi.

The test was done by reading the registers of two lm75 on the same I2C bus (the only one available on my RPi).

You have to manually switch the I2C pins to alt0 function. There are two bsc controllers on SoC, the older ones uses the bsc0 and gpio pins 0 and 1 while the newer boards uses the bsc1 with gpio pins 2 and 3.

There is a third bsc controller which is used for the HDMI connection. I have not touched this one (although it should just work).

So for my basics tests, here is what i did:

root at raspberry-pi:~ # sysctl dev.gpio.0.pin.0.function=alt0
dev.gpio.0.pin.0.function: input -> alt0
root at raspberry-pi:~ # sysctl dev.gpio.0.pin.1.function=alt0
dev.gpio.0.pin.1.function: input -> alt0
root at raspberry-pi:~ # cd src/lm75
root at raspberry-pi:~/src/lm75 # ./lm75 -d 150 -f /dev/iic0 -a
lm75 in comparator mode
O.S. polarity: active low
Fault Queue: 1
temperature: 17.0C
o.s. temperature: 80.0C
hyst temperature: 75.0C
root at raspberry-pi:~/src/lm75 # ./lm75 -d 158 -f /dev/iic0 -a
lm75 in comparator mode
O.S. polarity: active low
Fault Queue: 1
temperature: 16.5C
o.s. temperature: 80.0C
hyst temperature: 75.0C


The lm75 code is at: http://loos.no-ip.org/lm75.tar.gz

The BSC driver also exports some knobs under the dev.bsc sysctl:

root at raspberry-pi:~/src/lm75 # sysctl dev.bsc.0
dev.bsc.0.%desc: BCM2708/2835 BSC controller
dev.bsc.0.%driver: bsc
dev.bsc.0.%parent: simplebus0
dev.bsc.0.clock: 100000
dev.bsc.0.clock_stretch: 64
dev.bsc.0.fall_edge_delay: 48
dev.bsc.0.rise_edge_delay: 48


And the dmesg (for bsc part):

bsc0: <BCM2708/2835 BSC controller> mem 0x20205000-0x2020501f irq 61 on simplebus0
iicbus0: <Philips I2C bus> on bsc0
iic0: <I2C generic I/O> on iicbus0
bsc1: <BCM2708/2835 BSC controller> mem 0x20804000-0x2080401f irq 61 on simplebus0
iicbus1: <Philips I2C bus> on bsc1
iic1: <I2C generic I/O> on iicbus1


Is this ok ?

Thanks,
Luiz



-------------- next part --------------
A non-text attachment was scrubbed...
Name: bcm2835_bsc.diff
Type: application/octet-stream
Size: 15284 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-arm/attachments/20130815/1ab7d0bb/attachment.obj>


More information about the freebsd-arm mailing list