From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefano Babic Date: Thu, 23 Aug 2012 16:39:52 +0200 Subject: [U-Boot] [PATCH 1/2] gpio: add gpio api support to mx27 (v2) In-Reply-To: <1344266963-2514-1-git-send-email-tremyfr@yahoo.fr> References: <1344266963-2514-1-git-send-email-tremyfr@yahoo.fr> Message-ID: <503640B8.2010605@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 06/08/2012 17:29, Philippe Reynes wrote: > There is a little change on gpio_get_value because > on mx27 the register to read is ssr and not dr. > > Signed-off-by: Philippe Reynes > --- Hi Philippe, > 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 | 12 +++++-- > 4 files changed, 77 insertions(+), 31 deletions(-) > create mode 100644 arch/arm/include/asm/arch-mx27/gpio.h > > diff --git a/arch/arm/cpu/arm926ejs/mx27/generic.c b/arch/arm/cpu/arm926ejs/mx27/generic.c > index 65c4813..41bb84b 100644 > --- a/arch/arm/cpu/arm926ejs/mx27/generic.c > +++ b/arch/arm/cpu/arm926ejs/mx27/generic.c > @@ -24,6 +24,7 @@ > #include > #include > #include > +#include > #ifdef CONFIG_MXC_MMC > #include > #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); > } This is strange, because it does not make use of gpio_direction_output(). However, if we use it, generic.c depends on CONFIG_MXC_GPIO. Ok > > +#ifndef CONFIG_MX27 > val = (readl(®s->gpio_dr) >> gpio) & 0x01; > +#else > + val = (readl(®s->ssr) >> gpio) & 0x01; > +#endif > A recent patch uses psr on the other SOC instead of dr to read directly the pad status instead of the internal shadow register. If you rename your ssr into gpio_psr we do not need this #ifdef. Best regards, Stefano Babic -- ===================================================================== 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 =====================================================================