UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor tomams
Visitor
10,469 Views
Registered: ‎11-02-2008

SPI - ADS7846 touchscreen

Hi,

 

My touch screen is connected thro ADS7846 by SPI bus. How do I see this in /dev? Can someone let me know the example?

 

 

TOM

0 Kudos
10 Replies
Xilinx Employee
Xilinx Employee
10,452 Views
Registered: ‎04-23-2008

Re: SPI - ADS7846 touchscreen

Tom,

Looks like Linux actually has a driver for this touchscreen.

 

linux-2.6-xlnx/drivers/input/touchscreen/ads7846.c

 

Assuming that you've built a kernel with the Xilinx SPI driver and the driver for this touch screen, you'll need to figure out how to properly edit the device tree (the .dts file) to specify that this touchscreen is present.  This driver is not device-tree aware, so you'll need to make use of the kernel's workaround for the device (99% of SPI drivers haven't yet been modified to use the device tree directly yet).

 

Find the name of the driver in ads7846.c:

 

static struct spi_driver ads7846_driver = {

    .driver = { 

        .name   = "ads7846",

        .bus    = &spi_bus_type,

        .owner  = THIS_MODULE,

    },

    .probe      = ads7846_probe,

    .remove     = __devexit_p(ads7846_remove),

    .suspend    = ads7846_suspend,

    .resume     = ads7846_resume,

};

 
Add this name and a device tree allias for it to the modalias table in drivers/of/base.c
Something like: 
 
static struct of_modalias_table of_modalias_table[] = {
        { "fsl,mcu-mpc8349emitx", "mcu-mpc8349emitx" },
        { "mmc-spi-slot", "mmc_spi" },
        { "my-pretty-name", "ads7846" },
};
 
Add the device to your SPI bus controller in your .dts file and rebuild:
        SPI_CONTROLLER: xps-spi@83400000 {
            compatible = "xlnx,xps-spi-2.01.b", "xlnx,xps-spi-2.00.a";
            interrupt-parent = <&Interrupt_Cntlr>;
            interrupts = < 4 2 >;
            reg = < 0x83400000 0x10000 >;
            xlnx,family = "spartan6";
            xlnx,fifo-exist = <0x1>;
            xlnx,num-ss-bits = <0x1>;
            xlnx,num-transfer-bits = <0x8>;
            xlnx,sck-ratio = <0x20>;
            my_touchscreen@0 {
                compatible = "my-pretty-name", "ads7846";
                reg = <0>;
                spi-max-frequency = <10000000>;
            };
        } ;
 
And see if this driver recognizes your device at bootup.
 
In short, you've got some figuring out to do :-)
 
-Brian 

 

0 Kudos
Visitor tomams
Visitor
10,432 Views
Registered: ‎11-02-2008

Re: SPI - ADS7846 touchscreen

Hi, Thank you. I tried as you mentioned. The drivers fails for IRQ. It return with no IRQ? error. Any idea?

 

tom

0 Kudos
Visitor tomams
Visitor
10,427 Views
Registered: ‎11-02-2008

Re: SPI - ADS7846 touchscreen

Hi

 

When I skipped IRQ & No platform data errors, I get the following error

 

ads7846: probe of spi32766.0 failed with error -22

 

 

Please can you help?

 

tom

0 Kudos
Visitor tomams
Visitor
10,395 Views
Registered: ‎11-02-2008

Re: SPI - ADS7846 touchscreen

Hi

 

I do not get the error "no platform data".

 

I use the following dts

 

 xps_spi_ts: xps-spi@42400000 {
                        compatible = "xlnx,xps-spi-2.01.b", "xlnx,xps-spi-2.00.a";
                        interrupt-parent = <&xps_intc_0>;
                        interrupts = < 2 2 >;
                        reg = < 0x42400000 0x200 >;
                        xlnx,family = "virtex4";
                        xlnx,fifo-exist = <0x1>;
                        xlnx,num-ss-bits = <0x1>;
                        xlnx,num-transfer-bits = <0x8>;
                        xlnx,sck-ratio = <0xd0>;
                         #address-cells = <1>;
                         #size-cells = <0>;

                        ts@0{
                        compatible = "spi,ads7846";
                        reg        =<0>;
                        interrupt-parant =<&xps_intc_0>;
                        interrupts  = <3 2>;
                        spi-max-frequency = <100000>;
                        #addr-size = <2>;
                        #page-size = <32>;

                       };
};

 

 

 

This is the dmesg info

 

bus: 'spi': add driver ads7846
bus: 'spi': driver_probe_device: matched device spi32766.0 with driver ads7846
bus: 'spi': really_probe: probing driver ads7846 with device spi32766.0

ADS 7846 Testing
no platform data

 

 

Please can you let me know what could be the problem?

0 Kudos
Visitor tomams
Visitor
10,391 Views
Registered: ‎11-02-2008

Re: SPI - ADS7846 touchscreen

sorry!  I do get the error "no platform data"

 

tom

0 Kudos
Xilinx Employee
Xilinx Employee
10,387 Views
Registered: ‎04-23-2008

Re: SPI - ADS7846 touchscreen

Tom,

I believe this problem stems from the driver not being device tree aware.  The modalias table is a stop-gap (that doen't fill the gap in this case).

From looking at other (non device tree platforms) I see things like  arch/arm/mach-at91/board-cap9adk.c where a

 static struct ads7846_platform_data ads_info = {
        .model                  = 7843,
        .x_min                  = 150,
        .x_max                  = 3830,
        .y_min                  = 190,
        .y_max                  = 3830,
        .vref_delay_usecs       = 100,
        .x_plate_ohms           = 450,
        .y_plate_ohms           = 250,
        .pressure_max           = 15000,
        .debounce_max           = 1,
        .debounce_rep           = 0,
        .debounce_tol           = (~0),
        .get_pendown_state      = ads7843_pendown_state,
};

etc... is found.

 

I believe you'll have to modifiy the driver to get this state from ... somewhere.... Choices abound; it depends how clean you'd like your solution to be.

 

-Brian

0 Kudos
Xilinx Employee
Xilinx Employee
10,386 Views
Registered: ‎04-23-2008

Re: SPI - ADS7846 touchscreen

You may be able to just copy the scheme from the file I mentioned above to 

linux-2.6-xlnx/arch/powerpc/platforms/44x/virtex.c

 

-Brian

 

0 Kudos
Visitor tomams
Visitor
10,381 Views
Registered: ‎11-02-2008

Re: SPI - ADS7846 touchscreen

Hi Thanks.

 

Where should I use the board info?

0 Kudos
Xilinx Employee
Xilinx Employee
10,378 Views
Registered: ‎09-10-2008

Re: SPI - ADS7846 touchscreen

I'm not sure if this is helpful or not, but I attached a file (main.c) that I use for testing the spi eeprom when the eeprom driver doesn't support device tree.

 

I build a kernel module with this code and it works fine.  Just trying to illustrate another way, but not necessarily saying it's the best way.

 

Thanks.

0 Kudos
Visitor tomams
Visitor
2,976 Views
Registered: ‎11-02-2008

Re: SPI - ADS7846 touchscreen

Hi

 

I have modified the ads7846.c file by including the ads_info & all given in AT board. Still I get the no platform data error msg.  

0 Kudos