AnsweredAssumed Answered

Making Battery charger gpio as Wakeup-Source

Question asked by Prasanna Kulkarni on Mar 12, 2018
Latest reply on Mar 14, 2018 by Prasanna Kulkarni

Hi All,

       I am facing a issue in setting battery charger gpio as wakeup-source on imx6q-sabresd Android naugat. following are the code snapshots.

 

In fuel-Gauge driver : we are using max17040_battery.c file and adopted the same features from sabresd_battery.c driver.

related code has been added in the suspend and resume routines.

 

#ifdef CONFIG_PM_SLEEP

 

static int max17040_suspend(struct device *dev)
{
        struct i2c_client *client = to_i2c_client(dev);
        struct max17040_chip *chip = i2c_get_clientdata(client);
        int irq,error;
        if(device_may_wakeup(&client->dev))
        {

                 printk("Inside3__suspend__ ===============> %s \n", __func__);
                irq = gpio_to_irq(max17040_get_gpio(chip->client));
                error = enable_irq_wake(irq);
          }    
        cancel_delayed_work(&chip->work);
        return 0;
}

 

static int max17040_resume(struct device *dev)
{
        struct i2c_client *client = to_i2c_client(dev);
        struct max17040_chip *chip = i2c_get_clientdata(client);
        int irq,error;
         printk("Inside1__resume__ ===============> %s \n", __func__);
        if(device_may_wakeup(&client->dev))
        {
                printk("Inside2 __resume__ ===============> %s \n", __func__);
                irq = gpio_to_irq(max17040_get_gpio(chip->client));
                error = disable_irq_wake(irq);
        }
        queue_delayed_work(system_power_efficient_wq, &chip->work,
                           MAX17040_DELAY);
        return 0;
}

 

static SIMPLE_DEV_PM_OPS(max17040_pm_ops, max17040_suspend, max17040_resume);

-------------------------------------------------------------------------------------------------------------------------------------

 

Code from DTS file

 

        battery: max17040@36 {
               compatible = "maxim,max17040";
               pinctrl-names = "default";
               reg = <0x36>;
               chg_input = <&gpio2 24 1>;
                wakeup-source;
                fsl,dcm_always_high;
                fsl,dc_valid;
                fsl,usb_valid;
                fsl,adc_disable;
                status = "okay";
       };

 

The issue is interrupts are getting generated properly when I insert/remove the charger, but device is not waking up.

it tries to resume for a while but goes to suspend immediately. I have put prints also in the suspend and resume routines they are getting printed during resume/suspend (via Power button).

 

I have checked the sysfs path sys/class/power_supply/max17040-ac/power/wakeup it shows "enabled".

 

But it is not wakingup the device. kindly help me in solving this issue. 

Outcomes