Received: from mail.onstor.com ([66.201.51.107]) by onstor-exch02.onstor.net with Microsoft SMTPSVC(6.0.3790.3959);
	 Tue, 23 Sep 2008 12:04:36 -0700
Received: from ausesmta2-2.messageone.com ([64.20.241.45]) by mail.onstor.com with Microsoft SMTPSVC(6.0.3790.3959);
	 Tue, 23 Sep 2008 12:04:36 -0700
Received: from ftp.linux-mips.org (ftp.linux-mips.org [213.58.128.207])
	by ausesmta2-2.messageone.com (8.13.8/8.13.8) with ESMTP id m8NJ4YjQ011337
	for <andy.sharp@onstor.com>; Tue, 23 Sep 2008 14:04:35 -0500
Received: from localhost.localdomain ([127.0.0.1]:57323 "EHLO
	ftp.linux-mips.org") by ftp.linux-mips.org with ESMTP
	id S28600479AbYIWRtM (ORCPT <rfc822;andy.sharp@onstor.com>);
	Tue, 23 Sep 2008 18:49:12 +0100
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 23 Sep 2008 18:48:55 +0100 (BST)
Received: from mail30g.wh2.ocn.ne.jp ([220.111.41.239]:25761 "HELO
	mail30g.wh2.ocn.ne.jp") by ftp.linux-mips.org with SMTP
	id S28595016AbYIWRsp (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Tue, 23 Sep 2008 18:48:45 +0100
Received: from vs30a.wh2.ocn.ne.jp (220.111.41.231)
	by mail30g.wh2.ocn.ne.jp (RS ver 1.0.95vs) with SMTP id 0-0707642116;
	Wed, 24 Sep 2008 02:48:39 +0900 (JST)
From: Bruno Randolf <br1@einfach.org>
Subject: [PATCH] au1000: fix gpio direction
To: ralf@linux-mips.org
Cc: linux-mips@linux-mips.org
Date: 	Tue, 23 Sep 2008 19:48:36 +0200
Message-ID: <20080923174828.8694.12510.stgit@void>
User-Agent: StGIT/0.14.3
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
X-SF-Loop: 1
X-archive-position: 20605
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: br1@einfach.org
Precedence: bulk
X-list: 	linux-mips
X-MessageOne-Virus-Version: vendor=fsecure engine=4.65.7161:2.4.4,1.2.40,4.0.164 definitions=2008-09-23_08:2008-09-19,2008-09-23,2008-09-23 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-0805090000 definitions=main-0809230113
X-MessageOne-Spam-Score: 0
X-MessageOne-Spam-Bar: 
Return-Path: linux-mips-bounce@linux-mips.org
X-OriginalArrivalTime: 23 Sep 2008 19:04:36.0439 (UTC) FILETIME=[38B13670:01C91DAF]

when setting the direction of one GPIO pin we have to keep the state of the
other pins, hence use binary OR. also gpio_direction_output() wants to set an
initial value, so add that too.

this fixes a problem with the USB power switch on mtx-1 boards.

Signed-off-by: Bruno Randolf <br1@einfach.org>
---

 arch/mips/au1000/common/gpio.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/arch/mips/au1000/common/gpio.c b/arch/mips/au1000/common/gpio.c
index b485d94..1f05843 100644
--- a/arch/mips/au1000/common/gpio.c
+++ b/arch/mips/au1000/common/gpio.c
@@ -61,7 +61,8 @@ static int au1xxx_gpio2_direction_input(unsigned gpio)
 static int au1xxx_gpio2_direction_output(unsigned gpio, int value)
 {
 	gpio -= AU1XXX_GPIO_BASE;
-	gpio2->dir = (0x01 << gpio) | (value << gpio);
+	gpio2->dir |= 0x01 << gpio;
+	gpio2->output = (GPIO2_OUTPUT_ENABLE_MASK << gpio) | (value << gpio);
 	return 0;
 }
 
@@ -90,6 +91,7 @@ static int au1xxx_gpio1_direction_input(unsigned gpio)
 static int au1xxx_gpio1_direction_output(unsigned gpio, int value)
 {
 	gpio1->trioutclr = (0x01 & gpio);
+	au1xxx_gpio1_write(gpio, value);
 	return 0;
 }
 


