Friday, December 26, 2014

Beaglebone change I2C speed to 400 KHz

A velocidade padrão das capes no i2c é 100KHz, mas quero mudar para 400KHz
Testado na Beaglebone Black rev. C com Debian 7.5 e 7.7




#tirar o backup do device tree
cp /boot/uboot/dtbs/am335x-boneblack.dtb /boot/uboot/dtbs/am335x-boneblack.dtb-backup

#converte device tree binário para texto
dtc -I dtb -O dts -o /boot/uboot/dtbs/am335x-boneblack.dts /boot/uboot/dtbs/am335x-boneblack.dtb

#editar a clock-frequency para 400000
nano /boot/uboot/dtbs/am335x-boneblack.dts

      i2c@4819c000 {
                        compatible = "ti,omap4-i2c";
                        #address-cells = <0x1>;
                        #size-cells = <0x0>;
                        ti,hwmods = "i2c3";
                        reg = <0x4819c000 0x1000="">;
                        interrupts = <0x1e>;
                        status = "okay";
                        pinctrl-names = "default";
                        pinctrl-0 = <0x7>;
                        #clock-frequency = <0x186a0>; //100KHz
                        clock-frequency = <400000>;

#converte device tree de texto para binário
dtc -I dts -O dtb -o /boot/uboot/dtbs/am335x-boneblack.dtb /boot/uboot/dtbs/am335x-boneblack.dts

reiniciar, e procure no log, deve estar em 400KHz agora.

[    0.131766] omap_i2c 44e0b000.i2c: bus 0 rev0.11 at 400 kHz
[    0.132684] input: tps65217_pwr_but as /devices/ocp.3/44e0b000.i2c/i2c-0/0-0024/input/input0
[    0.140854] omap_i2c 44e0b000.i2c: unable to select pin group
[    0.141335] omap_i2c 4819c000.i2c: bus 1 rev0.11 at 400 kHz



Desativar o i2c das CAPES

#converte de binário para texto
dtc -I dtb -O dts -o am335x-boneblack.dts am335x-boneblack.dtb

#mudar de okay para disabled
 status = "okay";

 status = "disabled";

#converte de texto para binário
dtc -I dts -O dtb -o am335x-boneblack.dtb  am335x-boneblack.dts