raspberrypi/linux — pull request #651 by notro (2014-07-29 11:02:19+00:00)
Title: i2c: bcm2708: add device tree support

kconfig
```
ARCH=arm make bcmrpi_defconfig
scripts/config --enable BCM2708_DT
scripts/config --module I2C_BCM2835
yes "" | ARCH=arm make oldconfig
```

Enable i2c-1
```
$ fdtget /boot/bcm2708-rpi-b.dtb /soc/i2c@7e804000 status
disabled
$ sudo fdtput --type s /boot/bcm2708-rpi-b.dtb /soc/i2c@7e804000 status "okay"
$ sudo reboot
$ dmesg
[ 6.613730] bcm2708_i2c_init_pinmode(1,2)
[ 6.811634] bcm2708_i2c_init_pinmode(1,3)
[ 6.964823] bcm2708_i2c 20804000.i2c: BSC1 Controller at 0x20804000 (irq 79) (baudrate 100000)
[ 8.090310] pcm512x 1-004c: Failed to reset device: -5
[ 8.107153] pcm512x: probe of 1-004c failed with error -5
$ ls -l /dev/i2c*
crw-rw---T 1 root i2c 89, 1 Jul 28 20:47 /dev/i2c-1
```

Use the i2c-bcm2835 driver
```
$ fdtget /boot/bcm2708-rpi-b.dtb /soc/i2c@7e804000 compatible
brcm,bcm2708-i2c
$ sudo fdtput --type s /boot/bcm2708-rpi-b.dtb /soc/i2c@7e804000 compatible "brcm,bcm2835-i2c"
$ fdtget /boot/bcm2708-rpi-b.dtb /soc/i2c@7e804000 compatible
brcm,bcm2835-i2c
$ sudo reboot
$ dmesg
[ 8.020037] i2c-bcm2835 20804000.i2c: i2c transfer failed: 100
[ 8.028457] pcm512x 1-004c: Failed to reset device: -121
[ 8.036192] pcm512x: probe of 1-004c failed with error -121
$ ls -l /dev/i2c*
crw-rw---T 1 root i2c 89, 1 Jul 28 20:47 /dev/i2c-1
```
The transfer error seem to be related to the failed pcm512x probing.

Howto install latest dtc: https://github.com/notro/rpi-firmware/wiki/Device-Tree

**Test**

Using a ds1307 rtc chip.

Add to dts
```
&i2c1 {
status = "okay";

rtc@68 {
compatible = "dallas,ds1307";
reg = <0x68>;
};
};
```
Verify
```
$ dmesg
[ 6.895287] rtc-ds1307 1-0068: rtc core: registered ds1307 as rtc0
[ 6.903734] rtc-ds1307 1-0068: 56 bytes nvram
[ 7.242081] bcm2708_i2c 20804000.i2c: BSC1 Controller at 0x20804000 (irq 79) (baudrate 100000)
$ sudo hwclock -r
Mon 28 Jul 2014 20:26:15 UTC -0.905546 seconds
```
Works with both drivers.