My platform: Beagle Bone Black, Ubuntu, core: 3.14.29-ti-r46
Sensor: MPR121, connect to Beagle i2c-2
I want to make an MPR121 touch sensor (Freescal touchkey chip) to work with Black Beagle Bone Black. The kernel driver is ready to go. But it must work with the device tree.
First I create a dts file for the device tree for MPR121, as shown below:
tomxue@ubuntu:~/Tom/Source_Code/BBB/Ubuntu/ti-linux-kernel-dev/KERNEL/arch/arm/boot/dts$ cat am335x-bone-i2c2-mpr121.dts
/dts-v1/;
#include "am33xx.dtsi"
#include "am335x-bone-common.dtsi"
#include "am335x-bone-common-pinmux.dtsi"
/ {
model = "TI AM335x BeagleBone Black";
compatible = "ti,am335x-bone-black", "ti,am335x-bone", "ti,am33xx";
};
&ocp {
P9_19_pinmux {
mode = "i2c";
};
P9_20_pinmux {
mode = "i2c";
};
};
&i2c2 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <>;
clock-frequency = <100000>;
touchkey: mpr121@5a {
compatible = "fsl,mpr121";
reg = <0x5a>;
};
};
#include "am335x-bone-i2c2-cape-eeprom.dtsi"
Makefile in the directory dtsas shown below:
dtb-$(CONFIG_ARCH_OMAP2PLUS) += omap2420-h4.dtb \
...
am335x-base0033.dtb \
am335x-bone-i2c2-mpr121.dtb \
am3517-craneboard.dtb \
And then I recompile the kernel along with the device tree files. And use the official script to flash the kernel image, modules, and device trees on my Beagle Bone Black.
After rebooting Beagle, I checked the new kernel version:
root@arm:/dev/input
Linux arm 3.14.29-ti-r46
And then turn on the module:
root@arm:~
dmesg mpr121.
i2c-2, i2c-2 Beagle 0x5a ( ):
root@arm:~# i2cdetect -y -r 2
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- UU UU UU UU -- -- 5a -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
, :
root@arm:/dev/input
mice
!
? ?
!