[Qualcomm]8X16 's TP notes

Source: Internet
Author: User
Tags reset

TP Touch screen, should be the driver in the development of relatively simple and suitable for beginners to start the module. However, although simple, but related to the content is more, among them the main mechanism of Linux:

1. Input mechanism

2. Interrupts, timers

3. I²c

1.TP principle: TP is generally capacitive or resistive screen, but now is basically capacitive screen, some wince devices may also use resistive screen, but the basic Android is now a capacitive screen, and multi-touch and glove touch are integrated in the TP IC. When the user touches the capacitive screen, due to the human field, the user's finger and the working face form a coupling capacitance, because the work surface is connected with high-frequency signal, so the finger absorbs a very small current, the current from the screen of the four angle of the electrode outflow, and theoretically through the four electrodes of the distance between the fingers to the square, The controller obtains the position by the precise calculation of four current ratios. Up to 99% accuracy, with a response speed of less than 3ms. In the actual product, when the screen sensor touch or close to the finger, it will produce an external interrupt to the CPU, in the interrupt, the general interrupt the lower half, through the I²c bus, from the TP IC to read the relevant information, after certain data processing, reported x, Y coordinate values.

2.linux input mechanism:

The Linux input subsystem (subsystem) is implemented from top to bottom by three layers: input subsystem Event processing layer (EventHandler), input subsystem core layer (Inputcore), and input subsystem device driver layer.

For the input subsystem device driver layer, the main implementation of the hardware device read and write access, interrupt settings, and the hardware-generated events into the core layer defined by the specification submitted to the event processing layer . (What the engineer mainly does)

For the core layer, specifications and interfaces are provided for the device driver layer. As long as the device driver is concerned with how to drive the hardware and obtain the hardware data (such as the pressed key data), and then call the interface provided by the core layer, the core layer will automatically submit the data to the event processing layer.

For the event processing layer, it is the user-programmed interface (the device node) and handles the data processing of the drive-level submissions.

3. Interrupts

Interrupts are when the CPU is running normally, due to internal or external events or events scheduled by the program, the CPU temporarily stops the running program, in turn, to the inside or outside event or pre-scheduled event Service program, and then return to continue to run the program is temporarily interrupted. Linux is usually divided into external interrupts (also called hardware interrupts) and internal interrupts (also known as exceptions).

The Linux interrupt is divided into two halves: the top half (tophalf) and the lower half (bottom half). The function of the upper part is "register Interrupt", when an interrupt occurs, it performs the corresponding hardware read and write, and then hangs the lower half of the interrupt routine into the lower half of the device execution queue. As a result, the top half executes quickly and can serve more interrupt requests. However, only a "registration interruption" is not enough, because an interrupted event can be complex. As a result, Linux introduces a lower half to complete the most mission of interrupting events. The biggest difference between the lower half and the upper half is that the lower half is interruptible, the upper half is non-interruptible, the lower half does almost everything that interrupts the handler, and can be interrupted by a new interrupt. The lower half is relatively less urgent and usually time-consuming, so the system runs its own schedule and does not execute in the context of the interrupt service.

4. Timers

Two devices are clocked: the system timer and the real-time clock.

Real-time Clock (RTC): A device used to persist system time, even when the system is turned off, to provide power-holding system timing by a miniature battery on the motherboard. The system boot kernel initializes the wall time by reading the RTC, and the time is stored in the Xtime variable.

System timers: Kernel timing mechanism, register interrupt handlers, periodically trigger interrupts, respond to interrupt handlers, and perform the following tasks:

5. I²c protocol

2 bidirectional serial line, one data line SDA, one clock line SCL.

SDA transmission data is a big-endian transmission, each transmission 8bit, that is, one byte.
Supports multi-master (multimastering), which can only have one master at any point in time.
Each device on the bus has its own addr, a total of 7 bit, broadcast address 0.
The system may have a plurality of the same chip, for this addr is divided into fixed parts and programmable parts, details depending on the chip, see datasheet.

The main talk about the TP-related knowledge points, this is mainly, you have a basic concept of this module, know its working principle, so in the actual development process, you know how to write the driver, encountered problems, where the piece, how to solve.

This article, mainly according to the code to refer to the relevant mechanism of the previous article. TP line is very simple, all the way, a broken wire, VCC, Gnd,reset.

1. TP Main related demo:

Drive DEMO:\KERNEL\DRIVERS\INPUT\TOUCHSCREEN\FT5X06_TS.C

\kernel\drivers\input\touchscreen\ft5x06_ts.h

DTSi file: \kernel\arch\arm\boot\dts\qcom\msm8x16-qrd.dtsi

2. Explanation of DTSi

i2c@f9923000{//TP connected to the I²C register
focaltech@38{
compatible = "focaltech,5x06"; The content of the match is driven by i²c
Reg = <0x38>; I²c Address
Interrupt-parent = <&msmgpio>; Interrupt Pin
Interrupts = <1 0x2>;
Vdd-supply = <&pm8110_l19>; I²c-powered movie control
Vcc_i2c-supply = <&pm8110_l14>;
Focaltech,name = "ft6x06"; TP type
Focaltech,family-id = <0x06>;
Focaltech,reset-gpio = <&msmgpio 0 0x00>; Reset PIN, for initializing timing
Focaltech,irq-gpio = <&msmgpio 1 0x00>; Interrupt Pin
Focaltech,display-coords = <0 0 480 800>; Contact range of TP
Focaltech,panel-coords = <0 0 480 800>;
focaltech,button-map= <139 102 158>; Virtual keys
Focaltech,no-force-update;
focaltech,i2c-pull-up;
Focaltech,group-id = <1>;
Focaltech,hard-reset-delay-ms = <20>;
Focaltech,soft-reset-delay-ms = <150>;
Focaltech,num-max-touches = <2>;
Focaltech,fw-name = "Ft_8610_qrd_fw.bin"; TP Firmware
Focaltech,fw-delay-aa-ms = <100>;
Focaltech,fw-delay-55-ms = <30>;
FOCALTECH,FW-UPGRADE-ID1 = <0x79>;
Focaltech,fw-upgrade-id2 = <0x08>;
Focaltech,fw-delay-readid-ms = <10>;
Focaltech,fw-delay-era-flsh-ms = <2000>;
};
};

3. Driver files

3.1 I²c Driver Registration

static int __init ft5x06_ts_init (void)
{
Pr_err ("Start \ n");
Return I2c_add_driver (&ft5x06_ts_driver); I²c Driver Registration
Pr_err ("End \ n");
}

The 3.2 file interface, of_match_table, needs to be consistent in the definition of compatible in DTSi.

static struct I2c_driver Ft5x06_ts_driver = {
. Probe = Ft5x06_ts_probe,
. remove = Ft5x06_ts_remove,
. Driver = {
. Name = "Ft5x06_ts",
. Owner = This_module,
. of_match_table = Ft5x06_match_tabl
#ifdef CONFIG_PM
. PM = &ft5x06_ts_pm_ops,
#endif
},
. id_table = ft5x06_ts_id,
};

3.3 probe

This is too much code, it is not detailed one by one, here is mainly to explain some basic steps.

In general, the relevant structure of the allocation of storage space, and then from the DT device tree to read the relevant information to test whether the I²c pass.

Input_dev = Input_allocate_device ();//Allocate input subsystem

Data->input_dev = Input_dev;
data->client = client;
Data->pdata = pdata;
Input_dev->name = "Ft5x06_ts";
Input_dev->id.bustype = BUS_I2C;
Input_dev->dev.parent = &client->dev;
Input_set_drvdata (Input_dev, data);
I2c_set_clientdata (client, data);
__set_bit (Ev_key, input_dev->evbit); Set what event key event TP virtual key
__set_bit (Ev_abs, input_dev->evbit); Absolute Events
__set_bit (Btn_touch, input_dev->keybit);
__set_bit (Input_prop_direct, input_dev->propbit);
Input_mt_init_slots (Input_dev, pdata->num_max_touches, 0);
Input_set_abs_params (Input_dev, abs_mt_position_x, pdata->x_min,//x coordinate events
Pdata->x_max, 0, 0);
Input_set_abs_params (Input_dev, abs_mt_position_y, pdata->y_min,//y coordinate events
Pdata->y_max, 0, 0);

Ft5x06_power_init (data, true); Power supply, GPIO-related initialization

FT5X06_POWER_ON (data, true); Power-on, timing initialization

Err = REQUEST_THREADED_IRQ (CLIENT->IRQ, Null,ft5x06_ts_interrupt,irqf_oneshot,
Client->dev.driver->name, data); The request is interrupted and the event processing is placed in the lower part.

Psensor_input_dev = Input_allocate_device (); Assigning sub-input devices

Err = Input_register_device (Psensor_input_dev);

Ft5x06_update_fw_ver (data); Import firmware Information
FT5X06_UPDATE_FW_VENDOR_ID (data); Get Firmware Version ID


3.4 Interrupt Handler Ft5x06_ts_interrupt

static irqreturn_t ft5x06_ts_interrupt (int irq, void *dev_id)

This is mainly read in, according to the chip manual, data out, and then report the incident.

Input_report_abs (Ip_dev, abs_mt_position_x, X);
Input_report_abs (Ip_dev, abs_mt_position_y, Y);

Input_sync (Ip_dev);

of course some TP, such as GT9XXXX, will apply for a work queue, then interrupt generation will be in the top half, start the work queue, and then block the current interrupt after the Work queue event has been processed and enabled to be interrupted. Some also when an interrupt request fails, request a high-precision timer that will always poll the startup worker thread to escalate the event.


4. Debugging related Experience

4.1 General TP Drive development, screen production will give driver code or patch, then the main code in.

Generally find the code within the existing one TP drive, according to its Add. Main:

1. Put the driver file into the kernel\drivers\input\touchscreen\,

2. Modify the Kconfig and makefile, add the need to be based on the macro to be compiled, then you need to set the Deconfig in the configuration file to Y.

3. Add the configuration of the TP in the DTSi.


4.2 Compile boot, under out/target/product/msmxxx/obj/kernel_obj/driver/input/touchscreen/, see if there is an. o file, and the compilation is successful.

4.3 Brush The new boot file into the board and look at the kernel Log,cat proc/kmsg to see if there is any print information for the TP driver.

4.4 According to the printing information, determine the problem of error.

General problem, interrupt registration is not on, resource allocation is not successful, i²c device communication failed.

Some experience, the I²c bus is not through, it may be because the power supply is not power supply, or the bus hangs on the device too much influence, the early tuning is best on the I²c bus, only one device is hung.

If the probe succeeds, you can add some print logs to the interrupt or worker thread. In the ADB shell into the terminal, enter GetEvent, Hand press TP, see if there is data out, for the TP input device.


5. View the I²C device:

ROOT@ANDROID:/SYS/BUS/I2C # CD Devices
CD devices
Root@android:/sys/bus/i2c/devices # ls
Ls
0-0020
0-0022
0-0036
0-0078
1-000c
1-000d
1-001d
1-0028
1-0029
1-002a
1-0038
1-0060
1-0068
2-001c
i2c-0
I2c-1
I2c-2
Root@android:/sys/bus/i2c/devices # CD 0-0036
CD 0-0036
root@android:/sys/bus/i2c/devices/0-0036 # ls
Ls
Driver
Modalias
Name
Power
Subsystem
Uevent
root@android:/sys/bus/i2c/devices/0-0036 # cat Name
Cat Name
Msm_actuator
root@android:/sys/bus/i2c/devices/0-0036 #



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.