Re: [PATCH 2/2] ARM: imx: Add POWER_KEY to mx51 babbage board

From: Eric Bénard
Date: Fri Oct 15 2010 - 17:10:18 EST


Hi Dinh,

Le 15/10/2010 22:18, Dinh.Nguyen@xxxxxxxxxxxxx a écrit :
+/*!
+ * Power Key interrupt handler.
+ */
+static irqreturn_t power_key_int(int irq, void *dev_id)
+{
+ printk(KERN_INFO "PWR key pressed\n");
+ return 0;
+}
+
+/*!
+ * Power Key initialization.
+ */
+static int __init mxc_init_power_key(void)
+{
+ /* Set power key as wakeup resource */
+ int irq, ret;
+
+ /* power key */
+ ret = gpio_request(BABBAGE_POWER_KEY, "power-key");
+ if (ret) {
+ printk(KERN_ERR"failed to get BABBAGE_POWER_KEY: %d\n", ret);
+ return ret;
+ }
+ gpio_direction_input(BABBAGE_POWER_KEY);
+
+ irq = IOMUX_TO_IRQ(BABBAGE_POWER_KEY);
+ set_irq_type(irq, IRQF_TRIGGER_RISING);
+ ret = request_irq(irq, power_key_int, 0, "power-key", 0);
+ if (ret)
+ pr_info("register on-off key interrupt failed\n");
+ else
+ enable_irq_wake(irq);
+ return ret;
+}
+late_initcall(mxc_init_power_key);
+
instead of doing this, you could use the gpio-keys driver which will configure the IRQ as a wakeup source and also send keys to the input layer.

You can have an example here :
http://git.pengutronix.de/?p=imx/linux-2.6.git;a=blob;f=arch/arm/mach-mx5/eukrea_mbimxsd-baseboard.c;h=2b48f5190830c7cbe2f11676a628c55e1531c133;hb=imx-for-2.6.37#l98

Eric
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/