How to make the touch sensor work in the Linux kernel?

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 
/*
 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */
/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 {
        /* i2c2 */
        P9_19_pinmux {
                mode = "i2c";
        };
        P9_20_pinmux {
                mode = "i2c";
        };
};

&i2c2 {
        status = "okay";
        pinctrl-names = "default";
        pinctrl-0 = <>; /* pinctrl-0 = <&i2c2_pins>; */

        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# uname -a
Linux arm 3.14.29-ti-r46 #2 SMP PREEMPT Tue Apr 21 14:30:14 CST 2015 armv7l armv7l armv7l GNU/Linux

And then turn on the module:

root@arm:~# insmod mpr121_touchkey.ko

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# ls
mice

! ? ? !

+4
1

(mpr121_touchkey.c), .

, , , (insmod) /proc/bus/input/devices /proc/bus/input/handlers, node /dev , (udev...) node, node ( 13 ( )) - hexdump, hw .

/proc, .

, , printk dmesg , ( dev_err, , , - ).

0

Source: https://habr.com/ru/post/1584324/


All Articles