Ilitek touchscreen - i2c issue in threaded IRQ-handler

Hello,

i’m working on getting a touchscreen with an Ilitek-2132 controller running with the Jetson Nano production module.

For that, I backportet the touchscreen driver module ilitek_ts_i2c (attached) to the tegra-kernel4.9 provided with L4T_32.7.2 and enabled the touchscreen in the devicetree as follows:


touchscreen_i2c0: i2c@7000c000 {
	touchscreen@41 {
		compatible = "ilitek,ili2132";
		reg = <0x41>;
		interrupt-parent = <&gpio>;
		interrupts = <&gpio TEGRA_GPIO(CC, 0) IRQ_TYPE_LEVEL_LOW>;
		reset-gpios = <&gpio TEGRA_GPIO(CC, 6) GPIO_ACTIVE_LOW>;
		touchscreen-inverted-y;
		wakeup-source;
	};
};

The driver module initializes correctly as far as i can tell from the added debug statements. But the i2c read during the interrupt handler fails to get any data, the irq-handler fails and the cpu crashes.

When i run the i2c commands, that the driver issues from a python script, i am able to read touchcontroller data.

Do you have any hints regarding special requirements for i2c communication from an ISR on the Tegra X1, or on how to find the root-cause for the crash?


[ 500.293687] ilitek_ts_i2c: (ilitek_ts_i2c_probe): --enter probe–
[ 501.310083] ilitek_ts_i2c: (ilitek_protocol_init): --enter–
[ 501.315875] ilitek_ts_i2c: (api_protocol_set_cmd): --enter–
[ 501.321729] ilitek_ts_i2c: (ilitek_i2c_write_and_read): addr:0x41 cmd:0x42 w_len:1 r_len:3
[ 501.335310] ilitek_ts_i2c: (ilitek_read_tp_info): --enter–
[ 501.341091] ilitek_ts_i2c: (api_protocol_set_cmd): --enter–
[ 501.347529] ilitek_ts_i2c: (ilitek_i2c_write_and_read): addr:0x41 cmd:0x42 w_len:1 r_len:3
[ 501.361903] ilitek_ts_i2c: (api_protocol_set_cmd): --enter–
[ 501.367709] ilitek_ts_i2c: (ilitek_i2c_write_and_read): addr:0x41 cmd:0x61 w_len:1 r_len:32
[ 501.382035] ilitek_ts_i2c: (api_protocol_set_cmd): --enter–
[ 501.388067] ilitek_ts_i2c: (ilitek_i2c_write_and_read): addr:0x41 cmd:0x40 w_len:1 r_len:8
[ 501.403804] ilitek_ts_i2c: (api_protocol_set_cmd): --enter–
[ 501.409532] ilitek_ts_i2c: (ilitek_i2c_write_and_read): addr:0x41 cmd:0x21 w_len:1 r_len:8
[ 501.423293] ilitek_ts_i2c: (api_protocol_set_cmd): --enter–
[ 501.428999] ilitek_ts_i2c: (ilitek_i2c_write_and_read): addr:0x41 cmd:0x20 w_len:1 r_len:15
[ 501.444089] ilitek_ts_i2c: (api_protocol_set_cmd): --enter–
[ 501.449899] ilitek_ts_i2c: (ilitek_i2c_write_and_read): addr:0x41 cmd:0xc0 w_len:1 r_len:2
[ 501.463502] ilitek_ts_i2c: (ilitek_input_dev_init): --enter–
[ 501.469781] ilitek_ts_i2c: (ilitek_ts_i2c_probe): ilitek reg irq: 189
[ 501.476978] ilitek_ts_i2c: (ilitek_i2c_isr): --enter isr irq:189 –
[ 501.483308] ilitek_ts_i2c: (ilitek_process_and_report_v6): --process_and_report–
[ 501.490846] ilitek_ts_i2c: (ilitek_process_and_report_v6): #1
[ 501.496632] ilitek_ts_i2c: (ilitek_i2c_write_and_read): addr:0x41 cmd:0x0 w_len:0 r_len:64
[ 502.814642] irq 189: nobody cared (try booting with the “irqpoll” option)
[ 502.822801] handlers:
[ 502.825217] [] irq_default_primary_handler threaded [] ilitek_i2c_isr [ilitek_ts_i2c]
[ 502.836741] Disabling IRQ #189
[ 511.611291] tegra-i2c 7000d000.i2c: pio timed out addr: 0x3c tlen:28 rlen:4
[ 511.615216] tegra-i2c 7000c000.i2c: rx dma timeout txlen:12 rxlen:64
[ 511.615236] tegra-i2c 7000c000.i2c: — register dump for debugging ----
[ 511.615255] tegra-i2c 7000c000.i2c: I2C_CNFG - 0x22c00
[ 511.615273] tegra-i2c 7000c000.i2c: I2C_PACKET_TRANSFER_STATUS - 0x1010001
[ 511.615291] tegra-i2c 7000c000.i2c: I2C_FIFO_CONTROL - 0x1c
[ 511.615308] tegra-i2c 7000c000.i2c: I2C_FIFO_STATUS - 0x800080
[ 511.615325] tegra-i2c 7000c000.i2c: I2C_INT_MASK - 0x6c
[ 511.615340] tegra-i2c 7000c000.i2c: I2C_INT_STATUS - 0xc2
[ 511.615396] tegra-i2c 7000c000.i2c: i2c transfer timed out addr: 0x41
[ 511.615482] ilitek_ts_i2c: (ilitek_i2c_write_and_read): i2c_transfer #3 error=-110
[ 511.615505] ilitek_ts 0-0041: get touch info failed, err:-110
[ 511.615557] ilitek_ts 0-0041: [ilitek_i2c_isr] err:-110
[ 511.615582] ilitek_ts_i2c: (ilitek_i2c_isr): --enter isr irq:189 –
[ 511.615593] ilitek_ts_i2c: (ilitek_process_and_report_v6): --process_and_report–
[ 511.615601] ilitek_ts_i2c: (ilitek_process_and_report_v6): #1
[ 511.615617] ilitek_ts_i2c: (ilitek_i2c_write_and_read): addr:0x41 cmd:0x0 w_len:0 r_len:64
[ 511.723257] tegra-i2c 7000d000.i2c: — register dump for debugging ----
[ 511.730384] tegra-i2c 7000d000.i2c: I2C_CNFG - 0x22c00
[ 511.735862] tegra-i2c 7000d000.i2c: I2C_PACKET_TRANSFER_STATUS - 0x1010001
[ 511.743149] tegra-i2c 7000d000.i2c: I2C_FIFO_CONTROL - 0xe0
[ 511.749055] tegra-i2c 7000d000.i2c: I2C_FIFO_STATUS - 0x800081
[ 511.755286] tegra-i2c 7000d000.i2c: I2C_INT_MASK - 0x7d
[ 511.760860] tegra-i2c 7000d000.i2c: I2C_INT_STATUS - 0xc3
[ 511.766595] tegra-i2c 7000d000.i2c: i2c transfer timed out addr: 0x3c
[ 521.851278] tegra-i2c 7000c000.i2c: rx dma timeout txlen:12 rxlen:64
[ 521.855206] tegra-i2c 7000d000.i2c: pio timed out addr: 0x3c tlen:28 rlen:4
[ 521.855225] tegra-i2c 7000d000.i2c: — register dump for debugging ----
[ 521.855245] tegra-i2c 7000d000.i2c: I2C_CNFG - 0x22c00
[ 521.855263] tegra-i2c 7000d000.i2c: I2C_PACKET_TRANSFER_STATUS - 0x1010001
[ 521.855280] tegra-i2c 7000d000.i2c: I2C_FIFO_CONTROL - 0xe0
[ 521.855296] tegra-i2c 7000d000.i2c: I2C_FIFO_STATUS - 0x800081
[ 521.855314] tegra-i2c 7000d000.i2c: I2C_INT_MASK - 0x7d
[ 521.855329] tegra-i2c 7000d000.i2c: I2C_INT_STATUS - 0xc3
[ 521.855349] tegra-i2c 7000d000.i2c: i2c transfer timed out addr: 0x3c
[ 521.855472] Failed to set dvfs regulator vdd-core
[ 522.062198] tegra-i2c 7000c000.i2c: — register dump for debugging ----
[ 522.083269] tegra-i2c 7000c000.i2c: I2C_CNFG - 0x22c00
[ 522.102636] tegra-i2c 7000c000.i2c: I2C_PACKET_TRANSFER_STATUS - 0x1010001
[ 522.123809] tegra-i2c 7000c000.i2c: I2C_FIFO_CONTROL - 0x1c
[ 522.143467] tegra-i2c 7000c000.i2c: I2C_FIFO_STATUS - 0x800080
[ 522.163239] tegra-i2c 7000c000.i2c: I2C_INT_MASK - 0x6c
[ 522.182130] tegra-i2c 7000c000.i2c: I2C_INT_STATUS - 0xc2
[ 522.201079] tegra-i2c 7000c000.i2c: i2c transfer timed out addr: 0x41
[ 522.221019] ilitek_ts_i2c: (ilitek_i2c_write_and_read): i2c_transfer #3 error=-110
[ 522.242124] ilitek_ts 0-0041: get touch info failed, err:-110
[ 522.261647] ilitek_ts 0-0041: [ilitek_i2c_isr] err:-110
[ 522.482856] INFO: rcu_preempt detected stalls on CPUs/tasks:
[ 522.502059] 0-…: (1 GPs behind) idle=b09/140000000000001/0 softirq=31957/31958 fqs=2469
[ 522.523866] (detected by 2, t=5262 jiffies, g=8586, c=8585, q=10256)
[ 523.239082] INFO: rcu_sched detected stalls on CPUs/tasks:
[ 523.258117] 0-…: (1 GPs behind) idle=b09/140000000000001/0 softirq=31936/31958 fqs=2491
[ 523.280099] (detected by 3, t=5252 jiffies, g=3800, c=3799, q=699)
[ 528.343043] Kernel panic - not syncing: Watchdog detected hard LOCKUP on cpu 0
[ 528.364208] CPU: 3 PID: 0 Comm: swapper/3 Not tainted 4.9.253-tegra #10
[ 528.384710] Hardware name: Anvajo FL2_CBv2 (DT)
[ 528.403035] Call trace:
[ 528.419238] [] dump_backtrace+0x0/0x1a0
[ 528.438424] [] show_stack+0x24/0x30
[ 528.457140] [] dump_stack+0xa0/0xc4
[ 528.475740] [] panic+0x124/0x29c
[ 528.493926] [] watchdog_check_hardlockup_other_cpu+0x11c/0x120
[ 528.514803] [] watchdog_timer_fn+0x98/0x2c0
[ 528.533922] [] __hrtimer_run_queues+0xd8/0x360
[ 528.553224] [] hrtimer_interrupt+0xa8/0x1e0
[ 528.572142] [] tegra210_timer_isr+0x38/0x48
[ 528.590970] [] __handle_irq_event_percpu+0x68/0x288
[ 528.610438] [] handle_irq_event_percpu+0x28/0x60
[ 528.629595] [] handle_irq_event+0x50/0x80
[ 528.648014] [] handle_fasteoi_irq+0xd4/0x1c0
[ 528.666703] [] generic_handle_irq+0x34/0x50
[ 528.685279] [] __handle_domain_irq+0x68/0xc0
[ 528.703924] [] gic_handle_irq+0x5c/0xb0
[ 528.722142] [] el1_irq+0xe8/0x194
[ 528.739742] [] cpuidle_enter_state+0xb8/0x380
[ 528.758239] [] cpuidle_enter+0x34/0x48
[ 528.775986] [] call_cpuidle+0x44/0x70
[ 528.793486] [] cpu_startup_entry+0x1b0/0x200
[ 528.811425] [] secondary_start_kernel+0x190/0x1f8
[ 528.829834] [<0000000080f7c1a8>] 0x80f7c1a8
[ 528.846049] SMP: stopping secondary CPUs
[ 528.862225] Kernel Offset: disabled
[ 528.877721] Memory Limit: none
[ 528.937451] —[ end Kernel panic - not syncing: Watchdog detected hard LOCKUP on cpu 0


ilitek_ts_i2c.c (16.1 KB)

Best regards,
Johannes

hello johannes4422,

you may resolve i2c transfer timed out issue, which usually caused by regulator settings did not provide to this device.

Hello Jerry,

as the i2c communication is generally working - only not in the irq-handler - the regulators are not related to this issue.

→ I found the root cause:
My interrupt definition for the touchscreen in the device-tree section was wrong: it should contain only 2 values like:
interrupts = <TEGRA_GPIO(CC, 0) IRQ_TYPE_LEVEL_LOW>;

Thanks for the effort - layer 8 error :)

Best regards,
Johannes