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.

Linux/AM3351: Disabling wakeup source from GPIO0

Part Number: AM3351
Other Parts Discussed in Thread: SYSCONFIG

Tool/software: Linux

Hi,

We have custom board based on AM3351 and bq27421 fuel gas gauge sensor. In that, GPIO bank 0 is used as wakeup source and we are using wake up GPIO button, which is connected bank 0 for wake up purpose. Also we have connected fuel gas guage interrupt to GPIO bank 0. Because of this, it is automatically wake up the device from sleep mode(due to feul gas guage interrupt), even though we are not pressing wakeup gpio button. I have added disable/enable irq in suspend/resume function of fuel gauge driver in order to disable fuel gas gauge interrupt during sleep mode. But still fuel gauge interrupt wake up the device from sleep mode. Below is the code I have added.

static int bq27421_pm_suspend(struct device *dev)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct bq27421_device_info *di = i2c_get_clientdata(client);

	if (client->irq) {
		if (device_may_wakeup(dev))
			disable_irq_wake(client->irq);
	disable_irq(client->irq);
	}

	cancel_delayed_work_sync(&di->work);
	
	return 0;
}

static int bq27421_pm_resume(struct device *dev)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct bq27421_device_info *di = i2c_get_clientdata(client);

	if (client->irq) {
		if (device_may_wakeup(dev))
			enable_irq_wake(client->irq);
	enable_irq(client->irq);
	}

	schedule_delayed_work(&di->work, poll_interval * HZ);
	
	return 0;
}

  • Hi,

    What Linux version is this?
  • Hi Biser,
    I'm using linux processor-sdk-03.00.00.04

    Regards,
    Manoj
  • But I'm using linux kernel version 4.1.18 in processor-sdk-03.00.00.04 instead of kernel version 4.4
  • Manoj,

    GPIO wakeup feature is configured (enable/disable) in DTS file. See for example the AM335x TI EVM DTS file - am335-evm.dts

    gpio_keys: volume_keys@0 {
    compatible = "gpio-keys";
    #address-cells = <1>;
    #size-cells = <0>;
    autorepeat;

    switch@9 {
    label = "volume-up";
    linux,code = <115>;
    gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
    gpio-key,wakeup;
    };

    switch@10 {
    label = "volume-down";
    linux,code = <114>;
    gpios = <&gpio0 3 GPIO_ACTIVE_LOW>;
    gpio-key,wakeup;
    };
    };

    See also the below files:
    linux-kernel/Documentation/devicetree/bindings/power/wakeup-source.txt
    linux-kernel/Documentation/devicetree/bindings/input/gpio-keys.txt

    linux-kernel/arch/arm/boot/dts/am335x-evm.dts
    linux-kernel/arch/arm/boot/dts/am335x-evmsk.dts

    Check also the below e2e post:

    https://e2e.ti.com/support/arm/sitara_arm/f/791/p/572939/2102358#2102358

    Regards,
    Pavel

  • Hi Pavel,

    I doing it in the same way only.

    gpio_keys: volume_keys@0 { compatible = "gpio-keys"; #address-cells = <1>; #size-cells = <0>; pinctrl-names = "default"; pinctrl-0 = <&media_keys_s0>; switch@1 { label = "play-pause"; linux,code = <164>; gpios = <&gpio0 12 GPIO_ACTIVE_LOW>; gpio-key,wakeup; }; }

    But fuel gas guage interrupt(which is also connected to gpio 0 bank) is waking device during sleep mode. I want to disable fuel gas gauge interrupt  during sleep mode, so that it will not wake up the device.


    &i2c0 {
            pinctrl-names = "default";
            pinctrl-0 = <&i2c0_pins>;
            pinctrl-1 = <&i2c0_pins_sleep>;
    
            status = "okay";
            clock-frequency = <400000>;
    
            bq27421: bq27421@55 {
                    compatible = "ti,bq27421";
                    reg = <0x55>;
                    interrupt-parent = <&gpio0>;
                    interrupts = <7 2>;
                    ti,ext_batt_psy;
                    status = "okay";
            };
    
    };

  • Manoj Kumar said:
    gpio_keys: volume_keys@0 { compatible = "gpio-keys"; #address-cells = <1>; #size-cells = <0>; pinctrl-names = "default"; pinctrl-0 = <&media_keys_s0>; switch@1 { label = "play-pause"; linux,code = <164>; gpios = <&gpio0 12 GPIO_ACTIVE_LOW>; gpio-key,wakeup; }; }

    Remove that line gpio-key,wakeup; from your DTS file. Then check bit GPIO_SYSCONFIG[2] ENAWAKEUP. This bit should be 0.

    Regards,
    Pavel

  • Hi Pavel,

    Let me explain clearly. There are two interrupt GPIO0_12 and GPIO0_7 configured in dts, one for  Play/Pause Switch, another one for fuel gas gauge interrupt line.  By pressing Play/Pause switch(GPIO0_12), device will wakeup from sleep mode. In sleep mode, fuel gas gauge chip will be active, since it is powered by battery. Therefore it is also generating interrupt during sleep mode which intern wake up the device from sleep mode. So how to disable fuel gas guage interrupt from GPIO0_7 during sleep mode, so that it should not wake up the device. 

    Regards,

    Manoj

  • Manoj,

    Manoj Kumar said:
    &i2c0 { pinctrl-names = "default"; pinctrl-0 = <&i2c0_pins>; pinctrl-1 = <&i2c0_pins_sleep>; status = "okay"; clock-frequency = <400000>; bq27421: bq27421@55 { compatible = "ti,bq27421"; reg = <0x55>; interrupt-parent = <&gpio0>; interrupts = <7 2>; ti,ext_batt_psy; status = "okay"; }; };

    Is this all you have regarding BQ27421 description in your dts/dtsi files?

    Can you try first removing these two lines (interrupt-parent and interrupts), do you have interrupt generated by the BQ27421 then? I want to be sure that below two lines generate this interrupt, then I will check how we can disable this interrupt only during sleep mode.

    interrupt-parent = <&gpio0>;
    interrupts = <7 2>;



    Pavel