All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv5 1/3] ARM: mx5: Add gpio-keys to mx51 babbage board
@ 2010-10-22 16:56 ` Dinh.Nguyen at freescale.com
  0 siblings, 0 replies; 32+ messages in thread
From: Dinh.Nguyen @ 2010-10-22 16:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arm-kernel, linux, s.hauer, u.kleine-koenig,
	valentin.longchamp, daniel, grant.likely, bryan.wu,
	amit.kucheria, Dinh Nguyen

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 ++
 3 files changed, 25 insertions(+), 0 deletions(-)

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..8458852 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 const struct gpio_keys_platform_data imx_button_data __initconst = {
+	.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_gpio_keys(&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..8c50cb5 100644
--- a/arch/arm/mach-mx5/devices-imx51.h
+++ b/arch/arm/mach-mx5/devices-imx51.h
@@ -13,6 +13,8 @@ extern const struct imx_fec_data imx51_fec_data __initconst;
 #define imx51_add_fec(pdata)	\
 	imx_add_fec(&imx51_fec_data, pdata)
 
+#define imx51_add_gpio_keys(pdata) imx_add_gpio_keys(pdata)
+
 extern const struct imx_imx_i2c_data imx51_imx_i2c_data[] __initconst;
 #define imx51_add_imx_i2c(id, pdata)	\
 	imx_add_imx_i2c(&imx51_imx_i2c_data[id], pdata)
-- 
1.6.0.4



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCHv5 1/3] ARM: mx5: Add gpio-keys to mx51 babbage board
@ 2010-10-22 16:56 ` Dinh.Nguyen at freescale.com
  0 siblings, 0 replies; 32+ messages in thread
From: Dinh.Nguyen at freescale.com @ 2010-10-22 16:56 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 ++
 3 files changed, 25 insertions(+), 0 deletions(-)

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..8458852 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 const struct gpio_keys_platform_data imx_button_data __initconst = {
+	.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_gpio_keys(&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..8c50cb5 100644
--- a/arch/arm/mach-mx5/devices-imx51.h
+++ b/arch/arm/mach-mx5/devices-imx51.h
@@ -13,6 +13,8 @@ extern const struct imx_fec_data imx51_fec_data __initconst;
 #define imx51_add_fec(pdata)	\
 	imx_add_fec(&imx51_fec_data, pdata)
 
+#define imx51_add_gpio_keys(pdata) imx_add_gpio_keys(pdata)
+
 extern const struct imx_imx_i2c_data imx51_imx_i2c_data[] __initconst;
 #define imx51_add_imx_i2c(id, pdata)	\
 	imx_add_imx_i2c(&imx51_imx_i2c_data[id], pdata)
-- 
1.6.0.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
  2010-10-22 16:56 ` Dinh.Nguyen at freescale.com
@ 2010-10-22 16:56   ` Dinh.Nguyen at freescale.com
  -1 siblings, 0 replies; 32+ messages in thread
From: Dinh.Nguyen @ 2010-10-22 16:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arm-kernel, linux, s.hauer, u.kleine-koenig,
	valentin.longchamp, daniel, grant.likely, bryan.wu,
	amit.kucheria, Dinh Nguyen

From: Dinh Nguyen <Dinh.Nguyen@freescale.com>

Add imx_add_gpio_keys function to add gpio-keys in plat-mxc

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/plat-mxc/devices/Kconfig               |    4 +++
 arch/arm/plat-mxc/devices/Makefile              |    1 +
 arch/arm/plat-mxc/devices/platform-gpio_keys.c  |   27 +++++++++++++++++++++++
 arch/arm/plat-mxc/include/mach/devices-common.h |    4 +++
 arch/arm/plat-mxc/include/mach/iomux-mx51.h     |    2 +-
 5 files changed, 37 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/plat-mxc/devices/platform-gpio_keys.c

diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
index 4047994..f4772e7 100644
--- a/arch/arm/plat-mxc/devices/Kconfig
+++ b/arch/arm/plat-mxc/devices/Kconfig
@@ -9,6 +9,10 @@ config IMX_HAVE_PLATFORM_FLEXCAN
 	select HAVE_CAN_FLEXCAN
 	bool
 
+config IMX_HAVE_PLATFORM_GPIO_KEYS
+	bool
+	default y if ARCH_MX51
+	
 config IMX_HAVE_PLATFORM_IMX_I2C
 	bool
 
diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
index 0a3c1f0..45aefeb 100644
--- a/arch/arm/plat-mxc/devices/Makefile
+++ b/arch/arm/plat-mxc/devices/Makefile
@@ -1,6 +1,7 @@
 obj-$(CONFIG_IMX_HAVE_PLATFORM_ESDHC) += platform-esdhc.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_FEC) += platform-fec.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_FLEXCAN) += platform-flexcan.o
+obj-$(CONFIG_IMX_HAVE_PLATFORM_GPIO_KEYS) += platform-gpio_keys.o
 obj-y += platform-imx-dma.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_I2C) += platform-imx-i2c.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SSI) += platform-imx-ssi.o
diff --git a/arch/arm/plat-mxc/devices/platform-gpio_keys.c b/arch/arm/plat-mxc/devices/platform-gpio_keys.c
new file mode 100644
index 0000000..1c53a53
--- /dev/null
+++ b/arch/arm/plat-mxc/devices/platform-gpio_keys.c
@@ -0,0 +1,27 @@
+/*
+ * 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_gpio_keys(
+		const struct gpio_keys_platform_data *pdata)
+{
+	return imx_add_platform_device("gpio-keys", -1, NULL,
+		 0, 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..8c6896f 100644
--- a/arch/arm/plat-mxc/include/mach/devices-common.h
+++ b/arch/arm/plat-mxc/include/mach/devices-common.h
@@ -29,6 +29,10 @@ struct platform_device *__init imx_add_flexcan(int id,
 		resource_size_t irq,
 		const struct flexcan_platform_data *pdata);
 
+#include <linux/gpio_keys.h>
+struct platform_device *__init imx_add_gpio_keys(
+		const struct gpio_keys_platform_data *pdata);
+
 #include <mach/i2c.h>
 struct imx_imx_i2c_data {
 	int id;
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] 32+ messages in thread

* [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
@ 2010-10-22 16:56   ` Dinh.Nguyen at freescale.com
  0 siblings, 0 replies; 32+ messages in thread
From: Dinh.Nguyen at freescale.com @ 2010-10-22 16:56 UTC (permalink / raw)
  To: linux-arm-kernel

From: Dinh Nguyen <Dinh.Nguyen@freescale.com>

Add imx_add_gpio_keys function to add gpio-keys in plat-mxc

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/plat-mxc/devices/Kconfig               |    4 +++
 arch/arm/plat-mxc/devices/Makefile              |    1 +
 arch/arm/plat-mxc/devices/platform-gpio_keys.c  |   27 +++++++++++++++++++++++
 arch/arm/plat-mxc/include/mach/devices-common.h |    4 +++
 arch/arm/plat-mxc/include/mach/iomux-mx51.h     |    2 +-
 5 files changed, 37 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/plat-mxc/devices/platform-gpio_keys.c

diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
index 4047994..f4772e7 100644
--- a/arch/arm/plat-mxc/devices/Kconfig
+++ b/arch/arm/plat-mxc/devices/Kconfig
@@ -9,6 +9,10 @@ config IMX_HAVE_PLATFORM_FLEXCAN
 	select HAVE_CAN_FLEXCAN
 	bool
 
+config IMX_HAVE_PLATFORM_GPIO_KEYS
+	bool
+	default y if ARCH_MX51
+	
 config IMX_HAVE_PLATFORM_IMX_I2C
 	bool
 
diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
index 0a3c1f0..45aefeb 100644
--- a/arch/arm/plat-mxc/devices/Makefile
+++ b/arch/arm/plat-mxc/devices/Makefile
@@ -1,6 +1,7 @@
 obj-$(CONFIG_IMX_HAVE_PLATFORM_ESDHC) += platform-esdhc.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_FEC) += platform-fec.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_FLEXCAN) += platform-flexcan.o
+obj-$(CONFIG_IMX_HAVE_PLATFORM_GPIO_KEYS) += platform-gpio_keys.o
 obj-y += platform-imx-dma.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_I2C) += platform-imx-i2c.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SSI) += platform-imx-ssi.o
diff --git a/arch/arm/plat-mxc/devices/platform-gpio_keys.c b/arch/arm/plat-mxc/devices/platform-gpio_keys.c
new file mode 100644
index 0000000..1c53a53
--- /dev/null
+++ b/arch/arm/plat-mxc/devices/platform-gpio_keys.c
@@ -0,0 +1,27 @@
+/*
+ * 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_gpio_keys(
+		const struct gpio_keys_platform_data *pdata)
+{
+	return imx_add_platform_device("gpio-keys", -1, NULL,
+		 0, 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..8c6896f 100644
--- a/arch/arm/plat-mxc/include/mach/devices-common.h
+++ b/arch/arm/plat-mxc/include/mach/devices-common.h
@@ -29,6 +29,10 @@ struct platform_device *__init imx_add_flexcan(int id,
 		resource_size_t irq,
 		const struct flexcan_platform_data *pdata);
 
+#include <linux/gpio_keys.h>
+struct platform_device *__init imx_add_gpio_keys(
+		const struct gpio_keys_platform_data *pdata);
+
 #include <mach/i2c.h>
 struct imx_imx_i2c_data {
 	int id;
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] 32+ messages in thread

* [PATCHv5 3/3] ARM: imx: Add wake functionality to GPIO
  2010-10-22 16:56   ` Dinh.Nguyen at freescale.com
@ 2010-10-22 16:56     ` Dinh.Nguyen at freescale.com
  -1 siblings, 0 replies; 32+ messages in thread
From: Dinh.Nguyen @ 2010-10-22 16:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arm-kernel, linux, s.hauer, u.kleine-koenig,
	valentin.longchamp, daniel, grant.likely, bryan.wu,
	amit.kucheria, Dinh Nguyen

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] 32+ messages in thread

* [PATCHv5 3/3] ARM: imx: Add wake functionality to GPIO
@ 2010-10-22 16:56     ` Dinh.Nguyen at freescale.com
  0 siblings, 0 replies; 32+ messages in thread
From: Dinh.Nguyen at freescale.com @ 2010-10-22 16:56 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] 32+ messages in thread

* Re: [PATCHv5 1/3] ARM: mx5: Add gpio-keys to mx51 babbage board
  2010-10-22 16:56 ` Dinh.Nguyen at freescale.com
@ 2010-10-22 17:51   ` Amit Kucheria
  -1 siblings, 0 replies; 32+ messages in thread
From: Amit Kucheria @ 2010-10-22 17:51 UTC (permalink / raw)
  To: Dinh.Nguyen
  Cc: linux-kernel, linux-arm-kernel, linux, s.hauer, u.kleine-koenig,
	valentin.longchamp, daniel, grant.likely, bryan.wu

In the interest of bisectability, Patch 1 and 2 should've been reversed since
imx51_add_gpio_keys() is only defined in patch 2.

On 10 Oct 22, Dinh.Nguyen@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 ++
>  3 files changed, 25 insertions(+), 0 deletions(-)
> 
> 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..8458852 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 const struct gpio_keys_platform_data imx_button_data __initconst = {
> +	.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_gpio_keys(&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..8c50cb5 100644
> --- a/arch/arm/mach-mx5/devices-imx51.h
> +++ b/arch/arm/mach-mx5/devices-imx51.h
> @@ -13,6 +13,8 @@ extern const struct imx_fec_data imx51_fec_data __initconst;
>  #define imx51_add_fec(pdata)	\
>  	imx_add_fec(&imx51_fec_data, pdata)
>  
> +#define imx51_add_gpio_keys(pdata) imx_add_gpio_keys(pdata)
> +
>  extern const struct imx_imx_i2c_data imx51_imx_i2c_data[] __initconst;
>  #define imx51_add_imx_i2c(id, pdata)	\
>  	imx_add_imx_i2c(&imx51_imx_i2c_data[id], pdata)
> -- 
> 1.6.0.4
> 
> 

-- 
----------------------------------------------------------------------
Amit Kucheria, Kernel Engineer || amit.kucheria@canonical.com
----------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCHv5 1/3] ARM: mx5: Add gpio-keys to mx51 babbage board
@ 2010-10-22 17:51   ` Amit Kucheria
  0 siblings, 0 replies; 32+ messages in thread
From: Amit Kucheria @ 2010-10-22 17:51 UTC (permalink / raw)
  To: linux-arm-kernel

In the interest of bisectability, Patch 1 and 2 should've been reversed since
imx51_add_gpio_keys() is only defined in patch 2.

On 10 Oct 22, 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 ++
>  3 files changed, 25 insertions(+), 0 deletions(-)
> 
> 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..8458852 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 const struct gpio_keys_platform_data imx_button_data __initconst = {
> +	.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_gpio_keys(&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..8c50cb5 100644
> --- a/arch/arm/mach-mx5/devices-imx51.h
> +++ b/arch/arm/mach-mx5/devices-imx51.h
> @@ -13,6 +13,8 @@ extern const struct imx_fec_data imx51_fec_data __initconst;
>  #define imx51_add_fec(pdata)	\
>  	imx_add_fec(&imx51_fec_data, pdata)
>  
> +#define imx51_add_gpio_keys(pdata) imx_add_gpio_keys(pdata)
> +
>  extern const struct imx_imx_i2c_data imx51_imx_i2c_data[] __initconst;
>  #define imx51_add_imx_i2c(id, pdata)	\
>  	imx_add_imx_i2c(&imx51_imx_i2c_data[id], pdata)
> -- 
> 1.6.0.4
> 
> 

-- 
----------------------------------------------------------------------
Amit Kucheria, Kernel Engineer || amit.kucheria at canonical.com
----------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
  2010-10-22 16:56   ` Dinh.Nguyen at freescale.com
@ 2010-10-22 18:28     ` Uwe Kleine-König
  -1 siblings, 0 replies; 32+ messages in thread
From: Uwe Kleine-König @ 2010-10-22 18:28 UTC (permalink / raw)
  To: Dinh.Nguyen
  Cc: linux-kernel, linux-arm-kernel, linux, s.hauer,
	valentin.longchamp, daniel, grant.likely, bryan.wu,
	amit.kucheria

On Fri, Oct 22, 2010 at 11:56:14AM -0500, Dinh.Nguyen@freescale.com wrote:
> From: Dinh Nguyen <Dinh.Nguyen@freescale.com>
> 
> Add imx_add_gpio_keys function to add gpio-keys in plat-mxc
> 
> This patch is based on Sascha Hauer's imx/linux-2.6 for-rmk tree.
(This information isn't interesting once the patch is in git, so it can
better go after the tripple-dash below.)

> Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
Patch 1 depends on this one, so you should swap their order.

> ---
>  arch/arm/plat-mxc/devices/Kconfig               |    4 +++
>  arch/arm/plat-mxc/devices/Makefile              |    1 +
>  arch/arm/plat-mxc/devices/platform-gpio_keys.c  |   27 +++++++++++++++++++++++
>  arch/arm/plat-mxc/include/mach/devices-common.h |    4 +++
>  arch/arm/plat-mxc/include/mach/iomux-mx51.h     |    2 +-
>  5 files changed, 37 insertions(+), 1 deletions(-)
>  create mode 100644 arch/arm/plat-mxc/devices/platform-gpio_keys.c
> 
> diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
> index 4047994..f4772e7 100644
> --- a/arch/arm/plat-mxc/devices/Kconfig
> +++ b/arch/arm/plat-mxc/devices/Kconfig
> @@ -9,6 +9,10 @@ config IMX_HAVE_PLATFORM_FLEXCAN
>  	select HAVE_CAN_FLEXCAN
>  	bool
>  
> +config IMX_HAVE_PLATFORM_GPIO_KEYS
> +	bool
> +	default y if ARCH_MX51
> +	
>  config IMX_HAVE_PLATFORM_IMX_I2C
>  	bool
>  
> diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
> index 0a3c1f0..45aefeb 100644
> --- a/arch/arm/plat-mxc/devices/Makefile
> +++ b/arch/arm/plat-mxc/devices/Makefile
> @@ -1,6 +1,7 @@
>  obj-$(CONFIG_IMX_HAVE_PLATFORM_ESDHC) += platform-esdhc.o
>  obj-$(CONFIG_IMX_HAVE_PLATFORM_FEC) += platform-fec.o
>  obj-$(CONFIG_IMX_HAVE_PLATFORM_FLEXCAN) += platform-flexcan.o
> +obj-$(CONFIG_IMX_HAVE_PLATFORM_GPIO_KEYS) += platform-gpio_keys.o
>  obj-y += platform-imx-dma.o
>  obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_I2C) += platform-imx-i2c.o
>  obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SSI) += platform-imx-ssi.o
> diff --git a/arch/arm/plat-mxc/devices/platform-gpio_keys.c b/arch/arm/plat-mxc/devices/platform-gpio_keys.c
> new file mode 100644
> index 0000000..1c53a53
> --- /dev/null
> +++ b/arch/arm/plat-mxc/devices/platform-gpio_keys.c
> @@ -0,0 +1,27 @@
> +/*
> + * 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_gpio_keys(
> +		const struct gpio_keys_platform_data *pdata)
> +{
> +	return imx_add_platform_device("gpio-keys", -1, NULL,
> +		 0, 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..8c6896f 100644
> --- a/arch/arm/plat-mxc/include/mach/devices-common.h
> +++ b/arch/arm/plat-mxc/include/mach/devices-common.h
> @@ -29,6 +29,10 @@ struct platform_device *__init imx_add_flexcan(int id,
>  		resource_size_t irq,
>  		const struct flexcan_platform_data *pdata);
>  
> +#include <linux/gpio_keys.h>
> +struct platform_device *__init imx_add_gpio_keys(
> +		const struct gpio_keys_platform_data *pdata);
> +
>  #include <mach/i2c.h>
>  struct imx_imx_i2c_data {
>  	int id;
> 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)
I share the concerns of Arnaud.  MX51_GPIO_PAD_CTRL looks OK,
PAD_CTL_PUS_100K_UP does not.

>  #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] 32+ messages in thread

* [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
@ 2010-10-22 18:28     ` Uwe Kleine-König
  0 siblings, 0 replies; 32+ messages in thread
From: Uwe Kleine-König @ 2010-10-22 18:28 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Oct 22, 2010 at 11:56:14AM -0500, Dinh.Nguyen at freescale.com wrote:
> From: Dinh Nguyen <Dinh.Nguyen@freescale.com>
> 
> Add imx_add_gpio_keys function to add gpio-keys in plat-mxc
> 
> This patch is based on Sascha Hauer's imx/linux-2.6 for-rmk tree.
(This information isn't interesting once the patch is in git, so it can
better go after the tripple-dash below.)

> Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
Patch 1 depends on this one, so you should swap their order.

> ---
>  arch/arm/plat-mxc/devices/Kconfig               |    4 +++
>  arch/arm/plat-mxc/devices/Makefile              |    1 +
>  arch/arm/plat-mxc/devices/platform-gpio_keys.c  |   27 +++++++++++++++++++++++
>  arch/arm/plat-mxc/include/mach/devices-common.h |    4 +++
>  arch/arm/plat-mxc/include/mach/iomux-mx51.h     |    2 +-
>  5 files changed, 37 insertions(+), 1 deletions(-)
>  create mode 100644 arch/arm/plat-mxc/devices/platform-gpio_keys.c
> 
> diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
> index 4047994..f4772e7 100644
> --- a/arch/arm/plat-mxc/devices/Kconfig
> +++ b/arch/arm/plat-mxc/devices/Kconfig
> @@ -9,6 +9,10 @@ config IMX_HAVE_PLATFORM_FLEXCAN
>  	select HAVE_CAN_FLEXCAN
>  	bool
>  
> +config IMX_HAVE_PLATFORM_GPIO_KEYS
> +	bool
> +	default y if ARCH_MX51
> +	
>  config IMX_HAVE_PLATFORM_IMX_I2C
>  	bool
>  
> diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
> index 0a3c1f0..45aefeb 100644
> --- a/arch/arm/plat-mxc/devices/Makefile
> +++ b/arch/arm/plat-mxc/devices/Makefile
> @@ -1,6 +1,7 @@
>  obj-$(CONFIG_IMX_HAVE_PLATFORM_ESDHC) += platform-esdhc.o
>  obj-$(CONFIG_IMX_HAVE_PLATFORM_FEC) += platform-fec.o
>  obj-$(CONFIG_IMX_HAVE_PLATFORM_FLEXCAN) += platform-flexcan.o
> +obj-$(CONFIG_IMX_HAVE_PLATFORM_GPIO_KEYS) += platform-gpio_keys.o
>  obj-y += platform-imx-dma.o
>  obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_I2C) += platform-imx-i2c.o
>  obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SSI) += platform-imx-ssi.o
> diff --git a/arch/arm/plat-mxc/devices/platform-gpio_keys.c b/arch/arm/plat-mxc/devices/platform-gpio_keys.c
> new file mode 100644
> index 0000000..1c53a53
> --- /dev/null
> +++ b/arch/arm/plat-mxc/devices/platform-gpio_keys.c
> @@ -0,0 +1,27 @@
> +/*
> + * 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_gpio_keys(
> +		const struct gpio_keys_platform_data *pdata)
> +{
> +	return imx_add_platform_device("gpio-keys", -1, NULL,
> +		 0, 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..8c6896f 100644
> --- a/arch/arm/plat-mxc/include/mach/devices-common.h
> +++ b/arch/arm/plat-mxc/include/mach/devices-common.h
> @@ -29,6 +29,10 @@ struct platform_device *__init imx_add_flexcan(int id,
>  		resource_size_t irq,
>  		const struct flexcan_platform_data *pdata);
>  
> +#include <linux/gpio_keys.h>
> +struct platform_device *__init imx_add_gpio_keys(
> +		const struct gpio_keys_platform_data *pdata);
> +
>  #include <mach/i2c.h>
>  struct imx_imx_i2c_data {
>  	int id;
> 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)
I share the concerns of Arnaud.  MX51_GPIO_PAD_CTRL looks OK,
PAD_CTL_PUS_100K_UP does not.

>  #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] 32+ messages in thread

* RE: [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
  2010-10-22 18:28     ` Uwe Kleine-König
@ 2010-10-22 18:58       ` Nguyen Dinh-R00091
  -1 siblings, 0 replies; 32+ messages in thread
From: Nguyen Dinh-R00091 @ 2010-10-22 18:58 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: linux-kernel, linux-arm-kernel, linux, s.hauer,
	valentin.longchamp, daniel, grant.likely, bryan.wu,
	amit.kucheria

Hi Uwe,

>-----Original Message-----
>From: Uwe Kleine-König [mailto:u.kleine-koenig@pengutronix.de]
>Sent: Friday, October 22, 2010 1:28 PM
>To: Nguyen Dinh-R00091
>Cc: linux-kernel@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux@arm.linux.org.uk;
>s.hauer@pengutronix.de; valentin.longchamp@epfl.ch; daniel@caiaq.de; grant.likely@secretlab.ca;
>bryan.wu@canonical.com; amit.kucheria@canonical.com
>Subject: Re: [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
>
>On Fri, Oct 22, 2010 at 11:56:14AM -0500, Dinh.Nguyen@freescale.com wrote:
>> From: Dinh Nguyen <Dinh.Nguyen@freescale.com>
>>
>> Add imx_add_gpio_keys function to add gpio-keys in plat-mxc
>>
>> This patch is based on Sascha Hauer's imx/linux-2.6 for-rmk tree.
>(This information isn't interesting once the patch is in git, so it can
>better go after the tripple-dash below.)
>
>> Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
>Patch 1 depends on this one, so you should swap their order.
>
>> ---
>>  arch/arm/plat-mxc/devices/Kconfig               |    4 +++
>>  arch/arm/plat-mxc/devices/Makefile              |    1 +
>>  arch/arm/plat-mxc/devices/platform-gpio_keys.c  |   27 +++++++++++++++++++++++
>>  arch/arm/plat-mxc/include/mach/devices-common.h |    4 +++
>>  arch/arm/plat-mxc/include/mach/iomux-mx51.h     |    2 +-
>>  5 files changed, 37 insertions(+), 1 deletions(-)
>>  create mode 100644 arch/arm/plat-mxc/devices/platform-gpio_keys.c
>>
>> diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
>> index 4047994..f4772e7 100644
>> --- a/arch/arm/plat-mxc/devices/Kconfig
>> +++ b/arch/arm/plat-mxc/devices/Kconfig
>> @@ -9,6 +9,10 @@ config IMX_HAVE_PLATFORM_FLEXCAN
>>  	select HAVE_CAN_FLEXCAN
>>  	bool
>>
>> +config IMX_HAVE_PLATFORM_GPIO_KEYS
>> +	bool
>> +	default y if ARCH_MX51
>> +
>>  config IMX_HAVE_PLATFORM_IMX_I2C
>>  	bool
>>
>> diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
>> index 0a3c1f0..45aefeb 100644
>> --- a/arch/arm/plat-mxc/devices/Makefile
>> +++ b/arch/arm/plat-mxc/devices/Makefile
>> @@ -1,6 +1,7 @@
>>  obj-$(CONFIG_IMX_HAVE_PLATFORM_ESDHC) += platform-esdhc.o
>>  obj-$(CONFIG_IMX_HAVE_PLATFORM_FEC) += platform-fec.o
>>  obj-$(CONFIG_IMX_HAVE_PLATFORM_FLEXCAN) += platform-flexcan.o
>> +obj-$(CONFIG_IMX_HAVE_PLATFORM_GPIO_KEYS) += platform-gpio_keys.o
>>  obj-y += platform-imx-dma.o
>>  obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_I2C) += platform-imx-i2c.o
>>  obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SSI) += platform-imx-ssi.o
>> diff --git a/arch/arm/plat-mxc/devices/platform-gpio_keys.c b/arch/arm/plat-mxc/devices/platform-
>gpio_keys.c
>> new file mode 100644
>> index 0000000..1c53a53
>> --- /dev/null
>> +++ b/arch/arm/plat-mxc/devices/platform-gpio_keys.c
>> @@ -0,0 +1,27 @@
>> +/*
>> + * 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_gpio_keys(
>> +		const struct gpio_keys_platform_data *pdata)
>> +{
>> +	return imx_add_platform_device("gpio-keys", -1, NULL,
>> +		 0, 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..8c6896f 100644
>> --- a/arch/arm/plat-mxc/include/mach/devices-common.h
>> +++ b/arch/arm/plat-mxc/include/mach/devices-common.h
>> @@ -29,6 +29,10 @@ struct platform_device *__init imx_add_flexcan(int id,
>>  		resource_size_t irq,
>>  		const struct flexcan_platform_data *pdata);
>>
>> +#include <linux/gpio_keys.h>
>> +struct platform_device *__init imx_add_gpio_keys(
>> +		const struct gpio_keys_platform_data *pdata);
>> +
>>  #include <mach/i2c.h>
>>  struct imx_imx_i2c_data {
>>  	int id;
>> 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)
>I share the concerns of Arnaud.  MX51_GPIO_PAD_CTRL looks OK,
>PAD_CTL_PUS_100K_UP does not.

How do you suggest I define this pin for Babbage board only? Do I add to iomux-mx51.h
#define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21             IOMUX_PAD(0x45c, 0x0c8, 1, 0x0,   0,MX51_GPIO_PAD_CTRL | PAD_CTL_PUS_100K_UP) ?

Or do I define the pin in the board file with a 100K_UP? Like how eukrea_mbimxsd-baseboard.c did for MBIMXSD_GPIO_3_31?

>
>>  #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/  |

Thanks for your review comments...

Dinh



^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
@ 2010-10-22 18:58       ` Nguyen Dinh-R00091
  0 siblings, 0 replies; 32+ messages in thread
From: Nguyen Dinh-R00091 @ 2010-10-22 18:58 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Uwe,

>-----Original Message-----
>From: Uwe Kleine-K?nig [mailto:u.kleine-koenig at pengutronix.de]
>Sent: Friday, October 22, 2010 1:28 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
>Subject: Re: [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
>
>On Fri, Oct 22, 2010 at 11:56:14AM -0500, Dinh.Nguyen at freescale.com wrote:
>> From: Dinh Nguyen <Dinh.Nguyen@freescale.com>
>>
>> Add imx_add_gpio_keys function to add gpio-keys in plat-mxc
>>
>> This patch is based on Sascha Hauer's imx/linux-2.6 for-rmk tree.
>(This information isn't interesting once the patch is in git, so it can
>better go after the tripple-dash below.)
>
>> Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
>Patch 1 depends on this one, so you should swap their order.
>
>> ---
>>  arch/arm/plat-mxc/devices/Kconfig               |    4 +++
>>  arch/arm/plat-mxc/devices/Makefile              |    1 +
>>  arch/arm/plat-mxc/devices/platform-gpio_keys.c  |   27 +++++++++++++++++++++++
>>  arch/arm/plat-mxc/include/mach/devices-common.h |    4 +++
>>  arch/arm/plat-mxc/include/mach/iomux-mx51.h     |    2 +-
>>  5 files changed, 37 insertions(+), 1 deletions(-)
>>  create mode 100644 arch/arm/plat-mxc/devices/platform-gpio_keys.c
>>
>> diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
>> index 4047994..f4772e7 100644
>> --- a/arch/arm/plat-mxc/devices/Kconfig
>> +++ b/arch/arm/plat-mxc/devices/Kconfig
>> @@ -9,6 +9,10 @@ config IMX_HAVE_PLATFORM_FLEXCAN
>>  	select HAVE_CAN_FLEXCAN
>>  	bool
>>
>> +config IMX_HAVE_PLATFORM_GPIO_KEYS
>> +	bool
>> +	default y if ARCH_MX51
>> +
>>  config IMX_HAVE_PLATFORM_IMX_I2C
>>  	bool
>>
>> diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
>> index 0a3c1f0..45aefeb 100644
>> --- a/arch/arm/plat-mxc/devices/Makefile
>> +++ b/arch/arm/plat-mxc/devices/Makefile
>> @@ -1,6 +1,7 @@
>>  obj-$(CONFIG_IMX_HAVE_PLATFORM_ESDHC) += platform-esdhc.o
>>  obj-$(CONFIG_IMX_HAVE_PLATFORM_FEC) += platform-fec.o
>>  obj-$(CONFIG_IMX_HAVE_PLATFORM_FLEXCAN) += platform-flexcan.o
>> +obj-$(CONFIG_IMX_HAVE_PLATFORM_GPIO_KEYS) += platform-gpio_keys.o
>>  obj-y += platform-imx-dma.o
>>  obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_I2C) += platform-imx-i2c.o
>>  obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SSI) += platform-imx-ssi.o
>> diff --git a/arch/arm/plat-mxc/devices/platform-gpio_keys.c b/arch/arm/plat-mxc/devices/platform-
>gpio_keys.c
>> new file mode 100644
>> index 0000000..1c53a53
>> --- /dev/null
>> +++ b/arch/arm/plat-mxc/devices/platform-gpio_keys.c
>> @@ -0,0 +1,27 @@
>> +/*
>> + * 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_gpio_keys(
>> +		const struct gpio_keys_platform_data *pdata)
>> +{
>> +	return imx_add_platform_device("gpio-keys", -1, NULL,
>> +		 0, 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..8c6896f 100644
>> --- a/arch/arm/plat-mxc/include/mach/devices-common.h
>> +++ b/arch/arm/plat-mxc/include/mach/devices-common.h
>> @@ -29,6 +29,10 @@ struct platform_device *__init imx_add_flexcan(int id,
>>  		resource_size_t irq,
>>  		const struct flexcan_platform_data *pdata);
>>
>> +#include <linux/gpio_keys.h>
>> +struct platform_device *__init imx_add_gpio_keys(
>> +		const struct gpio_keys_platform_data *pdata);
>> +
>>  #include <mach/i2c.h>
>>  struct imx_imx_i2c_data {
>>  	int id;
>> 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)
>I share the concerns of Arnaud.  MX51_GPIO_PAD_CTRL looks OK,
>PAD_CTL_PUS_100K_UP does not.

How do you suggest I define this pin for Babbage board only? Do I add to iomux-mx51.h
#define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21             IOMUX_PAD(0x45c, 0x0c8, 1, 0x0,   0,MX51_GPIO_PAD_CTRL | PAD_CTL_PUS_100K_UP) ?

Or do I define the pin in the board file with a 100K_UP? Like how eukrea_mbimxsd-baseboard.c did for MBIMXSD_GPIO_3_31?

>
>>  #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/  |

Thanks for your review comments...

Dinh

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
  2010-10-22 18:58       ` Nguyen Dinh-R00091
@ 2010-10-22 19:42         ` Uwe Kleine-König
  -1 siblings, 0 replies; 32+ messages in thread
From: Uwe Kleine-König @ 2010-10-22 19:42 UTC (permalink / raw)
  To: Nguyen Dinh-R00091
  Cc: linux-kernel, linux-arm-kernel, linux, s.hauer,
	valentin.longchamp, daniel, grant.likely, bryan.wu,
	amit.kucheria

Hello Dinh,

On Fri, Oct 22, 2010 at 11:58:16AM -0700, Nguyen Dinh-R00091 wrote:
> >-----Original Message-----
> >From: Uwe Kleine-König [mailto:u.kleine-koenig@pengutronix.de]
> >Sent: Friday, October 22, 2010 1:28 PM
> >To: Nguyen Dinh-R00091
> >Cc: linux-kernel@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux@arm.linux.org.uk;
> >s.hauer@pengutronix.de; valentin.longchamp@epfl.ch; daniel@caiaq.de; grant.likely@secretlab.ca;
> >bryan.wu@canonical.com; amit.kucheria@canonical.com
> >Subject: Re: [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
> >
> >On Fri, Oct 22, 2010 at 11:56:14AM -0500, Dinh.Nguyen@freescale.com wrote:
> >> From: Dinh Nguyen <Dinh.Nguyen@freescale.com>
> >>
> >> Add imx_add_gpio_keys function to add gpio-keys in plat-mxc
> >>
> >> This patch is based on Sascha Hauer's imx/linux-2.6 for-rmk tree.
> >(This information isn't interesting once the patch is in git, so it can
> >better go after the tripple-dash below.)
> >
> >> Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
> >Patch 1 depends on this one, so you should swap their order.
> >
> >> ---
> >>  arch/arm/plat-mxc/devices/Kconfig               |    4 +++
> >>  arch/arm/plat-mxc/devices/Makefile              |    1 +
> >>  arch/arm/plat-mxc/devices/platform-gpio_keys.c  |   27 +++++++++++++++++++++++
> >>  arch/arm/plat-mxc/include/mach/devices-common.h |    4 +++
> >>  arch/arm/plat-mxc/include/mach/iomux-mx51.h     |    2 +-
> >>  5 files changed, 37 insertions(+), 1 deletions(-)
> >>  create mode 100644 arch/arm/plat-mxc/devices/platform-gpio_keys.c
> >>
> >> diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
> >> index 4047994..f4772e7 100644
> >> --- a/arch/arm/plat-mxc/devices/Kconfig
> >> +++ b/arch/arm/plat-mxc/devices/Kconfig
> >> @@ -9,6 +9,10 @@ config IMX_HAVE_PLATFORM_FLEXCAN
> >>  	select HAVE_CAN_FLEXCAN
> >>  	bool
> >>
> >> +config IMX_HAVE_PLATFORM_GPIO_KEYS
> >> +	bool
> >> +	default y if ARCH_MX51
> >> +
> >>  config IMX_HAVE_PLATFORM_IMX_I2C
> >>  	bool
> >>
> >> diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
> >> index 0a3c1f0..45aefeb 100644
> >> --- a/arch/arm/plat-mxc/devices/Makefile
> >> +++ b/arch/arm/plat-mxc/devices/Makefile
> >> @@ -1,6 +1,7 @@
> >>  obj-$(CONFIG_IMX_HAVE_PLATFORM_ESDHC) += platform-esdhc.o
> >>  obj-$(CONFIG_IMX_HAVE_PLATFORM_FEC) += platform-fec.o
> >>  obj-$(CONFIG_IMX_HAVE_PLATFORM_FLEXCAN) += platform-flexcan.o
> >> +obj-$(CONFIG_IMX_HAVE_PLATFORM_GPIO_KEYS) += platform-gpio_keys.o
> >>  obj-y += platform-imx-dma.o
> >>  obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_I2C) += platform-imx-i2c.o
> >>  obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SSI) += platform-imx-ssi.o
> >> diff --git a/arch/arm/plat-mxc/devices/platform-gpio_keys.c b/arch/arm/plat-mxc/devices/platform-
> >gpio_keys.c
> >> new file mode 100644
> >> index 0000000..1c53a53
> >> --- /dev/null
> >> +++ b/arch/arm/plat-mxc/devices/platform-gpio_keys.c
> >> @@ -0,0 +1,27 @@
> >> +/*
> >> + * 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_gpio_keys(
> >> +		const struct gpio_keys_platform_data *pdata)
> >> +{
> >> +	return imx_add_platform_device("gpio-keys", -1, NULL,
> >> +		 0, 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..8c6896f 100644
> >> --- a/arch/arm/plat-mxc/include/mach/devices-common.h
> >> +++ b/arch/arm/plat-mxc/include/mach/devices-common.h
> >> @@ -29,6 +29,10 @@ struct platform_device *__init imx_add_flexcan(int id,
> >>  		resource_size_t irq,
> >>  		const struct flexcan_platform_data *pdata);
> >>
> >> +#include <linux/gpio_keys.h>
> >> +struct platform_device *__init imx_add_gpio_keys(
> >> +		const struct gpio_keys_platform_data *pdata);
> >> +
> >>  #include <mach/i2c.h>
> >>  struct imx_imx_i2c_data {
> >>  	int id;
> >> 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)
> >I share the concerns of Arnaud.  MX51_GPIO_PAD_CTRL looks OK,
> >PAD_CTL_PUS_100K_UP does not.
> 
> How do you suggest I define this pin for Babbage board only? Do I add to iomux-mx51.h
> #define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21             IOMUX_PAD(0x45c, 0x0c8, 1, 0x0,   0,MX51_GPIO_PAD_CTRL | PAD_CTL_PUS_100K_UP) ?
> 
> Or do I define the pin in the board file with a 100K_UP? Like how eukrea_mbimxsd-baseboard.c did for MBIMXSD_GPIO_3_31?
I'd suggest something local to your machine file.  Unfortunately I don't
see an easy way to reuse the generic MX51_PAD_EIM_A27__GPIO_2_21 to
define your local symbol.  So I think something like you wrote above
should be fine.

Too bad that

	#define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21 (MX51_PAD_EIM_A27__GPIO_2_21 | PAD_CTL_PUS_100K_UP)

doesn't work.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
@ 2010-10-22 19:42         ` Uwe Kleine-König
  0 siblings, 0 replies; 32+ messages in thread
From: Uwe Kleine-König @ 2010-10-22 19:42 UTC (permalink / raw)
  To: linux-arm-kernel

Hello Dinh,

On Fri, Oct 22, 2010 at 11:58:16AM -0700, Nguyen Dinh-R00091 wrote:
> >-----Original Message-----
> >From: Uwe Kleine-K?nig [mailto:u.kleine-koenig at pengutronix.de]
> >Sent: Friday, October 22, 2010 1:28 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
> >Subject: Re: [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
> >
> >On Fri, Oct 22, 2010 at 11:56:14AM -0500, Dinh.Nguyen at freescale.com wrote:
> >> From: Dinh Nguyen <Dinh.Nguyen@freescale.com>
> >>
> >> Add imx_add_gpio_keys function to add gpio-keys in plat-mxc
> >>
> >> This patch is based on Sascha Hauer's imx/linux-2.6 for-rmk tree.
> >(This information isn't interesting once the patch is in git, so it can
> >better go after the tripple-dash below.)
> >
> >> Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
> >Patch 1 depends on this one, so you should swap their order.
> >
> >> ---
> >>  arch/arm/plat-mxc/devices/Kconfig               |    4 +++
> >>  arch/arm/plat-mxc/devices/Makefile              |    1 +
> >>  arch/arm/plat-mxc/devices/platform-gpio_keys.c  |   27 +++++++++++++++++++++++
> >>  arch/arm/plat-mxc/include/mach/devices-common.h |    4 +++
> >>  arch/arm/plat-mxc/include/mach/iomux-mx51.h     |    2 +-
> >>  5 files changed, 37 insertions(+), 1 deletions(-)
> >>  create mode 100644 arch/arm/plat-mxc/devices/platform-gpio_keys.c
> >>
> >> diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
> >> index 4047994..f4772e7 100644
> >> --- a/arch/arm/plat-mxc/devices/Kconfig
> >> +++ b/arch/arm/plat-mxc/devices/Kconfig
> >> @@ -9,6 +9,10 @@ config IMX_HAVE_PLATFORM_FLEXCAN
> >>  	select HAVE_CAN_FLEXCAN
> >>  	bool
> >>
> >> +config IMX_HAVE_PLATFORM_GPIO_KEYS
> >> +	bool
> >> +	default y if ARCH_MX51
> >> +
> >>  config IMX_HAVE_PLATFORM_IMX_I2C
> >>  	bool
> >>
> >> diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
> >> index 0a3c1f0..45aefeb 100644
> >> --- a/arch/arm/plat-mxc/devices/Makefile
> >> +++ b/arch/arm/plat-mxc/devices/Makefile
> >> @@ -1,6 +1,7 @@
> >>  obj-$(CONFIG_IMX_HAVE_PLATFORM_ESDHC) += platform-esdhc.o
> >>  obj-$(CONFIG_IMX_HAVE_PLATFORM_FEC) += platform-fec.o
> >>  obj-$(CONFIG_IMX_HAVE_PLATFORM_FLEXCAN) += platform-flexcan.o
> >> +obj-$(CONFIG_IMX_HAVE_PLATFORM_GPIO_KEYS) += platform-gpio_keys.o
> >>  obj-y += platform-imx-dma.o
> >>  obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_I2C) += platform-imx-i2c.o
> >>  obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SSI) += platform-imx-ssi.o
> >> diff --git a/arch/arm/plat-mxc/devices/platform-gpio_keys.c b/arch/arm/plat-mxc/devices/platform-
> >gpio_keys.c
> >> new file mode 100644
> >> index 0000000..1c53a53
> >> --- /dev/null
> >> +++ b/arch/arm/plat-mxc/devices/platform-gpio_keys.c
> >> @@ -0,0 +1,27 @@
> >> +/*
> >> + * 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_gpio_keys(
> >> +		const struct gpio_keys_platform_data *pdata)
> >> +{
> >> +	return imx_add_platform_device("gpio-keys", -1, NULL,
> >> +		 0, 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..8c6896f 100644
> >> --- a/arch/arm/plat-mxc/include/mach/devices-common.h
> >> +++ b/arch/arm/plat-mxc/include/mach/devices-common.h
> >> @@ -29,6 +29,10 @@ struct platform_device *__init imx_add_flexcan(int id,
> >>  		resource_size_t irq,
> >>  		const struct flexcan_platform_data *pdata);
> >>
> >> +#include <linux/gpio_keys.h>
> >> +struct platform_device *__init imx_add_gpio_keys(
> >> +		const struct gpio_keys_platform_data *pdata);
> >> +
> >>  #include <mach/i2c.h>
> >>  struct imx_imx_i2c_data {
> >>  	int id;
> >> 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)
> >I share the concerns of Arnaud.  MX51_GPIO_PAD_CTRL looks OK,
> >PAD_CTL_PUS_100K_UP does not.
> 
> How do you suggest I define this pin for Babbage board only? Do I add to iomux-mx51.h
> #define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21             IOMUX_PAD(0x45c, 0x0c8, 1, 0x0,   0,MX51_GPIO_PAD_CTRL | PAD_CTL_PUS_100K_UP) ?
> 
> Or do I define the pin in the board file with a 100K_UP? Like how eukrea_mbimxsd-baseboard.c did for MBIMXSD_GPIO_3_31?
I'd suggest something local to your machine file.  Unfortunately I don't
see an easy way to reuse the generic MX51_PAD_EIM_A27__GPIO_2_21 to
define your local symbol.  So I think something like you wrote above
should be fine.

Too bad that

	#define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21 (MX51_PAD_EIM_A27__GPIO_2_21 | PAD_CTL_PUS_100K_UP)

doesn't work.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 32+ messages in thread

* RE: [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
  2010-10-22 19:42         ` Uwe Kleine-König
@ 2010-10-23  2:43           ` Nguyen Dinh-R00091
  -1 siblings, 0 replies; 32+ messages in thread
From: Nguyen Dinh-R00091 @ 2010-10-23  2:43 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: linux-kernel, linux-arm-kernel, linux, s.hauer,
	valentin.longchamp, daniel, grant.likely, bryan.wu,
	amit.kucheria

Hello Uwe,

>-----Original Message-----
>From: Uwe Kleine-König [mailto:u.kleine-koenig@pengutronix.de]
>Sent: Friday, October 22, 2010 2:42 PM
>To: Nguyen Dinh-R00091
>Cc: linux-kernel@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux@arm.linux.org.uk;
>s.hauer@pengutronix.de; valentin.longchamp@epfl.ch; daniel@caiaq.de; grant.likely@secretlab.ca;
>bryan.wu@canonical.com; amit.kucheria@canonical.com
>Subject: Re: [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
>
>Hello Dinh,
>
>On Fri, Oct 22, 2010 at 11:58:16AM -0700, Nguyen Dinh-R00091 wrote:
>> >-----Original Message-----
>> >From: Uwe Kleine-König [mailto:u.kleine-koenig@pengutronix.de]
>> >Sent: Friday, October 22, 2010 1:28 PM
>> >To: Nguyen Dinh-R00091
>> >Cc: linux-kernel@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux@arm.linux.org.uk;
>> >s.hauer@pengutronix.de; valentin.longchamp@epfl.ch; daniel@caiaq.de; grant.likely@secretlab.ca;
>> >bryan.wu@canonical.com; amit.kucheria@canonical.com
>> >Subject: Re: [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
>> >
>> >On Fri, Oct 22, 2010 at 11:56:14AM -0500, Dinh.Nguyen@freescale.com wrote:
>> >> From: Dinh Nguyen <Dinh.Nguyen@freescale.com>
>> >>
>> >> Add imx_add_gpio_keys function to add gpio-keys in plat-mxc
>> >>
>> >> This patch is based on Sascha Hauer's imx/linux-2.6 for-rmk tree.
>> >(This information isn't interesting once the patch is in git, so it can
>> >better go after the tripple-dash below.)
>> >
>> >> Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
>> >Patch 1 depends on this one, so you should swap their order.
>> >
>> >> ---
>> >I share the concerns of Arnaud.  MX51_GPIO_PAD_CTRL looks OK,
>> >PAD_CTL_PUS_100K_UP does not.
>>
>> How do you suggest I define this pin for Babbage board only? Do I add to iomux-mx51.h
>> #define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21             IOMUX_PAD(0x45c, 0x0c8, 1, 0x0,
>0,MX51_GPIO_PAD_CTRL | PAD_CTL_PUS_100K_UP) ?
>>
>> Or do I define the pin in the board file with a 100K_UP? Like how eukrea_mbimxsd-baseboard.c did for
>MBIMXSD_GPIO_3_31?
>I'd suggest something local to your machine file.  Unfortunately I don't
>see an easy way to reuse the generic MX51_PAD_EIM_A27__GPIO_2_21 to
>define your local symbol.  So I think something like you wrote above
>should be fine.
>
>Too bad that
>
>	#define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21 (MX51_PAD_EIM_A27__GPIO_2_21 | PAD_CTL_PUS_100K_UP)
>
>doesn't work.

Yes, I also wish I didn't have to redefine the pin just because of PAD setting change. I am going to send out another patch that basically sets the pad_desc.pad_ctrl=PAD_SETTING in mxc_init_board() function. I think it's a bit cleaner than having to redefine the pin.

>Best regards
>Uwe
>
>--
>Pengutronix e.K.                           | Uwe Kleine-König            |
>Industrial Linux Solutions                 | http://www.pengutronix.de/  |

Thanks,
Dinh


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
@ 2010-10-23  2:43           ` Nguyen Dinh-R00091
  0 siblings, 0 replies; 32+ messages in thread
From: Nguyen Dinh-R00091 @ 2010-10-23  2:43 UTC (permalink / raw)
  To: linux-arm-kernel

Hello Uwe,

>-----Original Message-----
>From: Uwe Kleine-K?nig [mailto:u.kleine-koenig at pengutronix.de]
>Sent: Friday, October 22, 2010 2:42 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
>Subject: Re: [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
>
>Hello Dinh,
>
>On Fri, Oct 22, 2010 at 11:58:16AM -0700, Nguyen Dinh-R00091 wrote:
>> >-----Original Message-----
>> >From: Uwe Kleine-K?nig [mailto:u.kleine-koenig at pengutronix.de]
>> >Sent: Friday, October 22, 2010 1:28 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
>> >Subject: Re: [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
>> >
>> >On Fri, Oct 22, 2010 at 11:56:14AM -0500, Dinh.Nguyen at freescale.com wrote:
>> >> From: Dinh Nguyen <Dinh.Nguyen@freescale.com>
>> >>
>> >> Add imx_add_gpio_keys function to add gpio-keys in plat-mxc
>> >>
>> >> This patch is based on Sascha Hauer's imx/linux-2.6 for-rmk tree.
>> >(This information isn't interesting once the patch is in git, so it can
>> >better go after the tripple-dash below.)
>> >
>> >> Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
>> >Patch 1 depends on this one, so you should swap their order.
>> >
>> >> ---
>> >I share the concerns of Arnaud.  MX51_GPIO_PAD_CTRL looks OK,
>> >PAD_CTL_PUS_100K_UP does not.
>>
>> How do you suggest I define this pin for Babbage board only? Do I add to iomux-mx51.h
>> #define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21             IOMUX_PAD(0x45c, 0x0c8, 1, 0x0,
>0,MX51_GPIO_PAD_CTRL | PAD_CTL_PUS_100K_UP) ?
>>
>> Or do I define the pin in the board file with a 100K_UP? Like how eukrea_mbimxsd-baseboard.c did for
>MBIMXSD_GPIO_3_31?
>I'd suggest something local to your machine file.  Unfortunately I don't
>see an easy way to reuse the generic MX51_PAD_EIM_A27__GPIO_2_21 to
>define your local symbol.  So I think something like you wrote above
>should be fine.
>
>Too bad that
>
>	#define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21 (MX51_PAD_EIM_A27__GPIO_2_21 | PAD_CTL_PUS_100K_UP)
>
>doesn't work.

Yes, I also wish I didn't have to redefine the pin just because of PAD setting change. I am going to send out another patch that basically sets the pad_desc.pad_ctrl=PAD_SETTING in mxc_init_board() function. I think it's a bit cleaner than having to redefine the pin.

>Best regards
>Uwe
>
>--
>Pengutronix e.K.                           | Uwe Kleine-K?nig            |
>Industrial Linux Solutions                 | http://www.pengutronix.de/  |

Thanks,
Dinh

^ permalink raw reply	[flat|nested] 32+ messages in thread

* RE: [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
  2010-10-23  2:43           ` Nguyen Dinh-R00091
@ 2010-10-24  8:37             ` Lothar Waßmann
  -1 siblings, 0 replies; 32+ messages in thread
From: Lothar Waßmann @ 2010-10-24  8:37 UTC (permalink / raw)
  To: Nguyen Dinh-R00091
  Cc: Uwe Kleine-König, amit.kucheria, linux, s.hauer,
	linux-kernel, grant.likely, valentin.longchamp, daniel, bryan.wu,
	linux-arm-kernel

Hi,
> >> How do you suggest I define this pin for Babbage board only? Do I add to iomux-mx51.h
> >> #define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21             IOMUX_PAD(0x45c, 0x0c8, 1, 0x0,
> >0,MX51_GPIO_PAD_CTRL | PAD_CTL_PUS_100K_UP) ?
> >>
> >> Or do I define the pin in the board file with a 100K_UP? Like how eukrea_mbimxsd-baseboard.c did for
> >MBIMXSD_GPIO_3_31?
> >I'd suggest something local to your machine file.  Unfortunately I don't
> >see an easy way to reuse the generic MX51_PAD_EIM_A27__GPIO_2_21 to
> >define your local symbol.  So I think something like you wrote above
> >should be fine.
> >
> >Too bad that
> >
> >	#define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21 (MX51_PAD_EIM_A27__GPIO_2_21 | PAD_CTL_PUS_100K_UP)
> >
> >doesn't work.
> 
> Yes, I also wish I didn't have to redefine the pin just because of PAD setting change. I am going to send out another patch that basically sets the pad_desc.pad_ctrl=PAD_SETTING in mxc_init_board() function. I think it's a bit cleaner than having to redefine the pin.
> 
IMO the 'struct pad_desc' should be replaced with an u64 bitmap that
would allow for the pullup and other definitions that may be board
specific to be simply or'ed to the pad definition.

I could try to provide a patch if this is agreed on.


Lothar Waßmann
-- 
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Geschäftsführer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info@karo-electronics.de
___________________________________________________________

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
@ 2010-10-24  8:37             ` Lothar Waßmann
  0 siblings, 0 replies; 32+ messages in thread
From: Lothar Waßmann @ 2010-10-24  8:37 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,
> >> How do you suggest I define this pin for Babbage board only? Do I add to iomux-mx51.h
> >> #define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21             IOMUX_PAD(0x45c, 0x0c8, 1, 0x0,
> >0,MX51_GPIO_PAD_CTRL | PAD_CTL_PUS_100K_UP) ?
> >>
> >> Or do I define the pin in the board file with a 100K_UP? Like how eukrea_mbimxsd-baseboard.c did for
> >MBIMXSD_GPIO_3_31?
> >I'd suggest something local to your machine file.  Unfortunately I don't
> >see an easy way to reuse the generic MX51_PAD_EIM_A27__GPIO_2_21 to
> >define your local symbol.  So I think something like you wrote above
> >should be fine.
> >
> >Too bad that
> >
> >	#define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21 (MX51_PAD_EIM_A27__GPIO_2_21 | PAD_CTL_PUS_100K_UP)
> >
> >doesn't work.
> 
> Yes, I also wish I didn't have to redefine the pin just because of PAD setting change. I am going to send out another patch that basically sets the pad_desc.pad_ctrl=PAD_SETTING in mxc_init_board() function. I think it's a bit cleaner than having to redefine the pin.
> 
IMO the 'struct pad_desc' should be replaced with an u64 bitmap that
would allow for the pullup and other definitions that may be board
specific to be simply or'ed to the pad definition.

I could try to provide a patch if this is agreed on.


Lothar Wa?mann
-- 
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info at karo-electronics.de
___________________________________________________________

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
  2010-10-24  8:37             ` Lothar Waßmann
@ 2010-10-24 19:20               ` Uwe Kleine-König
  -1 siblings, 0 replies; 32+ messages in thread
From: Uwe Kleine-König @ 2010-10-24 19:20 UTC (permalink / raw)
  To: Lothar Waßmann
  Cc: Nguyen Dinh-R00091, amit.kucheria, linux, s.hauer, linux-kernel,
	grant.likely, valentin.longchamp, daniel, bryan.wu,
	linux-arm-kernel

Hi Lothar,

On Sun, Oct 24, 2010 at 10:37:19AM +0200, Lothar Waßmann wrote:
> Hi,
> > >> How do you suggest I define this pin for Babbage board only? Do I add to iomux-mx51.h
> > >> #define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21             IOMUX_PAD(0x45c, 0x0c8, 1, 0x0,
> > >0,MX51_GPIO_PAD_CTRL | PAD_CTL_PUS_100K_UP) ?
> > >>
> > >> Or do I define the pin in the board file with a 100K_UP? Like how eukrea_mbimxsd-baseboard.c did for
> > >MBIMXSD_GPIO_3_31?
> > >I'd suggest something local to your machine file.  Unfortunately I don't
> > >see an easy way to reuse the generic MX51_PAD_EIM_A27__GPIO_2_21 to
> > >define your local symbol.  So I think something like you wrote above
> > >should be fine.
> > >
> > >Too bad that
> > >
> > >	#define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21 (MX51_PAD_EIM_A27__GPIO_2_21 | PAD_CTL_PUS_100K_UP)
> > >
> > >doesn't work.
> > 
> > Yes, I also wish I didn't have to redefine the pin just because of PAD setting change. I am going to send out another patch that basically sets the pad_desc.pad_ctrl=PAD_SETTING in mxc_init_board() function. I think it's a bit cleaner than having to redefine the pin.
> > 
> IMO the 'struct pad_desc' should be replaced with an u64 bitmap that
> would allow for the pullup and other definitions that may be board
> specific to be simply or'ed to the pad definition.
> 
> I could try to provide a patch if this is agreed on.
Hmm, I thought about that, too, when writing my mail and when I added
the needed space for a struct pad_desc I stopped when it became >64.
Somehow I must have got it wrong.  After rechecking now it's ==64, so
yes, I'd like it.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
@ 2010-10-24 19:20               ` Uwe Kleine-König
  0 siblings, 0 replies; 32+ messages in thread
From: Uwe Kleine-König @ 2010-10-24 19:20 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Lothar,

On Sun, Oct 24, 2010 at 10:37:19AM +0200, Lothar Wa?mann wrote:
> Hi,
> > >> How do you suggest I define this pin for Babbage board only? Do I add to iomux-mx51.h
> > >> #define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21             IOMUX_PAD(0x45c, 0x0c8, 1, 0x0,
> > >0,MX51_GPIO_PAD_CTRL | PAD_CTL_PUS_100K_UP) ?
> > >>
> > >> Or do I define the pin in the board file with a 100K_UP? Like how eukrea_mbimxsd-baseboard.c did for
> > >MBIMXSD_GPIO_3_31?
> > >I'd suggest something local to your machine file.  Unfortunately I don't
> > >see an easy way to reuse the generic MX51_PAD_EIM_A27__GPIO_2_21 to
> > >define your local symbol.  So I think something like you wrote above
> > >should be fine.
> > >
> > >Too bad that
> > >
> > >	#define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21 (MX51_PAD_EIM_A27__GPIO_2_21 | PAD_CTL_PUS_100K_UP)
> > >
> > >doesn't work.
> > 
> > Yes, I also wish I didn't have to redefine the pin just because of PAD setting change. I am going to send out another patch that basically sets the pad_desc.pad_ctrl=PAD_SETTING in mxc_init_board() function. I think it's a bit cleaner than having to redefine the pin.
> > 
> IMO the 'struct pad_desc' should be replaced with an u64 bitmap that
> would allow for the pullup and other definitions that may be board
> specific to be simply or'ed to the pad definition.
> 
> I could try to provide a patch if this is agreed on.
Hmm, I thought about that, too, when writing my mail and when I added
the needed space for a struct pad_desc I stopped when it became >64.
Somehow I must have got it wrong.  After rechecking now it's ==64, so
yes, I'd like it.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
  2010-10-24 19:20               ` Uwe Kleine-König
@ 2010-10-25  7:02                 ` Lothar Waßmann
  -1 siblings, 0 replies; 32+ messages in thread
From: Lothar Waßmann @ 2010-10-25  7:02 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Nguyen Dinh-R00091, amit.kucheria, linux, s.hauer, linux-kernel,
	grant.likely, valentin.longchamp, daniel, bryan.wu,
	linux-arm-kernel

Hi Uwe,

Uwe Kleine-König writes:
> Hi Lothar,
> 
> On Sun, Oct 24, 2010 at 10:37:19AM +0200, Lothar Waßmann wrote:
> > Hi,
> > > >> How do you suggest I define this pin for Babbage board only? Do I add to iomux-mx51.h
> > > >> #define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21             IOMUX_PAD(0x45c, 0x0c8, 1, 0x0,
> > > >0,MX51_GPIO_PAD_CTRL | PAD_CTL_PUS_100K_UP) ?
> > > >>
> > > >> Or do I define the pin in the board file with a 100K_UP? Like how eukrea_mbimxsd-baseboard.c did for
> > > >MBIMXSD_GPIO_3_31?
> > > >I'd suggest something local to your machine file.  Unfortunately I don't
> > > >see an easy way to reuse the generic MX51_PAD_EIM_A27__GPIO_2_21 to
> > > >define your local symbol.  So I think something like you wrote above
> > > >should be fine.
> > > >
> > > >Too bad that
> > > >
> > > >	#define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21 (MX51_PAD_EIM_A27__GPIO_2_21 | PAD_CTL_PUS_100K_UP)
> > > >
> > > >doesn't work.
> > > 
> > > Yes, I also wish I didn't have to redefine the pin just because of PAD setting change. I am going to send out another patch that basically sets the pad_desc.pad_ctrl=PAD_SETTING in mxc_init_board() function. I think it's a bit cleaner than having to redefine the pin.
> > > 
> > IMO the 'struct pad_desc' should be replaced with an u64 bitmap that
> > would allow for the pullup and other definitions that may be board
> > specific to be simply or'ed to the pad definition.
> > 
> > I could try to provide a patch if this is agreed on.
> Hmm, I thought about that, too, when writing my mail and when I added
> the needed space for a struct pad_desc I stopped when it became >64.
> Somehow I must have got it wrong.  After rechecking now it's ==64, so
> yes, I'd like it.
> 
What kernel version should I base it on?
The master branch of git://git.pengutronix.de/git/imx/linux-2.6.git?


Lothar Waßmann
-- 
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Geschäftsführer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info@karo-electronics.de
___________________________________________________________

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
@ 2010-10-25  7:02                 ` Lothar Waßmann
  0 siblings, 0 replies; 32+ messages in thread
From: Lothar Waßmann @ 2010-10-25  7:02 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Uwe,

Uwe Kleine-K?nig writes:
> Hi Lothar,
> 
> On Sun, Oct 24, 2010 at 10:37:19AM +0200, Lothar Wa?mann wrote:
> > Hi,
> > > >> How do you suggest I define this pin for Babbage board only? Do I add to iomux-mx51.h
> > > >> #define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21             IOMUX_PAD(0x45c, 0x0c8, 1, 0x0,
> > > >0,MX51_GPIO_PAD_CTRL | PAD_CTL_PUS_100K_UP) ?
> > > >>
> > > >> Or do I define the pin in the board file with a 100K_UP? Like how eukrea_mbimxsd-baseboard.c did for
> > > >MBIMXSD_GPIO_3_31?
> > > >I'd suggest something local to your machine file.  Unfortunately I don't
> > > >see an easy way to reuse the generic MX51_PAD_EIM_A27__GPIO_2_21 to
> > > >define your local symbol.  So I think something like you wrote above
> > > >should be fine.
> > > >
> > > >Too bad that
> > > >
> > > >	#define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21 (MX51_PAD_EIM_A27__GPIO_2_21 | PAD_CTL_PUS_100K_UP)
> > > >
> > > >doesn't work.
> > > 
> > > Yes, I also wish I didn't have to redefine the pin just because of PAD setting change. I am going to send out another patch that basically sets the pad_desc.pad_ctrl=PAD_SETTING in mxc_init_board() function. I think it's a bit cleaner than having to redefine the pin.
> > > 
> > IMO the 'struct pad_desc' should be replaced with an u64 bitmap that
> > would allow for the pullup and other definitions that may be board
> > specific to be simply or'ed to the pad definition.
> > 
> > I could try to provide a patch if this is agreed on.
> Hmm, I thought about that, too, when writing my mail and when I added
> the needed space for a struct pad_desc I stopped when it became >64.
> Somehow I must have got it wrong.  After rechecking now it's ==64, so
> yes, I'd like it.
> 
What kernel version should I base it on?
The master branch of git://git.pengutronix.de/git/imx/linux-2.6.git?


Lothar Wa?mann
-- 
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info at karo-electronics.de
___________________________________________________________

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
  2010-10-25  7:02                 ` Lothar Waßmann
@ 2010-10-25  7:21                   ` Uwe Kleine-König
  -1 siblings, 0 replies; 32+ messages in thread
From: Uwe Kleine-König @ 2010-10-25  7:21 UTC (permalink / raw)
  To: Lothar Waßmann
  Cc: Nguyen Dinh-R00091, amit.kucheria, linux, s.hauer, linux-kernel,
	grant.likely, valentin.longchamp, daniel, bryan.wu,
	linux-arm-kernel

Hello Lothar,

On Mon, Oct 25, 2010 at 09:02:57AM +0200, Lothar Waßmann wrote:
> Uwe Kleine-König writes:
> > On Sun, Oct 24, 2010 at 10:37:19AM +0200, Lothar Waßmann wrote:
> > > Hi,
> > > > >> How do you suggest I define this pin for Babbage board only? Do I add to iomux-mx51.h
> > > > >> #define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21             IOMUX_PAD(0x45c, 0x0c8, 1, 0x0,
> > > > >0,MX51_GPIO_PAD_CTRL | PAD_CTL_PUS_100K_UP) ?
> > > > >>
> > > > >> Or do I define the pin in the board file with a 100K_UP? Like how eukrea_mbimxsd-baseboard.c did for
> > > > >MBIMXSD_GPIO_3_31?
> > > > >I'd suggest something local to your machine file.  Unfortunately I don't
> > > > >see an easy way to reuse the generic MX51_PAD_EIM_A27__GPIO_2_21 to
> > > > >define your local symbol.  So I think something like you wrote above
> > > > >should be fine.
> > > > >
> > > > >Too bad that
> > > > >
> > > > >	#define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21 (MX51_PAD_EIM_A27__GPIO_2_21 | PAD_CTL_PUS_100K_UP)
> > > > >
> > > > >doesn't work.
> > > > 
> > > > Yes, I also wish I didn't have to redefine the pin just because of PAD setting change. I am going to send out another patch that basically sets the pad_desc.pad_ctrl=PAD_SETTING in mxc_init_board() function. I think it's a bit cleaner than having to redefine the pin.
> > > > 
> > > IMO the 'struct pad_desc' should be replaced with an u64 bitmap that
> > > would allow for the pullup and other definitions that may be board
> > > specific to be simply or'ed to the pad definition.
> > > 
> > > I could try to provide a patch if this is agreed on.
> > Hmm, I thought about that, too, when writing my mail and when I added
> > the needed space for a struct pad_desc I stopped when it became >64.
> > Somehow I must have got it wrong.  After rechecking now it's ==64, so
> > yes, I'd like it.
> > 
> What kernel version should I base it on?
> The master branch of git://git.pengutronix.de/git/imx/linux-2.6.git?
I'd use the the for-rmk branch that rmk just pulled for .37.  imx/master
is at v2.6.35-rc4 which feels wrong.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc
@ 2010-10-25  7:21                   ` Uwe Kleine-König
  0 siblings, 0 replies; 32+ messages in thread
From: Uwe Kleine-König @ 2010-10-25  7:21 UTC (permalink / raw)
  To: linux-arm-kernel

Hello Lothar,

On Mon, Oct 25, 2010 at 09:02:57AM +0200, Lothar Wa?mann wrote:
> Uwe Kleine-K?nig writes:
> > On Sun, Oct 24, 2010 at 10:37:19AM +0200, Lothar Wa?mann wrote:
> > > Hi,
> > > > >> How do you suggest I define this pin for Babbage board only? Do I add to iomux-mx51.h
> > > > >> #define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21             IOMUX_PAD(0x45c, 0x0c8, 1, 0x0,
> > > > >0,MX51_GPIO_PAD_CTRL | PAD_CTL_PUS_100K_UP) ?
> > > > >>
> > > > >> Or do I define the pin in the board file with a 100K_UP? Like how eukrea_mbimxsd-baseboard.c did for
> > > > >MBIMXSD_GPIO_3_31?
> > > > >I'd suggest something local to your machine file.  Unfortunately I don't
> > > > >see an easy way to reuse the generic MX51_PAD_EIM_A27__GPIO_2_21 to
> > > > >define your local symbol.  So I think something like you wrote above
> > > > >should be fine.
> > > > >
> > > > >Too bad that
> > > > >
> > > > >	#define MX51_BABBAGE_PAD_EIM_A27__GPIO_2_21 (MX51_PAD_EIM_A27__GPIO_2_21 | PAD_CTL_PUS_100K_UP)
> > > > >
> > > > >doesn't work.
> > > > 
> > > > Yes, I also wish I didn't have to redefine the pin just because of PAD setting change. I am going to send out another patch that basically sets the pad_desc.pad_ctrl=PAD_SETTING in mxc_init_board() function. I think it's a bit cleaner than having to redefine the pin.
> > > > 
> > > IMO the 'struct pad_desc' should be replaced with an u64 bitmap that
> > > would allow for the pullup and other definitions that may be board
> > > specific to be simply or'ed to the pad definition.
> > > 
> > > I could try to provide a patch if this is agreed on.
> > Hmm, I thought about that, too, when writing my mail and when I added
> > the needed space for a struct pad_desc I stopped when it became >64.
> > Somehow I must have got it wrong.  After rechecking now it's ==64, so
> > yes, I'd like it.
> > 
> What kernel version should I base it on?
> The master branch of git://git.pengutronix.de/git/imx/linux-2.6.git?
I'd use the the for-rmk branch that rmk just pulled for .37.  imx/master
is at v2.6.35-rc4 which feels wrong.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH RFC] MXC IOMUX-V3 replace struct pad_desc with bitmapped cookie
  2010-10-25  7:21                   ` Uwe Kleine-König
  (?)
@ 2010-10-26  9:07                   ` Lothar Wa�mann
  2010-10-26  9:07                     ` Lothar Wa�mann
                                       ` (3 more replies)
  -1 siblings, 4 replies; 32+ messages in thread
From: Lothar Wa�mann @ 2010-10-26  9:07 UTC (permalink / raw)
  To: linux-arm-kernel

The following patch is a first step to convert the 'struct pad_desc'
to a bitmapped cookie to facilitate adding platform specific pullup or
drive strength definitions to existing pad definitions without need to
rewrite the complete pad def.

The patch wraps 'struct pad_desc' in an opaque data type and
introduces macros to access the individual members.
This patch does not constitute any functional change!

BTW: 'mx51_defconfig' produces the following compile error:
|fs/built-in.o: In function `nfs_callback_authenticate':
|file.c:(.text+0xd9274): undefined reference to `svc_gss_principal'

and 'mx3_defconfig':
|/usr/local/src/arm/linux-2.6-ptx/arch/arm/mach-mx3/devices.c:91: error: 'MX35_INT_MMC_SDHC2' undeclared here (not in a function)

Signed-Off-By: Lothar Wa?mann <LW@KARO-electronics.de>
---
 mach-mx25/eukrea_mbimxsd-baseboard.c |    2 +-
 mach-mx25/mach-cpuimx25.c            |    2 +-
 mach-mx25/mach-mx25_3ds.c            |    2 +-
 mach-mx3/eukrea_mbimxsd-baseboard.c  |    2 +-
 mach-mx3/mach-cpuimx35.c             |    2 +-
 mach-mx3/mach-mx35_3ds.c             |    2 +-
 mach-mx3/mach-pcm043.c               |   16 ++++++++--------
 mach-mx5/board-cpuimx51.c            |    2 +-
 mach-mx5/board-cpuimx51sd.c          |    2 +-
 mach-mx5/board-mx51_3ds.c            |    2 +-
 mach-mx5/board-mx51_babbage.c        |    8 ++++----
 mach-mx5/board-mx51_efikamx.c        |    2 +-
 mach-mx5/eukrea_mbimx51-baseboard.c  |    2 +-
 mach-mx5/eukrea_mbimxsd-baseboard.c  |    2 +-
 plat-mxc/include/mach/iomux-v3.h     |   15 +++++++++++----
 plat-mxc/iomux-v3.c                  |   22 +++++++++++-----------
 16 files changed, 46 insertions(+), 39 deletions(-)

diff --git a/arch/arm/mach-mx25/eukrea_mbimxsd-baseboard.c b/arch/arm/mach-mx25/eukrea_mbimxsd-baseboard.c
index e765ac5..690a940 100644
--- a/arch/arm/mach-mx25/eukrea_mbimxsd-baseboard.c
+++ b/arch/arm/mach-mx25/eukrea_mbimxsd-baseboard.c
@@ -39,7 +39,7 @@
 #include "devices-imx25.h"
 #include "devices.h"
 
-static struct pad_desc eukrea_mbimxsd_pads[] = {
+static iomux_v3_cfg_t eukrea_mbimxsd_pads[] = {
 	/* LCD */
 	MX25_PAD_LD0__LD0,
 	MX25_PAD_LD1__LD1,
diff --git a/arch/arm/mach-mx25/mach-cpuimx25.c b/arch/arm/mach-mx25/mach-cpuimx25.c
index 3b28a75..0f6e658 100644
--- a/arch/arm/mach-mx25/mach-cpuimx25.c
+++ b/arch/arm/mach-mx25/mach-cpuimx25.c
@@ -49,7 +49,7 @@ static const struct imxuart_platform_data uart_pdata __initconst = {
 	.flags = IMXUART_HAVE_RTSCTS,
 };
 
-static struct pad_desc eukrea_cpuimx25_pads[] = {
+static iomux_v3_cfg_t eukrea_cpuimx25_pads[] = {
 	/* FEC - RMII */
 	MX25_PAD_FEC_MDC__FEC_MDC,
 	MX25_PAD_FEC_MDIO__FEC_MDIO,
diff --git a/arch/arm/mach-mx25/mach-mx25_3ds.c b/arch/arm/mach-mx25/mach-mx25_3ds.c
index bd18056..44973dc 100644
--- a/arch/arm/mach-mx25/mach-mx25_3ds.c
+++ b/arch/arm/mach-mx25/mach-mx25_3ds.c
@@ -49,7 +49,7 @@ static const struct imxuart_platform_data uart_pdata __initconst = {
 	.flags = IMXUART_HAVE_RTSCTS,
 };
 
-static struct pad_desc mx25pdk_pads[] = {
+static iomux_v3_cfg_t mx25pdk_pads[] = {
 	MX25_PAD_FEC_MDC__FEC_MDC,
 	MX25_PAD_FEC_MDIO__FEC_MDIO,
 	MX25_PAD_FEC_TDATA0__FEC_TDATA0,
diff --git a/arch/arm/mach-mx3/eukrea_mbimxsd-baseboard.c b/arch/arm/mach-mx3/eukrea_mbimxsd-baseboard.c
index 1abc10d..3e644cf 100644
--- a/arch/arm/mach-mx3/eukrea_mbimxsd-baseboard.c
+++ b/arch/arm/mach-mx3/eukrea_mbimxsd-baseboard.c
@@ -111,7 +111,7 @@ static struct mx3fb_platform_data mx3fb_pdata = {
 	.num_modes	= ARRAY_SIZE(fb_modedb),
 };
 
-static struct pad_desc eukrea_mbimxsd_pads[] = {
+static iomux_v3_cfg_t eukrea_mbimxsd_pads[] = {
 	/* LCD */
 	MX35_PAD_LD0__IPU_DISPB_DAT_0,
 	MX35_PAD_LD1__IPU_DISPB_DAT_1,
diff --git a/arch/arm/mach-mx3/mach-cpuimx35.c b/arch/arm/mach-mx3/mach-cpuimx35.c
index bf2d6e2..8982515 100644
--- a/arch/arm/mach-mx3/mach-cpuimx35.c
+++ b/arch/arm/mach-mx3/mach-cpuimx35.c
@@ -78,7 +78,7 @@ static struct platform_device *devices[] __initdata = {
 	&imx_wdt_device0,
 };
 
-static struct pad_desc eukrea_cpuimx35_pads[] = {
+static iomux_v3_cfg_t eukrea_cpuimx35_pads[] = {
 	/* UART1 */
 	MX35_PAD_CTS1__UART1_CTS,
 	MX35_PAD_RTS1__UART1_RTS,
diff --git a/arch/arm/mach-mx3/mach-mx35_3ds.c b/arch/arm/mach-mx3/mach-mx35_3ds.c
index 91bb065..79d5cff 100644
--- a/arch/arm/mach-mx3/mach-mx35_3ds.c
+++ b/arch/arm/mach-mx3/mach-mx35_3ds.c
@@ -77,7 +77,7 @@ static struct platform_device *devices[] __initdata = {
 	&mx35pdk_flash,
 };
 
-static struct pad_desc mx35pdk_pads[] = {
+static iomux_v3_cfg_t mx35pdk_pads[] = {
 	/* UART1 */
 	MX35_PAD_CTS1__UART1_CTS,
 	MX35_PAD_RTS1__UART1_RTS,
diff --git a/arch/arm/mach-mx3/mach-pcm043.c b/arch/arm/mach-mx3/mach-pcm043.c
index a9397a4..a76bfc0 100644
--- a/arch/arm/mach-mx3/mach-pcm043.c
+++ b/arch/arm/mach-mx3/mach-pcm043.c
@@ -143,7 +143,7 @@ static struct platform_device *devices[] __initdata = {
 	&imx_wdt_device0,
 };
 
-static struct pad_desc pcm043_pads[] = {
+static iomux_v3_cfg_t pcm043_pads[] = {
 	/* UART1 */
 	MX35_PAD_CTS1__UART1_CTS,
 	MX35_PAD_RTS1__UART1_RTS,
@@ -230,8 +230,8 @@ static struct pad_desc pcm043_pads[] = {
 
 static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97)
 {
-	struct pad_desc txfs_gpio = MX35_PAD_STXFS4__GPIO2_31;
-	struct pad_desc txfs = MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS;
+	iomux_v3_cfg_t txfs_gpio = MX35_PAD_STXFS4__GPIO2_31;
+	iomux_v3_cfg_t txfs = MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS;
 	int ret;
 
 	ret = gpio_request(AC97_GPIO_TXFS, "SSI");
@@ -253,11 +253,11 @@ static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97)
 
 static void pcm043_ac97_cold_reset(struct snd_ac97 *ac97)
 {
-	struct pad_desc txfs_gpio = MX35_PAD_STXFS4__GPIO2_31;
-	struct pad_desc txfs = MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS;
-	struct pad_desc txd_gpio = MX35_PAD_STXD4__GPIO2_28;
-	struct pad_desc txd = MX35_PAD_STXD4__AUDMUX_AUD4_TXD;
-	struct pad_desc reset_gpio = MX35_PAD_SD2_CMD__GPIO2_0;
+	iomux_v3_cfg_t txfs_gpio = MX35_PAD_STXFS4__GPIO2_31;
+	iomux_v3_cfg_t txfs = MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS;
+	iomux_v3_cfg_t txd_gpio = MX35_PAD_STXD4__GPIO2_28;
+	iomux_v3_cfg_t txd = MX35_PAD_STXD4__AUDMUX_AUD4_TXD;
+	iomux_v3_cfg_t reset_gpio = MX35_PAD_SD2_CMD__GPIO2_0;
 	int ret;
 
 	ret = gpio_request(AC97_GPIO_TXFS, "SSI");
diff --git a/arch/arm/mach-mx5/board-cpuimx51.c b/arch/arm/mach-mx5/board-cpuimx51.c
index 378f532..e188562 100644
--- a/arch/arm/mach-mx5/board-cpuimx51.c
+++ b/arch/arm/mach-mx5/board-cpuimx51.c
@@ -113,7 +113,7 @@ static struct platform_device *devices[] __initdata = {
 #endif
 };
 
-static struct pad_desc eukrea_cpuimx51_pads[] = {
+static iomux_v3_cfg_t eukrea_cpuimx51_pads[] = {
 	/* UART1 */
 	MX51_PAD_UART1_RXD__UART1_RXD,
 	MX51_PAD_UART1_TXD__UART1_TXD,
diff --git a/arch/arm/mach-mx5/board-cpuimx51sd.c b/arch/arm/mach-mx5/board-cpuimx51sd.c
index bd5eb61..e2297b4 100644
--- a/arch/arm/mach-mx5/board-cpuimx51sd.c
+++ b/arch/arm/mach-mx5/board-cpuimx51sd.c
@@ -68,7 +68,7 @@
 #define CPUIMX51SD_GPIO_3_12 IOMUX_PAD(0x57C, 0x194, 3, 0x0, 0, \
 				MX51_PAD_CTRL_1 | PAD_CTL_PUS_22K_UP)
 
-static struct pad_desc eukrea_cpuimx51sd_pads[] = {
+static iomux_v3_cfg_t eukrea_cpuimx51sd_pads[] = {
 	/* UART1 */
 	MX51_PAD_UART1_RXD__UART1_RXD,
 	MX51_PAD_UART1_TXD__UART1_TXD,
diff --git a/arch/arm/mach-mx5/board-mx51_3ds.c b/arch/arm/mach-mx5/board-mx51_3ds.c
index ed08a23..68d07cc 100644
--- a/arch/arm/mach-mx5/board-mx51_3ds.c
+++ b/arch/arm/mach-mx5/board-mx51_3ds.c
@@ -30,7 +30,7 @@
 #define EXPIO_PARENT_INT	(MXC_INTERNAL_IRQS + GPIO_PORTA + 6)
 #define MX51_3DS_ECSPI2_CS	(GPIO_PORTC + 28)
 
-static struct pad_desc mx51_3ds_pads[] = {
+static iomux_v3_cfg_t mx51_3ds_pads[] = {
 	/* UART1 */
 	MX51_PAD_UART1_RXD__UART1_RXD,
 	MX51_PAD_UART1_TXD__UART1_TXD,
diff --git a/arch/arm/mach-mx5/board-mx51_babbage.c b/arch/arm/mach-mx5/board-mx51_babbage.c
index 23ee4a4..74bbdf4 100644
--- a/arch/arm/mach-mx5/board-mx51_babbage.c
+++ b/arch/arm/mach-mx5/board-mx51_babbage.c
@@ -46,7 +46,7 @@
 #define	MX51_USB_PLL_DIV_19_2_MHZ	0x01
 #define	MX51_USB_PLL_DIV_24_MHZ	0x02
 
-static struct pad_desc mx51babbage_pads[] = {
+static iomux_v3_cfg_t mx51babbage_pads[] = {
 	/* UART1 */
 	MX51_PAD_UART1_RXD__UART1_RXD,
 	MX51_PAD_UART1_TXD__UART1_TXD,
@@ -142,8 +142,8 @@ static struct imxi2c_platform_data babbage_hsi2c_data = {
 
 static int gpio_usbh1_active(void)
 {
-	struct pad_desc usbh1stp_gpio = MX51_PAD_USBH1_STP__GPIO_1_27;
-	struct pad_desc phyreset_gpio = MX51_PAD_EIM_D21__GPIO_2_5;
+	iomux_v3_cfg_t usbh1stp_gpio = MX51_PAD_USBH1_STP__GPIO_1_27;
+	iomux_v3_cfg_t phyreset_gpio = MX51_PAD_EIM_D21__GPIO_2_5;
 	int ret;
 
 	/* Set USBH1_STP to GPIO and toggle it */
@@ -280,7 +280,7 @@ __setup("otg_mode=", babbage_otg_mode);
  */
 static void __init mxc_board_init(void)
 {
-	struct pad_desc usbh1stp = MX51_PAD_USBH1_STP__USBH1_STP;
+	iomux_v3_cfg_t usbh1stp = MX51_PAD_USBH1_STP__USBH1_STP;
 
 	mxc_iomux_v3_setup_multiple_pads(mx51babbage_pads,
 					ARRAY_SIZE(mx51babbage_pads));
diff --git a/arch/arm/mach-mx5/board-mx51_efikamx.c b/arch/arm/mach-mx5/board-mx51_efikamx.c
index b00502a..865a94b 100644
--- a/arch/arm/mach-mx5/board-mx51_efikamx.c
+++ b/arch/arm/mach-mx5/board-mx51_efikamx.c
@@ -39,7 +39,7 @@
 
 #define	MX51_USB_PLL_DIV_24_MHZ	0x01
 
-static struct pad_desc mx51efikamx_pads[] = {
+static iomux_v3_cfg_t mx51efikamx_pads[] = {
 	/* UART1 */
 	MX51_PAD_UART1_RXD__UART1_RXD,
 	MX51_PAD_UART1_TXD__UART1_TXD,
diff --git a/arch/arm/mach-mx5/eukrea_mbimx51-baseboard.c b/arch/arm/mach-mx5/eukrea_mbimx51-baseboard.c
index a2e6e8c..f0b09ec 100644
--- a/arch/arm/mach-mx5/eukrea_mbimx51-baseboard.c
+++ b/arch/arm/mach-mx5/eukrea_mbimx51-baseboard.c
@@ -84,7 +84,7 @@ static struct platform_device *devices[] __initdata = {
 	&mbimx51_leds_gpio,
 };
 
-static struct pad_desc mbimx51_pads[] = {
+static iomux_v3_cfg_t mbimx51_pads[] = {
 	/* UART2 */
 	MX51_PAD_UART2_RXD__UART2_RXD,
 	MX51_PAD_UART2_TXD__UART2_TXD,
diff --git a/arch/arm/mach-mx5/eukrea_mbimxsd-baseboard.c b/arch/arm/mach-mx5/eukrea_mbimxsd-baseboard.c
index 2b48f51..8c9c5e5 100644
--- a/arch/arm/mach-mx5/eukrea_mbimxsd-baseboard.c
+++ b/arch/arm/mach-mx5/eukrea_mbimxsd-baseboard.c
@@ -48,7 +48,7 @@
 #define MBIMXSD_GPIO_3_31 IOMUX_PAD(0x554, 0x16C, 3, 0x0, 0, \
 				MX51_PAD_CTRL_1 | PAD_CTL_PUS_22K_UP)
 
-static struct pad_desc eukrea_mbimxsd_pads[] = {
+static iomux_v3_cfg_t eukrea_mbimxsd_pads[] = {
 	/* LED */
 	MX51_PAD_NANDF_D10__GPIO_3_30,
 	/* SWITCH */
diff --git a/arch/arm/plat-mxc/include/mach/iomux-v3.h b/arch/arm/plat-mxc/include/mach/iomux-v3.h
index 0880a4a..d101cf7 100644
--- a/arch/arm/plat-mxc/include/mach/iomux-v3.h
+++ b/arch/arm/plat-mxc/include/mach/iomux-v3.h
@@ -44,7 +44,7 @@
  *
  */
 
-struct pad_desc {
+typedef struct pad_desc {
 	unsigned mux_ctrl_ofs:12; /* IOMUXC_SW_MUX_CTL_PAD offset */
 	unsigned mux_mode:8;
 	unsigned pad_ctrl_ofs:12; /* IOMUXC_SW_PAD_CTRL offset */
@@ -52,7 +52,14 @@ struct pad_desc {
 	unsigned pad_ctrl:17;
 	unsigned select_input_ofs:12; /* IOMUXC_SELECT_INPUT offset */
 	unsigned select_input:3;
-};
+} iomux_v3_cfg_t;
+
+#define MUX_CTRL_OFS(pad)		(pad)->mux_ctrl_ofs
+#define MUX_MODE(pad)			(pad)->mux_mode
+#define MUX_SELECT_INPUT_OFS(pad)	(pad)->select_input_ofs
+#define MUX_SELECT_INPUT(pad)		(pad)->select_input
+#define MUX_PAD_CTRL_OFS(pad)		(pad)->pad_ctrl_ofs
+#define MUX_PAD_CTRL(pad)		(pad)->pad_ctrl
 
 #define IOMUX_PAD(_pad_ctrl_ofs, _mux_ctrl_ofs, _mux_mode, _select_input_ofs, \
 		_select_input, _pad_ctrl)				\
@@ -107,13 +114,13 @@ struct pad_desc {
 /*
  * setups a single pad in the iomuxer
  */
-int mxc_iomux_v3_setup_pad(struct pad_desc *pad);
+int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t *pad);
 
 /*
  * setups mutliple pads
  * convenient way to call the above function with tables
  */
-int mxc_iomux_v3_setup_multiple_pads(struct pad_desc *pad_list, unsigned count);
+int mxc_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t *pad_list, unsigned count);
 
 /*
  * Initialise the iomux controller
diff --git a/arch/arm/plat-mxc/iomux-v3.c b/arch/arm/plat-mxc/iomux-v3.c
index b318c6a..975ca7c 100644
--- a/arch/arm/plat-mxc/iomux-v3.c
+++ b/arch/arm/plat-mxc/iomux-v3.c
@@ -32,26 +32,26 @@
 static void __iomem *base;
 
 /*
- * setups a single pad in the iomuxer
+ * configures a single pad in the iomuxer
  */
-int mxc_iomux_v3_setup_pad(struct pad_desc *pad)
+int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t *pad)
 {
-	if (pad->mux_ctrl_ofs)
-		__raw_writel(pad->mux_mode, base + pad->mux_ctrl_ofs);
+	if (MUX_CTRL_OFS(pad))
+		__raw_writel(MUX_MODE(pad), base + MUX_CTRL_OFS(pad));
 
-	if (pad->select_input_ofs)
-		__raw_writel(pad->select_input,
-				base + pad->select_input_ofs);
+	if (MUX_SELECT_INPUT_OFS(pad))
+		__raw_writel(MUX_SELECT_INPUT(pad),
+			base + MUX_SELECT_INPUT(pad));
 
-	if (!(pad->pad_ctrl & NO_PAD_CTRL) && pad->pad_ctrl_ofs)
-		__raw_writel(pad->pad_ctrl, base + pad->pad_ctrl_ofs);
+	if (!(MUX_PAD_CTRL(pad) & NO_PAD_CTRL) && MUX_PAD_CTRL_OFS(pad))
+		__raw_writel(MUX_PAD_CTRL(pad), base + MUX_PAD_CTRL_OFS(pad));
 	return 0;
 }
 EXPORT_SYMBOL(mxc_iomux_v3_setup_pad);
 
-int mxc_iomux_v3_setup_multiple_pads(struct pad_desc *pad_list, unsigned count)
+int mxc_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t *pad_list, unsigned count)
 {
-	struct pad_desc *p = pad_list;
+	iomux_v3_cfg_t *p = pad_list;
 	int i;
 	int ret;
 

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH RFC] MXC IOMUX-V3 replace struct pad_desc with bitmapped cookie
  2010-10-26  9:07                   ` [PATCH RFC] MXC IOMUX-V3 replace struct pad_desc with bitmapped cookie Lothar Wa�mann
@ 2010-10-26  9:07                     ` Lothar Wa�mann
  2010-10-26  9:23                     ` Uwe Kleine-König
                                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 32+ messages in thread
From: Lothar Wa�mann @ 2010-10-26  9:07 UTC (permalink / raw)
  To: linux-arm-kernel

-static struct pad_desc eukrea_mbimxsd_pads[] = {
+static iomux_v3_cfg_t eukrea_mbimxsd_pads[] = {
 	/* LCD */
 	MX25_PAD_LD0__LD0,
 	MX25_PAD_LD1__LD1,
diff --git a/arch/arm/mach-mx25/mach-cpuimx25.c b/arch/arm/mach-mx25/mach-cpuimx25.c
index 3b28a75..0f6e658 100644
--- a/arch/arm/mach-mx25/mach-cpuimx25.c
+++ b/arch/arm/mach-mx25/mach-cpuimx25.c
@@ -49,7 +49,7 @@ static const struct imxuart_platform_data uart_pdata __initconst = {
 	.flags = IMXUART_HAVE_RTSCTS,
 };
 
-static struct pad_desc eukrea_cpuimx25_pads[] = {
+static iomux_v3_cfg_t eukrea_cpuimx25_pads[] = {
 	/* FEC - RMII */
 	MX25_PAD_FEC_MDC__FEC_MDC,
 	MX25_PAD_FEC_MDIO__FEC_MDIO,
diff --git a/arch/arm/mach-mx25/mach-mx25_3ds.c b/arch/arm/mach-mx25/mach-mx25_3ds.c
index bd18056..44973dc 100644
--- a/arch/arm/mach-mx25/mach-mx25_3ds.c
+++ b/arch/arm/mach-mx25/mach-mx25_3ds.c
@@ -49,7 +49,7 @@ static const struct imxuart_platform_data uart_pdata __initconst = {
 	.flags = IMXUART_HAVE_RTSCTS,
 };
 
-static struct pad_desc mx25pdk_pads[] = {
+static iomux_v3_cfg_t mx25pdk_pads[] = {
 	MX25_PAD_FEC_MDC__FEC_MDC,
 	MX25_PAD_FEC_MDIO__FEC_MDIO,
 	MX25_PAD_FEC_TDATA0__FEC_TDATA0,
diff --git a/arch/arm/mach-mx3/eukrea_mbimxsd-baseboard.c b/arch/arm/mach-mx3/eukrea_mbimxsd-baseboard.c
index 1abc10d..3e644cf 100644
--- a/arch/arm/mach-mx3/eukrea_mbimxsd-baseboard.c
+++ b/arch/arm/mach-mx3/eukrea_mbimxsd-baseboard.c
@@ -111,7 +111,7 @@ static struct mx3fb_platform_data mx3fb_pdata = {
 	.num_modes	= ARRAY_SIZE(fb_modedb),
 };
 
-static struct pad_desc eukrea_mbimxsd_pads[] = {
+static iomux_v3_cfg_t eukrea_mbimxsd_pads[] = {
 	/* LCD */
 	MX35_PAD_LD0__IPU_DISPB_DAT_0,
 	MX35_PAD_LD1__IPU_DISPB_DAT_1,
diff --git a/arch/arm/mach-mx3/mach-cpuimx35.c b/arch/arm/mach-mx3/mach-cpuimx35.c
index bf2d6e2..8982515 100644
--- a/arch/arm/mach-mx3/mach-cpuimx35.c
+++ b/arch/arm/mach-mx3/mach-cpuimx35.c
@@ -78,7 +78,7 @@ static struct platform_device *devices[] __initdata = {
 	&imx_wdt_device0,
 };
 
-static struct pad_desc eukrea_cpuimx35_pads[] = {
+static iomux_v3_cfg_t eukrea_cpuimx35_pads[] = {
 	/* UART1 */
 	MX35_PAD_CTS1__UART1_CTS,
 	MX35_PAD_RTS1__UART1_RTS,
diff --git a/arch/arm/mach-mx3/mach-mx35_3ds.c b/arch/arm/mach-mx3/mach-mx35_3ds.c
index 91bb065..79d5cff 100644
--- a/arch/arm/mach-mx3/mach-mx35_3ds.c
+++ b/arch/arm/mach-mx3/mach-mx35_3ds.c
@@ -77,7 +77,7 @@ static struct platform_device *devices[] __initdata = {
 	&mx35pdk_flash,
 };
 
-static struct pad_desc mx35pdk_pads[] = {
+static iomux_v3_cfg_t mx35pdk_pads[] = {
 	/* UART1 */
 	MX35_PAD_CTS1__UART1_CTS,
 	MX35_PAD_RTS1__UART1_RTS,
diff --git a/arch/arm/mach-mx3/mach-pcm043.c b/arch/arm/mach-mx3/mach-pcm043.c
index a9397a4..a76bfc0 100644
--- a/arch/arm/mach-mx3/mach-pcm043.c
+++ b/arch/arm/mach-mx3/mach-pcm043.c
@@ -143,7 +143,7 @@ static struct platform_device *devices[] __initdata = {
 	&imx_wdt_device0,
 };
 
-static struct pad_desc pcm043_pads[] = {
+static iomux_v3_cfg_t pcm043_pads[] = {
 	/* UART1 */
 	MX35_PAD_CTS1__UART1_CTS,
 	MX35_PAD_RTS1__UART1_RTS,
@@ -230,8 +230,8 @@ static struct pad_desc pcm043_pads[] = {
 
 static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97)
 {
-	struct pad_desc txfs_gpio = MX35_PAD_STXFS4__GPIO2_31;
-	struct pad_desc txfs = MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS;
+	iomux_v3_cfg_t txfs_gpio = MX35_PAD_STXFS4__GPIO2_31;
+	iomux_v3_cfg_t txfs = MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS;
 	int ret;
 
 	ret = gpio_request(AC97_GPIO_TXFS, "SSI");
@@ -253,11 +253,11 @@ static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97)
 
 static void pcm043_ac97_cold_reset(struct snd_ac97 *ac97)
 {
-	struct pad_desc txfs_gpio = MX35_PAD_STXFS4__GPIO2_31;
-	struct pad_desc txfs = MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS;
-	struct pad_desc txd_gpio = MX35_PAD_STXD4__GPIO2_28;
-	struct pad_desc txd = MX35_PAD_STXD4__AUDMUX_AUD4_TXD;
-	struct pad_desc reset_gpio = MX35_PAD_SD2_CMD__GPIO2_0;
+	iomux_v3_cfg_t txfs_gpio = MX35_PAD_STXFS4__GPIO2_31;
+	iomux_v3_cfg_t txfs = MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS;
+	iomux_v3_cfg_t txd_gpio = MX35_PAD_STXD4__GPIO2_28;
+	iomux_v3_cfg_t txd = MX35_PAD_STXD4__AUDMUX_AUD4_TXD;
+	iomux_v3_cfg_t reset_gpio = MX35_PAD_SD2_CMD__GPIO2_0;
 	int ret;
 
 	ret = gpio_request(AC97_GPIO_TXFS, "SSI");
diff --git a/arch/arm/mach-mx5/board-cpuimx51.c b/arch/arm/mach-mx5/board-cpuimx51.c
index 378f532..e188562 100644
--- a/arch/arm/mach-mx5/board-cpuimx51.c
+++ b/arch/arm/mach-mx5/board-cpuimx51.c
@@ -113,7 +113,7 @@ static struct platform_device *devices[] __initdata = {
 #endif
 };
 
-static struct pad_desc eukrea_cpuimx51_pads[] = {
+static iomux_v3_cfg_t eukrea_cpuimx51_pads[] = {
 	/* UART1 */
 	MX51_PAD_UART1_RXD__UART1_RXD,
 	MX51_PAD_UART1_TXD__UART1_TXD,
diff --git a/arch/arm/mach-mx5/board-cpuimx51sd.c b/arch/arm/mach-mx5/board-cpuimx51sd.c
index bd5eb61..e2297b4 100644
--- a/arch/arm/mach-mx5/board-cpuimx51sd.c
+++ b/arch/arm/mach-mx5/board-cpuimx51sd.c
@@ -68,7 +68,7 @@
 #define CPUIMX51SD_GPIO_3_12 IOMUX_PAD(0x57C, 0x194, 3, 0x0, 0, \
 				MX51_PAD_CTRL_1 | PAD_CTL_PUS_22K_UP)
 
-static struct pad_desc eukrea_cpuimx51sd_pads[] = {
+static iomux_v3_cfg_t eukrea_cpuimx51sd_pads[] = {
 	/* UART1 */
 	MX51_PAD_UART1_RXD__UART1_RXD,
 	MX51_PAD_UART1_TXD__UART1_TXD,
diff --git a/arch/arm/mach-mx5/board-mx51_3ds.c b/arch/arm/mach-mx5/board-mx51_3ds.c
index ed08a23..68d07cc 100644
--- a/arch/arm/mach-mx5/board-mx51_3ds.c
+++ b/arch/arm/mach-mx5/board-mx51_3ds.c
@@ -30,7 +30,7 @@
 #define EXPIO_PARENT_INT	(MXC_INTERNAL_IRQS + GPIO_PORTA + 6)
 #define MX51_3DS_ECSPI2_CS	(GPIO_PORTC + 28)
 
-static struct pad_desc mx51_3ds_pads[] = {
+static iomux_v3_cfg_t mx51_3ds_pads[] = {
 	/* UART1 */
 	MX51_PAD_UART1_RXD__UART1_RXD,
 	MX51_PAD_UART1_TXD__UART1_TXD,
diff --git a/arch/arm/mach-mx5/board-mx51_babbage.c b/arch/arm/mach-mx5/board-mx51_babbage.c
index 23ee4a4..74bbdf4 100644
--- a/arch/arm/mach-mx5/board-mx51_babbage.c
+++ b/arch/arm/mach-mx5/board-mx51_babbage.c
@@ -46,7 +46,7 @@
 #define	MX51_USB_PLL_DIV_19_2_MHZ	0x01
 #define	MX51_USB_PLL_DIV_24_MHZ	0x02
 
-static struct pad_desc mx51babbage_pads[] = {
+static iomux_v3_cfg_t mx51babbage_pads[] = {
 	/* UART1 */
 	MX51_PAD_UART1_RXD__UART1_RXD,
 	MX51_PAD_UART1_TXD__UART1_TXD,
@@ -142,8 +142,8 @@ static struct imxi2c_platform_data babbage_hsi2c_data = {
 
 static int gpio_usbh1_active(void)
 {
-	struct pad_desc usbh1stp_gpio = MX51_PAD_USBH1_STP__GPIO_1_27;
-	struct pad_desc phyreset_gpio = MX51_PAD_EIM_D21__GPIO_2_5;
+	iomux_v3_cfg_t usbh1stp_gpio = MX51_PAD_USBH1_STP__GPIO_1_27;
+	iomux_v3_cfg_t phyreset_gpio = MX51_PAD_EIM_D21__GPIO_2_5;
 	int ret;
 
 	/* Set USBH1_STP to GPIO and toggle it */
@@ -280,7 +280,7 @@ __setup("otg_mode=", babbage_otg_mode);
  */
 static void __init mxc_board_init(void)
 {
-	struct pad_desc usbh1stp = MX51_PAD_USBH1_STP__USBH1_STP;
+	iomux_v3_cfg_t usbh1stp = MX51_PAD_USBH1_STP__USBH1_STP;
 
 	mxc_iomux_v3_setup_multiple_pads(mx51babbage_pads,
 					ARRAY_SIZE(mx51babbage_pads));
diff --git a/arch/arm/mach-mx5/board-mx51_efikamx.c b/arch/arm/mach-mx5/board-mx51_efikamx.c
index b00502a..865a94b 100644
--- a/arch/arm/mach-mx5/board-mx51_efikamx.c
+++ b/arch/arm/mach-mx5/board-mx51_efikamx.c
@@ -39,7 +39,7 @@
 
 #define	MX51_USB_PLL_DIV_24_MHZ	0x01
 
-static struct pad_desc mx51efikamx_pads[] = {
+static iomux_v3_cfg_t mx51efikamx_pads[] = {
 	/* UART1 */
 	MX51_PAD_UART1_RXD__UART1_RXD,
 	MX51_PAD_UART1_TXD__UART1_TXD,
diff --git a/arch/arm/mach-mx5/eukrea_mbimx51-baseboard.c b/arch/arm/mach-mx5/eukrea_mbimx51-baseboard.c
index a2e6e8c..f0b09ec 100644
--- a/arch/arm/mach-mx5/eukrea_mbimx51-baseboard.c
+++ b/arch/arm/mach-mx5/eukrea_mbimx51-baseboard.c
@@ -84,7 +84,7 @@ static struct platform_device *devices[] __initdata = {
 	&mbimx51_leds_gpio,
 };
 
-static struct pad_desc mbimx51_pads[] = {
+static iomux_v3_cfg_t mbimx51_pads[] = {
 	/* UART2 */
 	MX51_PAD_UART2_RXD__UART2_RXD,
 	MX51_PAD_UART2_TXD__UART2_TXD,
diff --git a/arch/arm/mach-mx5/eukrea_mbimxsd-baseboard.c b/arch/arm/mach-mx5/eukrea_mbimxsd-baseboard.c
index 2b48f51..8c9c5e5 100644
--- a/arch/arm/mach-mx5/eukrea_mbimxsd-baseboard.c
+++ b/arch/arm/mach-mx5/eukrea_mbimxsd-baseboard.c
@@ -48,7 +48,7 @@
 #define MBIMXSD_GPIO_3_31 IOMUX_PAD(0x554, 0x16C, 3, 0x0, 0, \
 				MX51_PAD_CTRL_1 | PAD_CTL_PUS_22K_UP)
 
-static struct pad_desc eukrea_mbimxsd_pads[] = {
+static iomux_v3_cfg_t eukrea_mbimxsd_pads[] = {
 	/* LED */
 	MX51_PAD_NANDF_D10__GPIO_3_30,
 	/* SWITCH */
diff --git a/arch/arm/plat-mxc/include/mach/iomux-v3.h b/arch/arm/plat-mxc/include/mach/iomux-v3.h
index 0880a4a..d101cf7 100644
--- a/arch/arm/plat-mxc/include/mach/iomux-v3.h
+++ b/arch/arm/plat-mxc/include/mach/iomux-v3.h
@@ -44,7 +44,7 @@
  *
  */
 
-struct pad_desc {
+typedef struct pad_desc {
 	unsigned mux_ctrl_ofs:12; /* IOMUXC_SW_MUX_CTL_PAD offset */
 	unsigned mux_mode:8;
 	unsigned pad_ctrl_ofs:12; /* IOMUXC_SW_PAD_CTRL offset */
@@ -52,7 +52,14 @@ struct pad_desc {
 	unsigned pad_ctrl:17;
 	unsigned select_input_ofs:12; /* IOMUXC_SELECT_INPUT offset */
 	unsigned select_input:3;
-};
+} iomux_v3_cfg_t;
+
+#define MUX_CTRL_OFS(pad)		(pad)->mux_ctrl_ofs
+#define MUX_MODE(pad)			(pad)->mux_mode
+#define MUX_SELECT_INPUT_OFS(pad)	(pad)->select_input_ofs
+#define MUX_SELECT_INPUT(pad)		(pad)->select_input
+#define MUX_PAD_CTRL_OFS(pad)		(pad)->pad_ctrl_ofs
+#define MUX_PAD_CTRL(pad)		(pad)->pad_ctrl
 
 #define IOMUX_PAD(_pad_ctrl_ofs, _mux_ctrl_ofs, _mux_mode, _select_input_ofs, \
 		_select_input, _pad_ctrl)				\
@@ -107,13 +114,13 @@ struct pad_desc {
 /*
  * setups a single pad in the iomuxer
  */
-int mxc_iomux_v3_setup_pad(struct pad_desc *pad);
+int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t *pad);
 
 /*
  * setups mutliple pads
  * convenient way to call the above function with tables
  */
-int mxc_iomux_v3_setup_multiple_pads(struct pad_desc *pad_list, unsigned count);
+int mxc_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t *pad_list, unsigned count);
 
 /*
  * Initialise the iomux controller
diff --git a/arch/arm/plat-mxc/iomux-v3.c b/arch/arm/plat-mxc/iomux-v3.c
index b318c6a..975ca7c 100644
--- a/arch/arm/plat-mxc/iomux-v3.c
+++ b/arch/arm/plat-mxc/iomux-v3.c
@@ -32,26 +32,26 @@
 static void __iomem *base;
 
 /*
- * setups a single pad in the iomuxer
+ * configures a single pad in the iomuxer
  */
-int mxc_iomux_v3_setup_pad(struct pad_desc *pad)
+int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t *pad)
 {
-	if (pad->mux_ctrl_ofs)
-		__raw_writel(pad->mux_mode, base + pad->mux_ctrl_ofs);
+	if (MUX_CTRL_OFS(pad))
+		__raw_writel(MUX_MODE(pad), base + MUX_CTRL_OFS(pad));
 
-	if (pad->select_input_ofs)
-		__raw_writel(pad->select_input,
-				base + pad->select_input_ofs);
+	if (MUX_SELECT_INPUT_OFS(pad))
+		__raw_writel(MUX_SELECT_INPUT(pad),
+			base + MUX_SELECT_INPUT(pad));
 
-	if (!(pad->pad_ctrl & NO_PAD_CTRL) && pad->pad_ctrl_ofs)
-		__raw_writel(pad->pad_ctrl, base + pad->pad_ctrl_ofs);
+	if (!(MUX_PAD_CTRL(pad) & NO_PAD_CTRL) && MUX_PAD_CTRL_OFS(pad))
+		__raw_writel(MUX_PAD_CTRL(pad), base + MUX_PAD_CTRL_OFS(pad));
 	return 0;
 }
 EXPORT_SYMBOL(mxc_iomux_v3_setup_pad);
 
-int mxc_iomux_v3_setup_multiple_pads(struct pad_desc *pad_list, unsigned count)
+int mxc_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t *pad_list, unsigned count)
 {
-	struct pad_desc *p = pad_list;
+	iomux_v3_cfg_t *p = pad_list;
 	int i;
 	int ret;
 

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH RFC] MXC IOMUX-V3 replace struct pad_desc with bitmapped cookie
  2010-10-26  9:07                   ` [PATCH RFC] MXC IOMUX-V3 replace struct pad_desc with bitmapped cookie Lothar Wa�mann
  2010-10-26  9:07                     ` Lothar Wa�mann
@ 2010-10-26  9:23                     ` Uwe Kleine-König
  2010-10-26 12:28                       ` Lothar Waßmann
  2010-10-26 14:16                     ` Sascha Hauer
  2010-11-22  8:39                     ` [PATCH] MXC IOMUX-V3 replace struct pad_desc with bitmapped cookie (step 2) Lothar Waßmann
  3 siblings, 1 reply; 32+ messages in thread
From: Uwe Kleine-König @ 2010-10-26  9:23 UTC (permalink / raw)
  To: linux-arm-kernel

Hello Lothar,

great you follow up on this.

On Tue, Oct 26, 2010 at 11:07:21AM +0200, Lothar Wa?mann wrote:
> The following patch is a first step to convert the 'struct pad_desc'
> to a bitmapped cookie to facilitate adding platform specific pullup or
> drive strength definitions to existing pad definitions without need to
> rewrite the complete pad def.
> 
> The patch wraps 'struct pad_desc' in an opaque data type and
> introduces macros to access the individual members.
> This patch does not constitute any functional change!
great
 
> BTW: 'mx51_defconfig' produces the following compile error:
> |fs/built-in.o: In function `nfs_callback_authenticate':
> |file.c:(.text+0xd9274): undefined reference to `svc_gss_principal'
If you enable CRYPTO or disable NFSv4 this is gone.  See
http://thread.gmane.org/gmane.linux.kernel/1027380 for some details.
Linus tree doesn't have this problem anymore.

> and 'mx3_defconfig':
> |/usr/local/src/arm/linux-2.6-ptx/arch/arm/mach-mx3/devices.c:91: error: 'MX35_INT_MMC_SDHC2' undeclared here (not in a function)
This is already fixed in Saschas imx-for-2.6.37 branch.
 
> Signed-Off-By: Lothar Wa?mann <LW@KARO-electronics.de>
Something between your fingers and my eyes messed up the encoding of
your mail.


> ---
>  mach-mx25/eukrea_mbimxsd-baseboard.c |    2 +-
>  mach-mx25/mach-cpuimx25.c            |    2 +-
>  mach-mx25/mach-mx25_3ds.c            |    2 +-
>  mach-mx3/eukrea_mbimxsd-baseboard.c  |    2 +-
>  mach-mx3/mach-cpuimx35.c             |    2 +-
>  mach-mx3/mach-mx35_3ds.c             |    2 +-
>  mach-mx3/mach-pcm043.c               |   16 ++++++++--------
>  mach-mx5/board-cpuimx51.c            |    2 +-
>  mach-mx5/board-cpuimx51sd.c          |    2 +-
>  mach-mx5/board-mx51_3ds.c            |    2 +-
>  mach-mx5/board-mx51_babbage.c        |    8 ++++----
>  mach-mx5/board-mx51_efikamx.c        |    2 +-
>  mach-mx5/eukrea_mbimx51-baseboard.c  |    2 +-
>  mach-mx5/eukrea_mbimxsd-baseboard.c  |    2 +-
>  plat-mxc/include/mach/iomux-v3.h     |   15 +++++++++++----
>  plat-mxc/iomux-v3.c                  |   22 +++++++++++-----------
>  16 files changed, 46 insertions(+), 39 deletions(-)
> 
> [...]
> --- a/arch/arm/plat-mxc/include/mach/iomux-v3.h
> +++ b/arch/arm/plat-mxc/include/mach/iomux-v3.h
> @@ -44,7 +44,7 @@
>   *
>   */
>  
> -struct pad_desc {
> +typedef struct pad_desc {
if you remove the "pad_desc" here all users of the old name are catched
by the compiler.

>  	unsigned mux_ctrl_ofs:12; /* IOMUXC_SW_MUX_CTL_PAD offset */
>  	unsigned mux_mode:8;
>  	unsigned pad_ctrl_ofs:12; /* IOMUXC_SW_PAD_CTRL offset */
> @@ -52,7 +52,14 @@ struct pad_desc {
>  	unsigned pad_ctrl:17;
>  	unsigned select_input_ofs:12; /* IOMUXC_SELECT_INPUT offset */
>  	unsigned select_input:3;
> -};
> +} iomux_v3_cfg_t;
> +
> +#define MUX_CTRL_OFS(pad)		(pad)->mux_ctrl_ofs
> +#define MUX_MODE(pad)			(pad)->mux_mode
> +#define MUX_SELECT_INPUT_OFS(pad)	(pad)->select_input_ofs
> +#define MUX_SELECT_INPUT(pad)		(pad)->select_input
> +#define MUX_PAD_CTRL_OFS(pad)		(pad)->pad_ctrl_ofs
> +#define MUX_PAD_CTRL(pad)		(pad)->pad_ctrl
Maybe make these static inlines?  This adds basic type-checking and
doesn't have any downsides AFAIK.

>  #define IOMUX_PAD(_pad_ctrl_ofs, _mux_ctrl_ofs, _mux_mode, _select_input_ofs, \
>  		_select_input, _pad_ctrl)				\
> @@ -107,13 +114,13 @@ struct pad_desc {
>  /*
>   * setups a single pad in the iomuxer
>   */
> -int mxc_iomux_v3_setup_pad(struct pad_desc *pad);
> +int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t *pad);
>  
>  /*
>   * setups mutliple pads
>   * convenient way to call the above function with tables
>   */
> -int mxc_iomux_v3_setup_multiple_pads(struct pad_desc *pad_list, unsigned count);
> +int mxc_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t *pad_list, unsigned count);
>  
>  /*
>   * Initialise the iomux controller
> diff --git a/arch/arm/plat-mxc/iomux-v3.c b/arch/arm/plat-mxc/iomux-v3.c
> index b318c6a..975ca7c 100644
> --- a/arch/arm/plat-mxc/iomux-v3.c
> +++ b/arch/arm/plat-mxc/iomux-v3.c
> @@ -32,26 +32,26 @@
>  static void __iomem *base;
>  
>  /*
> - * setups a single pad in the iomuxer
> + * configures a single pad in the iomuxer
>   */
> -int mxc_iomux_v3_setup_pad(struct pad_desc *pad)
> +int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t *pad)
>  {
> -	if (pad->mux_ctrl_ofs)
> -		__raw_writel(pad->mux_mode, base + pad->mux_ctrl_ofs);
> +	if (MUX_CTRL_OFS(pad))
> +		__raw_writel(MUX_MODE(pad), base + MUX_CTRL_OFS(pad));
>  
> -	if (pad->select_input_ofs)
> -		__raw_writel(pad->select_input,
> -				base + pad->select_input_ofs);
> +	if (MUX_SELECT_INPUT_OFS(pad))
> +		__raw_writel(MUX_SELECT_INPUT(pad),
> +			base + MUX_SELECT_INPUT(pad));
>  
> -	if (!(pad->pad_ctrl & NO_PAD_CTRL) && pad->pad_ctrl_ofs)
> -		__raw_writel(pad->pad_ctrl, base + pad->pad_ctrl_ofs);
> +	if (!(MUX_PAD_CTRL(pad) & NO_PAD_CTRL) && MUX_PAD_CTRL_OFS(pad))
> +		__raw_writel(MUX_PAD_CTRL(pad), base + MUX_PAD_CTRL_OFS(pad));
unrelated to this patch:  I wonder if this is correct.  Maybe something
like:

	if (MUX_PAD_CTRL_OFS(pad))
		__raw_writel(MUX_PAD_CTRL(pad) & ~NO_PAD_CTRL, ...);

to get a defined value (here 0) into the MUX_PAD_CTRL register?  Not
sure this is needed/correct though.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH RFC] MXC IOMUX-V3 replace struct pad_desc with bitmapped cookie
  2010-10-26  9:23                     ` Uwe Kleine-König
@ 2010-10-26 12:28                       ` Lothar Waßmann
  0 siblings, 0 replies; 32+ messages in thread
From: Lothar Waßmann @ 2010-10-26 12:28 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

Uwe Kleine-K?nig writes:
> > Signed-Off-By: Lothar Wa?mann <LW@KARO-electronics.de>
> Something between your fingers and my eyes messed up the encoding of
> your mail.
> 
That was the first time I used git-send-email...
Probably need to configure the default git-encoding.

> > --- a/arch/arm/plat-mxc/include/mach/iomux-v3.h
> > +++ b/arch/arm/plat-mxc/include/mach/iomux-v3.h
> > @@ -44,7 +44,7 @@
> >   *
> >   */
> >  
> > -struct pad_desc {
> > +typedef struct pad_desc {
> if you remove the "pad_desc" here all users of the old name are catched
> by the compiler.
> 
OK.

> >  	unsigned mux_ctrl_ofs:12; /* IOMUXC_SW_MUX_CTL_PAD offset */
> >  	unsigned mux_mode:8;
> >  	unsigned pad_ctrl_ofs:12; /* IOMUXC_SW_PAD_CTRL offset */
> > @@ -52,7 +52,14 @@ struct pad_desc {
> >  	unsigned pad_ctrl:17;
> >  	unsigned select_input_ofs:12; /* IOMUXC_SELECT_INPUT offset */
> >  	unsigned select_input:3;
> > -};
> > +} iomux_v3_cfg_t;
> > +
> > +#define MUX_CTRL_OFS(pad)		(pad)->mux_ctrl_ofs
> > +#define MUX_MODE(pad)			(pad)->mux_mode
> > +#define MUX_SELECT_INPUT_OFS(pad)	(pad)->select_input_ofs
> > +#define MUX_SELECT_INPUT(pad)		(pad)->select_input
> > +#define MUX_PAD_CTRL_OFS(pad)		(pad)->pad_ctrl_ofs
> > +#define MUX_PAD_CTRL(pad)		(pad)->pad_ctrl
> Maybe make these static inlines?  This adds basic type-checking and
> doesn't have any downsides AFAIK.
> 
OK. The code is even better with inline functions.

> > -	if (!(pad->pad_ctrl & NO_PAD_CTRL) && pad->pad_ctrl_ofs)
> > -		__raw_writel(pad->pad_ctrl, base + pad->pad_ctrl_ofs);
> > +	if (!(MUX_PAD_CTRL(pad) & NO_PAD_CTRL) && MUX_PAD_CTRL_OFS(pad))
> > +		__raw_writel(MUX_PAD_CTRL(pad), base + MUX_PAD_CTRL_OFS(pad));
> unrelated to this patch:  I wonder if this is correct.  Maybe something
> like:
> 
> 	if (MUX_PAD_CTRL_OFS(pad))
> 		__raw_writel(MUX_PAD_CTRL(pad) & ~NO_PAD_CTRL, ...);
> 
> to get a defined value (here 0) into the MUX_PAD_CTRL register?  Not
> sure this is needed/correct though.
>
As far as I understand the logic, the flag NO_PAD_CTRL means that the
pad_ctl register should not be touched. This could be one way to have
platform specific pad_ctl values, but with the new apporach there is a
better possibility to achieve this. Thus this flag could be removed in
the final version and explicit pad_ctl values (reset default) given
for all pads. But this may break existing configurations that rely on
some other value being set up by the bootloader or platform init code.

Here is an updated patch:

Signed-Off-By: Lothar Wa?mann <LW@KARO-electronics.de>

diff --git a/arch/arm/mach-mx25/eukrea_mbimxsd-baseboard.c b/arch/arm/mach-mx25/eukrea_mbimxsd-baseboard.c
index e765ac5..690a940 100644
--- a/arch/arm/mach-mx25/eukrea_mbimxsd-baseboard.c
+++ b/arch/arm/mach-mx25/eukrea_mbimxsd-baseboard.c
@@ -39,7 +39,7 @@
 #include "devices-imx25.h"
 #include "devices.h"
 
-static struct pad_desc eukrea_mbimxsd_pads[] = {
+static iomux_v3_cfg_t eukrea_mbimxsd_pads[] = {
 	/* LCD */
 	MX25_PAD_LD0__LD0,
 	MX25_PAD_LD1__LD1,
diff --git a/arch/arm/mach-mx25/mach-cpuimx25.c b/arch/arm/mach-mx25/mach-cpuimx25.c
index 3b28a75..0f6e658 100644
--- a/arch/arm/mach-mx25/mach-cpuimx25.c
+++ b/arch/arm/mach-mx25/mach-cpuimx25.c
@@ -49,7 +49,7 @@ static const struct imxuart_platform_data uart_pdata __initconst = {
 	.flags = IMXUART_HAVE_RTSCTS,
 };
 
-static struct pad_desc eukrea_cpuimx25_pads[] = {
+static iomux_v3_cfg_t eukrea_cpuimx25_pads[] = {
 	/* FEC - RMII */
 	MX25_PAD_FEC_MDC__FEC_MDC,
 	MX25_PAD_FEC_MDIO__FEC_MDIO,
diff --git a/arch/arm/mach-mx25/mach-mx25_3ds.c b/arch/arm/mach-mx25/mach-mx25_3ds.c
index bd18056..44973dc 100644
--- a/arch/arm/mach-mx25/mach-mx25_3ds.c
+++ b/arch/arm/mach-mx25/mach-mx25_3ds.c
@@ -49,7 +49,7 @@ static const struct imxuart_platform_data uart_pdata __initconst = {
 	.flags = IMXUART_HAVE_RTSCTS,
 };
 
-static struct pad_desc mx25pdk_pads[] = {
+static iomux_v3_cfg_t mx25pdk_pads[] = {
 	MX25_PAD_FEC_MDC__FEC_MDC,
 	MX25_PAD_FEC_MDIO__FEC_MDIO,
 	MX25_PAD_FEC_TDATA0__FEC_TDATA0,
diff --git a/arch/arm/mach-mx3/eukrea_mbimxsd-baseboard.c b/arch/arm/mach-mx3/eukrea_mbimxsd-baseboard.c
index 1abc10d..3e644cf 100644
--- a/arch/arm/mach-mx3/eukrea_mbimxsd-baseboard.c
+++ b/arch/arm/mach-mx3/eukrea_mbimxsd-baseboard.c
@@ -111,7 +111,7 @@ static struct mx3fb_platform_data mx3fb_pdata = {
 	.num_modes	= ARRAY_SIZE(fb_modedb),
 };
 
-static struct pad_desc eukrea_mbimxsd_pads[] = {
+static iomux_v3_cfg_t eukrea_mbimxsd_pads[] = {
 	/* LCD */
 	MX35_PAD_LD0__IPU_DISPB_DAT_0,
 	MX35_PAD_LD1__IPU_DISPB_DAT_1,
diff --git a/arch/arm/mach-mx3/mach-cpuimx35.c b/arch/arm/mach-mx3/mach-cpuimx35.c
index bf2d6e2..8982515 100644
--- a/arch/arm/mach-mx3/mach-cpuimx35.c
+++ b/arch/arm/mach-mx3/mach-cpuimx35.c
@@ -78,7 +78,7 @@ static struct platform_device *devices[] __initdata = {
 	&imx_wdt_device0,
 };
 
-static struct pad_desc eukrea_cpuimx35_pads[] = {
+static iomux_v3_cfg_t eukrea_cpuimx35_pads[] = {
 	/* UART1 */
 	MX35_PAD_CTS1__UART1_CTS,
 	MX35_PAD_RTS1__UART1_RTS,
diff --git a/arch/arm/mach-mx3/mach-mx35_3ds.c b/arch/arm/mach-mx3/mach-mx35_3ds.c
index 91bb065..79d5cff 100644
--- a/arch/arm/mach-mx3/mach-mx35_3ds.c
+++ b/arch/arm/mach-mx3/mach-mx35_3ds.c
@@ -77,7 +77,7 @@ static struct platform_device *devices[] __initdata = {
 	&mx35pdk_flash,
 };
 
-static struct pad_desc mx35pdk_pads[] = {
+static iomux_v3_cfg_t mx35pdk_pads[] = {
 	/* UART1 */
 	MX35_PAD_CTS1__UART1_CTS,
 	MX35_PAD_RTS1__UART1_RTS,
diff --git a/arch/arm/mach-mx3/mach-pcm043.c b/arch/arm/mach-mx3/mach-pcm043.c
index a9397a4..a76bfc0 100644
--- a/arch/arm/mach-mx3/mach-pcm043.c
+++ b/arch/arm/mach-mx3/mach-pcm043.c
@@ -143,7 +143,7 @@ static struct platform_device *devices[] __initdata = {
 	&imx_wdt_device0,
 };
 
-static struct pad_desc pcm043_pads[] = {
+static iomux_v3_cfg_t pcm043_pads[] = {
 	/* UART1 */
 	MX35_PAD_CTS1__UART1_CTS,
 	MX35_PAD_RTS1__UART1_RTS,
@@ -230,8 +230,8 @@ static struct pad_desc pcm043_pads[] = {
 
 static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97)
 {
-	struct pad_desc txfs_gpio = MX35_PAD_STXFS4__GPIO2_31;
-	struct pad_desc txfs = MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS;
+	iomux_v3_cfg_t txfs_gpio = MX35_PAD_STXFS4__GPIO2_31;
+	iomux_v3_cfg_t txfs = MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS;
 	int ret;
 
 	ret = gpio_request(AC97_GPIO_TXFS, "SSI");
@@ -253,11 +253,11 @@ static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97)
 
 static void pcm043_ac97_cold_reset(struct snd_ac97 *ac97)
 {
-	struct pad_desc txfs_gpio = MX35_PAD_STXFS4__GPIO2_31;
-	struct pad_desc txfs = MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS;
-	struct pad_desc txd_gpio = MX35_PAD_STXD4__GPIO2_28;
-	struct pad_desc txd = MX35_PAD_STXD4__AUDMUX_AUD4_TXD;
-	struct pad_desc reset_gpio = MX35_PAD_SD2_CMD__GPIO2_0;
+	iomux_v3_cfg_t txfs_gpio = MX35_PAD_STXFS4__GPIO2_31;
+	iomux_v3_cfg_t txfs = MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS;
+	iomux_v3_cfg_t txd_gpio = MX35_PAD_STXD4__GPIO2_28;
+	iomux_v3_cfg_t txd = MX35_PAD_STXD4__AUDMUX_AUD4_TXD;
+	iomux_v3_cfg_t reset_gpio = MX35_PAD_SD2_CMD__GPIO2_0;
 	int ret;
 
 	ret = gpio_request(AC97_GPIO_TXFS, "SSI");
diff --git a/arch/arm/mach-mx5/board-cpuimx51.c b/arch/arm/mach-mx5/board-cpuimx51.c
index 378f532..e188562 100644
--- a/arch/arm/mach-mx5/board-cpuimx51.c
+++ b/arch/arm/mach-mx5/board-cpuimx51.c
@@ -113,7 +113,7 @@ static struct platform_device *devices[] __initdata = {
 #endif
 };
 
-static struct pad_desc eukrea_cpuimx51_pads[] = {
+static iomux_v3_cfg_t eukrea_cpuimx51_pads[] = {
 	/* UART1 */
 	MX51_PAD_UART1_RXD__UART1_RXD,
 	MX51_PAD_UART1_TXD__UART1_TXD,
diff --git a/arch/arm/mach-mx5/board-cpuimx51sd.c b/arch/arm/mach-mx5/board-cpuimx51sd.c
index bd5eb61..e2297b4 100644
--- a/arch/arm/mach-mx5/board-cpuimx51sd.c
+++ b/arch/arm/mach-mx5/board-cpuimx51sd.c
@@ -68,7 +68,7 @@
 #define CPUIMX51SD_GPIO_3_12 IOMUX_PAD(0x57C, 0x194, 3, 0x0, 0, \
 				MX51_PAD_CTRL_1 | PAD_CTL_PUS_22K_UP)
 
-static struct pad_desc eukrea_cpuimx51sd_pads[] = {
+static iomux_v3_cfg_t eukrea_cpuimx51sd_pads[] = {
 	/* UART1 */
 	MX51_PAD_UART1_RXD__UART1_RXD,
 	MX51_PAD_UART1_TXD__UART1_TXD,
diff --git a/arch/arm/mach-mx5/board-mx51_3ds.c b/arch/arm/mach-mx5/board-mx51_3ds.c
index ed08a23..68d07cc 100644
--- a/arch/arm/mach-mx5/board-mx51_3ds.c
+++ b/arch/arm/mach-mx5/board-mx51_3ds.c
@@ -30,7 +30,7 @@
 #define EXPIO_PARENT_INT	(MXC_INTERNAL_IRQS + GPIO_PORTA + 6)
 #define MX51_3DS_ECSPI2_CS	(GPIO_PORTC + 28)
 
-static struct pad_desc mx51_3ds_pads[] = {
+static iomux_v3_cfg_t mx51_3ds_pads[] = {
 	/* UART1 */
 	MX51_PAD_UART1_RXD__UART1_RXD,
 	MX51_PAD_UART1_TXD__UART1_TXD,
diff --git a/arch/arm/mach-mx5/board-mx51_babbage.c b/arch/arm/mach-mx5/board-mx51_babbage.c
index 23ee4a4..74bbdf4 100644
--- a/arch/arm/mach-mx5/board-mx51_babbage.c
+++ b/arch/arm/mach-mx5/board-mx51_babbage.c
@@ -46,7 +46,7 @@
 #define	MX51_USB_PLL_DIV_19_2_MHZ	0x01
 #define	MX51_USB_PLL_DIV_24_MHZ	0x02
 
-static struct pad_desc mx51babbage_pads[] = {
+static iomux_v3_cfg_t mx51babbage_pads[] = {
 	/* UART1 */
 	MX51_PAD_UART1_RXD__UART1_RXD,
 	MX51_PAD_UART1_TXD__UART1_TXD,
@@ -142,8 +142,8 @@ static struct imxi2c_platform_data babbage_hsi2c_data = {
 
 static int gpio_usbh1_active(void)
 {
-	struct pad_desc usbh1stp_gpio = MX51_PAD_USBH1_STP__GPIO_1_27;
-	struct pad_desc phyreset_gpio = MX51_PAD_EIM_D21__GPIO_2_5;
+	iomux_v3_cfg_t usbh1stp_gpio = MX51_PAD_USBH1_STP__GPIO_1_27;
+	iomux_v3_cfg_t phyreset_gpio = MX51_PAD_EIM_D21__GPIO_2_5;
 	int ret;
 
 	/* Set USBH1_STP to GPIO and toggle it */
@@ -280,7 +280,7 @@ __setup("otg_mode=", babbage_otg_mode);
  */
 static void __init mxc_board_init(void)
 {
-	struct pad_desc usbh1stp = MX51_PAD_USBH1_STP__USBH1_STP;
+	iomux_v3_cfg_t usbh1stp = MX51_PAD_USBH1_STP__USBH1_STP;
 
 	mxc_iomux_v3_setup_multiple_pads(mx51babbage_pads,
 					ARRAY_SIZE(mx51babbage_pads));
diff --git a/arch/arm/mach-mx5/board-mx51_efikamx.c b/arch/arm/mach-mx5/board-mx51_efikamx.c
index b00502a..865a94b 100644
--- a/arch/arm/mach-mx5/board-mx51_efikamx.c
+++ b/arch/arm/mach-mx5/board-mx51_efikamx.c
@@ -39,7 +39,7 @@
 
 #define	MX51_USB_PLL_DIV_24_MHZ	0x01
 
-static struct pad_desc mx51efikamx_pads[] = {
+static iomux_v3_cfg_t mx51efikamx_pads[] = {
 	/* UART1 */
 	MX51_PAD_UART1_RXD__UART1_RXD,
 	MX51_PAD_UART1_TXD__UART1_TXD,
diff --git a/arch/arm/mach-mx5/eukrea_mbimx51-baseboard.c b/arch/arm/mach-mx5/eukrea_mbimx51-baseboard.c
index a2e6e8c..f0b09ec 100644
--- a/arch/arm/mach-mx5/eukrea_mbimx51-baseboard.c
+++ b/arch/arm/mach-mx5/eukrea_mbimx51-baseboard.c
@@ -84,7 +84,7 @@ static struct platform_device *devices[] __initdata = {
 	&mbimx51_leds_gpio,
 };
 
-static struct pad_desc mbimx51_pads[] = {
+static iomux_v3_cfg_t mbimx51_pads[] = {
 	/* UART2 */
 	MX51_PAD_UART2_RXD__UART2_RXD,
 	MX51_PAD_UART2_TXD__UART2_TXD,
diff --git a/arch/arm/mach-mx5/eukrea_mbimxsd-baseboard.c b/arch/arm/mach-mx5/eukrea_mbimxsd-baseboard.c
index 2b48f51..8c9c5e5 100644
--- a/arch/arm/mach-mx5/eukrea_mbimxsd-baseboard.c
+++ b/arch/arm/mach-mx5/eukrea_mbimxsd-baseboard.c
@@ -48,7 +48,7 @@
 #define MBIMXSD_GPIO_3_31 IOMUX_PAD(0x554, 0x16C, 3, 0x0, 0, \
 				MX51_PAD_CTRL_1 | PAD_CTL_PUS_22K_UP)
 
-static struct pad_desc eukrea_mbimxsd_pads[] = {
+static iomux_v3_cfg_t eukrea_mbimxsd_pads[] = {
 	/* LED */
 	MX51_PAD_NANDF_D10__GPIO_3_30,
 	/* SWITCH */
diff --git a/arch/arm/plat-mxc/include/mach/iomux-v3.h b/arch/arm/plat-mxc/include/mach/iomux-v3.h
index 0880a4a..811716f 100644
--- a/arch/arm/plat-mxc/include/mach/iomux-v3.h
+++ b/arch/arm/plat-mxc/include/mach/iomux-v3.h
@@ -44,7 +44,7 @@
  *
  */
 
-struct pad_desc {
+typedef struct deprecated_pad_desc {
 	unsigned mux_ctrl_ofs:12; /* IOMUXC_SW_MUX_CTL_PAD offset */
 	unsigned mux_mode:8;
 	unsigned pad_ctrl_ofs:12; /* IOMUXC_SW_PAD_CTRL offset */
@@ -52,7 +52,37 @@ struct pad_desc {
 	unsigned pad_ctrl:17;
 	unsigned select_input_ofs:12; /* IOMUXC_SELECT_INPUT offset */
 	unsigned select_input:3;
-};
+} iomux_v3_cfg_t;
+
+static inline unsigned int MUX_CTRL_OFS(iomux_v3_cfg_t *pad)
+{
+	return pad->mux_ctrl_ofs;
+}
+
+static inline unsigned int MUX_MODE(iomux_v3_cfg_t *pad)
+{
+	return pad->mux_mode;
+}
+
+static inline unsigned int MUX_SELECT_INPUT_OFS(iomux_v3_cfg_t *pad)
+{
+	return pad->select_input_ofs;
+}
+
+static inline unsigned int MUX_SELECT_INPUT(iomux_v3_cfg_t *pad)
+{
+	return pad->select_input;
+}
+
+static inline unsigned int MUX_PAD_CTRL_OFS(iomux_v3_cfg_t *pad)
+{
+	return pad->pad_ctrl_ofs;
+}
+
+static inline unsigned int MUX_PAD_CTRL(iomux_v3_cfg_t *pad)
+{
+	return pad->pad_ctrl;
+}
 
 #define IOMUX_PAD(_pad_ctrl_ofs, _mux_ctrl_ofs, _mux_mode, _select_input_ofs, \
 		_select_input, _pad_ctrl)				\
@@ -107,13 +137,13 @@ struct pad_desc {
 /*
  * setups a single pad in the iomuxer
  */
-int mxc_iomux_v3_setup_pad(struct pad_desc *pad);
+int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t *pad);
 
 /*
  * setups mutliple pads
  * convenient way to call the above function with tables
  */
-int mxc_iomux_v3_setup_multiple_pads(struct pad_desc *pad_list, unsigned count);
+int mxc_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t *pad_list, unsigned count);
 
 /*
  * Initialise the iomux controller
diff --git a/arch/arm/plat-mxc/iomux-v3.c b/arch/arm/plat-mxc/iomux-v3.c
index b318c6a..975ca7c 100644
--- a/arch/arm/plat-mxc/iomux-v3.c
+++ b/arch/arm/plat-mxc/iomux-v3.c
@@ -32,26 +32,26 @@
 static void __iomem *base;
 
 /*
- * setups a single pad in the iomuxer
+ * configures a single pad in the iomuxer
  */
-int mxc_iomux_v3_setup_pad(struct pad_desc *pad)
+int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t *pad)
 {
-	if (pad->mux_ctrl_ofs)
-		__raw_writel(pad->mux_mode, base + pad->mux_ctrl_ofs);
+	if (MUX_CTRL_OFS(pad))
+		__raw_writel(MUX_MODE(pad), base + MUX_CTRL_OFS(pad));
 
-	if (pad->select_input_ofs)
-		__raw_writel(pad->select_input,
-				base + pad->select_input_ofs);
+	if (MUX_SELECT_INPUT_OFS(pad))
+		__raw_writel(MUX_SELECT_INPUT(pad),
+			base + MUX_SELECT_INPUT(pad));
 
-	if (!(pad->pad_ctrl & NO_PAD_CTRL) && pad->pad_ctrl_ofs)
-		__raw_writel(pad->pad_ctrl, base + pad->pad_ctrl_ofs);
+	if (!(MUX_PAD_CTRL(pad) & NO_PAD_CTRL) && MUX_PAD_CTRL_OFS(pad))
+		__raw_writel(MUX_PAD_CTRL(pad), base + MUX_PAD_CTRL_OFS(pad));
 	return 0;
 }
 EXPORT_SYMBOL(mxc_iomux_v3_setup_pad);
 
-int mxc_iomux_v3_setup_multiple_pads(struct pad_desc *pad_list, unsigned count)
+int mxc_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t *pad_list, unsigned count)
 {
-	struct pad_desc *p = pad_list;
+	iomux_v3_cfg_t *p = pad_list;
 	int i;
 	int ret;
 


Lothar Wa?mann
-- 
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info at karo-electronics.de
___________________________________________________________

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH RFC] MXC IOMUX-V3 replace struct pad_desc with bitmapped cookie
  2010-10-26  9:07                   ` [PATCH RFC] MXC IOMUX-V3 replace struct pad_desc with bitmapped cookie Lothar Wa�mann
  2010-10-26  9:07                     ` Lothar Wa�mann
  2010-10-26  9:23                     ` Uwe Kleine-König
@ 2010-10-26 14:16                     ` Sascha Hauer
  2010-11-22  8:39                     ` [PATCH] MXC IOMUX-V3 replace struct pad_desc with bitmapped cookie (step 2) Lothar Waßmann
  3 siblings, 0 replies; 32+ messages in thread
From: Sascha Hauer @ 2010-10-26 14:16 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Lothar,

On Tue, Oct 26, 2010 at 11:07:21AM +0200, Lothar Wa?mann wrote:
> The following patch is a first step to convert the 'struct pad_desc'
> to a bitmapped cookie to facilitate adding platform specific pullup or
> drive strength definitions to existing pad definitions without need to
> rewrite the complete pad def.

I'm all in favour for this patch. I regret that I haven't implemented it
this way in the first time.
I think we should delay this to the next merge window though because
it introduces a change for many i.MX boards. Some more testing for this
patch is a good thing.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH] MXC IOMUX-V3 replace struct pad_desc with bitmapped cookie (step 2)
  2010-10-26  9:07                   ` [PATCH RFC] MXC IOMUX-V3 replace struct pad_desc with bitmapped cookie Lothar Wa�mann
                                       ` (2 preceding siblings ...)
  2010-10-26 14:16                     ` Sascha Hauer
@ 2010-11-22  8:39                     ` Lothar Waßmann
  2010-11-22  9:16                       ` Uwe Kleine-König
  2010-11-24 10:59                       ` Sascha Hauer
  3 siblings, 2 replies; 32+ messages in thread
From: Lothar Waßmann @ 2010-11-22  8:39 UTC (permalink / raw)
  To: linux-arm-kernel

This patch actually replaces the 'struct pad_desc' with a u64 cookie
to facilitate adding platform specific pad_ctrl settings to an
existing pad definition.

So, instead of:
	iomux_v3_cfg_t power_key = MX51_PAD_EIM_A27__GPIO_2_21;
	power_key.pad_ctrl = MX51_GPIO_PAD_CTRL_2;
	mxc_iomux_v3_setup_pad(&power_key);
one can write:
	mxc_iomux_v3_setup_pad((MX51_PAD_EIM_A27__GPIO_2_21 & ~MUX_PAD_CTRL_MASK) | MX51_GPIO_PAD_CTRL_2);

Patch applies to branch 'imx-for-2.6.38' of git://git.pengutronix.de/git/imx/linux-2.6

Signed-Off-By: Lothar Wa?mann <LW@KARO-electronics.de>
---
 mach-mx3/mach-pcm043.c           |   14 +++---
 mach-mx5/board-mx51_babbage.c    |   11 ++---
 plat-mxc/include/mach/iomux-v3.h |   84 ++++++++++++++++++++++-----------------
 plat-mxc/iomux-v3.c              |    4 -
 4 files changed, 63 insertions(+), 50 deletions(-)

diff --git a/arch/arm/mach-mx3/mach-pcm043.c b/arch/arm/mach-mx3/mach-pcm043.c
index 6b17b40..bb97e6b 100644
--- a/arch/arm/mach-mx3/mach-pcm043.c
+++ b/arch/arm/mach-mx3/mach-pcm043.c
@@ -240,7 +240,7 @@ static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97)
 		return;
 	}
 
-	mxc_iomux_v3_setup_pad(&txfs_gpio);
+	mxc_iomux_v3_setup_pad(txfs_gpio);
 
 	/* warm reset */
 	gpio_direction_output(AC97_GPIO_TXFS, 1);
@@ -248,7 +248,7 @@ static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97)
 	gpio_set_value(AC97_GPIO_TXFS, 0);
 
 	gpio_free(AC97_GPIO_TXFS);
-	mxc_iomux_v3_setup_pad(&txfs);
+	mxc_iomux_v3_setup_pad(txfs);
 }
 
 static void pcm043_ac97_cold_reset(struct snd_ac97 *ac97)
@@ -272,9 +272,9 @@ static void pcm043_ac97_cold_reset(struct snd_ac97 *ac97)
 	if (ret)
 		goto err3;
 
-	mxc_iomux_v3_setup_pad(&txfs_gpio);
-	mxc_iomux_v3_setup_pad(&txd_gpio);
-	mxc_iomux_v3_setup_pad(&reset_gpio);
+	mxc_iomux_v3_setup_pad(txfs_gpio);
+	mxc_iomux_v3_setup_pad(txd_gpio);
+	mxc_iomux_v3_setup_pad(reset_gpio);
 
 	gpio_direction_output(AC97_GPIO_TXFS, 0);
 	gpio_direction_output(AC97_GPIO_TXD, 0);
@@ -284,8 +284,8 @@ static void pcm043_ac97_cold_reset(struct snd_ac97 *ac97)
 	udelay(10);
 	gpio_direction_output(AC97_GPIO_RESET, 1);
 
-	mxc_iomux_v3_setup_pad(&txd);
-	mxc_iomux_v3_setup_pad(&txfs);
+	mxc_iomux_v3_setup_pad(txd);
+	mxc_iomux_v3_setup_pad(txfs);
 
 	gpio_free(AC97_GPIO_RESET);
 err3:
diff --git a/arch/arm/mach-mx5/board-mx51_babbage.c b/arch/arm/mach-mx5/board-mx51_babbage.c
index 66b07d8..35b8f61 100644
--- a/arch/arm/mach-mx5/board-mx51_babbage.c
+++ b/arch/arm/mach-mx5/board-mx51_babbage.c
@@ -193,7 +193,7 @@ static int gpio_usbh1_active(void)
 	int ret;
 
 	/* Set USBH1_STP to GPIO and toggle it */
-	mxc_iomux_v3_setup_pad(&usbh1stp_gpio);
+	mxc_iomux_v3_setup_pad(usbh1stp_gpio);
 	ret = gpio_request(BABBAGE_USBH1_STP, "usbh1_stp");
 
 	if (ret) {
@@ -206,7 +206,7 @@ static int gpio_usbh1_active(void)
 	gpio_free(BABBAGE_USBH1_STP);
 
 	/* De-assert USB PHY RESETB */
-	mxc_iomux_v3_setup_pad(&phyreset_gpio);
+	mxc_iomux_v3_setup_pad(phyreset_gpio);
 	ret = gpio_request(BABBAGE_PHY_RESET, "phy_reset");
 
 	if (ret) {
@@ -348,7 +348,8 @@ static const struct spi_imx_master mx51_babbage_spi_pdata __initconst = {
 static void __init mxc_board_init(void)
 {
 	iomux_v3_cfg_t usbh1stp = MX51_PAD_USBH1_STP__USBH1_STP;
-	iomux_v3_cfg_t power_key = MX51_PAD_EIM_A27__GPIO_2_21;
+	iomux_v3_cfg_t power_key = (MX51_PAD_EIM_A27__GPIO_2_21 &
+				~MUX_PAD_CTRL_MASK) | MX51_GPIO_PAD_CTRL_2;
 
 #if defined(CONFIG_CPU_FREQ_IMX)
 	get_cpu_op = mx51_get_cpu_op;
@@ -360,8 +361,7 @@ static void __init mxc_board_init(void)
 	imx51_add_fec(NULL);
 
 	/* Set the PAD settings for the pwr key. */
-	power_key.pad_ctrl = MX51_GPIO_PAD_CTRL_2;
-	mxc_iomux_v3_setup_pad(&power_key);
+	mxc_iomux_v3_setup_pad(power_key);
 	imx51_add_gpio_keys(&imx_button_data);
 
 	imx51_add_imx_i2c(0, &babbage_i2c_data);
@@ -378,7 +378,7 @@ static void __init mxc_board_init(void)
 	gpio_usbh1_active();
 	mxc_register_device(&mxc_usbh1_device, &usbh1_config);
 	/* setback USBH1_STP to be function */
-	mxc_iomux_v3_setup_pad(&usbh1stp);
+	mxc_iomux_v3_setup_pad(usbh1stp);
 	babbage_usbhub_reset();
 
 	imx51_add_esdhc(0, NULL);
diff --git a/arch/arm/plat-mxc/include/mach/iomux-v3.h b/arch/arm/plat-mxc/include/mach/iomux-v3.h
index 811716f..ae6dec9 100644
--- a/arch/arm/plat-mxc/include/mach/iomux-v3.h
+++ b/arch/arm/plat-mxc/include/mach/iomux-v3.h
@@ -42,58 +42,72 @@
  * If <padname> or <padmode> refers to a GPIO, it is named
  * GPIO_<unit>_<num>
  *
- */
-
-typedef struct deprecated_pad_desc {
-	unsigned mux_ctrl_ofs:12; /* IOMUXC_SW_MUX_CTL_PAD offset */
-	unsigned mux_mode:8;
-	unsigned pad_ctrl_ofs:12; /* IOMUXC_SW_PAD_CTRL offset */
-#define	NO_PAD_CTRL	(1 << 16)
-	unsigned pad_ctrl:17;
-	unsigned select_input_ofs:12; /* IOMUXC_SELECT_INPUT offset */
-	unsigned select_input:3;
-} iomux_v3_cfg_t;
-
-static inline unsigned int MUX_CTRL_OFS(iomux_v3_cfg_t *pad)
+ * IOMUX/PAD Bit field definitions
+ *
+ * MUX_CTRL_OFS:	    0..11 (12)
+ * PAD_CTRL_OFS:	   12..23 (12)
+ * SEL_INPUT_OFS:	   24..35 (12)
+ * MUX_MODE + SION:	   36..40  (5)
+ * PAD_CTRL + NO_PAD_CTRL: 41..57 (17)
+ * SEL_INP:		   58..61  (4)
+ * reserved:		     63    (1)
+*/
+
+typedef u64 iomux_v3_cfg_t;
+
+#define MUX_CTRL_OFS_SHIFT	0
+#define MUX_CTRL_OFS_MASK	((iomux_v3_cfg_t)0xfff << MUX_CTRL_OFS_SHIFT)
+#define MUX_PAD_CTRL_OFS_SHIFT	12
+#define MUX_PAD_CTRL_OFS_MASK	((iomux_v3_cfg_t)0xfff << MUX_PAD_CTRL_OFS_SHIFT)
+#define MUX_SEL_INPUT_OFS_SHIFT	24
+#define MUX_SEL_INPUT_OFS_MASK	((iomux_v3_cfg_t)0xfff << MUX_SEL_INPUT_OFS_SHIFT)
+
+#define MUX_MODE_SHIFT		36
+#define MUX_MODE_MASK		((iomux_v3_cfg_t)0x1f << MUX_MODE_SHIFT)
+#define MUX_PAD_CTRL_SHIFT	41
+#define MUX_PAD_CTRL_MASK	((iomux_v3_cfg_t)0x1ffff << MUX_PAD_CTRL_SHIFT)
+#define NO_PAD_CTRL		((iomux_v3_cfg_t)1 << (MUX_PAD_CTRL_SHIFT + 16))
+#define MUX_SEL_INPUT_SHIFT	58
+#define MUX_SEL_INPUT_MASK	((iomux_v3_cfg_t)0xf << MUX_SEL_INPUT_SHIFT)
+
+static inline unsigned int MUX_CTRL_OFS(iomux_v3_cfg_t pad)
 {
-	return pad->mux_ctrl_ofs;
+	return (pad & MUX_CTRL_OFS_MASK) >> MUX_CTRL_OFS_SHIFT;
 }
 
-static inline unsigned int MUX_MODE(iomux_v3_cfg_t *pad)
+static inline unsigned int MUX_MODE(iomux_v3_cfg_t pad)
 {
-	return pad->mux_mode;
+	return (pad & MUX_MODE_MASK) >> MUX_MODE_SHIFT;
 }
 
-static inline unsigned int MUX_SELECT_INPUT_OFS(iomux_v3_cfg_t *pad)
+static inline unsigned int MUX_SELECT_INPUT_OFS(iomux_v3_cfg_t pad)
 {
-	return pad->select_input_ofs;
+	return (pad & MUX_SEL_INPUT_OFS_MASK) >> MUX_SEL_INPUT_OFS_SHIFT;
 }
 
-static inline unsigned int MUX_SELECT_INPUT(iomux_v3_cfg_t *pad)
+static inline unsigned int MUX_SELECT_INPUT(iomux_v3_cfg_t pad)
 {
-	return pad->select_input;
+	return (pad & MUX_SEL_INPUT_MASK) >> MUX_SEL_INPUT_SHIFT;
 }
 
-static inline unsigned int MUX_PAD_CTRL_OFS(iomux_v3_cfg_t *pad)
+static inline unsigned int MUX_PAD_CTRL_OFS(iomux_v3_cfg_t pad)
 {
-	return pad->pad_ctrl_ofs;
+	return (pad & MUX_PAD_CTRL_OFS_MASK) >> MUX_PAD_CTRL_OFS_SHIFT;
 }
 
-static inline unsigned int MUX_PAD_CTRL(iomux_v3_cfg_t *pad)
+static inline unsigned int MUX_PAD_CTRL(iomux_v3_cfg_t pad)
 {
-	return pad->pad_ctrl;
+	return (pad & MUX_PAD_CTRL_MASK) >> MUX_PAD_CTRL_SHIFT;
 }
 
-#define IOMUX_PAD(_pad_ctrl_ofs, _mux_ctrl_ofs, _mux_mode, _select_input_ofs, \
-		_select_input, _pad_ctrl)				\
-		{							\
-			.mux_ctrl_ofs     = _mux_ctrl_ofs,		\
-			.mux_mode         = _mux_mode,			\
-			.pad_ctrl_ofs     = _pad_ctrl_ofs,		\
-			.pad_ctrl         = _pad_ctrl,			\
-			.select_input_ofs = _select_input_ofs,		\
-			.select_input     = _select_input,		\
-		}
+#define IOMUX_PAD(_pad_ctrl_ofs, _mux_ctrl_ofs, _mux_mode, _sel_input_ofs, \
+		_sel_input, _pad_ctrl)					\
+	(((iomux_v3_cfg_t)(_mux_ctrl_ofs) << MUX_CTRL_OFS_SHIFT) |	\
+		((iomux_v3_cfg_t)(_mux_mode) << MUX_MODE_SHIFT) |	\
+		((iomux_v3_cfg_t)(_pad_ctrl_ofs) << MUX_PAD_CTRL_OFS_SHIFT) | \
+		((iomux_v3_cfg_t)(_pad_ctrl) << MUX_PAD_CTRL_SHIFT) |	\
+		((iomux_v3_cfg_t)(_sel_input_ofs) << MUX_SEL_INPUT_OFS_SHIFT) | \
+		((iomux_v3_cfg_t)(_sel_input) << MUX_SEL_INPUT_SHIFT))
 
 /*
  * Use to set PAD control
@@ -137,7 +151,7 @@ static inline unsigned int MUX_PAD_CTRL(iomux_v3_cfg_t *pad)
 /*
  * setups a single pad in the iomuxer
  */
-int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t *pad);
+int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t pad);
 
 /*
  * setups mutliple pads
diff --git a/arch/arm/plat-mxc/iomux-v3.c b/arch/arm/plat-mxc/iomux-v3.c
index 4cbbf2c..09fb5b8 100644
--- a/arch/arm/plat-mxc/iomux-v3.c
+++ b/arch/arm/plat-mxc/iomux-v3.c
@@ -34,7 +34,7 @@ static void __iomem *base;
 /*
  * configures a single pad in the iomuxer
  */
-int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t *pad)
+int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t pad)
 {
 	if (MUX_CTRL_OFS(pad))
 		__raw_writel(MUX_MODE(pad), base + MUX_CTRL_OFS(pad));
@@ -56,7 +56,7 @@ int mxc_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t *pad_list, unsigned count)
 	int ret;
 
 	for (i = 0; i < count; i++) {
-		ret = mxc_iomux_v3_setup_pad(p);
+		ret = mxc_iomux_v3_setup_pad(*p);
 		if (ret)
 			return ret;
 		p++;


Lothar Wa?mann
-- 
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info@karo-electronics.de
___________________________________________________________

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH] MXC IOMUX-V3 replace struct pad_desc with bitmapped cookie (step 2)
  2010-11-22  8:39                     ` [PATCH] MXC IOMUX-V3 replace struct pad_desc with bitmapped cookie (step 2) Lothar Waßmann
@ 2010-11-22  9:16                       ` Uwe Kleine-König
  2010-11-24 10:59                       ` Sascha Hauer
  1 sibling, 0 replies; 32+ messages in thread
From: Uwe Kleine-König @ 2010-11-22  9:16 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Nov 22, 2010 at 09:39:51AM +0100, Lothar Wa?mann wrote:
> This patch actually replaces the 'struct pad_desc' with a u64 cookie
> to facilitate adding platform specific pad_ctrl settings to an
> existing pad definition.
> 
> So, instead of:
> 	iomux_v3_cfg_t power_key = MX51_PAD_EIM_A27__GPIO_2_21;
> 	power_key.pad_ctrl = MX51_GPIO_PAD_CTRL_2;
> 	mxc_iomux_v3_setup_pad(&power_key);
> one can write:
> 	mxc_iomux_v3_setup_pad((MX51_PAD_EIM_A27__GPIO_2_21 & ~MUX_PAD_CTRL_MASK) | MX51_GPIO_PAD_CTRL_2);
> 
> Patch applies to branch 'imx-for-2.6.38' of git://git.pengutronix.de/git/imx/linux-2.6
minor nitpick: This doens't belong here, but after the triple dash below
(IMHO).
 
> Signed-Off-By: Lothar Wa?mann <LW@KARO-electronics.de>
minor nitpick: The more usual way to write that is:

	Signed-off-by: ...

(i.e. off and by in lower case).  This might prevent you to appear in
the various hit lists like http://www.remword.com/kps_result/ :-)

> ---
>  mach-mx3/mach-pcm043.c           |   14 +++---
>  mach-mx5/board-mx51_babbage.c    |   11 ++---
>  plat-mxc/include/mach/iomux-v3.h |   84 ++++++++++++++++++++++-----------------
>  plat-mxc/iomux-v3.c              |    4 -
>  4 files changed, 63 insertions(+), 50 deletions(-)
> 
> diff --git a/arch/arm/mach-mx3/mach-pcm043.c b/arch/arm/mach-mx3/mach-pcm043.c
> index 6b17b40..bb97e6b 100644
> --- a/arch/arm/mach-mx3/mach-pcm043.c
> +++ b/arch/arm/mach-mx3/mach-pcm043.c
> @@ -240,7 +240,7 @@ static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97)
>  		return;
>  	}
>  
> -	mxc_iomux_v3_setup_pad(&txfs_gpio);
> +	mxc_iomux_v3_setup_pad(txfs_gpio);
>  
>  	/* warm reset */
>  	gpio_direction_output(AC97_GPIO_TXFS, 1);
> @@ -248,7 +248,7 @@ static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97)
>  	gpio_set_value(AC97_GPIO_TXFS, 0);
>  
>  	gpio_free(AC97_GPIO_TXFS);
> -	mxc_iomux_v3_setup_pad(&txfs);
> +	mxc_iomux_v3_setup_pad(txfs);
>  }
>  
>  static void pcm043_ac97_cold_reset(struct snd_ac97 *ac97)
> @@ -272,9 +272,9 @@ static void pcm043_ac97_cold_reset(struct snd_ac97 *ac97)
>  	if (ret)
>  		goto err3;
>  
> -	mxc_iomux_v3_setup_pad(&txfs_gpio);
> -	mxc_iomux_v3_setup_pad(&txd_gpio);
> -	mxc_iomux_v3_setup_pad(&reset_gpio);
> +	mxc_iomux_v3_setup_pad(txfs_gpio);
> +	mxc_iomux_v3_setup_pad(txd_gpio);
> +	mxc_iomux_v3_setup_pad(reset_gpio);
>  
>  	gpio_direction_output(AC97_GPIO_TXFS, 0);
>  	gpio_direction_output(AC97_GPIO_TXD, 0);
> @@ -284,8 +284,8 @@ static void pcm043_ac97_cold_reset(struct snd_ac97 *ac97)
>  	udelay(10);
>  	gpio_direction_output(AC97_GPIO_RESET, 1);
>  
> -	mxc_iomux_v3_setup_pad(&txd);
> -	mxc_iomux_v3_setup_pad(&txfs);
> +	mxc_iomux_v3_setup_pad(txd);
> +	mxc_iomux_v3_setup_pad(txfs);
>  
>  	gpio_free(AC97_GPIO_RESET);
>  err3:
> diff --git a/arch/arm/mach-mx5/board-mx51_babbage.c b/arch/arm/mach-mx5/board-mx51_babbage.c
> index 66b07d8..35b8f61 100644
> --- a/arch/arm/mach-mx5/board-mx51_babbage.c
> +++ b/arch/arm/mach-mx5/board-mx51_babbage.c
> @@ -193,7 +193,7 @@ static int gpio_usbh1_active(void)
>  	int ret;
>  
>  	/* Set USBH1_STP to GPIO and toggle it */
> -	mxc_iomux_v3_setup_pad(&usbh1stp_gpio);
> +	mxc_iomux_v3_setup_pad(usbh1stp_gpio);
>  	ret = gpio_request(BABBAGE_USBH1_STP, "usbh1_stp");
>  
>  	if (ret) {
> @@ -206,7 +206,7 @@ static int gpio_usbh1_active(void)
>  	gpio_free(BABBAGE_USBH1_STP);
>  
>  	/* De-assert USB PHY RESETB */
> -	mxc_iomux_v3_setup_pad(&phyreset_gpio);
> +	mxc_iomux_v3_setup_pad(phyreset_gpio);
>  	ret = gpio_request(BABBAGE_PHY_RESET, "phy_reset");
>  
>  	if (ret) {
> @@ -348,7 +348,8 @@ static const struct spi_imx_master mx51_babbage_spi_pdata __initconst = {
>  static void __init mxc_board_init(void)
>  {
>  	iomux_v3_cfg_t usbh1stp = MX51_PAD_USBH1_STP__USBH1_STP;
> -	iomux_v3_cfg_t power_key = MX51_PAD_EIM_A27__GPIO_2_21;
> +	iomux_v3_cfg_t power_key = (MX51_PAD_EIM_A27__GPIO_2_21 &
> +				~MUX_PAD_CTRL_MASK) | MX51_GPIO_PAD_CTRL_2;
>  
>  #if defined(CONFIG_CPU_FREQ_IMX)
>  	get_cpu_op = mx51_get_cpu_op;
> @@ -360,8 +361,7 @@ static void __init mxc_board_init(void)
>  	imx51_add_fec(NULL);
>  
>  	/* Set the PAD settings for the pwr key. */
> -	power_key.pad_ctrl = MX51_GPIO_PAD_CTRL_2;
> -	mxc_iomux_v3_setup_pad(&power_key);
> +	mxc_iomux_v3_setup_pad(power_key);
>  	imx51_add_gpio_keys(&imx_button_data);
>  
>  	imx51_add_imx_i2c(0, &babbage_i2c_data);
> @@ -378,7 +378,7 @@ static void __init mxc_board_init(void)
>  	gpio_usbh1_active();
>  	mxc_register_device(&mxc_usbh1_device, &usbh1_config);
>  	/* setback USBH1_STP to be function */
> -	mxc_iomux_v3_setup_pad(&usbh1stp);
> +	mxc_iomux_v3_setup_pad(usbh1stp);
>  	babbage_usbhub_reset();
>  
>  	imx51_add_esdhc(0, NULL);
> diff --git a/arch/arm/plat-mxc/include/mach/iomux-v3.h b/arch/arm/plat-mxc/include/mach/iomux-v3.h
> index 811716f..ae6dec9 100644
> --- a/arch/arm/plat-mxc/include/mach/iomux-v3.h
> +++ b/arch/arm/plat-mxc/include/mach/iomux-v3.h
> @@ -42,58 +42,72 @@
>   * If <padname> or <padmode> refers to a GPIO, it is named
>   * GPIO_<unit>_<num>
>   *
> - */
> -
> -typedef struct deprecated_pad_desc {
> -	unsigned mux_ctrl_ofs:12; /* IOMUXC_SW_MUX_CTL_PAD offset */
> -	unsigned mux_mode:8;
> -	unsigned pad_ctrl_ofs:12; /* IOMUXC_SW_PAD_CTRL offset */
> -#define	NO_PAD_CTRL	(1 << 16)
> -	unsigned pad_ctrl:17;
> -	unsigned select_input_ofs:12; /* IOMUXC_SELECT_INPUT offset */
> -	unsigned select_input:3;
> -} iomux_v3_cfg_t;
> -
> -static inline unsigned int MUX_CTRL_OFS(iomux_v3_cfg_t *pad)
> + * IOMUX/PAD Bit field definitions
> + *
> + * MUX_CTRL_OFS:	    0..11 (12)
> + * PAD_CTRL_OFS:	   12..23 (12)
> + * SEL_INPUT_OFS:	   24..35 (12)
> + * MUX_MODE + SION:	   36..40  (5)
> + * PAD_CTRL + NO_PAD_CTRL: 41..57 (17)
> + * SEL_INP:		   58..61  (4)
> + * reserved:		     63    (1)
> +*/
> +
> +typedef u64 iomux_v3_cfg_t;
> +
> +#define MUX_CTRL_OFS_SHIFT	0
> +#define MUX_CTRL_OFS_MASK	((iomux_v3_cfg_t)0xfff << MUX_CTRL_OFS_SHIFT)
It doesn't matter for the compiler, but for the reader

	((iomux_v3_cfg_t)(0xfff << MUX_CTRL_OFS_SHIFT))

might be clearer?!  Ah, I see the problem:

	((iomux_v3_cfg_t)0x1f << MUX_MODE_SHIFT) != ((iomux_v3_cfg_t)(0x1f << MUX_MODE_SHIFT))

Well, OK.

And these constants should be named (e.g.)

	IMX_IOMUXV3_CTRL_OFS_MASK

to use the proper namespace.  IMHO this applies to NO_PAD_CTRL and
IOMUX_PAD, too.  Maybe fix the name and define the old name to the new
for now?

> +#define MUX_PAD_CTRL_OFS_SHIFT	12
> +#define MUX_PAD_CTRL_OFS_MASK	((iomux_v3_cfg_t)0xfff << MUX_PAD_CTRL_OFS_SHIFT)
> +#define MUX_SEL_INPUT_OFS_SHIFT	24
> +#define MUX_SEL_INPUT_OFS_MASK	((iomux_v3_cfg_t)0xfff << MUX_SEL_INPUT_OFS_SHIFT)
> +
> +#define MUX_MODE_SHIFT		36
> +#define MUX_MODE_MASK		((iomux_v3_cfg_t)0x1f << MUX_MODE_SHIFT)
> +#define MUX_PAD_CTRL_SHIFT	41
> +#define MUX_PAD_CTRL_MASK	((iomux_v3_cfg_t)0x1ffff << MUX_PAD_CTRL_SHIFT)
> +#define NO_PAD_CTRL		((iomux_v3_cfg_t)1 << (MUX_PAD_CTRL_SHIFT + 16))
> +#define MUX_SEL_INPUT_SHIFT	58
> +#define MUX_SEL_INPUT_MASK	((iomux_v3_cfg_t)0xf << MUX_SEL_INPUT_SHIFT)
> +
> +static inline unsigned int MUX_CTRL_OFS(iomux_v3_cfg_t pad)
>  {
> -	return pad->mux_ctrl_ofs;
> +	return (pad & MUX_CTRL_OFS_MASK) >> MUX_CTRL_OFS_SHIFT;
>  }
>  
> -static inline unsigned int MUX_MODE(iomux_v3_cfg_t *pad)
> +static inline unsigned int MUX_MODE(iomux_v3_cfg_t pad)
>  {
> -	return pad->mux_mode;
> +	return (pad & MUX_MODE_MASK) >> MUX_MODE_SHIFT;
>  }
>  
> -static inline unsigned int MUX_SELECT_INPUT_OFS(iomux_v3_cfg_t *pad)
> +static inline unsigned int MUX_SELECT_INPUT_OFS(iomux_v3_cfg_t pad)
>  {
> -	return pad->select_input_ofs;
> +	return (pad & MUX_SEL_INPUT_OFS_MASK) >> MUX_SEL_INPUT_OFS_SHIFT;
>  }
>  
> -static inline unsigned int MUX_SELECT_INPUT(iomux_v3_cfg_t *pad)
> +static inline unsigned int MUX_SELECT_INPUT(iomux_v3_cfg_t pad)
>  {
> -	return pad->select_input;
> +	return (pad & MUX_SEL_INPUT_MASK) >> MUX_SEL_INPUT_SHIFT;
>  }
>  
> -static inline unsigned int MUX_PAD_CTRL_OFS(iomux_v3_cfg_t *pad)
> +static inline unsigned int MUX_PAD_CTRL_OFS(iomux_v3_cfg_t pad)
>  {
> -	return pad->pad_ctrl_ofs;
> +	return (pad & MUX_PAD_CTRL_OFS_MASK) >> MUX_PAD_CTRL_OFS_SHIFT;
>  }
>  
> -static inline unsigned int MUX_PAD_CTRL(iomux_v3_cfg_t *pad)
> +static inline unsigned int MUX_PAD_CTRL(iomux_v3_cfg_t pad)
>  {
> -	return pad->pad_ctrl;
> +	return (pad & MUX_PAD_CTRL_MASK) >> MUX_PAD_CTRL_SHIFT;
>  }
>  
> -#define IOMUX_PAD(_pad_ctrl_ofs, _mux_ctrl_ofs, _mux_mode, _select_input_ofs, \
> -		_select_input, _pad_ctrl)				\
> -		{							\
> -			.mux_ctrl_ofs     = _mux_ctrl_ofs,		\
> -			.mux_mode         = _mux_mode,			\
> -			.pad_ctrl_ofs     = _pad_ctrl_ofs,		\
> -			.pad_ctrl         = _pad_ctrl,			\
> -			.select_input_ofs = _select_input_ofs,		\
> -			.select_input     = _select_input,		\
> -		}
> +#define IOMUX_PAD(_pad_ctrl_ofs, _mux_ctrl_ofs, _mux_mode, _sel_input_ofs, \
> +		_sel_input, _pad_ctrl)					\
> +	(((iomux_v3_cfg_t)(_mux_ctrl_ofs) << MUX_CTRL_OFS_SHIFT) |	\
> +		((iomux_v3_cfg_t)(_mux_mode) << MUX_MODE_SHIFT) |	\
> +		((iomux_v3_cfg_t)(_pad_ctrl_ofs) << MUX_PAD_CTRL_OFS_SHIFT) | \
> +		((iomux_v3_cfg_t)(_pad_ctrl) << MUX_PAD_CTRL_SHIFT) |	\
> +		((iomux_v3_cfg_t)(_sel_input_ofs) << MUX_SEL_INPUT_OFS_SHIFT) | \
> +		((iomux_v3_cfg_t)(_sel_input) << MUX_SEL_INPUT_SHIFT))
>  
>  /*
>   * Use to set PAD control
> @@ -137,7 +151,7 @@ static inline unsigned int MUX_PAD_CTRL(iomux_v3_cfg_t *pad)
>  /*
>   * setups a single pad in the iomuxer
>   */
> -int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t *pad);
> +int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t pad);
>  
>  /*
>   * setups mutliple pads
> diff --git a/arch/arm/plat-mxc/iomux-v3.c b/arch/arm/plat-mxc/iomux-v3.c
> index 4cbbf2c..09fb5b8 100644
> --- a/arch/arm/plat-mxc/iomux-v3.c
> +++ b/arch/arm/plat-mxc/iomux-v3.c
> @@ -34,7 +34,7 @@ static void __iomem *base;
>  /*
>   * configures a single pad in the iomuxer
>   */
> -int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t *pad)
> +int mxc_iomux_v3_setup_pad(iomux_v3_cfg_t pad)
>  {
>  	if (MUX_CTRL_OFS(pad))
>  		__raw_writel(MUX_MODE(pad), base + MUX_CTRL_OFS(pad));
> @@ -56,7 +56,7 @@ int mxc_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t *pad_list, unsigned count)
>  	int ret;
>  
>  	for (i = 0; i < count; i++) {
> -		ret = mxc_iomux_v3_setup_pad(p);
> +		ret = mxc_iomux_v3_setup_pad(*p);
>  		if (ret)
>  			return ret;
>  		p++;
> 
> 
> Lothar Wa?mann
> -- 
> ___________________________________________________________
> 
> Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
> Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
> Gesch?ftsf?hrer: Matthias Kaussen
> Handelsregistereintrag: Amtsgericht Aachen, HRB 4996
> 
> www.karo-electronics.de | info at karo-electronics.de
> ___________________________________________________________
> 

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH] MXC IOMUX-V3 replace struct pad_desc with bitmapped cookie (step 2)
  2010-11-22  8:39                     ` [PATCH] MXC IOMUX-V3 replace struct pad_desc with bitmapped cookie (step 2) Lothar Waßmann
  2010-11-22  9:16                       ` Uwe Kleine-König
@ 2010-11-24 10:59                       ` Sascha Hauer
  1 sibling, 0 replies; 32+ messages in thread
From: Sascha Hauer @ 2010-11-24 10:59 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Lothar,

On Mon, Nov 22, 2010 at 09:39:51AM +0100, Lothar Wa?mann wrote:
> This patch actually replaces the 'struct pad_desc' with a u64 cookie
> to facilitate adding platform specific pad_ctrl settings to an
> existing pad definition.
> 
> So, instead of:
> 	iomux_v3_cfg_t power_key = MX51_PAD_EIM_A27__GPIO_2_21;
> 	power_key.pad_ctrl = MX51_GPIO_PAD_CTRL_2;
> 	mxc_iomux_v3_setup_pad(&power_key);
> one can write:
> 	mxc_iomux_v3_setup_pad((MX51_PAD_EIM_A27__GPIO_2_21 & ~MUX_PAD_CTRL_MASK) | MX51_GPIO_PAD_CTRL_2);
> 
> Patch applies to branch 'imx-for-2.6.38' of git://git.pengutronix.de/git/imx/linux-2.6
> 
> Signed-Off-By: Lothar Wa?mann <LW@KARO-electronics.de>
> ---
>  mach-mx3/mach-pcm043.c           |   14 +++---
>  mach-mx5/board-mx51_babbage.c    |   11 ++---
>  plat-mxc/include/mach/iomux-v3.h |   84 ++++++++++++++++++++++-----------------
>  plat-mxc/iomux-v3.c              |    4 -
>  4 files changed, 63 insertions(+), 50 deletions(-)
> 
> diff --git a/arch/arm/mach-mx5/board-mx51_babbage.c b/arch/arm/mach-mx5/board-mx51_babbage.c
> index 66b07d8..35b8f61 100644
> --- a/arch/arm/mach-mx5/board-mx51_babbage.c
> +++ b/arch/arm/mach-mx5/board-mx51_babbage.c
> @@ -348,7 +348,8 @@ static const struct spi_imx_master mx51_babbage_spi_pdata __initconst = {
>  static void __init mxc_board_init(void)
>  {
>  	iomux_v3_cfg_t usbh1stp = MX51_PAD_USBH1_STP__USBH1_STP;
> -	iomux_v3_cfg_t power_key = MX51_PAD_EIM_A27__GPIO_2_21;
> +	iomux_v3_cfg_t power_key = (MX51_PAD_EIM_A27__GPIO_2_21 &
> +				~MUX_PAD_CTRL_MASK) | MX51_GPIO_PAD_CTRL_2;
>  

This does not work. MX51_GPIO_PAD_CTRL_2 is defined as:

#define MX51_GPIO_PAD_CTRL_2	(PAD_CTL_SRE_FAST | PAD_CTL_DSE_HIGH | \
					PAD_CTL_PUS_100K_UP)

It has to be shifted to the correct location in the bit field. The
following fixes this, but it does not look particularly nice:

+	iomux_v3_cfg_t power_key = (MX51_PAD_EIM_A27__GPIO_2_21 &
+				~MUX_PAD_CTRL_MASK) | ((iomux_v3_cfg_t)(MX51_GPIO_PAD_CTRL_2) << MUX_PAD_CTRL_SHIFT);

How do we proceed from here?

Some

#define MUX_PAD_CTRL(mode) ((iomux_v3_cfg_t)(mode) << MUX_PAD_CTRL_SHIFT)

Macro would be nice. Unfortunately the name is already used for a
function doing the opposite.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2010-11-24 10:59 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-22 16:56 [PATCHv5 1/3] ARM: mx5: Add gpio-keys to mx51 babbage board Dinh.Nguyen
2010-10-22 16:56 ` Dinh.Nguyen at freescale.com
2010-10-22 16:56 ` [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc Dinh.Nguyen
2010-10-22 16:56   ` Dinh.Nguyen at freescale.com
2010-10-22 16:56   ` [PATCHv5 3/3] ARM: imx: Add wake functionality to GPIO Dinh.Nguyen
2010-10-22 16:56     ` Dinh.Nguyen at freescale.com
2010-10-22 18:28   ` [PATCHv5 2/3] ARM: imx: Add gpio-keys to plat-mxc Uwe Kleine-König
2010-10-22 18:28     ` Uwe Kleine-König
2010-10-22 18:58     ` Nguyen Dinh-R00091
2010-10-22 18:58       ` Nguyen Dinh-R00091
2010-10-22 19:42       ` Uwe Kleine-König
2010-10-22 19:42         ` Uwe Kleine-König
2010-10-23  2:43         ` Nguyen Dinh-R00091
2010-10-23  2:43           ` Nguyen Dinh-R00091
2010-10-24  8:37           ` Lothar Waßmann
2010-10-24  8:37             ` Lothar Waßmann
2010-10-24 19:20             ` Uwe Kleine-König
2010-10-24 19:20               ` Uwe Kleine-König
2010-10-25  7:02               ` Lothar Waßmann
2010-10-25  7:02                 ` Lothar Waßmann
2010-10-25  7:21                 ` Uwe Kleine-König
2010-10-25  7:21                   ` Uwe Kleine-König
2010-10-26  9:07                   ` [PATCH RFC] MXC IOMUX-V3 replace struct pad_desc with bitmapped cookie Lothar Wa�mann
2010-10-26  9:07                     ` Lothar Wa�mann
2010-10-26  9:23                     ` Uwe Kleine-König
2010-10-26 12:28                       ` Lothar Waßmann
2010-10-26 14:16                     ` Sascha Hauer
2010-11-22  8:39                     ` [PATCH] MXC IOMUX-V3 replace struct pad_desc with bitmapped cookie (step 2) Lothar Waßmann
2010-11-22  9:16                       ` Uwe Kleine-König
2010-11-24 10:59                       ` Sascha Hauer
2010-10-22 17:51 ` [PATCHv5 1/3] ARM: mx5: Add gpio-keys to mx51 babbage board Amit Kucheria
2010-10-22 17:51   ` Amit Kucheria

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.