AD7873
AD7873 Input Touch Screen Digitizer Linux Driver.
Supported Devices
Description
The AD7843/AD7873 is a 12-bit successive-approximation ADC with a synchronous serial interface and low on resistance switches for driving touch screens. The parts operates from a single 2.2 V to 5.25 V power supply and features throughput rates greater than 125 kSPS. The external reference applied to the AD7843 can be varied from 1 V to +VCC, while the analog input range is from 0 V to VREF. The device includes a shutdown mode that reduces the current consumption to less than 1 µA.
The AD7873 is similar to the AD7843 but has added functionality such as an on-chip temperature sensor (-40°C to + 85°C), on-chip 2.5 V reference and direct battery and touch-pressure measurement.
See also: AD7877 See also: AD7879
Driver features and limitations
Configuration
Source Code
Status
Files
Function |
File |
|---|---|
driver |
|
include |
Adding Linux driver support
Kernel configuration
Configure kernel with make menuconfig (alternatively use make xconfig or
make qconfig)
Note
The AD7873 driver depends on CONFIG_SPI.
Input device support
-*- Generic input layer (needed for keyboard, mouse, ...)
< > Support for memoryless force-feedback devices
< > Polled input device skeleton
< > Sparse keymap support library
*** Userland interfaces ***
< > Mouse interface
< > Joystick interface
<*> Event interface
< > Event debugging
*** Input Device Drivers ***
[ ] Keyboards --->
[ ] Mice --->
[ ] Joysticks/Gamepads --->
[ ] Tablets --->
[*] Touchscreens --->
--- Touchscreens
<*> ADS7846/TSC2046/AD7873 and AD(S)7843 based touchscreens (NEW)
< > AD7877 based touchscreens
< > Analog Devices AD7879-1/AD7889-1 touchscreen interface (NEW)
[ ] Miscellaneous devices --->
Hardware I/O ports --->
Driver compiled as a module
root:~> modprobe evdev
root:~> modprobe ads7846
ads7846 spi0.18: touchscreen, irq 56
input: ADS7873 Touchscreen as /devices/platform/bfin-spi.0/spi0.18/input/input0
Driver compiled into the kernel
Your kernel startup messages should include something like this
ads7846 spi0.18: touchscreen, irq 56
input: ADS7873 Touchscreen as /devices/platform/bfin-spi.0/spi0.18/input/input0
Platform-data configuration
Example platform device initialization
For compile time configuration, it’s common Linux practice to keep board- and application-specific configuration out of the main driver file, instead putting it into the board support file.
For devices on custom boards, as typical of embedded and SoC-(system-on-chip)
based hardware, Linux uses platform_data to point to board-specific structures
describing devices and how they are connected to the SoC. This can include
available ports, chip variants, preferred modes, default initialization,
additional pin roles, and so on. This shrinks the board-support packages (BSPs)
and minimizes board and application specific #ifdefs in drivers.
AD7873 and AD7843 are handled by the shared ads7846 driver. The
devicetree compatible string selects the model: ti,ads7873 for the
AD7873, ti,ads7843 for the AD7843 (the driver also supports
ti,ads7846, ti,ads7845 and ti,tsc2046 for the related TI parts).
Required devicetree properties are compatible and reg. The PENIRQ
line is described with interrupts and pendown-gpio. Optional properties include the vcc
regulator supply, ti,x-plate-ohms, ti,debounce-rep,
ti,debounce-tol, ti,settle-delay-usec and touchscreen-swapped-x-y.
&spi0 {
#address-cells = <1>;
#size-cells = <0>;
touchscreen@0 {
compatible = "ti,ads7873";
reg = <0>;
spi-max-frequency = <2000000>;
interrupt-parent = <&gpio1>;
interrupts = <6 IRQ_TYPE_EDGE_FALLING>;
pendown-gpio = <&gpio1 6 GPIO_ACTIVE_LOW>;
vcc-supply = <&vcc>;
ti,x-plate-ohms = /bits/ 16 <620>;
};
};
Driver testing
Identify the device
After the kernel boot your device folder should include at least one device node for the touchscreen
root:/> ls -al /dev/input/
drw-r--r-- 2 root root 0 Jan 1 00:03 .
drwxr-xr-x 5 root root 0 Jan 1 00:03 ..
crw-rw-r-- 1 root root 13, 64 Jan 1 00:03 event0
root:/>
Check that the interrupt is registered.
root:~> cat /proc/interrupts | grep ads7846
56: 16 GPIO ads7846
root:~> cat /sys/class/input/input0/name
ADS7873 Touchscreen
Use the event_test utility to test proper function
root:/> event_test /dev/input/event0
Input driver version is 1.0.0
Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0
Input device name: "ADS7873 Touchscreen"
Supported events:
Event type 0 (Reset)
Event code 0 (Reset)
Event code 1 (Key)
Event code 3 (Absolute)
Event type 1 (Key)
Event type 3 (Absolute)
Event code 0 (X)
Value 760
Min 0
Max 4095
Event code 1 (Y)
Value 1973
Min 0
Max 4095
Event code 24 (Pressure)
Value 0
Min 0
Max 0
Testing ... (interrupt to exit)
Event: time 258292.823196, type 1 (Key), code 330 (Touch), value 1
Event: time 258292.823209, type 3 (Absolute), code 0 (X), value 776
Event: time 258292.823214, type 3 (Absolute), code 1 (Y), value 505
Event: time 258292.823220, type 3 (Absolute), code 24 (Pressure), value 491
Event: time 258292.823225, type 0 (Reset), code 0 (Reset), value 0
Event: time 258292.828643, type 3 (Absolute), code 0 (X), value 789
Event: time 258292.828653, type 3 (Absolute), code 1 (Y), value 489
Event: time 258292.828659, type 3 (Absolute), code 24 (Pressure), value 485
Event: time 258292.828664, type 0 (Reset), code 0 (Reset), value 0
Event: time 258292.834085, type 3 (Absolute), code 0 (X), value 790
Event: time 258292.834095, type 3 (Absolute), code 1 (Y), value 499
Event: time 258292.834101, type 3 (Absolute), code 24 (Pressure), value 482
Event: time 258292.834106, type 0 (Reset), code 0 (Reset), value 0
Event: time 258292.839527, type 3 (Absolute), code 0 (X), value 789
Event: time 258292.839538, type 3 (Absolute), code 1 (Y), value 502
Event: time 258292.839544, type 3 (Absolute), code 24 (Pressure), value 481
Event: time 258292.839549, type 0 (Reset), code 0 (Reset), value 0
Tip
In case you touch the surface and don’t receive events, it’s likely that something with your /PENIRQ Interrupt is wrong. Check the IRQ and pendown-gpio in the devicetree node.