This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Touch Screen and SEED-OMAPl137

Other Parts Discussed in Thread: TSC2046, ADS7846, DA8XX

Hello all!!

I want to enable the touch screen (TSC2046) which is connected to the board via SPI1.

I am using the last linux distribution (by git).

When i build the kernel, i choose in the menuconfig the options of TOUCH SCREEN and ADS7846 based touch-screen. Also, i enable the spi support.

When choosing these options i may think that it may work, but no, it doesnt. From looking at the davinci files (da830.c) i can see that there aren't any SPI protocols or devices initialiation.

I want to initialize the SPI protocol (i saw that in montavista - files - release they init the SPI when init the board), so i guess i have to add structs and pins and mux configuration and initializaion to the C files of "da830" and "devices-da830", but i dont know how to do it..

Any body got something? idea? a patch?

Please Help, i am getting crazy of figuring it out.

 

  • Hello, Liran!
    I use touchscreen on SEED DEC137 with montavista linux. I'm not familiar with git distribution, so filenames in your case will different.
    To configure TSC2046 first of all I changed file
     /opt/mv_pro_5.0_texas/montavista/pro/devkit/lsp/ti-davinci/linux-2.6.18_pro500/arch/arm/mach-da8xx/spi.c

    //changes in file spi.c
       
        // irq using for TSC2046 is pin 4 of bank 4 so it's number is 68
    static int ads7846_gpioirq_num = 68;// ads7846_gpioirq_num = (bank_num * 16) + pin_num

        // TSC2046 is selected permanently
    static u8 davinci_spi1_chip_sel[] = {
        0
    };

        // platform data use pointer to this function
    static int ads7846_pendown_state(void)
    {
          return !gpio_get_value( ads7846_gpioirq_num ); // PENIRQ.
    }

        // platform data for touchscreen
    static struct ads7846_platform_data ads7846_ts_data = {
          .model                 = 7846,
          .x_min                 = 150,
          .x_max                 = 3830,
          .y_min                 = 190,
          .y_max                 = 3830,
          .vref_delay_usecs         = 100,
        //.settle_delay_usecs    = 200,
          .x_plate_ohms             = 900,
          .y_plate_ohms             = 900,
          .pressure_max             = 15000,
          .debounce_max             = 50,
          .debounce_rep             = 20,
          .debounce_tol             = (~20),
          .get_pendown_state     = ads7846_pendown_state,
    };


    struct davinci_spi_config_t tsc2046IPWR_spi_cfg = {
        .wdelay        = 0,
        .odd_parity    = 0,
        .parity_enable    = 0,
        .wait_enable    = 0,
        .lsb_first    = 0,
        .timer_disable    = 0,
        .clk_high    = 0,
        .phase_in    = 1,
        .clk_internal    = 1,
        .loop_back    = 0,
        .cs_hold    = 1,
        .intr_level    = 0,
        .pin_op_modes    = SPI_OPMODE_3PIN,
    #ifndef CONFIG_SPI_INTERRUPT
        .poll_mode    = 1,
    #endif
    };




    static struct spi_board_info da8xx_spi_board_info1[] = {
        [0] = {
            .modalias = "ads7846",
            .platform_data = &ads7846_ts_data,
            .controller_data = &tsc2046IPWR_spi_cfg,
            .mode = SPI_MODE_0,
            .irq = 0,
            .max_speed_hz = 31250*26  ,
            .bus_num = 1,
            .chip_select = 0,
        },
    };

    // end of spi.c

    After editing spi.c my touchscreen driver was loaded and I received /dev/input/0 node. But it did not work because pen interrupt did not come into ads7846 driver. My experience in Linux is not very deep for now, so I don't know how to select tsc2046 irq for using driver in the right way. In spi.c, there is "da8xx_spi_board_info1.spi" field. But tsc2046 does not use irq line, it explore gpio 4 in bank 4. And I don't know irq number for this gpio before initialization. It is received later with assigning gpio to irq.
    I edited my driver directly though it is strongly not recommended. I don't load driver during normal boot. Instead, I made a number of changes in a copy of ads7846.c and build a kernel module from it. After interrupt configuring driver become functional.
    I think that including board-specific information in driver is not a good thing. For this reason I can't recommend it for all and not describe driver code changes here. I can send them by email or in other way if you need.

    Regards,
    Eugene

  • Hey Eugene!

    Thanks a lot for your help.. I will try to run it and i will tell u what happened..

    Anyway, I found that there are "TSC2046" files (C and H), which supposed to be the drivers for the touch screen, so maybe you dont need to change the ads7846 files.. If you want i can send them to you via email..

    ......

    So, i changed my spi.c as you wrote, but still, i dont get any dev/input for the touch-screen.

    I dont understand why it doesnt recognize it..

     

  • Ok, I changed the ads7846 driver - i deleted the lines:

    if (!spi->irq) {

    dev_dbg(&spi->dev, "no IRQ?\n");

    return -ENODEV;

    }

     

    because we emit the irq to 0 and therefore its always stay on 0.

    Anyway, when i write the ts_test command, it turn off the lcd and i cant see nothing. is there a way to test the Touch screen? and i would glad to see the changes that u made to the ads7846 driver, and maybe understand more about it. so i would thank you if you send it to me: rejtkop@bgu.ac.il

    thanks in advance, Liran

  • Note, that for OMAP L137, you must change pointer in framebuffer driver.For tslib utilities, you need to change file:

    file tslib/test/fbutils.c

    int open_framebuffer(void)
    {
    ...
    130:     fbuffer = mmap(NULL, fix.smem_len, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, fb_fd, 0);
        fbuffer += 32;
    }

    void close_framebuffer(void)
    {
    ...
    150:    fbuffer -= 32;
        munmap(fbuffer, fix.smem_len);
    }

    I don't know is it required only for montavista driver or for any other linux. Otherwise, you receive black screen or blitter and graphic controller will hang till you reset the board.

    ads7846 chip in SEED-DEC137 is not connected to irq0. I set it in da8xx_spi_board_info1, but really another line is used for pen irq (gpio pin 4 in bank 4 as I said above). You must configure your touchscreen driver for receiving signal from this line. It is necessary to assign this gpio pin to any irq number, and then remember this number in spi_device struct used in driver. Also you must set correct pinmux for this line.

    Did you get node for touchscreen in /dev ? (something like /dev/input/event0)

  • First of all, I checked the TSC2046 driver i have, its the same as ads7846 exactly. The difference is that it works with 16 bits, but spi cant transfer 16 bits, so it doesnt matter for us, any way..

    Well, You knew exactly what is my next question. I do get a black screen when i enter "ts_test" and i cant see nothing, so i wonder how to test the touch screen. I dont have the source code for the tslib so i have to download it and cross compile for the arm.

    I do get event0. and i checked the irq_return function. I added  in function ads7846_irq(...)"

     

        static irqreturn_t ads7846_irq(int irq, void *handle, struct pt_regs *regs)

        {

            struct ads7846 *ts = handle;

            unsigned long flags;

            printk("\n<1> ads7846_irq(), ts->spi->irq=%d\n", ts->spi->irq);

    ...

    and when i load the module, i get this line repeatedly, but i can see that when i touch the screen, this printed line is printed repeatedly much faster, so i guess the touch screen works. But still, i have to check that it works fine.

    i cross-compiled the tslib from beginning, and now i have it installed. but still. when i enter "ts_calibrate" it shows me the message:

    xres=640 yres=480

    and thats all, it stuck and not responding, and i have to ctrl-break it.

    also, ts_test doesnt work at all - black screen.

     

    What do u say?

     

     

     

  • Yes, I received repeated irq from tsc2046 when tested irq line. But now it appears only during screen touch. I can't check now, what is responsible for irq repeating, may be it is function ads7846_pendown_state() in spi.c (the difference is in testing lifted or lowered state of the pen)