* [PATCHv4 1/2] ARM: imx: Add gpio-keys to mx51 babbage board
@ 2010-10-21 18:55 Dinh.Nguyen at freescale.com
2010-10-21 18:55 ` [PATCHv4 2/2] ARM: imx: Add wake functionality to GPIO Dinh.Nguyen at freescale.com
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Dinh.Nguyen at freescale.com @ 2010-10-21 18:55 UTC (permalink / raw)
To: linux-arm-kernel
From: Dinh Nguyen <Dinh.Nguyen@freescale.com>
Add functionality for the power button on MX51 Babbage board.
This patch is based on Sascha Hauer's imx/linux-2.6 for-rmk tree.
Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
---
arch/arm/configs/mx51_defconfig | 1 +
arch/arm/mach-mx5/board-mx51_babbage.c | 22 +++++++++++++++++
arch/arm/mach-mx5/devices-imx51.h | 2 +
arch/arm/plat-mxc/devices/Kconfig | 5 ++++
arch/arm/plat-mxc/devices/Makefile | 1 +
arch/arm/plat-mxc/devices/platform-buttons.c | 29 +++++++++++++++++++++++
arch/arm/plat-mxc/include/mach/devices-common.h | 4 +++
arch/arm/plat-mxc/include/mach/iomux-mx51.h | 2 +-
8 files changed, 65 insertions(+), 1 deletions(-)
create mode 100644 arch/arm/plat-mxc/devices/platform-buttons.c
diff --git a/arch/arm/configs/mx51_defconfig b/arch/arm/configs/mx51_defconfig
index 163cfee..5c7a872 100644
--- a/arch/arm/configs/mx51_defconfig
+++ b/arch/arm/configs/mx51_defconfig
@@ -82,6 +82,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 23ee4a4..f6ce0d6 100644
--- a/arch/arm/mach-mx5/board-mx51_babbage.c
+++ b/arch/arm/mach-mx5/board-mx51_babbage.c
@@ -18,6 +18,8 @@
#include <linux/io.h>
#include <linux/fsl_devices.h>
#include <linux/fec.h>
+#include <linux/gpio_keys.h>
+#include <linux/input.h>
#include <mach/common.h>
#include <mach/hardware.h>
@@ -37,6 +39,7 @@
#define BABBAGE_USBH1_STP (0*32 + 27) /* GPIO_1_27 */
#define BABBAGE_PHY_RESET (1*32 + 5) /* GPIO_2_5 */
#define BABBAGE_FEC_PHY_RESET (1*32 + 14) /* GPIO_2_14 */
+#define BABBAGE_POWER_KEY (1*32 + 21) /* GPIO_2_21 */
/* USB_CTRL_1 */
#define MX51_USB_CTRL_1_OFFSET 0x10
@@ -46,6 +49,21 @@
#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 imx_button_data = {
+ .buttons = babbage_buttons,
+ .nbuttons = ARRAY_SIZE(babbage_buttons),
+};
+
static struct pad_desc mx51babbage_pads[] = {
/* UART1 */
MX51_PAD_UART1_RXD__UART1_RXD,
@@ -112,6 +130,9 @@ static struct pad_desc mx51babbage_pads[] = {
/* FEC PHY reset line */
MX51_PAD_EIM_A20__GPIO_2_14,
+
+ /* Power Key */
+ MX51_PAD_EIM_A27__GPIO_2_21,
};
/* Serial ports */
@@ -287,6 +308,7 @@ static void __init mxc_board_init(void)
mxc_init_imx_uart();
babbage_fec_reset();
imx51_add_fec(NULL);
+ imx51_add_buttons(&imx_button_data);
imx51_add_imx_i2c(0, &babbage_i2c_data);
imx51_add_imx_i2c(1, &babbage_i2c_data);
diff --git a/arch/arm/mach-mx5/devices-imx51.h b/arch/arm/mach-mx5/devices-imx51.h
index 5cc910e..a114d65 100644
--- a/arch/arm/mach-mx5/devices-imx51.h
+++ b/arch/arm/mach-mx5/devices-imx51.h
@@ -9,6 +9,8 @@
#include <mach/mx51.h>
#include <mach/devices-common.h>
+#define imx51_add_buttons(pdata) imx_add_buttons(pdata)
+
extern const struct imx_fec_data imx51_fec_data __initconst;
#define imx51_add_fec(pdata) \
imx_add_fec(&imx51_fec_data, pdata)
diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
index 4047994..dbd688b 100644
--- a/arch/arm/plat-mxc/devices/Kconfig
+++ b/arch/arm/plat-mxc/devices/Kconfig
@@ -23,3 +23,8 @@ config IMX_HAVE_PLATFORM_MXC_NAND
config IMX_HAVE_PLATFORM_SPI_IMX
bool
+
+config IMX_HAVE_PLATFORM_GPIO_BUTTONS
+ bool
+ default y if ARCH_MX51
+
diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
index 0a3c1f0..41008be 100644
--- a/arch/arm/plat-mxc/devices/Makefile
+++ b/arch/arm/plat-mxc/devices/Makefile
@@ -7,3 +7,4 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SSI) += platform-imx-ssi.o
obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_UART) += platform-imx-uart.o
obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_NAND) += platform-mxc_nand.o
obj-$(CONFIG_IMX_HAVE_PLATFORM_SPI_IMX) += platform-spi_imx.o
+obj-$(CONFIG_IMX_HAVE_PLATFORM_GPIO_BUTTONS) += platform-buttons.o
\ No newline at end of file
diff --git a/arch/arm/plat-mxc/devices/platform-buttons.c b/arch/arm/plat-mxc/devices/platform-buttons.c
new file mode 100644
index 0000000..23ceed8
--- /dev/null
+++ b/arch/arm/plat-mxc/devices/platform-buttons.c
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+#include <asm/sizes.h>
+#include <mach/hardware.h>
+#include <mach/devices-common.h>
+
+struct platform_device *__init imx_add_buttons(
+ const struct gpio_keys_platform_data *pdata)
+{
+
+ return imx_add_platform_device("gpio-keys", -1, NULL,
+ NULL, pdata, sizeof(*pdata));
+
+}
diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h
index 86d7575..0b37d6d 100644
--- a/arch/arm/plat-mxc/include/mach/devices-common.h
+++ b/arch/arm/plat-mxc/include/mach/devices-common.h
@@ -14,6 +14,10 @@ struct platform_device *imx_add_platform_device(const char *name, int id,
const struct resource *res, unsigned int num_resources,
const void *data, size_t size_data);
+#include <linux/gpio_keys.h>
+struct platform_device *__init imx_add_buttons(
+ const struct gpio_keys_platform_data *pdata);
+
#include <linux/fec.h>
struct imx_fec_data {
resource_size_t iobase;
diff --git a/arch/arm/plat-mxc/include/mach/iomux-mx51.h b/arch/arm/plat-mxc/include/mach/iomux-mx51.h
index e46b1c2..7ae27e8 100644
--- a/arch/arm/plat-mxc/include/mach/iomux-mx51.h
+++ b/arch/arm/plat-mxc/include/mach/iomux-mx51.h
@@ -114,7 +114,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_GPIO_PAD_CTRL | PAD_CTL_PUS_100K_UP)
#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] 8+ messages in thread
* [PATCHv4 2/2] ARM: imx: Add wake functionality to GPIO
2010-10-21 18:55 [PATCHv4 1/2] ARM: imx: Add gpio-keys to mx51 babbage board Dinh.Nguyen at freescale.com
@ 2010-10-21 18:55 ` Dinh.Nguyen at freescale.com
2010-10-21 19:14 ` Uwe Kleine-König
2010-10-21 19:10 ` [PATCHv4 1/2] ARM: imx: Add gpio-keys to mx51 babbage board Uwe Kleine-König
2010-10-22 10:47 ` Amit Kucheria
2 siblings, 1 reply; 8+ messages in thread
From: Dinh.Nguyen at freescale.com @ 2010-10-21 18:55 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.
This patch is based on Sascha Hauer's imx/linux-2.6 for-rmk tree.
This patch has been tested on a MX51 Babbage system that had suspend
code implemented. The set_wake implementation is necessary for a
GPIO to wake up a system from suspend.
Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
---
arch/arm/plat-mxc/gpio.c | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/arch/arm/plat-mxc/gpio.c b/arch/arm/plat-mxc/gpio.c
index 9d38da0..9c3e362 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,42 @@ 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) {
+ if (port->irq_high && (gpio_idx >= 16))
+ enable_irq_wake(port->irq_high);
+ else
+ enable_irq_wake(port->irq);
+ } else {
+ 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,
--
1.6.0.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCHv4 1/2] ARM: imx: Add gpio-keys to mx51 babbage board
2010-10-21 18:55 [PATCHv4 1/2] ARM: imx: Add gpio-keys to mx51 babbage board Dinh.Nguyen at freescale.com
2010-10-21 18:55 ` [PATCHv4 2/2] ARM: imx: Add wake functionality to GPIO Dinh.Nguyen at freescale.com
@ 2010-10-21 19:10 ` Uwe Kleine-König
2010-10-22 16:32 ` Nguyen Dinh-R00091
2010-10-22 10:47 ` Amit Kucheria
2 siblings, 1 reply; 8+ messages in thread
From: Uwe Kleine-König @ 2010-10-21 19:10 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Oct 21, 2010 at 01:55:23PM -0500, Dinh.Nguyen at freescale.com wrote:
> From: Dinh Nguyen <Dinh.Nguyen@freescale.com>
>
> Add functionality for the power button on MX51 Babbage board.
>
> This patch is based on Sascha Hauer's imx/linux-2.6 for-rmk tree.
>
> Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
> ---
> arch/arm/configs/mx51_defconfig | 1 +
> arch/arm/mach-mx5/board-mx51_babbage.c | 22 +++++++++++++++++
> arch/arm/mach-mx5/devices-imx51.h | 2 +
> arch/arm/plat-mxc/devices/Kconfig | 5 ++++
> arch/arm/plat-mxc/devices/Makefile | 1 +
> arch/arm/plat-mxc/devices/platform-buttons.c | 29 +++++++++++++++++++++++
> arch/arm/plat-mxc/include/mach/devices-common.h | 4 +++
> arch/arm/plat-mxc/include/mach/iomux-mx51.h | 2 +-
> 8 files changed, 65 insertions(+), 1 deletions(-)
> create mode 100644 arch/arm/plat-mxc/devices/platform-buttons.c
>
> diff --git a/arch/arm/configs/mx51_defconfig b/arch/arm/configs/mx51_defconfig
> index 163cfee..5c7a872 100644
> --- a/arch/arm/configs/mx51_defconfig
> +++ b/arch/arm/configs/mx51_defconfig
> @@ -82,6 +82,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 23ee4a4..f6ce0d6 100644
> --- a/arch/arm/mach-mx5/board-mx51_babbage.c
> +++ b/arch/arm/mach-mx5/board-mx51_babbage.c
> @@ -18,6 +18,8 @@
> #include <linux/io.h>
> #include <linux/fsl_devices.h>
> #include <linux/fec.h>
> +#include <linux/gpio_keys.h>
> +#include <linux/input.h>
>
> #include <mach/common.h>
> #include <mach/hardware.h>
> @@ -37,6 +39,7 @@
> #define BABBAGE_USBH1_STP (0*32 + 27) /* GPIO_1_27 */
> #define BABBAGE_PHY_RESET (1*32 + 5) /* GPIO_2_5 */
> #define BABBAGE_FEC_PHY_RESET (1*32 + 14) /* GPIO_2_14 */
> +#define BABBAGE_POWER_KEY (1*32 + 21) /* GPIO_2_21 */
>
> /* USB_CTRL_1 */
> #define MX51_USB_CTRL_1_OFFSET 0x10
> @@ -46,6 +49,21 @@
> #define MX51_USB_PLL_DIV_19_2_MHZ 0x01
> #define MX51_USB_PLL_DIV_24_MHZ 0x02
>
> +static struct gpio_keys_button babbage_buttons[] = {
const? (Maybe gpio_keys_platform_data has to be changed for that.)
> + {
> + .gpio = BABBAGE_POWER_KEY,
> + .code = BTN_0,
> + .desc = "PWR",
> + .active_low = 1,
> + .wakeup = 1,
> + },
> +};
> +
> +static struct gpio_keys_platform_data imx_button_data = {
const and __initconst please
> + .buttons = babbage_buttons,
> + .nbuttons = ARRAY_SIZE(babbage_buttons),
> +};
> +
> static struct pad_desc mx51babbage_pads[] = {
> /* UART1 */
> MX51_PAD_UART1_RXD__UART1_RXD,
> @@ -112,6 +130,9 @@ static struct pad_desc mx51babbage_pads[] = {
>
> /* FEC PHY reset line */
> MX51_PAD_EIM_A20__GPIO_2_14,
> +
> + /* Power Key */
> + MX51_PAD_EIM_A27__GPIO_2_21,
> };
>
> /* Serial ports */
> @@ -287,6 +308,7 @@ static void __init mxc_board_init(void)
> mxc_init_imx_uart();
> babbage_fec_reset();
> imx51_add_fec(NULL);
> + imx51_add_buttons(&imx_button_data);
>
> imx51_add_imx_i2c(0, &babbage_i2c_data);
> imx51_add_imx_i2c(1, &babbage_i2c_data);
> diff --git a/arch/arm/mach-mx5/devices-imx51.h b/arch/arm/mach-mx5/devices-imx51.h
> index 5cc910e..a114d65 100644
> --- a/arch/arm/mach-mx5/devices-imx51.h
> +++ b/arch/arm/mach-mx5/devices-imx51.h
> @@ -9,6 +9,8 @@
> #include <mach/mx51.h>
> #include <mach/devices-common.h>
>
> +#define imx51_add_buttons(pdata) imx_add_buttons(pdata)
> +
> extern const struct imx_fec_data imx51_fec_data __initconst;
> #define imx51_add_fec(pdata) \
> imx_add_fec(&imx51_fec_data, pdata)
> diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
> index 4047994..dbd688b 100644
> --- a/arch/arm/plat-mxc/devices/Kconfig
> +++ b/arch/arm/plat-mxc/devices/Kconfig
> @@ -23,3 +23,8 @@ config IMX_HAVE_PLATFORM_MXC_NAND
>
> config IMX_HAVE_PLATFORM_SPI_IMX
> bool
> +
> +config IMX_HAVE_PLATFORM_GPIO_BUTTONS
> + bool
> + default y if ARCH_MX51
> +
> diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
> index 0a3c1f0..41008be 100644
> --- a/arch/arm/plat-mxc/devices/Makefile
> +++ b/arch/arm/plat-mxc/devices/Makefile
> @@ -7,3 +7,4 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SSI) += platform-imx-ssi.o
> obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_UART) += platform-imx-uart.o
> obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_NAND) += platform-mxc_nand.o
> obj-$(CONFIG_IMX_HAVE_PLATFORM_SPI_IMX) += platform-spi_imx.o
> +obj-$(CONFIG_IMX_HAVE_PLATFORM_GPIO_BUTTONS) += platform-buttons.o
> \ No newline at end of file
This file is supposed to be ordered alphabetically and to have a newline
at the end of file.
> diff --git a/arch/arm/plat-mxc/devices/platform-buttons.c b/arch/arm/plat-mxc/devices/platform-buttons.c
> new file mode 100644
> index 0000000..23ceed8
> --- /dev/null
> +++ b/arch/arm/plat-mxc/devices/platform-buttons.c
> @@ -0,0 +1,29 @@
> +/*
> + * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version 2
> + * of the License, or (at your option) any later version.
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
> + * Boston, MA 02110-1301, USA.
> + */
> +#include <asm/sizes.h>
> +#include <mach/hardware.h>
> +#include <mach/devices-common.h>
> +
> +struct platform_device *__init imx_add_buttons(
I'd like to have that function named imx_add_gpio_keys to match the
device name (as good as possible).
> + const struct gpio_keys_platform_data *pdata)
> +{
> +
> + return imx_add_platform_device("gpio-keys", -1, NULL,
> + NULL, pdata, sizeof(*pdata));
> +
> +}
> diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h
> index 86d7575..0b37d6d 100644
> --- a/arch/arm/plat-mxc/include/mach/devices-common.h
> +++ b/arch/arm/plat-mxc/include/mach/devices-common.h
> @@ -14,6 +14,10 @@ struct platform_device *imx_add_platform_device(const char *name, int id,
> const struct resource *res, unsigned int num_resources,
> const void *data, size_t size_data);
>
> +#include <linux/gpio_keys.h>
> +struct platform_device *__init imx_add_buttons(
> + const struct gpio_keys_platform_data *pdata);
> +
> #include <linux/fec.h>
> struct imx_fec_data {
> resource_size_t iobase;
> diff --git a/arch/arm/plat-mxc/include/mach/iomux-mx51.h b/arch/arm/plat-mxc/include/mach/iomux-mx51.h
> index e46b1c2..7ae27e8 100644
> --- a/arch/arm/plat-mxc/include/mach/iomux-mx51.h
> +++ b/arch/arm/plat-mxc/include/mach/iomux-mx51.h
> @@ -114,7 +114,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_GPIO_PAD_CTRL | PAD_CTL_PUS_100K_UP)
Is this a generic change valid for all mx51 machines or only for the
babbage board?
> #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
--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCHv4 2/2] ARM: imx: Add wake functionality to GPIO
2010-10-21 18:55 ` [PATCHv4 2/2] ARM: imx: Add wake functionality to GPIO Dinh.Nguyen at freescale.com
@ 2010-10-21 19:14 ` Uwe Kleine-König
2010-10-21 19:37 ` Nguyen Dinh-R00091
0 siblings, 1 reply; 8+ messages in thread
From: Uwe Kleine-König @ 2010-10-21 19:14 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Oct 21, 2010 at 01:55:24PM -0500, Dinh.Nguyen at freescale.com wrote:
> From: Dinh Nguyen <Dinh.Nguyen@freescale.com>
>
> Add function definition for irq_chip.set_wake to enable GPIO to
> wake-up the system.
>
> This patch is based on Sascha Hauer's imx/linux-2.6 for-rmk tree.
>
> This patch has been tested on a MX51 Babbage system that had suspend
> code implemented. The set_wake implementation is necessary for a
> GPIO to wake up a system from suspend.
>
> Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
> ---
> arch/arm/plat-mxc/gpio.c | 32 ++++++++++++++++++++++++++++++++
> 1 files changed, 32 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/plat-mxc/gpio.c b/arch/arm/plat-mxc/gpio.c
> index 9d38da0..9c3e362 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,42 @@ 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) {
> + if (port->irq_high && (gpio_idx >= 16))
> + enable_irq_wake(port->irq_high);
> + else
> + enable_irq_wake(port->irq);
> + } else {
> + if (port->irq_high && (gpio_idx >= 16))
> + disable_irq_wake(port->irq_high);
> + else
> + disable_irq_wake(port->irq);
> + }
> +
> + return 0;
> +}
> +
Is this really enough to let the CPU wake up? Is this implementation
correct for all i.MX SoCs?
Best regards
Uwe
> 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,
> --
> 1.6.0.4
>
>
>
--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCHv4 2/2] ARM: imx: Add wake functionality to GPIO
2010-10-21 19:14 ` Uwe Kleine-König
@ 2010-10-21 19:37 ` Nguyen Dinh-R00091
0 siblings, 0 replies; 8+ messages in thread
From: Nguyen Dinh-R00091 @ 2010-10-21 19:37 UTC (permalink / raw)
To: linux-arm-kernel
Hi Uwe,
>-----Original Message-----
>From: Uwe Kleine-K?nig [mailto:u.kleine-koenig at pengutronix.de]
>Sent: Thursday, October 21, 2010 2:15 PM
>To: Nguyen Dinh-R00091
>Cc: linux-kernel at vger.kernel.org; linux-arm-kernel at lists.infradead.org; linux at arm.linux.org.uk;
>s.hauer at pengutronix.de; valentin.longchamp at epfl.ch; daniel at caiaq.de; grant.likely at secretlab.ca;
>bryan.wu at canonical.com; amit.kucheria at canonical.com; Zhang Lily-R58066
>Subject: Re: [PATCHv4 2/2] ARM: imx: Add wake functionality to GPIO
>
>On Thu, Oct 21, 2010 at 01:55:24PM -0500, Dinh.Nguyen at freescale.com wrote:
>> From: Dinh Nguyen <Dinh.Nguyen@freescale.com>
>>
>> Add function definition for irq_chip.set_wake to enable GPIO to
>> wake-up the system.
>>
>> This patch is based on Sascha Hauer's imx/linux-2.6 for-rmk tree.
>>
>> This patch has been tested on a MX51 Babbage system that had suspend
>> code implemented. The set_wake implementation is necessary for a
>> GPIO to wake up a system from suspend.
>>
>> Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
>> ---
>> arch/arm/plat-mxc/gpio.c | 32 ++++++++++++++++++++++++++++++++
>> 1 files changed, 32 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/arm/plat-mxc/gpio.c b/arch/arm/plat-mxc/gpio.c
>> index 9d38da0..9c3e362 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,42 @@ 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) {
>> + if (port->irq_high && (gpio_idx >= 16))
>> + enable_irq_wake(port->irq_high);
>> + else
>> + enable_irq_wake(port->irq);
>> + } else {
>> + if (port->irq_high && (gpio_idx >= 16))
>> + disable_irq_wake(port->irq_high);
>> + else
>> + disable_irq_wake(port->irq);
>> + }
>> +
>> + return 0;
>> +}
>> +
>Is this really enough to let the CPU wake up? Is this implementation
>correct for all i.MX SoCs?
I tested the code to wakeup from suspend on my MX51 Babbage board, without this code the power button on the Babbage board will not wakeup the system. It appears that in the gpio-keys.c, gpio_keys_suspend() will call the enable_irq_wake, which then will call the GPIO's set_wake function on the GPIO pin. This implementation should be correct for all i.MX SoCs.
>
>Best regards
>Uwe
>
>> 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,
>> --
>> 1.6.0.4
>>
>>
>>
>
>--
>Pengutronix e.K. | Uwe Kleine-K?nig |
>Industrial Linux Solutions | http://www.pengutronix.de/ |
Thanks,
Dinh
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCHv4 1/2] ARM: imx: Add gpio-keys to mx51 babbage board
2010-10-21 18:55 [PATCHv4 1/2] ARM: imx: Add gpio-keys to mx51 babbage board Dinh.Nguyen at freescale.com
2010-10-21 18:55 ` [PATCHv4 2/2] ARM: imx: Add wake functionality to GPIO Dinh.Nguyen at freescale.com
2010-10-21 19:10 ` [PATCHv4 1/2] ARM: imx: Add gpio-keys to mx51 babbage board Uwe Kleine-König
@ 2010-10-22 10:47 ` Amit Kucheria
2 siblings, 0 replies; 8+ messages in thread
From: Amit Kucheria @ 2010-10-22 10:47 UTC (permalink / raw)
To: linux-arm-kernel
Dinh,
The platform code should be separated from the board-specific code.
Can you split this into two patches?
Regards,
Amit
On 10 Oct 21, Dinh.Nguyen at freescale.com wrote:
> From: Dinh Nguyen <Dinh.Nguyen@freescale.com>
>
> Add functionality for the power button on MX51 Babbage board.
>
> This patch is based on Sascha Hauer's imx/linux-2.6 for-rmk tree.
>
> Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
> ---
> arch/arm/configs/mx51_defconfig | 1 +
> arch/arm/mach-mx5/board-mx51_babbage.c | 22 +++++++++++++++++
> arch/arm/mach-mx5/devices-imx51.h | 2 +
> arch/arm/plat-mxc/devices/Kconfig | 5 ++++
> arch/arm/plat-mxc/devices/Makefile | 1 +
> arch/arm/plat-mxc/devices/platform-buttons.c | 29 +++++++++++++++++++++++
> arch/arm/plat-mxc/include/mach/devices-common.h | 4 +++
> arch/arm/plat-mxc/include/mach/iomux-mx51.h | 2 +-
> 8 files changed, 65 insertions(+), 1 deletions(-)
> create mode 100644 arch/arm/plat-mxc/devices/platform-buttons.c
>
> diff --git a/arch/arm/configs/mx51_defconfig b/arch/arm/configs/mx51_defconfig
> index 163cfee..5c7a872 100644
> --- a/arch/arm/configs/mx51_defconfig
> +++ b/arch/arm/configs/mx51_defconfig
> @@ -82,6 +82,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 23ee4a4..f6ce0d6 100644
> --- a/arch/arm/mach-mx5/board-mx51_babbage.c
> +++ b/arch/arm/mach-mx5/board-mx51_babbage.c
> @@ -18,6 +18,8 @@
> #include <linux/io.h>
> #include <linux/fsl_devices.h>
> #include <linux/fec.h>
> +#include <linux/gpio_keys.h>
> +#include <linux/input.h>
>
> #include <mach/common.h>
> #include <mach/hardware.h>
> @@ -37,6 +39,7 @@
> #define BABBAGE_USBH1_STP (0*32 + 27) /* GPIO_1_27 */
> #define BABBAGE_PHY_RESET (1*32 + 5) /* GPIO_2_5 */
> #define BABBAGE_FEC_PHY_RESET (1*32 + 14) /* GPIO_2_14 */
> +#define BABBAGE_POWER_KEY (1*32 + 21) /* GPIO_2_21 */
>
> /* USB_CTRL_1 */
> #define MX51_USB_CTRL_1_OFFSET 0x10
> @@ -46,6 +49,21 @@
> #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 imx_button_data = {
> + .buttons = babbage_buttons,
> + .nbuttons = ARRAY_SIZE(babbage_buttons),
> +};
> +
> static struct pad_desc mx51babbage_pads[] = {
> /* UART1 */
> MX51_PAD_UART1_RXD__UART1_RXD,
> @@ -112,6 +130,9 @@ static struct pad_desc mx51babbage_pads[] = {
>
> /* FEC PHY reset line */
> MX51_PAD_EIM_A20__GPIO_2_14,
> +
> + /* Power Key */
> + MX51_PAD_EIM_A27__GPIO_2_21,
> };
>
> /* Serial ports */
> @@ -287,6 +308,7 @@ static void __init mxc_board_init(void)
> mxc_init_imx_uart();
> babbage_fec_reset();
> imx51_add_fec(NULL);
> + imx51_add_buttons(&imx_button_data);
>
> imx51_add_imx_i2c(0, &babbage_i2c_data);
> imx51_add_imx_i2c(1, &babbage_i2c_data);
> diff --git a/arch/arm/mach-mx5/devices-imx51.h b/arch/arm/mach-mx5/devices-imx51.h
> index 5cc910e..a114d65 100644
> --- a/arch/arm/mach-mx5/devices-imx51.h
> +++ b/arch/arm/mach-mx5/devices-imx51.h
> @@ -9,6 +9,8 @@
> #include <mach/mx51.h>
> #include <mach/devices-common.h>
>
> +#define imx51_add_buttons(pdata) imx_add_buttons(pdata)
> +
> extern const struct imx_fec_data imx51_fec_data __initconst;
> #define imx51_add_fec(pdata) \
> imx_add_fec(&imx51_fec_data, pdata)
> diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
> index 4047994..dbd688b 100644
> --- a/arch/arm/plat-mxc/devices/Kconfig
> +++ b/arch/arm/plat-mxc/devices/Kconfig
> @@ -23,3 +23,8 @@ config IMX_HAVE_PLATFORM_MXC_NAND
>
> config IMX_HAVE_PLATFORM_SPI_IMX
> bool
> +
> +config IMX_HAVE_PLATFORM_GPIO_BUTTONS
> + bool
> + default y if ARCH_MX51
> +
> diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
> index 0a3c1f0..41008be 100644
> --- a/arch/arm/plat-mxc/devices/Makefile
> +++ b/arch/arm/plat-mxc/devices/Makefile
> @@ -7,3 +7,4 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SSI) += platform-imx-ssi.o
> obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_UART) += platform-imx-uart.o
> obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_NAND) += platform-mxc_nand.o
> obj-$(CONFIG_IMX_HAVE_PLATFORM_SPI_IMX) += platform-spi_imx.o
> +obj-$(CONFIG_IMX_HAVE_PLATFORM_GPIO_BUTTONS) += platform-buttons.o
> \ No newline at end of file
> diff --git a/arch/arm/plat-mxc/devices/platform-buttons.c b/arch/arm/plat-mxc/devices/platform-buttons.c
> new file mode 100644
> index 0000000..23ceed8
> --- /dev/null
> +++ b/arch/arm/plat-mxc/devices/platform-buttons.c
> @@ -0,0 +1,29 @@
> +/*
> + * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version 2
> + * of the License, or (at your option) any later version.
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
> + * Boston, MA 02110-1301, USA.
> + */
> +#include <asm/sizes.h>
> +#include <mach/hardware.h>
> +#include <mach/devices-common.h>
> +
> +struct platform_device *__init imx_add_buttons(
> + const struct gpio_keys_platform_data *pdata)
> +{
> +
> + return imx_add_platform_device("gpio-keys", -1, NULL,
> + NULL, pdata, sizeof(*pdata));
> +
> +}
> diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h
> index 86d7575..0b37d6d 100644
> --- a/arch/arm/plat-mxc/include/mach/devices-common.h
> +++ b/arch/arm/plat-mxc/include/mach/devices-common.h
> @@ -14,6 +14,10 @@ struct platform_device *imx_add_platform_device(const char *name, int id,
> const struct resource *res, unsigned int num_resources,
> const void *data, size_t size_data);
>
> +#include <linux/gpio_keys.h>
> +struct platform_device *__init imx_add_buttons(
> + const struct gpio_keys_platform_data *pdata);
> +
> #include <linux/fec.h>
> struct imx_fec_data {
> resource_size_t iobase;
> diff --git a/arch/arm/plat-mxc/include/mach/iomux-mx51.h b/arch/arm/plat-mxc/include/mach/iomux-mx51.h
> index e46b1c2..7ae27e8 100644
> --- a/arch/arm/plat-mxc/include/mach/iomux-mx51.h
> +++ b/arch/arm/plat-mxc/include/mach/iomux-mx51.h
> @@ -114,7 +114,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_GPIO_PAD_CTRL | PAD_CTL_PUS_100K_UP)
> #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
>
>
--
----------------------------------------------------------------------
Amit Kucheria, Kernel Engineer || amit.kucheria at canonical.com
----------------------------------------------------------------------
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCHv4 1/2] ARM: imx: Add gpio-keys to mx51 babbage board
2010-10-21 19:10 ` [PATCHv4 1/2] ARM: imx: Add gpio-keys to mx51 babbage board Uwe Kleine-König
@ 2010-10-22 16:32 ` Nguyen Dinh-R00091
2010-10-22 17:07 ` Arnaud Patard (Rtp)
0 siblings, 1 reply; 8+ messages in thread
From: Nguyen Dinh-R00091 @ 2010-10-22 16:32 UTC (permalink / raw)
To: linux-arm-kernel
Hi Uwe,
>-----Original Message-----
>From: Uwe Kleine-K?nig [mailto:u.kleine-koenig at pengutronix.de]
>Sent: Thursday, October 21, 2010 2:10 PM
>To: Nguyen Dinh-R00091
>Cc: linux-kernel at vger.kernel.org; linux-arm-kernel at lists.infradead.org; linux at arm.linux.org.uk;
>s.hauer at pengutronix.de; valentin.longchamp at epfl.ch; daniel at caiaq.de; grant.likely at secretlab.ca;
>bryan.wu at canonical.com; amit.kucheria at canonical.com; Zhang Lily-R58066
>Subject: Re: [PATCHv4 1/2] ARM: imx: Add gpio-keys to mx51 babbage board
>
>On Thu, Oct 21, 2010 at 01:55:23PM -0500, Dinh.Nguyen at freescale.com wrote:
>> From: Dinh Nguyen <Dinh.Nguyen@freescale.com>
>>
>> Add functionality for the power button on MX51 Babbage board.
>>
>> This patch is based on Sascha Hauer's imx/linux-2.6 for-rmk tree.
>>
>> Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
>> ---
>> arch/arm/configs/mx51_defconfig | 1 +
>> arch/arm/mach-mx5/board-mx51_babbage.c | 22 +++++++++++++++++
>> arch/arm/mach-mx5/devices-imx51.h | 2 +
>> arch/arm/plat-mxc/devices/Kconfig | 5 ++++
>> arch/arm/plat-mxc/devices/Makefile | 1 +
>> arch/arm/plat-mxc/devices/platform-buttons.c | 29 +++++++++++++++++++++++
>> arch/arm/plat-mxc/include/mach/devices-common.h | 4 +++
>> arch/arm/plat-mxc/include/mach/iomux-mx51.h | 2 +-
>> 8 files changed, 65 insertions(+), 1 deletions(-)
>> create mode 100644 arch/arm/plat-mxc/devices/platform-buttons.c
>>
>> diff --git a/arch/arm/configs/mx51_defconfig b/arch/arm/configs/mx51_defconfig
>> index 163cfee..5c7a872 100644
>> --- a/arch/arm/configs/mx51_defconfig
>> +++ b/arch/arm/configs/mx51_defconfig
>> @@ -82,6 +82,7 @@ CONFIG_FEC=y
>> CONFIG_INPUT_FF_MEMLESS=m
>>
>> /* USB_CTRL_1 */
>> #define MX51_USB_CTRL_1_OFFSET 0x10
>> @@ -46,6 +49,21 @@
>> #define MX51_USB_PLL_DIV_19_2_MHZ 0x01
>> #define MX51_USB_PLL_DIV_24_MHZ 0x02
>>
>> +static struct gpio_keys_button babbage_buttons[] = {
>const? (Maybe gpio_keys_platform_data has to be changed for that.)
>> + {
>> + .gpio = BABBAGE_POWER_KEY,
>> + .code = BTN_0,
>> + .desc = "PWR",
>> + .active_low = 1,
>> + .wakeup = 1,
>> + },
>> +};
>> +
>> +static struct gpio_keys_platform_data imx_button_data = {
>const and __initconst please
>
>> + .buttons = babbage_buttons,
>> + .nbuttons = ARRAY_SIZE(babbage_buttons),
>> +};
>> +
>> static struct pad_desc mx51babbage_pads[] = {
>> /* UART1 */
>> MX51_PAD_UART1_RXD__UART1_RXD,
>> @@ -112,6 +130,9 @@ static struct pad_desc mx51babbage_pads[] = {
>>
>> /* FEC PHY reset line */
>> MX51_PAD_EIM_A20__GPIO_2_14,
>> +
>> + /* Power Key */
>> + MX51_PAD_EIM_A27__GPIO_2_21,
>> };
>>
>> /* Serial ports */
>> @@ -287,6 +308,7 @@ static void __init mxc_board_init(void)
>> mxc_init_imx_uart();
>> babbage_fec_reset();
>> imx51_add_fec(NULL);
>> + imx51_add_buttons(&imx_button_data);
>>
>> imx51_add_imx_i2c(0, &babbage_i2c_data);
>> imx51_add_imx_i2c(1, &babbage_i2c_data);
>> diff --git a/arch/arm/mach-mx5/devices-imx51.h b/arch/arm/mach-mx5/devices-imx51.h
>> index 5cc910e..a114d65 100644
>> --- a/arch/arm/mach-mx5/devices-imx51.h
>> +++ b/arch/arm/mach-mx5/devices-imx51.h
>> @@ -9,6 +9,8 @@
>> #include <mach/mx51.h>
>> #include <mach/devices-common.h>
>>
>> +#define imx51_add_buttons(pdata) imx_add_buttons(pdata)
>> +
>> extern const struct imx_fec_data imx51_fec_data __initconst;
>> #define imx51_add_fec(pdata) \
>> imx_add_fec(&imx51_fec_data, pdata)
>> diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
>> index 4047994..dbd688b 100644
>> --- a/arch/arm/plat-mxc/devices/Kconfig
>> +++ b/arch/arm/plat-mxc/devices/Kconfig
>> @@ -23,3 +23,8 @@ config IMX_HAVE_PLATFORM_MXC_NAND
>>
>> config IMX_HAVE_PLATFORM_SPI_IMX
>> bool
>> +
>> +config IMX_HAVE_PLATFORM_GPIO_BUTTONS
>> + bool
>> + default y if ARCH_MX51
>> +
>> diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
>> index 0a3c1f0..41008be 100644
>> --- a/arch/arm/plat-mxc/devices/Makefile
>> +++ b/arch/arm/plat-mxc/devices/Makefile
>> @@ -7,3 +7,4 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SSI) += platform-imx-ssi.o
>> obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_UART) += platform-imx-uart.o
>> obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_NAND) += platform-mxc_nand.o
>> obj-$(CONFIG_IMX_HAVE_PLATFORM_SPI_IMX) += platform-spi_imx.o
>> +obj-$(CONFIG_IMX_HAVE_PLATFORM_GPIO_BUTTONS) += platform-buttons.o
>> \ No newline at end of file
>This file is supposed to be ordered alphabetically and to have a newline
>at the end of file.
>
>> diff --git a/arch/arm/plat-mxc/devices/platform-buttons.c b/arch/arm/plat-mxc/devices/platform-
>buttons.c
>> new file mode 100644
>> index 0000000..23ceed8
>> --- /dev/null
>> +++ b/arch/arm/plat-mxc/devices/platform-buttons.c
>> @@ -0,0 +1,29 @@
>> +/*
>> + * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
>> + *
>> + * This program is free software; you can redistribute it and/or
>> + * modify it under the terms of the GNU General Public License
>> + * as published by the Free Software Foundation; either version 2
>> + * of the License, or (at your option) any later version.
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>> + * GNU General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU General Public License
>> + * along with this program; if not, write to the Free Software
>> + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
>> + * Boston, MA 02110-1301, USA.
>> + */
>> +#include <asm/sizes.h>
>> +#include <mach/hardware.h>
>> +#include <mach/devices-common.h>
>> +
>> +struct platform_device *__init imx_add_buttons(
>I'd like to have that function named imx_add_gpio_keys to match the
>device name (as good as possible).
>
>> + const struct gpio_keys_platform_data *pdata)
>> +{
>> +
>> + return imx_add_platform_device("gpio-keys", -1, NULL,
>> + NULL, pdata, sizeof(*pdata));
>> +
>> +}
>> diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-
>mxc/include/mach/devices-common.h
>> index 86d7575..0b37d6d 100644
>> --- a/arch/arm/plat-mxc/include/mach/devices-common.h
>> +++ b/arch/arm/plat-mxc/include/mach/devices-common.h
>> @@ -14,6 +14,10 @@ struct platform_device *imx_add_platform_device(const char *name, int id,
>> const struct resource *res, unsigned int num_resources,
>> const void *data, size_t size_data);
>>
>> +#include <linux/gpio_keys.h>
>> +struct platform_device *__init imx_add_buttons(
>> + const struct gpio_keys_platform_data *pdata);
>> +
>> #include <linux/fec.h>
>> struct imx_fec_data {
>> resource_size_t iobase;
>> diff --git a/arch/arm/plat-mxc/include/mach/iomux-mx51.h b/arch/arm/plat-mxc/include/mach/iomux-
>mx51.h
>> index e46b1c2..7ae27e8 100644
>> --- a/arch/arm/plat-mxc/include/mach/iomux-mx51.h
>> +++ b/arch/arm/plat-mxc/include/mach/iomux-mx51.h
>> @@ -114,7 +114,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_GPIO_PAD_CTRL | PAD_CTL_PUS_100K_UP)
>Is this a generic change valid for all mx51 machines or only for the
>babbage board?
This is a change that is probably valid for all mx51 machines, but I have only tested on Babbage.
>
>> #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
>
>--
>Pengutronix e.K. | Uwe Kleine-K?nig |
>Industrial Linux Solutions | http://www.pengutronix.de/ |
Thanks,
Dinh
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCHv4 1/2] ARM: imx: Add gpio-keys to mx51 babbage board
2010-10-22 16:32 ` Nguyen Dinh-R00091
@ 2010-10-22 17:07 ` Arnaud Patard (Rtp)
0 siblings, 0 replies; 8+ messages in thread
From: Arnaud Patard (Rtp) @ 2010-10-22 17:07 UTC (permalink / raw)
To: linux-arm-kernel
Nguyen Dinh-R00091 <R00091@freescale.com> writes:
Hi,
[...]
>>> index e46b1c2..7ae27e8 100644
>>> --- a/arch/arm/plat-mxc/include/mach/iomux-mx51.h
>>> +++ b/arch/arm/plat-mxc/include/mach/iomux-mx51.h
>>> @@ -114,7 +114,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_GPIO_PAD_CTRL | PAD_CTL_PUS_100K_UP)
>>Is this a generic change valid for all mx51 machines or only for the
>>babbage board?
>
> This is a change that is probably valid for all mx51 machines, but I have only tested on Babbage.
While I agree to change from NO_PAD_CTRL to MX51_GPIO_PAD_CTRL, I
believe that adding PAD_CTRL_PUS_100K_UP is not valid for all
machines. For instance, one may want PAD_CTL_PUS_47K_UP or no
pull-up at all because one has been added on the board.
Also, if it's generic, I'll be happy to understand why it has not been
added to MX51_GPIO_PAD_CTRL when MX51_GPIO_PAD_CTRL was added.
Regards,
Arnaud
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-10-22 17:07 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-21 18:55 [PATCHv4 1/2] ARM: imx: Add gpio-keys to mx51 babbage board Dinh.Nguyen at freescale.com
2010-10-21 18:55 ` [PATCHv4 2/2] ARM: imx: Add wake functionality to GPIO Dinh.Nguyen at freescale.com
2010-10-21 19:14 ` Uwe Kleine-König
2010-10-21 19:37 ` Nguyen Dinh-R00091
2010-10-21 19:10 ` [PATCHv4 1/2] ARM: imx: Add gpio-keys to mx51 babbage board Uwe Kleine-König
2010-10-22 16:32 ` Nguyen Dinh-R00091
2010-10-22 17:07 ` Arnaud Patard (Rtp)
2010-10-22 10:47 ` Amit Kucheria
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox