From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefano Babic Date: Thu, 23 Aug 2012 16:03:50 +0200 Subject: [U-Boot] [PATCH] mxc: Make gpio_get_value() use PSR In-Reply-To: <1991832745.2612487.1345496141598.JavaMail.root@advansee.com> References: <1991832745.2612487.1345496141598.JavaMail.root@advansee.com> Message-ID: <50363846.3040906@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 20/08/2012 22:55, Beno?t Th?baudeau wrote: > gpio_get_value() should use PSR like Linux, not DR, because DR does not always > reflect the pin state, while PSR does. This is especially useful to detect a > short circuit on a GPIO pin configured as output, or to read the level of a pin > controlled by a non-GPIO IOMUX function. > > Signed-off-by: Beno?t Th?baudeau > Cc: Stefano Babic > --- > This patch depends on http://patchwork.ozlabs.org/patch/178694/ . > > .../drivers/gpio/mxc_gpio.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git u-boot-imx-84ab1cb.orig/drivers/gpio/mxc_gpio.c u-boot-imx-84ab1cb/drivers/gpio/mxc_gpio.c > index 6615535..e9bf278 100644 > --- u-boot-imx-84ab1cb.orig/drivers/gpio/mxc_gpio.c > +++ u-boot-imx-84ab1cb/drivers/gpio/mxc_gpio.c > @@ -116,7 +116,7 @@ int gpio_get_value(unsigned gpio) > > regs = (struct gpio_regs *)gpio_ports[port]; > > - val = (readl(®s->gpio_dr) >> gpio) & 0x01; > + val = (readl(®s->gpio_psr) >> gpio) & 0x01; > > return val; > } > Applied to u-boot-imx, thanks. 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 =====================================================================