From patchwork Wed May 30 15:42:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Longchamp X-Patchwork-Id: 162012 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 E0719B702D for ; Thu, 31 May 2012 01:42:39 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C8A932808B; Wed, 30 May 2012 17:42:35 +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 0iwJWSOLMgAe; Wed, 30 May 2012 17:42:35 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 69F302807B; Wed, 30 May 2012 17:42:32 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7285828082 for ; Wed, 30 May 2012 17:42:27 +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 ESB4hma9TqYf for ; Wed, 30 May 2012 17:42:25 +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.ch.keymile.com (mail.ch.keymile.com [193.17.201.103]) by theia.denx.de (Postfix) with SMTP id 4904D2807B for ; Wed, 30 May 2012 17:42:21 +0200 (CEST) Received: from SRVCHBER1212.ch.keymile.net ([172.31.32.9]) by eSafe SMTP Relay 1334159602; Wed, 30 May 2012 17:42:19 +0200 Received: from chber1-10533x.ch.keymile.net ([172.31.40.3]) by SRVCHBER1212.ch.keymile.net with Microsoft SMTPSVC(6.0.3790.4675); Wed, 30 May 2012 17:42:19 +0200 From: Valentin Longchamp To: To: prafulla@marvell.com Date: Wed, 30 May 2012 17:42:03 +0200 Message-Id: <1338392526-5754-2-git-send-email-valentin.longchamp@keymile.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1338392526-5754-1-git-send-email-valentin.longchamp@keymile.com> References: <1338392526-5754-1-git-send-email-valentin.longchamp@keymile.com> X-OriginalArrivalTime: 30 May 2012 15:42:19.0298 (UTC) FILETIME=[CBFE3820:01CD3E7A] X-ESAFE-STATUS: [srvchber1306.keymile.net] Mail allowed Cc: Valentin Longchamp , holger.brunck@keymile.com, u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 1/4] kirkwood: add kirkwood_mpp_read 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: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This function can be used to save current mpp state of all mpp pins given in the mpp_list argument by reading the mpp registers, in the second mpp_saved argument. A later call to kirkwood_mpp_conf function with this saved list will reset the mpp configuration as it was when kirkwood_mpp_read was called. Signed-off-by: Valentin Longchamp cc: Holger Brunck cc: Prafulla Wadaskar --- arch/arm/cpu/arm926ejs/kirkwood/mpp.c | 41 ++++++++++++++++++++++++++++++ arch/arm/include/asm/arch-kirkwood/mpp.h | 1 + 2 files changed, 42 insertions(+), 0 deletions(-) diff --git a/arch/arm/cpu/arm926ejs/kirkwood/mpp.c b/arch/arm/cpu/arm926ejs/kirkwood/mpp.c index 3da6c98..9fb9aea 100644 --- a/arch/arm/cpu/arm926ejs/kirkwood/mpp.c +++ b/arch/arm/cpu/arm926ejs/kirkwood/mpp.c @@ -80,3 +80,44 @@ void kirkwood_mpp_conf(u32 *mpp_list) debug("\n"); } + +void kirkwood_mpp_read(u32 *mpp_list, u32 *mpp_saved) +{ + u32 mpp_ctrl[MPP_NR_REGS]; + unsigned int variant_mask; + int i; + + variant_mask = kirkwood_variant(); + if (!variant_mask) + return; + + for (i = 0; i < MPP_NR_REGS; i++) { + mpp_ctrl[i] = readl(MPP_CTRL(i)); + debug(" %08x", mpp_ctrl[i]); + } + + while (*mpp_list) { + unsigned int num = MPP_NUM(*mpp_list); + unsigned int sel; + int shift; + + if (num > MPP_MAX) { + debug("kirkwood_mpp_conf: invalid MPP " + "number (%u)\n", num); + continue; + } + if (!(*mpp_list & variant_mask)) { + debug("kirkwood_mpp_conf: requested MPP%u config " + "unavailable on this hardware\n", num); + continue; + } + + shift = (num & 7) << 2; + sel = (mpp_ctrl[num / 8] >> shift) & 0xf; + *mpp_saved = num | (sel << 8) | variant_mask; + + mpp_list++; + mpp_saved++; + } +} + diff --git a/arch/arm/include/asm/arch-kirkwood/mpp.h b/arch/arm/include/asm/arch-kirkwood/mpp.h index b3c090e..22a64b8 100644 --- a/arch/arm/include/asm/arch-kirkwood/mpp.h +++ b/arch/arm/include/asm/arch-kirkwood/mpp.h @@ -313,5 +313,6 @@ #define MPP_MAX 49 void kirkwood_mpp_conf(unsigned int *mpp_list); +void kirkwood_mpp_read(u32 *mpp_list, u32 *mpp_saved); #endif