How can I use key button to wake up system?

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

How can I use key button to wake up system?

4,930 Views
chenglong
Contributor I

I use i'mx53.
I want to use a key button to wake up system.The key button uses gpio1_8.I have changed arch/arm/mach-mx5/Pm.c to use irq 50.But it does not work.When system enter sleeping,it dose not wake up.How can I do?Thanks a lot.

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");

}

Labels (2)
0 Kudos
Reply
19 Replies

3,660 Views
enaud
Contributor III

nothing can help me?

pls

0 Kudos
Reply

3,660 Views
jimmychan
NXP TechSupport
NXP TechSupport

Are you board use the same PMIC DA9053 as the SMD board?

mx53_smd_loco_irq_wake_fixup() function called in the "mx53_smd.c --> smd_suspend_enter() " or "mx53_loco.c --> loco_suspend_enter() " . Please double check the function called properly when enter to the suspend mode.

0 Kudos
Reply

3,660 Views
enaud
Contributor III

Why 0x1<<18???? what is this?

0 Kudos
Reply

3,660 Views
jimmychan
NXP TechSupport
NXP TechSupport

Please read the i.MX53RM Chapter 75.6.14 Wakeup Config Register: Irq 0 to 31 (TZIC_WAKEUPn) for more details.

The Wakeup Conguration Registers (WAKEUP) are used to set which interrupts will assert the tzic_wakeup_request signal. Each bit in the register corresponds to an interrupt source available in the system.

For example: According to the i.MX53 RM "Table 3-1. ARM Domain Interrupt Summary", IRQ 50 is "Combined interrupt indication for GPIO-1 signal 0 throughout 15".

Then in Chapter 75.6.14, the formula is WAKEUP[31] -> (32*X)+31.

In this case, WAKEUP[50] is 32*1+18.  so the TZIC_WAKEUP1's 18bit need to be set 1.

Hope this can help you to understand.

0 Kudos
Reply

3,660 Views
enaud
Contributor III
jimmychan: but I must use this code in upper part of this post or simply i must use this code, how FabioEstevan suggest me? Standby and wakeup with a gpio
0 Kudos
Reply

3,660 Views
jimmychan
NXP TechSupport
NXP TechSupport

This part of code is write to register directly. Just want to make sure that the GPIO is set as a wakeup source directly to avoid if somewhere missed or set it wrongly. Plesae also check the initial value (pull-up or pull-down) of the GPIO. So when you press the button, the value should from 0->1  or  1->0. 

0 Kudos
Reply

3,660 Views
enaud
Contributor III

I've setted gpio6_3:

in mx53loco.c i have:

#define GPIO105 (0x1<<9)    <------- It is a correct value?  from iMX53RM pg217 ---> 105 GPIO-6  "Combined interrupt indication for GPIO-6 signal 0 throughout 15"


in static iomux_v3_cfg_t mx53_loco_pads[] {


//MX53_PAD_CSI0_DAT17__IPU_CSI0_D_17,

MX53_PAD_CSI0_DAT17__GPIO6_3,


and:


static void loco_da9053_irq_wakeup_only_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(GPIO105, tzic_base + TZIC_WAKEUP3_OFFSET);

  iounmap(tzic_base);

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

}

static void loco_suspend_enter(void)

{

  if (!board_is_mx53_loco_mc34708()) {

  loco_da9053_irq_wakeup_only_fixup();

  da9053_suspend_cmd_sw();

  }

}


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

0 Kudos
Reply

3,660 Views
jimmychan
NXP TechSupport
NXP TechSupport

1. define a key

#define MX53_PAD_ WAKEUP  (5*32 + 3)   /* GPIO6_3 */

2.  put it in the gpio_key_button to register the gpio button.

#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)

#define GPIO_BUTTON(gpio_num, ev_code, act_low, descr, wake) \

{        \

.gpio  = gpio_num,    \

.type  = EV_KEY,    \

.code  = ev_code,    \

.active_low = act_low,    \

.desc  = "btn " descr,    \

.wakeup  = wake,     \

}

static struct gpio_keys_button loco_buttons[] = {

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

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

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

GPIO_BUTTON(MX53_PAD_ WAKEUP,KEY_F4,0,"wakeup",1),

};

0 Kudos
Reply

3,660 Views
enaud
Contributor III

what is KEY_F4? in GPIO_BUTTON(MX53_PAD_ WAKEUP,KEY_F4,0,"wakeup",1),?

And this?

#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)

#define GPIO_BUTTON(gpio_num, ev_code, act_low, descr, wake) \

{        \

.gpio  = gpio_num,    \

.type  = EV_KEY,    \

.code  = ev_code,    \

.active_low = act_low,    \

.desc  = "btn " descr,    \

.wakeup  = wake,     \

}

0 Kudos
Reply

3,660 Views
jimmychan
NXP TechSupport
NXP TechSupport

You can find this part of code in mx53_loco.c.

Just like other key buttons, to define the F4 Key as a wakeup button.


0 Kudos
Reply

3,660 Views
enaud
Contributor III

In static iomux_v3_cfg_t mx53_loco_pads[] = {

I have writed:

I commented:

//MX53_PAD_CSI0_DAT17__IPU_CSI0_D_17,

and  i have add:

MX53_PAD_CSI0_DAT17__GPIO6_3,

IS RIGHT?

And this function ? i must modified nothing?

static void loco_da9053_irq_wakeup_only_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);

  iounmap(tzic_base);

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

}

0 Kudos
Reply

3,659 Views
enaud
Contributor III

i've tested  your code but it dont work,

AT GPIO6_3 i have connected a button and when i press it /sys/class/gpio/gpio163/value is 0.

look here:

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.174 msecs

suspend wp cpu=400000000

PM: late suspend of devices complete after 0.784 msecs

only da9053 irq is wakeup-enabled

PM: early resume of devices complete after 0.377 msecs

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

and gpio163(6_3) dont work.

THEN i have enabled:

CONFIG_KEYBOARD_GPIO=y in ltib->device_driver->etc....

and when i type in console:

echo 163 > /sys/class/gpio/export

echo in > /sys/class/gpio/gpio163/direction

i have error and gpio163 dont exist in /sys/class/gpio/      

:smileyangry:

my mx53loco is this attached, pls help me :smileysad:

0 Kudos
Reply

3,659 Views
chenglong
Contributor I

When the system is running,the key button can cause the interrupt.I have checked it.So the imoux setting has no problem.But when the system enter sleeping,the irq can't wake up system.I don't konw how to modify the codes.

0 Kudos
Reply

3,659 Views
RichardZhao
Contributor I

On some platforms, iomux registers are over-written to save power when enter into suspend. I'm not sure whether it's the case. What release are you using? And you can dump registers after setup everything to see whether it's as expected.

0 Kudos
Reply

3,661 Views
RongDian
Contributor I

According your code modification and description,  IRQ 50  should  be registered into system wakeup  IRQ source group

0 Kudos
Reply

3,661 Views
RongDian
Contributor I

hi, I belive imx53  bsp supplies powerkey feature for suspend/resume , you can refer to mxc_pwrkey.c. According to your code, you should catch key signal  with oscilloscope to check your wakeup irq and IO pad property/IO direction input/iomux configure

0 Kudos
Reply

3,661 Views
RichardZhao
Contributor I

Did you check iomux settings?

0 Kudos
Reply

3,661 Views
chenglong
Contributor I

I have checked the iomux setting.It's gpio.It is no problem.Thanks for your reply.

0 Kudos
Reply

3,660 Views
RichardZhao
Contributor I

hmm.., can you receive interrupt at runtime, or just can not wake up the system?

0 Kudos
Reply