Search

Technical Discussion Group Forum

This forum is provided for user discussion. While Beacon EmbeddedWorks support staff and engineers participate, Beacon EmbeddedWorks does not guarantee the accuracy of all information within in the Technical Discussion Group (TDG).

The "Articles" forums provide brief Articles written by Beacon EmbeddedWorks engineers that address the most frequently asked technical questions.

To receive email notifications when updates are posted for a Beacon EmbeddedWorks product download, please subscribe to the TDG Forum of interest.

TDG Forum

PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 15 Dec 2015 02:05 PM by  Adam Ford
TSC2004IRTJ re-initialization on wakeup from sleep?
 12 Replies
Sort:
You are not authorized to post a reply.
Author Messages
mvly
Basic Member
Basic Member
Posts:104


--
02 Dec 2015 11:57 AM

    I am trying to save power by powering down the TSC2004IRTJ when my screen is off. I noticed that when I power up the screen again, the touch screen is not responsive. Looking at the code in the kernel, there is some initialization code I need to run. Is there a simple way to reinitialize the TSC2004 when I wake up from sleep? If so how do I go about doing this?

     

    I tried looking into the board-omap3logic-display.c code where all the display things happens. What function or things do I need to do to reinitialize the TSC2004?

     

    This is android OS implementation.

    Adam Ford
    Advanced Member
    Advanced Member
    Posts:794


    --
    03 Dec 2015 03:04 PM
    The TSC2004 is initialized in kernel/arch/arm/mach-omap2/board-omap3logic.c

    Search for CONFIG_TOUCHSCREEN_TSC2004 and you'll find the related code in the ifdef there.

    I have an inquiry into one of the developers to see if he has a suggestion on how to best re-initialize the touchscreen upon wakeup.

    I will let you know what he says.

    adam
    mvly
    Basic Member
    Basic Member
    Posts:104


    --
    03 Dec 2015 06:06 PM

    Thanks for your help Adam! I looked at board-omap3logic.c, but I think it only initializes the IRQ and some pins on the omap side not really the touch controller. I think I need to write some I2C commands to the chip to get it to work. Those IRQ should still be valid and do not need to initialize.

    mvly
    Basic Member
    Basic Member
    Posts:104


    --
    03 Dec 2015 06:08 PM

    I also looked at the tsc2004.c file in the kernel/driver/input/touchscreen folder. I think this is where all the i2c commands happens. What is the best way to call one of these functions from the lcd_enable command in board-omap3logic-display.c?

    Adam Ford
    Advanced Member
    Advanced Member
    Posts:794


    --
    04 Dec 2015 11:07 AM
    Can you clarify when you mean by sleep? Is the CPU in suspend or just the screen? Can you also clarify what is powering the TSC2004 on your board?

    The system default should have a resume function that is called when the CPU goes to sleep. This resume function is found in the tsc2004 driver.

    static int tsc2004_resume(struct i2c_client *client)
    {
    struct tsc2004 *ts = i2c_get_clientdata(client);
    tsc2004_prepare_for_reading(ts);
    return 0;
    }


    Because resume is tied to the power management system, it is only called when the system wakes up when the CPU comes out of sleep. The TSC2004 driver assumes the power is already available and may independent of the video power. If you're turning off the power to the TSC2004 but keeping the CPU awake, the resume function won't get called. If you're running the TSC off a GPIO that controlls the LCD, the resume won't know whether or not the power is available.

    adam

    mvly
    Basic Member
    Basic Member
    Posts:104


    --
    04 Dec 2015 03:13 PM

    The power rail on the tsc2004 on the evaluation board is tied to 3.3V and 1.8V. This means that when the switch is on, the tsc2004 is getting 3.3V and 1.8V. This is true even when the Torpedo SOM is put into a sleep state. This means that the tsc2004 never loses its memory and when we wake it up again, the touchscreen still works. However on my system, the 3.3V and 1.8V is tied to the power of the LCD. I figured if the LCD is off, there is no need to keep powering the tsc2004 controller. This is for power saving. However, unlike the Evaluation kit, the tsc2004 will lose its configuration and need to be reconfigured the moment the Torpedo SOM is put to sleep via the power button.

     

    I am not controlling the TSC in the LCD function. I only want to reconfigure it when the LCD is turned on again. I do know when the power is applied because the power control is tied to the LCD_enable pin. In the LCD driver, I control this pin directly.

     

    I will test with the evaluation kit to see if it does call the resume function in the tsc2004 driver file.

    mvly
    Basic Member
    Basic Member
    Posts:104


    --
    04 Dec 2015 03:29 PM
    Justed checked. The resume function from the tsc2004 drivers is not called on resume. The effect is the same even though I put an empty suspend function and wired it into the driver.

    Adam Ford
    Advanced Member
    Advanced Member
    Posts:794


    --
    07 Dec 2015 07:59 AM
    Looking through the source code commit logs, it appears as if the resume code was inserted for this very purpose.

    DM37LINUX-581: Restore needed context for TSC2004 when resuming

    When the regen line is set to have its level dropped to 0 during
    suspend/resume, the TSC2004 chip has its power cut. When the
    system resumes, its power is restored but the context has been
    lost in the chip itself. Since the chip is quite simple (there
    is really only two meaningful setting registers), we can restore
    "context" by just calling the initial initialization function
    which mainly enables interrupts and conversions on the device.


    I'll let him know your feedback and I'll see what he says. I am not sure why it wouldn't call the resume function. I don't see any pending bugs regarding unresponsive touch screen after sleep.

    In the meantime, you might want to try to either call the resume code manually after you enable the power.

    adam
    mvly
    Basic Member
    Basic Member
    Posts:104


    --
    14 Dec 2015 10:14 AM

    Keep in mind I am using this on android. I do see the code in the android version. But I have tested in the evaluation kit as well as our board. I put printk function in the resume function and it does not print anything. Do I need to manually set the regen pin? If so how would the OS know if it needs to resume or not? 

    Adam Ford
    Advanced Member
    Advanced Member
    Posts:794


    --
    15 Dec 2015 07:10 AM
    One of our main Android developers is off site working at a customer's location and then he is taking next week off for an extended holiday break. I'll have to do some inquiries here, but responses may be slow. So I want to apologize in advance.

    adam
    mvly
    Basic Member
    Basic Member
    Posts:104


    --
    15 Dec 2015 10:49 AM
    Thanks adam.

    Here is some more debug information if you need it.

    [ 565.010894] omap_i2c omap_i2c.3: controller timed out
    [ 565.026580] tsc2004 3-0048: i2c io (read) error: -110
    [ 554.925018] tsc2004 3-0048: i2c io (read) error: -110
    [ 555.924987] omap_i2c omap_i2c.3: controller timed out
    [ 555.930358] tsc2004 3-0048: i2c io (read) error: -110
    [ 556.932861] omap_i2c omap_i2c.3: controller timed out
    [ 556.938293] tsc2004 3-0048: i2c io (read) error: -110
    [ 557.940612] omap_i2c omap_i2c.3: controller timed out
    [ 557.956268] tsc2004 3-0048: i2c io (read) error: -110
    [ 558.956237] omap_i2c omap_i2c.3: controller timed out
    [ 558.961639] tsc2004 3-0048: i2c io (read) error: -110
    [ 559.964050] omap_i2c omap_i2c.3: controller timed out
    [ 559.979675] tsc2004 3-0048: i2c io (read) error: -110
    [ 560.979644] omap_i2c omap_i2c.3: controller timed out
    [ 560.985015] tsc2004 3-0048: i2c io (read) error: -110
    [ 561.987457] omap_i2c omap_i2c.3: controller timed out
    [ 561.992828] tsc2004 3-0048: i2c io (read) error: -110
    [ 562.995330] omap_i2c omap_i2c.3: controller timed out
    [ 563.000701] tsc2004 3-0048: i2c io (read) error: -110


    I am getting this message all the the time.

    Just to reiterate, I only get this message after 30-40 seconds or so after I power down the screen. I suspect the android code is still looking for the screen even though the screen is off.
    mvly
    Basic Member
    Basic Member
    Posts:104


    --
    15 Dec 2015 01:54 PM
    OK i finally got the issue resolved. From the previous post, the "power down" of the TSC2004 chip is causing interrupts to occur. This is because the interrupt is active-low. This would cause the driver to read the TSC2004 via the i2c. However because the chip is not there, it times out and probably puts the kernel in a weird states to prevent it from coming up properly when I do enable the screen again.

    I fixed it by disabling the interrupt, when I put the screen to sleep and enable it when I wake the screen.

    I still need to reinitialize the TSC2004 using the tsc2004_prepare_for_reading function.

    Everything seems to work now. I will do further testing, but so far it looks like it works.
    Adam Ford
    Advanced Member
    Advanced Member
    Posts:794


    --
    15 Dec 2015 02:05 PM
    I am glad it worked out for you. If you are interested in having us do a schematic review, we have different support packages available. If we do the schematic reviews, we put an NDA in place to protect each other and it gives us some insight into the hardware so we can make software suggestions. I realize that you may not be able to share too much due to sensitive nature of whatever your product may be, but we have worked with a variety of customers in aerospace, defense, and medical.

    I am glad it's working for you.

    adam

    You are not authorized to post a reply.