Received: from mail.onstor.com (66.201.51.107) by exch1.onstor.net
 (10.0.0.225) with Microsoft SMTP Server id 8.1.311.2; Fri, 28 Nov 2008
 11:44:08 -0800
Received: from dalesmta2-2.messageone.com ([129.41.169.249]) by
 mail.onstor.com with Microsoft SMTPSVC(6.0.3790.3959);	 Fri, 28 Nov 2008
 11:44:08 -0800
Received: from ftp.linux-mips.org (ftp.linux-mips.org [213.58.128.207])	by
 dalesmta2-2.messageone.com (8.13.8/8.13.8) with ESMTP id mASJi7EA026094	for
 <andy.sharp@onstor.com>; Fri, 28 Nov 2008 13:44:07 -0600
Received: from localhost.localdomain ([127.0.0.1]:23000 "EHLO
	ftp.linux-mips.org") by ftp.linux-mips.org with ESMTP	id S23974177AbYK1ToA
 (ORCPT <rfc822;andy.sharp@onstor.com>);	Fri, 28 Nov 2008 19:44:00 +0000
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 28 Nov 2008 19:43:43
 +0000 (GMT)
Received: from orbit.nwl.cc ([81.169.176.177]:53151 "EHLO
	mail.ifyouseekate.net") by ftp.linux-mips.org with ESMTP	id S23974383AbYK1Tnj
 (ORCPT <rfc822;linux-mips@linux-mips.org>);	Fri, 28 Nov 2008 19:43:39 +0000
Received: from nuty (localhost [127.0.0.1])	by mail.ifyouseekate.net (Postfix)
 with ESMTP id B8090386B1A6;	Fri, 28 Nov 2008 20:43:33 +0100 (CET)
From: Phil Sutter <n0-1@freewrt.org>
To: Ralf Baechle <ralf@linux-mips.org>
CC: "linux-mips@linux-mips.org" <linux-mips@linux-mips.org>
Sender: "linux-mips-bounce@linux-mips.org" <linux-mips-bounce@linux-mips.org>
Date: Fri, 28 Nov 2008 11:46:09 -0800
Subject: [PATCH] MIPS: rb532: auto disable GPIO alternate function
Thread-Topic: [PATCH] MIPS: rb532: auto disable GPIO alternate function
Thread-Index: AclRka46AFLQD2MQQQyhnXPx8IeacA==
Message-ID: <20081128194333.B8090386B1A6@mail.ifyouseekate.net>
References: <20081128193322.D103C386DBBE@mail.ifyouseekate.net>
In-Reply-To: <20081128193322.D103C386DBBE@mail.ifyouseekate.net>
Accept-Language: en-US
Content-Language: en-US
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 0b
X-MS-Exchange-Organization-AuthSource: exch1.onstor.net
X-MS-Has-Attach:
X-Auto-Response-Suppress: All
X-MS-TNEF-Correlator:
x-originalarrivaltime: 28 Nov 2008 19:44:08.0816 (UTC)
 FILETIME=[AE00B700:01C95191]
errors-to: linux-mips-bounce@linux-mips.org
x-ems-proccessed: 2K3Xl1OQTInXD6xxuA8z3Q==
x-ems-stamp: et0bhV+bN3QcDL1VYnjZ7g==
x-messageone-virus-version: vendor=fsecure
 engine=4.65.7400:2.4.4,1.2.40,4.0.164
 definitions=2008-11-26_13:2008-11-24,2008-11-26,2008-11-26 signatures=0
x-messageone-virus-scanned: Clean
x-messageone-envelope-sender: linux-mips-bounce@linux-mips.org
x-messageone-spam-details: rule=m773emszm_notspam policy=m773emszm score=0
 spamscore=0 ipscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam
 adjust=0 reason=mlx engine=3.1.0-0810130000 definitions=main-0811260160
x-messageone-spam-score: 0
x-messageone-spam-bar:
x-list: linux-mips
x-archive-position: 21469
x-ecartis-version: Ecartis v1.0.0
x-original-sender: n0-1@freewrt.org
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

When a driver calls gpio_set_direction_{input,output}(), it obviously
doesn't want the alternate function for that pin to be active (as the
direction would not matter in that case). This patch ensures alternate
function is disabled when the direction is being changed.

Signed-off-by: Phil Sutter <n0-1@freewrt.org>
---
 arch/mips/rb532/gpio.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/mips/rb532/gpio.c b/arch/mips/rb532/gpio.c
index e35cb75..f5b15a1 100644
--- a/arch/mips/rb532/gpio.c
+++ b/arch/mips/rb532/gpio.c
@@ -169,8 +169,8 @@ static int rb532_gpio_direction_input(struct gpio_chip =
*chip, unsigned offset)
=20
 	gpch =3D container_of(chip, struct rb532_gpio_chip, chip);
=20
-	if (rb532_get_bit(offset, gpch->regbase + GPIOFUNC))
-		return 1;	/* alternate function, GPIOCFG is ignored */
+	/* disable alternate function in case it's set */
+	rb532_set_bit(0, offset, gpch->regbase + GPIOFUNC);
=20
 	rb532_set_bit(0, offset, gpch->regbase + GPIOCFG);
 	return 0;
@@ -186,8 +186,8 @@ static int rb532_gpio_direction_output(struct gpio_chip=
 *chip,
=20
 	gpch =3D container_of(chip, struct rb532_gpio_chip, chip);
=20
-	if (rb532_get_bit(offset, gpch->regbase + GPIOFUNC))
-		return 1;	/* alternate function, GPIOCFG is ignored */
+	/* disable alternate function in case it's set */
+	rb532_set_bit(0, offset, gpch->regbase + GPIOFUNC);
=20
 	/* set the initial output value */
 	rb532_set_bit(value, offset, gpch->regbase + GPIOD);
--=20
1.5.6.4


