如何编写模拟设备触摸屏ad7879 i2c的设备树覆盖图


8

我为驱动程序ad78​​79-i2c触摸屏(使用Raspberry Pi源作为模块编译为模块,文件:ad7879-i2c.c,ad7879.c)编写了设备树覆盖图。驱动程序被加载,但是我想参数没有传递给驱动程序。设备位于i2c1、0x2c地址,GPIO 26(BCM 12)上。evtest显示驱动程序的默认参数,并且触摸屏根本不起作用。

在/boot/config.txt中:

dtparam=i2c_arm=on
dtoverlay=i2c-ad7879

在/ etc / modules中:

i2c-bcm2708
i2c-dev

gpio readall的输出:

 +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |   2 |   8 |   SDA.1 | ALT0 | 1 |  3 || 4  |   |      | 5V      |     |     |
 |   3 |   9 |   SCL.1 | ALT0 | 1 |  5 || 6  |   |      | 0v      |     |     |
 |   4 |   7 | GPIO. 7 |   IN | 0 |  7 || 8  | 1 | ALT0 | TxD     | 15  | 14  |
 |     |     |      0v |      |   |  9 || 10 | 1 | ALT0 | RxD     | 16  | 15  |
 |  17 |   0 | GPIO. 0 |   IN | 0 | 11 || 12 | 0 | IN   | GPIO. 1 | 1   | 18  |
 |  27 |   2 | GPIO. 2 |   IN | 0 | 13 || 14 |   |      | 0v      |     |     |
 |  22 |   3 | GPIO. 3 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO. 4 | 4   | 23  |
 |     |     |    3.3v |      |   | 17 || 18 | 0 | IN   | GPIO. 5 | 5   | 24  |
 |  10 |  12 |    MOSI |   IN | 0 | 19 || 20 |   |      | 0v      |     |     |
 |   9 |  13 |    MISO |   IN | 0 | 21 || 22 | 0 | IN   | GPIO. 6 | 6   | 25  |
 |  11 |  14 |    SCLK |   IN | 0 | 23 || 24 | 1 | IN   | CE0     | 10  | 8   |
 |     |     |      0v |      |   | 25 || 26 | 1 | IN   | CE1     | 11  | 7   |
 |   0 |  30 |   SDA.0 |   IN | 0 | 27 || 28 | 1 | IN   | SCL.0   | 31  | 1   |
 |   5 |  21 | GPIO.21 |   IN | 1 | 29 || 30 |   |      | 0v      |     |     |
 |   6 |  22 | GPIO.22 |   IN | 0 | 31 || 32 | 1 | IN   | GPIO.26 | 26  | 12  |
 |  13 |  23 | GPIO.23 |   IN | 0 | 33 || 34 |   |      | 0v      |     |     |
 |  19 |  24 | GPIO.24 |   IN | 0 | 35 || 36 | 0 | IN   | GPIO.27 | 27  | 16  |
 |  26 |  25 | GPIO.25 |   IN | 1 | 37 || 38 | 0 | IN   | GPIO.28 | 28  | 20  |
 |     |     |      0v |      |   | 39 || 40 | 0 | IN   | GPIO.29 | 29  | 21  |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+

dmesg的输出:

3.235940] input: AD7879 Touchscreen as /devices/platform/soc/3f804000.i2c/i2c-1/1-002c/input/input0

vcdbg日志消息的输出(在调试模式下):

002590.952: Loaded overlay 'i2c-ad7879'
002591.011: dtdebug: Found fragment 0 (offset 36)
002596.047: dtdebug: merge_fragment(/soc/i2c@7e804000,/fragment@0/__overlay__)
002596.070: dtdebug:   +prop(#address-cells)
002596.967: dtdebug:   +prop(#size-cells)
002597.869: dtdebug:   +prop(status)
002601.245: dtdebug: merge_fragment(/soc/i2c@7e804000/ad7879@2c,/fragment@0/__overlay__/ad7879@2c)
002601.271: dtdebug:   +prop(compatible)
002602.139: dtdebug:   +prop(reg)
002603.067: dtdebug:   +prop(adi,swap-xy-axis-enable)
002604.278: dtdebug:   +prop(adi,x-plate-ohms)
002605.510: dtdebug:   +prop(adi,x-min)
002606.760: dtdebug:   +prop(adi,x-max)
002608.025: dtdebug:   +prop(adi,y-min)
002609.306: dtdebug:   +prop(adi,y.max)
002610.619: dtdebug:   +prop(adi,pressure-min)
002611.927: dtdebug:   +prop(adi,pressure-max)
002613.257: dtdebug:   +prop(adi,pen-down-acquisition-interval)
002614.601: dtdebug:   +prop(adi,first-conversion-delay)
002615.968: dtdebug:   +prop(adi,acquisition-time)
002617.359: dtdebug:   +prop(adi,averaging)
002618.773: dtdebug:   +prop(adi,median)
002620.213: dtdebug:   +prop(interrupts)
002621.325: dtdebug:   +prop(interrupt-parent)
002622.386: dtdebug:   +prop(status)
002623.509: dtdebug:   +prop(linux,phandle)
002624.646: dtdebug:   +prop(phandle)
002625.820: dtdebug: merge_fragment() end
002625.867: dtdebug: merge_fragment() end
002626.003: dtdebug: delete_node(/hat)

i2cdetect -y 1的输出:

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: 60 -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                        

lsmod的输出:

Module                  Size  Used by
cfg80211              420690  0 
rfkill                 16659  1 cfg80211
i2c_dev                 6047  0 
snd_bcm2835            19769  0 
snd_pcm                74825  1 snd_bcm2835
snd_seq                53561  0 
snd_seq_device          3650  1 snd_seq
snd_timer              18157  2 snd_pcm,snd_seq
snd                    52116  5 snd_bcm2835,snd_timer,snd_pcm,snd_seq,snd_seq_device
evdev                  10216  1 
joydev                  9047  0 
ad7879_i2c              1525  0 
ad7879                  5379  1 ad7879_i2c
rtc_abx80x              3247  0 
i2c_bcm2708             5014  0 
bcm2835_gpiomem         3023  0 
uio_pdrv_genirq         2966  0 
uio                     8235  1 uio_pdrv_genirq

覆盖设备树的源文件i2c-ad7879-overlay.dts:

// Definition for I2C based Touch screen ad7879
/dts-v1/;
/plugin/;

/ {
    compatible = "brcm,bcm2708";

    fragment@0 {
            target = <&i2c_arm>;
            __overlay__ {
                    #address-cells = <1>;
                    #size-cells = <0>;
                    status = "okay";

                    ad7879: ad7879@2c {
                            compatible = "adi,ad7879";
                            reg = <0x2c>;

                            adi,swap-xy-axis-enable = <0>;
                            adi,x-plate-ohms = <620>;
                            adi,x-min = <0>;
                            adi,x-max = <4000>;
                            adi,y-min = <0>;
                            adi,y-max = <4000>;
                            adi,pressure-min = <0>;
                            adi,pressure-max = <10000>;

                            interrupts = <26 2>;  /* falling edge */
                            interrupt-parent = <&gpio>;

                            status = "okay";
                    };
            };
      };
};

evtest / dev / input / touchscreen的输出:

Input driver version is 1.0.1
Input device ID: bus 0x18 vendor 0x0 product 0x79 version 0x3
Input device name: "AD7879 Touchscreen"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 330 (BTN_TOUCH)
  Event type 3 (EV_ABS)
    Event code 0 (ABS_X)
      Value    286
      Min        0
      Max     4095
    Event code 1 (ABS_Y)
      Value   2729
      Min        0
      Max     4095
    Event code 24 (ABS_PRESSURE)
      Value      0
      Min        0
      Max        0
Properties:
Testing ... (interrupt to exit)

你有这个工作吗?如果是这样,您能给我发送设备树吗?如果不是,您是否需要同舟共济的人的帮助?我有建议,它们可能没有任何好处。如果您已经使用过,我不希望发送给他们。鲍勃
鲍勃·克鲁斯2015年

Answers:


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.