[U-Boot] imx: gpio cleanups

This patchset cleanups up the gpio related stuff on imx boards. Define a common header for gpio and remove the same struct defines in all the include directories.
Vikram Narayanan (3): imx25: Move MXC_GPIO_PORT_TO_NUM to imx-regs.h tx25: Use generic gpio_* calls imx: Define a common header file for gpio.h
arch/arm/include/asm/arch-mx25/gpio.h | 45 -------------------- arch/arm/include/asm/arch-mx25/imx-regs.h | 6 +++ arch/arm/include/asm/arch-mx31/gpio.h | 35 --------------- arch/arm/include/asm/arch-mx35/gpio.h | 40 ----------------- arch/arm/include/asm/arch-mx5/gpio.h | 35 --------------- board/CarMediaLab/flea3/flea3.c | 2 +- board/davedenx/qong/fpga.c | 2 +- board/davedenx/qong/qong.c | 2 +- board/denx/m28evk/m28evk.c | 2 +- board/efikamx/efikamx-usb.c | 2 +- board/efikamx/efikamx.c | 2 +- board/esg/ima3-mx53/ima3-mx53.c | 2 +- board/freescale/mx28evk/mx28evk.c | 2 +- board/freescale/mx35pdk/mx35pdk.c | 2 +- board/freescale/mx51evk/mx51evk.c | 2 +- board/freescale/mx53ard/mx53ard.c | 2 +- board/freescale/mx53evk/mx53evk.c | 2 +- board/freescale/mx53loco/mx53loco.c | 2 +- board/freescale/mx53smd/mx53smd.c | 2 +- board/freescale/mx6qarm2/mx6qarm2.c | 2 +- board/freescale/mx6qsabrelite/mx6qsabrelite.c | 2 +- board/karo/tx25/tx25.c | 30 ++++++------- board/syteco/zmx25/zmx25.c | 2 +- board/ttcontrol/vision2/vision2.c | 2 +- common/cmd_gpio.c | 2 +- drivers/gpio/mxc_gpio.c | 2 +- .../asm/arch-mx6/gpio.h => drivers/gpio/mxc_gpio.h | 12 +++--- drivers/spi/mxc_spi.c | 2 +- 28 files changed, 46 insertions(+), 199 deletions(-) delete mode 100644 arch/arm/include/asm/arch-mx25/gpio.h delete mode 100644 arch/arm/include/asm/arch-mx31/gpio.h delete mode 100644 arch/arm/include/asm/arch-mx35/gpio.h delete mode 100644 arch/arm/include/asm/arch-mx5/gpio.h rename arch/arm/include/asm/arch-mx6/gpio.h => drivers/gpio/mxc_gpio.h (85%)

Move the macro to imx-regs.h so that the other mx25 boards can make use of it.
Signed-off-by: Vikram Narayanan vikram186@gmail.com --- arch/arm/include/asm/arch-mx25/gpio.h | 4 ---- arch/arm/include/asm/arch-mx25/imx-regs.h | 6 ++++++ 2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/arm/include/asm/arch-mx25/gpio.h b/arch/arm/include/asm/arch-mx25/gpio.h index dc6edc7..cc32d50 100644 --- a/arch/arm/include/asm/arch-mx25/gpio.h +++ b/arch/arm/include/asm/arch-mx25/gpio.h @@ -25,10 +25,6 @@ #ifndef __ASM_ARCH_MX25_GPIO_H #define __ASM_ARCH_MX25_GPIO_H
-/* Converts a GPIO port number and the internal bit position - * to the GPIO number - */ -#define MXC_GPIO_PORT_TO_NUM(port, bit) (((port - 1) << 5) + (bit & 0x1f))
/* GPIO registers */ struct gpio_regs { diff --git a/arch/arm/include/asm/arch-mx25/imx-regs.h b/arch/arm/include/asm/arch-mx25/imx-regs.h index cf925d7..1f67abb 100644 --- a/arch/arm/include/asm/arch-mx25/imx-regs.h +++ b/arch/arm/include/asm/arch-mx25/imx-regs.h @@ -356,4 +356,10 @@ struct aips_regs { #define CHIP_REV_1_0 0x10 #define CHIP_REV_1_1 0x11
+ +/* Converts a GPIO port number and the internal bit position + * to the GPIO number + */ +#define MXC_GPIO_PORT_TO_NUM(port, bit) (((port - 1) << 5) + (bit & 0x1f)) + #endif /* _IMX_REGS_H */

Hi Vikram,
On Sun, Jun 10, 2012 at 10:02 AM, Vikram Narayanan vikram186@gmail.com wrote:
+/* Converts a GPIO port number and the internal bit position
- to the GPIO number
- */
+#define MXC_GPIO_PORT_TO_NUM(port, bit) (((port - 1) << 5) + (bit & 0x1f))
Just a minor comment:
MXC_GPIO_PORT_TO_NUM looks like a very looong string.
Couldn't we use the same macro as in the Linux kernel (IMX_GPIO_NR) instead?
It is more concise and it would nice to have the same macro name for kernel and U-boot.
What do you think?
Thanks,
Fabio Estevam

On 6/10/2012 8:03 PM, Fabio Estevam wrote:
Hi Vikram,
On Sun, Jun 10, 2012 at 10:02 AM, Vikram Narayananvikram186@gmail.com wrote:
+/* Converts a GPIO port number and the internal bit position
- to the GPIO number
- */
+#define MXC_GPIO_PORT_TO_NUM(port, bit) (((port - 1)<< 5) + (bit& 0x1f))
Just a minor comment:
MXC_GPIO_PORT_TO_NUM looks like a very looong string.
Couldn't we use the same macro as in the Linux kernel (IMX_GPIO_NR) instead?
It is more concise and it would nice to have the same macro name for kernel and U-boot.
What do you think?
Yes. That should be a better option. I'll go with it.
~Vikram
Thanks,
Fabio Estevam

On 6/11/2012 8:00 AM, Vikram Narayanan wrote:
On 6/10/2012 8:03 PM, Fabio Estevam wrote:
Hi Vikram,
On Sun, Jun 10, 2012 at 10:02 AM, Vikram Narayananvikram186@gmail.com wrote:
+/* Converts a GPIO port number and the internal bit position
- to the GPIO number
- */
+#define MXC_GPIO_PORT_TO_NUM(port, bit) (((port - 1)<< 5) + (bit& 0x1f))
Just a minor comment:
MXC_GPIO_PORT_TO_NUM looks like a very looong string.
Couldn't we use the same macro as in the Linux kernel (IMX_GPIO_NR) instead?
It is more concise and it would nice to have the same macro name for kernel and U-boot.
What do you think?
Yes. That should be a better option. I'll go with it.
We have this line already
arch/arm/include/asm/arch-mx6/imx-regs.h:#define GPIO_NUMBER(port, index) ((((port)-1)*32)+((index)&31))
~Vikram
Thanks,
Fabio Estevam
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot .

On Sun, Jun 10, 2012 at 10:02 AM, Vikram Narayanan vikram186@gmail.com wrote:
Move the macro to imx-regs.h so that the other mx25 boards can make use of it.
Signed-off-by: Vikram Narayanan vikram186@gmail.com
arch/arm/include/asm/arch-mx25/gpio.h | 4 ---- arch/arm/include/asm/arch-mx25/imx-regs.h | 6 ++++++ 2 files changed, 6 insertions(+), 4 deletions(-)
Also, this macro is useful not only for mx25, and it would be nice to let it avaible for the other i.MX SoCs as well.

Hello Fabio,
On 6/10/2012 8:33 PM, Fabio Estevam wrote:
On Sun, Jun 10, 2012 at 10:02 AM, Vikram Narayananvikram186@gmail.com wrote:
Move the macro to imx-regs.h so that the other mx25 boards can make use of it.
Signed-off-by: Vikram Narayananvikram186@gmail.com
arch/arm/include/asm/arch-mx25/gpio.h | 4 ---- arch/arm/include/asm/arch-mx25/imx-regs.h | 6 ++++++ 2 files changed, 6 insertions(+), 4 deletions(-)
Also, this macro is useful not only for mx25, and it would be nice to let it avaible for the other i.MX SoCs as well.
Agree. But I guess u-boot doesn't have a common folder where this can be put up something like plat-mxc. So, I should think where to place this macro to avoid duplicates in many header files. Any pointers?
Thanks, Vikram

On Mon, Jun 11, 2012 at 12:02 PM, Vikram Narayanan vikram186@gmail.com wrote:
Also, this macro is useful not only for mx25, and it would be nice to let it avaible for the other i.MX SoCs as well.
Agree. But I guess u-boot doesn't have a common folder where this can be put up something like plat-mxc. So, I should think where to place this macro to avoid duplicates in many header files. Any pointers?
Yes, a common folder would help indeed.
Copying Stefano, so that he could provide us some suggestion on this.
Thanks,
Fabio Estevam

On 13/06/2012 13:37, Fabio Estevam wrote:
On Mon, Jun 11, 2012 at 12:02 PM, Vikram Narayanan vikram186@gmail.com wrote:
Also, this macro is useful not only for mx25, and it would be nice to let it avaible for the other i.MX SoCs as well.
Agree. But I guess u-boot doesn't have a common folder where this can be put up something like plat-mxc. So, I should think where to place this macro to avoid duplicates in many header files. Any pointers?
Yes, a common folder would help indeed.
Copying Stefano, so that he could provide us some suggestion on this.
A general common folder helps - we have already an imx-common, whose name was copied from omap-common we already head. At the moment, it contains files common to i.MX5 and i.MX6. However, it is located under armv7, and it is not accessible for other i.MX.
Really I am for a solution like in kernel, with a plat-mxc into include/asm/, where we can put common things for all i.MX.
Best regards, Stefano Babic

Hi Stefano,
On 6/15/2012 8:25 PM, Stefano Babic wrote:
On 13/06/2012 13:37, Fabio Estevam wrote:
On Mon, Jun 11, 2012 at 12:02 PM, Vikram Narayananvikram186@gmail.com wrote:
Also, this macro is useful not only for mx25, and it would be nice to let it avaible for the other i.MX SoCs as well.
Agree. But I guess u-boot doesn't have a common folder where this can be put up something like plat-mxc. So, I should think where to place this macro to avoid duplicates in many header files. Any pointers?
Yes, a common folder would help indeed.
Copying Stefano, so that he could provide us some suggestion on this.
A general common folder helps - we have already an imx-common, whose name was copied from omap-common we already head. At the moment, it contains files common to i.MX5 and i.MX6. However, it is located under armv7, and it is not accessible for other i.MX.
Really I am for a solution like in kernel, with a plat-mxc into include/asm/, where we can put common things for all i.MX.
I'm with the same idea too. In this way we can avoid duplicate datastructures spread across many arch directories.
So, are there any opposers for this?
Regards, Vikram

On Fri, Jun 15, 2012 at 3:10 PM, Vikram Narayanan vikram186@gmail.com wrote:
Really I am for a solution like in kernel, with a plat-mxc into include/asm/, where we can put common things for all i.MX.
I'm with the same idea too. In this way we can avoid duplicate datastructures spread across many arch directories.
Agree!

Instead of manipulating gpio registers directly, use the calls from the gpio library.
Signed-off-by: Vikram Narayanan vikram186@gmail.com Cc: John Rigby jcrigby@gmail.com Cc: Stefano Babic sbabic@denx.de --- board/karo/tx25/tx25.c | 28 ++++++++++++---------------- 1 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/board/karo/tx25/tx25.c b/board/karo/tx25/tx25.c index 2a29943..6d03130 100644 --- a/board/karo/tx25/tx25.c +++ b/board/karo/tx25/tx25.c @@ -34,14 +34,13 @@ DECLARE_GLOBAL_DATA_PTR;
#ifdef CONFIG_FEC_MXC +#define GPIO_FEC_RESET_B MXC_GPIO_PORT_TO_NUM(4, 7) +#define GPIO_FEC_ENABLE_B MXC_GPIO_PORT_TO_NUM(4, 9) void tx25_fec_init(void) { struct iomuxc_mux_ctl *muxctl; struct iomuxc_pad_ctl *padctl; - u32 val; u32 gpio_mux_mode = MX25_PIN_MUX_MODE(5); - struct gpio_regs *gpio4 = (struct gpio_regs *)IMX_GPIO4_BASE; - struct gpio_regs *gpio3 = (struct gpio_regs *)IMX_GPIO3_BASE; u32 saved_rdata0_mode, saved_rdata1_mode, saved_rx_dv_mode;
debug("tx25_fec_init\n"); @@ -66,18 +65,18 @@ void tx25_fec_init(void) writel(0x0, &padctl->pad_d11);
/* drop PHY power and assert reset (low) */ - val = readl(&gpio4->gpio_dr) & ~((1 << 7) | (1 << 9)); - writel(val, &gpio4->gpio_dr); - val = readl(&gpio4->gpio_dir) | (1 << 7) | (1 << 9); - writel(val, &gpio4->gpio_dir); + gpio_direction_output(GPIO_FEC_RESET_B, 0); + gpio_direction_output(GPIO_FEC_ENABLE_B, 0); + + gpio_direction_output(GPIO_FEC_RESET_B, 1); + gpio_direction_output(GPIO_FEC_ENABLE_B, 1);
mdelay(5);
debug("resetting phy\n");
/* turn on PHY power leaving reset asserted */ - val = readl(&gpio4->gpio_dr) | 1 << 9; - writel(val, &gpio4->gpio_dr); + gpio_direction_output(GPIO_FEC_ENABLE_B, 1);
mdelay(10);
@@ -107,19 +106,16 @@ void tx25_fec_init(void) /* * set each to 1 and make each an output */ - val = readl(&gpio3->gpio_dr) | (1 << 10) | (1 << 11) | (1 << 12); - writel(val, &gpio3->gpio_dr); - val = readl(&gpio3->gpio_dir) | (1 << 10) | (1 << 11) | (1 << 12); - writel(val, &gpio3->gpio_dir); + gpio_direction_output(MXC_GPIO_PORT_TO_NUM(3, 10), 1); + gpio_direction_output(MXC_GPIO_PORT_TO_NUM(3, 11), 1); + gpio_direction_output(MXC_GPIO_PORT_TO_NUM(3, 12), 1);
mdelay(22); /* this value came from RedBoot */
/* * deassert PHY reset */ - val = readl(&gpio4->gpio_dr) | 1 << 7; - writel(val, &gpio4->gpio_dr); - writel(val, &gpio4->gpio_dr); + gpio_direction_output(GPIO_FEC_RESET_B, 1);
mdelay(5);

On Sun, Jun 10, 2012 at 10:03 AM, Vikram Narayanan vikram186@gmail.com wrote:
/* drop PHY power and assert reset (low) */
- val = readl(&gpio4->gpio_dr) & ~((1 << 7) | (1 << 9));
- writel(val, &gpio4->gpio_dr);
- val = readl(&gpio4->gpio_dir) | (1 << 7) | (1 << 9);
- writel(val, &gpio4->gpio_dir);
- gpio_direction_output(GPIO_FEC_RESET_B, 0);
- gpio_direction_output(GPIO_FEC_ENABLE_B, 0);
- gpio_direction_output(GPIO_FEC_RESET_B, 1);
- gpio_direction_output(GPIO_FEC_ENABLE_B, 1);
gpio_direction_output should be set only once for each GPIO.
After you set the direction (input or output) you should use 'gpio_set_value' for setting the GPIO to 0 or 1.
Also, please remove the:
gpio_direction_output(GPIO_FEC_RESET_B, 1);
gpio_direction_output(GPIO_FEC_ENABLE_B, 1);
lines, as the setting to 1 should be after the delay (via gpio_set_value).

Hi Fabio,
On 6/10/2012 8:08 PM, Fabio Estevam wrote:
On Sun, Jun 10, 2012 at 10:03 AM, Vikram Narayananvikram186@gmail.com wrote:
/* drop PHY power and assert reset (low) */
val = readl(&gpio4->gpio_dr)& ~((1<< 7) | (1<< 9));
writel(val,&gpio4->gpio_dr);
val = readl(&gpio4->gpio_dir) | (1<< 7) | (1<< 9);
writel(val,&gpio4->gpio_dir);
gpio_direction_output(GPIO_FEC_RESET_B, 0);
gpio_direction_output(GPIO_FEC_ENABLE_B, 0);
gpio_direction_output(GPIO_FEC_RESET_B, 1);
gpio_direction_output(GPIO_FEC_ENABLE_B, 1);
gpio_direction_output should be set only once for each GPIO.
After you set the direction (input or output) you should use 'gpio_set_value' for setting the GPIO to 0 or 1.
That was my understanding too. But some board file used it in the above way. Hope I got a wrong example. I'll fix this.
Also, please remove the:
gpio_direction_output(GPIO_FEC_RESET_B, 1);
gpio_direction_output(GPIO_FEC_ENABLE_B, 1);
lines, as the setting to 1 should be after the delay (via gpio_set_value).
Any idea about the delay value?
Thanks, Vikram

On Mon, Jun 11, 2012 at 11:58 AM, Vikram Narayanan vikram186@gmail.com wrote:
Hi Fabio,
On 6/10/2012 8:08 PM, Fabio Estevam wrote:
On Sun, Jun 10, 2012 at 10:03 AM, Vikram Narayananvikram186@gmail.com wrote:
/* drop PHY power and assert reset (low) */
val = readl(&gpio4->gpio_dr)& ~((1<< 7) | (1<< 9));
writel(val,&gpio4->gpio_dr);
val = readl(&gpio4->gpio_dir) | (1<< 7) | (1<< 9);
writel(val,&gpio4->gpio_dir);
- gpio_direction_output(GPIO_FEC_RESET_B, 0);
- gpio_direction_output(GPIO_FEC_ENABLE_B, 0);
- gpio_direction_output(GPIO_FEC_RESET_B, 1);
- gpio_direction_output(GPIO_FEC_ENABLE_B, 1);
gpio_direction_output should be set only once for each GPIO.
After you set the direction (input or output) you should use 'gpio_set_value' for setting the GPIO to 0 or 1.
That was my understanding too. But some board file used it in the above way. Hope I got a wrong example. I'll fix this.
Also, please remove the:
- gpio_direction_output(GPIO_FEC_RESET_B, 1);
- gpio_direction_output(GPIO_FEC_ENABLE_B, 1);
lines, as the setting to 1 should be after the delay (via gpio_set_value).
Any idea about the delay value?
You should not change the delay value, just use the same as in current code.
My comment was only for you to remove the
gpio_direction_output(GPIO_FEC_RESET_B, 1); gpio_direction_output(GPIO_FEC_ENABLE_B, 1);
,immediately after setting to 0.
Regards,
Fabio Estevam

Remove redundant gpio_regs structure for every board and define a common header for gpio_regs in the drivers/gpio directory. All the board files needs to be changed to point to asm-generic/gpio.h for gpio_* functions.
Signed-off-by: Vikram Narayanan vikram186@gmail.com Cc: John Rigby jcrigby@gmail.com Cc: Stefano Babic sbabic@denx.de Cc: Fabio Estevam fabio.estevam@freescale.com --- arch/arm/include/asm/arch-mx25/gpio.h | 41 -------------------- arch/arm/include/asm/arch-mx31/gpio.h | 35 ----------------- arch/arm/include/asm/arch-mx35/gpio.h | 40 ------------------- arch/arm/include/asm/arch-mx5/gpio.h | 35 ----------------- board/CarMediaLab/flea3/flea3.c | 2 +- board/davedenx/qong/fpga.c | 2 +- board/davedenx/qong/qong.c | 2 +- board/denx/m28evk/m28evk.c | 2 +- board/efikamx/efikamx-usb.c | 2 +- board/efikamx/efikamx.c | 2 +- board/esg/ima3-mx53/ima3-mx53.c | 2 +- board/freescale/mx28evk/mx28evk.c | 2 +- board/freescale/mx35pdk/mx35pdk.c | 2 +- board/freescale/mx51evk/mx51evk.c | 2 +- board/freescale/mx53ard/mx53ard.c | 2 +- board/freescale/mx53evk/mx53evk.c | 2 +- board/freescale/mx53loco/mx53loco.c | 2 +- board/freescale/mx53smd/mx53smd.c | 2 +- board/freescale/mx6qarm2/mx6qarm2.c | 2 +- board/freescale/mx6qsabrelite/mx6qsabrelite.c | 2 +- board/karo/tx25/tx25.c | 2 +- board/syteco/zmx25/zmx25.c | 2 +- board/ttcontrol/vision2/vision2.c | 2 +- common/cmd_gpio.c | 2 +- drivers/gpio/mxc_gpio.c | 2 +- .../asm/arch-mx6/gpio.h => drivers/gpio/mxc_gpio.h | 12 +++--- drivers/spi/mxc_spi.c | 2 +- 27 files changed, 28 insertions(+), 179 deletions(-) delete mode 100644 arch/arm/include/asm/arch-mx25/gpio.h delete mode 100644 arch/arm/include/asm/arch-mx31/gpio.h delete mode 100644 arch/arm/include/asm/arch-mx35/gpio.h delete mode 100644 arch/arm/include/asm/arch-mx5/gpio.h rename arch/arm/include/asm/arch-mx6/gpio.h => drivers/gpio/mxc_gpio.h (85%)
diff --git a/arch/arm/include/asm/arch-mx25/gpio.h b/arch/arm/include/asm/arch-mx25/gpio.h deleted file mode 100644 index cc32d50..0000000 --- a/arch/arm/include/asm/arch-mx25/gpio.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2011 - * Stefano Babic, DENX Software Engineering, sbabic@denx.de - * - * See file CREDITS for list of people who contributed to this - * project. - * - * 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., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - */ - - -#ifndef __ASM_ARCH_MX25_GPIO_H -#define __ASM_ARCH_MX25_GPIO_H - - -/* GPIO registers */ -struct gpio_regs { - u32 gpio_dr; /* data */ - u32 gpio_dir; /* direction */ - u32 psr; /* pad satus */ - u32 icr1; /* interrupt config 1 */ - u32 icr2; /* interrupt config 2 */ - u32 imr; /* interrupt mask */ - u32 isr; /* interrupt status */ - u32 edge_sel; /* edge select */ -}; - -#endif diff --git a/arch/arm/include/asm/arch-mx31/gpio.h b/arch/arm/include/asm/arch-mx31/gpio.h deleted file mode 100644 index 95b73bf..0000000 --- a/arch/arm/include/asm/arch-mx31/gpio.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2011 - * Stefano Babic, DENX Software Engineering, sbabic@denx.de - * - * See file CREDITS for list of people who contributed to this - * project. - * - * 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., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - */ - - -#ifndef __ASM_ARCH_MX31_GPIO_H -#define __ASM_ARCH_MX31_GPIO_H - -/* GPIO Registers */ -struct gpio_regs { - u32 gpio_dr; - u32 gpio_dir; - u32 gpio_psr; -}; - -#endif diff --git a/arch/arm/include/asm/arch-mx35/gpio.h b/arch/arm/include/asm/arch-mx35/gpio.h deleted file mode 100644 index 7bcc3e8..0000000 --- a/arch/arm/include/asm/arch-mx35/gpio.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2011 - * Stefano Babic, DENX Software Engineering, sbabic@denx.de - * - * See file CREDITS for list of people who contributed to this - * project. - * - * 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., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - */ - - -#ifndef __ASM_ARCH_MX35_GPIO_H -#define __ASM_ARCH_MX35_GPIO_H - -/* GPIO registers */ -struct gpio_regs { - u32 gpio_dr; /* data */ - u32 gpio_dir; /* direction */ - u32 psr; /* pad satus */ - u32 icr1; /* interrupt config 1 */ - u32 icr2; /* interrupt config 2 */ - u32 imr; /* interrupt mask */ - u32 isr; /* interrupt status */ - u32 edge_sel; /* edge select */ -}; - -#endif diff --git a/arch/arm/include/asm/arch-mx5/gpio.h b/arch/arm/include/asm/arch-mx5/gpio.h deleted file mode 100644 index 1dc34e9..0000000 --- a/arch/arm/include/asm/arch-mx5/gpio.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2011 - * Stefano Babic, DENX Software Engineering, sbabic@denx.de - * - * See file CREDITS for list of people who contributed to this - * project. - * - * 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., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - */ - - -#ifndef __ASM_ARCH_MX5_GPIO_H -#define __ASM_ARCH_MX5_GPIO_H - -/* GPIO registers */ -struct gpio_regs { - u32 gpio_dr; - u32 gpio_dir; - u32 gpio_psr; -}; - -#endif diff --git a/board/CarMediaLab/flea3/flea3.c b/board/CarMediaLab/flea3/flea3.c index 34ede87..5577ca7 100644 --- a/board/CarMediaLab/flea3/flea3.c +++ b/board/CarMediaLab/flea3/flea3.c @@ -33,7 +33,7 @@ #include <asm/arch/iomux.h> #include <i2c.h> #include <linux/types.h> -#include <asm/gpio.h> +#include <asm-generic/gpio.h> #include <asm/arch/sys_proto.h> #include <netdev.h>
diff --git a/board/davedenx/qong/fpga.c b/board/davedenx/qong/fpga.c index 6536a0b..726c136 100644 --- a/board/davedenx/qong/fpga.c +++ b/board/davedenx/qong/fpga.c @@ -25,7 +25,7 @@ #include <common.h> #include <asm/arch/clock.h> #include <asm/arch/imx-regs.h> -#include <asm/gpio.h> +#include <asm-generic/gpio.h> #include <fpga.h> #include <lattice.h> #include "qong_fpga.h" diff --git a/board/davedenx/qong/qong.c b/board/davedenx/qong/qong.c index c41f11d..0f29cb2 100644 --- a/board/davedenx/qong/qong.c +++ b/board/davedenx/qong/qong.c @@ -30,7 +30,7 @@ #include <nand.h> #include <pmic.h> #include <fsl_pmic.h> -#include <asm/gpio.h> +#include <asm-generic/gpio.h> #include "qong_fpga.h" #include <watchdog.h>
diff --git a/board/denx/m28evk/m28evk.c b/board/denx/m28evk/m28evk.c index 3d28ea8..1304ba3 100644 --- a/board/denx/m28evk/m28evk.c +++ b/board/denx/m28evk/m28evk.c @@ -24,7 +24,7 @@ */
#include <common.h> -#include <asm/gpio.h> +#include <asm-generic/gpio.h> #include <asm/io.h> #include <asm/arch/imx-regs.h> #include <asm/arch/iomux-mx28.h> diff --git a/board/efikamx/efikamx-usb.c b/board/efikamx/efikamx-usb.c index 618b39d..7845ff9 100644 --- a/board/efikamx/efikamx-usb.c +++ b/board/efikamx/efikamx-usb.c @@ -28,7 +28,7 @@ #include <asm/arch/imx-regs.h> #include <asm/arch/mx5x_pins.h> #include <asm/arch/iomux.h> -#include <asm/gpio.h> +#include <asm-generic/gpio.h> #include <usb/ehci-fsl.h> #include <usb/ulpi.h> #include <errno.h> diff --git a/board/efikamx/efikamx.c b/board/efikamx/efikamx.c index e88b2ed..4fd095d 100644 --- a/board/efikamx/efikamx.c +++ b/board/efikamx/efikamx.c @@ -27,7 +27,7 @@ #include <asm/arch/imx-regs.h> #include <asm/arch/mx5x_pins.h> #include <asm/arch/iomux.h> -#include <asm/gpio.h> +#include <asm-generic/gpio.h> #include <asm/errno.h> #include <asm/arch/sys_proto.h> #include <asm/arch/crm_regs.h> diff --git a/board/esg/ima3-mx53/ima3-mx53.c b/board/esg/ima3-mx53/ima3-mx53.c index 9ecf31d..e60d60d 100644 --- a/board/esg/ima3-mx53/ima3-mx53.c +++ b/board/esg/ima3-mx53/ima3-mx53.c @@ -32,7 +32,7 @@ #include <netdev.h> #include <mmc.h> #include <fsl_esdhc.h> -#include <asm/gpio.h> +#include <asm-generic/gpio.h>
/* NOR flash configuration */ #define IMA3_MX53_CS0GCR1 (CSEN | DSZ(2)) diff --git a/board/freescale/mx28evk/mx28evk.c b/board/freescale/mx28evk/mx28evk.c index 1bc83e9..3a09453 100644 --- a/board/freescale/mx28evk/mx28evk.c +++ b/board/freescale/mx28evk/mx28evk.c @@ -24,7 +24,7 @@ */
#include <common.h> -#include <asm/gpio.h> +#include <asm-generic/gpio.h> #include <asm/io.h> #include <asm/arch/imx-regs.h> #include <asm/arch/iomux-mx28.h> diff --git a/board/freescale/mx35pdk/mx35pdk.c b/board/freescale/mx35pdk/mx35pdk.c index bc415b8..e50d5cd 100644 --- a/board/freescale/mx35pdk/mx35pdk.c +++ b/board/freescale/mx35pdk/mx35pdk.c @@ -35,7 +35,7 @@ #include <mc9sdz60.h> #include <mc13892.h> #include <linux/types.h> -#include <asm/gpio.h> +#include <asm-generic/gpio.h> #include <asm/arch/sys_proto.h> #include <netdev.h>
diff --git a/board/freescale/mx51evk/mx51evk.c b/board/freescale/mx51evk/mx51evk.c index 514a7ac..3b47f86 100644 --- a/board/freescale/mx51evk/mx51evk.c +++ b/board/freescale/mx51evk/mx51evk.c @@ -22,7 +22,7 @@
#include <common.h> #include <asm/io.h> -#include <asm/gpio.h> +#include <asm-generic/gpio.h> #include <asm/arch/imx-regs.h> #include <asm/arch/mx5x_pins.h> #include <asm/arch/iomux.h> diff --git a/board/freescale/mx53ard/mx53ard.c b/board/freescale/mx53ard/mx53ard.c index 2d21584..a2410bc 100644 --- a/board/freescale/mx53ard/mx53ard.c +++ b/board/freescale/mx53ard/mx53ard.c @@ -31,7 +31,7 @@ #include <netdev.h> #include <mmc.h> #include <fsl_esdhc.h> -#include <asm/gpio.h> +#include <asm-generic/gpio.h>
#define ETHERNET_INT (1 * 32 + 31) /* GPIO2_31 */
diff --git a/board/freescale/mx53evk/mx53evk.c b/board/freescale/mx53evk/mx53evk.c index 8a6e31d..0edc327 100644 --- a/board/freescale/mx53evk/mx53evk.c +++ b/board/freescale/mx53evk/mx53evk.c @@ -34,7 +34,7 @@ #include <fsl_esdhc.h> #include <pmic.h> #include <fsl_pmic.h> -#include <asm/gpio.h> +#include <asm-generic/gpio.h> #include <mc13892.h>
DECLARE_GLOBAL_DATA_PTR; diff --git a/board/freescale/mx53loco/mx53loco.c b/board/freescale/mx53loco/mx53loco.c index d8e027c..d747b51 100644 --- a/board/freescale/mx53loco/mx53loco.c +++ b/board/freescale/mx53loco/mx53loco.c @@ -35,7 +35,7 @@ #include <i2c.h> #include <mmc.h> #include <fsl_esdhc.h> -#include <asm/gpio.h> +#include <asm-generic/gpio.h> #include <pmic.h> #include <dialog_pmic.h> #include <fsl_pmic.h> diff --git a/board/freescale/mx53smd/mx53smd.c b/board/freescale/mx53smd/mx53smd.c index c237980..9cf73f4 100644 --- a/board/freescale/mx53smd/mx53smd.c +++ b/board/freescale/mx53smd/mx53smd.c @@ -27,7 +27,7 @@ #include <asm/arch/sys_proto.h> #include <asm/arch/crm_regs.h> #include <asm/arch/iomux.h> -#include <asm/errno.h> +#include <asm-generic/errno.h> #include <netdev.h> #include <mmc.h> #include <fsl_esdhc.h> diff --git a/board/freescale/mx6qarm2/mx6qarm2.c b/board/freescale/mx6qarm2/mx6qarm2.c index 1367b88..c286a6d 100644 --- a/board/freescale/mx6qarm2/mx6qarm2.c +++ b/board/freescale/mx6qarm2/mx6qarm2.c @@ -26,7 +26,7 @@ #include <asm/arch/mx6x_pins.h> #include <asm/arch/iomux-v3.h> #include <asm/errno.h> -#include <asm/gpio.h> +#include <asm-generic/gpio.h> #include <mmc.h> #include <fsl_esdhc.h> #include <miiphy.h> diff --git a/board/freescale/mx6qsabrelite/mx6qsabrelite.c b/board/freescale/mx6qsabrelite/mx6qsabrelite.c index 29cbfed..72669c9 100644 --- a/board/freescale/mx6qsabrelite/mx6qsabrelite.c +++ b/board/freescale/mx6qsabrelite/mx6qsabrelite.c @@ -27,7 +27,7 @@ #include <asm/arch/iomux-v3.h> #include <asm/arch/clock.h> #include <asm/errno.h> -#include <asm/gpio.h> +#include <asm-generic/gpio.h> #include <mmc.h> #include <fsl_esdhc.h> #include <micrel.h> diff --git a/board/karo/tx25/tx25.c b/board/karo/tx25/tx25.c index 6d03130..d1c8701 100644 --- a/board/karo/tx25/tx25.c +++ b/board/karo/tx25/tx25.c @@ -28,7 +28,7 @@ #include <asm/io.h> #include <asm/arch/imx-regs.h> #include <asm/arch/imx25-pinmux.h> -#include <asm/gpio.h> +#include <asm-generic/gpio.h> #include <asm/arch/sys_proto.h>
DECLARE_GLOBAL_DATA_PTR; diff --git a/board/syteco/zmx25/zmx25.c b/board/syteco/zmx25/zmx25.c index c56b195..6efb783 100644 --- a/board/syteco/zmx25/zmx25.c +++ b/board/syteco/zmx25/zmx25.c @@ -29,7 +29,7 @@ * */ #include <common.h> -#include <asm/gpio.h> +#include <asm-generic/gpio.h> #include <asm/io.h> #include <asm/arch/imx-regs.h> #include <asm/arch/imx25-pinmux.h> diff --git a/board/ttcontrol/vision2/vision2.c b/board/ttcontrol/vision2/vision2.c index d68bef7..980016d 100644 --- a/board/ttcontrol/vision2/vision2.c +++ b/board/ttcontrol/vision2/vision2.c @@ -29,7 +29,7 @@ #include <asm/arch/mx5x_pins.h> #include <asm/arch/crm_regs.h> #include <asm/arch/iomux.h> -#include <asm/gpio.h> +#include <asm-generic/gpio.h> #include <asm/arch/sys_proto.h> #include <i2c.h> #include <mmc.h> diff --git a/common/cmd_gpio.c b/common/cmd_gpio.c index 47eee89..d33e83b 100644 --- a/common/cmd_gpio.c +++ b/common/cmd_gpio.c @@ -9,7 +9,7 @@ #include <common.h> #include <command.h>
-#include <asm/gpio.h> +#include <asm-generic/gpio.h>
#ifndef name_to_gpio #define name_to_gpio(name) simple_strtoul(name, NULL, 10) diff --git a/drivers/gpio/mxc_gpio.c b/drivers/gpio/mxc_gpio.c index 6615535..c990609 100644 --- a/drivers/gpio/mxc_gpio.c +++ b/drivers/gpio/mxc_gpio.c @@ -25,7 +25,7 @@ */ #include <common.h> #include <asm/arch/imx-regs.h> -#include <asm/gpio.h> +#include "mxc_gpio.h" #include <asm/io.h> #include <errno.h>
diff --git a/arch/arm/include/asm/arch-mx6/gpio.h b/drivers/gpio/mxc_gpio.h similarity index 85% rename from arch/arm/include/asm/arch-mx6/gpio.h rename to drivers/gpio/mxc_gpio.h index 20c4e57..af6a8e8 100644 --- a/arch/arm/include/asm/arch-mx6/gpio.h +++ b/drivers/gpio/mxc_gpio.h @@ -22,14 +22,14 @@ */
-#ifndef __ASM_ARCH_MX6_GPIO_H -#define __ASM_ARCH_MX6_GPIO_H +#ifndef __IMX_GPIO_H +#define __IMX_GPIO_H
/* GPIO registers */ struct gpio_regs { - u32 gpio_dr; - u32 gpio_dir; - u32 gpio_psr; + u32 gpio_dr; /* data */ + u32 gpio_dir; /* direction */ + u32 gpio_psr; /* pad satus */ };
-#endif /* __ASM_ARCH_MX6_GPIO_H */ +#endif /* __IMX_GPIO_H */ diff --git a/drivers/spi/mxc_spi.c b/drivers/spi/mxc_spi.c index 2e15318..e11b714 100644 --- a/drivers/spi/mxc_spi.c +++ b/drivers/spi/mxc_spi.c @@ -23,7 +23,7 @@ #include <spi.h> #include <asm/errno.h> #include <asm/io.h> -#include <asm/gpio.h> +#include <asm-generic/gpio.h> #include <asm/arch/imx-regs.h> #include <asm/arch/clock.h>

On 6/10/2012 6:31 PM, Vikram Narayanan wrote:
This patchset cleanups up the gpio related stuff on imx boards. Define a common header for gpio and remove the same struct defines in all the include directories.
As I don't have any mx25 based hardware, I've not tested it on any boards. Any testing report would be appreciated.
Thanks Vikram
participants (4)
-
Fabio Estevam
-
Stefano Babic
-
Troy Kisky
-
Vikram Narayanan