imx: gpio cleanups
Subsystems (4)
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%)
Signature · 1 line
1.7.4.1
PATCH 1/3 imx25: Move MXC_GPIO_PORT_TO_NUM to imx-regs.h
Move the macro to imx-regs.h so that the other mx25 boards can make use of it.
--- 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(-)
arch/arm/include/asm/arch-mx25/gpio.h +0 -4
@@ -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 {
arch/arm/include/asm/arch-mx25/imx-regs.h +6 -0
@@ -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 */
Signature · 1 line
1.7.4.1
PATCH 2/3 tx25: Use generic gpio_* calls
In reply to Vikram NarayananInstead of manipulating gpio registers directly, use the calls from the gpio library.
--- board/karo/tx25/tx25.c | 28 ++++++++++++---------------- 1 files changed, 12 insertions(+), 16 deletions(-)
board/karo/tx25/tx25.c +12 -16
@@ -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 );
Signature · 1 line
1.7.4.1
PATCH 3/3 imx: Define a common header file for gpio.h
In reply to Vikram NarayananRemove 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.
--- 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%)
arch/arm/include/asm/arch-mx25/gpio.h deleted +0 -41
@@ -1,41 +0,0 @@ -/* -* Copyright (C) 2011 -* Stefano Babic, DENX Software Engineering, <[email protected]> -* -* 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
arch/arm/include/asm/arch-mx31/gpio.h deleted +0 -35
@@ -1,35 +0,0 @@ -/* -* Copyright (C) 2011 -* Stefano Babic, DENX Software Engineering, <[email protected]> -* -* 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
arch/arm/include/asm/arch-mx35/gpio.h deleted +0 -40
@@ -1,40 +0,0 @@ -/* -* Copyright (C) 2011 -* Stefano Babic, DENX Software Engineering, <[email protected]> -* -* 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
arch/arm/include/asm/arch-mx5/gpio.h deleted +0 -35
@@ -1,35 +0,0 @@ -/* -* Copyright (C) 2011 -* Stefano Babic, DENX Software Engineering, <[email protected]> -* -* 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
board/CarMediaLab/flea3/flea3.c +1 -1
@@ -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>
board/davedenx/qong/fpga.c +1 -1
@@ -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"
board/davedenx/qong/qong.c +1 -1
@@ -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>
board/denx/m28evk/m28evk.c +1 -1
@@ -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>
board/efikamx/efikamx-usb.c +1 -1
@@ -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>
board/efikamx/efikamx.c +1 -1
@@ -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>
board/esg/ima3-mx53/ima3-mx53.c +1 -1
@@ -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))
board/freescale/mx28evk/mx28evk.c +1 -1
@@ -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>
board/freescale/mx35pdk/mx35pdk.c +1 -1
@@ -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>
board/freescale/mx51evk/mx51evk.c +1 -1
@@ -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>
board/freescale/mx53ard/mx53ard.c +1 -1
@@ -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 */
board/freescale/mx53evk/mx53evk.c +1 -1
@@ -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 ;
board/freescale/mx53loco/mx53loco.c +1 -1
@@ -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>
board/freescale/mx53smd/mx53smd.c +1 -1
@@ -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>
board/freescale/mx6qarm2/mx6qarm2.c +1 -1
@@ -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>
board/freescale/mx6qsabrelite/mx6qsabrelite.c +1 -1
@@ -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>
board/karo/tx25/tx25.c +1 -1
@@ -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 ;
board/syteco/zmx25/zmx25.c +1 -1
@@ -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>
board/ttcontrol/vision2/vision2.c +1 -1
@@ -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>
common/cmd_gpio.c +1 -1
@@ -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)
drivers/gpio/mxc_gpio.c +1 -1
@@ -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>
drivers/gpio/mxc_gpio.h renamed from arch/arm/include/asm/arch-mx6/gpio.h +6 -6
@@ -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 */
drivers/spi/mxc_spi.c +1 -1
@@ -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>
Signature · 1 line
1.7.4.1
Quoted 3 lines · Vikram Narayanan
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
Fabio Estevam
reviewerPATCH 1/3 imx25: Move MXC_GPIO_PORT_TO_NUM to imx-regs.h
In reply to Vikram NarayananHi Vikram,
arch/arm/include/asm/arch-mx25/imx-regs.h struct aips_regs { · line 363
Quoted 5 lines · Vikram Narayanan
arch/arm/include/asm/arch-mx25/imx-regs.h +5
-0+ +/* 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
Fabio Estevam
reviewerPATCH 2/3 tx25: Use generic gpio_* calls
In reply to Vikram NarayananQuoted 10 lines · Vikram Narayanan
? ? ? ?/* 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:
Review
Quoted 2 lines
(quoted diff) +2
-0+ 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).
Fabio Estevam
reviewerPATCH 1/3 imx25: Move MXC_GPIO_PORT_TO_NUM to imx-regs.h
In reply to Vikram NarayananQuoted 8 lines · Vikram Narayanan
Move the macro to
imx-regs.hso that the other mx25 boards can make use of it.Signed-off-by Vikram Narayanan <[email protected]>---
?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.
PATCH 2/3 tx25: Use generic gpio_* calls
In reply to Fabio EstevamHi Fabio,
Quoted 13 lines · Fabio Estevam
board/karo/tx25/tx25.c void tx25_fec_init(void) · line 72
Quoted 10 lines · Vikram Narayanan
/* drop PHY power and assert reset (low) */board/karo/tx25/tx25.c +5
-4- 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 );
Quoted 4 lines
gpio_direction_outputshould 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.
Quoted 6 lines
Also, please remove the:
Review
Quoted 2 lines
(quoted diff) +2
-0+ 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
PATCH 1/3 imx25: Move MXC_GPIO_PORT_TO_NUM to imx-regs.h
In reply to Fabio EstevamQuoted 12 lines · Fabio Estevam
Hi Vikram,
arch/arm/include/asm/arch-mx25/imx-regs.h struct aips_regs {
Quoted 5 lines · Vikram Narayanan
arch/arm/include/asm/arch-mx25/imx-regs.h +5
-0+ +/* 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:
Quoted 8 lines
MXC_GPIO_PORT_TO_NUMlooks 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
Quoted 3 lines
Thanks,
Fabio Estevam
Fabio Estevam
reviewerPATCH 2/3 tx25: Use generic gpio_* calls
In reply to Vikram NarayananQuoted 34 lines · Vikram Narayanan
Hi Fabio,
Quoted 18 lines · Fabio Estevam
Quoted 4 lines · On Sun, Jun 10, 2012 at 10:03 AM, Vikram Narayanan<[email protected]> ?wrote:
? ? ? ?/* drop PHY power and assert reset (low) */
- ? ? ? val = readl(&gpio4->gpio_dr)& ?~((1<< ?7) | (1<< ?9));
- ? ? ?writel(val,&gpio4->gpio_dr);Quoted 8 lines
- ? ? ? 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);Quoted 4 lines
gpio_direction_outputshould 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.
Quoted 2 lines
Also, please remove the:
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
+ ? ? ?
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
PATCH 1/3 imx25: Move MXC_GPIO_PORT_TO_NUM to imx-regs.h
In reply to Fabio EstevamHello Fabio,
Quoted 4 lines · Fabio Estevam
Quoted 3 lines · Vikram Narayanan
Move the macro to
imx-regs.hso that the other mx25 boards can make use of it.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Vikram Narayanan<[email protected]>--- 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
PATCH 1/3 imx25: Move MXC_GPIO_PORT_TO_NUM to imx-regs.h
In reply to Vikram NarayananQuoted 20 lines · Vikram Narayanan
Quoted 19 lines · Fabio Estevam
Hi Vikram,
Quoted 6 lines · Vikram Narayanan
arch/arm/include/asm/arch-mx25/imx-regs.h +5
-0+ +/* 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_NUMlooks like a very looong string.Couldn't we use the same macro as in the Linux kernel (
IMX_GPIO_NR) instead?
Quoted 6 lines
Quoted 4 lines
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))
Quoted 13 lines
~Vikram
Quoted 3 lines
Thanks,
Fabio Estevam
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
.
Fabio Estevam
reviewerPATCH 1/3 imx25: Move MXC_GPIO_PORT_TO_NUM to imx-regs.h
In reply to Vikram NarayananQuoted 7 lines · Vikram Narayanan
Quoted 2 lines
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
PATCH 1/3 imx25: Move MXC_GPIO_PORT_TO_NUM to imx-regs.h
Quoted 6 lines · Fabio Estevam
Quoted 4 lines · Vikram Narayanan
Quoted 2 lines
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.
Quoted 7 lines
Quoted 3 lines
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
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH 1/3 imx25: Move MXC_GPIO_PORT_TO_NUM to imx-regs.h
Hi Stefano,
Quoted 15 lines · Stefano Babic
Quoted 6 lines · Fabio Estevam
Quoted 4 lines · Vikram Narayanan
Quoted 2 lines
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.
Quoted 7 lines
Quoted 3 lines
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.
Quoted 7 lines
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
Fabio Estevam
reviewerPATCH 1/3 imx25: Move MXC_GPIO_PORT_TO_NUM to imx-regs.h
Quoted 6 lines · Vikram Narayanan
Quoted 2 lines
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!