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");
}
nothing can help me?
pls
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.
Why 0x1<<18???? what is this?
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.
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.
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
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),
};
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, \
}
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.
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");
}
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:
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.
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.
According your code modification and description, IRQ 50 should be registered into system wakeup IRQ source group
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
Did you check iomux settings?
I have checked the iomux setting.It's gpio.It is no problem.Thanks for your reply.
hmm.., can you receive interrupt at runtime, or just can not wake up the system?