How to enable ft5x_ts driver on A20?

Started by mushketer888, September 29, 2014, 06:38:58 PM

Previous topic - Next topic

mushketer888

Hi all...
How to enable ft5x_ts driver on A20?
i tried to do this by editing .fex but it doesnt change anything!
i cant see in logs that it loads this driver.
but i can see when fex sunxi can load RTP (resistive touch)
but it doesnt load CTP at all (as it seems)

when i had RTP in config i got:
[    2.169977] sun4i-ts.c: sun4i_ts_init: start ...
[    2.176092] rtp_used == 1.
[    2.182100] sun4i-ts: tp_screen_size is 5 inch.
[    2.189686] sun4i-ts: tp_regidity_level is 5.
[    2.197787] sun4i-ts: tp_press_threshold_enable is 0.
[    2.206137] sun4i-ts: rtp_sensitive_level is 15.
[    2.214199] sun4i-ts: rtp_exchange_x_y_flag is 0.
[    2.222361] sun4i-ts.c: sun4i_ts_probe: start...

and when i made rtp_used 0 and enabled ctp (ctp_used=1 etc)
it gives:
[    2.170074] sun4i-ts.c: sun4i_ts_init: start ...
[    2.176185] rtp_used == 0.
[    2.183922] sunxi-rtc sunxi-rtc: Warning: RTC time is wrong!
[    2.194851] sunxi-rtc sunxi-rtc: rtc core: registered rtc as rtc0
[    2.203449] i2c /dev entries driver

it seems as it doesnt load CTP configuration at all...

P.S. i have compiled kernel and debian image by olimex blog tutorial

dave-at-axon

I use Android and in there you have the insmod the driver on startup in the .rc fie.

The FEX only enables the driver to try to auto detect but I have found this to be less than satisfactory. Better to enable in the .rfc file.

Try to insmod the ft5x driver and see what debug shows and if this works, at it to your .rc file or whatever Linux uses to start drivers.


mushketer888

Big thanks for reply!
You mean rc.d?
How i can do this in debian?

mushketer888

I tried to insmod ft5x_ts and input appeared in /dev/input/ as event1
when i "cat" it it doesnt send anything..
so far so good

but from where it gets pin configuration? if it doesnt read .fex?
.dts?

dave-at-axon

I don't know about linux but check in the source code and it might indicate where?

mushketer888

It starts to load this module when i added ft5x_ts to /etc/modules
But now i am trying to configure it..

mushketer888

Now it gives me:

[    9.746102] ===========================ft5x_ts_init=====================
[    9.755564] ctp_fetch_sysconfig_para.
[    9.768735] ctp_fetch_sysconfig_para: after: ctp_twi_addr is 0x38, dirty_addr_buf: 0x38. dirty_addr_buf[1]: 0xfffe
[    9.783399] ctp_fetch_sysconfig_para: ctp_twi_id is 0.
[    9.793100] ctp_fetch_sysconfig_para: screen_max_x = 800.
[    9.803049] ctp_fetch_sysconfig_para: screen_max_y = 480.
[    9.812928] ctp_fetch_sysconfig_para: revert_x_flag = 0.
[    9.822688] ctp_fetch_sysconfig_para: revert_y_flag = 0.
[    9.832796] ctp_fetch_sysconfig_para: exchange_x_y_flag = 0.
[    9.846194] ft5x_ts_init: after fetch_sysconfig_para:  normal_i2c: 0x38. normal_i2c[1]: 0xfffe
[    9.860164] ctp_init_platform_resource: tp_reset request gpio fail!
[    9.871921] ctp_init_platform_resource: No power port feature present.
[    9.880014] ctp_wakeup.
[    9.945796] ctp_detect: Detected chip ft5x_ts at adapter 0, address 0x38
[    9.956609] ====ft5x_ts_probe begin=====. 
[    9.968254] input: ft5x_ts as /devices/platform/sunxi-i2c.0/i2c-0/0-0038/input/input1
[    9.980996] ctp_set_irq_mode: config gpio to int mode.
[    9.992102] ctp_set_irq_mode, 225: gpio_int_info, port = 2, port_num = 3.
[   10.000990]  INTERRUPT CONFIG
[   10.007661] IRQ handler type mismatch for IRQ 60
[   10.015076] current handler: sunxi-gpio
[   10.026503] [<c0014d74>] (unwind_backtrace+0x0/0x138) from [<c0091418>] (__setup_irq+0x384/0x3d0)
[   10.043367] [<c0091418>] (__setup_irq+0x384/0x3d0) from [<c0091514>] (request_threaded_irq+0xb0/0x140)
[   10.061716] [<c0091514>] (request_threaded_irq+0xb0/0x140) from [<bf0ba5ec>] (ft5x_ts_probe+0x294/0x470 [ft5x_ts])
[   10.080760] [<bf0ba5ec>] (ft5x_ts_probe+0x294/0x470 [ft5x_ts]) from [<c03c14f0>] (i2c_device_probe+0xcc/0x124)
[   10.099012] [<c03c14f0>] (i2c_device_probe+0xcc/0x124) from [<c03337bc>] (driver_probe_device+0xb0/0x348)
[   10.116740] [<c03337bc>] (driver_probe_device+0xb0/0x348) from [<c0331db8>] (bus_for_each_drv+0x5c/0x88)
[   10.133773] [<c0331db8>] (bus_for_each_drv+0x5c/0x88) from [<c03336a4>] (device_attach+0x88/0xa0)
[   10.150198] [<c03336a4>] (device_attach+0x88/0xa0) from [<c0332ba8>] (bus_probe_device+0x84/0xa8)
[   10.166540] [<c0332ba8>] (bus_probe_device+0x84/0xa8) from [<c03312d4>] (device_add+0x4c0/0x5bc)
[   10.182706] [<c03312d4>] (device_add+0x4c0/0x5bc) from [<c03c1b8c>] (i2c_new_device+0xf0/0x1ac)
[   10.199481] [<c03c1b8c>] (i2c_new_device+0xf0/0x1ac) from [<c03c3058>] (i2c_do_add_adapter+0x190/0x24c)
[   10.217034] [<c03c3058>] (i2c_do_add_adapter+0x190/0x24c) from [<c0331e38>] (bus_for_each_dev+0x54/0x88)
[   10.234326] [<c0331e38>] (bus_for_each_dev+0x54/0x88) from [<c03c1790>] (i2c_for_each_dev+0x34/0x48)
[   10.251532] [<c03c1790>] (i2c_for_each_dev+0x34/0x48) from [<c03c3390>] (i2c_register_driver+0x78/0xe4)
[   10.268999] [<c03c3390>] (i2c_register_driver+0x78/0xe4) from [<c00085b8>] (do_one_initcall+0x34/0x174)
[   10.286382] [<c00085b8>] (do_one_initcall+0x34/0x174) from [<c007e600>] (sys_init_module+0xe18/0x1cd0)
[   10.303593] [<c007e600>] (sys_init_module+0xe18/0x1cd0) from [<c000e980>] (ret_fast_syscall+0x0/0x30)
[   10.321452] ft5x_ts 0-0038: ft5x_ts_probe: request irq failed
[   10.331001] ------------[ cut here ]------------
[   10.341116] WARNING: at kernel/irq/manage.c:428 enable_irq+0x3c/0x74()
[   10.350508] Unbalanced enable for IRQ 60
[   10.356258] Modules linked in: ft5x_ts(+) sunxi_cedar_mod 8192cu ump hdmi lcd
[   10.375982] [<c0014d74>] (unwind_backtrace+0x0/0x138) from [<c00359dc>] (warn_slowpath_common+0x4c/0x64)
[   10.393709] [<c00359dc>] (warn_slowpath_common+0x4c/0x64) from [<c0035a88>] (warn_slowpath_fmt+0x30/0x40)
[   10.410655] [<c0035a88>] (warn_slowpath_fmt+0x30/0x40) from [<c0090e9c>] (enable_irq+0x3c/0x74)
[   10.427443] [<c0090e9c>] (enable_irq+0x3c/0x74) from [<bf0ba728>] (ft5x_ts_probe+0x3d0/0x470 [ft5x_ts])
[   10.445530] [<bf0ba728>] (ft5x_ts_probe+0x3d0/0x470 [ft5x_ts]) from [<c03c14f0>] (i2c_device_probe+0xcc/0x124)
[   10.463781] [<c03c14f0>] (i2c_device_probe+0xcc/0x124) from [<c03337bc>] (driver_probe_device+0xb0/0x348)
[   10.481510] [<c03337bc>] (driver_probe_device+0xb0/0x348) from [<c0331db8>] (bus_for_each_drv+0x5c/0x88)
[   10.498542] [<c0331db8>] (bus_for_each_drv+0x5c/0x88) from [<c03336a4>] (device_attach+0x88/0xa0)
[   10.514985] [<c03336a4>] (device_attach+0x88/0xa0) from [<c0332ba8>] (bus_probe_device+0x84/0xa8)
[   10.531377] [<c0332ba8>] (bus_probe_device+0x84/0xa8) from [<c03312d4>] (device_add+0x4c0/0x5bc)
[   10.547550] [<c03312d4>] (device_add+0x4c0/0x5bc) from [<c03c1b8c>] (i2c_new_device+0xf0/0x1ac)
[   10.564323] [<c03c1b8c>] (i2c_new_device+0xf0/0x1ac) from [<c03c3058>] (i2c_do_add_adapter+0x190/0x24c)
[   10.581879] [<c03c3058>] (i2c_do_add_adapter+0x190/0x24c) from [<c0331e38>] (bus_for_each_dev+0x54/0x88)
[   10.599172] [<c0331e38>] (bus_for_each_dev+0x54/0x88) from [<c03c1790>] (i2c_for_each_dev+0x34/0x48)
[   10.616379] [<c03c1790>] (i2c_for_each_dev+0x34/0x48) from [<c03c3390>] (i2c_register_driver+0x78/0xe4)
[   10.633846] [<c03c3390>] (i2c_register_driver+0x78/0xe4) from [<c00085b8>] (do_one_initcall+0x34/0x174)
[   10.651232] [<c00085b8>] (do_one_initcall+0x34/0x174) from [<c007e600>] (sys_init_module+0xe18/0x1cd0)
[   10.668444] [<c007e600>] (sys_init_module+0xe18/0x1cd0) from [<c000e980>] (ret_fast_syscall+0x0/0x30)
[   10.681222] ---[ end trace 47a4ad426d819219 ]---
[   10.690892] ------------[ cut here ]------------
[   10.701209] WARNING: at kernel/irq/manage.c:1196 __free_irq+0x9c/0x1dc()
[   10.711052] Trying to free already-free IRQ 60
[   10.717348] Modules linked in: ft5x_ts(+) sunxi_cedar_mod 8192cu ump hdmi lcd
[   10.737084] [<c0014d74>] (unwind_backtrace+0x0/0x138) from [<c00359dc>] (warn_slowpath_common+0x4c/0x64)
[   10.754812] [<c00359dc>] (warn_slowpath_common+0x4c/0x64) from [<c0035a88>] (warn_slowpath_fmt+0x30/0x40)
[   10.771849] [<c0035a88>] (warn_slowpath_fmt+0x30/0x40) from [<c0090588>] (__free_irq+0x9c/0x1dc)
[   10.787326] [<c0090588>] (__free_irq+0x9c/0x1dc) from [<c0090714>] (free_irq+0x4c/0xa0)
[   10.803247] [<c0090714>] (free_irq+0x4c/0xa0) from [<bf0ba73c>] (ft5x_ts_probe+0x3e4/0x470 [ft5x_ts])
[   10.821161] [<bf0ba73c>] (ft5x_ts_probe+0x3e4/0x470 [ft5x_ts]) from [<c03c14f0>] (i2c_device_probe+0xcc/0x124)
[   10.839412] [<c03c14f0>] (i2c_device_probe+0xcc/0x124) from [<c03337bc>] (driver_probe_device+0xb0/0x348)
[   10.857140] [<c03337bc>] (driver_probe_device+0xb0/0x348) from [<c0331db8>] (bus_for_each_drv+0x5c/0x88)
[   10.874173] [<c0331db8>] (bus_for_each_drv+0x5c/0x88) from [<c03336a4>] (device_attach+0x88/0xa0)
[   10.890598] [<c03336a4>] (device_attach+0x88/0xa0) from [<c0332ba8>] (bus_probe_device+0x84/0xa8)
[   10.906937] [<c0332ba8>] (bus_probe_device+0x84/0xa8) from [<c03312d4>] (device_add+0x4c0/0x5bc)
[   10.923103] [<c03312d4>] (device_add+0x4c0/0x5bc) from [<c03c1b8c>] (i2c_new_device+0xf0/0x1ac)
[   10.939877] [<c03c1b8c>] (i2c_new_device+0xf0/0x1ac) from [<c03c3058>] (i2c_do_add_adapter+0x190/0x24c)
[   10.957431] [<c03c3058>] (i2c_do_add_adapter+0x190/0x24c) from [<c0331e38>] (bus_for_each_dev+0x54/0x88)
[   10.974723] [<c0331e38>] (bus_for_each_dev+0x54/0x88) from [<c03c1790>] (i2c_for_each_dev+0x34/0x48)
[   10.991929] [<c03c1790>] (i2c_for_each_dev+0x34/0x48) from [<c03c3390>] (i2c_register_driver+0x78/0xe4)
[   11.009396] [<c03c3390>] (i2c_register_driver+0x78/0xe4) from [<c00085b8>] (do_one_initcall+0x34/0x174)
[   11.026781] [<c00085b8>] (do_one_initcall+0x34/0x174) from [<c007e600>] (sys_init_module+0xe18/0x1cd0)
[   11.043992] [<c007e600>] (sys_init_module+0xe18/0x1cd0) from [<c000e980>] (ret_fast_syscall+0x0/0x30)
[   11.056770] ---[ end trace 47a4ad426d81921a ]---
[   11.063925] ==singlethread error =
[   11.071817] ft5x_ts: probe of 0-0038 failed with error -16
[   11.079994] incomplete xfer (0x20)
[   11.085869] incomplete xfer (0x20)


Will tweak it
i have Rst on PB03 and Int on PB04

dave-at-axon


MBR

Quote from: mushketer888 on September 30, 2014, 02:31:12 PM
but from where it gets pin configuration? if it doesnt read .fex?
.dts?

Allwinner SoCs don't have device tree, they read all config data from the FEX file. To enable the panel, you must modify the [rtp_para] entries in the FEX file, see http://linux-sunxi.org/Fex_Guide#resistive_touch_panel_configuration

mushketer888

#9
Firstly thank you all that you try to help me!

Secondly i have in .fex this:

[ctp_para]
ctp_used = 1
ctp_name = "ft5x_ts"
ctp_twi_id = 0
ctp_twi_addr = 0x38
ctp_screen_max_x = 800
ctp_screen_max_y = 480
ctp_revert_x_flag = 0
ctp_revert_y_flag = 0
ctp_exchange_x_y_flag = 0
ctp_int_port = port:PB03<5><default><default><default>
ctp_wakeup = port:PB04<1><default><default><1>
ctp_io_port = port:PB03<0><default><default><default>

[ctp_list_para]
ctp_det_used = 1
ft5x_ts = 1
gt82x = 0
gslX680 = 0
gt9xx_ts = 0


But really i tried to change this <5> <6> etc but i dont know what this really means and it doesnt affect...

And if it will help: cat /proc/interrupts
root@a20-OLinuXino:~# cat /proc/interrupts
           CPU0       CPU1
29:      16316       1906       GIC  arch_timer
30:          0          0       GIC  arch_timer
32:          0          0       GIC  axp_mfd
33:        308          0       GIC  serial
39:       7044          0       GIC  sunxi-i2c.0
40:          2          0       GIC  sunxi-i2c.1
41:          2          0       GIC  sunxi-i2c.2
54:          0          0       GIC  timer0
55:         12          0       GIC  aw_clock_event
56:          0          0       GIC  sunxi-rtc alarm
59:          0          0       GIC  dma_irq
60:          0          0       GIC  sunxi-gpio
64:      20357          0       GIC  sunxi-mmc
67:          0          0       GIC  sunxi-mmc
71:          0          0       GIC  ehci_hcd:usb2
72:          0          0       GIC  ehci_hcd:usb4
76:      64822          0       GIC  sunxi lcd0
77:          0          0       GIC  sunxi lcd1
78:          1          0       GIC  g2d
79:      32405          0       GIC  sunxi scaler0
80:          0          0       GIC  sunxi scaler1
85:          0          0       GIC  cedar_dev
87:       1760          0       GIC  eth0
92:          0          0       GIC  ace_dev
96:          0          0       GIC  ohci_hcd:usb3
97:          0          0       GIC  ohci_hcd:usb5
101:          0          0       GIC  mali_gp_irq_handlers
102:          0          0       GIC  mali_mmu_irq_handlers
103:          0          0       GIC  mali_pp_irq_handlers
104:          0          0       GIC  mali_mmu_irq_handlers
106:          0          0       GIC  mali_pp_irq_handlers
107:          0          0       GIC  mali_mmu_irq_handlers
IPI0:          0          0  Timer broadcast interrupts
IPI1:       2766       3212  Rescheduling interrupts
IPI2:          0          0  Function call interrupts
IPI3:          8         18  Single function call interrupts
IPI4:          0          0  CPU stop interrupts
IPI5:          0          0  CPU backtrace
Err:          0

mushketer888

#10
It is a bit funny but it seems like kernel uses ft5x module from here:
http://dl.cubieboard.org/parteners/waveshare/Source_Code/a20-cubieboard-dvk/driver%20source/ft5x_ts.c

For example in fex there is no ctp_reset option... (rst_port instead, from sunxi fex guie)
i added this and it shows me


[    9.954868] ctp_init_platform_resource: No power port feature present.
[    9.962799] ctp_reset.
[   10.015343] ctp_detect: Detected chip ft5x_ts at adapter 0, address 0x38


something messed up...

mushketer888

#11
I have changed
err = request_irq(SW_INT_IRQNO_PIO, ft5x_ts_interrupt, IRQF_TRIGGER_FALLING | IRQF_SHARED, "ft5x_ts", ft5x_ts);
to
err = request_irq(SW_INT_IRQNO_PIO, ft5x_ts_interrupt,  IRQF_SHARED, "ft5x_ts", ft5x_ts);

Recompiled etc..
and now at least it doesnt show any errors and loads successfully

But it isnt working from # cat /dev/input/event1 yet
And interrutp doesnt work

mushketer888

Tried to compile latest sunxi kernel 3.4.103 ..the same problem
Does A20 really cant interrupt on Faling signal edge?

mushketer888

There is some trick
I changed INT pin to PH23 and it(original) loaded without problems
something with interrupts...
interrupts can be on all PHx pins? there is no info about it

mushketer888

Haah changed int pin to PH21 from fex guide and all started to work
(needs a bit tweaking X,Y)
the trick was with this pin and interrupt
didnt know this because couldnt find info about it...and no one said