From d6f32393eaf455ce3c32d4e9bafd34d9091eaf45 Mon Sep 17 00:00:00 2001 From: Mahesh Mahadevan Date: Wed, 22 May 2013 17:05:06 -0500 Subject: ENGR00263785 Update code to read GPIO signal value The code reads the direction register and returns value from the DR register if pin is configured as output and from the PSR register if pin is configured as input. Signed-off-by: Mahesh Mahadevan --- arch/arm/plat-mxc/gpio.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'arch') diff --git a/arch/arm/plat-mxc/gpio.c b/arch/arm/plat-mxc/gpio.c index 82b70d537df9..e12aee5b093b 100755 --- a/arch/arm/plat-mxc/gpio.c +++ b/arch/arm/plat-mxc/gpio.c @@ -3,7 +3,7 @@ * Copyright 2008 Juergen Beisert, kernel@pengutronix.de * * Based on code from Freescale, - * Copyright (C) 2004-2012 Freescale Semiconductor, Inc. + * Copyright (C) 2004-2013 Freescale Semiconductor, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -283,8 +283,13 @@ static int mxc_gpio_get(struct gpio_chip *chip, unsigned offset) { struct mxc_gpio_port *port = container_of(chip, struct mxc_gpio_port, chip); + u32 gpio_direction; - return (__raw_readl(port->base + GPIO_PSR) >> offset) & 1; + gpio_direction = __raw_readl(port->base + GPIO_GDIR); + if (((gpio_direction >> offset) & 1)) /* output mode */ + return (__raw_readl(port->base + GPIO_DR) >> offset) & 1; + else /* input mode */ + return (__raw_readl(port->base + GPIO_PSR) >> offset) & 1; } static int mxc_gpio_direction_input(struct gpio_chip *chip, unsigned offset) -- cgit v1.2.3