gpio: add gpio api support to mx27
Subsystems (3)
PATCH 1/2 gpio: add gpio api support to mx27
--- arch/arm/cpu/arm926ejs/mx27/generic.c | 11 +++--- arch/arm/include/asm/arch-mx27/gpio.h | 55 +++++++++++++++++++++++++++++ arch/arm/include/asm/arch-mx27/imx-regs.h | 30 ++++------------ drivers/gpio/mxc_gpio.c | 8 +++-- 4 files changed, 73 insertions(+), 31 deletions(-) create mode 100644 arch/arm/include/asm/arch-mx27/gpio.h
arch/arm/cpu/arm926ejs/mx27/generic.c +6 -5
@@ -24,6 +24,7 @@#include <asm/io.h> #include <asm/arch/imx-regs.h> #include <asm/arch/clock.h> +#include <asm/arch/gpio.h> #ifdef CONFIG_MXC_MMC #include <asm/arch/mxcmmc.h> #endif
@@ -209,7 +210,7 @@ int cpu_mmc_init(bd_t *bis)void imx_gpio_mode (int gpio_mode) { -struct gpio_regs *regs = (struct gpio_regs *)IMX_GPIO_BASE ; +struct gpio_port_regs *regs = (struct gpio_port_regs *)IMX_GPIO_BASE ;unsigned int pin = gpio_mode &GPIO_PIN_MASK ;unsigned int port = (gpio_mode &GPIO_PORT_MASK ) >>GPIO_PORT_SHIFT ;unsigned int ocr = (gpio_mode &GPIO_OCR_MASK ) >>GPIO_OCR_SHIFT ;
@@ -228,11 +229,11 @@ void imx_gpio_mode(int gpio_mode)/* Data direction */ if (gpio_mode &GPIO_OUT ) { -writel (readl (®s->port[port].ddir) |1 << pin, - ®s->port[port].ddir); +writel (readl (®s->port[port].gpio_dir) |1 << pin, + ®s->port[port].gpio_dir); }else { -writel (readl (®s->port[port].ddir) & ~(1 << pin), - ®s->port[port].ddir); +writel (readl (®s->port[port].gpio_dir) & ~(1 << pin), + ®s->port[port].gpio_dir); }/* Primary / alternate function */
arch/arm/include/asm/arch-mx27/gpio.h new file +55 -0
55 lines not on this page · raw message
arch/arm/include/asm/arch-mx27/imx-regs.h +7 -23
@@ -162,29 +162,6 @@ struct gpt_regs {#define PORTE 4#define PORTF 5 -struct gpio_regs { -struct { -u32 ddir; -u32 ocr1; -u32 ocr2; -u32 iconfa1; -u32 iconfa2; -u32 iconfb1; -u32 iconfb2; -u32 dr; -u32 gius; -u32 ssr; -u32 icr1; -u32 icr2; -u32 imr; -u32 isr; -u32 gpr; -u32 swr; -u32 puen; -u32 res[0x2f ]; - } port[6 ]; -}; -/* IIM Control Registers */ struct iim_regs {u32 iim_stat;
@@ -471,6 +448,13 @@ struct fuse_bank0_regs {#define TSTAT_CAPT (1 << 1)/* Capture event */ #define TSTAT_COMP 1/* Compare event */ +#define GPIO1_BASE_ADDR 0x10015000 +#define GPIO2_BASE_ADDR 0x10015100 +#define GPIO3_BASE_ADDR 0x10015200 +#define GPIO4_BASE_ADDR 0x10015300 +#define GPIO5_BASE_ADDR 0x10015400 +#define GPIO6_BASE_ADDR 0x10015500 +#define GPIO_PIN_MASK 0x1f#define GPIO_PORT_SHIFT 5
drivers/gpio/mxc_gpio.c +5 -3
@@ -41,13 +41,15 @@ static unsigned long gpio_ports[] = { [0] = GPIO1_BASE_ADDR, [1] = GPIO2_BASE_ADDR, [2] = GPIO3_BASE_ADDR, -#if defined(CONFIG_MX25 ) || defined(CONFIG_MX51 ) || defined(CONFIG_MX53 ) || \ - defined(CONFIG_MX6Q ) +#if defined(CONFIG_MX25 ) || defined(CONFIG_MX27 ) || defined(CONFIG_MX51 ) || \ + defined(CONFIG_MX53 ) || defined(CONFIG_MX6Q ) [3] = GPIO4_BASE_ADDR,#endif -#if defined(CONFIG_MX53 ) || defined(CONFIG_MX6Q ) +#if defined(CONFIG_MX27 ) || defined(CONFIG_MX53 ) || defined(CONFIG_MX6Q ) [4] = GPIO5_BASE_ADDR, [5] = GPIO6_BASE_ADDR, +#endif +#if defined(CONFIG_MX53 ) || defined(CONFIG_MX6Q ) [6] = GPIO7_BASE_ADDR,#endif };
Signature · 1 line
1.7.4.4
PATCH 2/2 imx27lite: update with gpio api change
--- board/logicpd/imx27lite/imx27lite.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
board/logicpd/imx27lite/imx27lite.c +4 -3
@@ -23,12 +23,13 @@#include <common.h> #include <asm/io.h> #include <asm/arch/imx-regs.h> +#include <asm/arch/gpio.h> DECLARE_GLOBAL_DATA_PTR ;int board_init (void ) { -struct gpio_regs *regs = (struct gpio_regs *)IMX_GPIO_BASE ; +struct gpio_port_regs *regs = (struct gpio_port_regs *)IMX_GPIO_BASE ;#if defined(CONFIG_SYS_NAND_LARGEPAGE )struct system_control_regs *sc_regs = (struct system_control_regs *)IMX_SYSTEM_CTL_BASE ;
@@ -43,8 +44,8 @@ int board_init(void)#ifdef CONFIG_FEC_MXC mx27_fec_init_pins ();imx_gpio_mode ((GPIO_PORTC |GPIO_OUT |GPIO_PUEN |GPIO_GPIO |31 )); -writel (readl (®s->port[PORTC ].dr) | (1 <<31 ), - ®s->port[PORTC ].dr); +writel (readl (®s->port[PORTC ].gpio_dr) | (1 <<31 ), + ®s->port[PORTC ].gpio_dr);#endif #ifdef CONFIG_MXC_MMC #if defined(CONFIG_MAGNESIUM )
Signature · 1 line
1.7.4.4
PATCH 2/2 imx27lite: update with gpio api change
Quoted 5 lines · Philippe Reynes
Signed-off-by Philippe Reynes <[email protected]>--- board/logicpd/imx27lite/imx27lite.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
Hi Philippe,
Quoted 7 lines
{
board/logicpd/imx27lite/imx27lite.c +1
-1-struct gpio_regs *regs = (struct gpio_regs *)IMX_GPIO_BASE ; +struct gpio_port_regs *regs = (struct gpio_port_regs *)IMX_GPIO_BASE ;#if defined(CONFIG_SYS_NAND_LARGEPAGE )struct system_control_regs *sc_regs = (struct system_control_regs *)IMX_SYSTEM_CTL_BASE ;
board/logicpd/imx27lite/imx27lite.c int board_init(void) · line 48
Quoted 7 lines
board/logicpd/imx27lite/imx27lite.c +2
-2@@ -43,8 +44,8 @@ int board_init(void)#ifdef CONFIG_FEC_MXC mx27_fec_init_pins ();imx_gpio_mode ((GPIO_PORTC |GPIO_OUT |GPIO_PUEN |GPIO_GPIO |31 )); -writel (readl (®s->port[PORTC ].dr) | (1 <<31 ), - ®s->port[PORTC ].dr); +writel (readl (®s->port[PORTC ].gpio_dr) | (1 <<31 ), + ®s->port[PORTC ].gpio_dr);
This is not what I am expecting from the patch when it will move to generic GPIO API.
The GPIO API uses really generic as in kernel functions, independently from the SOC where it is running. This hides the physical registers of the GPIOs.
Instead of that, gpio_set_value(), gpio_get_value(), gpio_direction_input() and gpio_direction_output() should be used. You can take a look at other iMX (MX3, MX28, MX5, MX6), that are already using the generic API.
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 2/2 imx27lite: update with gpio api change
Quoted 10 lines · Philippe Reynes
Quoted 5 lines
Signed-off-by Philippe Reynes <[email protected]>---
?board/logicpd/imx27lite/imx27lite.c|? ? 7 ++++--- ? 1 files changed, 4 insertions(+), 3 deletions(-)Hi Philippe,
Hi Stefano,
Quoted 18 lines
Quoted 7 lines
? {
-??? structgpio_regs*regs = (structgpio_regs*)IMX_GPIO_BASE; +??? structgpio_port_regs*regs = (structgpio_port_regs*)IMX_GPIO_BASE; ? #ifdefined(CONFIG_SYS_NAND_LARGEPAGE)
? ??? structsystem_control_regs*sc_regs=
? ??? ??? (structsystem_control_regs*)IMX_SYSTEM_CTL_BASE;(quoted diff) +0
-0@@ -43,8 +44,8 @@ int board_init(void)Quoted 7 lines
? #ifdef
CONFIG_FEC_MXC
? ???mx27_fec_init_pins();
? ???imx_gpio_mode((GPIO_PORTC | GPIO_OUT | GPIO_PUEN | GPIO_GPIO | 31)); -??? writel(readl(®s->port[PORTC].dr) | (1 << 31),
-??? ??? ??? ??? ®s->port[PORTC].dr);
+???writel(readl(®s->port[PORTC].gpio_dr) | (1 << 31), +??? ??? ??? ??? ®s->port[PORTC].gpio_dr);This is not what I am expecting from the patch when it will move to generic GPIO API.
Quoted 8 lines
The GPIO API uses really generic as in kernel functions, independently from the SOC where it is running. This hides the physical registers of the GPIOs.
Instead of that,
gpio_set_value(),gpio_get_value(),gpio_direction_input()andgpio_direction_output()should be used. You can take a look at other iMX (MX3, MX28, MX5, MX6), that are already using the generic API.
Oh, I understand. As I don't have this board, I've done the smallest change to fix the compilation. I add the driver mxc_gpio on imx27lite, remove this direct acces to gpio register, ?and send the new version of the patch.
regards,
Philippe
PATCH 2/2 imx27lite: update with gpio api change
Quoted 5 lines · Philippe Reynes
Oh, I understand. As I don't have this board, I've done the smallest change to fix the compilation.
I add the drivermxc_gpioon imx27lite, remove this direct acces to gpio register,
and send the new version of the patch.
I think I can test it, at least the base functionality.
Best regards,
Stefano
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 =====================================================================