DRV_06_I2C接口觸摸屏驅(qū)動(dòng)分析

資料下載

由于無法通過瀏覽器直接訪問coding,您需要使用git工具進(jìn)行下載:

git clone https://e.coding.net/weidongshan/linux/doc_and_source_for_drivers.git

視頻觀看

您可以觀看百問網(wǎng)的驅(qū)動(dòng)大全視頻。

I2C接口觸摸屏驅(qū)動(dòng)分析參考資料

  • Linux 5.x內(nèi)核

    • Documentationdevicetreebindingsinputtouchscreengoodix.txt
    • drivers/input/touchscreen/goodix.c
  • Linux 4.x內(nèi)核

    • Documentationdevicetreebindingsinputtouchscreengoodix.txt
    • drivers/input/touchscreen/gt9xx/gt9xx.c
  • 設(shè)備樹

    • IMX6ULL:Linux-4.9.88/arch/arm/boot/dts/100ask_imx6ull-14×14.dts
    • STM32MP157:Linux-5.4/arch/arm/boot/dts/stm32mp15xx-100ask.dtsi

驅(qū)動(dòng)程序框架

DRV_06_I2C接口觸摸屏驅(qū)動(dòng)分析

設(shè)備樹示例

設(shè)備樹講解示例

作為一個(gè)I2C設(shè)備,在某個(gè)I2C控制器節(jié)點(diǎn)下創(chuàng)建一個(gè)子節(jié)點(diǎn)。屬性包括:

  • 必備,根據(jù)這個(gè)屬性找到驅(qū)動(dòng)程序:compatible = “xxxx”;
  • 必備,I2C設(shè)備地址:reg = ;
  • 可選:中斷、復(fù)位引腳
i2c@00000000 {/* ... */gt928@5d {compatible = "goodix,gt928";reg = ;interrupt-parent = ;interrupts = ;irq-gpios = ;reset-gpios = ;};/* ... */};

100ASK_IMX6ULL

&i2c2 {gt9xx@5d {compatible = "goodix,gt9xx";reg = ;status = "okay";interrupt-parent = ;interrupts = ;pinctrl-names = "default";pinctrl-0 = ;/*pinctrl-1 = ;*//* pinctrl-names = "default", "int-output-low", "int-output-high", "int-input"; pinctrl-0 = ; pinctrl-1 = ; pinctrl-2 = ; pinctrl-3 = ;*/reset-gpios = ;irq-gpios = ;irq-flags = ;                /*1:rising 2: falling*/touchscreen-max-id = ;touchscreen-size-x = ;touchscreen-size-y = ;touchscreen-max-w = ;touchscreen-max-p = ;/*touchscreen-key-map = , ;*/ /*KEY_HOMEPAGE, KEY_BACK*/goodix,type-a-report = ;goodix,driver-send-cfg = ;goodix,create-wr-node = ;goodix,wakeup-with-reset = ;goodix,resume-in-workqueue = ;goodix,int-sync = ;goodix,swap-x2y = ;goodix,esd-protect = ;goodix,pen-suppress-finger = ;goodix,auto-update = ;goodix,auto-update-cfg = ;goodix,power-off-sleep = ;/* ...... */};};

100ASK_STM32MP157

&i2c4 {    gt911@5d {compatible = "goodix,gt928";reg = ;interrupt-parent = ;interrupts = ;reset-gpios = ;irq-gpios = ;irq-flags = ;                /*1:rising 2: falling*/touchscreen-max-id = ;touchscreen-size-x = ;touchscreen-size-y = ;};};

驅(qū)動(dòng)程序分析

分配/設(shè)置/注冊(cè)input_dev

  • IMX6ULL Linux 4.x
gtp_proberet = gtp_request_input_dev(ts);ts->input_dev = input_allocate_device();......ret = input_register_device(ts->input_dev);ret = gtp_request_irq(ts);
  • STM32MP157 Linux 5.x
goodix_ts_probeerror = request_firmware_nowait(THIS_MODULE, true, ts->cfg_name,&client->dev, GFP_KERNEL, ts,goodix_config_cb);goodix_config_cbgoodix_configure_dev(ts);ts->input_dev = devm_input_allocate_device(&ts->client->dev);......error = input_register_device(ts->input_dev);error = goodix_request_irq(ts);

注冊(cè)中斷處理函數(shù)

  • IMX6ULL Linux 4.x
ret = request_threaded_irq(ts->client->irq, NULL,gtp_irq_handler,ts->pdata->irq_flags | IRQF_ONESHOT,ts->client->name,ts);
  • STM32MP157 Linux 5.x
static int goodix_request_irq(struct goodix_ts_data *ts){return devm_request_threaded_irq(&ts->client->dev, ts->client->irq, NULL, goodix_ts_irq_handler, ts->irq_flags, ts->client->name, ts);}

中斷處理函數(shù)分析

通過I2C函數(shù)讀取數(shù)據(jù)、上報(bào)數(shù)據(jù)。

  • IMX6ULL Linux 4.x
gtp_irq_handlergtp_work_func(ts);point_state = gtp_get_points(ts, points, &key_value);gtp_i2c_readi2c_transfergtp_mt_slot_report(ts, point_state & 0x0f, points);input_mt_slotinput_mt_report_slot_stateinput_report_abs
  • STM32MP157 Linux 5.x
goodix_ts_irq_handlergoodix_process_events(ts);touch_num = goodix_ts_read_input_report(ts, point_data);goodix_i2c_readi2c_transfergoodix_ts_report_touch_9binput_mt_slotinput_mt_report_slot_statetouchscreen_report_posinput_report_abs

? 版權(quán)聲明
THE END
喜歡就支持一下吧
點(diǎn)贊13 分享