Standby and wakeup with a gpio

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Standby and wakeup with a gpio

3,346 Views
enaud
Contributor III

Hi,

my system is formed by a board with imx53 and a display 10''

LVDS.

I need to put the system in standby(STOP MODE?) consuming as little as

possible (turnin off the display) and wake up it with the push of a

button (GPIO connected all'MX53) quickly.

How do I?

PS: I'm already reading the AN4270. but I can not find the wakeup function and how enable the STOP MODE?

thanks

0 Kudos
Reply
13 Replies

1,781 Views
fabio_estevam
NXP Employee
NXP Employee

Take a look at arch/arm/mach-mx5/board-mx53_loco.c:

static const struct gpio_keys_button loco_buttons[] __initconst = {

    GPIO_BUTTON(MX53_LOCO_POWER, KEY_POWER, 1, "power", 1),

    GPIO_BUTTON(MX53_LOCO_UI1, KEY_VOLUMEUP, 1, "volume-up", 0),

    GPIO_BUTTON(MX53_LOCO_UI2, KEY_VOLUMEDOWN, 1, "volume-down", 0),

};

all these GPIOs act as wakeup sources.


Look also at the GPIO_BUTTON definition to understand how it works (hint: there is a .wakeup field).


Also, don't forget to setup your GPIO pin as GPIO (look at mx53_loco_pads array).

Regards,

Fabio Estevam


0 Kudos
Reply

1,781 Views
enaud
Contributor III

Thanks Fabio,

I've view this post https://community.freescale.com/message/302517#302517

I must put this code in mx53_loco.c?

static void mx53_smd_loco_irq_wake_fixup(void)

{

void __iomem *tzic_base;

tzic_base = ioremap(MX53_TZIC_BASE_ADDR, SZ_4K);

if (NULL == tzic_base) {

  pr_err("fail to map MX53_TZIC_BASE_ADDR\n");

  return;

}

__raw_writel(0, tzic_base + TZIC_WAKEUP0_OFFSET);

__raw_writel(0, tzic_base + TZIC_WAKEUP1_OFFSET);

__raw_writel(0, tzic_base + TZIC_WAKEUP2_OFFSET);

/* only enable irq wakeup for da9053 */

// __raw_writel(GPIO7_0_11_IRQ_BIT, tzic_base + TZIC_WAKEUP3_OFFSET);

__raw_writel(0x1<<18, tzic_base + TZIC_WAKEUP1_OFFSET);

iounmap(tzic_base);

pr_info("only da9053 irq is wakeup-enabled\n");

}

0 Kudos
Reply

1,781 Views
fabio_estevam
NXP Employee
NXP Employee

No, no need to add such code.

As I told you you only need to do two things:

1.  Add

GPIO_BUTTON(MX53_LOCO_POWER, KEY_POWER, 1, "power", 1),

,where MX53_LOCO_POWER needs to be adapted to the GPIO number you have in your real hardware

2. Setup your GPIO pin as GPIO (look at mx53_loco_pads array).

Regards,

Fabio Estevam

1,781 Views
enaud
Contributor III

Hi,

Thanks:

so, i have this GPIO: MX53_PAD_CSI0_DAT17__GPIO6_3

and in mx53_loco.c:

1) #define GPIO6_3     (5*32+3)   //GPIO6_3

2) in static iomux_v3_cfg_t mx53_loco_pads[], add:

     MX53_PAD_CSI0_DAT17__GPIO6_3,

and comment:

//MX53_PAD_CSI0_DAT17__IPU_CSI0_D_17,

3) in static struct gpio_keys_button loco_buttons[] = {

//  GPIO_BUTTON(MX53_nONKEY, KEY_POWER, 1, "power", 0),

  GPIO_BUTTON(GPIO6_3, KEY_POWER, 1, "power", 1),

  GPIO_BUTTON(USER_UI1, KEY_VOLUMEUP, 1, "volume-up", 0),

  GPIO_BUTTON(USER_UI2, KEY_VOLUMEDOWN, 1, "volume-down", 0),

};

IS CORRECT?

YOU confirm it?

so i can standby the system with : echo mem > /sys/power/state ?

THANKS

0 Kudos
Reply

1,781 Views
fabio_estevam
NXP Employee
NXP Employee

Yes, it seems OK.

Regards,

Fabio Estevam

0 Kudos
Reply

1,781 Views
enaud
Contributor III

How long does it wakes up the system? fast is it?

I can turn off other things to further lower the power consumption compared to the state of standbye?

If yes... how?

thanks

0 Kudos
Reply

1,781 Views
fabio_estevam
NXP Employee
NXP Employee

I haven't measured the time it takes to wakeup the system, but this is something you can easily measure.

Yes, many drivers can be turned off in low power mode. Power Management layer (CONFIG_PM) will take care of it.

Each individual driver may have its own hooks for handling low power mode.

Regards,

Fabio Estevam

0 Kudos
Reply

1,781 Views
enaud
Contributor III

Where i set and config the Power Management Layer? In which file?

Thanks

0 Kudos
Reply

1,781 Views
fabio_estevam
NXP Employee
NXP Employee

Most likely you have alreadt CONFIG_PM=y in your .config file.

#

# Power management options

#

CONFIG_SUSPEND=y

# CONFIG_PM_TEST_SUSPEND is not set

CONFIG_SUSPEND_DEVICE_TIME_DEBUG=y

CONFIG_SUSPEND_FREEZER=y

CONFIG_PM_SLEEP=y

CONFIG_PM_SLEEP_SMP=y

CONFIG_PM_RUNTIME=y

CONFIG_PM=y

CONFIG_PM_DEBUG=y


Regards,


Fabio Estevam

0 Kudos
Reply

1,781 Views
enaud
Contributor III

This is my .config file:

#

# Power management options

#

CONFIG_PM=y

CONFIG_PM_DEBUG=y

# CONFIG_PM_ADVANCED_DEBUG is not set

# CONFIG_PM_VERBOSE is not set

CONFIG_CAN_PM_TRACE=y

CONFIG_PM_SLEEP=y

CONFIG_SUSPEND_NVS=y

CONFIG_SUSPEND=y

# CONFIG_PM_TEST_SUSPEND is not set

CONFIG_SUSPEND_DEVICE_TIME_DEBUG=y

CONFIG_SUSPEND_FREEZER=y

CONFIG_APM_EMULATION=y

CONFIG_PM_RUNTIME=y

CONFIG_PM_OPS=y

CONFIG_ARCH_SUSPEND_POSSIBLE=y

CONFIG_NET=y

SO THIS IS MAX of LOW POWER for i.MX53 ??

0 Kudos
Reply

1,781 Views
fabio_estevam
NXP Employee
NXP Employee

In order to enter into low power mode:

echo mem > /sys/power/state

Many low-power techniques are already implemented in the FSL BSP.

If you need to further optmize power savings, you may refer to this application note:

cache.freescale.com/files/32bit/doc/app_note/AN4270.pdf

Regards,

Fabio Estevam

0 Kudos
Reply

1,780 Views
enaud
Contributor III

Hi,

i've tested the new kernel with this changes, but it dont work at wakeup...

I've setted gpio163:

root@freescale ~$ echo 163 > /sys/class/gpio/export                                                

root@freescale ~$ echo in > /sys/class/gpio/gpio163/direction                

root@freescale ~$ cd /sys/class/gpio

root@freescale /sys/class/gpio$ cd gpio163

and it work infact when i pres button vale change:

root@freescale /sys/class/gpio/gpio163$ cat value

1

root@freescale /sys/class/gpio/gpio163$ cat value

0

root@freescale /sys/class/gpio/gpio163$ cat value

1

root@freescale /sys/class/gpio/gpio163$ cat value

0

after i go in standby:

root@freescale ~$ echo 163 > /sys/class/gpio/export

root@freescale ~$ echo in > /sys/class/gpio/gpio163/direction

root@freescale ~$ cd /sys

root@freescale /sys$ cd power

STANDBY MODE:

root@freescale /sys/power$ echo mem > state

PM: Syncing filesystems ... done.

Freezing user space processes ... (elapsed 0.01 seconds) done.

Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done.

da9052_tsi_suspend: called

PM: suspend of devices complete after 727.189 msecs

suspend wp cpu=400000000

PM: late suspend of devices complete after 0.794 msecs

only da9053 irq is wakeup-enabled

PM: early resume of devices complete after 0.390 msecs

IPU DMFC NORMAL mode: 1(0~1), 5B(4,5), 5F(6,7)

NOW WHEN I PRESS BUTTON IT DONT RETURN IN IDLE STATE to CONSOLE...

why? you can help me pls?

0 Kudos
Reply

1,781 Views
enaud
Contributor III

nothing here?

0 Kudos
Reply