* [PATCHv2 1/2] ARM: imx: Add wake functionality to GPIO
@ 2010-10-18 16:35 Dinh.Nguyen at freescale.com
2010-10-18 16:35 ` [PATCHv2 2/2] ARM: imx: Add gpio-keys to mx51 babbage board Dinh.Nguyen at freescale.com
0 siblings, 1 reply; 3+ messages in thread
From: Dinh.Nguyen at freescale.com @ 2010-10-18 16:35 UTC (permalink / raw)
To: linux-arm-kernel
From: Dinh Nguyen <Dinh.Nguyen@freescale.com>
Add function definition for irq_chip.set_wake to enable GPIO to
wake-up the system.
Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
---
arch/arm/plat-mxc/gpio.c | 34 +++++++++++++++++++++++++++++++++
arch/arm/plat-mxc/include/mach/gpio.h | 1 +
2 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/arch/arm/plat-mxc/gpio.c b/arch/arm/plat-mxc/gpio.c
index 57ec4a8..0788af5 100644
--- a/arch/arm/plat-mxc/gpio.c
+++ b/arch/arm/plat-mxc/gpio.c
@@ -20,6 +20,7 @@
*/
#include <linux/init.h>
+#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/irq.h>
#include <linux/gpio.h>
@@ -201,11 +202,44 @@ static void mx2_gpio_irq_handler(u32 irq, struct irq_desc *desc)
}
}
+/*
+ * Set interrupt number "irq" in the GPIO as a wake-up source.
+ * While system is running, all registered GPIO interrupts need to have
+ * wake-up enabled. When system is suspended, only selected GPIO interrupts
+ * need to have wake-up enabled.
+ * @param irq interrupt source number
+ * @param enable enable as wake-up if equal to non-zero
+ * @return This function returns 0 on success.
+ */
+static int gpio_set_wake_irq(u32 irq, u32 enable)
+{
+ u32 gpio = irq_to_gpio(irq);
+ u32 gpio_idx = gpio & 0x1F;
+ struct mxc_gpio_port *port = &mxc_gpio_ports[gpio / 32];
+
+ if (enable) {
+ port->suspend_wakeup |= (1 << gpio_idx);
+ if (port->irq_high && (gpio_idx >= 16))
+ enable_irq_wake(port->irq_high);
+ else
+ enable_irq_wake(port->irq);
+ } else {
+ port->suspend_wakeup &= ~(1 << gpio_idx);
+ if (port->irq_high && (gpio_idx >= 16))
+ disable_irq_wake(port->irq_high);
+ else
+ disable_irq_wake(port->irq);
+ }
+
+ return 0;
+}
+
static struct irq_chip gpio_irq_chip = {
.ack = gpio_ack_irq,
.mask = gpio_mask_irq,
.unmask = gpio_unmask_irq,
.set_type = gpio_set_irq_type,
+ .set_wake = gpio_set_wake_irq,
};
static void _set_gpio_direction(struct gpio_chip *chip, unsigned offset,
diff --git a/arch/arm/plat-mxc/include/mach/gpio.h b/arch/arm/plat-mxc/include/mach/gpio.h
index af33b74..133150e 100644
--- a/arch/arm/plat-mxc/include/mach/gpio.h
+++ b/arch/arm/plat-mxc/include/mach/gpio.h
@@ -39,6 +39,7 @@ struct mxc_gpio_port {
struct gpio_chip chip;
u32 both_edges;
spinlock_t lock;
+ u32 suspend_wakeup;
};
int mxc_gpio_init(struct mxc_gpio_port*, int);
--
1.6.0.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCHv2 2/2] ARM: imx: Add gpio-keys to mx51 babbage board
2010-10-18 16:35 [PATCHv2 1/2] ARM: imx: Add wake functionality to GPIO Dinh.Nguyen at freescale.com
@ 2010-10-18 16:35 ` Dinh.Nguyen at freescale.com
2010-10-18 18:12 ` Uwe Kleine-König
0 siblings, 1 reply; 3+ messages in thread
From: Dinh.Nguyen at freescale.com @ 2010-10-18 16:35 UTC (permalink / raw)
To: linux-arm-kernel
From: Dinh Nguyen <Dinh.Nguyen@freescale.com>
Add functionality for the power button on MX51 Babbage board.
Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
---
arch/arm/configs/mx51_defconfig | 1 +
arch/arm/mach-mx5/board-mx51_babbage.c | 33 +++++++++++++++++++++++++++
arch/arm/plat-mxc/include/mach/iomux-mx51.h | 4 ++-
3 files changed, 37 insertions(+), 1 deletions(-)
diff --git a/arch/arm/configs/mx51_defconfig b/arch/arm/configs/mx51_defconfig
index a665ecb..f46f87e 100644
--- a/arch/arm/configs/mx51_defconfig
+++ b/arch/arm/configs/mx51_defconfig
@@ -81,6 +81,7 @@ CONFIG_FEC=y
CONFIG_INPUT_FF_MEMLESS=m
# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
CONFIG_INPUT_EVDEV=y
+CONFIG_KEYBOARD_GPIO=y
CONFIG_INPUT_EVBUG=m
CONFIG_MOUSE_PS2=m
CONFIG_MOUSE_PS2_ELANTECH=y
diff --git a/arch/arm/mach-mx5/board-mx51_babbage.c b/arch/arm/mach-mx5/board-mx51_babbage.c
index 6e384d9..0dded49 100644
--- a/arch/arm/mach-mx5/board-mx51_babbage.c
+++ b/arch/arm/mach-mx5/board-mx51_babbage.c
@@ -16,7 +16,11 @@
#include <linux/gpio.h>
#include <linux/delay.h>
#include <linux/io.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
#include <linux/fsl_devices.h>
+#include <linux/gpio_keys.h>
+#include <linux/input.h>
#include <mach/common.h>
#include <mach/hardware.h>
@@ -36,6 +40,7 @@
#define BABBAGE_USB_HUB_RESET (0*32 + 7) /* GPIO_1_7 */
#define BABBAGE_USBH1_STP (0*32 + 27) /* GPIO_1_27 */
#define BABBAGE_PHY_RESET (1*32 +5) /* GPIO_2_5 */
+#define BABBAGE_POWER_KEY (1*32 + 21) /* GPIO_2_21 */
/* USB_CTRL_1 */
#define MX51_USB_CTRL_1_OFFSET 0x10
@@ -45,8 +50,33 @@
#define MX51_USB_PLL_DIV_19_2_MHZ 0x01
#define MX51_USB_PLL_DIV_24_MHZ 0x02
+static struct gpio_keys_button babbage_buttons[] = {
+ {
+ .gpio = BABBAGE_POWER_KEY,
+ .code = BTN_0,
+ .desc = "PWR",
+ .active_low = 1,
+ .wakeup = 1,
+ },
+};
+
+static struct gpio_keys_platform_data babbage_button_data = {
+ .buttons = babbage_buttons,
+ .nbuttons = ARRAY_SIZE(babbage_buttons),
+};
+
+static struct platform_device babbage_button_device = {
+ .name = "gpio-keys",
+ .id = -1,
+ .num_resources = 0,
+ .dev = {
+ .platform_data = &babbage_button_data,
+ }
+};
+
static struct platform_device *devices[] __initdata = {
&mxc_fec_device,
+ &babbage_button_device,
};
static struct pad_desc mx51babbage_pads[] = {
@@ -93,6 +123,9 @@ static struct pad_desc mx51babbage_pads[] = {
/* USB HUB reset line*/
MX51_PAD_GPIO_1_7__GPIO_1_7,
+
+ /* Power Key */
+ MX51_PAD_EIM_A27__GPIO_2_21,
};
/* Serial ports */
diff --git a/arch/arm/plat-mxc/include/mach/iomux-mx51.h b/arch/arm/plat-mxc/include/mach/iomux-mx51.h
index 21bfa46..05f62a4 100644
--- a/arch/arm/plat-mxc/include/mach/iomux-mx51.h
+++ b/arch/arm/plat-mxc/include/mach/iomux-mx51.h
@@ -31,6 +31,8 @@ typedef enum iomux_config {
IOMUX_CONFIG_SION = 0x1 << 4, /* LOOPBACK:MUX SION bit */
} iomux_pin_cfg_t;
+#define IOMUX_TO_IRQ(pin) (MXC_GPIO_IRQ_START + pin)
+
/* Pad control groupings */
#define MX51_UART1_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PKE | PAD_CTL_PUE | \
PAD_CTL_DSE_HIGH)
@@ -102,7 +104,7 @@ typedef enum iomux_config {
#define MX51_PAD_EIM_A24__GPIO_2_18 IOMUX_PAD(0x450, 0x0bc, 1, 0x0, 0, NO_PAD_CTRL)
#define MX51_PAD_EIM_A25__GPIO_2_19 IOMUX_PAD(0x454, 0x0c0, 1, 0x0, 0, NO_PAD_CTRL)
#define MX51_PAD_EIM_A26__GPIO_2_20 IOMUX_PAD(0x458, 0x0c4, 1, 0x0, 0, NO_PAD_CTRL)
-#define MX51_PAD_EIM_A27__GPIO_2_21 IOMUX_PAD(0x45c, 0x0c8, 1, 0x0, 0, NO_PAD_CTRL)
+#define MX51_PAD_EIM_A27__GPIO_2_21 IOMUX_PAD(0x45c, 0x0c8, 1, 0x0, 0, MX51_I2C_PAD_CTRL)
#define MX51_PAD_EIM_EB0__EIM_EB0 IOMUX_PAD(0x460, 0x0cc, 0, 0x0, 0, NO_PAD_CTRL)
#define MX51_PAD_EIM_EB1__EIM_EB1 IOMUX_PAD(0x464, 0x0d0, 0, 0x0, 0, NO_PAD_CTRL)
#define MX51_PAD_EIM_EB2__GPIO_2_22 IOMUX_PAD(0x468, 0x0d4, 1, 0x0, 0, NO_PAD_CTRL)
--
1.6.0.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCHv2 2/2] ARM: imx: Add gpio-keys to mx51 babbage board
2010-10-18 16:35 ` [PATCHv2 2/2] ARM: imx: Add gpio-keys to mx51 babbage board Dinh.Nguyen at freescale.com
@ 2010-10-18 18:12 ` Uwe Kleine-König
0 siblings, 0 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2010-10-18 18:12 UTC (permalink / raw)
To: linux-arm-kernel
Hello Dinh,
On Mon, Oct 18, 2010 at 11:35:31AM -0500, Dinh.Nguyen at freescale.com wrote:
> From: Dinh Nguyen <Dinh.Nguyen@freescale.com>
>
> Add functionality for the power button on MX51 Babbage board.
>
> Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
> ---
> arch/arm/configs/mx51_defconfig | 1 +
> arch/arm/mach-mx5/board-mx51_babbage.c | 33 +++++++++++++++++++++++++++
> arch/arm/plat-mxc/include/mach/iomux-mx51.h | 4 ++-
> 3 files changed, 37 insertions(+), 1 deletions(-)
>
> diff --git a/arch/arm/configs/mx51_defconfig b/arch/arm/configs/mx51_defconfig
> index a665ecb..f46f87e 100644
> --- a/arch/arm/configs/mx51_defconfig
> +++ b/arch/arm/configs/mx51_defconfig
> @@ -81,6 +81,7 @@ CONFIG_FEC=y
> CONFIG_INPUT_FF_MEMLESS=m
> # CONFIG_INPUT_MOUSEDEV_PSAUX is not set
> CONFIG_INPUT_EVDEV=y
> +CONFIG_KEYBOARD_GPIO=y
> CONFIG_INPUT_EVBUG=m
> CONFIG_MOUSE_PS2=m
> CONFIG_MOUSE_PS2_ELANTECH=y
nice
> diff --git a/arch/arm/mach-mx5/board-mx51_babbage.c b/arch/arm/mach-mx5/board-mx51_babbage.c
> index 6e384d9..0dded49 100644
> --- a/arch/arm/mach-mx5/board-mx51_babbage.c
> +++ b/arch/arm/mach-mx5/board-mx51_babbage.c
> @@ -16,7 +16,11 @@
> #include <linux/gpio.h>
> #include <linux/delay.h>
> #include <linux/io.h>
> +#include <linux/interrupt.h>
> +#include <linux/irq.h>
> #include <linux/fsl_devices.h>
> +#include <linux/gpio_keys.h>
> +#include <linux/input.h>
>
> #include <mach/common.h>
> #include <mach/hardware.h>
> @@ -36,6 +40,7 @@
> #define BABBAGE_USB_HUB_RESET (0*32 + 7) /* GPIO_1_7 */
> #define BABBAGE_USBH1_STP (0*32 + 27) /* GPIO_1_27 */
> #define BABBAGE_PHY_RESET (1*32 +5) /* GPIO_2_5 */
> +#define BABBAGE_POWER_KEY (1*32 + 21) /* GPIO_2_21 */
>
> /* USB_CTRL_1 */
> #define MX51_USB_CTRL_1_OFFSET 0x10
> @@ -45,8 +50,33 @@
> #define MX51_USB_PLL_DIV_19_2_MHZ 0x01
> #define MX51_USB_PLL_DIV_24_MHZ 0x02
>
> +static struct gpio_keys_button babbage_buttons[] = {
> + {
> + .gpio = BABBAGE_POWER_KEY,
> + .code = BTN_0,
> + .desc = "PWR",
> + .active_low = 1,
> + .wakeup = 1,
> + },
> +};
> +
> +static struct gpio_keys_platform_data babbage_button_data = {
> + .buttons = babbage_buttons,
> + .nbuttons = ARRAY_SIZE(babbage_buttons),
> +};
> +
> +static struct platform_device babbage_button_device = {
> + .name = "gpio-keys",
> + .id = -1,
> + .num_resources = 0,
> + .dev = {
> + .platform_data = &babbage_button_data,
> + }
> +};
> +
> static struct platform_device *devices[] __initdata = {
> &mxc_fec_device,
> + &babbage_button_device,
I think this won't fit on top of Sascha's tree as it has a patch that
changed the way the fec is registered.
> };
>
> static struct pad_desc mx51babbage_pads[] = {
> @@ -93,6 +123,9 @@ static struct pad_desc mx51babbage_pads[] = {
>
> /* USB HUB reset line*/
> MX51_PAD_GPIO_1_7__GPIO_1_7,
> +
> + /* Power Key */
> + MX51_PAD_EIM_A27__GPIO_2_21,
> };
>
> /* Serial ports */
> diff --git a/arch/arm/plat-mxc/include/mach/iomux-mx51.h b/arch/arm/plat-mxc/include/mach/iomux-mx51.h
> index 21bfa46..05f62a4 100644
> --- a/arch/arm/plat-mxc/include/mach/iomux-mx51.h
> +++ b/arch/arm/plat-mxc/include/mach/iomux-mx51.h
> @@ -31,6 +31,8 @@ typedef enum iomux_config {
> IOMUX_CONFIG_SION = 0x1 << 4, /* LOOPBACK:MUX SION bit */
> } iomux_pin_cfg_t;
>
> +#define IOMUX_TO_IRQ(pin) (MXC_GPIO_IRQ_START + pin)
> +
This isn't used. (Didn't check patch 1, it should go there if it is
needed.)
> /* Pad control groupings */
> #define MX51_UART1_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PKE | PAD_CTL_PUE | \
> PAD_CTL_DSE_HIGH)
> @@ -102,7 +104,7 @@ typedef enum iomux_config {
> #define MX51_PAD_EIM_A24__GPIO_2_18 IOMUX_PAD(0x450, 0x0bc, 1, 0x0, 0, NO_PAD_CTRL)
> #define MX51_PAD_EIM_A25__GPIO_2_19 IOMUX_PAD(0x454, 0x0c0, 1, 0x0, 0, NO_PAD_CTRL)
> #define MX51_PAD_EIM_A26__GPIO_2_20 IOMUX_PAD(0x458, 0x0c4, 1, 0x0, 0, NO_PAD_CTRL)
> -#define MX51_PAD_EIM_A27__GPIO_2_21 IOMUX_PAD(0x45c, 0x0c8, 1, 0x0, 0, NO_PAD_CTRL)
> +#define MX51_PAD_EIM_A27__GPIO_2_21 IOMUX_PAD(0x45c, 0x0c8, 1, 0x0, 0, MX51_I2C_PAD_CTRL)
This looks wrong. Isn't there a MX51_GPIO_PAD_CTRL?
> #define MX51_PAD_EIM_EB0__EIM_EB0 IOMUX_PAD(0x460, 0x0cc, 0, 0x0, 0, NO_PAD_CTRL)
> #define MX51_PAD_EIM_EB1__EIM_EB1 IOMUX_PAD(0x464, 0x0d0, 0, 0x0, 0, NO_PAD_CTRL)
> #define MX51_PAD_EIM_EB2__GPIO_2_22 IOMUX_PAD(0x468, 0x0d4, 1, 0x0, 0, NO_PAD_CTRL)
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-10-18 18:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-18 16:35 [PATCHv2 1/2] ARM: imx: Add wake functionality to GPIO Dinh.Nguyen at freescale.com
2010-10-18 16:35 ` [PATCHv2 2/2] ARM: imx: Add gpio-keys to mx51 babbage board Dinh.Nguyen at freescale.com
2010-10-18 18:12 ` Uwe Kleine-König
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).