LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Embedded & Single-board computer (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/)
-   -   ADS7846 linux driver with mediatek devices (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/ads7846-linux-driver-with-mediatek-devices-4175680005/)

arktrin 08-06-2020 12:14 PM

ADS7846 linux driver with mediatek devices
 
Hello!
Trying to add touchscreen ( compatible = "ti,ads7846"; ) to my MT7621 based router through SPI, but it looks like OpenWrt (kernel 5.4.52) doesn't want to route interrupt to ads7846 driver (https://github.com/torvalds/linux/bl...reen/ads7846.c). I've got these lines in device tree:
Code:

....
#include "mt7621.dtsi"
....

    xpt2046reg: xpt2046_reg {
        compatible = "regulator-fixed";
        regulator-name = "xpt2046_vcc";
        regulator-min-microvolt = <3300000>;
        regulator-max-microvolt = <3300000>;
        regulator-always-on;
.....
&spi0 {
    status = "okay";

....

    spidev3@3 {
        #address-cells = <1>;
        #size-cells = <0>;
        compatible = "ralink,mt7621-spi";
        reg = <3>;
        spi-max-frequency = <250000>;
        status = "disabled";
    };
       
    xpt2046@4 {
        compatible = "ti,ads7846";
        reg = <3>;
        vcc-supply = <&xpt2046reg>;
        spi-max-frequency = <250000>;

        interrupt-parent = <&gpio>;
        interrupts = <18 IRQ_TYPE_EDGE_FALLING>;
        pendown-gpio = <&gpio 18 GPIO_ACTIVE_LOW>;
        ti,x-min = /bits/ 16 <0x0>;
        ti,x-max = /bits/ 16 <0x0fff>;
        ti,y-min = /bits/ 16 <0x0>;
        ti,y-max = /bits/ 16 <0x0fff>;
        ti,x-plate-ohms = /bits/ 16 <180>;
        ti,pressure-max = /bits/ 16 <255>;
        ti,debounce-max = /bits/ 16 <10>;
        ti,debounce-tol = /bits/ 16 <5>;
        ti,debounce-rep = /bits/ 16 <1>;
        ti,keep-vref-on = <1>;
        ti,settle-delay-usec = /bits/ 16 <150>;

        wakeup-source;
        status = "okay";
    };
};

Interrupt is successfully registered in the system:
Code:

ads7846 spi0.3: touchscreen, irq 27
Driver is loaded:
Code:

input: ADS7846 Touchscreen as /devices/platform/1e000000.palmbus/1e000b00.spi/spi_master/spi0/spi0.3/input/input0
Event is located in /dev/input/event0. MISO, MOSI, SCK and CS are working on spi0.3 and touchscreen driver is replying something meaningful during driver probe/initialization. There is corresponding line in /proc/interrupts:

Code:

27:          0          0          0          0  1e000600.gpio  18  ads7846
GPIO18 is pulled up externally through 10k resistor. But when touchscreen driver chip pulls down this gpio (pendown) nothing is happening in /proc/interrupts. ads7846_hard_irq() and ads7846_irq() functions from linux driver not even used.

If I remove any reference of GPIO18 in device tree - GPIO18 can be used freely as interrupt source through echo falling > /sys/class/gpio/gpio490/edge, that is clearly seen in /proc/interrupts.

Code:

# cat /proc/bus/input/devices
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="ADS7846 Touchscreen"
P: Phys=spi0.3/input0
S: Sysfs=/devices/platform/1e000000.palmbus/1e000b00.spi/spi_master/spi0/spi0.3/input/input0
U: Uniq=
H: Handlers=event0
B: PROP=0
B: EV=b
B: KEY=400 0 0 0 0 0 0 0 0 0 0
B: ABS=1000003

How else can I debug this issue?

business_kid 08-07-2020 05:39 AM

I've just finished searching for drivers for the Ralink 5370 wifi chip, and found that Mediatek and Ralink are strongly linked. I very much doubt if any of their devices are in the kernel at all. Here'e the thread https://www.linuxquestions.org/quest...er-4175679811/

The one driver I found was 2012 vintage done for a 2.6 kernel. It's a compile outside source job. .No firmware. I don't like the bus/product/version all being 0000.

I'd try a 2k2 instead of a 10k pullup and see if the interrupt behaves better. That's the only idea I have for you.

arktrin 08-07-2020 12:00 PM

Quote:

Mediatek and Ralink are strongly linked
Well :) ... "On 5 May 2011, Ralink was acquired by MediaTek".

Quote:

2k2 instead of a 10k pullup
But I already said that GPIO can be used as interrupt through gpiolib - "GPIO18 can be used freely as interrupt source through echo falling > /sys/class/gpio/gpio490/edge, that is clearly seen in /proc/interrupts". Anyway, tried it, didn't help as expected :(.


All times are GMT -5. The time now is 11:11 AM.