From patchwork Fri Jun 28 06:45:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 255282 X-Patchwork-Delegate: sonic.adi@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id DDC8C2C0343 for ; Fri, 28 Jun 2013 16:46:06 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DC7844A15C; Fri, 28 Jun 2013 08:45:54 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CvEUEH5t-Tr5; Fri, 28 Jun 2013 08:45:54 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E05364A14E; Fri, 28 Jun 2013 08:45:47 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A67764A14E for ; Fri, 28 Jun 2013 08:45:42 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vDC5RRll4-qi for ; Fri, 28 Jun 2013 08:45:30 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pa0-f47.google.com (mail-pa0-f47.google.com [209.85.220.47]) by theia.denx.de (Postfix) with ESMTPS id 8722F4A143 for ; Fri, 28 Jun 2013 08:45:18 +0200 (CEST) Received: by mail-pa0-f47.google.com with SMTP id kl14so2055143pab.6 for ; Thu, 27 Jun 2013 23:45:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:subject:from:to:cc:date:content-type:x-mailer :mime-version:content-transfer-encoding:x-gm-message-state; bh=zPOlKVmGNDaZ/ZquNvBYgHmTSt3exfFnKIeYVxIQWo4=; b=UYpRX6wNUOGvmG6LIgKq/bVymr//aYECDR5hhCNgtk2NF2QqGhfPEGIdBq9nITHrUy 25em65rl2OBaK63HrUP8xhGUMae3tAISLkxOy7ALHIQQ3v+0+84rS/XTl2gBI/eMNvIP g4T5SqFWq5M+IsLq+72yDBTIRGY6AxsSna63sC2z4gYOZPj6O4z432yL9dx4CZPxEvVB ONC1fZFftr5H7H7ebf6JnkYncWFuuZ6Dl6X3UnStBuRXZcoJT9Z46yQ1GwirQPl3mdQ/ zZI/zWWBsTkbXbMDzsGaiJI55vHiJFywsqVllrVLS41VmzWqwzt6v6vtX0Lo9fR8uQlk upqQ== X-Received: by 10.68.111.228 with SMTP id il4mr9795415pbb.134.1372401911996; Thu, 27 Jun 2013 23:45:11 -0700 (PDT) Received: from [192.168.0.100] (218-173-170-13.dynamic.hinet.net. [218.173.170.13]) by mx.google.com with ESMTPSA id tt7sm6668018pbc.34.2013.06.27.23.45.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 27 Jun 2013 23:45:11 -0700 (PDT) Message-ID: <1372401906.5103.4.camel@phoenix> From: Axel Lin To: Sonic Zhang Date: Fri, 28 Jun 2013 14:45:06 +0800 X-Mailer: Evolution 3.6.4-0ubuntu1 Mime-Version: 1.0 X-Gm-Message-State: ALoCoQmFCOlobmv6BHhaT/Wf60xpF/uyFN6QWhj7lz2lBY+nTMxnnj0zjn1nR1BOPeQHCl7GUB1B Cc: u-boot@lists.denx.de, Bob Liu Subject: [U-Boot] [PATCH] blackfin: gpio: Use proper mask for comparing function X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de The function return from P_FUNCT2MUX(per) takes 2 bits, however for BF537_FAMILY with offset != 1 the function is 1 bit. Also has small refactor for better readability. In portmux_setup(), it looks odd having "muxreg &= ~(3 << 1);" while in current code we do muxreg |= (function << offset);. Signed-off-by: Axel Lin Acked-by: Sonic Zhang --- arch/blackfin/cpu/gpio.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/blackfin/cpu/gpio.c b/arch/blackfin/cpu/gpio.c index f74a0b7..c4cddaf 100644 --- a/arch/blackfin/cpu/gpio.c +++ b/arch/blackfin/cpu/gpio.c @@ -247,7 +247,7 @@ static struct { static void portmux_setup(unsigned short per) { - u16 y, offset, muxreg; + u16 y, offset, muxreg, mask; u16 function = P_FUNCT2MUX(per); for (y = 0; y < ARRAY_SIZE(port_mux_lut); y++) { @@ -258,12 +258,13 @@ static void portmux_setup(unsigned short per) offset = port_mux_lut[y].offset; muxreg = bfin_read_PORT_MUX(); - if (offset != 1) - muxreg &= ~(1 << offset); + if (offset == 1) + mask = 3; else - muxreg &= ~(3 << 1); + mask = 1; - muxreg |= (function << offset); + muxreg &= ~(mask << offset); + muxreg |= ((function & mask) << offset); bfin_write_PORT_MUX(muxreg); } }